summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore21
-rw-r--r--CMakeLists.txt8
-rw-r--r--client/client_priv.h2
-rw-r--r--client/mysql.cc9
-rw-r--r--client/mysqladmin.cc9
-rw-r--r--client/mysqlbinlog.cc33
-rw-r--r--client/mysqlcheck.c9
-rw-r--r--client/mysqldump.c35
-rw-r--r--client/mysqlimport.c9
-rw-r--r--client/mysqlshow.c9
-rw-r--r--client/mysqlslap.c11
-rw-r--r--client/mysqltest.c12
-rw-r--r--config/ac-macros/misc.m424
-rw-r--r--config/ac-macros/zlib.m415
-rw-r--r--configure.in2
-rw-r--r--include/errmsg.h3
-rw-r--r--include/my_time.h3
-rw-r--r--include/typelib.h5
-rw-r--r--libmysql/client_settings.h2
-rw-r--r--libmysql/errmsg.c3
-rw-r--r--libmysql/libmysql.c4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_max_relay_size.test3
-rw-r--r--mysql-test/extra/rpl_tests/rpl_relayrotate.test4
-rw-r--r--mysql-test/include/federated.inc5
-rw-r--r--mysql-test/include/federated_cleanup.inc2
-rw-r--r--mysql-test/include/not_embedded.inc2
-rw-r--r--mysql-test/lib/mtr_cases.pl4
-rwxr-xr-xmysql-test/mysql-test-run.pl14
-rw-r--r--mysql-test/r/binlog_statement_insert_delayed.result12
-rw-r--r--mysql-test/r/date_formats.result18
-rw-r--r--mysql-test/r/distinct.result14
-rw-r--r--mysql-test/r/func_sapdb.result6
-rw-r--r--mysql-test/r/func_time.result10
-rw-r--r--mysql-test/r/grant.result123
-rw-r--r--mysql-test/r/information_schema_db.result71
-rw-r--r--mysql-test/r/mysql_protocols.result1
-rw-r--r--mysql-test/r/mysqlbinlog2.result34
-rw-r--r--mysql-test/r/ndb_dd_basic.result7
-rw-r--r--mysql-test/r/ndb_restore.result31
-rw-r--r--mysql-test/r/ps_2myisam.result7
-rw-r--r--mysql-test/r/ps_3innodb.result7
-rw-r--r--mysql-test/r/ps_4heap.result7
-rw-r--r--mysql-test/r/ps_5merge.result14
-rw-r--r--mysql-test/r/ps_7ndb.result7
-rw-r--r--mysql-test/r/row.result18
-rw-r--r--mysql-test/r/rpl_log_pos.result2
-rw-r--r--mysql-test/r/rpl_ndb_basic.result27
-rw-r--r--mysql-test/r/select.result9
-rw-r--r--mysql-test/r/sp-security.result35
-rw-r--r--mysql-test/r/sp.result40
-rw-r--r--mysql-test/r/sp_trans_log.result27
-rw-r--r--mysql-test/r/strict.result7
-rw-r--r--mysql-test/r/subselect.result71
-rw-r--r--mysql-test/r/subselect3.result4
-rw-r--r--mysql-test/r/truncate.result27
-rw-r--r--mysql-test/r/type_date.result26
-rw-r--r--mysql-test/r/type_datetime.result35
-rw-r--r--mysql-test/r/view.result10
-rw-r--r--mysql-test/r/view_grant.result97
-rw-r--r--mysql-test/suite/funcs_1/r/a_version_check.result2
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs.inc93
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_delete.inc53
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in4
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_date.in4
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_float.in4
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_int.in45
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_time.in4
-rw-r--r--mysql-test/suite/partitions/include/partition_supported_sql_funcs_main.inc39
-rw-r--r--mysql-test/suite/partitions/r/partition_supported_sql_func_innodb.result10887
-rw-r--r--mysql-test/suite/partitions/r/partition_supported_sql_func_myisam.result10887
-rw-r--r--mysql-test/suite/partitions/r/partition_supported_sql_func_ndb.result13724
-rw-r--r--mysql-test/suite/partitions/r/partition_t55.out68
-rw-r--r--mysql-test/suite/partitions/t/disabled.def2
-rw-r--r--mysql-test/suite/partitions/t/partition_supported_sql_func_innodb.test10
-rw-r--r--mysql-test/suite/partitions/t/partition_supported_sql_func_myisam.test6
-rw-r--r--mysql-test/suite/partitions/t/partition_supported_sql_func_ndb.test40
-rw-r--r--mysql-test/suite/row_lock/include/row_lock.inc83
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_big_tab.inc94
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc93
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc93
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_trig.inc96
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_view.inc89
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_view_mix.inc92
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_view_storedp.inc126
-rw-r--r--mysql-test/suite/row_lock/include/row_lock_view_trig.inc99
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_1.result142
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_2.result32
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_3.result32
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_4.result142
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_5.result32
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result97
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result145
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result113
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result151
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result37
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result34
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result40
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result48
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result40
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result312
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result47
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result183
-rw-r--r--mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result38
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_1.result139
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_2.result31
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_3.result30
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_4.result139
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_5.result30
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result177
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result357
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result255
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result148
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result35
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result194
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result200
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result169
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result38
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result309
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result46
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result180
-rw-r--r--mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result36
-rw-r--r--mysql-test/suite/row_lock/readme.txt9
-rw-r--r--mysql-test/suite/row_lock/summary_of_sel_test.txt36
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_1.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_2.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_3.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_4.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_5.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test10
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test10
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test10
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test9
-rw-r--r--mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test9
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_1.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_2.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_3.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_4.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_5.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test7
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test7
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test7
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test6
-rw-r--r--mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test6
-rw-r--r--mysql-test/t/date_formats.test2
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--mysql-test/t/distinct.test13
-rw-r--r--mysql-test/t/federated_server.test5
-rw-r--r--mysql-test/t/func_sapdb.test2
-rw-r--r--mysql-test/t/grant.test229
-rw-r--r--mysql-test/t/information_schema_db.test55
-rw-r--r--mysql-test/t/myisam-system.test6
-rw-r--r--mysql-test/t/mysqlbinlog2.test8
-rw-r--r--mysql-test/t/ndb_autodiscover.test32
-rw-r--r--mysql-test/t/ndb_dd_basic.test8
-rw-r--r--mysql-test/t/ndb_loaddatalocal.test8
-rw-r--r--mysql-test/t/ndb_restore.test40
-rw-r--r--mysql-test/t/row.test25
-rw-r--r--mysql-test/t/rpl_flushlog_loop.test3
-rw-r--r--mysql-test/t/rpl_loaddatalocal.test4
-rw-r--r--mysql-test/t/rpl_log_pos.test2
-rw-r--r--mysql-test/t/rpl_misc_functions.test4
-rw-r--r--mysql-test/t/rpl_ndb_basic.test31
-rw-r--r--mysql-test/t/rpl_rbr_to_sbr.test4
-rw-r--r--mysql-test/t/rpl_row_NOW.test4
-rw-r--r--mysql-test/t/rpl_row_sp001.test4
-rw-r--r--mysql-test/t/rpl_row_sp011.test4
-rw-r--r--mysql-test/t/select.test13
-rw-r--r--mysql-test/t/show_check.test3
-rw-r--r--mysql-test/t/sp-security.test77
-rw-r--r--mysql-test/t/sp.test64
-rw-r--r--mysql-test/t/sp_trans_log.test43
-rw-r--r--mysql-test/t/strict.test9
-rw-r--r--mysql-test/t/subselect.test37
-rw-r--r--mysql-test/t/subselect3.test3
-rw-r--r--mysql-test/t/truncate.test32
-rw-r--r--mysql-test/t/type_date.test13
-rw-r--r--mysql-test/t/type_datetime.test22
-rw-r--r--mysql-test/t/view.test2
-rw-r--r--mysql-test/t/view_grant.test110
-rw-r--r--mysys/my_alloc.c2
-rw-r--r--mysys/my_handler.c1
-rw-r--r--mysys/my_lib.c4
-rw-r--r--mysys/my_seek.c2
-rw-r--r--mysys/thr_alarm.c5
-rw-r--r--mysys/typelib.c22
-rw-r--r--scripts/make_binary_distribution.sh51
-rwxr-xr-xscripts/make_win_bin_dist35
-rw-r--r--server-tools/instance-manager/log.cc8
-rw-r--r--server-tools/instance-manager/thread_registry.cc7
-rw-r--r--sql-common/client.c14
-rw-r--r--sql-common/my_time.c62
-rw-r--r--sql/CMakeLists.txt2
-rw-r--r--sql/event_data_objects.cc20
-rw-r--r--sql/event_db_repository.cc8
-rw-r--r--sql/event_queue.cc2
-rw-r--r--sql/field.cc121
-rw-r--r--sql/field.h30
-rw-r--r--sql/ha_ndbcluster.cc127
-rw-r--r--sql/ha_ndbcluster.h4
-rw-r--r--sql/ha_ndbcluster_binlog.cc22
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/item.cc156
-rw-r--r--sql/item.h70
-rw-r--r--sql/item_cmpfunc.cc92
-rw-r--r--sql/item_func.h8
-rw-r--r--sql/item_timefunc.cc217
-rw-r--r--sql/item_timefunc.h48
-rw-r--r--sql/log.cc8
-rw-r--r--sql/my_decimal.cc2
-rw-r--r--sql/my_decimal.h2
-rw-r--r--sql/mysql_priv.h41
-rw-r--r--sql/mysqld.cc131
-rw-r--r--sql/net_serv.cc9
-rw-r--r--sql/protocol.cc12
-rw-r--r--sql/protocol.h18
-rw-r--r--sql/set_var.cc9
-rw-r--r--sql/slave.cc6
-rw-r--r--sql/sp.cc8
-rw-r--r--sql/sp_head.cc8
-rw-r--r--sql/sql_acl.cc31
-rw-r--r--sql/sql_base.cc29
-rw-r--r--sql/sql_cache.cc6
-rw-r--r--sql/sql_class.cc10
-rw-r--r--sql/sql_class.h10
-rw-r--r--sql/sql_connect.cc5
-rw-r--r--sql/sql_db.cc339
-rw-r--r--sql/sql_delete.cc13
-rw-r--r--sql/sql_error.cc12
-rw-r--r--sql/sql_insert.cc18
-rw-r--r--sql/sql_lex.cc1
-rw-r--r--sql/sql_load.cc16
-rw-r--r--sql/sql_parse.cc204
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc97
-rw-r--r--sql/sql_show.cc32
-rw-r--r--sql/sql_table.cc29
-rw-r--r--sql/sql_union.cc1
-rw-r--r--sql/sql_update.cc56
-rw-r--r--sql/sql_view.cc42
-rw-r--r--sql/structs.h3
-rw-r--r--sql/table.cc5
-rw-r--r--sql/time.cc48
-rw-r--r--sql/tztime.cc92
-rw-r--r--sql/tztime.h12
-rw-r--r--sql/unireg.cc4
-rw-r--r--storage/ndb/include/kernel/AttributeHeader.hpp1
-rw-r--r--storage/ndb/include/kernel/signaldata/SumaImpl.hpp3
-rw-r--r--storage/ndb/include/ndbapi/Ndb.hpp20
-rw-r--r--storage/ndb/include/ndbapi/NdbDictionary.hpp45
-rw-r--r--storage/ndb/include/ndbapi/NdbRecAttr.hpp14
-rw-r--r--storage/ndb/include/ndbapi/NdbReceiver.hpp4
-rw-r--r--storage/ndb/include/ndbapi/NdbTransaction.hpp2
-rw-r--r--storage/ndb/include/util/BaseString.hpp7
-rw-r--r--storage/ndb/include/util/Vector.hpp67
-rw-r--r--storage/ndb/src/common/util/BaseString.cpp145
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp3
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp4
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp8
-rw-r--r--storage/ndb/src/kernel/blocks/suma/Suma.cpp10
-rw-r--r--storage/ndb/src/ndbapi/DictCache.cpp13
-rw-r--r--storage/ndb/src/ndbapi/DictCache.hpp2
-rw-r--r--storage/ndb/src/ndbapi/Makefile.am3
-rw-r--r--storage/ndb/src/ndbapi/Ndb.cpp46
-rw-r--r--storage/ndb/src/ndbapi/NdbDictionary.cpp120
-rw-r--r--storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp390
-rw-r--r--storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp41
-rw-r--r--storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp20
-rw-r--r--storage/ndb/src/ndbapi/NdbImpl.hpp34
-rw-r--r--storage/ndb/src/ndbapi/NdbOperation.cpp6
-rw-r--r--storage/ndb/src/ndbapi/NdbRecAttr.cpp25
-rw-r--r--storage/ndb/src/ndbapi/NdbReceiver.cpp31
-rw-r--r--storage/ndb/src/ndbapi/NdbScanFilter.cpp12
-rw-r--r--storage/ndb/src/ndbapi/NdbScanOperation.cpp9
-rw-r--r--storage/ndb/src/ndbapi/NdbTransaction.cpp14
-rw-r--r--storage/ndb/src/ndbapi/Ndbif.cpp3
-rw-r--r--storage/ndb/src/ndbapi/Ndblist.cpp10
-rw-r--r--storage/ndb/src/ndbapi/ObjectMap.cpp62
-rw-r--r--storage/ndb/src/ndbapi/ObjectMap.hpp52
-rw-r--r--storage/ndb/src/ndbapi/SignalSender.cpp10
-rw-r--r--storage/ndb/src/ndbapi/ndb_cluster_connection.cpp20
-rw-r--r--storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp2
-rw-r--r--storage/ndb/src/ndbapi/ndberror.c1
-rw-r--r--storage/ndb/test/include/HugoOperations.hpp2
-rw-r--r--storage/ndb/test/ndbapi/testBasic.cpp62
-rw-r--r--storage/ndb/test/run-test/daily-basic-tests.txt4
-rw-r--r--storage/ndb/test/src/HugoAsynchTransactions.cpp58
-rw-r--r--storage/ndb/test/src/HugoOperations.cpp93
-rw-r--r--storage/ndb/test/src/HugoTransactions.cpp82
-rw-r--r--storage/ndb/test/tools/Makefile.am3
-rw-r--r--storage/ndb/test/tools/log_listner.cpp88
-rw-r--r--storage/ndb/tools/restore/Restore.hpp3
-rw-r--r--storage/ndb/tools/restore/consumer_restore.cpp60
-rw-r--r--storage/ndb/tools/restore/restore_main.cpp4
-rw-r--r--support-files/mysql.spec.sh16
-rw-r--r--tests/mysql_client_test.c154
-rw-r--r--win/README2
-rw-r--r--zlib/Makefile.am16
313 files changed, 44051 insertions, 3592 deletions
diff --git a/.bzrignore b/.bzrignore
index 00a11761207..45cd1bdf674 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -354,6 +354,8 @@ client/decimal.c
client/insert_test
client/log_event.cc
client/log_event.h
+client/log_event_old.cc
+client/log_event_old.h
client/mf_iocache.c
client/mf_iocache.cc
client/my_decimal.cc
@@ -379,6 +381,9 @@ client/mysqltestmanager-pwgen
client/mysqltestmanagerc
client/mysys_priv.h
client/readline.cpp
+client/rpl_constants.h
+client/rpl_record_old.cc
+client/rpl_record_old.h
client/select_test
client/sql_string.cpp
client/ssl_test
@@ -1087,6 +1092,7 @@ libmysqld/libmysql.c
libmysqld/lock.cc
libmysqld/log.cc
libmysqld/log_event.cc
+libmysqld/log_event_old.cc
libmysqld/md5.c
libmysqld/mf_iocache.cc
libmysqld/mini_client.cc
@@ -1109,6 +1115,8 @@ libmysqld/records.cc
libmysqld/repl_failsafe.cc
libmysqld/rpl_filter.cc
libmysqld/rpl_injector.cc
+libmysqld/rpl_record.cc
+libmysqld/rpl_record_old.cc
libmysqld/set_var.cc
libmysqld/simple-test
libmysqld/slave.cc
@@ -1347,10 +1355,15 @@ mysql-test/suite/funcs_1/r/myisam_trig_03e.warnings
mysql-test/suite/funcs_1/r/myisam_views.warnings
mysql-test/suite/funcs_1/r/ndb_trig_03e.warnings
mysql-test/suite/funcs_1/r/ndb_views.warnings
+mysql-test/suite/partitions/r/dif
mysql-test/suite/partitions/r/diff
+mysql-test/suite/partitions/r/partition.result
mysql-test/suite/partitions/r/partition_bit_ndb.warnings
mysql-test/suite/partitions/r/partition_special_innodb.warnings
mysql-test/suite/partitions/r/partition_special_myisam.warnings
+mysql-test/suite/partitions/r/partition_t55.out
+mysql-test/suite/partitions/r/partition_t55.refout
+mysql-test/suite/partitions/t/partition.test
mysql-test/t/index_merge.load
mysql-test/t/tmp.test
mysql-test/var
@@ -2956,11 +2969,3 @@ win/vs71cache.txt
win/vs8cache.txt
zlib/*.ds?
zlib/*.vcproj
-client/rpl_constants.h
-client/log_event_old.cc
-client/log_event_old.h
-client/rpl_record_old.cc
-client/rpl_record_old.h
-libmysqld/log_event_old.cc
-libmysqld/rpl_record.cc
-libmysqld/rpl_record_old.cc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48992cf574b..09915c65e6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,6 +114,14 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG})
+ STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+ STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO
+ ${CMAKE_C_FLAGS_RELWITHDEBINFO})
+
+ # generate .map files
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS")
+
# remove support for Exception handling
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
diff --git a/client/client_priv.h b/client/client_priv.h
index 9a678eb7d2a..ddc0e50b723 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -67,5 +67,5 @@ enum options_client
OPT_SLAP_POST_QUERY,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
- OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_WRITE_BINLOG
+ OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG
};
diff --git a/client/mysql.cc b/client/mysql.cc
index e54732d8ac6..95b05f7f309 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -885,14 +885,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_nopager= 1;
break;
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
break;
- }
break;
case 'A':
opt_rehash= 0;
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index cb704d716cc..03b37f2ba3a 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -287,15 +287,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
break;
}
- }
if (error)
{
usage();
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 254126dbb79..033c55707fc 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -944,14 +944,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
remote_opt= 1;
break;
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
break;
- }
case OPT_START_DATETIME:
start_datetime= convert_str_to_timestamp(start_datetime_str);
break;
@@ -1167,7 +1162,7 @@ could be out of memory");
}
if (len < 8 && net->read_pos[0] == 254)
break; // end of data
- DBUG_PRINT("info",( "len: %lu, net->read_pos[5]: %d\n",
+ DBUG_PRINT("info",( "len: %lu net->read_pos[5]: %d\n",
len, net->read_pos[5]));
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error_msg,
@@ -1222,6 +1217,18 @@ could be out of memory");
len= 1; // fake Rotate, so don't increment old_off
}
}
+ else if (type == FORMAT_DESCRIPTION_EVENT)
+ {
+ /*
+ This could be an fake Format_description_log_event that server
+ (5.0+) automatically sends to a slave on connect, before sending
+ a first event at the requested position. If this is the case,
+ don't increment old_off. Real Format_description_log_event always
+ starts from BIN_LOG_HEADER_SIZE position.
+ */
+ if (old_off != BIN_LOG_HEADER_SIZE)
+ len= 1; // fake event, don't increment old_off
+ }
if ((error= process_event(print_event_info, ev, old_off)))
{
error= ((error < 0) ? 0 : 1);
@@ -1234,16 +1241,16 @@ could be out of memory");
const char *old_fname= le->fname;
uint old_len= le->fname_len;
File file;
-
+
if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0)
{
error= 1;
goto err;
}
-
+
if ((error= process_event(print_event_info, ev, old_off)))
{
- my_close(file,MYF(MY_WME));
+ my_close(file,MYF(MY_WME));
error= ((error < 0) ? 0 : 1);
goto err;
}
@@ -1256,8 +1263,8 @@ could be out of memory");
}
}
/*
- Let's adjust offset for remote log as for local log to produce
- similar text.
+ Let's adjust offset for remote log as for local log to produce
+ similar text and to have --stop-position to work identically.
*/
old_off+= len-1;
}
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 2f5d435d0a5..43a938badbe 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -315,15 +315,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case 'V': print_version(); exit(0);
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
break;
}
- }
return 0;
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 99415a5a593..1506fb0bf19 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -109,7 +109,8 @@ static char *opt_password=0,*current_user=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
*where=0, *order_by=0,
*opt_compatible_mode_str= 0,
- *err_ptr= 0;
+ *err_ptr= 0,
+ *log_error_file= NULL;
static char **defaults_argv= 0;
static char compatible_mode_normal_str[255];
static ulong opt_compatible_mode= 0;
@@ -120,7 +121,9 @@ static my_string opt_mysql_unix_port=0;
static int first_error=0;
static DYNAMIC_STRING extended_row;
#include <sslopt-vars.h>
-FILE *md_result_file= 0;
+FILE *md_result_file= 0;
+FILE *stderror_file=0;
+
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
#endif
@@ -320,6 +323,9 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0},
{"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables,
(gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+ {"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.",
+ (gptr*) &log_error_file, (gptr*) &log_error_file, 0, GET_STR,
+ REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"master-data", OPT_MASTER_DATA,
"This causes the binary log position and filename to be appended to the "
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
@@ -801,14 +807,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
}
case (int) OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
- break;
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
+ break;
}
return 0;
}
@@ -4210,6 +4211,16 @@ int main(int argc, char **argv)
free_resources(0);
exit(exit_code);
}
+
+ if (log_error_file)
+ {
+ if(!(stderror_file= freopen(log_error_file, "a+", stderr)))
+ {
+ free_resources(0);
+ exit(EX_MYSQLERR);
+ }
+ }
+
if (connect_to_db(current_host, current_user, opt_password))
{
free_resources(0);
@@ -4273,5 +4284,9 @@ err:
if (!path)
write_footer(md_result_file);
free_resources();
+
+ if (stderror_file)
+ fclose(stderror_file);
+
return(first_error);
} /* main */
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 3e054fba308..c037da9c0b9 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -231,14 +231,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
#endif
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
break;
- }
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
break;
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 1c714cc640f..0c6a6229964 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -287,14 +287,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
break;
- }
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
break;
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index ef11f4bab5b..0335922881a 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -689,14 +689,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
- {
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
- }
- break;
- }
+ opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
+ opt->name);
+ break;
case '#':
DBUG_PUSH(argument ? argument : default_dbug_option);
break;
diff --git a/client/mysqltest.c b/client/mysqltest.c
index e8b151a093f..12047856b82 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2498,17 +2498,20 @@ wait_for_position:
if (!(res= mysql_store_result(mysql)))
die("mysql_store_result() returned NULL for '%s'", query_buf);
if (!(row= mysql_fetch_row(res)))
+ {
+ mysql_free_result(res);
die("empty result in %s", query_buf);
+ }
if (!row[0])
{
/*
It may be that the slave SQL thread has not started yet, though START
SLAVE has been issued ?
*/
+ mysql_free_result(res);
if (tries++ == 30)
die("could not sync with master ('%s' returned NULL)", query_buf);
sleep(1); /* So at most we will wait 30 seconds and make 31 tries */
- mysql_free_result(res);
goto wait_for_position;
}
mysql_free_result(res);
@@ -2549,6 +2552,7 @@ int do_save_master_pos()
MYSQL *mysql = &cur_con->mysql;
const char *query;
int rpl_parse;
+ DBUG_ENTER("do_save_master_pos");
rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql);
@@ -2706,7 +2710,7 @@ int do_save_master_pos()
if (rpl_parse)
mysql_enable_rpl_parse(mysql);
- return 0;
+ DBUG_RETURN(0);
}
@@ -3161,7 +3165,7 @@ struct st_connection * find_connection_by_name(const char *name)
int select_connection_name(const char *name)
{
- DBUG_ENTER("select_connection2");
+ DBUG_ENTER("select_connection_name");
DBUG_PRINT("enter",("name: '%s'", name));
if (!(cur_con= find_connection_by_name(name)))
@@ -3184,7 +3188,7 @@ int select_connection(struct st_command *command)
if (*p)
*p++= 0;
command->last_argument= p;
- return select_connection_name(name);
+ DBUG_RETURN(select_connection_name(name));
}
diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4
index fdce85aa136..6e9dfe8231c 100644
--- a/config/ac-macros/misc.m4
+++ b/config/ac-macros/misc.m4
@@ -663,3 +663,27 @@ esac
AC_SUBST(AR)
AC_SUBST(ARFLAGS)
])
+
+dnl
+dnl Macro to check time_t range: according to C standard
+dnl array index must be greater than 0 => if time_t is signed,
+dnl the code in the macros below won't compile.
+dnl
+
+AC_DEFUN([MYSQL_CHECK_TIME_T],[
+ AC_MSG_CHECKING(if time_t is unsigned)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[
+#include <time.h>
+ ]],
+ [[
+ int array[(((time_t)-1) > 0) ? 1 : -1];
+ ]] )
+ ], [
+ AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
+ AC_MSG_RESULT(yes)
+ ],
+ [AC_MSG_RESULT(no)]
+ )
+])
+
diff --git a/config/ac-macros/zlib.m4 b/config/ac-macros/zlib.m4
index 17b951d4723..5586b1ba816 100644
--- a/config/ac-macros/zlib.m4
+++ b/config/ac-macros/zlib.m4
@@ -2,7 +2,7 @@ dnl Define zlib paths to point at bundled zlib
AC_DEFUN([MYSQL_USE_BUNDLED_ZLIB], [
ZLIB_INCLUDES="-I\$(top_srcdir)/zlib"
-ZLIB_LIBS="\$(top_builddir)/zlib/libz.la"
+ZLIB_LIBS="\$(top_builddir)/zlib/libzlt.la"
dnl Omit -L$pkglibdir as it's always in the list of mysql_config deps.
ZLIB_DEPS="-lz"
zlib_dir="zlib"
@@ -10,16 +10,25 @@ AC_SUBST([zlib_dir])
mysql_cv_compress="yes"
])
-dnl Auxiliary macro to check for zlib at given path
+dnl Auxiliary macro to check for zlib at given path.
+dnl We are strict with the server, as "archive" engine
+dnl needs zlibCompileFlags(), but for client only we
+dnl are less strict, and take the zlib we find.
AC_DEFUN([MYSQL_CHECK_ZLIB_DIR], [
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
CPPFLAGS="$ZLIB_INCLUDES $CPPFLAGS"
LIBS="$LIBS $ZLIB_LIBS"
+if test X"$with_server" = Xno
+then
+ zlibsym=zlibVersion
+else
+ zlibsym=zlibCompileFlags
+fi
AC_CACHE_VAL([mysql_cv_compress],
[AC_TRY_LINK([#include <zlib.h>],
- [return zlibCompileFlags();],
+ [return $zlibsym();],
[mysql_cv_compress="yes"
AC_MSG_RESULT([ok])],
[mysql_cv_compress="no"])
diff --git a/configure.in b/configure.in
index 89a6b97e0c7..51c4ba19ee0 100644
--- a/configure.in
+++ b/configure.in
@@ -24,7 +24,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0
# Remember that regexps needs to quote [ and ] since this is run through m4
MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"`
MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"`
-MYSQL_VERSION_ID=`echo $MYSQL_NO_DASH_VERSION. | sed -e 's/[[^0-9.]]//g; s/\./ /g; s/ \([[0-9]]\) / 0\\1 /g; s/ //g'`
+MYSQL_VERSION_ID=`echo $MYSQL_NO_DASH_VERSION | sed -e 's|[[^0-9.]].*$||;s|$|.|' | sed -e 's/[[^0-9.]]//g; s/\./ /g; s/ \([[0-9]]\) / 0\\1 /g; s/ //g'`
# The port should be constant for a LONG time
MYSQL_TCP_PORT_DEFAULT=3306
diff --git a/include/errmsg.h b/include/errmsg.h
index e4d20b061a5..e7b59ca8bd7 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -95,6 +95,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NO_RESULT_SET 2053
#define CR_NOT_IMPLEMENTED 2054
#define CR_SERVER_LOST_EXTENDED 2055
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2055
+#define CR_STMT_CLOSED 2056
+#define CR_ERROR_LAST /*Copy last error nr:*/ 2056
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
diff --git a/include/my_time.h b/include/my_time.h
index 6aa25487cf1..e3bdb58e5c2 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -51,8 +51,6 @@ typedef long my_time_t;
/* two-digit years < this are 20..; >= this are 19.. */
#define YY_PART_YEAR 70
-/* apply above magic to years < this */
-#define YY_MAGIC_BELOW 200
/* Flags to str_to_datetime */
#define TIME_FUZZY_DATE 1
@@ -95,6 +93,7 @@ int check_time_range(struct st_mysql_time *, int *warning);
long calc_daynr(uint year,uint month,uint day);
uint calc_days_in_year(uint year);
+uint year_2000_handling(uint year);
void init_time(void);
diff --git a/include/typelib.h b/include/typelib.h
index e04ec20f2bc..aa51864749f 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -26,8 +26,9 @@ typedef struct st_typelib { /* Different types saved here */
unsigned int *type_lengths;
} TYPELIB;
-extern int find_type(char *x, const TYPELIB *typelib,
- unsigned int full_name);
+extern int find_type_or_exit(const char *x, TYPELIB *typelib,
+ const char *option);
+extern int find_type(char *x, const TYPELIB *typelib, unsigned int full_name);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h
index b67fbbc03af..4bc4bda5b63 100644
--- a/libmysql/client_settings.h
+++ b/libmysql/client_settings.h
@@ -41,7 +41,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename);
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group);
-void mysql_detach_stmt_list(LIST **stmt_list);
+void mysql_detach_stmt_list(LIST **stmt_list, const char *func_name);
MYSQL *
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index 59089d5ec18..e7f495d1f43 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -83,6 +83,7 @@ const char *client_errors[]=
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
"Lost connection to MySQL server at '%s', system error: %d",
+ "Statement closed indirectly because of a preceeding %s() call",
""
};
@@ -147,6 +148,7 @@ const char *client_errors[]=
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
"Lost connection to MySQL server at '%s', system error: %d",
+ "Statement closed indirectly because of a preceeding %s() call",
""
};
@@ -209,6 +211,7 @@ const char *client_errors[]=
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
"Lost connection to MySQL server at '%s', system error: %d",
+ "Statement closed indirectly because of a preceeding %s() call",
""
};
#endif
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 181904edc1a..374676ebe32 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -715,7 +715,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
The server will close all statements no matter was the attempt
to change user successful or not.
*/
- mysql_detach_stmt_list(&mysql->stmts);
+ mysql_detach_stmt_list(&mysql->stmts, "mysql_change_user");
if (rc == 0)
{
/* Free old connect information */
@@ -2872,7 +2872,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
if (!mysql)
{
- set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate);
+ /* Error is already set in mysql_detatch_stmt_list */
DBUG_RETURN(1);
}
diff --git a/mysql-test/extra/rpl_tests/rpl_max_relay_size.test b/mysql-test/extra/rpl_tests/rpl_max_relay_size.test
index 5b995374ba0..d05fefe916b 100644
--- a/mysql-test/extra/rpl_tests/rpl_max_relay_size.test
+++ b/mysql-test/extra/rpl_tests/rpl_max_relay_size.test
@@ -6,6 +6,9 @@
# Requires statement logging
-- source include/master-slave.inc
+# We have to sync with master, to ensure slave had time to start properly
+# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
+sync_slave_with_master;
connection slave;
stop slave;
connection master;
diff --git a/mysql-test/extra/rpl_tests/rpl_relayrotate.test b/mysql-test/extra/rpl_tests/rpl_relayrotate.test
index dc91f9e7fff..0d2f25e2b4a 100644
--- a/mysql-test/extra/rpl_tests/rpl_relayrotate.test
+++ b/mysql-test/extra/rpl_tests/rpl_relayrotate.test
@@ -10,6 +10,10 @@
-- source include/master-slave.inc
+# We have to sync with master, to ensure slave had time to start properly
+# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
+connection master;
+sync_slave_with_master;
connection slave;
stop slave;
connection master;
diff --git a/mysql-test/include/federated.inc b/mysql-test/include/federated.inc
index c8e8ededa11..dde24cd8198 100644
--- a/mysql-test/include/federated.inc
+++ b/mysql-test/include/federated.inc
@@ -5,6 +5,11 @@ source ./include/master-slave.inc;
# remote table creation
+# We have to sync with master, to ensure slave had time to start properly
+# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
+connection master;
+sync_slave_with_master;
+
connection slave;
#--replicate-ignore-db=federated
stop slave;
diff --git a/mysql-test/include/federated_cleanup.inc b/mysql-test/include/federated_cleanup.inc
index 17a6e1e5100..06fd7f6737a 100644
--- a/mysql-test/include/federated_cleanup.inc
+++ b/mysql-test/include/federated_cleanup.inc
@@ -2,10 +2,8 @@ connection master;
--disable_warnings
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
---enable_warnings
connection slave;
---disable_warnings
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
--enable_warnings
diff --git a/mysql-test/include/not_embedded.inc b/mysql-test/include/not_embedded.inc
index fcc1756caab..360f268ad4f 100644
--- a/mysql-test/include/not_embedded.inc
+++ b/mysql-test/include/not_embedded.inc
@@ -1,5 +1,5 @@
-- require r/not_embedded.require
disable_query_log;
-select version() like N'%embedded%' as 'have_embedded';
+select version() like '%embedded%' as 'have_embedded';
enable_query_log;
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index 28c78fbffeb..2c563f23e5a 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -534,7 +534,7 @@ sub collect_one_test_case($$$$$$$) {
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
{
$tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "Not running with binlog format '$tinfo->{'binlog_format'}'";
+ $tinfo->{'comment'}= "Requiring binlog format '$tinfo->{'binlog_format'}'";
return;
}
@@ -599,7 +599,7 @@ our @tags=
(
["include/have_innodb.inc", "innodb_test", 1],
["include/have_binlog_format_row.inc", "binlog_format", "row"],
- ["include/have_binlog_format_statement.inc", "binlog_format", "stmt"],
+ ["include/have_binlog_format_statement.inc", "binlog_format", "statement"],
["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"],
["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1],
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 46938ea7cde..7f775bd0942 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -3278,9 +3278,9 @@ sub do_after_run_mysqltest($)
}
-sub run_testcase_mark_logs($)
+sub run_testcase_mark_logs($$)
{
- my ($log_msg)= @_;
+ my ($tinfo, $log_msg)= @_;
# Write a marker to all log files
@@ -3293,6 +3293,12 @@ sub run_testcase_mark_logs($)
mtr_tofile($mysqld->{path_myerr}, $log_msg);
}
+ if ( $tinfo->{'component_id'} eq 'im')
+ {
+ mtr_tofile($instance_manager->{path_err}, $log_msg);
+ mtr_tofile($instance_manager->{path_log}, $log_msg);
+ }
+
# ndbcluster log file
mtr_tofile($path_ndb_testrun_log, $log_msg);
@@ -3419,7 +3425,7 @@ sub run_testcase ($) {
}
# Write to all log files to indicate start of testcase
- run_testcase_mark_logs("CURRENT_TEST: $tinfo->{name}\n");
+ run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
my $died= mtr_record_dead_children();
if ($died or $master_restart or $slave_restart)
@@ -3493,7 +3499,7 @@ sub run_testcase ($) {
# Stop Instance Manager if we are processing an IM-test case.
# ----------------------------------------------------------------------
if ( $tinfo->{'component_id'} eq 'im' and
- !mtr_im_stop($instance_manager, $tinfo->{'name'}) )
+ !mtr_im_stop($instance_manager, $tinfo->{'name'}))
{
mtr_error("Failed to stop Instance Manager.")
}
diff --git a/mysql-test/r/binlog_statement_insert_delayed.result b/mysql-test/r/binlog_statement_insert_delayed.result
index 7a1b9a7ec9b..3a2dc441632 100644
--- a/mysql-test/r/binlog_statement_insert_delayed.result
+++ b/mysql-test/r/binlog_statement_insert_delayed.result
@@ -3,13 +3,13 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
insert delayed into t1 values (207);
insert delayed into t1 values (null);
insert delayed into t1 values (300);
-show binlog events from 102;
+show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
-master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (207)
-master-bin.000001 # Intvar 1 # INSERT_ID=208
-master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (null)
-master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (300)
+master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
+master-bin.000001 # Query # # use `test`; insert delayed into t1 values (207)
+master-bin.000001 # Intvar # # INSERT_ID=208
+master-bin.000001 # Query # # use `test`; insert delayed into t1 values (null)
+master-bin.000001 # Query # # use `test`; insert delayed into t1 values (300)
insert delayed into t1 values (null),(null),(null),(null);
insert delayed into t1 values (null),(null),(400),(null);
11 == 11
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result
index 9d8de75fe60..7375260d863 100644
--- a/mysql-test/r/date_formats.result
+++ b/mysql-test/r/date_formats.result
@@ -91,6 +91,8 @@ create table t1 (date char(30), format char(30) not null);
insert into t1 values
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
+('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
+('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
@@ -122,6 +124,8 @@ select date,format,str_to_date(date, format) as str_to_date from t1;
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 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
+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
@@ -153,6 +157,8 @@ select date,format,concat('',str_to_date(date, format)) as con from t1;
date format con
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
+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
@@ -184,6 +190,8 @@ select date,format,cast(str_to_date(date, format) as datetime) as datetime from
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
+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
@@ -215,6 +223,8 @@ select date,format,DATE(str_to_date(date, format)) as date2 from t1;
date format date2
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02
+0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02
@@ -246,6 +256,8 @@ select date,format,TIME(str_to_date(date, format)) as time from t1;
date format time
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
+0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
@@ -277,6 +289,8 @@ select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
date format time2
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
+0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
@@ -402,14 +416,14 @@ select date,format,str_to_date(date, format) as str_to_date from t1;
date format str_to_date
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 0003-01-02 22: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'
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 0003-01-02 22: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'
drop table t1;
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index 109ddcd02e1..20538694218 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -668,3 +668,17 @@ NULL
3
4
DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES(1,1),(1,2),(1,3);
+SELECT DISTINCT a, b FROM t1;
+a b
+1 1
+1 2
+1 3
+SELECT DISTINCT a, a, b FROM t1;
+a a b
+1 1 1
+1 1 2
+1 1 3
+DROP TABLE t1;
+End of 5.0 tests
diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result
index 124b20e9b46..b7dbfc670a8 100644
--- a/mysql-test/r/func_sapdb.result
+++ b/mysql-test/r/func_sapdb.result
@@ -75,6 +75,12 @@ NULL
select weekofyear("1997-11-30 23:59:59.000001");
weekofyear("1997-11-30 23:59:59.000001")
48
+select makedate(03,1);
+makedate(03,1)
+2003-01-01
+select makedate('0003',1);
+makedate('0003',1)
+2003-01-01
select makedate(1997,1);
makedate(1997,1)
1997-01-01
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 16a1e5d01d7..2d59a32218c 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1225,13 +1225,13 @@ TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s")
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)
-NULL
+0049-12-31 23:59:59
select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND)
-NULL
+0198-12-31 23:59:59
select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND)
-NULL
+0200-01-01 00:00:01
select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
0199-12-31 23:59:59
@@ -1252,8 +1252,8 @@ date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND)
1989-12-31 23:59:59
select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND)
-NULL
+0068-12-31 23:59:59
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
-NULL
+0168-12-31 23:59:59
End of 5.1 tests
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 2ac5953c456..f82e52d6370 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -1,3 +1,4 @@
+SET GLOBAL log_bin_trust_function_creators = 1;
drop table if exists t1;
drop database if exists mysqltest;
SET NAMES binary;
@@ -1059,6 +1060,128 @@ DROP DATABASE bug23556;
DROP USER bug23556@localhost;
GRANT PROCESS ON * TO user@localhost;
ERROR 3D000: No database selected
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+DROP DATABASE IF EXISTS mysqltest3;
+DROP DATABASE IF EXISTS mysqltest4;
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+CREATE DATABASE mysqltest3;
+CREATE DATABASE mysqltest4;
+CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
+SELECT 1;
+CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
+SELECT 1;
+CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
+RETURN 1;
+CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
+RETURN 1;
+GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
+GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
+GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
+GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
+GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
+
+---> connection: bug9504_con1
+use mysqltest1;
+use mysqltest2;
+use mysqltest3;
+use mysqltest4;
+use test;
+CALL mysqltest1.p_def();
+1
+1
+CALL mysqltest2.p_inv();
+1
+1
+SELECT mysqltest3.f_def();
+mysqltest3.f_def()
+1
+SELECT mysqltest4.f_inv();
+mysqltest4.f_inv()
+1
+
+---> connection: default
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP DATABASE mysqltest3;
+DROP DATABASE mysqltest4;
+DROP USER mysqltest_1@localhost;
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
+GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
+CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
+SELECT 1;
+
+---> connection: bug27337_con1
+CREATE TABLE t1(c INT);
+ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
+CALL mysqltest1.p1();
+1
+1
+CREATE TABLE t1(c INT);
+ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
+
+---> connection: bug27337_con2
+CREATE TABLE t1(c INT);
+ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
+SHOW TABLES;
+Tables_in_mysqltest2
+
+---> connection: default
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER mysqltest_1@localhost;
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+CREATE TABLE mysqltest1.t1(c INT);
+CREATE TABLE mysqltest2.t2(c INT);
+GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
+GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
+
+---> connection: bug27337_con1
+SHOW TABLES FROM mysqltest1;
+Tables_in_mysqltest1
+t1
+PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
+EXECUTE stmt1;
+Tables_in_mysqltest1
+t1
+
+---> connection: bug27337_con2
+SHOW COLUMNS FROM mysqltest2.t2;
+Field Type Null Key Default Extra
+c int(11) YES NULL
+PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
+EXECUTE stmt2;
+Field Type Null Key Default Extra
+c int(11) YES NULL
+
+---> connection: default
+REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
+REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
+
+---> connection: bug27337_con1
+SHOW TABLES FROM mysqltest1;
+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
+EXECUTE stmt1;
+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
+
+---> connection: bug27337_con2
+SHOW COLUMNS FROM mysqltest2.t2;
+ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
+EXECUTE stmt2;
+ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
+
+---> connection: default
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER mysqltest_1@localhost;
End of 5.0 tests
set names utf8;
grant select on test.* to юзер_юзер@localhost;
diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
index 2a6a3e6e0fb..94ebc213122 100644
--- a/mysql-test/r/information_schema_db.result
+++ b/mysql-test/r/information_schema_db.result
@@ -117,16 +117,82 @@ use testdb_1;
create table t1 (f1 char(4));
create view v1 as select f1 from t1;
grant insert on v1 to testdb_2@localhost;
+create view v5 as select f1 from t1;
+grant show view on v5 to testdb_2@localhost;
+create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
+use testdb_1;
+create view v6 as select f1 from t1;
+grant show view on v6 to testdb_2@localhost;
+create table t2 (f1 char(4));
+create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
+Warnings:
+Note 1449 There is no 'no_such_user'@'no_such_host' registered
+show fields from testdb_1.v6;
+Field Type Null Key Default Extra
+f1 char(4) YES NULL
+show create view testdb_1.v6;
+View Create View
+v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1`
+show create view testdb_1.v7;
+View Create View
+v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
+Warnings:
+Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+show fields from testdb_1.v7;
+Field Type Null Key Default Extra
+f1 null YES NULL
+Warnings:
+Note 1449 There is no 'no_such_user'@'no_such_host' registered
create table t3 (f1 char(4), f2 char(4));
create view v3 as select f1,f2 from t3;
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
create view v2 as select f1 from testdb_1.v1;
create view v4 as select f1,f2 from testdb_1.v3;
+show fields from testdb_1.v5;
+Field Type Null Key Default Extra
+f1 char(4) YES NULL
+show create view testdb_1.v5;
+View Create View
+v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
+show fields from testdb_1.v6;
+Field Type Null Key Default Extra
+f1 char(4) YES NULL
+show create view testdb_1.v6;
+View Create View
+v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
+show fields from testdb_1.v7;
+Field Type Null Key Default Extra
+f1 null YES NULL
+Warnings:
+Note 1449 There is no 'no_such_user'@'no_such_host' registered
+show create view testdb_1.v7;
+View Create View
+v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
+Warnings:
+Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
revoke insert(f1) on v3 from testdb_2@localhost;
+revoke show view on v5 from testdb_2@localhost;
+use testdb_1;
+revoke show view on v6 from testdb_2@localhost;
+show fields from testdb_1.v5;
+ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
+show create view testdb_1.v5;
+ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
+show fields from testdb_1.v6;
+ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
+show create view testdb_1.v6;
+ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
+show fields from testdb_1.v7;
+ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
+show create view testdb_1.v7;
+ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
show create view v4;
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
show fields from v4;
-ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+Field Type Null Key Default Extra
+f1 null YES NULL
+f2 char(4) YES NULL
show fields from v2;
Field Type Null Key Default Extra
f1 char(4) YES NULL
@@ -151,7 +217,8 @@ where a.table_name = 'testdb_1.v1';
view_definition
select * from v2;
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-drop view testdb_1.v1,v2, testdb_1.v3, v4;
+use test;
+drop view testdb_1.v1, v2, testdb_1.v3, v4;
drop database testdb_1;
drop user testdb_1@localhost;
drop user testdb_2@localhost;
diff --git a/mysql-test/r/mysql_protocols.result b/mysql-test/r/mysql_protocols.result
index cbead9254a2..c6207c4f4f5 100644
--- a/mysql-test/r/mysql_protocols.result
+++ b/mysql-test/r/mysql_protocols.result
@@ -7,3 +7,4 @@ SOCKET
ERROR 2047 (HY000): Wrong or unknown protocol
ERROR 2047 (HY000): Wrong or unknown protocol
Unknown option to protocol: NullS
+Alternatives are: 'TCP','SOCKET','PIPE','MEMORY'
diff --git a/mysql-test/r/mysqlbinlog2.result b/mysql-test/r/mysqlbinlog2.result
index e76ab71fd54..ef6e4ee80fd 100644
--- a/mysql-test/r/mysqlbinlog2.result
+++ b/mysql-test/r/mysqlbinlog2.result
@@ -122,6 +122,23 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+--- start and stop positions ---
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET INSERT_ID=4/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1579609946/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+insert into t1 values(null, "d")/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
--- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
@@ -482,6 +499,23 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+--- start and stop positions ---
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET INSERT_ID=4/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1579609946/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+insert into t1 values(null, "d")/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
--- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result
index 470c2cb9c0e..7aeb156869b 100644
--- a/mysql-test/r/ndb_dd_basic.result
+++ b/mysql-test/r/ndb_dd_basic.result
@@ -468,6 +468,13 @@ insert into t1 values(7,'x');
insert into t1 values(8,'x');
delete from t1 where a = 0;
commit;
+delete from t1;
+begin;
+insert into t1 values (1, 'x');
+select * from t1;
+a b
+1 x
+rollback;
set autocommit = 1;
drop table t1;
create table test.t1 (f1 varchar(50) primary key, f2 text,f3 int)
diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result
index b946d97bea1..b57fc2e14ba 100644
--- a/mysql-test/r/ndb_restore.result
+++ b/mysql-test/r/ndb_restore.result
@@ -2,12 +2,12 @@ use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
CREATE TABLE `t1_c` (
-`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment,
+`capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment,
`goaledatta` char(2) NOT NULL default '',
`maturegarbagefa` varchar(32) NOT NULL default '',
PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
-INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt');
+INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt');
CREATE TABLE `t2_c` (
`capgotod` smallint(5) unsigned NOT NULL auto_increment,
`gotod` smallint(5) unsigned NOT NULL default '0',
@@ -16,9 +16,9 @@ CREATE TABLE `t2_c` (
`descrpooppo` varchar(64) default NULL,
`svcutonsa` varchar(64) NOT NULL default '',
PRIMARY KEY (`capgotod`),
-KEY `i_quadaddsvr` (`gotod`)
+KEY `i quadaddsvr` (`gotod`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
-INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
+INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
CREATE TABLE `t3_c` (
`CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
`capgotod` smallint(5) unsigned NOT NULL default '0',
@@ -36,7 +36,7 @@ PRIMARY KEY (`fa`,`realm`),
KEY `capfa` (`capfa`),
KEY `i_quadentity` (`fa`,`realm`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
-INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
+INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
CREATE TABLE `t5_c` (
`capfa` bigint(20) unsigned NOT NULL default '0',
`gotod` smallint(5) unsigned NOT NULL default '0',
@@ -53,7 +53,7 @@ PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`)
INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0);
CREATE TABLE `t7_c` (
`dardpo` char(15) NOT NULL default '',
-`dardtestard` tinyint(3) unsigned NOT NULL default '0',
+`dardtestard` tinyint(3) unsigned NOT NULL auto_increment,
`FastFA` char(5) NOT NULL default '',
`FastCode` char(6) NOT NULL default '',
`Fastca` char(1) NOT NULL default '',
@@ -118,6 +118,7 @@ PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`)
INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3);
CREATE TABLE t10_c (a INT AUTO_INCREMENT KEY) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO t10_c VALUES (1),(2),(3);
+insert into t10_c values (10000),(2000),(3000);
create table t1 engine=myisam as select * from t1_c;
create table t2 engine=myisam as select * from t2_c;
create table t3 engine=myisam as select * from t3_c;
@@ -240,6 +241,24 @@ a
1
2
3
+2000
+3000
+10000
+show table status like 't1_c';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+X X X X X X X X X X 3001 X X X X X X X
+show table status like 't2_c';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+X X X X X X X X X X 501 X X X X X X X
+show table status like 't4_c';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+X X X X X X X X X X 290000001 X X X X X X X
+show table status like 't7_c';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+X X X X X X X X X X 29 X X X X X X X
+show table status like 't10_c';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+X X X X X X X X X X 10001 X X X X X X X
ALTER TABLE t7_c
PARTITION BY LINEAR KEY (`dardtestard`);
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index af7a762c5a8..d18bb8dc434 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -2961,20 +2961,26 @@ delete from t9 ;
test_sequence
-- insert into date/time columns --
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1264 Out of range value for column 'c13' at row 1
@@ -3005,6 +3011,7 @@ 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
Warnings:
+Note 1265 Data truncated for column 'c13' 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 1264 Out of range value for column 'c17' at row 1
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 8c0b9f1e19b..e6ff668760c 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -2944,20 +2944,26 @@ delete from t9 ;
test_sequence
-- insert into date/time columns --
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1264 Out of range value for column 'c13' at row 1
@@ -2988,6 +2994,7 @@ 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
Warnings:
+Note 1265 Data truncated for column 'c13' 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 1264 Out of range value for column 'c17' at row 1
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 7ad6e3ea722..046992806cc 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -2945,20 +2945,26 @@ delete from t9 ;
test_sequence
-- insert into date/time columns --
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1264 Out of range value for column 'c13' at row 1
@@ -2989,6 +2995,7 @@ 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
Warnings:
+Note 1265 Data truncated for column 'c13' 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 1264 Out of range value for column 'c17' at row 1
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 1e2c27e6e4f..bbdb80df5d4 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -2881,20 +2881,26 @@ delete from t9 ;
test_sequence
-- insert into date/time columns --
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1264 Out of range value for column 'c13' at row 1
@@ -2925,6 +2931,7 @@ 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
Warnings:
+Note 1265 Data truncated for column 'c13' 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 1264 Out of range value for column 'c17' at row 1
@@ -5895,20 +5902,26 @@ delete from t9 ;
test_sequence
-- insert into date/time columns --
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1264 Out of range value for column 'c13' at row 1
@@ -5939,6 +5952,7 @@ 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
Warnings:
+Note 1265 Data truncated for column 'c13' 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 1264 Out of range value for column 'c17' at row 1
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index e43f6b4ed6c..20d38ba84bd 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -2944,20 +2944,26 @@ delete from t9 ;
test_sequence
-- insert into date/time columns --
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
+Note 1265 Data truncated for column 'c13' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
Warnings:
Warning 1264 Out of range value for column 'c13' at row 1
@@ -2988,6 +2994,7 @@ 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
Warnings:
+Note 1265 Data truncated for column 'c13' 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 1264 Out of range value for column 'c17' at row 1
diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result
index 26d616df2f3..e6dea211fdc 100644
--- a/mysql-test/r/row.result
+++ b/mysql-test/r/row.result
@@ -175,6 +175,24 @@ ROW(2,10) <=> ROW(3,4)
SELECT ROW(NULL,10) <=> ROW(3,NULL);
ROW(NULL,10) <=> ROW(3,NULL)
0
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2)));
+ERROR 21000: Operand should contain 3 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
+ERROR 21000: Operand should contain 1 column(s)
+SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
+ERROR 21000: Operand should contain 1 column(s)
SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ;
1 0 0 0 null
1 0 0 0 NULL
diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result
index 60fba96fb6a..28ddbaf33a0 100644
--- a/mysql-test/r/rpl_log_pos.result
+++ b/mysql-test/r/rpl_log_pos.result
@@ -27,7 +27,7 @@ change master to master_log_pos=178;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert
-# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 178 # # master-bin.000001 No Yes 0 0 178 # None 0 No # No
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 178 # # master-bin.000001 # Yes 0 0 178 # None 0 No # No
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 106 <Binlog_Ignore_DB>
diff --git a/mysql-test/r/rpl_ndb_basic.result b/mysql-test/r/rpl_ndb_basic.result
index 9a99ddd2137..4dab05b31de 100644
--- a/mysql-test/r/rpl_ndb_basic.result
+++ b/mysql-test/r/rpl_ndb_basic.result
@@ -24,6 +24,33 @@ nid nom prenom
select * from t1 order by nid;
nid nom prenom
1 XYZ2 ABC2
+delete from t1;
+insert into t1 values(1,"AA", "AA");
+insert into t1 values(2,"BB", "BB");
+insert into t1 values(3,"CC", "CC");
+insert into t1 values(4,"DD", "DD");
+begin;
+delete from t1 where nid = 1;
+insert into t1 values (1,"A2", "A2");
+update t1 set nom="B2" where nid = 2;
+delete from t1 where nid = 2;
+update t1 set nom = "D2" where nid = 4;
+delete from t1 where nid = 4;
+insert into t1 values (4, "D3", "D3");
+update t1 set nom = "D4" where nid = 4;
+insert into t1 values (5, "EE", "EE");
+delete from t1 where nid = 5;
+commit;
+select * from t1 order by 1;
+nid nom prenom
+1 A2 A2
+3 CC CC
+4 D4 D3
+select * from t1 order by 1;
+nid nom prenom
+1 A2 A2
+3 CC CC
+4 D4 D3
DROP table t1;
CREATE TABLE `t1` ( `nid` int(11) NOT NULL default '0',
`nom` char(4) default NULL,
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index f88f046f0ac..6ffb769292f 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -3971,4 +3971,13 @@ t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
faq_id
265
DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT, b INT, KEY inx (b,a));
+INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7);
+EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
+ON ( f1.b=f2.b AND f1.a<f2.a )
+WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index
+1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index b2fdf6a864e..7315ef40083 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -8,22 +8,29 @@ create procedure db1_secret.dummy() begin end;
drop procedure db1_secret.dummy;
use db1_secret;
create table t1 ( u varchar(64), i int );
+insert into t1 values('test', 0);
create procedure stamp(i int)
insert into db1_secret.t1 values (user(), i);
show procedure status like 'stamp';
Db Name Type Definer Modified Created Security_type Comment
db1_secret stamp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-create function db() returns varchar(64) return database();
+create function db() returns varchar(64)
+begin
+declare v varchar(64);
+select u into v from t1 limit 1;
+return v;
+end|
show function status like 'db';
Db Name Type Definer Modified Created Security_type Comment
db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
call stamp(1);
select * from t1;
u i
+test 0
root@localhost 1
select db();
db()
-db1_secret
+test
grant execute on procedure db1_secret.stamp to user1@'%';
grant execute on function db1_secret.db to user1@'%';
grant execute on procedure db1_secret.stamp to ''@'%';
@@ -31,25 +38,34 @@ grant execute on function db1_secret.db to ''@'%';
call db1_secret.stamp(2);
select db1_secret.db();
db1_secret.db()
-db1_secret
+test
select * from db1_secret.t1;
ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
create procedure db1_secret.dummy() begin end;
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
drop procedure db1_secret.dummy;
ERROR 42000: PROCEDURE db1_secret.dummy does not exist
+drop procedure db1_secret.stamp;
+ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.stamp'
+drop function db1_secret.db;
+ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.db'
call db1_secret.stamp(3);
select db1_secret.db();
db1_secret.db()
-db1_secret
+test
select * from db1_secret.t1;
ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
create procedure db1_secret.dummy() begin end;
ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
drop procedure db1_secret.dummy;
ERROR 42000: PROCEDURE db1_secret.dummy does not exist
+drop procedure db1_secret.stamp;
+ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.stamp'
+drop function db1_secret.db;
+ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.db'
select * from t1;
u i
+test 0
root@localhost 1
user1@localhost 2
anon@localhost 3
@@ -64,21 +80,22 @@ db1_secret db FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 IN
call stamp(4);
select * from t1;
u i
+test 0
root@localhost 1
user1@localhost 2
anon@localhost 3
root@localhost 4
select db();
db()
-db1_secret
+test
call db1_secret.stamp(5);
-ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
+ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 't1'
select db1_secret.db();
-ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
+ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
call db1_secret.stamp(6);
-ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
+ERROR 42000: INSERT command denied to user ''@'localhost' for table 't1'
select db1_secret.db();
-ERROR 42000: Access denied for user ''@'%' to database 'db1_secret'
+ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
drop database if exists db2;
create database db2;
use db2;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 312bb6857a5..44abc11029a 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -6061,6 +6061,21 @@ SUM(f2) bug25373(f1)
21.300000071526 NULL
DROP FUNCTION bug25373|
DROP TABLE t3|
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1|
+CREATE DATABASE mysqltest2|
+CREATE PROCEDURE mysqltest1.p1()
+DROP DATABASE mysqltest2|
+use mysqltest2|
+CALL mysqltest1.p1()|
+Warnings:
+Note 1049 Unknown database 'mysqltest2'
+SELECT DATABASE()|
+DATABASE()
+NULL
+DROP DATABASE mysqltest1|
+use test|
drop function if exists bug20777|
drop table if exists examplebug20777|
create function bug20777(f1 bigint unsigned) returns bigint unsigned
@@ -6147,3 +6162,28 @@ bug20777(18446744073709551613)+1
drop function bug20777;
End of 5.0 tests.
drop table t1,t2;
+CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
+CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
+set @a=0;
+CREATE function bug27354() RETURNS int deterministic
+begin
+insert into t1 values (null);
+set @a=@a+1;
+return @a;
+end|
+update t2 set b=1 where a=bug27354();
+select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
+count(t_1.a) count(t_2.a)
+0 0
+insert into t2 values (1,1),(2,2),(3,3);
+update t2 set b=-b where a=bug27354();
+select * from t2 /* must return 1,-1 ... */;
+a b
+1 -1
+2 -2
+3 -3
+select count(*) from t1 /* must be 3 */;
+count(*)
+3
+drop table t1,t2;
+drop function bug27354;
diff --git a/mysql-test/r/sp_trans_log.result b/mysql-test/r/sp_trans_log.result
new file mode 100644
index 00000000000..a835b06858b
--- /dev/null
+++ b/mysql-test/r/sp_trans_log.result
@@ -0,0 +1,27 @@
+drop function if exists bug23333|
+drop table if exists t1,t2|
+CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
+CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
+insert into t2 values (1,1)|
+create function bug23333()
+RETURNS int(11)
+DETERMINISTIC
+begin
+insert into t1 values (null);
+select count(*) from t1 into @a;
+return @a;
+end|
+reset master|
+insert into t2 values (bug23333(),1)|
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+show binlog events from 106 /* with fixes for #23333 will show there is the query */|
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Table_map 1 # #
+master-bin.000001 # Table_map 1 # #
+master-bin.000001 # Write_rows 1 # #
+master-bin.000001 # Query 1 # #
+select count(*),@a from t1 /* must be 1,1 */|
+count(*) @a
+1 1
+drop table t1,t2;
+drop function if exists bug23333;
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 74cd723e130..94f4637cd05 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -206,6 +206,8 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y'));
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
+Warnings:
+Note 1265 Data truncated for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -1386,4 +1388,9 @@ ERROR 01000: Data truncated for column 'a' at row 1
insert into t1 values ('2E3x');
ERROR 01000: Data truncated for column 'a' at row 1
drop table t1;
+set sql_mode='traditional';
+create table t1 (f1 set('a','a'));
+ERROR HY000: Column 'f1' has duplicated value 'a' in SET
+create table t1 (f1 enum('a','a'));
+ERROR HY000: Column 'f1' has duplicated value 'a' in ENUM
End of 5.0 tests
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 089fb10aaae..8263350fe58 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -48,7 +48,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1276 Field or reference '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 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 ((select '1' AS `a`) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
@@ -330,7 +330,7 @@ patient_uq clinic_uq
explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t6 ALL NULL NULL NULL NULL 4 100.00 Using where
-2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index
Warnings:
Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))
@@ -1741,7 +1741,7 @@ Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `tes
explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where
-2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 tt.id 1 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))
@@ -3924,6 +3924,71 @@ c a (SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a)
3 3 4
1 4 2,2
DROP table t1,t2;
+CREATE TABLE t1 (a int, b INT, d INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
+INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'),
+(1,5,0,'e'), (2,1,0,'f'), (2,2,0,'g'), (2,3,0,'h'), (3,4,0,'i'), (3,3,0,'j'),
+(3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p');
+SELECT a, MAX(b),
+(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test
+FROM t1 GROUP BY a;
+a MAX(b) test
+1 9 m
+2 3 h
+3 4 i
+SELECT a x, MAX(b),
+(SELECT t.c FROM t1 AS t WHERE x=t.a AND t.b=MAX(t1.b + 0)) as test
+FROM t1 GROUP BY a;
+x MAX(b) test
+1 9 m
+2 3 h
+3 4 i
+SELECT a, AVG(b),
+(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b)) AS test
+FROM t1 WHERE t1.d=0 GROUP BY a;
+a AVG(b) test
+1 4.0000 d
+2 2.0000 g
+3 2.5000 NULL
+SELECT tt.a,
+(SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
+LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+FROM t1 as tt;
+a test
+1 n
+1 n
+1 n
+1 n
+1 n
+1 n
+1 n
+2 o
+2 o
+2 o
+2 o
+3 p
+3 p
+3 p
+3 p
+3 p
+SELECT tt.a,
+(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
+LIMIT 1)
+FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+FROM t1 as tt GROUP BY tt.a;
+a test
+1 n
+2 o
+3 p
+SELECT tt.a, MAX(
+(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
+LIMIT 1)
+FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test
+FROM t1 as tt GROUP BY tt.a;
+a test
+1 n
+2 o
+3 p
+DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index 4b8ece1c931..18feb7cb6b9 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -432,7 +432,7 @@ alter table t1 add index idx(oref,ie);
explain select oref, a, a in (select ie from t1 where oref=t2.oref) 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_or_null idx idx 10 t2.oref,func 4 Using where; Using index; Full scan on NULL key
+2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 test.t2.oref,func 4 Using where; Using index; Full scan on NULL key
select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;
oref a Z
ee NULL NULL
@@ -457,7 +457,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 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; Using filesort
select oref, a,
a in (select min(ie) from t1 where oref=t2.oref
group by grp having min(ie) > 1) Z
diff --git a/mysql-test/r/truncate.result b/mysql-test/r/truncate.result
index 74a6cb72cc6..6c21db0e2b8 100644
--- a/mysql-test/r/truncate.result
+++ b/mysql-test/r/truncate.result
@@ -53,3 +53,30 @@ a
3
4
drop table t1;
+create table t1 (s1 int);
+insert into t1 (s1) values (1), (2), (3), (4), (5);
+create view v1 as select * from t1;
+truncate table v1;
+select count(*) from t1;
+count(*)
+0
+insert into t1 (s1) values (1), (2), (3), (4), (5);
+create view v2 as select * from t1 where s1 > 3;
+truncate table v2;
+select * from t1;
+s1
+1
+2
+3
+select * from v2;
+s1
+delete from t1;
+create table t2 (s1 int, s2 int);
+create view v3 as select a.s1, b.s2 from t1 a join t2 b on a.s1 = b.s1 where a.s1 > 3;
+truncate table v3;
+ERROR HY000: Can not delete from join view 'test.v3'
+create view v4 as select * from t1 limit 1,1;
+truncate table v4;
+ERROR HY000: The target table v4 of the TRUNCATE is not updatable
+drop view v1, v2, v3, v4;
+drop table t1, t2;
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 644d4d971c6..6d5218873ce 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -110,3 +110,29 @@ select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_dat
1
1
drop table t1;
+select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date);
+@d:=1111 year(@d) month(@d) day(@d) cast(@d as date)
+1111 2000 11 11 2000-11-11
+select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date);
+@d:=011111 year(@d) month(@d) day(@d) cast(@d as date)
+11111 2001 11 11 2001-11-11
+select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date);
+@d:=1311 year(@d) month(@d) day(@d) cast(@d as date)
+1311 NULL NULL NULL NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1311'
+Warning 1292 Incorrect datetime value: '1311'
+Warning 1292 Incorrect datetime value: '1311'
+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 'ts' at row 1
+insert into t1 values (11111,11111,11111);
+select * from t1;
+d dt ts
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00
+2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00
+drop table t1;
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index e40ec689127..045a6cd1c0a 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -192,3 +192,38 @@ CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMA
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
+set @org_mode=@@sql_mode;
+create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
+Warnings:
+Note 1265 Data truncated for column 'da' at row 1
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `da` date DEFAULT '1962-03-03',
+ `dt` datetime DEFAULT '1962-03-03 00:00:00'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ();
+insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
+Warnings:
+Note 1265 Data truncated for column 'da' at row 1
+set @@sql_mode='ansi,traditional';
+insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
+Warnings:
+Note 1265 Data truncated for column 'da' at row 1
+insert into t1 set dt='2007-03-23 13:49:38',da=dt;
+Warnings:
+Note 1265 Data truncated for column 'da' at row 1
+insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
+ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1
+select * from t1;
+da dt
+1962-03-03 1962-03-03 00:00:00
+2007-03-23 2007-03-23 13:49:38
+2007-03-23 2007-03-23 13:49:38
+2007-03-23 2007-03-23 13:49:38
+drop table t1;
+create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
+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;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 0fa7cda1187..a542d3270a2 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2385,6 +2385,16 @@ Table Op Msg_type Msg_text
test.v1 optimize error 'test.v1' is not BASE TABLE
Warnings:
Error 1347 'test.v1' is not BASE TABLE
+ANALYZE TABLE v1;
+Table Op Msg_type Msg_text
+test.v1 analyze error 'test.v1' is not BASE TABLE
+Warnings:
+Error 1347 'test.v1' is not BASE TABLE
+REPAIR TABLE v1;
+Table Op Msg_type Msg_text
+test.v1 repair error 'test.v1' is not BASE TABLE
+Warnings:
+Error 1347 'test.v1' is not BASE TABLE
DROP VIEW v1;
create definer = current_user() sql security invoker view v1 as select 1;
show create view v1;
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 2a0bedc1443..51d131f0044 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -284,15 +284,6 @@ create view mysqltest.v3 as select b from mysqltest.t2;
grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
drop view mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2;
-grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost;
-drop view mysqltest.v3;
-create view mysqltest.v3 as select b from mysqltest.t2;
-ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
-create table mysqltest.v3 (b int);
-grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
-drop table mysqltest.v3;
-create view mysqltest.v3 as select b from mysqltest.t2;
-ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
create view v4 as select b+1 from mysqltest.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
grant create view,update,select on test.* to mysqltest_1@localhost;
@@ -796,6 +787,94 @@ View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1`
DROP USER u26813@localhost;
DROP DATABASE db26813;
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+CREATE TABLE mysqltest1.t1(c1 INT);
+CREATE TABLE mysqltest1.t2(c2 INT);
+CREATE TABLE mysqltest1.t3(c3 INT);
+CREATE TABLE mysqltest1.t4(c4 INT);
+INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
+INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
+INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
+INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
+GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
+GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
+GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
+GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
+GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
+
+---> connection: bug24040_con
+SELECT * FROM mysqltest1.t1;
+c1
+11
+12
+13
+14
+INSERT INTO mysqltest1.t2 VALUES(25);
+UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
+DELETE FROM mysqltest1.t4 WHERE c4 = 44;
+CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
+CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
+CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
+CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
+SELECT * FROM v1;
+c1
+11
+12
+13
+14
+INSERT INTO v2 VALUES(26);
+UPDATE v3 SET c3 = 332 WHERE c3 = 32;
+DELETE FROM v4 WHERE c4 = 43;
+CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
+ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v12'
+CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
+CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
+CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
+ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c1' in table 'v21'
+CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
+ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c3' in table 'v23'
+CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
+ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c4' in table 'v24'
+CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
+CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
+ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v32'
+CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
+CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
+CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
+ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42'
+CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
+
+---> connection: default
+SELECT * FROM mysqltest1.t1;
+c1
+11
+12
+13
+14
+SELECT * FROM mysqltest1.t2;
+c2
+21
+22
+23
+24
+25
+26
+SELECT * FROM mysqltest1.t3;
+c3
+331
+332
+33
+34
+SELECT * FROM mysqltest1.t4;
+c4
+41
+42
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER mysqltest_u1@localhost;
End of 5.0 tests.
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/suite/funcs_1/r/a_version_check.result b/mysql-test/suite/funcs_1/r/a_version_check.result
index 1569c40e4e5..da6ba0846fd 100644
--- a/mysql-test/suite/funcs_1/r/a_version_check.result
+++ b/mysql-test/suite/funcs_1/r/a_version_check.result
@@ -6,6 +6,6 @@
. updated with each new version --- THIS IS INTENDED!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-funcs_1 checked with version: 5.1.16
+funcs_1 checked with version: 5.1.17
Warnings:
Warning 1548 Leading spaces are removed from name ' '
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs.inc b/mysql-test/suite/partitions/include/partition_supported_sql_funcs.inc
index f74fce39a7d..b2e102f8e07 100644
--- a/mysql-test/suite/partitions/include/partition_supported_sql_funcs.inc
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs.inc
@@ -1,7 +1,7 @@
################################################################################
-# t/partition_supported_sql_funcs.inc # #
+# t/partition_supported_sql_funcs.inc # # #
# Purpose: #
-# Tests around sql functions #
+# Tests frame for allowed sql functions #
# #
# #
#------------------------------------------------------------------------------#
@@ -83,24 +83,23 @@ eval insert into t3 values ($val1);
eval insert into t3 values ($val2);
eval insert into t3 values ($val3);
-eval insert into t4 values (1,$val1);
-eval insert into t4 values (2,$val2);
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/partitions/include/$infile' into table t4;
-eval insert into t5 values (1,$val1);
-eval insert into t5 values (2,$val2);
-eval insert into t5 values (3,$val3);
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/partitions/include/$infile' into table t5;
-eval insert into t6 values (1,$val2);
-eval insert into t6 values (2,$val3);
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/partitions/include/$infile' into table t6;
-eval select $sqlfunc from t1;
+eval select $sqlfunc from t1 order by col1;
-select * from t1;
-select * from t2;
-select * from t3;
-select * from t4;
-select * from t5;
-select * from t6;
+select * from t1 order by col1;
+select * from t2 order by col1;
+select * from t3 order by col1;
+select * from t4 order by colint;
+select * from t5 order by colint;
+select * from t6 order by colint;
if ($do_long_tests)
{
@@ -111,12 +110,12 @@ if ($do_long_tests)
eval update t5 set col1=$val4 where col1=$val1;
eval update t6 set col1=$val4 where col1=$val1;
- select * from t1;
- select * from t2;
- select * from t3;
- select * from t4;
- select * from t5;
- select * from t6;
+ select * from t1 order by col1;
+ select * from t2 order by col1;
+ select * from t3 order by col1;
+ select * from t4 order by colint;
+ select * from t5 order by colint;
+ select * from t6 order by colint;
}
--echo -------------------------------------------------------------------------
@@ -175,46 +174,63 @@ partition by range(colint)
(partition p0 values less than ($valsqlfunc),
partition p1 values less than maxvalue);
-select * from t11;
-select * from t22;
-select * from t33;
-select * from t44;
-select * from t55;
-select * from t66;
+select * from t11 order by col1;
+select * from t22 order by col1;
+select * from t33 order by col1;
+select * from t44 order by colint;
+select * from t55 order by colint;
+select * from t66 order by colint;
if ($do_long_tests)
{
+ --echo ---------------------------
+ --echo ---- some alter table begin
+ --echo ---------------------------
eval alter table t11
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
- select * from t11;
+ select * from t11 order by col1;
eval alter table t11
reorganize partition s1 into
(partition p0 values less than (15),
partition p1 values less than maxvalue);
- select * from t11;
+ select * from t11 order by col1;
+
+eval alter table t55
+partition by list(colint)
+subpartition by hash($sqlfunc) 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;
+ select * from t55 order by colint;
eval alter table t66
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
- select * from t66;
+ select * from t66 order by colint;
eval alter table t66
reorganize partition s1 into
(partition p0 values less than ($valsqlfunc),
partition p1 values less than maxvalue);
- select * from t66;
+ select * from t66 order by colint;
eval alter table t66
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
- select * from t66;
+ select * from t66 order by colint;
- eval alter table t66
- add partition s0
- (partition p0 values less than ($valsqlfunc);
- select * fromt t66;
+ eval alter table t66
+ reorganize partition s1 into
+ (partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+ select * from t66 order by colint;
let $t1=t1;
let $t2=t2;
@@ -233,6 +249,9 @@ if ($do_long_tests)
let $t6=t66;
--source suite/partitions/include/partition_supported_sql_funcs_delete.inc
# --source include/partition_supported_sql_funcs_delete.inc
+ --echo -------------------------
+ --echo ---- some alter table end
+ --echo -------------------------
}
--disable_warnings
drop table if exists t1 ;
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_delete.inc b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_delete.inc
index c733d750fab..76e8bd6dcc6 100644
--- a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_delete.inc
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_delete.inc
@@ -1,3 +1,16 @@
+################################################################################
+# t/partition_supported_sql_funcs_delete.inc # # #
+# Purpose: #
+# Delete access of the tests frame for allowed sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
--echo -------------------------------------------------------------------------
--echo --- Delete rows and partitions of tables with $sqlfunc
--echo -------------------------------------------------------------------------
@@ -9,25 +22,25 @@ eval delete from $t4 where col1=$val2;
eval delete from $t5 where col1=$val2;
eval delete from $t6 where col1=$val2;
-eval select * from $t1;
-eval select * from $t2;
-eval select * from $t3;
-eval select * from $t4;
-eval select * from $t5;
+eval select * from $t1 order by col1;
+eval select * from $t2 order by col1;
+eval select * from $t3 order by col1;
+eval select * from $t4 order by colint;
+eval select * from $t5 order by colint;
eval insert into $t1 values ($val2);
eval insert into $t2 values ($val2);
eval insert into $t3 values ($val2);
-eval insert into $t4 values (4,$val2);
-eval insert into $t5 values (4,$val2);
-eval insert into $t6 values (4,$val2);
+eval insert into $t4 values (60,$val2);
+eval insert into $t5 values (60,$val2);
+eval insert into $t6 values (60,$val2);
-eval select * from $t1;
-eval select * from $t2;
-eval select * from $t3;
-eval select * from $t4;
-eval select * from $t5;
-eval select * from $t6;
+eval select * from $t1 order by col1;
+eval select * from $t2 order by col1;
+eval select * from $t3 order by col1;
+eval select * from $t4 order by colint;
+eval select * from $t5 order by colint;
+eval select * from $t6 order by colint;
eval alter table $t1 drop partition p0;
eval alter table $t2 drop partition p0;
@@ -35,9 +48,9 @@ eval alter table $t4 drop partition p0;
eval alter table $t5 drop partition p0;
eval alter table $t6 drop partition p0;
-eval select * from $t1;
-eval select * from $t2;
-eval select * from $t3;
-eval select * from $t4;
-eval select * from $t5;
-eval select * from $t6;
+eval select * from $t1 order by col1;
+eval select * from $t2 order by col1;
+eval select * from $t3 order by col1;
+eval select * from $t4 order by colint;
+eval select * from $t5 order by colint;
+eval select * from $t6 order by colint;
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in
new file mode 100644
index 00000000000..8ae6e5fc807
--- /dev/null
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in
@@ -0,0 +1,4 @@
+1 1
+2 9
+3 3
+4 8 \ No newline at end of file
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_date.in b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_date.in
new file mode 100644
index 00000000000..9eb41fb007b
--- /dev/null
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_date.in
@@ -0,0 +1,4 @@
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05 \ No newline at end of file
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_float.in b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_float.in
new file mode 100644
index 00000000000..34d8b1d1c4d
--- /dev/null
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_float.in
@@ -0,0 +1,4 @@
+1 5.1230
+2 13.345
+3 17.987
+4 15.654
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_int.in b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_int.in
new file mode 100644
index 00000000000..d2f5c82a241
--- /dev/null
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_int.in
@@ -0,0 +1,45 @@
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123 \ No newline at end of file
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_time.in b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_time.in
new file mode 100644
index 00000000000..941ba418f32
--- /dev/null
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_time.in
@@ -0,0 +1,4 @@
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
diff --git a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_main.inc b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_main.inc
index ccfdd7a2ece..b0ec63d39a9 100644
--- a/mysql-test/suite/partitions/include/partition_supported_sql_funcs_main.inc
+++ b/mysql-test/suite/partitions/include/partition_supported_sql_funcs_main.inc
@@ -2,7 +2,7 @@
# t/partition_supported_sql_funcs_main.inc #
# #
# Purpose: #
-# Tests around sql functions #
+# Tests which SQL functions are allowed in partinioning clauses. #
# #
# #
#------------------------------------------------------------------------------#
@@ -11,12 +11,28 @@
# Change Author: #
# Change Date: #
# Change: #
+# #
+# This test uses a test frame (partition_supported_sql_funcs.inc) for every #
+# SQL function allowed in the partitioning parts of CREATE and ALTE TABLE. #
+# The variales represent the #
+# - SQL function isself with a column (sqlfunc) and a literal (valsqlsunc), #
+# - the type of the column (coltype), #
+# - a file with test values of the coltype (infile) and #
+# - single test values (val1 to val4). #
+# The test frame includes CREATE/ALTER TABLE and some access statements. #
+# Column types are int, float(7,4), char(1), date and time depending on the #
+# SQL function. The test frame uses the include file #
+# "partition_supported_sql_funcs_delete.inc" testing the deletion of #
+# partitions. #
+# The CREATE and ALTER TABLE statement do not cover the complete partitions #
+# functions, but will ashure that the SQL functions are basically working. #
################################################################################
let $sqlfunc = abs(col1);
let $valsqlfunc = abs(15);
let $coltype = int;
+let $infile = partition_supported_sql_funcs_int_int.in;
let $val1 = 5 ;
let $val2 = 13 ;
let $val3 = 17 ;
@@ -27,6 +43,7 @@ let $val4 = 15 ;
let $sqlfunc = ascii(col1);
let $valsqlfunc = ascii('5');
let $coltype = char(1);
+let $infile = partition_supported_sql_funcs_int_ch1.in;
let $val1 = '1';
let $val2 = '9';
let $val3 = '3';
@@ -37,6 +54,7 @@ let $val4 = '8';
let $sqlfunc = cast(ceiling(col1) as signed integer);
let $valsqlfunc = cast(ceiling(15) as signed integer);
let $coltype = float(7,4);
+let $infile = partition_supported_sql_funcs_int_float.in;
let $val1 = 5.1230;
let $val2 = 13.345;
let $val3 = 17.987;
@@ -47,6 +65,7 @@ let $val4 = 15.654 ;
let $sqlfunc = cast(floor(col1) as signed);
let $valsqlfunc = cast(floor(15.123) as signed);
let $coltype = float(7,4);
+let $infile = partition_supported_sql_funcs_int_float.in;
let $val1 = 5.1230;
let $val2 = 13.345;
let $val3 = 17.987;
@@ -57,6 +76,7 @@ let $val4 = 15.654 ;
let $sqlfunc = cast(mod(col1,10) as signed);
let $valsqlfunc = cast(mod(15,10) as signed);
let $coltype = float(7,4);
+let $infile = partition_supported_sql_funcs_int_float.in;
let $val1 = 5.0000;
let $val2 = 19;
let $val3 = 17;
@@ -67,6 +87,7 @@ let $val4 = 15 ;
let $sqlfunc = ord(col1);
let $valsqlfunc = ord('a');
let $coltype = char(3);
+let $infile = partition_supported_sql_funcs_int_ch1.in;
let $val1 = '1';
let $val2 = '9';
let $val3 = '3';
@@ -77,6 +98,7 @@ let $val4 = '8';
let $sqlfunc = day(col1);
let $valsqlfunc = day('2006-12-21');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-02-03';
let $val2 = '2006-01-17';
let $val3 = '2006-01-25';
@@ -87,6 +109,7 @@ let $val4 = '2006-02-05';
let $sqlfunc = dayofmonth(col1);
let $valsqlfunc = dayofmonth('2006-12-24');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-02-03';
let $val2 = '2006-01-17';
let $val3 = '2006-01-25';
@@ -97,6 +120,7 @@ let $val4 = '2006-02-05';
let $sqlfunc = dayofweek(col1);
let $valsqlfunc = dayofweek('2006-12-24');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-02-17';
let $val3 = '2006-01-25';
@@ -107,6 +131,7 @@ let $val4 = '2006-02-05';
let $sqlfunc = dayofyear(col1);
let $valsqlfunc = dayofyear('2006-12-25');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-01-17';
let $val3 = '2006-02-25';
@@ -120,6 +145,7 @@ let $coltype = char(30);
let $sqlfunc = extract(month from col1);
let $valsqlfunc = extract(year from '1998-11-23');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-02-17';
let $val3 = '2006-01-25';
@@ -130,6 +156,7 @@ let $val4 = '2006-02-05';
let $sqlfunc = hour(col1);
let $valsqlfunc = hour('18:30');
let $coltype = time;
+let $infile = partition_supported_sql_funcs_int_time.in;
let $val1 = '09:09';
let $val2 = '14:30';
let $val3 = '21:59';
@@ -140,6 +167,7 @@ let $val4 = '10:30';
let $sqlfunc = microsecond(col1);
let $valsqlfunc = microsecond('10:30:10.000010');
let $coltype = time;
+let $infile = partition_supported_sql_funcs_int_time.in;
let $val1 = '09:09:15.000002';
let $val2 = '04:30:01.000018';
let $val3 = '00:59:22.000024';
@@ -160,6 +188,7 @@ let $val4 = '10:24:23';
let $sqlfunc = second(col1);
let $valsqlfunc = second('18:30:14');
let $coltype = time;
+let $infile = partition_supported_sql_funcs_int_time.in;
let $val1 = '09:09:09';
let $val2 = '14:30:20';
let $val3 = '21:59:22';
@@ -173,6 +202,7 @@ let $coltype = char(30);
let $sqlfunc = month(col1);
let $valsqlfunc = month('2006-10-14');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-12-17';
let $val3 = '2006-05-25';
@@ -183,6 +213,7 @@ let $val4 = '2006-11-06';
let $sqlfunc = quarter(col1);
let $valsqlfunc = quarter('2006-10-14');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-12-17';
let $val3 = '2006-09-25';
@@ -193,6 +224,7 @@ let $val4 = '2006-07-30';
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;
+let $infile = partition_supported_sql_funcs_int_time.in;
let $val1 = '09:09:15';
let $val2 = '14:30:45';
let $val3 = '21:59:22';
@@ -203,6 +235,7 @@ let $val4 = '10:33:11';
let $sqlfunc = to_days(col1)-to_days('2006-01-01');
let $valsqlfunc = to_days('2006-02-02')-to_days('2006-01-01');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-02-03';
let $val2 = '2006-01-17';
let $val3 = '2006-01-25';
@@ -213,6 +246,7 @@ let $val4 = '2006-02-06';
let $sqlfunc = weekday(col1);
let $valsqlfunc = weekday('2006-10-14');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-12-03';
let $val2 = '2006-11-17';
let $val3 = '2006-05-25';
@@ -223,6 +257,7 @@ let $val4 = '2006-02-06';
let $sqlfunc = weekofyear(col1);
let $valsqlfunc = weekofyear('2006-02-14');
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-03-17';
let $val3 = '2006-05-25';
@@ -233,6 +268,7 @@ let $val4 = '2006-09-06';
let $sqlfunc = year(col1)-1990;
let $valsqlfunc = year('2005-10-14')-1990;
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '1996-01-03';
let $val2 = '2000-02-17';
let $val3 = '2004-05-25';
@@ -243,6 +279,7 @@ let $val4 = '2002-02-15';
let $sqlfunc = yearweek(col1)-200600;
let $valsqlfunc = yearweek('2006-10-14')-200600;
let $coltype = date;
+let $infile = partition_supported_sql_funcs_int_date.in;
let $val1 = '2006-01-03';
let $val2 = '2006-08-17';
let $val3 = '2006-03-25';
diff --git a/mysql-test/suite/partitions/r/partition_supported_sql_func_innodb.result b/mysql-test/suite/partitions/r/partition_supported_sql_func_innodb.result
index bb25ac5fc73..196f7930bb0 100644
--- a/mysql-test/suite/partitions/r/partition_supported_sql_func_innodb.result
+++ b/mysql-test/suite/partitions/r/partition_supported_sql_func_innodb.result
@@ -55,44 +55,329 @@ insert into t2 values (17 );
insert into t3 values (5 );
insert into t3 values (13 );
insert into t3 values (17 );
-insert into t4 values (1,5 );
-insert into t4 values (2,13 );
-insert into t5 values (1,5 );
-insert into t5 values (2,13 );
-insert into t5 values (3,17 );
-insert into t6 values (1,13 );
-insert into t6 values (2,17 );
-select abs(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t6;
+select abs(col1) from t1 order by col1;
abs(col1)
5
13
-select * from t1;
+select * from t1 order by col1;
col1
5
13
-select * from t2;
+select * from t2 order by col1;
col1
5
13
17
-select * from t3;
+select * from t3 order by col1;
col1
5
13
17
-select * from t4;
+select * from t4 order by colint;
colint col1
1 5
2 13
-select * from t5;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
colint col1
1 5
2 13
-3 17
-select * from t6;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t6 order by colint;
colint col1
-1 13
-2 17
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 ;
+select * from t1 order by col1;
+col1
+13
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t6 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
-------------------------------------------------------------------------
--- Alter tables with abs(col1)
-------------------------------------------------------------------------
@@ -142,33 +427,1241 @@ alter table t66
partition by range(colint)
(partition p0 values less than (abs(15)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5
13
-select * from t22;
+15
+select * from t22 order by col1;
col1
-5
13
+15
17
-select * from t33;
+select * from t33 order by col1;
col1
-5
13
+15
17
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 5
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t55 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+---------------------------
+---- 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
+13
+15
+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
+13
+15
+alter table t55
+partition by list(colint)
+subpartition by hash(abs(col1)) 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` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (abs(col1)) 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 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
2 13
-select * from t55;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 5
+1 15
2 13
-3 17
-select * from t66;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 13
-2 17
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with abs(col1)
+-------------------------------------------------------------------------
+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 ;
+select * from t1 order by col1;
+col1
+15
+select * from t2 order by col1;
+col1
+15
+17
+select * from t3 order by col1;
+col1
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 );
+select * from t1 order by col1;
+col1
+13
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t5 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t6 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+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
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t5 order by colint;
+colint col1
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t6 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with abs(col1)
+-------------------------------------------------------------------------
+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 ;
+select * from t11 order by col1;
+col1
+15
+select * from t22 order by col1;
+col1
+15
+17
+select * from t33 order by col1;
+col1
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t55 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 );
+select * from t11 order by col1;
+col1
+13
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t55 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t66 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+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
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t55 order by colint;
+colint col1
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t66 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -238,44 +1731,83 @@ insert into t2 values ('3');
insert into t3 values ('1');
insert into t3 values ('9');
insert into t3 values ('3');
-insert into t4 values (1,'1');
-insert into t4 values (2,'9');
-insert into t5 values (1,'1');
-insert into t5 values (2,'9');
-insert into t5 values (3,'3');
-insert into t6 values (1,'9');
-insert into t6 values (2,'3');
-select ascii(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t6;
+select ascii(col1) from t1 order by col1;
ascii(col1)
49
57
-select * from t1;
+select * from t1 order by col1;
col1
1
9
-select * from t2;
+select * from t2 order by col1;
col1
1
-9
3
-select * from t3;
+9
+select * from t3 order by col1;
col1
1
-9
3
-select * from t4;
+9
+select * from t4 order by colint;
colint col1
1 1
2 9
-select * from t5;
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t6 order by colint;
colint col1
1 1
2 9
3 3
-select * from t6;
+4 8
+update t1 set col1='8' where col1='1';
+update t2 set col1='8' where col1='1';
+update t3 set col1='8' where col1='1';
+update t4 set col1='8' where col1='1';
+update t5 set col1='8' where col1='1';
+update t6 set col1='8' where col1='1';
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t5 order by colint;
colint col1
-1 9
-2 3
+1 8
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
-------------------------------------------------------------------------
--- Alter tables with ascii(col1)
-------------------------------------------------------------------------
@@ -325,33 +1857,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (ascii('5')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-1
+8
9
-select * from t22;
+select * from t22 order by col1;
col1
-1
+3
+8
9
+select * from t33 order by col1;
+col1
3
-select * from t33;
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+---------------------------
+---- 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
-1
+8
9
-3
-select * from t44;
+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
+8
+9
+alter table t55
+partition by list(colint)
+subpartition by hash(ascii(col1)) 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` char(1) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (ascii(col1)) 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 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
2 9
-select * from t55;
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
2 9
3 3
-select * from t66;
+4 8
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ascii(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='9';
+delete from t2 where col1='9';
+delete from t3 where col1='9';
+delete from t4 where col1='9';
+delete from t5 where col1='9';
+delete from t6 where col1='9';
+select * from t1 order by col1;
+col1
+8
+select * from t2 order by col1;
+col1
+3
+8
+select * from t3 order by col1;
+col1
+3
+8
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t1 values ('9');
+insert into t2 values ('9');
+insert into t3 values ('9');
+insert into t4 values (60,'9');
+insert into t5 values (60,'9');
+insert into t6 values (60,'9');
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
colint col1
-1 9
-2 3
+1 8
+3 3
+4 8
+60 9
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t6 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+60 9
+select * from t5 order by colint;
+colint col1
+60 9
+select * from t6 order by colint;
+colint col1
+60 9
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ascii(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='9';
+delete from t22 where col1='9';
+delete from t33 where col1='9';
+delete from t44 where col1='9';
+delete from t55 where col1='9';
+delete from t66 where col1='9';
+select * from t11 order by col1;
+col1
+8
+select * from t22 order by col1;
+col1
+3
+8
+select * from t33 order by col1;
+col1
+3
+8
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t11 values ('9');
+insert into t22 values ('9');
+insert into t33 values ('9');
+insert into t44 values (60,'9');
+insert into t55 values (60,'9');
+insert into t66 values (60,'9');
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t66 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+60 9
+select * from t55 order by colint;
+colint col1
+60 9
+select * from t66 order by colint;
+colint col1
+60 9
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -421,44 +2231,83 @@ insert into t2 values (17.987);
insert into t3 values (5.1230);
insert into t3 values (13.345);
insert into t3 values (17.987);
-insert into t4 values (1,5.1230);
-insert into t4 values (2,13.345);
-insert into t5 values (1,5.1230);
-insert into t5 values (2,13.345);
-insert into t5 values (3,17.987);
-insert into t6 values (1,13.345);
-insert into t6 values (2,17.987);
-select cast(ceiling(col1) as signed integer) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(ceiling(col1) as signed integer) from t1 order by col1;
cast(ceiling(col1) as signed integer)
6
14
-select * from t1;
+select * from t1 order by col1;
col1
5.1230
13.3450
-select * from t2;
+select * from t2 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t3;
+select * from t3 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t4;
+select * from t4 order by colint;
colint col1
1 5.1230
2 13.3450
-select * from t5;
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
1 5.1230
2 13.3450
3 17.9870
-select * from t6;
+4 15.6540
+select * from t6 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15.654 where col1=5.1230;
+update t2 set col1=15.654 where col1=5.1230;
+update t3 set col1=15.654 where col1=5.1230;
+update t4 set col1=15.654 where col1=5.1230;
+update t5 set col1=15.654 where col1=5.1230;
+update t6 set col1=15.654 where col1=5.1230;
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
-------------------------------------------------------------------------
--- Alter tables with cast(ceiling(col1) as signed integer)
-------------------------------------------------------------------------
@@ -508,33 +2357,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (cast(ceiling(15) as signed integer)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5.1230
13.3450
-select * from t22;
+15.6540
+select * from t22 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t33;
+select * from t33 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 5.1230
+1 15.6540
2 13.3450
-select * from t55;
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
colint col1
-1 5.1230
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+13.3450
+15.6540
+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
+13.3450
+15.6540
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) 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` float(7,4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(ceiling(col1) as signed integer)) 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 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
2 13.3450
3 17.9870
-select * from t66;
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+delete from t1 where col1=13.345;
+delete from t2 where col1=13.345;
+delete from t3 where col1=13.345;
+delete from t4 where col1=13.345;
+delete from t5 where col1=13.345;
+delete from t6 where col1=13.345;
+select * from t1 order by col1;
+col1
+15.6540
+select * from t2 order by col1;
+col1
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t1 values (13.345);
+insert into t2 values (13.345);
+insert into t3 values (13.345);
+insert into t4 values (60,13.345);
+insert into t5 values (60,13.345);
+insert into t6 values (60,13.345);
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t6 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+60 13.3450
+select * from t5 order by colint;
+colint col1
+60 13.3450
+select * from t6 order by colint;
+colint col1
+60 13.3450
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+delete from t11 where col1=13.345;
+delete from t22 where col1=13.345;
+delete from t33 where col1=13.345;
+delete from t44 where col1=13.345;
+delete from t55 where col1=13.345;
+delete from t66 where col1=13.345;
+select * from t11 order by col1;
+col1
+15.6540
+select * from t22 order by col1;
+col1
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t11 values (13.345);
+insert into t22 values (13.345);
+insert into t33 values (13.345);
+insert into t44 values (60,13.345);
+insert into t55 values (60,13.345);
+insert into t66 values (60,13.345);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t66 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+60 13.3450
+select * from t55 order by colint;
+colint col1
+60 13.3450
+select * from t66 order by colint;
+colint col1
+60 13.3450
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -604,44 +2729,83 @@ insert into t2 values (17.987);
insert into t3 values (5.1230);
insert into t3 values (13.345);
insert into t3 values (17.987);
-insert into t4 values (1,5.1230);
-insert into t4 values (2,13.345);
-insert into t5 values (1,5.1230);
-insert into t5 values (2,13.345);
-insert into t5 values (3,17.987);
-insert into t6 values (1,13.345);
-insert into t6 values (2,17.987);
-select cast(floor(col1) as signed) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(floor(col1) as signed) from t1 order by col1;
cast(floor(col1) as signed)
5
13
-select * from t1;
+select * from t1 order by col1;
col1
5.1230
13.3450
-select * from t2;
+select * from t2 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t3;
+select * from t3 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t4;
+select * from t4 order by colint;
colint col1
1 5.1230
2 13.3450
-select * from t5;
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
1 5.1230
2 13.3450
3 17.9870
-select * from t6;
+4 15.6540
+select * from t6 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15.654 where col1=5.1230;
+update t2 set col1=15.654 where col1=5.1230;
+update t3 set col1=15.654 where col1=5.1230;
+update t4 set col1=15.654 where col1=5.1230;
+update t5 set col1=15.654 where col1=5.1230;
+update t6 set col1=15.654 where col1=5.1230;
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
-------------------------------------------------------------------------
--- Alter tables with cast(floor(col1) as signed)
-------------------------------------------------------------------------
@@ -691,33 +2855,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (cast(floor(15.123) as signed)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5.1230
13.3450
-select * from t22;
+15.6540
+select * from t22 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t33;
+select * from t33 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 5.1230
+1 15.6540
2 13.3450
-select * from t55;
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
colint col1
-1 5.1230
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+13.3450
+15.6540
+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
+13.3450
+15.6540
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(floor(col1) as signed)) 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` float(7,4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(floor(col1) as signed)) 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 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
2 13.3450
3 17.9870
-select * from t66;
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+delete from t1 where col1=13.345;
+delete from t2 where col1=13.345;
+delete from t3 where col1=13.345;
+delete from t4 where col1=13.345;
+delete from t5 where col1=13.345;
+delete from t6 where col1=13.345;
+select * from t1 order by col1;
+col1
+15.6540
+select * from t2 order by col1;
+col1
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t1 values (13.345);
+insert into t2 values (13.345);
+insert into t3 values (13.345);
+insert into t4 values (60,13.345);
+insert into t5 values (60,13.345);
+insert into t6 values (60,13.345);
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t6 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+60 13.3450
+select * from t5 order by colint;
+colint col1
+60 13.3450
+select * from t6 order by colint;
+colint col1
+60 13.3450
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+delete from t11 where col1=13.345;
+delete from t22 where col1=13.345;
+delete from t33 where col1=13.345;
+delete from t44 where col1=13.345;
+delete from t55 where col1=13.345;
+delete from t66 where col1=13.345;
+select * from t11 order by col1;
+col1
+15.6540
+select * from t22 order by col1;
+col1
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t11 values (13.345);
+insert into t22 values (13.345);
+insert into t33 values (13.345);
+insert into t44 values (60,13.345);
+insert into t55 values (60,13.345);
+insert into t66 values (60,13.345);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t66 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+60 13.3450
+select * from t55 order by colint;
+colint col1
+60 13.3450
+select * from t66 order by colint;
+colint col1
+60 13.3450
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -787,44 +3227,83 @@ insert into t2 values (17);
insert into t3 values (5.0000);
insert into t3 values (19);
insert into t3 values (17);
-insert into t4 values (1,5.0000);
-insert into t4 values (2,19);
-insert into t5 values (1,5.0000);
-insert into t5 values (2,19);
-insert into t5 values (3,17);
-insert into t6 values (1,19);
-insert into t6 values (2,17);
-select cast(mod(col1,10) as signed) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(mod(col1,10) as signed) from t1 order by col1;
cast(mod(col1,10) as signed)
5
9
-select * from t1;
+select * from t1 order by col1;
col1
5.0000
19.0000
-select * from t2;
+select * from t2 order by col1;
col1
5.0000
-19.0000
17.0000
-select * from t3;
+19.0000
+select * from t3 order by col1;
col1
5.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15 where col1=5.0000;
+update t2 set col1=15 where col1=5.0000;
+update t3 set col1=15 where col1=5.0000;
+update t4 set col1=15 where col1=5.0000;
+update t5 set col1=15 where col1=5.0000;
+update t6 set col1=15 where col1=5.0000;
+select * from t1 order by col1;
+col1
+15.0000
+19.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
19.0000
+select * from t3 order by col1;
+col1
+15.0000
17.0000
-select * from t4;
+19.0000
+select * from t4 order by colint;
colint col1
-1 5.0000
-2 19.0000
-select * from t5;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
-1 5.0000
-2 19.0000
-3 17.0000
-select * from t6;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
colint col1
-1 19.0000
-2 17.0000
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
-------------------------------------------------------------------------
--- Alter tables with cast(mod(col1,10) as signed)
-------------------------------------------------------------------------
@@ -874,33 +3353,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (cast(mod(15,10) as signed)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5.0000
+15.0000
19.0000
-select * from t22;
+select * from t22 order by col1;
col1
-5.0000
+15.0000
+17.0000
19.0000
+select * from t33 order by col1;
+col1
+15.0000
17.0000
-select * from t33;
+19.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
-5.0000
+15.0000
19.0000
+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
+15.0000
+19.0000
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) 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` float(7,4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(mod(col1,10) as signed)) 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 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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;
+select * from t1 order by col1;
+col1
+15.0000
+select * from t2 order by col1;
+col1
+15.0000
17.0000
-select * from t44;
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+select * from t4 order by colint;
colint col1
-1 5.0000
-2 19.0000
-select * from t55;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
-1 5.0000
-2 19.0000
-3 17.0000
-select * from t66;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+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);
+select * from t1 order by col1;
+col1
+15.0000
+19.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+60 19.0000
+select * from t5 order by colint;
+colint col1
+60 19.0000
+select * from t6 order by colint;
+colint col1
+60 19.0000
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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;
+select * from t11 order by col1;
+col1
+15.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+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);
+select * from t11 order by col1;
+col1
+15.0000
+19.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+60 19.0000
+select * from t55 order by colint;
+colint col1
+60 19.0000
+select * from t66 order by colint;
colint col1
-1 19.0000
-2 17.0000
+60 19.0000
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -970,44 +3727,83 @@ insert into t2 values ('3');
insert into t3 values ('1');
insert into t3 values ('9');
insert into t3 values ('3');
-insert into t4 values (1,'1');
-insert into t4 values (2,'9');
-insert into t5 values (1,'1');
-insert into t5 values (2,'9');
-insert into t5 values (3,'3');
-insert into t6 values (1,'9');
-insert into t6 values (2,'3');
-select ord(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t6;
+select ord(col1) from t1 order by col1;
ord(col1)
49
57
-select * from t1;
+select * from t1 order by col1;
col1
1
9
-select * from t2;
+select * from t2 order by col1;
col1
1
-9
3
-select * from t3;
+9
+select * from t3 order by col1;
col1
1
-9
3
-select * from t4;
+9
+select * from t4 order by colint;
colint col1
1 1
2 9
-select * from t5;
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t6 order by colint;
colint col1
1 1
2 9
3 3
-select * from t6;
+4 8
+update t1 set col1='8' where col1='1';
+update t2 set col1='8' where col1='1';
+update t3 set col1='8' where col1='1';
+update t4 set col1='8' where col1='1';
+update t5 set col1='8' where col1='1';
+update t6 set col1='8' where col1='1';
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t5 order by colint;
colint col1
-1 9
-2 3
+1 8
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
-------------------------------------------------------------------------
--- Alter tables with ord(col1)
-------------------------------------------------------------------------
@@ -1057,33 +3853,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (ord('a')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-1
+8
9
-select * from t22;
+select * from t22 order by col1;
col1
-1
+3
+8
9
+select * from t33 order by col1;
+col1
3
-select * from t33;
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+---------------------------
+---- 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
-1
+8
9
-3
-select * from t44;
+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
+8
+9
+alter table t55
+partition by list(colint)
+subpartition by hash(ord(col1)) 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` char(3) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (ord(col1)) 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 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
2 9
-select * from t55;
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
2 9
3 3
-select * from t66;
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ord(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='9';
+delete from t2 where col1='9';
+delete from t3 where col1='9';
+delete from t4 where col1='9';
+delete from t5 where col1='9';
+delete from t6 where col1='9';
+select * from t1 order by col1;
+col1
+8
+select * from t2 order by col1;
+col1
+3
+8
+select * from t3 order by col1;
+col1
+3
+8
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t1 values ('9');
+insert into t2 values ('9');
+insert into t3 values ('9');
+insert into t4 values (60,'9');
+insert into t5 values (60,'9');
+insert into t6 values (60,'9');
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t6 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+60 9
+select * from t5 order by colint;
+colint col1
+60 9
+select * from t6 order by colint;
colint col1
-1 9
-2 3
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ord(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='9';
+delete from t22 where col1='9';
+delete from t33 where col1='9';
+delete from t44 where col1='9';
+delete from t55 where col1='9';
+delete from t66 where col1='9';
+select * from t11 order by col1;
+col1
+8
+select * from t22 order by col1;
+col1
+3
+8
+select * from t33 order by col1;
+col1
+3
+8
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t11 values ('9');
+insert into t22 values ('9');
+insert into t33 values ('9');
+insert into t44 values (60,'9');
+insert into t55 values (60,'9');
+insert into t66 values (60,'9');
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t66 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+60 9
+select * from t55 order by colint;
+colint col1
+60 9
+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 ;
@@ -1153,44 +4225,83 @@ 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');
-insert into t4 values (1,'2006-02-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-02-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-01-25');
-select day(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select day(col1) from t1 order by col1;
day(col1)
-3
17
-select * from t1;
+3
+select * from t1 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t2;
-col1
2006-02-03
+select * from t2 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t3;
-col1
2006-02-03
+select * from t3 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t4;
+2006-02-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
3 2006-01-25
-select * from t6;
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with day(col1)
-------------------------------------------------------------------------
@@ -1240,33 +4351,307 @@ alter table t66
partition by range(colint)
(partition p0 values less than (day('2006-12-21')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t33;
+2006-02-05
+select * from t33 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t44;
+2006-02-05
+select * from t44 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
2 2006-01-17
3 2006-01-25
-select * from t66;
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(day(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (day(col1)) 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 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with day(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with day(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -1336,44 +4721,83 @@ 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');
-insert into t4 values (1,'2006-02-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-02-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-01-25');
-select dayofmonth(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofmonth(col1) from t1 order by col1;
dayofmonth(col1)
-3
17
-select * from t1;
+3
+select * from t1 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t2;
-col1
2006-02-03
+select * from t2 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t3;
-col1
2006-02-03
+select * from t3 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t4;
+2006-02-03
+select * from t4 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
3 2006-01-25
-select * from t6;
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofmonth(col1)
-------------------------------------------------------------------------
@@ -1423,33 +4847,307 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofmonth('2006-12-24')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t33;
+2006-02-05
+select * from t33 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t44;
+2006-02-05
+select * from t44 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
2 2006-01-17
3 2006-01-25
-select * from t66;
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofmonth(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofmonth(col1)) 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 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -1519,44 +5217,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-02-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-02-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-02-17');
-insert into t6 values (2,'2006-01-25');
-select dayofweek(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofweek(col1) from t1 order by col1;
dayofweek(col1)
3
6
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-02-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
-2006-02-17
2006-01-25
-select * from t3;
+2006-02-17
+select * from t3 order by col1;
col1
2006-01-03
+2006-01-25
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
2006-02-17
+select * from t2 order by col1;
+col1
2006-01-25
-select * from t4;
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-02-17
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-1 2006-01-03
-select * from t6;
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofweek(col1)
-------------------------------------------------------------------------
@@ -1606,33 +5343,319 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofweek('2006-12-24')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-02-05
2006-02-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
+2006-01-25
+2006-02-05
2006-02-17
+select * from t33 order by col1;
+col1
2006-01-25
-select * from t33;
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
+2006-02-05
2006-02-17
+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
+2006-02-05
+2006-02-17
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofweek(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofweek(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
2006-01-25
-select * from t44;
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t55;
+60 2006-02-17
+select * from t5 order by colint;
colint col1
-2 2006-02-17
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-1 2006-01-03
-select * from t66;
+4 2006-02-05
+60 2006-02-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -1702,44 +5725,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-02-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-02-25');
-select dayofyear(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofyear(col1) from t1 order by col1;
dayofyear(col1)
3
17
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-01-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t6;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofyear(col1)
-------------------------------------------------------------------------
@@ -1789,33 +5851,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofyear('2006-12-25')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t33;
+select * from t33 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t66;
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofyear(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+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 ;
@@ -1885,44 +6223,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-02-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-02-25');
-select dayofyear(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofyear(col1) from t1 order by col1;
dayofyear(col1)
3
17
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-01-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
2 2006-01-17
-select * from t6;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofyear(col1)
-------------------------------------------------------------------------
@@ -1972,33 +6349,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofyear('2006-12-25')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t33;
+select * from t33 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t66;
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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` char(30) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofyear(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+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 ;
@@ -2068,44 +6721,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-02-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-02-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-02-17');
-insert into t6 values (2,'2006-01-25');
-select extract(month from col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select extract(month from col1) from t1 order by col1;
extract(month from col1)
1
2
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-02-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
-2006-02-17
2006-01-25
-select * from t3;
+2006-02-17
+select * from t3 order by col1;
col1
2006-01-03
+2006-01-25
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
2006-02-17
+select * from t3 order by col1;
+col1
2006-01-25
-select * from t4;
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-select * from t6;
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with extract(month from col1)
-------------------------------------------------------------------------
@@ -2155,33 +6847,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (extract(year from '1998-11-23')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-02-05
2006-02-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
+2006-01-25
+2006-02-05
2006-02-17
+select * from t33 order by col1;
+col1
2006-01-25
-select * from t33;
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
+2006-02-05
+2006-02-17
+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
+2006-02-05
+2006-02-17
+alter table t55
+partition by list(colint)
+subpartition by hash(extract(month from col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (extract(month from col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with extract(month from col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
2006-02-17
+select * from t3 order by col1;
+col1
2006-01-25
-select * from t44;
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t5 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-select * from t66;
+4 2006-02-05
+60 2006-02-17
+select * from t6 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with extract(month from col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+60 2006-02-17
+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 ;
@@ -2251,44 +7219,83 @@ insert into t2 values ('21:59');
insert into t3 values ('09:09');
insert into t3 values ('14:30');
insert into t3 values ('21:59');
-insert into t4 values (1,'09:09');
-insert into t4 values (2,'14:30');
-insert into t5 values (1,'09:09');
-insert into t5 values (2,'14:30');
-insert into t5 values (3,'21:59');
-insert into t6 values (1,'14:30');
-insert into t6 values (2,'21:59');
-select hour(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select hour(col1) from t1 order by col1;
hour(col1)
9
14
-select * from t1;
+select * from t1 order by col1;
col1
09:09:00
14:30:00
-select * from t2;
+select * from t2 order by col1;
col1
09:09:00
14:30:00
21:59:00
-select * from t3;
+select * from t3 order by col1;
col1
09:09:00
14:30:00
21:59:00
-select * from t4;
+select * from t4 order by colint;
colint col1
-2 14:30:00
-1 09:09:00
-select * from t5;
+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
-2 14:30:00
-1 09:09:00
-3 21:59:00
-select * from t6;
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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';
+select * from t1 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
colint col1
-1 14:30:00
-2 21:59:00
+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
-------------------------------------------------------------------------
--- Alter tables with hour(col1)
-------------------------------------------------------------------------
@@ -2338,33 +7345,315 @@ alter table t66
partition by range(colint)
(partition p0 values less than (hour('18:30')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:00
+10:30:00
14:30:00
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:00
+10:30:00
14:30:00
21:59:00
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:00
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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:30:00
+14:30:00
+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:30:00
+14:30:00
+alter table t55
+partition by list(colint)
+subpartition by hash(hour(col1)) 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 (hour(col1)) 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 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with hour(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+21:59:00
+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
+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');
+select * from t1 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t5 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t6 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+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
+select * from t2 order by col1;
+col1
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
+colint col1
+60 14:30:00
+select * from t5 order by colint;
+colint col1
+60 14:30:00
+select * from t6 order by colint;
+colint col1
+60 14:30:00
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with hour(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+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
+select * from t22 order by col1;
+col1
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
14:30:00
21:59:00
-select * from t44;
+select * from t44 order by colint;
colint col1
-2 14:30:00
-1 09:09:00
-select * from t55;
+60 14:30:00
+select * from t55 order by colint;
colint col1
-2 14:30:00
-1 09:09:00
-3 21:59:00
-select * from t66;
+60 14:30:00
+select * from t66 order by colint;
colint col1
-1 14:30:00
-2 21:59:00
+60 14:30:00
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2434,44 +7723,83 @@ 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');
-insert into t4 values (1,'09:09:15.000002');
-insert into t4 values (2,'04:30:01.000018');
-insert into t5 values (1,'09:09:15.000002');
-insert into t5 values (2,'04:30:01.000018');
-insert into t5 values (3,'00:59:22.000024');
-insert into t6 values (1,'04:30:01.000018');
-insert into t6 values (2,'00:59:22.000024');
-select microsecond(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select microsecond(col1) from t1 order by col1;
microsecond(col1)
0
0
-select * from t1;
+select * from t1 order by col1;
col1
+04:30:01
09:09:15
+select * from t2 order by col1;
+col1
+00:59:22
04:30:01
-select * from t2;
+09:09:15
+select * from t3 order by col1;
col1
+00:59:22
+04:30:01
09:09:15
+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='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';
+select * from t1 order by col1;
+col1
04:30:01
-00:59:22
-select * from t3;
+05:30:34
+select * from t2 order by col1;
col1
-09:09:15
+00:59:22
04:30:01
+05:30:34
+select * from t3 order by col1;
+col1
00:59:22
-select * from t4;
+04:30:01
+05:30:34
+select * from t4 order by colint;
colint col1
-1 09:09:15
+1 05:30:34
2 04:30:01
-select * from t5;
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
colint col1
-1 09:09:15
+1 05:30:34
2 04:30:01
3 00:59:22
-select * from t6;
+4 05:30:34
+select * from t6 order by colint;
colint col1
-1 04:30:01
-2 00:59:22
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
-------------------------------------------------------------------------
--- Alter tables with microsecond(col1)
-------------------------------------------------------------------------
@@ -2521,33 +7849,301 @@ alter table t66
partition by range(colint)
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:15
04:30:01
-select * from t22;
+05:30:34
+select * from t22 order by col1;
col1
-09:09:15
+00:59:22
04:30:01
+05:30:34
+select * from t33 order by col1;
+col1
00:59:22
-select * from t33;
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 05:30:34
+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
-09:09:15
04:30:01
-00:59:22
-select * from t44;
+05:30:34
+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
+alter table t55
+partition by list(colint)
+subpartition by hash(microsecond(col1)) 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 (microsecond(col1)) 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 05:30:34
+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 09:09:15
+1 05:30:34
2 04:30:01
-select * from t55;
+3 00:59:22
+4 05:30:34
+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 09:09:15
+1 05:30:34
+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 05:30:34
2 04:30:01
3 00:59:22
-select * from t66;
+4 05:30:34
+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
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with microsecond(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
colint col1
-1 04:30:01
-2 00:59:22
+1 05:30:34
+3 00:59:22
+4 05:30:34
+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');
+select * from t1 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t5 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t6 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+60 04:30:01
+select * from t5 order by colint;
+colint col1
+60 04:30:01
+select * from t6 order by colint;
+colint col1
+60 04:30:01
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with microsecond(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t66 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+60 04:30:01
+select * from t55 order by colint;
+colint col1
+60 04:30:01
+select * from t66 order by colint;
+colint col1
+60 04:30:01
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2617,44 +8213,83 @@ 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');
-insert into t4 values (1,'09:09:15');
-insert into t4 values (2,'14:30:45');
-insert into t5 values (1,'09:09:15');
-insert into t5 values (2,'14:30:45');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:45');
-insert into t6 values (2,'21:59:22');
-select minute(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select minute(col1) from t1 order by col1;
minute(col1)
9
30
-select * from t1;
+select * from t1 order by col1;
col1
09:09:15
14:30:45
-select * from t2;
+select * from t2 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t4;
+select * from t4 order by colint;
colint col1
-2 14:30:45
1 09:09:15
-select * from t5;
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
colint col1
-2 14:30:45
1 09:09:15
-3 21:59:22
-select * from t6;
+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: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';
+select * from t1 order by col1;
+col1
+10:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t4 order by colint;
colint col1
-1 14:30:45
-2 21:59:22
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t6 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
-------------------------------------------------------------------------
--- Alter tables with minute(col1)
-------------------------------------------------------------------------
@@ -2704,33 +8339,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (minute('18:30')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:15
+10:24:23
14:30:45
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:15
+10:24:23
14:30:45
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:15
+10:24:23
14:30:45
21:59:22
-select * from t44;
+select * from t44 order by colint;
colint col1
-2 14:30:45
-1 09:09:15
-select * from t55;
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
colint col1
-2 14:30:45
-1 09:09:15
-3 21:59:22
-select * from t66;
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
colint col1
-1 14:30:45
-2 21:59:22
+1 10:24:23
+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:24:23
+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:24:23
+14:30:45
+alter table t55
+partition by list(colint)
+subpartition by hash(minute(col1)) 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 (minute(col1)) 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:24:23
+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:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with minute(col1)
+-------------------------------------------------------------------------
+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:24:23
+select * from t2 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+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:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+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
+60 14:30:45
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with minute(col1)
+-------------------------------------------------------------------------
+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:24:23
+select * from t22 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+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:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+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
+60 14:30:45
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2800,44 +8723,83 @@ 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');
-insert into t4 values (1,'09:09:09');
-insert into t4 values (2,'14:30:20');
-insert into t5 values (1,'09:09:09');
-insert into t5 values (2,'14:30:20');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:20');
-insert into t6 values (2,'21:59:22');
-select second(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select second(col1) from t1 order by col1;
second(col1)
9
20
-select * from t1;
+select * from t1 order by col1;
col1
09:09:09
14:30:20
-select * from t2;
+select * from t2 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t4;
+select * from t4 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t5;
+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: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';
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+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
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t6;
+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 14:30:20
-2 21:59:22
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
-------------------------------------------------------------------------
--- Alter tables with second(col1)
-------------------------------------------------------------------------
@@ -2887,33 +8849,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (second('18:30:14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t44;
+select * from t44 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t55;
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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:22:33
+14:30:20
+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:22:33
+14:30:20
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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 (second(col1)) 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 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+select * from t2 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t4 order by colint;
colint col1
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t66;
+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 14:30:20
-2 21:59:22
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+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
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+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:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+60 14:30:20
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:22:33
+select * from t22 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+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:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+60 14:30:20
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2983,44 +9233,83 @@ 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');
-insert into t4 values (1,'09:09:09');
-insert into t4 values (2,'14:30:20');
-insert into t5 values (1,'09:09:09');
-insert into t5 values (2,'14:30:20');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:20');
-insert into t6 values (2,'21:59:22');
-select second(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select second(col1) from t1 order by col1;
second(col1)
9
20
-select * from t1;
+select * from t1 order by col1;
col1
09:09:09
14:30:20
-select * from t2;
+select * from t2 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t4;
+select * from t4 order by colint;
+colint col1
+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.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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t5;
+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
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t6;
+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 14:30:20
-2 21:59:22
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
-------------------------------------------------------------------------
--- Alter tables with second(col1)
-------------------------------------------------------------------------
@@ -3070,33 +9359,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (second('18:30:14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t44;
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+---------------------------
+---- 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:22:33
+14:30:20
+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:22:33
+14:30:20
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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` char(30) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (second(col1)) 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 09:09:15.000002
+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 09:09:15.000002
+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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t55;
+1 09:09:15.000002
+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 09:09:15.000002
+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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t66;
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+select * from t2 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t4 order by colint;
+colint col1
+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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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');
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+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:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+60 14:30:20
+select * from t5 order by colint;
colint col1
-1 14:30:20
-2 21:59:22
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+60 14:30:20
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:22:33
+select * from t22 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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');
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+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:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+60 14:30:20
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3166,44 +9743,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-12-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-12-17');
-insert into t5 values (3,'2006-05-25');
-insert into t6 values (1,'2006-12-17');
-insert into t6 values (2,'2006-05-25');
-select month(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select month(col1) from t1 order by col1;
month(col1)
1
12
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-12-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-05-25
2006-12-17
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
+2006-05-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-11-06
2006-12-17
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
2006-05-25
-select * from t4;
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-12-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with month(col1)
-------------------------------------------------------------------------
@@ -3253,33 +9869,315 @@ alter table t66
partition by range(colint)
(partition p0 values less than (month('2006-10-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-11-06
2006-12-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
2006-05-25
+2006-11-06
2006-12-17
-select * from t33;
+select * from t33 order by col1;
col1
-2006-01-03
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-11-06
+2006-12-17
+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
+2006-11-06
+2006-12-17
+alter table t55
+partition by list(colint)
+subpartition by hash(month(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (month(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with month(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-11-06
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t2 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+60 2006-12-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with month(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-11-06
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t22 order by col1;
+col1
+2006-11-06
2006-12-17
+select * from t33 order by col1;
+col1
2006-05-25
-select * from t44;
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t55;
+60 2006-12-17
+select * from t55 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-05-25
-select * from t66;
+60 2006-12-17
+select * from t66 order by colint;
colint col1
-1 2006-12-17
-2 2006-05-25
+60 2006-12-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3349,44 +10247,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-12-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-12-17');
-insert into t5 values (3,'2006-09-25');
-insert into t6 values (1,'2006-12-17');
-insert into t6 values (2,'2006-09-25');
-select quarter(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select quarter(col1) from t1 order by col1;
quarter(col1)
1
4
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-12-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
-2006-12-17
2006-09-25
-select * from t3;
+2006-12-17
+select * from t3 order by col1;
col1
2006-01-03
+2006-09-25
2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-07-30
2006-09-25
-select * from t4;
+2006-12-17
+select * from t4 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-09-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-12-17
-2 2006-09-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with quarter(col1)
-------------------------------------------------------------------------
@@ -3436,33 +10373,313 @@ alter table t66
partition by range(colint)
(partition p0 values less than (quarter('2006-10-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-07-30
2006-12-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
+2006-07-30
+2006-09-25
2006-12-17
+select * from t33 order by col1;
+col1
+2006-07-30
2006-09-25
-select * from t33;
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
+2006-07-30
2006-12-17
+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
+2006-07-30
+2006-12-17
+alter table t55
+partition by list(colint)
+subpartition by hash(quarter(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (quarter(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with quarter(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-07-30
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+4 2006-02-05
+60 2006-12-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with quarter(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-07-30
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-07-30
2006-09-25
-select * from t44;
+2006-12-17
+select * from t44 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t55 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-09-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t66 order by colint;
colint col1
-1 2006-12-17
-2 2006-09-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t44 order by colint;
+colint col1
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+4 2006-02-05
+60 2006-12-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3532,44 +10749,83 @@ 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');
-insert into t4 values (1,'09:09:15');
-insert into t4 values (2,'14:30:45');
-insert into t5 values (1,'09:09:15');
-insert into t5 values (2,'14:30:45');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:45');
-insert into t6 values (2,'21:59:22');
-select time_to_sec(col1)-(time_to_sec(col1)-20) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' 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;
+select * from t1 order by col1;
col1
09:09:15
14:30:45
-select * from t2;
+select * from t2 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t4;
+select * from t4 order by colint;
colint col1
1 09:09:15
-2 14:30:45
-select * from t5;
+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 14:30:45
-3 21:59:22
-select * from t6;
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t6 order by colint;
colint col1
-1 14:30:45
-2 21:59:22
+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)
-------------------------------------------------------------------------
@@ -3619,33 +10875,319 @@ 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;
+select * from t11 order by col1;
col1
-09:09:15
+10:33:11
14:30:45
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:15
+10:33:11
14:30:45
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:15
+10:33:11
14:30:45
21:59:22
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 09:09:15
-2 14:30:45
-select * from t55;
+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 09:09:15
-2 14:30:45
-3 21:59:22
-select * from t66;
+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 14:30:45
-2 21:59:22
+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 ;
@@ -3715,44 +11257,83 @@ 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');
-insert into t4 values (1,'2006-02-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-02-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-01-25');
-select to_days(col1)-to_days('2006-01-01') from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select to_days(col1)-to_days('2006-01-01') from t1 order by col1;
to_days(col1)-to_days('2006-01-01')
-33
16
-select * from t1;
+33
+select * from t1 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t2;
+2006-02-03
+select * from t2 order by col1;
col1
2006-01-17
2006-01-25
2006-02-03
-select * from t3;
+select * from t3 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t4;
+2006-02-03
+select * from t4 order by colint;
colint col1
-2 2006-01-17
1 2006-02-03
-select * from t5;
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
+1 2006-02-03
2 2006-01-17
3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
1 2006-02-03
-select * from t6;
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+update t1 set col1='2006-02-06' where col1='2006-02-03';
+update t2 set col1='2006-02-06' where col1='2006-02-03';
+update t3 set col1='2006-02-06' where col1='2006-02-03';
+update t4 set col1='2006-02-06' where col1='2006-02-03';
+update t5 set col1='2006-02-06' where col1='2006-02-03';
+update t6 set col1='2006-02-06' where col1='2006-02-03';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with to_days(col1)-to_days('2006-01-01')
-------------------------------------------------------------------------
@@ -3802,33 +11383,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t22;
+2006-02-06
+select * from t22 order by col1;
col1
2006-01-17
2006-01-25
-2006-02-03
-select * from t33;
+2006-02-06
+select * from t33 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t44;
+2006-02-06
+select * from t44 order by colint;
colint col1
+1 2006-02-06
2 2006-01-17
-1 2006-02-03
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
+1 2006-02-06
2 2006-01-17
3 2006-01-25
-1 2006-02-03
-select * from t66;
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-06
+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
+2006-01-17
+2006-02-06
+alter table t55
+partition by list(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (to_days(col1)-to_days('2006-01-01')) 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 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3898,44 +11757,83 @@ 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');
-insert into t4 values (1,'2006-12-03');
-insert into t4 values (2,'2006-11-17');
-insert into t5 values (1,'2006-12-03');
-insert into t5 values (2,'2006-11-17');
-insert into t5 values (3,'2006-05-25');
-insert into t6 values (1,'2006-11-17');
-insert into t6 values (2,'2006-05-25');
-select weekday(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select weekday(col1) from t1 order by col1;
weekday(col1)
-6
4
-select * from t1;
+6
+select * from t1 order by col1;
col1
+2006-11-17
2006-12-03
+select * from t2 order by col1;
+col1
+2006-05-25
2006-11-17
-select * from t2;
+2006-12-03
+select * from t3 order by col1;
col1
+2006-05-25
+2006-11-17
2006-12-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
2006-11-17
-2006-05-25
-select * from t3;
+select * from t2 order by col1;
col1
-2006-12-03
+2006-02-06
+2006-05-25
2006-11-17
+select * from t3 order by col1;
+col1
+2006-02-06
2006-05-25
-select * from t4;
+2006-11-17
+select * from t4 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-3 2006-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-11-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with weekday(col1)
-------------------------------------------------------------------------
@@ -3985,33 +11883,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (weekday('2006-10-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-12-03
+2006-02-06
2006-11-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-12-03
+2006-02-06
+2006-05-25
2006-11-17
+select * from t33 order by col1;
+col1
+2006-02-06
2006-05-25
-select * from t33;
+2006-11-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-12-03
+2006-02-06
2006-11-17
+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
+2006-02-06
+2006-11-17
+alter table t55
+partition by list(colint)
+subpartition by hash(weekday(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (weekday(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekday(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+60 2006-11-17
+select * from t5 order by colint;
+colint col1
+60 2006-11-17
+select * from t6 order by colint;
+colint col1
+60 2006-11-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekday(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t33 order by col1;
+col1
+2006-02-06
2006-05-25
-select * from t44;
+2006-11-17
+select * from t44 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t55 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-3 2006-05-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t66 order by colint;
colint col1
-1 2006-11-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t44 order by colint;
+colint col1
+60 2006-11-17
+select * from t55 order by colint;
+colint col1
+60 2006-11-17
+select * from t66 order by colint;
+colint col1
+60 2006-11-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -4081,44 +12257,83 @@ insert into t2 values ('2006-05-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-03-17');
insert into t3 values ('2006-05-25');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-03-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-03-17');
-insert into t5 values (3,'2006-05-25');
-insert into t6 values (1,'2006-03-17');
-insert into t6 values (2,'2006-05-25');
-select weekofyear(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select weekofyear(col1) from t1 order by col1;
weekofyear(col1)
1
11
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-03-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-03-17
2006-05-25
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
2006-03-17
2006-05-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-3 2006-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-03-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+update t1 set col1='2006-09-06' where col1='2006-01-03';
+update t2 set col1='2006-09-06' where col1='2006-01-03';
+update t3 set col1='2006-09-06' where col1='2006-01-03';
+update t4 set col1='2006-09-06' where col1='2006-01-03';
+update t5 set col1='2006-09-06' where col1='2006-01-03';
+update t6 set col1='2006-09-06' where col1='2006-01-03';
+select * from t1 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with weekofyear(col1)
-------------------------------------------------------------------------
@@ -4168,33 +12383,319 @@ alter table t66
partition by range(colint)
(partition p0 values less than (weekofyear('2006-02-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-03-17
-select * from t22;
+2006-09-06
+select * from t22 order by col1;
col1
-2006-01-03
2006-03-17
2006-05-25
-select * from t33;
+2006-09-06
+select * from t33 order by col1;
col1
-2006-01-03
2006-03-17
2006-05-25
-select * from t44;
+2006-09-06
+select * from t44 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-3 2006-05-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-03-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-03-17
+2006-09-06
+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
+2006-03-17
+2006-09-06
+alter table t55
+partition by list(colint)
+subpartition by hash(weekofyear(col1)) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (weekofyear(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekofyear(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='2006-03-17';
+delete from t2 where col1='2006-03-17';
+delete from t3 where col1='2006-03-17';
+delete from t4 where col1='2006-03-17';
+delete from t5 where col1='2006-03-17';
+delete from t6 where col1='2006-03-17';
+select * from t1 order by col1;
+col1
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+insert into t1 values ('2006-03-17');
+insert into t2 values ('2006-03-17');
+insert into t3 values ('2006-03-17');
+insert into t4 values (60,'2006-03-17');
+insert into t5 values (60,'2006-03-17');
+insert into t6 values (60,'2006-03-17');
+select * from t1 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+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
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+60 2006-03-17
+select * from t5 order by colint;
+colint col1
+60 2006-03-17
+select * from t6 order by colint;
+colint col1
+60 2006-03-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekofyear(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='2006-03-17';
+delete from t22 where col1='2006-03-17';
+delete from t33 where col1='2006-03-17';
+delete from t44 where col1='2006-03-17';
+delete from t55 where col1='2006-03-17';
+delete from t66 where col1='2006-03-17';
+select * from t11 order by col1;
+col1
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+insert into t11 values ('2006-03-17');
+insert into t22 values ('2006-03-17');
+insert into t33 values ('2006-03-17');
+insert into t44 values (60,'2006-03-17');
+insert into t55 values (60,'2006-03-17');
+insert into t66 values (60,'2006-03-17');
+select * from t11 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+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
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+60 2006-03-17
+select * from t55 order by colint;
+colint col1
+60 2006-03-17
+select * from t66 order by colint;
+colint col1
+60 2006-03-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -4264,44 +12765,83 @@ 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');
-insert into t4 values (1,'1996-01-03');
-insert into t4 values (2,'2000-02-17');
-insert into t5 values (1,'1996-01-03');
-insert into t5 values (2,'2000-02-17');
-insert into t5 values (3,'2004-05-25');
-insert into t6 values (1,'2000-02-17');
-insert into t6 values (2,'2004-05-25');
-select year(col1)-1990 from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select year(col1)-1990 from t1 order by col1;
year(col1)-1990
6
10
-select * from t1;
+select * from t1 order by col1;
col1
1996-01-03
2000-02-17
-select * from t2;
+select * from t2 order by col1;
col1
1996-01-03
2000-02-17
2004-05-25
-select * from t3;
+select * from t3 order by col1;
col1
1996-01-03
2000-02-17
2004-05-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-3 2004-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t2 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
colint col1
-1 2000-02-17
-2 2004-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with year(col1)-1990
-------------------------------------------------------------------------
@@ -4351,33 +12891,315 @@ alter table t66
partition by range(colint)
(partition p0 values less than (year('2005-10-14')-1990),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-1996-01-03
2000-02-17
-select * from t22;
+2002-02-15
+select * from t22 order by col1;
col1
-1996-01-03
2000-02-17
+2002-02-15
2004-05-25
-select * from t33;
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2000-02-17
+2002-02-15
+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
+2000-02-17
+2002-02-15
+alter table t55
+partition by list(colint)
+subpartition by hash(year(col1)-1990) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (year(col1)-1990) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with year(col1)-1990
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2002-02-15
+select * from t2 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t2 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+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
+select * from t2 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+60 2000-02-17
+select * from t5 order by colint;
+colint col1
+60 2000-02-17
+select * from t6 order by colint;
+colint col1
+60 2000-02-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with year(col1)-1990
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2002-02-15
+select * from t22 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
col1
-1996-01-03
2000-02-17
+2002-02-15
+select * from t22 order by col1;
+col1
+2000-02-17
+2002-02-15
2004-05-25
-select * from t44;
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t55 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t66 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-3 2004-05-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+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
+select * from t22 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
colint col1
-1 2000-02-17
-2 2004-05-25
+60 2000-02-17
+select * from t55 order by colint;
+colint col1
+60 2000-02-17
+select * from t66 order by colint;
+colint col1
+60 2000-02-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -4447,44 +13269,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-08-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-08-17');
-insert into t5 values (3,'2006-03-25');
-insert into t6 values (1,'2006-08-17');
-insert into t6 values (2,'2006-03-25');
-select yearweek(col1)-200600 from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select yearweek(col1)-200600 from t1 order by col1;
yearweek(col1)-200600
1
33
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-08-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-03-25
2006-08-17
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
+2006-03-25
2006-08-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
2006-03-25
-select * from t4;
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
colint col1
-1 2006-01-03
-2 2006-08-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-3 2006-03-25
-1 2006-01-03
-2 2006-08-17
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-08-17
-2 2006-03-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with yearweek(col1)-200600
-------------------------------------------------------------------------
@@ -4534,33 +13395,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (yearweek('2006-10-14')-200600),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-08-17
-select * from t22;
+2006-11-15
+select * from t22 order by col1;
col1
-2006-01-03
2006-03-25
2006-08-17
-select * from t33;
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
2006-08-17
+2006-11-15
+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
+2006-08-17
+2006-11-15
+alter table t55
+partition by list(colint)
+subpartition by hash(yearweek(col1)-200600) 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` date DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (yearweek(col1)-200600) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+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
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
2006-03-25
-select * from t44;
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+60 2006-08-17
+select * from t5 order by colint;
+colint col1
+60 2006-08-17
+select * from t6 order by colint;
+colint col1
+60 2006-08-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+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
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
colint col1
-1 2006-01-03
-2 2006-08-17
-select * from t55;
+60 2006-08-17
+select * from t55 order by colint;
colint col1
-3 2006-03-25
-1 2006-01-03
-2 2006-08-17
-select * from t66;
+60 2006-08-17
+select * from t66 order by colint;
colint col1
-1 2006-08-17
-2 2006-03-25
+60 2006-08-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
diff --git a/mysql-test/suite/partitions/r/partition_supported_sql_func_myisam.result b/mysql-test/suite/partitions/r/partition_supported_sql_func_myisam.result
index 73d69e5c90a..86742038990 100644
--- a/mysql-test/suite/partitions/r/partition_supported_sql_func_myisam.result
+++ b/mysql-test/suite/partitions/r/partition_supported_sql_func_myisam.result
@@ -55,44 +55,329 @@ insert into t2 values (17 );
insert into t3 values (5 );
insert into t3 values (13 );
insert into t3 values (17 );
-insert into t4 values (1,5 );
-insert into t4 values (2,13 );
-insert into t5 values (1,5 );
-insert into t5 values (2,13 );
-insert into t5 values (3,17 );
-insert into t6 values (1,13 );
-insert into t6 values (2,17 );
-select abs(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t6;
+select abs(col1) from t1 order by col1;
abs(col1)
5
13
-select * from t1;
+select * from t1 order by col1;
col1
5
13
-select * from t2;
+select * from t2 order by col1;
col1
5
13
17
-select * from t3;
+select * from t3 order by col1;
col1
5
13
17
-select * from t4;
+select * from t4 order by colint;
colint col1
1 5
2 13
-select * from t5;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
colint col1
1 5
2 13
-3 17
-select * from t6;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t6 order by colint;
colint col1
-1 13
-2 17
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 ;
+select * from t1 order by col1;
+col1
+13
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t6 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
-------------------------------------------------------------------------
--- Alter tables with abs(col1)
-------------------------------------------------------------------------
@@ -142,33 +427,1241 @@ alter table t66
partition by range(colint)
(partition p0 values less than (abs(15)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5
13
-select * from t22;
+15
+select * from t22 order by col1;
col1
-5
13
+15
17
-select * from t33;
+select * from t33 order by col1;
col1
-5
13
+15
17
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 5
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t55 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+---------------------------
+---- 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
+13
+15
+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
+13
+15
+alter table t55
+partition by list(colint)
+subpartition by hash(abs(col1)) 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` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (abs(col1)) 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 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
2 13
-select * from t55;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 5
+1 15
2 13
-3 17
-select * from t66;
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 13
-2 17
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with abs(col1)
+-------------------------------------------------------------------------
+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 ;
+select * from t1 order by col1;
+col1
+15
+select * from t2 order by col1;
+col1
+15
+17
+select * from t3 order by col1;
+col1
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 );
+select * from t1 order by col1;
+col1
+13
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t5 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t6 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+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
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t5 order by colint;
+colint col1
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t6 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with abs(col1)
+-------------------------------------------------------------------------
+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 ;
+select * from t11 order by col1;
+col1
+15
+select * from t22 order by col1;
+col1
+15
+17
+select * from t33 order by col1;
+col1
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t55 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 );
+select * from t11 order by col1;
+col1
+13
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t55 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t66 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+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
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t55 order by colint;
+colint col1
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t66 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -238,44 +1731,83 @@ insert into t2 values ('3');
insert into t3 values ('1');
insert into t3 values ('9');
insert into t3 values ('3');
-insert into t4 values (1,'1');
-insert into t4 values (2,'9');
-insert into t5 values (1,'1');
-insert into t5 values (2,'9');
-insert into t5 values (3,'3');
-insert into t6 values (1,'9');
-insert into t6 values (2,'3');
-select ascii(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t6;
+select ascii(col1) from t1 order by col1;
ascii(col1)
49
57
-select * from t1;
+select * from t1 order by col1;
col1
1
9
-select * from t2;
+select * from t2 order by col1;
col1
1
-9
3
-select * from t3;
+9
+select * from t3 order by col1;
col1
1
-9
3
-select * from t4;
+9
+select * from t4 order by colint;
colint col1
1 1
2 9
-select * from t5;
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t6 order by colint;
colint col1
1 1
2 9
3 3
-select * from t6;
+4 8
+update t1 set col1='8' where col1='1';
+update t2 set col1='8' where col1='1';
+update t3 set col1='8' where col1='1';
+update t4 set col1='8' where col1='1';
+update t5 set col1='8' where col1='1';
+update t6 set col1='8' where col1='1';
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t5 order by colint;
colint col1
-1 9
-2 3
+1 8
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
-------------------------------------------------------------------------
--- Alter tables with ascii(col1)
-------------------------------------------------------------------------
@@ -325,33 +1857,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (ascii('5')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-1
+8
9
-select * from t22;
+select * from t22 order by col1;
col1
-1
+3
+8
9
+select * from t33 order by col1;
+col1
3
-select * from t33;
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+---------------------------
+---- 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
-1
+8
9
-3
-select * from t44;
+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
+8
+9
+alter table t55
+partition by list(colint)
+subpartition by hash(ascii(col1)) 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` char(1) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (ascii(col1)) 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 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
2 9
-select * from t55;
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
2 9
3 3
-select * from t66;
+4 8
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ascii(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='9';
+delete from t2 where col1='9';
+delete from t3 where col1='9';
+delete from t4 where col1='9';
+delete from t5 where col1='9';
+delete from t6 where col1='9';
+select * from t1 order by col1;
+col1
+8
+select * from t2 order by col1;
+col1
+3
+8
+select * from t3 order by col1;
+col1
+3
+8
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t1 values ('9');
+insert into t2 values ('9');
+insert into t3 values ('9');
+insert into t4 values (60,'9');
+insert into t5 values (60,'9');
+insert into t6 values (60,'9');
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
colint col1
-1 9
-2 3
+1 8
+3 3
+4 8
+60 9
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t6 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+60 9
+select * from t5 order by colint;
+colint col1
+60 9
+select * from t6 order by colint;
+colint col1
+60 9
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ascii(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='9';
+delete from t22 where col1='9';
+delete from t33 where col1='9';
+delete from t44 where col1='9';
+delete from t55 where col1='9';
+delete from t66 where col1='9';
+select * from t11 order by col1;
+col1
+8
+select * from t22 order by col1;
+col1
+3
+8
+select * from t33 order by col1;
+col1
+3
+8
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t11 values ('9');
+insert into t22 values ('9');
+insert into t33 values ('9');
+insert into t44 values (60,'9');
+insert into t55 values (60,'9');
+insert into t66 values (60,'9');
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t66 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+60 9
+select * from t55 order by colint;
+colint col1
+60 9
+select * from t66 order by colint;
+colint col1
+60 9
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -421,44 +2231,83 @@ insert into t2 values (17.987);
insert into t3 values (5.1230);
insert into t3 values (13.345);
insert into t3 values (17.987);
-insert into t4 values (1,5.1230);
-insert into t4 values (2,13.345);
-insert into t5 values (1,5.1230);
-insert into t5 values (2,13.345);
-insert into t5 values (3,17.987);
-insert into t6 values (1,13.345);
-insert into t6 values (2,17.987);
-select cast(ceiling(col1) as signed integer) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(ceiling(col1) as signed integer) from t1 order by col1;
cast(ceiling(col1) as signed integer)
6
14
-select * from t1;
+select * from t1 order by col1;
col1
5.1230
13.3450
-select * from t2;
+select * from t2 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t3;
+select * from t3 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t4;
+select * from t4 order by colint;
colint col1
1 5.1230
2 13.3450
-select * from t5;
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
1 5.1230
2 13.3450
3 17.9870
-select * from t6;
+4 15.6540
+select * from t6 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15.654 where col1=5.1230;
+update t2 set col1=15.654 where col1=5.1230;
+update t3 set col1=15.654 where col1=5.1230;
+update t4 set col1=15.654 where col1=5.1230;
+update t5 set col1=15.654 where col1=5.1230;
+update t6 set col1=15.654 where col1=5.1230;
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
-------------------------------------------------------------------------
--- Alter tables with cast(ceiling(col1) as signed integer)
-------------------------------------------------------------------------
@@ -508,33 +2357,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (cast(ceiling(15) as signed integer)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5.1230
13.3450
-select * from t22;
+15.6540
+select * from t22 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t33;
+select * from t33 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 5.1230
+1 15.6540
2 13.3450
-select * from t55;
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
colint col1
-1 5.1230
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+13.3450
+15.6540
+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
+13.3450
+15.6540
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) 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` float(7,4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(ceiling(col1) as signed integer)) 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 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
2 13.3450
3 17.9870
-select * from t66;
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+delete from t1 where col1=13.345;
+delete from t2 where col1=13.345;
+delete from t3 where col1=13.345;
+delete from t4 where col1=13.345;
+delete from t5 where col1=13.345;
+delete from t6 where col1=13.345;
+select * from t1 order by col1;
+col1
+15.6540
+select * from t2 order by col1;
+col1
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t1 values (13.345);
+insert into t2 values (13.345);
+insert into t3 values (13.345);
+insert into t4 values (60,13.345);
+insert into t5 values (60,13.345);
+insert into t6 values (60,13.345);
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t6 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+60 13.3450
+select * from t5 order by colint;
+colint col1
+60 13.3450
+select * from t6 order by colint;
+colint col1
+60 13.3450
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+delete from t11 where col1=13.345;
+delete from t22 where col1=13.345;
+delete from t33 where col1=13.345;
+delete from t44 where col1=13.345;
+delete from t55 where col1=13.345;
+delete from t66 where col1=13.345;
+select * from t11 order by col1;
+col1
+15.6540
+select * from t22 order by col1;
+col1
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t11 values (13.345);
+insert into t22 values (13.345);
+insert into t33 values (13.345);
+insert into t44 values (60,13.345);
+insert into t55 values (60,13.345);
+insert into t66 values (60,13.345);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t66 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+60 13.3450
+select * from t55 order by colint;
+colint col1
+60 13.3450
+select * from t66 order by colint;
+colint col1
+60 13.3450
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -604,44 +2729,83 @@ insert into t2 values (17.987);
insert into t3 values (5.1230);
insert into t3 values (13.345);
insert into t3 values (17.987);
-insert into t4 values (1,5.1230);
-insert into t4 values (2,13.345);
-insert into t5 values (1,5.1230);
-insert into t5 values (2,13.345);
-insert into t5 values (3,17.987);
-insert into t6 values (1,13.345);
-insert into t6 values (2,17.987);
-select cast(floor(col1) as signed) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(floor(col1) as signed) from t1 order by col1;
cast(floor(col1) as signed)
5
13
-select * from t1;
+select * from t1 order by col1;
col1
5.1230
13.3450
-select * from t2;
+select * from t2 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t3;
+select * from t3 order by col1;
col1
5.1230
13.3450
17.9870
-select * from t4;
+select * from t4 order by colint;
colint col1
1 5.1230
2 13.3450
-select * from t5;
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
1 5.1230
2 13.3450
3 17.9870
-select * from t6;
+4 15.6540
+select * from t6 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15.654 where col1=5.1230;
+update t2 set col1=15.654 where col1=5.1230;
+update t3 set col1=15.654 where col1=5.1230;
+update t4 set col1=15.654 where col1=5.1230;
+update t5 set col1=15.654 where col1=5.1230;
+update t6 set col1=15.654 where col1=5.1230;
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
-------------------------------------------------------------------------
--- Alter tables with cast(floor(col1) as signed)
-------------------------------------------------------------------------
@@ -691,33 +2855,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (cast(floor(15.123) as signed)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5.1230
13.3450
-select * from t22;
+15.6540
+select * from t22 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t33;
+select * from t33 order by col1;
col1
-5.1230
13.3450
+15.6540
17.9870
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 5.1230
+1 15.6540
2 13.3450
-select * from t55;
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
colint col1
-1 5.1230
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+13.3450
+15.6540
+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
+13.3450
+15.6540
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(floor(col1) as signed)) 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` float(7,4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(floor(col1) as signed)) 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 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
2 13.3450
3 17.9870
-select * from t66;
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 13.3450
-2 17.9870
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+delete from t1 where col1=13.345;
+delete from t2 where col1=13.345;
+delete from t3 where col1=13.345;
+delete from t4 where col1=13.345;
+delete from t5 where col1=13.345;
+delete from t6 where col1=13.345;
+select * from t1 order by col1;
+col1
+15.6540
+select * from t2 order by col1;
+col1
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t1 values (13.345);
+insert into t2 values (13.345);
+insert into t3 values (13.345);
+insert into t4 values (60,13.345);
+insert into t5 values (60,13.345);
+insert into t6 values (60,13.345);
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t6 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+60 13.3450
+select * from t5 order by colint;
+colint col1
+60 13.3450
+select * from t6 order by colint;
+colint col1
+60 13.3450
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+delete from t11 where col1=13.345;
+delete from t22 where col1=13.345;
+delete from t33 where col1=13.345;
+delete from t44 where col1=13.345;
+delete from t55 where col1=13.345;
+delete from t66 where col1=13.345;
+select * from t11 order by col1;
+col1
+15.6540
+select * from t22 order by col1;
+col1
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t11 values (13.345);
+insert into t22 values (13.345);
+insert into t33 values (13.345);
+insert into t44 values (60,13.345);
+insert into t55 values (60,13.345);
+insert into t66 values (60,13.345);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t66 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+60 13.3450
+select * from t55 order by colint;
+colint col1
+60 13.3450
+select * from t66 order by colint;
+colint col1
+60 13.3450
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -787,44 +3227,83 @@ insert into t2 values (17);
insert into t3 values (5.0000);
insert into t3 values (19);
insert into t3 values (17);
-insert into t4 values (1,5.0000);
-insert into t4 values (2,19);
-insert into t5 values (1,5.0000);
-insert into t5 values (2,19);
-insert into t5 values (3,17);
-insert into t6 values (1,19);
-insert into t6 values (2,17);
-select cast(mod(col1,10) as signed) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(mod(col1,10) as signed) from t1 order by col1;
cast(mod(col1,10) as signed)
5
9
-select * from t1;
+select * from t1 order by col1;
col1
5.0000
19.0000
-select * from t2;
+select * from t2 order by col1;
col1
5.0000
-19.0000
17.0000
-select * from t3;
+19.0000
+select * from t3 order by col1;
col1
5.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15 where col1=5.0000;
+update t2 set col1=15 where col1=5.0000;
+update t3 set col1=15 where col1=5.0000;
+update t4 set col1=15 where col1=5.0000;
+update t5 set col1=15 where col1=5.0000;
+update t6 set col1=15 where col1=5.0000;
+select * from t1 order by col1;
+col1
+15.0000
+19.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
19.0000
+select * from t3 order by col1;
+col1
+15.0000
17.0000
-select * from t4;
+19.0000
+select * from t4 order by colint;
colint col1
-1 5.0000
-2 19.0000
-select * from t5;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
-1 5.0000
-2 19.0000
-3 17.0000
-select * from t6;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
colint col1
-1 19.0000
-2 17.0000
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
-------------------------------------------------------------------------
--- Alter tables with cast(mod(col1,10) as signed)
-------------------------------------------------------------------------
@@ -874,33 +3353,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (cast(mod(15,10) as signed)),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-5.0000
+15.0000
19.0000
-select * from t22;
+select * from t22 order by col1;
col1
-5.0000
+15.0000
+17.0000
19.0000
+select * from t33 order by col1;
+col1
+15.0000
17.0000
-select * from t33;
+19.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
-5.0000
+15.0000
19.0000
+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
+15.0000
+19.0000
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) 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` float(7,4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(mod(col1,10) as signed)) 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 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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;
+select * from t1 order by col1;
+col1
+15.0000
+select * from t2 order by col1;
+col1
+15.0000
17.0000
-select * from t44;
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+select * from t4 order by colint;
colint col1
-1 5.0000
-2 19.0000
-select * from t55;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
colint col1
-1 5.0000
-2 19.0000
-3 17.0000
-select * from t66;
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+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);
+select * from t1 order by col1;
+col1
+15.0000
+19.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+60 19.0000
+select * from t5 order by colint;
+colint col1
+60 19.0000
+select * from t6 order by colint;
+colint col1
+60 19.0000
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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;
+select * from t11 order by col1;
+col1
+15.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+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);
+select * from t11 order by col1;
+col1
+15.0000
+19.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+60 19.0000
+select * from t55 order by colint;
+colint col1
+60 19.0000
+select * from t66 order by colint;
colint col1
-1 19.0000
-2 17.0000
+60 19.0000
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -970,44 +3727,83 @@ insert into t2 values ('3');
insert into t3 values ('1');
insert into t3 values ('9');
insert into t3 values ('3');
-insert into t4 values (1,'1');
-insert into t4 values (2,'9');
-insert into t5 values (1,'1');
-insert into t5 values (2,'9');
-insert into t5 values (3,'3');
-insert into t6 values (1,'9');
-insert into t6 values (2,'3');
-select ord(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t6;
+select ord(col1) from t1 order by col1;
ord(col1)
49
57
-select * from t1;
+select * from t1 order by col1;
col1
1
9
-select * from t2;
+select * from t2 order by col1;
col1
1
-9
3
-select * from t3;
+9
+select * from t3 order by col1;
col1
1
-9
3
-select * from t4;
+9
+select * from t4 order by colint;
colint col1
1 1
2 9
-select * from t5;
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t6 order by colint;
colint col1
1 1
2 9
3 3
-select * from t6;
+4 8
+update t1 set col1='8' where col1='1';
+update t2 set col1='8' where col1='1';
+update t3 set col1='8' where col1='1';
+update t4 set col1='8' where col1='1';
+update t5 set col1='8' where col1='1';
+update t6 set col1='8' where col1='1';
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t5 order by colint;
colint col1
-1 9
-2 3
+1 8
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
-------------------------------------------------------------------------
--- Alter tables with ord(col1)
-------------------------------------------------------------------------
@@ -1057,33 +3853,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (ord('a')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-1
+8
9
-select * from t22;
+select * from t22 order by col1;
col1
-1
+3
+8
9
+select * from t33 order by col1;
+col1
3
-select * from t33;
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+---------------------------
+---- 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
-1
+8
9
-3
-select * from t44;
+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
+8
+9
+alter table t55
+partition by list(colint)
+subpartition by hash(ord(col1)) 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` char(3) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (ord(col1)) 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 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
2 9
-select * from t55;
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-1 1
+1 8
2 9
3 3
-select * from t66;
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ord(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='9';
+delete from t2 where col1='9';
+delete from t3 where col1='9';
+delete from t4 where col1='9';
+delete from t5 where col1='9';
+delete from t6 where col1='9';
+select * from t1 order by col1;
+col1
+8
+select * from t2 order by col1;
+col1
+3
+8
+select * from t3 order by col1;
+col1
+3
+8
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t1 values ('9');
+insert into t2 values ('9');
+insert into t3 values ('9');
+insert into t4 values (60,'9');
+insert into t5 values (60,'9');
+insert into t6 values (60,'9');
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t6 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+60 9
+select * from t5 order by colint;
+colint col1
+60 9
+select * from t6 order by colint;
colint col1
-1 9
-2 3
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ord(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='9';
+delete from t22 where col1='9';
+delete from t33 where col1='9';
+delete from t44 where col1='9';
+delete from t55 where col1='9';
+delete from t66 where col1='9';
+select * from t11 order by col1;
+col1
+8
+select * from t22 order by col1;
+col1
+3
+8
+select * from t33 order by col1;
+col1
+3
+8
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t11 values ('9');
+insert into t22 values ('9');
+insert into t33 values ('9');
+insert into t44 values (60,'9');
+insert into t55 values (60,'9');
+insert into t66 values (60,'9');
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t66 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+60 9
+select * from t55 order by colint;
+colint col1
+60 9
+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 ;
@@ -1153,44 +4225,83 @@ 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');
-insert into t4 values (1,'2006-02-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-02-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-01-25');
-select day(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select day(col1) from t1 order by col1;
day(col1)
-3
17
-select * from t1;
+3
+select * from t1 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t2;
-col1
2006-02-03
+select * from t2 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t3;
-col1
2006-02-03
+select * from t3 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t4;
+2006-02-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
3 2006-01-25
-select * from t6;
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with day(col1)
-------------------------------------------------------------------------
@@ -1240,33 +4351,307 @@ alter table t66
partition by range(colint)
(partition p0 values less than (day('2006-12-21')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t33;
+2006-02-05
+select * from t33 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t44;
+2006-02-05
+select * from t44 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
2 2006-01-17
3 2006-01-25
-select * from t66;
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(day(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (day(col1)) 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 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with day(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with day(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -1336,44 +4721,83 @@ 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');
-insert into t4 values (1,'2006-02-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-02-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-01-25');
-select dayofmonth(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofmonth(col1) from t1 order by col1;
dayofmonth(col1)
-3
17
-select * from t1;
+3
+select * from t1 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t2;
-col1
2006-02-03
+select * from t2 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t3;
-col1
2006-02-03
+select * from t3 order by col1;
+col1
2006-01-17
2006-01-25
-select * from t4;
+2006-02-03
+select * from t4 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
1 2006-02-03
2 2006-01-17
3 2006-01-25
-select * from t6;
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofmonth(col1)
-------------------------------------------------------------------------
@@ -1423,33 +4847,307 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofmonth('2006-12-24')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t33;
+2006-02-05
+select * from t33 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t44;
+2006-02-05
+select * from t44 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-02-03
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
2 2006-01-17
3 2006-01-25
-select * from t66;
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofmonth(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofmonth(col1)) 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 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -1519,44 +5217,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-02-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-02-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-02-17');
-insert into t6 values (2,'2006-01-25');
-select dayofweek(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofweek(col1) from t1 order by col1;
dayofweek(col1)
3
6
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-02-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
-2006-02-17
2006-01-25
-select * from t3;
+2006-02-17
+select * from t3 order by col1;
col1
2006-01-03
+2006-01-25
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
2006-02-17
+select * from t2 order by col1;
+col1
2006-01-25
-select * from t4;
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-02-17
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-1 2006-01-03
-select * from t6;
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofweek(col1)
-------------------------------------------------------------------------
@@ -1606,33 +5343,319 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofweek('2006-12-24')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-02-05
2006-02-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
+2006-01-25
+2006-02-05
2006-02-17
+select * from t33 order by col1;
+col1
2006-01-25
-select * from t33;
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
+2006-02-05
2006-02-17
+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
+2006-02-05
+2006-02-17
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofweek(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofweek(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
2006-01-25
-select * from t44;
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t55;
+60 2006-02-17
+select * from t5 order by colint;
colint col1
-2 2006-02-17
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-1 2006-01-03
-select * from t66;
+4 2006-02-05
+60 2006-02-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -1702,44 +5725,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-02-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-02-25');
-select dayofyear(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofyear(col1) from t1 order by col1;
dayofyear(col1)
3
17
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-01-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t6;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofyear(col1)
-------------------------------------------------------------------------
@@ -1789,33 +5851,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofyear('2006-12-25')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t33;
+select * from t33 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t66;
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofyear(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+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 ;
@@ -1885,44 +6223,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-02-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-02-25');
-select dayofyear(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofyear(col1) from t1 order by col1;
dayofyear(col1)
3
17
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-01-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
2006-01-17
2006-02-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
2 2006-01-17
-select * from t5;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
2 2006-01-17
-select * from t6;
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with dayofyear(col1)
-------------------------------------------------------------------------
@@ -1972,33 +6349,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (dayofyear('2006-12-25')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-01-17
-select * from t22;
+2006-02-05
+select * from t22 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t33;
+select * from t33 order by col1;
col1
-2006-01-03
2006-01-17
+2006-02-05
2006-02-25
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-3 2006-02-25
-1 2006-01-03
+1 2006-02-03
2 2006-01-17
-select * from t66;
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-01-17
-2 2006-02-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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` char(30) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofyear(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+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 ;
@@ -2068,44 +6721,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-02-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-02-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-02-17');
-insert into t6 values (2,'2006-01-25');
-select extract(month from col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select extract(month from col1) from t1 order by col1;
extract(month from col1)
1
2
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-02-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
-2006-02-17
2006-01-25
-select * from t3;
+2006-02-17
+select * from t3 order by col1;
col1
2006-01-03
+2006-01-25
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
2006-02-17
+select * from t3 order by col1;
+col1
2006-01-25
-select * from t4;
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-select * from t6;
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with extract(month from col1)
-------------------------------------------------------------------------
@@ -2155,33 +6847,309 @@ alter table t66
partition by range(colint)
(partition p0 values less than (extract(year from '1998-11-23')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-02-05
2006-02-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
+2006-01-25
+2006-02-05
2006-02-17
+select * from t33 order by col1;
+col1
2006-01-25
-select * from t33;
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
+2006-02-05
+2006-02-17
+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
+2006-02-05
+2006-02-17
+alter table t55
+partition by list(colint)
+subpartition by hash(extract(month from col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (extract(month from col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with extract(month from col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
2006-02-17
+select * from t3 order by col1;
+col1
2006-01-25
-select * from t44;
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t5 order by colint;
colint col1
-2 2006-02-17
-1 2006-01-03
+1 2006-02-03
+2 2006-01-17
3 2006-01-25
-select * from t66;
+4 2006-02-05
+60 2006-02-17
+select * from t6 order by colint;
colint col1
-1 2006-02-17
-2 2006-01-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with extract(month from col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+60 2006-02-17
+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 ;
@@ -2251,44 +7219,83 @@ insert into t2 values ('21:59');
insert into t3 values ('09:09');
insert into t3 values ('14:30');
insert into t3 values ('21:59');
-insert into t4 values (1,'09:09');
-insert into t4 values (2,'14:30');
-insert into t5 values (1,'09:09');
-insert into t5 values (2,'14:30');
-insert into t5 values (3,'21:59');
-insert into t6 values (1,'14:30');
-insert into t6 values (2,'21:59');
-select hour(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select hour(col1) from t1 order by col1;
hour(col1)
9
14
-select * from t1;
+select * from t1 order by col1;
col1
09:09:00
14:30:00
-select * from t2;
+select * from t2 order by col1;
col1
09:09:00
14:30:00
21:59:00
-select * from t3;
+select * from t3 order by col1;
col1
09:09:00
14:30:00
21:59:00
-select * from t4;
+select * from t4 order by colint;
colint col1
-2 14:30:00
-1 09:09:00
-select * from t5;
+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
-2 14:30:00
-1 09:09:00
-3 21:59:00
-select * from t6;
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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';
+select * from t1 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
colint col1
-1 14:30:00
-2 21:59:00
+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
-------------------------------------------------------------------------
--- Alter tables with hour(col1)
-------------------------------------------------------------------------
@@ -2338,33 +7345,315 @@ alter table t66
partition by range(colint)
(partition p0 values less than (hour('18:30')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:00
+10:30:00
14:30:00
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:00
+10:30:00
14:30:00
21:59:00
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:00
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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:30:00
+14:30:00
+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:30:00
+14:30:00
+alter table t55
+partition by list(colint)
+subpartition by hash(hour(col1)) 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 (hour(col1)) 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 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with hour(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+21:59:00
+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
+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');
+select * from t1 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t5 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t6 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+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
+select * from t2 order by col1;
+col1
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
+colint col1
+60 14:30:00
+select * from t5 order by colint;
+colint col1
+60 14:30:00
+select * from t6 order by colint;
+colint col1
+60 14:30:00
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with hour(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+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
+select * from t22 order by col1;
+col1
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
14:30:00
21:59:00
-select * from t44;
+select * from t44 order by colint;
colint col1
-2 14:30:00
-1 09:09:00
-select * from t55;
+60 14:30:00
+select * from t55 order by colint;
colint col1
-2 14:30:00
-1 09:09:00
-3 21:59:00
-select * from t66;
+60 14:30:00
+select * from t66 order by colint;
colint col1
-1 14:30:00
-2 21:59:00
+60 14:30:00
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2434,44 +7723,83 @@ 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');
-insert into t4 values (1,'09:09:15.000002');
-insert into t4 values (2,'04:30:01.000018');
-insert into t5 values (1,'09:09:15.000002');
-insert into t5 values (2,'04:30:01.000018');
-insert into t5 values (3,'00:59:22.000024');
-insert into t6 values (1,'04:30:01.000018');
-insert into t6 values (2,'00:59:22.000024');
-select microsecond(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select microsecond(col1) from t1 order by col1;
microsecond(col1)
0
0
-select * from t1;
+select * from t1 order by col1;
col1
+04:30:01
09:09:15
+select * from t2 order by col1;
+col1
+00:59:22
04:30:01
-select * from t2;
+09:09:15
+select * from t3 order by col1;
col1
+00:59:22
+04:30:01
09:09:15
+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='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';
+select * from t1 order by col1;
+col1
04:30:01
-00:59:22
-select * from t3;
+05:30:34
+select * from t2 order by col1;
col1
-09:09:15
+00:59:22
04:30:01
+05:30:34
+select * from t3 order by col1;
+col1
00:59:22
-select * from t4;
+04:30:01
+05:30:34
+select * from t4 order by colint;
colint col1
-1 09:09:15
+1 05:30:34
2 04:30:01
-select * from t5;
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
colint col1
-1 09:09:15
+1 05:30:34
2 04:30:01
3 00:59:22
-select * from t6;
+4 05:30:34
+select * from t6 order by colint;
colint col1
-1 04:30:01
-2 00:59:22
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
-------------------------------------------------------------------------
--- Alter tables with microsecond(col1)
-------------------------------------------------------------------------
@@ -2521,33 +7849,301 @@ alter table t66
partition by range(colint)
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:15
04:30:01
-select * from t22;
+05:30:34
+select * from t22 order by col1;
col1
-09:09:15
+00:59:22
04:30:01
+05:30:34
+select * from t33 order by col1;
+col1
00:59:22
-select * from t33;
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 05:30:34
+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
-09:09:15
04:30:01
-00:59:22
-select * from t44;
+05:30:34
+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
+alter table t55
+partition by list(colint)
+subpartition by hash(microsecond(col1)) 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 (microsecond(col1)) 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 05:30:34
+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 09:09:15
+1 05:30:34
2 04:30:01
-select * from t55;
+3 00:59:22
+4 05:30:34
+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 09:09:15
+1 05:30:34
+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 05:30:34
2 04:30:01
3 00:59:22
-select * from t66;
+4 05:30:34
+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
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with microsecond(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
colint col1
-1 04:30:01
-2 00:59:22
+1 05:30:34
+3 00:59:22
+4 05:30:34
+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');
+select * from t1 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t5 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t6 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+60 04:30:01
+select * from t5 order by colint;
+colint col1
+60 04:30:01
+select * from t6 order by colint;
+colint col1
+60 04:30:01
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with microsecond(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t66 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+60 04:30:01
+select * from t55 order by colint;
+colint col1
+60 04:30:01
+select * from t66 order by colint;
+colint col1
+60 04:30:01
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2617,44 +8213,83 @@ 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');
-insert into t4 values (1,'09:09:15');
-insert into t4 values (2,'14:30:45');
-insert into t5 values (1,'09:09:15');
-insert into t5 values (2,'14:30:45');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:45');
-insert into t6 values (2,'21:59:22');
-select minute(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select minute(col1) from t1 order by col1;
minute(col1)
9
30
-select * from t1;
+select * from t1 order by col1;
col1
09:09:15
14:30:45
-select * from t2;
+select * from t2 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t4;
+select * from t4 order by colint;
colint col1
-2 14:30:45
1 09:09:15
-select * from t5;
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
colint col1
-2 14:30:45
1 09:09:15
-3 21:59:22
-select * from t6;
+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: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';
+select * from t1 order by col1;
+col1
+10:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t4 order by colint;
colint col1
-1 14:30:45
-2 21:59:22
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t6 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
-------------------------------------------------------------------------
--- Alter tables with minute(col1)
-------------------------------------------------------------------------
@@ -2704,33 +8339,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (minute('18:30')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:15
+10:24:23
14:30:45
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:15
+10:24:23
14:30:45
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:15
+10:24:23
14:30:45
21:59:22
-select * from t44;
+select * from t44 order by colint;
colint col1
-2 14:30:45
-1 09:09:15
-select * from t55;
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
colint col1
-2 14:30:45
-1 09:09:15
-3 21:59:22
-select * from t66;
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
colint col1
-1 14:30:45
-2 21:59:22
+1 10:24:23
+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:24:23
+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:24:23
+14:30:45
+alter table t55
+partition by list(colint)
+subpartition by hash(minute(col1)) 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 (minute(col1)) 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:24:23
+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:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with minute(col1)
+-------------------------------------------------------------------------
+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:24:23
+select * from t2 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+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:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+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
+60 14:30:45
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with minute(col1)
+-------------------------------------------------------------------------
+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:24:23
+select * from t22 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+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:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+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
+60 14:30:45
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2800,44 +8723,83 @@ 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');
-insert into t4 values (1,'09:09:09');
-insert into t4 values (2,'14:30:20');
-insert into t5 values (1,'09:09:09');
-insert into t5 values (2,'14:30:20');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:20');
-insert into t6 values (2,'21:59:22');
-select second(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select second(col1) from t1 order by col1;
second(col1)
9
20
-select * from t1;
+select * from t1 order by col1;
col1
09:09:09
14:30:20
-select * from t2;
+select * from t2 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t4;
+select * from t4 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t5;
+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: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';
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+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
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t6;
+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 14:30:20
-2 21:59:22
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
-------------------------------------------------------------------------
--- Alter tables with second(col1)
-------------------------------------------------------------------------
@@ -2887,33 +8849,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (second('18:30:14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t44;
+select * from t44 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t55;
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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:22:33
+14:30:20
+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:22:33
+14:30:20
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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 (second(col1)) 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 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+select * from t2 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t4 order by colint;
colint col1
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t66;
+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 14:30:20
-2 21:59:22
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+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
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+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:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+60 14:30:20
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:22:33
+select * from t22 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+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:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+60 14:30:20
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -2983,44 +9233,83 @@ 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');
-insert into t4 values (1,'09:09:09');
-insert into t4 values (2,'14:30:20');
-insert into t5 values (1,'09:09:09');
-insert into t5 values (2,'14:30:20');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:20');
-insert into t6 values (2,'21:59:22');
-select second(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select second(col1) from t1 order by col1;
second(col1)
9
20
-select * from t1;
+select * from t1 order by col1;
col1
09:09:09
14:30:20
-select * from t2;
+select * from t2 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:09
14:30:20
21:59:22
-select * from t4;
+select * from t4 order by colint;
+colint col1
+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.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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t5;
+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
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t6;
+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 14:30:20
-2 21:59:22
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
-------------------------------------------------------------------------
--- Alter tables with second(col1)
-------------------------------------------------------------------------
@@ -3070,33 +9359,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (second('18:30:14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:09
+10:22:33
14:30:20
21:59:22
-select * from t44;
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+---------------------------
+---- 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:22:33
+14:30:20
+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:22:33
+14:30:20
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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` char(30) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (second(col1)) 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 09:09:15.000002
+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 09:09:15.000002
+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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-2 14:30:20
-1 09:09:09
-select * from t55;
+1 09:09:15.000002
+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 09:09:15.000002
+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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
colint col1
-2 14:30:20
-3 21:59:22
-1 09:09:09
-select * from t66;
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+select * from t2 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t4 order by colint;
+colint col1
+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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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');
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+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:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+60 14:30:20
+select * from t5 order by colint;
colint col1
-1 14:30:20
-2 21:59:22
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+60 14:30:20
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:22:33
+select * from t22 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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');
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+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:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+60 14:30:20
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3166,44 +9743,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-12-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-12-17');
-insert into t5 values (3,'2006-05-25');
-insert into t6 values (1,'2006-12-17');
-insert into t6 values (2,'2006-05-25');
-select month(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select month(col1) from t1 order by col1;
month(col1)
1
12
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-12-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-05-25
2006-12-17
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
+2006-05-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-11-06
2006-12-17
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
2006-05-25
-select * from t4;
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-12-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with month(col1)
-------------------------------------------------------------------------
@@ -3253,33 +9869,315 @@ alter table t66
partition by range(colint)
(partition p0 values less than (month('2006-10-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-11-06
2006-12-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
2006-05-25
+2006-11-06
2006-12-17
-select * from t33;
+select * from t33 order by col1;
col1
-2006-01-03
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-11-06
+2006-12-17
+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
+2006-11-06
+2006-12-17
+alter table t55
+partition by list(colint)
+subpartition by hash(month(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (month(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with month(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-11-06
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t2 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+60 2006-12-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with month(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-11-06
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t22 order by col1;
+col1
+2006-11-06
2006-12-17
+select * from t33 order by col1;
+col1
2006-05-25
-select * from t44;
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t55;
+60 2006-12-17
+select * from t55 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-05-25
-select * from t66;
+60 2006-12-17
+select * from t66 order by colint;
colint col1
-1 2006-12-17
-2 2006-05-25
+60 2006-12-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3349,44 +10247,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-12-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-12-17');
-insert into t5 values (3,'2006-09-25');
-insert into t6 values (1,'2006-12-17');
-insert into t6 values (2,'2006-09-25');
-select quarter(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select quarter(col1) from t1 order by col1;
quarter(col1)
1
4
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-12-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
-2006-12-17
2006-09-25
-select * from t3;
+2006-12-17
+select * from t3 order by col1;
col1
2006-01-03
+2006-09-25
2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-07-30
2006-09-25
-select * from t4;
+2006-12-17
+select * from t4 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-09-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-12-17
-2 2006-09-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with quarter(col1)
-------------------------------------------------------------------------
@@ -3436,33 +10373,313 @@ alter table t66
partition by range(colint)
(partition p0 values less than (quarter('2006-10-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
+2006-07-30
2006-12-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-01-03
+2006-07-30
+2006-09-25
2006-12-17
+select * from t33 order by col1;
+col1
+2006-07-30
2006-09-25
-select * from t33;
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
+2006-07-30
2006-12-17
+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
+2006-07-30
+2006-12-17
+alter table t55
+partition by list(colint)
+subpartition by hash(quarter(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (quarter(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with quarter(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-07-30
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+4 2006-02-05
+60 2006-12-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with quarter(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-07-30
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-07-30
2006-09-25
-select * from t44;
+2006-12-17
+select * from t44 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t55 order by colint;
colint col1
-2 2006-12-17
-1 2006-01-03
-3 2006-09-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t66 order by colint;
colint col1
-1 2006-12-17
-2 2006-09-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t44 order by colint;
+colint col1
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+4 2006-02-05
+60 2006-12-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3532,44 +10749,83 @@ 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');
-insert into t4 values (1,'09:09:15');
-insert into t4 values (2,'14:30:45');
-insert into t5 values (1,'09:09:15');
-insert into t5 values (2,'14:30:45');
-insert into t5 values (3,'21:59:22');
-insert into t6 values (1,'14:30:45');
-insert into t6 values (2,'21:59:22');
-select time_to_sec(col1)-(time_to_sec(col1)-20) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' 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;
+select * from t1 order by col1;
col1
09:09:15
14:30:45
-select * from t2;
+select * from t2 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t3;
+select * from t3 order by col1;
col1
09:09:15
14:30:45
21:59:22
-select * from t4;
+select * from t4 order by colint;
colint col1
1 09:09:15
-2 14:30:45
-select * from t5;
+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 14:30:45
-3 21:59:22
-select * from t6;
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t6 order by colint;
colint col1
-1 14:30:45
-2 21:59:22
+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)
-------------------------------------------------------------------------
@@ -3619,33 +10875,319 @@ 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;
+select * from t11 order by col1;
col1
-09:09:15
+10:33:11
14:30:45
-select * from t22;
+select * from t22 order by col1;
col1
-09:09:15
+10:33:11
14:30:45
21:59:22
-select * from t33;
+select * from t33 order by col1;
col1
-09:09:15
+10:33:11
14:30:45
21:59:22
-select * from t44;
+select * from t44 order by colint;
colint col1
-1 09:09:15
-2 14:30:45
-select * from t55;
+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 09:09:15
-2 14:30:45
-3 21:59:22
-select * from t66;
+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 14:30:45
-2 21:59:22
+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 ;
@@ -3715,44 +11257,83 @@ 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');
-insert into t4 values (1,'2006-02-03');
-insert into t4 values (2,'2006-01-17');
-insert into t5 values (1,'2006-02-03');
-insert into t5 values (2,'2006-01-17');
-insert into t5 values (3,'2006-01-25');
-insert into t6 values (1,'2006-01-17');
-insert into t6 values (2,'2006-01-25');
-select to_days(col1)-to_days('2006-01-01') from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select to_days(col1)-to_days('2006-01-01') from t1 order by col1;
to_days(col1)-to_days('2006-01-01')
-33
16
-select * from t1;
+33
+select * from t1 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t2;
+2006-02-03
+select * from t2 order by col1;
col1
2006-01-17
2006-01-25
2006-02-03
-select * from t3;
+select * from t3 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t4;
+2006-02-03
+select * from t4 order by colint;
colint col1
-2 2006-01-17
1 2006-02-03
-select * from t5;
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
+1 2006-02-03
2 2006-01-17
3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
1 2006-02-03
-select * from t6;
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+update t1 set col1='2006-02-06' where col1='2006-02-03';
+update t2 set col1='2006-02-06' where col1='2006-02-03';
+update t3 set col1='2006-02-06' where col1='2006-02-03';
+update t4 set col1='2006-02-06' where col1='2006-02-03';
+update t5 set col1='2006-02-06' where col1='2006-02-03';
+update t6 set col1='2006-02-06' where col1='2006-02-03';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with to_days(col1)-to_days('2006-01-01')
-------------------------------------------------------------------------
@@ -3802,33 +11383,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-02-03
2006-01-17
-select * from t22;
+2006-02-06
+select * from t22 order by col1;
col1
2006-01-17
2006-01-25
-2006-02-03
-select * from t33;
+2006-02-06
+select * from t33 order by col1;
col1
-2006-02-03
2006-01-17
2006-01-25
-select * from t44;
+2006-02-06
+select * from t44 order by colint;
colint col1
+1 2006-02-06
2 2006-01-17
-1 2006-02-03
-select * from t55;
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
+1 2006-02-06
2 2006-01-17
3 2006-01-25
-1 2006-02-03
-select * from t66;
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-01-17
-2 2006-01-25
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-06
+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
+2006-01-17
+2006-02-06
+alter table t55
+partition by list(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (to_days(col1)-to_days('2006-01-01')) 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 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -3898,44 +11757,83 @@ 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');
-insert into t4 values (1,'2006-12-03');
-insert into t4 values (2,'2006-11-17');
-insert into t5 values (1,'2006-12-03');
-insert into t5 values (2,'2006-11-17');
-insert into t5 values (3,'2006-05-25');
-insert into t6 values (1,'2006-11-17');
-insert into t6 values (2,'2006-05-25');
-select weekday(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select weekday(col1) from t1 order by col1;
weekday(col1)
-6
4
-select * from t1;
+6
+select * from t1 order by col1;
col1
+2006-11-17
2006-12-03
+select * from t2 order by col1;
+col1
+2006-05-25
2006-11-17
-select * from t2;
+2006-12-03
+select * from t3 order by col1;
col1
+2006-05-25
+2006-11-17
2006-12-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
2006-11-17
-2006-05-25
-select * from t3;
+select * from t2 order by col1;
col1
-2006-12-03
+2006-02-06
+2006-05-25
2006-11-17
+select * from t3 order by col1;
+col1
+2006-02-06
2006-05-25
-select * from t4;
+2006-11-17
+select * from t4 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-3 2006-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-11-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with weekday(col1)
-------------------------------------------------------------------------
@@ -3985,33 +11883,311 @@ alter table t66
partition by range(colint)
(partition p0 values less than (weekday('2006-10-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-12-03
+2006-02-06
2006-11-17
-select * from t22;
+select * from t22 order by col1;
col1
-2006-12-03
+2006-02-06
+2006-05-25
2006-11-17
+select * from t33 order by col1;
+col1
+2006-02-06
2006-05-25
-select * from t33;
+2006-11-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-12-03
+2006-02-06
2006-11-17
+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
+2006-02-06
+2006-11-17
+alter table t55
+partition by list(colint)
+subpartition by hash(weekday(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (weekday(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekday(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+60 2006-11-17
+select * from t5 order by colint;
+colint col1
+60 2006-11-17
+select * from t6 order by colint;
+colint col1
+60 2006-11-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekday(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t33 order by col1;
+col1
+2006-02-06
2006-05-25
-select * from t44;
+2006-11-17
+select * from t44 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t55 order by colint;
colint col1
-1 2006-12-03
-2 2006-11-17
-3 2006-05-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t66 order by colint;
colint col1
-1 2006-11-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t44 order by colint;
+colint col1
+60 2006-11-17
+select * from t55 order by colint;
+colint col1
+60 2006-11-17
+select * from t66 order by colint;
+colint col1
+60 2006-11-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -4081,44 +12257,83 @@ insert into t2 values ('2006-05-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-03-17');
insert into t3 values ('2006-05-25');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-03-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-03-17');
-insert into t5 values (3,'2006-05-25');
-insert into t6 values (1,'2006-03-17');
-insert into t6 values (2,'2006-05-25');
-select weekofyear(col1) from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select weekofyear(col1) from t1 order by col1;
weekofyear(col1)
1
11
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-03-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-03-17
2006-05-25
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
2006-03-17
2006-05-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-3 2006-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-03-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+update t1 set col1='2006-09-06' where col1='2006-01-03';
+update t2 set col1='2006-09-06' where col1='2006-01-03';
+update t3 set col1='2006-09-06' where col1='2006-01-03';
+update t4 set col1='2006-09-06' where col1='2006-01-03';
+update t5 set col1='2006-09-06' where col1='2006-01-03';
+update t6 set col1='2006-09-06' where col1='2006-01-03';
+select * from t1 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with weekofyear(col1)
-------------------------------------------------------------------------
@@ -4168,33 +12383,319 @@ alter table t66
partition by range(colint)
(partition p0 values less than (weekofyear('2006-02-14')),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-03-17
-select * from t22;
+2006-09-06
+select * from t22 order by col1;
col1
-2006-01-03
2006-03-17
2006-05-25
-select * from t33;
+2006-09-06
+select * from t33 order by col1;
col1
-2006-01-03
2006-03-17
2006-05-25
-select * from t44;
+2006-09-06
+select * from t44 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
colint col1
-1 2006-01-03
-2 2006-03-17
-3 2006-05-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
colint col1
-1 2006-03-17
-2 2006-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-03-17
+2006-09-06
+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
+2006-03-17
+2006-09-06
+alter table t55
+partition by list(colint)
+subpartition by hash(weekofyear(col1)) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (weekofyear(col1)) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekofyear(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='2006-03-17';
+delete from t2 where col1='2006-03-17';
+delete from t3 where col1='2006-03-17';
+delete from t4 where col1='2006-03-17';
+delete from t5 where col1='2006-03-17';
+delete from t6 where col1='2006-03-17';
+select * from t1 order by col1;
+col1
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+insert into t1 values ('2006-03-17');
+insert into t2 values ('2006-03-17');
+insert into t3 values ('2006-03-17');
+insert into t4 values (60,'2006-03-17');
+insert into t5 values (60,'2006-03-17');
+insert into t6 values (60,'2006-03-17');
+select * from t1 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+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
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+60 2006-03-17
+select * from t5 order by colint;
+colint col1
+60 2006-03-17
+select * from t6 order by colint;
+colint col1
+60 2006-03-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekofyear(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='2006-03-17';
+delete from t22 where col1='2006-03-17';
+delete from t33 where col1='2006-03-17';
+delete from t44 where col1='2006-03-17';
+delete from t55 where col1='2006-03-17';
+delete from t66 where col1='2006-03-17';
+select * from t11 order by col1;
+col1
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+insert into t11 values ('2006-03-17');
+insert into t22 values ('2006-03-17');
+insert into t33 values ('2006-03-17');
+insert into t44 values (60,'2006-03-17');
+insert into t55 values (60,'2006-03-17');
+insert into t66 values (60,'2006-03-17');
+select * from t11 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+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
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+60 2006-03-17
+select * from t55 order by colint;
+colint col1
+60 2006-03-17
+select * from t66 order by colint;
+colint col1
+60 2006-03-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -4264,44 +12765,83 @@ 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');
-insert into t4 values (1,'1996-01-03');
-insert into t4 values (2,'2000-02-17');
-insert into t5 values (1,'1996-01-03');
-insert into t5 values (2,'2000-02-17');
-insert into t5 values (3,'2004-05-25');
-insert into t6 values (1,'2000-02-17');
-insert into t6 values (2,'2004-05-25');
-select year(col1)-1990 from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select year(col1)-1990 from t1 order by col1;
year(col1)-1990
6
10
-select * from t1;
+select * from t1 order by col1;
col1
1996-01-03
2000-02-17
-select * from t2;
+select * from t2 order by col1;
col1
1996-01-03
2000-02-17
2004-05-25
-select * from t3;
+select * from t3 order by col1;
col1
1996-01-03
2000-02-17
2004-05-25
-select * from t4;
+select * from t4 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-3 2004-05-25
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t2 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
colint col1
-1 2000-02-17
-2 2004-05-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with year(col1)-1990
-------------------------------------------------------------------------
@@ -4351,33 +12891,315 @@ alter table t66
partition by range(colint)
(partition p0 values less than (year('2005-10-14')-1990),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-1996-01-03
2000-02-17
-select * from t22;
+2002-02-15
+select * from t22 order by col1;
col1
-1996-01-03
2000-02-17
+2002-02-15
2004-05-25
-select * from t33;
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2000-02-17
+2002-02-15
+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
+2000-02-17
+2002-02-15
+alter table t55
+partition by list(colint)
+subpartition by hash(year(col1)-1990) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (year(col1)-1990) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with year(col1)-1990
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2002-02-15
+select * from t2 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t2 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+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
+select * from t2 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+60 2000-02-17
+select * from t5 order by colint;
+colint col1
+60 2000-02-17
+select * from t6 order by colint;
+colint col1
+60 2000-02-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with year(col1)-1990
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2002-02-15
+select * from t22 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
col1
-1996-01-03
2000-02-17
+2002-02-15
+select * from t22 order by col1;
+col1
+2000-02-17
+2002-02-15
2004-05-25
-select * from t44;
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t55 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-select * from t55;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t66 order by colint;
colint col1
-1 1996-01-03
-2 2000-02-17
-3 2004-05-25
-select * from t66;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+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
+select * from t22 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
colint col1
-1 2000-02-17
-2 2004-05-25
+60 2000-02-17
+select * from t55 order by colint;
+colint col1
+60 2000-02-17
+select * from t66 order by colint;
+colint col1
+60 2000-02-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
@@ -4447,44 +13269,83 @@ 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');
-insert into t4 values (1,'2006-01-03');
-insert into t4 values (2,'2006-08-17');
-insert into t5 values (1,'2006-01-03');
-insert into t5 values (2,'2006-08-17');
-insert into t5 values (3,'2006-03-25');
-insert into t6 values (1,'2006-08-17');
-insert into t6 values (2,'2006-03-25');
-select yearweek(col1)-200600 from t1;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select yearweek(col1)-200600 from t1 order by col1;
yearweek(col1)-200600
1
33
-select * from t1;
+select * from t1 order by col1;
col1
2006-01-03
2006-08-17
-select * from t2;
+select * from t2 order by col1;
col1
2006-01-03
2006-03-25
2006-08-17
-select * from t3;
+select * from t3 order by col1;
col1
2006-01-03
+2006-03-25
2006-08-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
2006-03-25
-select * from t4;
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
colint col1
-1 2006-01-03
-2 2006-08-17
-select * from t5;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
colint col1
-3 2006-03-25
-1 2006-01-03
-2 2006-08-17
-select * from t6;
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
colint col1
-1 2006-08-17
-2 2006-03-25
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
-------------------------------------------------------------------------
--- Alter tables with yearweek(col1)-200600
-------------------------------------------------------------------------
@@ -4534,33 +13395,321 @@ alter table t66
partition by range(colint)
(partition p0 values less than (yearweek('2006-10-14')-200600),
partition p1 values less than maxvalue);
-select * from t11;
+select * from t11 order by col1;
col1
-2006-01-03
2006-08-17
-select * from t22;
+2006-11-15
+select * from t22 order by col1;
col1
-2006-01-03
2006-03-25
2006-08-17
-select * from t33;
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
-2006-01-03
2006-08-17
+2006-11-15
+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
+2006-08-17
+2006-11-15
+alter table t55
+partition by list(colint)
+subpartition by hash(yearweek(col1)-200600) 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` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (yearweek(col1)-200600) 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 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+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
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
2006-03-25
-select * from t44;
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+60 2006-08-17
+select * from t5 order by colint;
+colint col1
+60 2006-08-17
+select * from t6 order by colint;
+colint col1
+60 2006-08-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+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
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
colint col1
-1 2006-01-03
-2 2006-08-17
-select * from t55;
+60 2006-08-17
+select * from t55 order by colint;
colint col1
-3 2006-03-25
-1 2006-01-03
-2 2006-08-17
-select * from t66;
+60 2006-08-17
+select * from t66 order by colint;
colint col1
-1 2006-08-17
-2 2006-03-25
+60 2006-08-17
+-------------------------
+---- some alter table end
+-------------------------
drop table if exists t1 ;
drop table if exists t2 ;
drop table if exists t3 ;
diff --git a/mysql-test/suite/partitions/r/partition_supported_sql_func_ndb.result b/mysql-test/suite/partitions/r/partition_supported_sql_func_ndb.result
new file mode 100644
index 00000000000..5dc27d16538
--- /dev/null
+++ b/mysql-test/suite/partitions/r/partition_supported_sql_func_ndb.result
@@ -0,0 +1,13724 @@
+-------------------------------------------------------------------------
+--- abs(col1) in partition with coltype int
+-------------------------------------------------------------------------
+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 abs(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 int) engine='NDB'
+partition by range(abs(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 int) engine='NDB'
+partition by list(abs(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),
+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 int) engine='NDB'
+partition by hash(abs(col1));
+create table t4 (colint int, col1 int) engine='NDB'
+partition by range(colint)
+subpartition by hash(abs(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 int) engine='NDB'
+partition by list(colint)
+subpartition by hash(abs(col1)) 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 int) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with abs(col1)
+-------------------------------------------------------------------------
+insert into t1 values (5 );
+insert into t1 values (13 );
+insert into t2 values (5 );
+insert into t2 values (13 );
+insert into t2 values (17 );
+insert into t3 values (5 );
+insert into t3 values (13 );
+insert into t3 values (17 );
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_int.in' into table t6;
+select abs(col1) from t1 order by col1;
+abs(col1)
+5
+13
+select * from t1 order by col1;
+col1
+5
+13
+select * from t2 order by col1;
+col1
+5
+13
+17
+select * from t3 order by col1;
+col1
+5
+13
+17
+select * from t4 order by colint;
+colint col1
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t6 order by colint;
+colint col1
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 ;
+select * from t1 order by col1;
+col1
+13
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t6 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+-------------------------------------------------------------------------
+--- Alter tables with abs(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(abs(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(abs(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),
+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(abs(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(abs(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(abs(col1)) 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 (abs(15)),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+13
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t55 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+---------------------------
+---- 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
+13
+15
+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
+13
+15
+alter table t55
+partition by list(colint)
+subpartition by hash(abs(col1)) 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` int(11) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (abs(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (abs(15)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with abs(col1)
+-------------------------------------------------------------------------
+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 ;
+select * from t1 order by col1;
+col1
+15
+select * from t2 order by col1;
+col1
+15
+17
+select * from t3 order by col1;
+col1
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t5 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 );
+select * from t1 order by col1;
+col1
+13
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t5 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t6 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+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
+15
+select * from t2 order by col1;
+col1
+13
+15
+17
+select * from t3 order by col1;
+col1
+13
+15
+17
+select * from t4 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t5 order by colint;
+colint col1
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t6 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with abs(col1)
+-------------------------------------------------------------------------
+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 ;
+select * from t11 order by col1;
+col1
+15
+select * from t22 order by col1;
+col1
+15
+17
+select * from t33 order by col1;
+col1
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+select * from t55 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+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 );
+select * from t11 order by col1;
+col1
+13
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t55 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t66 order by colint;
+colint col1
+1 15
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+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
+15
+select * from t22 order by col1;
+col1
+13
+15
+17
+select * from t33 order by col1;
+col1
+13
+15
+17
+select * from t44 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t55 order by colint;
+colint col1
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+select * from t66 order by colint;
+colint col1
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 15
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123
+60 13
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- ascii(col1) in partition with coltype char(1)
+-------------------------------------------------------------------------
+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 ascii(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 char(1)) engine='NDB'
+partition by range(ascii(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 char(1)) engine='NDB'
+partition by list(ascii(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),
+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 char(1)) engine='NDB'
+partition by hash(ascii(col1));
+create table t4 (colint int, col1 char(1)) engine='NDB'
+partition by range(colint)
+subpartition by hash(ascii(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 char(1)) engine='NDB'
+partition by list(colint)
+subpartition by hash(ascii(col1)) 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 char(1)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with ascii(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('1');
+insert into t1 values ('9');
+insert into t2 values ('1');
+insert into t2 values ('9');
+insert into t2 values ('3');
+insert into t3 values ('1');
+insert into t3 values ('9');
+insert into t3 values ('3');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t6;
+select ascii(col1) from t1 order by col1;
+ascii(col1)
+49
+57
+select * from t1 order by col1;
+col1
+1
+9
+select * from t2 order by col1;
+col1
+1
+3
+9
+select * from t3 order by col1;
+col1
+1
+3
+9
+select * from t4 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+update t1 set col1='8' where col1='1';
+update t2 set col1='8' where col1='1';
+update t3 set col1='8' where col1='1';
+update t4 set col1='8' where col1='1';
+update t5 set col1='8' where col1='1';
+update t6 set col1='8' where col1='1';
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+-------------------------------------------------------------------------
+--- Alter tables with ascii(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(ascii(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(ascii(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),
+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(ascii(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(ascii(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(ascii(col1)) 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 (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+---------------------------
+---- 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
+8
+9
+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
+8
+9
+alter table t55
+partition by list(colint)
+subpartition by hash(ascii(col1)) 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` char(1) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (ascii(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ascii('5')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ascii(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='9';
+delete from t2 where col1='9';
+delete from t3 where col1='9';
+delete from t4 where col1='9';
+delete from t5 where col1='9';
+delete from t6 where col1='9';
+select * from t1 order by col1;
+col1
+8
+select * from t2 order by col1;
+col1
+3
+8
+select * from t3 order by col1;
+col1
+3
+8
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t1 values ('9');
+insert into t2 values ('9');
+insert into t3 values ('9');
+insert into t4 values (60,'9');
+insert into t5 values (60,'9');
+insert into t6 values (60,'9');
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t6 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+60 9
+select * from t5 order by colint;
+colint col1
+60 9
+select * from t6 order by colint;
+colint col1
+60 9
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ascii(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='9';
+delete from t22 where col1='9';
+delete from t33 where col1='9';
+delete from t44 where col1='9';
+delete from t55 where col1='9';
+delete from t66 where col1='9';
+select * from t11 order by col1;
+col1
+8
+select * from t22 order by col1;
+col1
+3
+8
+select * from t33 order by col1;
+col1
+3
+8
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t11 values ('9');
+insert into t22 values ('9');
+insert into t33 values ('9');
+insert into t44 values (60,'9');
+insert into t55 values (60,'9');
+insert into t66 values (60,'9');
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t66 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+60 9
+select * from t55 order by colint;
+colint col1
+60 9
+select * from t66 order by colint;
+colint col1
+60 9
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- cast(ceiling(col1) as signed integer) in partition with coltype float(7,4)
+-------------------------------------------------------------------------
+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 cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+create table t1 (col1 float(7,4)) engine='NDB'
+partition by range(cast(ceiling(col1) as signed integer))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 float(7,4)) engine='NDB'
+partition by list(cast(ceiling(col1) as signed integer))
+(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 float(7,4)) engine='NDB'
+partition by hash(cast(ceiling(col1) as signed integer));
+create table t4 (colint int, col1 float(7,4)) engine='NDB'
+partition by range(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 float(7,4)) engine='NDB'
+partition by list(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) 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 float(7,4)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+insert into t1 values (5.1230);
+insert into t1 values (13.345);
+insert into t2 values (5.1230);
+insert into t2 values (13.345);
+insert into t2 values (17.987);
+insert into t3 values (5.1230);
+insert into t3 values (13.345);
+insert into t3 values (17.987);
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(ceiling(col1) as signed integer) from t1 order by col1;
+cast(ceiling(col1) as signed integer)
+6
+14
+select * from t1 order by col1;
+col1
+5.1230
+13.3450
+select * from t2 order by col1;
+col1
+5.1230
+13.3450
+17.9870
+select * from t3 order by col1;
+col1
+5.1230
+13.3450
+17.9870
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15.654 where col1=5.1230;
+update t2 set col1=15.654 where col1=5.1230;
+update t3 set col1=15.654 where col1=5.1230;
+update t4 set col1=15.654 where col1=5.1230;
+update t5 set col1=15.654 where col1=5.1230;
+update t6 set col1=15.654 where col1=5.1230;
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Alter tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(cast(ceiling(col1) as signed integer))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(cast(ceiling(col1) as signed integer))
+(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(cast(ceiling(col1) as signed integer));
+alter table t44
+partition by range(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) 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 (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+13.3450
+15.6540
+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
+13.3450
+15.6540
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(ceiling(col1) as signed integer)) 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` float(7,4) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(ceiling(col1) as signed integer)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(ceiling(15) as signed integer)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+delete from t1 where col1=13.345;
+delete from t2 where col1=13.345;
+delete from t3 where col1=13.345;
+delete from t4 where col1=13.345;
+delete from t5 where col1=13.345;
+delete from t6 where col1=13.345;
+select * from t1 order by col1;
+col1
+15.6540
+select * from t2 order by col1;
+col1
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t1 values (13.345);
+insert into t2 values (13.345);
+insert into t3 values (13.345);
+insert into t4 values (60,13.345);
+insert into t5 values (60,13.345);
+insert into t6 values (60,13.345);
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t6 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+60 13.3450
+select * from t5 order by colint;
+colint col1
+60 13.3450
+select * from t6 order by colint;
+colint col1
+60 13.3450
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(ceiling(col1) as signed integer)
+-------------------------------------------------------------------------
+delete from t11 where col1=13.345;
+delete from t22 where col1=13.345;
+delete from t33 where col1=13.345;
+delete from t44 where col1=13.345;
+delete from t55 where col1=13.345;
+delete from t66 where col1=13.345;
+select * from t11 order by col1;
+col1
+15.6540
+select * from t22 order by col1;
+col1
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t11 values (13.345);
+insert into t22 values (13.345);
+insert into t33 values (13.345);
+insert into t44 values (60,13.345);
+insert into t55 values (60,13.345);
+insert into t66 values (60,13.345);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t66 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+60 13.3450
+select * from t55 order by colint;
+colint col1
+60 13.3450
+select * from t66 order by colint;
+colint col1
+60 13.3450
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- cast(floor(col1) as signed) in partition with coltype float(7,4)
+-------------------------------------------------------------------------
+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 cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+create table t1 (col1 float(7,4)) engine='NDB'
+partition by range(cast(floor(col1) as signed))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 float(7,4)) engine='NDB'
+partition by list(cast(floor(col1) as signed))
+(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 float(7,4)) engine='NDB'
+partition by hash(cast(floor(col1) as signed));
+create table t4 (colint int, col1 float(7,4)) engine='NDB'
+partition by range(colint)
+subpartition by hash(cast(floor(col1) as signed)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 float(7,4)) engine='NDB'
+partition by list(colint)
+subpartition by hash(cast(floor(col1) as signed)) 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 float(7,4)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+insert into t1 values (5.1230);
+insert into t1 values (13.345);
+insert into t2 values (5.1230);
+insert into t2 values (13.345);
+insert into t2 values (17.987);
+insert into t3 values (5.1230);
+insert into t3 values (13.345);
+insert into t3 values (17.987);
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(floor(col1) as signed) from t1 order by col1;
+cast(floor(col1) as signed)
+5
+13
+select * from t1 order by col1;
+col1
+5.1230
+13.3450
+select * from t2 order by col1;
+col1
+5.1230
+13.3450
+17.9870
+select * from t3 order by col1;
+col1
+5.1230
+13.3450
+17.9870
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15.654 where col1=5.1230;
+update t2 set col1=15.654 where col1=5.1230;
+update t3 set col1=15.654 where col1=5.1230;
+update t4 set col1=15.654 where col1=5.1230;
+update t5 set col1=15.654 where col1=5.1230;
+update t6 set col1=15.654 where col1=5.1230;
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Alter tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(cast(floor(col1) as signed))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(cast(floor(col1) as signed))
+(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(cast(floor(col1) as signed));
+alter table t44
+partition by range(colint)
+subpartition by hash(cast(floor(col1) as signed)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(floor(col1) as signed)) 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 (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+13.3450
+15.6540
+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
+13.3450
+15.6540
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(floor(col1) as signed)) 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` float(7,4) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(floor(col1) as signed)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(floor(15.123) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 15.6540
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+delete from t1 where col1=13.345;
+delete from t2 where col1=13.345;
+delete from t3 where col1=13.345;
+delete from t4 where col1=13.345;
+delete from t5 where col1=13.345;
+delete from t6 where col1=13.345;
+select * from t1 order by col1;
+col1
+15.6540
+select * from t2 order by col1;
+col1
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t1 values (13.345);
+insert into t2 values (13.345);
+insert into t3 values (13.345);
+insert into t4 values (60,13.345);
+insert into t5 values (60,13.345);
+insert into t6 values (60,13.345);
+select * from t1 order by col1;
+col1
+13.3450
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t5 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t6 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t2 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t3 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t4 order by colint;
+colint col1
+60 13.3450
+select * from t5 order by colint;
+colint col1
+60 13.3450
+select * from t6 order by colint;
+colint col1
+60 13.3450
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(floor(col1) as signed)
+-------------------------------------------------------------------------
+delete from t11 where col1=13.345;
+delete from t22 where col1=13.345;
+delete from t33 where col1=13.345;
+delete from t44 where col1=13.345;
+delete from t55 where col1=13.345;
+delete from t66 where col1=13.345;
+select * from t11 order by col1;
+col1
+15.6540
+select * from t22 order by col1;
+col1
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+insert into t11 values (13.345);
+insert into t22 values (13.345);
+insert into t33 values (13.345);
+insert into t44 values (60,13.345);
+insert into t55 values (60,13.345);
+insert into t66 values (60,13.345);
+select * from t11 order by col1;
+col1
+13.3450
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t55 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+select * from t66 order by colint;
+colint col1
+1 15.6540
+3 17.9870
+4 15.6540
+60 13.3450
+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
+15.6540
+select * from t22 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t33 order by col1;
+col1
+13.3450
+15.6540
+17.9870
+select * from t44 order by colint;
+colint col1
+60 13.3450
+select * from t55 order by colint;
+colint col1
+60 13.3450
+select * from t66 order by colint;
+colint col1
+60 13.3450
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- cast(mod(col1,10) as signed) in partition with coltype float(7,4)
+-------------------------------------------------------------------------
+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 cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+create table t1 (col1 float(7,4)) engine='NDB'
+partition by range(cast(mod(col1,10) as signed))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 float(7,4)) engine='NDB'
+partition by list(cast(mod(col1,10) as signed))
+(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 float(7,4)) engine='NDB'
+partition by hash(cast(mod(col1,10) as signed));
+create table t4 (colint int, col1 float(7,4)) engine='NDB'
+partition by range(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 float(7,4)) engine='NDB'
+partition by list(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) 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 float(7,4)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+insert into t1 values (5.0000);
+insert into t1 values (19);
+insert into t2 values (5.0000);
+insert into t2 values (19);
+insert into t2 values (17);
+insert into t3 values (5.0000);
+insert into t3 values (19);
+insert into t3 values (17);
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_float.in' into table t6;
+select cast(mod(col1,10) as signed) from t1 order by col1;
+cast(mod(col1,10) as signed)
+5
+9
+select * from t1 order by col1;
+col1
+5.0000
+19.0000
+select * from t2 order by col1;
+col1
+5.0000
+17.0000
+19.0000
+select * from t3 order by col1;
+col1
+5.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+update t1 set col1=15 where col1=5.0000;
+update t2 set col1=15 where col1=5.0000;
+update t3 set col1=15 where col1=5.0000;
+update t4 set col1=15 where col1=5.0000;
+update t5 set col1=15 where col1=5.0000;
+update t6 set col1=15 where col1=5.0000;
+select * from t1 order by col1;
+col1
+15.0000
+19.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Alter tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(cast(mod(col1,10) as signed))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(cast(mod(col1,10) as signed))
+(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(cast(mod(col1,10) as signed));
+alter table t44
+partition by range(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) 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 (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+15.0000
+19.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+---------------------------
+---- 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
+15.0000
+19.0000
+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
+15.0000
+19.0000
+alter table t55
+partition by list(colint)
+subpartition by hash(cast(mod(col1,10) as signed)) 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` float(7,4) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (cast(mod(col1,10) as signed)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (cast(mod(15,10) as signed)),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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;
+select * from t1 order by col1;
+col1
+15.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+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);
+select * from t1 order by col1;
+col1
+15.0000
+19.0000
+select * from t2 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t5 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t6 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t4 order by colint;
+colint col1
+60 19.0000
+select * from t5 order by colint;
+colint col1
+60 19.0000
+select * from t6 order by colint;
+colint col1
+60 19.0000
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with cast(mod(col1,10) as signed)
+-------------------------------------------------------------------------
+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;
+select * from t11 order by col1;
+col1
+15.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+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);
+select * from t11 order by col1;
+col1
+15.0000
+19.0000
+select * from t22 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t55 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+select * from t66 order by colint;
+colint col1
+1 5.1230
+2 13.3450
+3 17.9870
+4 15.6540
+60 19.0000
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+15.0000
+17.0000
+19.0000
+select * from t44 order by colint;
+colint col1
+60 19.0000
+select * from t55 order by colint;
+colint col1
+60 19.0000
+select * from t66 order by colint;
+colint col1
+60 19.0000
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- ord(col1) in partition with coltype char(3)
+-------------------------------------------------------------------------
+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 ord(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 char(3)) engine='NDB'
+partition by range(ord(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 char(3)) engine='NDB'
+partition by list(ord(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),
+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 char(3)) engine='NDB'
+partition by hash(ord(col1));
+create table t4 (colint int, col1 char(3)) engine='NDB'
+partition by range(colint)
+subpartition by hash(ord(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 char(3)) engine='NDB'
+partition by list(colint)
+subpartition by hash(ord(col1)) 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 char(3)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with ord(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('1');
+insert into t1 values ('9');
+insert into t2 values ('1');
+insert into t2 values ('9');
+insert into t2 values ('3');
+insert into t3 values ('1');
+insert into t3 values ('9');
+insert into t3 values ('3');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in' into table t6;
+select ord(col1) from t1 order by col1;
+ord(col1)
+49
+57
+select * from t1 order by col1;
+col1
+1
+9
+select * from t2 order by col1;
+col1
+1
+3
+9
+select * from t3 order by col1;
+col1
+1
+3
+9
+select * from t4 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 1
+2 9
+3 3
+4 8
+update t1 set col1='8' where col1='1';
+update t2 set col1='8' where col1='1';
+update t3 set col1='8' where col1='1';
+update t4 set col1='8' where col1='1';
+update t5 set col1='8' where col1='1';
+update t6 set col1='8' where col1='1';
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t6 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+-------------------------------------------------------------------------
+--- Alter tables with ord(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(ord(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(ord(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),
+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(ord(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(ord(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(ord(col1)) 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 (ord('a')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+---------------------------
+---- 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
+8
+9
+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
+8
+9
+alter table t55
+partition by list(colint)
+subpartition by hash(ord(col1)) 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` char(3) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (ord(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (ord('a')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 8
+2 9
+3 3
+4 8
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ord(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='9';
+delete from t2 where col1='9';
+delete from t3 where col1='9';
+delete from t4 where col1='9';
+delete from t5 where col1='9';
+delete from t6 where col1='9';
+select * from t1 order by col1;
+col1
+8
+select * from t2 order by col1;
+col1
+3
+8
+select * from t3 order by col1;
+col1
+3
+8
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t1 values ('9');
+insert into t2 values ('9');
+insert into t3 values ('9');
+insert into t4 values (60,'9');
+insert into t5 values (60,'9');
+insert into t6 values (60,'9');
+select * from t1 order by col1;
+col1
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t5 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t6 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t2 order by col1;
+col1
+3
+8
+9
+select * from t3 order by col1;
+col1
+3
+8
+9
+select * from t4 order by colint;
+colint col1
+60 9
+select * from t5 order by colint;
+colint col1
+60 9
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with ord(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='9';
+delete from t22 where col1='9';
+delete from t33 where col1='9';
+delete from t44 where col1='9';
+delete from t55 where col1='9';
+delete from t66 where col1='9';
+select * from t11 order by col1;
+col1
+8
+select * from t22 order by col1;
+col1
+3
+8
+select * from t33 order by col1;
+col1
+3
+8
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+insert into t11 values ('9');
+insert into t22 values ('9');
+insert into t33 values ('9');
+insert into t44 values (60,'9');
+insert into t55 values (60,'9');
+insert into t66 values (60,'9');
+select * from t11 order by col1;
+col1
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t55 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+select * from t66 order by colint;
+colint col1
+1 8
+3 3
+4 8
+60 9
+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
+8
+9
+select * from t22 order by col1;
+col1
+3
+8
+9
+select * from t33 order by col1;
+col1
+3
+8
+9
+select * from t44 order by colint;
+colint col1
+60 9
+select * from t55 order by colint;
+colint col1
+60 9
+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 ;
+-------------------------------------------------------------------------
+--- day(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 day(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(day(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(day(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),
+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 date) engine='NDB'
+partition by hash(day(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(day(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(day(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with day(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-02-03');
+insert into t1 values ('2006-01-17');
+insert into t2 values ('2006-02-03');
+insert into t2 values ('2006-01-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select day(col1) from t1 order by col1;
+day(col1)
+17
+3
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-03
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-03
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with day(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(day(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(day(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),
+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(day(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(day(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(day(col1)) 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 (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(day(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (day(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (day('2006-12-21')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with day(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with day(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- dayofmonth(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 dayofmonth(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(dayofmonth(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(dayofmonth(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),
+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 date) engine='NDB'
+partition by hash(dayofmonth(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(dayofmonth(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(dayofmonth(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-02-03');
+insert into t1 values ('2006-01-17');
+insert into t2 values ('2006-02-03');
+insert into t2 values ('2006-01-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofmonth(col1) from t1 order by col1;
+dayofmonth(col1)
+17
+3
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-03
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-03
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(dayofmonth(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(dayofmonth(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),
+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(dayofmonth(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(dayofmonth(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofmonth(col1)) 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 (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofmonth(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofmonth(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofmonth('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofmonth(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-05
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- dayofweek(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 dayofweek(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(dayofweek(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(dayofweek(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),
+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 date) engine='NDB'
+partition by hash(dayofweek(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(dayofweek(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(dayofweek(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with dayofweek(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-02-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-02-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofweek(col1) from t1 order by col1;
+dayofweek(col1)
+3
+6
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-01-25
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-01-25
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(dayofweek(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(dayofweek(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),
+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(dayofweek(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(dayofweek(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofweek(col1)) 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 (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-02-05
+2006-02-17
+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
+2006-02-05
+2006-02-17
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofweek(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofweek(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofweek('2006-12-24')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofweek(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- dayofyear(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 dayofyear(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(dayofyear(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(dayofyear(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),
+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 date) engine='NDB'
+partition by hash(dayofyear(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(dayofyear(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with dayofyear(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-01-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-01-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofyear(col1) from t1 order by col1;
+dayofyear(col1)
+3
+17
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-01-17
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-01-17
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(dayofyear(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(dayofyear(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),
+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(dayofyear(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(dayofyear(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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 (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofyear(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+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 ;
+-------------------------------------------------------------------------
+--- dayofyear(col1) in partition with coltype char(30)
+-------------------------------------------------------------------------
+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 dayofyear(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 char(30)) engine='NDB'
+partition by range(dayofyear(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 char(30)) engine='NDB'
+partition by list(dayofyear(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),
+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 char(30)) engine='NDB'
+partition by hash(dayofyear(col1));
+create table t4 (colint int, col1 char(30)) engine='NDB'
+partition by range(colint)
+subpartition by hash(dayofyear(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 char(30)) engine='NDB'
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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 char(30)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with dayofyear(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-01-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-01-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select dayofyear(col1) from t1 order by col1;
+dayofyear(col1)
+3
+17
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-01-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-01-17
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-01-17
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(dayofyear(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(dayofyear(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),
+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(dayofyear(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(dayofyear(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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 (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-05
+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
+2006-01-17
+2006-02-05
+alter table t55
+partition by list(colint)
+subpartition by hash(dayofyear(col1)) 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` char(30) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (dayofyear(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (dayofyear('2006-12-25')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with dayofyear(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-02-05
+2006-02-25
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+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 ;
+-------------------------------------------------------------------------
+--- extract(month from col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 extract(month from col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(extract(month from col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(extract(month from 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),
+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 date) engine='NDB'
+partition by hash(extract(month from col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(extract(month from col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(extract(month from col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with extract(month from col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-02-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-02-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select extract(month from col1) from t1 order by col1;
+extract(month from col1)
+1
+2
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-01-25
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-01-25
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with extract(month from col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(extract(month from col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(extract(month from 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),
+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(extract(month from col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(extract(month from col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(extract(month from col1)) 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 (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-02-05
+2006-02-17
+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
+2006-02-05
+2006-02-17
+alter table t55
+partition by list(colint)
+subpartition by hash(extract(month from col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (extract(month from col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (extract(year from '1998-11-23')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with extract(month from col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-05
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t4 order by colint;
+colint col1
+60 2006-02-17
+select * from t5 order by colint;
+colint col1
+60 2006-02-17
+select * from t6 order by colint;
+colint col1
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with extract(month from col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-05
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-05
+2006-02-17
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-02-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-05
+2006-02-17
+select * from t44 order by colint;
+colint col1
+60 2006-02-17
+select * from t55 order by colint;
+colint col1
+60 2006-02-17
+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 ;
+-------------------------------------------------------------------------
+--- hour(col1) 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 hour(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 time) engine='NDB'
+partition by range(hour(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 time) engine='NDB'
+partition by list(hour(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),
+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='NDB'
+partition by hash(hour(col1));
+create table t4 (colint int, col1 time) engine='NDB'
+partition by range(colint)
+subpartition by hash(hour(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 time) engine='NDB'
+partition by list(colint)
+subpartition by hash(hour(col1)) 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='NDB'
+partition by range(colint)
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with hour(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('09:09');
+insert into t1 values ('14:30');
+insert into t2 values ('09:09');
+insert into t2 values ('14:30');
+insert into t2 values ('21:59');
+insert into t3 values ('09:09');
+insert into t3 values ('14:30');
+insert into t3 values ('21:59');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select hour(col1) from t1 order by col1;
+hour(col1)
+9
+14
+select * from t1 order by col1;
+col1
+09:09:00
+14:30:00
+select * from t2 order by col1;
+col1
+09:09:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+09:09:00
+14:30:00
+21:59:00
+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: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';
+select * from t1 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+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
+-------------------------------------------------------------------------
+--- Alter tables with hour(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(hour(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(hour(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),
+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(hour(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(hour(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(hour(col1)) 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 (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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:30:00
+14:30:00
+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:30:00
+14:30:00
+alter table t55
+partition by list(colint)
+subpartition by hash(hour(col1)) 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=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (hour(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (hour('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with hour(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+21:59:00
+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
+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');
+select * from t1 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t2 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t5 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t6 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+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
+select * from t2 order by col1;
+col1
+14:30:00
+21:59:00
+select * from t3 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t4 order by colint;
+colint col1
+60 14:30:00
+select * from t5 order by colint;
+colint col1
+60 14:30:00
+select * from t6 order by colint;
+colint col1
+60 14:30:00
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with hour(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+10:30:00
+14:30:00
+select * from t22 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:00
+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
+select * from t22 order by col1;
+col1
+14:30:00
+21:59:00
+select * from t33 order by col1;
+col1
+10:30:00
+14:30:00
+21:59:00
+select * from t44 order by colint;
+colint col1
+60 14:30:00
+select * from t55 order by colint;
+colint col1
+60 14:30:00
+select * from t66 order by colint;
+colint col1
+60 14:30:00
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- microsecond(col1) 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 microsecond(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 time) engine='NDB'
+partition by range(microsecond(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 time) engine='NDB'
+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),
+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='NDB'
+partition by hash(microsecond(col1));
+create table t4 (colint int, col1 time) engine='NDB'
+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='NDB'
+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),
+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='NDB'
+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)
+-------------------------------------------------------------------------
+insert into t1 values ('09:09:15.000002');
+insert into t1 values ('04:30:01.000018');
+insert into t2 values ('09:09:15.000002');
+insert into t2 values ('04:30:01.000018');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select microsecond(col1) from t1 order by col1;
+microsecond(col1)
+0
+0
+select * from t1 order by col1;
+col1
+04:30:01
+09:09:15
+select * from t2 order by col1;
+col1
+00:59:22
+04:30:01
+09:09:15
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+09:09:15
+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='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';
+select * from t1 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t6 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Alter tables with microsecond(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(microsecond(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+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),
+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(microsecond(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(microsecond(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+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),
+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 (microsecond('10:30:10.000010')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 05:30:34
+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
+04:30:01
+05:30:34
+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
+alter table t55
+partition by list(colint)
+subpartition by hash(microsecond(col1)) 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=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (microsecond(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+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 05:30:34
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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
+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
+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
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with microsecond(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+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');
+select * from t1 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t2 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t5 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t6 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t4 order by colint;
+colint col1
+60 04:30:01
+select * from t5 order by colint;
+colint col1
+60 04:30:01
+select * from t6 order by colint;
+colint col1
+60 04:30:01
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with microsecond(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+04:30:01
+05:30:34
+select * from t22 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t55 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+select * from t66 order by colint;
+colint col1
+1 05:30:34
+3 00:59:22
+4 05:30:34
+60 04:30:01
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+00:59:22
+04:30:01
+05:30:34
+select * from t44 order by colint;
+colint col1
+60 04:30:01
+select * from t55 order by colint;
+colint col1
+60 04:30:01
+select * from t66 order by colint;
+colint col1
+60 04:30:01
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- minute(col1) 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 minute(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 time) engine='NDB'
+partition by range(minute(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 time) engine='NDB'
+partition by list(minute(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),
+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='NDB'
+partition by hash(minute(col1));
+create table t4 (colint int, col1 time) engine='NDB'
+partition by range(colint)
+subpartition by hash(minute(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 time) engine='NDB'
+partition by list(colint)
+subpartition by hash(minute(col1)) 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='NDB'
+partition by range(colint)
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with minute(col1)
+-------------------------------------------------------------------------
+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 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select minute(col1) from t1 order by col1;
+minute(col1)
+9
+30
+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: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';
+select * from t1 order by col1;
+col1
+10:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t6 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Alter tables with minute(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(minute(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(minute(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),
+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(minute(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(minute(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(minute(col1)) 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 (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+10:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+14:30:45
+alter table t55
+partition by list(colint)
+subpartition by hash(minute(col1)) 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=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (minute(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (minute('18:30')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with minute(col1)
+-------------------------------------------------------------------------
+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:24:23
+select * from t2 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t5 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+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:24:23
+14:30:45
+select * from t2 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t3 order by col1;
+col1
+10:24:23
+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
+60 14:30:45
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with minute(col1)
+-------------------------------------------------------------------------
+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:24:23
+select * from t22 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 10:24:23
+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:24:23
+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:24:23
+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:24:23
+14:30:45
+select * from t22 order by col1;
+col1
+10:24:23
+14:30:45
+21:59:22
+select * from t33 order by col1;
+col1
+10:24:23
+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
+60 14:30:45
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- second(col1) 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 second(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 time) engine='NDB'
+partition by range(second(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 time) engine='NDB'
+partition by list(second(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),
+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='NDB'
+partition by hash(second(col1));
+create table t4 (colint int, col1 time) engine='NDB'
+partition by range(colint)
+subpartition by hash(second(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 time) engine='NDB'
+partition by list(colint)
+subpartition by hash(second(col1)) 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='NDB'
+partition by range(colint)
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with second(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('09:09:09');
+insert into t1 values ('14:30:20');
+insert into t2 values ('09:09:09');
+insert into t2 values ('14:30:20');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select second(col1) from t1 order by col1;
+second(col1)
+9
+20
+select * from t1 order by col1;
+col1
+09:09:09
+14:30:20
+select * from t2 order by col1;
+col1
+09:09:09
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+09:09:09
+14:30:20
+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: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';
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+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
+-------------------------------------------------------------------------
+--- Alter tables with second(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(second(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(second(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),
+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(second(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(second(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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:22:33
+14:30:20
+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:22:33
+14:30:20
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (second(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+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 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+select * from t2 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+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
+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');
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+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
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+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:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+60 14:30:20
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:22:33
+select * from t22 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+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');
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+1 09:09:15
+2 04:30:01
+3 00:59:22
+4 05:30:34
+60 14:30:20
+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:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+60 14:30:20
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- second(col1) in partition with coltype char(30)
+-------------------------------------------------------------------------
+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 second(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 char(30)) engine='NDB'
+partition by range(second(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 char(30)) engine='NDB'
+partition by list(second(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),
+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 char(30)) engine='NDB'
+partition by hash(second(col1));
+create table t4 (colint int, col1 char(30)) engine='NDB'
+partition by range(colint)
+subpartition by hash(second(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 char(30)) engine='NDB'
+partition by list(colint)
+subpartition by hash(second(col1)) 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 char(30)) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (second('18:30:14')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with second(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('09:09:09');
+insert into t1 values ('14:30:20');
+insert into t2 values ('09:09:09');
+insert into t2 values ('14:30:20');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t6;
+select second(col1) from t1 order by col1;
+second(col1)
+9
+20
+select * from t1 order by col1;
+col1
+09:09:09
+14:30:20
+select * from t2 order by col1;
+col1
+09:09:09
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+09:09:09
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+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.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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+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.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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+-------------------------------------------------------------------------
+--- Alter tables with second(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(second(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(second(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),
+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(second(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(second(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+---------------------------
+---- 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:22:33
+14:30:20
+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:22:33
+14:30:20
+alter table t55
+partition by list(colint)
+subpartition by hash(second(col1)) 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` char(30) DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (second(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+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 09:09:15.000002
+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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+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 09:09:15.000002
+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 (second('18:30:14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+10:22:33
+select * from t2 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t4 order by colint;
+colint col1
+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.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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');
+select * from t1 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+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:22:33
+14:30:20
+select * from t2 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t3 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t4 order by colint;
+colint col1
+60 14:30:20
+select * from t5 order by colint;
+colint col1
+60 14:30:20
+select * from t6 order by colint;
+colint col1
+60 14:30:20
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with second(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+10:22:33
+select * from t22 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+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');
+select * from t11 order by col1;
+col1
+10:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+60 14:30:20
+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:22:33
+14:30:20
+select * from t22 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t33 order by col1;
+col1
+10:22:33
+14:30:20
+21:59:22
+select * from t44 order by colint;
+colint col1
+60 14:30:20
+select * from t55 order by colint;
+colint col1
+60 14:30:20
+select * from t66 order by colint;
+colint col1
+60 14:30:20
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- month(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 month(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(month(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(month(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),
+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 date) engine='NDB'
+partition by hash(month(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(month(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(month(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with month(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-12-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-12-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select month(col1) from t1 order by col1;
+month(col1)
+1
+12
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-05-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-05-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with month(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(month(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(month(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),
+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(month(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(month(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(month(col1)) 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 (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-11-06
+2006-12-17
+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
+2006-11-06
+2006-12-17
+alter table t55
+partition by list(colint)
+subpartition by hash(month(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (month(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (month('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with month(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-11-06
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t2 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t4 order by colint;
+colint col1
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+60 2006-12-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with month(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-11-06
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t22 order by col1;
+col1
+2006-11-06
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-11-06
+2006-12-17
+select * from t44 order by colint;
+colint col1
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+60 2006-12-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- quarter(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 quarter(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(quarter(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(quarter(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),
+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 date) engine='NDB'
+partition by hash(quarter(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(quarter(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(quarter(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with quarter(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-12-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-12-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select quarter(col1) from t1 order by col1;
+quarter(col1)
+1
+4
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with quarter(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(quarter(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(quarter(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),
+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(quarter(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(quarter(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(quarter(col1)) 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 (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-07-30
+2006-12-17
+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
+2006-07-30
+2006-12-17
+alter table t55
+partition by list(colint)
+subpartition by hash(quarter(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (quarter(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (quarter('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with quarter(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-07-30
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t2 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t4 order by colint;
+colint col1
+60 2006-12-17
+select * from t5 order by colint;
+colint col1
+60 2006-12-17
+select * from t6 order by colint;
+colint col1
+4 2006-02-05
+60 2006-12-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with quarter(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-07-30
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-07-30
+2006-12-17
+select * from t22 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-12-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-07-30
+2006-09-25
+2006-12-17
+select * from t44 order by colint;
+colint col1
+60 2006-12-17
+select * from t55 order by colint;
+colint col1
+60 2006-12-17
+select * from t66 order by colint;
+colint col1
+4 2006-02-05
+60 2006-12-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- 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='NDB'
+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='NDB'
+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='NDB'
+partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
+create table t4 (colint int, col1 time) engine='NDB'
+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='NDB'
+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='NDB'
+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 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_time.in' 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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' 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=NDB 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 = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+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 ;
+-------------------------------------------------------------------------
+--- to_days(col1)-to_days('2006-01-01') in partition with coltype date
+-------------------------------------------------------------------------
+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 to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(to_days(col1)-to_days('2006-01-01'))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(to_days(col1)-to_days('2006-01-01'))
+(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 date) engine='NDB'
+partition by hash(to_days(col1)-to_days('2006-01-01'));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+insert into t1 values ('2006-02-03');
+insert into t1 values ('2006-01-17');
+insert into t2 values ('2006-02-03');
+insert into t2 values ('2006-01-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select to_days(col1)-to_days('2006-01-01') from t1 order by col1;
+to_days(col1)-to_days('2006-01-01')
+16
+33
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-03
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-03
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+update t1 set col1='2006-02-06' where col1='2006-02-03';
+update t2 set col1='2006-02-06' where col1='2006-02-03';
+update t3 set col1='2006-02-06' where col1='2006-02-03';
+update t4 set col1='2006-02-06' where col1='2006-02-03';
+update t5 set col1='2006-02-06' where col1='2006-02-03';
+update t6 set col1='2006-02-06' where col1='2006-02-03';
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(to_days(col1)-to_days('2006-01-01'))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(to_days(col1)-to_days('2006-01-01'))
+(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(to_days(col1)-to_days('2006-01-01'));
+alter table t44
+partition by range(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) 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 (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-01-17
+2006-02-06
+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
+2006-01-17
+2006-02-06
+alter table t55
+partition by list(colint)
+subpartition by hash(to_days(col1)-to_days('2006-01-01')) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (to_days(col1)-to_days('2006-01-01')) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t3 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t4 order by colint;
+colint col1
+60 2006-01-17
+select * from t5 order by colint;
+colint col1
+60 2006-01-17
+select * from t6 order by colint;
+colint col1
+60 2006-01-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-06
+3 2006-01-25
+4 2006-02-05
+60 2006-01-17
+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
+2006-01-17
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t33 order by col1;
+col1
+2006-01-17
+2006-01-25
+2006-02-06
+select * from t44 order by colint;
+colint col1
+60 2006-01-17
+select * from t55 order by colint;
+colint col1
+60 2006-01-17
+select * from t66 order by colint;
+colint col1
+60 2006-01-17
+-------------------------
+---- 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 ;
+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 weekday(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(weekday(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(weekday(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),
+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 date) engine='NDB'
+partition by hash(weekday(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(weekday(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(weekday(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with weekday(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-12-03');
+insert into t1 values ('2006-11-17');
+insert into t2 values ('2006-12-03');
+insert into t2 values ('2006-11-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select weekday(col1) from t1 order by col1;
+weekday(col1)
+4
+6
+select * from t1 order by col1;
+col1
+2006-11-17
+2006-12-03
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-11-17
+2006-12-03
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-11-17
+2006-12-03
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with weekday(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(weekday(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(weekday(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),
+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(weekday(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(weekday(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(weekday(col1)) 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 (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-02-06
+2006-11-17
+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
+2006-02-06
+2006-11-17
+alter table t55
+partition by list(colint)
+subpartition by hash(weekday(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (weekday(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekday('2006-10-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekday(col1)
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-02-06
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t2 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+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
+select * from t2 order by col1;
+col1
+select * from t3 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t4 order by colint;
+colint col1
+60 2006-11-17
+select * from t5 order by colint;
+colint col1
+60 2006-11-17
+select * from t6 order by colint;
+colint col1
+60 2006-11-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekday(col1)
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-02-06
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-02-06
+2006-11-17
+select * from t22 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-11-17
+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
+select * from t22 order by col1;
+col1
+select * from t33 order by col1;
+col1
+2006-02-06
+2006-05-25
+2006-11-17
+select * from t44 order by colint;
+colint col1
+60 2006-11-17
+select * from t55 order by colint;
+colint col1
+60 2006-11-17
+select * from t66 order by colint;
+colint col1
+60 2006-11-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- weekofyear(col1) in partition with coltype date
+-------------------------------------------------------------------------
+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 weekofyear(col1)
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(weekofyear(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(weekofyear(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),
+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 date) engine='NDB'
+partition by hash(weekofyear(col1));
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(weekofyear(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(weekofyear(col1)) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with weekofyear(col1)
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-03-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-03-17');
+insert into t2 values ('2006-05-25');
+insert into t3 values ('2006-01-03');
+insert into t3 values ('2006-03-17');
+insert into t3 values ('2006-05-25');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select weekofyear(col1) from t1 order by col1;
+weekofyear(col1)
+1
+11
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-03-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-03-17
+2006-05-25
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-03-17
+2006-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+update t1 set col1='2006-09-06' where col1='2006-01-03';
+update t2 set col1='2006-09-06' where col1='2006-01-03';
+update t3 set col1='2006-09-06' where col1='2006-01-03';
+update t4 set col1='2006-09-06' where col1='2006-01-03';
+update t5 set col1='2006-09-06' where col1='2006-01-03';
+update t6 set col1='2006-09-06' where col1='2006-01-03';
+select * from t1 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with weekofyear(col1)
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(weekofyear(col1))
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(weekofyear(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),
+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(weekofyear(col1));
+alter table t44
+partition by range(colint)
+subpartition by hash(weekofyear(col1)) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(weekofyear(col1)) 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 (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-03-17
+2006-09-06
+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
+2006-03-17
+2006-09-06
+alter table t55
+partition by list(colint)
+subpartition by hash(weekofyear(col1)) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (weekofyear(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (weekofyear('2006-02-14')),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekofyear(col1)
+-------------------------------------------------------------------------
+delete from t1 where col1='2006-03-17';
+delete from t2 where col1='2006-03-17';
+delete from t3 where col1='2006-03-17';
+delete from t4 where col1='2006-03-17';
+delete from t5 where col1='2006-03-17';
+delete from t6 where col1='2006-03-17';
+select * from t1 order by col1;
+col1
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+insert into t1 values ('2006-03-17');
+insert into t2 values ('2006-03-17');
+insert into t3 values ('2006-03-17');
+insert into t4 values (60,'2006-03-17');
+insert into t5 values (60,'2006-03-17');
+insert into t6 values (60,'2006-03-17');
+select * from t1 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+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
+2006-09-06
+select * from t2 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t3 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t4 order by colint;
+colint col1
+60 2006-03-17
+select * from t5 order by colint;
+colint col1
+60 2006-03-17
+select * from t6 order by colint;
+colint col1
+60 2006-03-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with weekofyear(col1)
+-------------------------------------------------------------------------
+delete from t11 where col1='2006-03-17';
+delete from t22 where col1='2006-03-17';
+delete from t33 where col1='2006-03-17';
+delete from t44 where col1='2006-03-17';
+delete from t55 where col1='2006-03-17';
+delete from t66 where col1='2006-03-17';
+select * from t11 order by col1;
+col1
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+insert into t11 values ('2006-03-17');
+insert into t22 values ('2006-03-17');
+insert into t33 values ('2006-03-17');
+insert into t44 values (60,'2006-03-17');
+insert into t55 values (60,'2006-03-17');
+insert into t66 values (60,'2006-03-17');
+select * from t11 order by col1;
+col1
+2006-03-17
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-03-17
+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
+2006-09-06
+select * from t22 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t33 order by col1;
+col1
+2006-03-17
+2006-05-25
+2006-09-06
+select * from t44 order by colint;
+colint col1
+60 2006-03-17
+select * from t55 order by colint;
+colint col1
+60 2006-03-17
+select * from t66 order by colint;
+colint col1
+60 2006-03-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- year(col1)-1990 in partition with coltype date
+-------------------------------------------------------------------------
+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 year(col1)-1990
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(year(col1)-1990)
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(year(col1)-1990)
+(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 date) engine='NDB'
+partition by hash(year(col1)-1990);
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(year(col1)-1990) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(year(col1)-1990) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with year(col1)-1990
+-------------------------------------------------------------------------
+insert into t1 values ('1996-01-03');
+insert into t1 values ('2000-02-17');
+insert into t2 values ('1996-01-03');
+insert into t2 values ('2000-02-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select year(col1)-1990 from t1 order by col1;
+year(col1)-1990
+6
+10
+select * from t1 order by col1;
+col1
+1996-01-03
+2000-02-17
+select * from t2 order by col1;
+col1
+1996-01-03
+2000-02-17
+2004-05-25
+select * from t3 order by col1;
+col1
+1996-01-03
+2000-02-17
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t2 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with year(col1)-1990
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(year(col1)-1990)
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(year(col1)-1990)
+(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(year(col1)-1990);
+alter table t44
+partition by range(colint)
+subpartition by hash(year(col1)-1990) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(year(col1)-1990) 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 (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t22 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2000-02-17
+2002-02-15
+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
+2000-02-17
+2002-02-15
+alter table t55
+partition by list(colint)
+subpartition by hash(year(col1)-1990) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (year(col1)-1990) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (year('2005-10-14')-1990),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with year(col1)-1990
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2002-02-15
+select * from t2 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t2 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+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
+select * from t2 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t3 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t4 order by colint;
+colint col1
+60 2000-02-17
+select * from t5 order by colint;
+colint col1
+60 2000-02-17
+select * from t6 order by colint;
+colint col1
+60 2000-02-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with year(col1)-1990
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2002-02-15
+select * from t22 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2000-02-17
+2002-02-15
+select * from t22 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2000-02-17
+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
+select * from t22 order by col1;
+col1
+2002-02-15
+2004-05-25
+select * from t33 order by col1;
+col1
+2000-02-17
+2002-02-15
+2004-05-25
+select * from t44 order by colint;
+colint col1
+60 2000-02-17
+select * from t55 order by colint;
+colint col1
+60 2000-02-17
+select * from t66 order by colint;
+colint col1
+60 2000-02-17
+-------------------------
+---- 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 ;
+-------------------------------------------------------------------------
+--- yearweek(col1)-200600 in partition with coltype date
+-------------------------------------------------------------------------
+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 yearweek(col1)-200600
+-------------------------------------------------------------------------
+create table t1 (col1 date) engine='NDB'
+partition by range(yearweek(col1)-200600)
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t2 (col1 date) engine='NDB'
+partition by list(yearweek(col1)-200600)
+(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 date) engine='NDB'
+partition by hash(yearweek(col1)-200600);
+create table t4 (colint int, col1 date) engine='NDB'
+partition by range(colint)
+subpartition by hash(yearweek(col1)-200600) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+create table t5 (colint int, col1 date) engine='NDB'
+partition by list(colint)
+subpartition by hash(yearweek(col1)-200600) 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 date) engine='NDB'
+partition by range(colint)
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+-------------------------------------------------------------------------
+--- Access tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+insert into t1 values ('2006-01-03');
+insert into t1 values ('2006-08-17');
+insert into t2 values ('2006-01-03');
+insert into t2 values ('2006-08-17');
+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');
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t4;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t5;
+load data infile 'MYSQL_TEST_DIR/suite/partitions/include/partition_supported_sql_funcs_int_date.in' into table t6;
+select yearweek(col1)-200600 from t1 order by col1;
+yearweek(col1)-200600
+1
+33
+select * from t1 order by col1;
+col1
+2006-01-03
+2006-08-17
+select * from t2 order by col1;
+col1
+2006-01-03
+2006-03-25
+2006-08-17
+select * from t3 order by col1;
+col1
+2006-01-03
+2006-03-25
+2006-08-17
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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';
+select * from t1 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Alter tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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='NDB' as select * from t1;
+create table t22 engine='NDB' as select * from t2;
+create table t33 engine='NDB' as select * from t3;
+create table t44 engine='NDB' as select * from t4;
+create table t55 engine='NDB' as select * from t5;
+create table t66 engine='NDB' as select * from t6;
+alter table t11
+partition by range(yearweek(col1)-200600)
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t22
+partition by list(yearweek(col1)-200600)
+(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(yearweek(col1)-200600);
+alter table t44
+partition by range(colint)
+subpartition by hash(yearweek(col1)-200600) subpartitions 2
+(partition p0 values less than (15),
+partition p1 values less than maxvalue);
+alter table t55
+partition by list(colint)
+subpartition by hash(yearweek(col1)-200600) 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 (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t11 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+---------------------------
+---- 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
+2006-08-17
+2006-11-15
+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
+2006-08-17
+2006-11-15
+alter table t55
+partition by list(colint)
+subpartition by hash(yearweek(col1)-200600) 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` date DEFAULT NULL
+) ENGINE=NDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (yearweek(col1)-200600) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = NDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = NDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = NDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = NDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = NDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = NDB) */
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition p0,p1 into
+(partition s1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+alter table t66
+reorganize partition s1 into
+(partition p0 values less than (yearweek('2006-10-14')-200600),
+partition p1 values less than maxvalue);
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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';
+select * from t1 order by col1;
+col1
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t1 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t5 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t6 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+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
+2006-08-17
+2006-11-15
+select * from t2 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t3 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t4 order by colint;
+colint col1
+60 2006-08-17
+select * from t5 order by colint;
+colint col1
+60 2006-08-17
+select * from t6 order by colint;
+colint col1
+60 2006-08-17
+-------------------------------------------------------------------------
+--- Delete rows and partitions of tables with yearweek(col1)-200600
+-------------------------------------------------------------------------
+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';
+select * from t11 order by col1;
+col1
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+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');
+select * from t11 order by col1;
+col1
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t55 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+select * from t66 order by colint;
+colint col1
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05
+60 2006-08-17
+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
+2006-08-17
+2006-11-15
+select * from t22 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t33 order by col1;
+col1
+2006-03-25
+2006-08-17
+2006-11-15
+select * from t44 order by colint;
+colint col1
+60 2006-08-17
+select * from t55 order by colint;
+colint col1
+60 2006-08-17
+select * from t66 order by colint;
+colint col1
+60 2006-08-17
+-------------------------
+---- 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 ;
diff --git a/mysql-test/suite/partitions/r/partition_t55.out b/mysql-test/suite/partitions/r/partition_t55.out
new file mode 100644
index 00000000000..d86ceda8c38
--- /dev/null
+++ b/mysql-test/suite/partitions/r/partition_t55.out
@@ -0,0 +1,68 @@
+show create table t55;
+Table Create Table
+t55 CREATE TABLE `t55` (
+ `colint` int(11) DEFAULT NULL,
+ `col1` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (abs(col1)) 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) */
+27 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp0.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp0.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp1.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp1.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp2.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp2.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp3.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp3.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp4.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p0#SP#p0sp4.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp0.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp0.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp1.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp1.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp2.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp2.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp3.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp3.MYI
+36 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp4.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p1#SP#p1sp4.MYI
+36 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp0.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp0.MYI
+0 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp1.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp1.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp2.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp2.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp3.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp3.MYI
+27 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp4.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p2#SP#p2sp4.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp0.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp0.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp1.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp1.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp2.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp2.MYI
+18 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp3.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp3.MYI
+45 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp4.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p3#SP#p3sp4.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp0.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp0.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp1.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp1.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp2.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp2.MYI
+0 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp3.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp3.MYI
+0 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp4.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p4#SP#p4sp4.MYI
+0 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp0.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp0.MYI
+0 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp1.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp1.MYI
+0 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp2.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp2.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp3.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp3.MYI
+9 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp4.MYD
+1024 MYSQL_TEST_DIR/var/master-data/test/t55#P#p5#SP#p5sp4.MYI
+8594 MYSQL_TEST_DIR/var/master-data/test/t55.frm
+408 MYSQL_TEST_DIR/var/master-data/test/t55.par
diff --git a/mysql-test/suite/partitions/t/disabled.def b/mysql-test/suite/partitions/t/disabled.def
index ede5d6b6e60..212ca0206e2 100644
--- a/mysql-test/suite/partitions/t/disabled.def
+++ b/mysql-test/suite/partitions/t/disabled.def
@@ -13,4 +13,4 @@ partition_alter2_ndb : cannot create t1
partition_char_innodb : crash. Bug? More investigations
partition_sessions : needs system_3_init.inc
partition_engine_ndb : cannot create t1
-
+partition_supported_sql_func_ndb : cannot create t1
diff --git a/mysql-test/suite/partitions/t/partition_supported_sql_func_innodb.test b/mysql-test/suite/partitions/t/partition_supported_sql_func_innodb.test
index 4440f814d1e..135c869c841 100644
--- a/mysql-test/suite/partitions/t/partition_supported_sql_func_innodb.test
+++ b/mysql-test/suite/partitions/t/partition_supported_sql_func_innodb.test
@@ -2,8 +2,8 @@
# t/partition_supported_sql_funcs_innodb.test #
# #
# Purpose: #
-# Tests around sql functions #
-# INNODB branch #
+# Tests which SQL functions are allowed in partinioning clauses with #
+# INNODB. #
# #
#------------------------------------------------------------------------------#
# Original Author: HH #
@@ -18,16 +18,12 @@
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
-# Please read the README at the end of include/partition.pre before changing
-# any of the variables.
-#
-
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
##### Options, for debugging support #####
let $debug= 0;
-let $do_long_tests= 0;
+let $do_long_tests= 1;
# The server must support partitioning.
--source include/have_partition.inc
diff --git a/mysql-test/suite/partitions/t/partition_supported_sql_func_myisam.test b/mysql-test/suite/partitions/t/partition_supported_sql_func_myisam.test
index 3daa72c7ff7..131a5e23f39 100644
--- a/mysql-test/suite/partitions/t/partition_supported_sql_func_myisam.test
+++ b/mysql-test/suite/partitions/t/partition_supported_sql_func_myisam.test
@@ -2,8 +2,8 @@
# t/partition_supported_sql_funcs_myisam.test #
# #
# Purpose: #
-# Tests around sql functions #
-# MyISAM branch #
+# Tests which SQL functions are allowed in partinioning clauses with #
+# MYISAM. #
# #
#------------------------------------------------------------------------------#
# Original Author: HH #
@@ -27,7 +27,7 @@
##### Options, for debugging support #####
let $debug= 0;
-let $do_long_tests= 0;
+let $do_long_tests= 1;
# The server must support partitioning.
--source include/have_partition.inc
diff --git a/mysql-test/suite/partitions/t/partition_supported_sql_func_ndb.test b/mysql-test/suite/partitions/t/partition_supported_sql_func_ndb.test
new file mode 100644
index 00000000000..2a536fbce94
--- /dev/null
+++ b/mysql-test/suite/partitions/t/partition_supported_sql_func_ndb.test
@@ -0,0 +1,40 @@
+################################################################################
+# t/partition_supported_sql_funcs_myisam.test #
+# #
+# Purpose: #
+# Tests which SQL functions are allowed in partinioning clauses with #
+# NDB. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT NDB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+let $do_long_tests= 1;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+--source include/have_ndb.inc
+##### Storage engine to be tested
+let $engine= 'NDB';
+
+#------------------------------------------------------------------------------#
+--source suite/partitions/include/partition_supported_sql_funcs_main.inc
+# --source include/partition_supported_sql_funcs_main.inc
+
diff --git a/mysql-test/suite/row_lock/include/row_lock.inc b/mysql-test/suite/row_lock/include/row_lock.inc
new file mode 100644
index 00000000000..8572bc0246e
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock.inc
@@ -0,0 +1,83 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+eval $indext2;
+COMMIT;
+SELECT @@global.tx_isolation;
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP TABLE t1, t2;
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_big_tab.inc b/mysql-test/suite/row_lock/include/row_lock_big_tab.inc
new file mode 100644
index 00000000000..f0823067eac
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_big_tab.inc
@@ -0,0 +1,94 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+eval $indext2;
+DELIMITER |;
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+ INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+ SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+ DECLARE res int DEFAULT 0;
+ SELECT count(*)/2 INTO res FROM t1;
+ RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+ INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+ SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+ DECLARE res int DEFAULT 0;
+ SELECT count(*)/2 INTO res FROM t2;
+ RETURN res;
+END;
+|
+DELIMITER ;|
+CALL fill_t1 (10);
+CALL fill_t2 (10);
+COMMIT;
+SELECT @@global.tx_isolation;
+# With the two separate selects (without join) the differs from
+# that select with join.
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT k from t1 WHERE k < half_t1();
+SELECT k from t1 WHERE k >= half_t1();
+UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP VIEW IF EXISTS v1;
+DROP TABLE t1, t2;
+#DROP VIEW v1;
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc b/mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc
new file mode 100644
index 00000000000..8535c016819
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc
@@ -0,0 +1,93 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+eval $indext2;
+DELIMITER |;
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+ INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+ SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+ DECLARE res int DEFAULT 0;
+ SELECT MOD(k,2) INTO res FROM t1;
+ RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+ INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+ SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+ DECLARE res int DEFAULT 0;
+ SELECT MOD(k,2) INTO res FROM t2;
+ RETURN res;
+END;
+|
+DELIMITER ;|
+eval CALL fill_t1 ($nbrows);
+eval CALL fill_t2 ($nbrows);
+COMMIT;
+SELECT @@global.tx_isolation;
+# With the two separate selects (without join) the differs from
+# that select with join.
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE;
+UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k;
+SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
+SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
+
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP TABLE t1, t2;
+
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc b/mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc
new file mode 100644
index 00000000000..050f2a54016
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc
@@ -0,0 +1,93 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+eval $indext2;
+DELIMITER |;
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+ INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+ SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+ DECLARE res int DEFAULT 0;
+ SELECT MOD(k,2) INTO res FROM t1;
+ RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+ INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+ SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+ DECLARE res int DEFAULT 0;
+ SELECT MOD(k,2) INTO res FROM t2;
+ RETURN res;
+END;
+|
+DELIMITER ;|
+eval CALL fill_t1 ($nbrows);
+eval CALL fill_t2 ($nbrows);
+COMMIT;
+SELECT @@global.tx_isolation;
+# With the two separate selects (without join) the differs from
+# that select with join.
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+
+--echo connection root1;
+CONNECTION root1;
+#SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k FOR UPDATE;
+DELETE FROM t1 WHERE t1.k % 2 = 1;
+SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
+SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
+
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
+SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP TABLE t1, t2;
+
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_trig.inc b/mysql-test/suite/row_lock/include/row_lock_trig.inc
new file mode 100644
index 00000000000..384f00f243e
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_trig.inc
@@ -0,0 +1,96 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+eval $indext2;
+DELIMITER |;
+
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+ FOR EACH ROW BEGIN
+ UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
+ END;
+|
+
+DELIMITER ;|
+
+COMMIT;
+SELECT @@global.tx_isolation;
+# With the two separate selects (without join) the differs from
+# that select with join.
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+--echo connection root1;
+CONNECTION root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t2 SET t2.i=223 WHERE t2.i=123;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE t2 SET t2.i=226 WHERE t2.i=126;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t2 SET t2.i=224 WHERE t2.i=124;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP TABLE t1, t2;
+#DROP VIEW v1;
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_view.inc b/mysql-test/suite/row_lock/include/row_lock_view.inc
new file mode 100644
index 00000000000..fbed8f64d3a
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_view.inc
@@ -0,0 +1,89 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+eval $indext2;
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+# With the two separate selects (without join) the differs from
+# that select with join.
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE v1 SET i=325 where i=125;
+SELECT * FROM v1 ORDER BY i,l;
+SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE v1 SET i=323 where i=123;
+SELECT * FROM v1 ORDER BY i,l;
+SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE v1 SET i=326 where i=126;
+SELECT * FROM v1 ORDER BY i,l;
+SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE v1 SET i=324 where i=124;
+SELECT * FROM v1 ORDER BY i,l;
+SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection root1;
+CONNECTION root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP VIEW IF EXISTS v1;
+DROP TABLE t1, t2;
+#DROP VIEW v1;
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_view_mix.inc b/mysql-test/suite/row_lock/include/row_lock_view_mix.inc
new file mode 100644
index 00000000000..9e8cf3d34fc
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_view_mix.inc
@@ -0,0 +1,92 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+eval $indext2;
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+# With the two separate selects (without join) the differs from
+# that select with join.
+
+# Both transaction are able to update the tables
+eval EXPLAIN $select;
+eval $select;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+#UPDATE v1 SET i=325 where i=125;
+#SELECT * FROM v1 ORDER BY i,l;
+#SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE v1 SET i=323 where i=123;
+SELECT * FROM v1 ORDER BY i,l;
+SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE v1 SET i=324 where i=124;
+SELECT * FROM v1 ORDER BY i,l;
+SELECT * FROM t1 ORDER BY t1.k;
+
+--echo connection root1;
+CONNECTION root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP VIEW IF EXISTS v1;
+DROP TABLE t1, t2;
+#DROP VIEW v1;
+
diff --git a/mysql-test/suite/row_lock/include/row_lock_view_storedp.inc b/mysql-test/suite/row_lock/include/row_lock_view_storedp.inc
new file mode 100644
index 00000000000..479392098be
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_view_storedp.inc
@@ -0,0 +1,126 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+DROP PROCEDURE IF EXISTS stp_t;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+CONNECT (root2, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+INSERT INTO t1 VALUES (5,127,5,127);
+INSERT INTO t1 VALUES (6,128,6,128);
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+INSERT INTO t2 VALUES (5,127,5,127);
+INSERT INTO t2 VALUES (6,128,6,128);
+eval $indext2;
+CREATE VIEW v1 AS SELECT t1.i from t1;
+DELIMITER |;
+
+CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
+ BEGIN
+ UPDATE t2 SET i = p2 WHERE i = p1;
+ UPDATE v1 SET i = p2 WHERE i = p1;
+ SELECT * FROM v1 ORDER BY i;
+ SELECT * FROM t1 ORDER BY t1.k;
+ SELECT * FROM t2 ORDER BY t2.k;
+ END;
+|
+
+DELIMITER ;|
+
+COMMIT;
+SELECT @@global.tx_isolation;
+eval EXPLAIN $select;
+eval $select;
+--echo connection root1;
+CONNECTION root1;
+CALL stp_t (125, 225);
+
+--echo connection root2;
+CONNECTION root2;
+CALL stp_t (127, 227);
+
+--echo connection default;
+CONNECTION default;
+CALL stp_t (123, 223);
+
+--echo connection root1;
+CONNECTION root1;
+CALL stp_t (126, 226);
+
+--echo connection root2;
+CONNECTION root2;
+CALL stp_t (128, 228);
+
+--echo connection default;
+CONNECTION default;
+CALL stp_t (124, 224);
+
+--echo connection root1;
+CONNECTION root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root2;
+CONNECTION root2;
+DELETE FROM t1 WHERE t1.i=228;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection root1;
+CONNECTION root1;
+COMMIT;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+
+--echo connection root2;
+CONNECTION root2;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root2;
+
+--echo connection default;
+CONNECTION default;
+--disable_warnings
+DROP VIEW v1;
+DROP PROCEDURE stp_t;
+DROP TABLE t1, t2;
+--enable_warnings
diff --git a/mysql-test/suite/row_lock/include/row_lock_view_trig.inc b/mysql-test/suite/row_lock/include/row_lock_view_trig.inc
new file mode 100644
index 00000000000..785eb1b66a9
--- /dev/null
+++ b/mysql-test/suite/row_lock/include/row_lock_view_trig.inc
@@ -0,0 +1,99 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+SET autocommit=0;
+# Create additional connections used through test
+CONNECT (root1, localhost, root,,);
+SET autocommit=0;
+--echo connection default;
+CONNECTION default;
+eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+eval $indext1;
+eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+eval $indext2;
+CREATE VIEW v1 AS SELECT t1.i from t1;
+DELIMITER |;
+
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+ FOR EACH ROW BEGIN
+ UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
+ END;
+|
+
+DELIMITER ;|
+
+COMMIT;
+SELECT @@global.tx_isolation;
+eval EXPLAIN $select;
+eval $select;
+--echo connection root1;
+CONNECTION root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t2 SET t2.i=223 WHERE t2.i=123;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+UPDATE t2 SET t2.i=226 WHERE t2.i=126;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+UPDATE t2 SET t2.i=224 WHERE t2.i=124;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection default;
+CONNECTION default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+COMMIT;
+
+--echo connection root1;
+CONNECTION root1;
+ROLLBACK;
+
+--echo connection default;
+CONNECTION default;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+
+--echo connection root1;
+CONNECTION root1;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+DISCONNECT root1;
+--echo connection default;
+CONNECTION default;
+DROP TABLE t1, t2;
+DROP VIEW v1;
+
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_1.result
new file mode 100644
index 00000000000..54ed4350ba9
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_1.result
@@ -0,0 +1,142 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_2.result
new file mode 100644
index 00000000000..56154e64489
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_2.result
@@ -0,0 +1,32 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_3.result b/mysql-test/suite/row_lock/r/innodb_row_lock_3.result
new file mode 100644
index 00000000000..a89c55973d2
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_3.result
@@ -0,0 +1,32 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_4.result b/mysql-test/suite/row_lock/r/innodb_row_lock_4.result
new file mode 100644
index 00000000000..310d24a456a
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_4.result
@@ -0,0 +1,142 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_5.result b/mysql-test/suite/row_lock/r/innodb_row_lock_5.result
new file mode 100644
index 00000000000..ace5fddfad5
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_5.result
@@ -0,0 +1,32 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result
new file mode 100644
index 00000000000..8f00c3a0bb7
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result
@@ -0,0 +1,97 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+CREATE INDEX ixi ON t2 (i);
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT count(*)/2 INTO res FROM t1;
+RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT count(*)/2 INTO res FROM t2;
+RETURN res;
+END;
+|
+CALL fill_t1 (10);
+CALL fill_t2 (10);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 10 Using where; Using index
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where; Using index
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+connection root1;
+SELECT k from t1 WHERE k < half_t1();
+k
+0
+1
+2
+3
+4
+SELECT k from t1 WHERE k >= half_t1();
+k
+5
+6
+7
+8
+9
+UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+0 1111 0 100
+1 1111 1 101
+2 1111 2 102
+3 1111 3 103
+4 1111 4 104
+5 105 5 105
+6 106 6 106
+7 107 7 107
+8 108 8 108
+9 109 9 109
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+0 2222 0 100
+1 2222 1 101
+2 2222 2 102
+3 2222 3 103
+4 2222 4 104
+5 105 5 105
+6 106 6 106
+7 107 7 107
+8 108 8 108
+9 109 9 109
+connection default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result
new file mode 100644
index 00000000000..0b12f149193
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result
@@ -0,0 +1,145 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+CREATE INDEX ixi ON t2 (i);
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t1;
+RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t2;
+RETURN res;
+END;
+|
+CALL fill_t1 (40);
+CALL fill_t2 (40);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY ixi 5 NULL 40 Using where; Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
+i i
+100 100
+102 102
+104 104
+106 106
+108 108
+110 110
+112 112
+114 114
+116 116
+118 118
+120 120
+122 122
+124 124
+126 126
+128 128
+130 130
+132 132
+134 134
+136 136
+138 138
+connection root1;
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE;
+i i
+101 101
+103 103
+105 105
+107 107
+109 109
+111 111
+113 113
+115 115
+117 117
+119 119
+121 121
+123 123
+125 125
+127 127
+129 129
+131 131
+133 133
+135 135
+137 137
+139 139
+UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k;
+SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
+k i j l
+0 100 0 100
+1 1111 1 101
+2 102 2 102
+3 1111 3 103
+4 104 4 104
+5 1111 5 105
+6 106 6 106
+7 1111 7 107
+8 108 8 108
+9 1111 9 109
+10 110 10 110
+11 1111 11 111
+12 112 12 112
+13 1111 13 113
+14 114 14 114
+15 1111 15 115
+16 116 16 116
+17 1111 17 117
+18 118 18 118
+19 1111 19 119
+SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
+k i j l
+0 100 0 100
+1 2222 1 101
+2 102 2 102
+3 2222 3 103
+4 104 4 104
+5 2222 5 105
+6 106 6 106
+7 2222 7 107
+8 108 8 108
+9 2222 9 109
+10 110 10 110
+11 2222 11 111
+12 112 12 112
+13 2222 13 113
+14 114 14 114
+15 2222 15 115
+16 116 16 116
+17 2222 17 117
+18 118 18 118
+19 2222 19 119
+connection default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result
new file mode 100644
index 00000000000..cc9f297f9fb
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result
@@ -0,0 +1,113 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+CREATE INDEX ixi ON t2 (i);
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t1;
+RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t2;
+RETURN res;
+END;
+|
+CALL fill_t1 (40);
+CALL fill_t2 (40);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY ixi 5 NULL 40 Using where; Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
+i i
+100 100
+102 102
+104 104
+106 106
+108 108
+110 110
+112 112
+114 114
+116 116
+118 118
+120 120
+122 122
+124 124
+126 126
+128 128
+130 130
+132 132
+134 134
+136 136
+138 138
+connection root1;
+DELETE FROM t1 WHERE t1.k % 2 = 1;
+SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
+k i j l
+0 100 0 100
+2 102 2 102
+4 104 4 104
+6 106 6 106
+8 108 8 108
+10 110 10 110
+12 112 12 112
+14 114 14 114
+16 116 16 116
+18 118 18 118
+SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 105 5 105
+6 106 6 106
+7 107 7 107
+8 108 8 108
+9 109 9 109
+10 110 10 110
+11 111 11 111
+12 112 12 112
+13 113 13 113
+14 114 14 114
+15 115 15 115
+16 116 16 116
+17 117 17 117
+18 118 18 118
+19 119 19 119
+connection default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result
new file mode 100644
index 00000000000..dd43e5752e5
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result
@@ -0,0 +1,151 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 225
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t2 SET t2.i=223 WHERE t2.i=123;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t2 SET t2.i=226 WHERE t2.i=126;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 225
+4 126 4 226
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t2 SET t2.i=224 WHERE t2.i=124;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 225
+4 126 4 226
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result
new file mode 100644
index 00000000000..cb3a5c692e9
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result
@@ -0,0 +1,37 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result
new file mode 100644
index 00000000000..834cb669833
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result
@@ -0,0 +1,34 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE v1 SET i=325 where i=125;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result
new file mode 100644
index 00000000000..440138d4cd1
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result
@@ -0,0 +1,40 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 4 Using index
+SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+i
+123
+124
+123
+124
+123
+124
+123
+124
+connection root1;
+UPDATE v1 SET i=325 where i=125;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result
new file mode 100644
index 00000000000..230873b67a0
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result
@@ -0,0 +1,48 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE v1 SET i=323 where i=123;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result
new file mode 100644
index 00000000000..d792d573f8e
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result
@@ -0,0 +1,40 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 4 Using index
+SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+i
+123
+124
+123
+124
+123
+124
+123
+124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result
new file mode 100644
index 00000000000..77b9a4dd964
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result
@@ -0,0 +1,312 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+INSERT INTO t1 VALUES (5,127,5,127);
+INSERT INTO t1 VALUES (6,128,6,128);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+INSERT INTO t2 VALUES (5,127,5,127);
+INSERT INTO t2 VALUES (6,128,6,128);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
+BEGIN
+UPDATE t2 SET i = p2 WHERE i = p1;
+UPDATE v1 SET i = p2 WHERE i = p1;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 6 Using where; Using index
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+CALL stp_t (125, 225);
+i
+123
+124
+126
+127
+128
+225
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+CALL stp_t (127, 227);
+i
+123
+124
+125
+126
+128
+227
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 128 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 128 6 128
+connection default;
+CALL stp_t (123, 223);
+i
+124
+125
+126
+127
+128
+223
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root1;
+CALL stp_t (126, 226);
+i
+123
+124
+127
+128
+225
+226
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+CALL stp_t (128, 228);
+i
+123
+124
+125
+126
+227
+228
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+connection default;
+CALL stp_t (124, 224);
+i
+125
+126
+127
+128
+223
+224
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+DELETE FROM t1 WHERE t1.i=228;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+COMMIT;
+connection root1;
+ROLLBACK;
+connection root1;
+COMMIT;
+connection default;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+127
+128
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root1;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+127
+128
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+SELECT * FROM v1 ORDER BY i;
+i
+123
+124
+125
+126
+227
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+connection default;
+DROP TABLE t1, t2;
+DROP VIEW v1;
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result
new file mode 100644
index 00000000000..73d8a3f4bea
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result
@@ -0,0 +1,47 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+INSERT INTO t1 VALUES (5,127,5,127);
+INSERT INTO t1 VALUES (6,128,6,128);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+INSERT INTO t2 VALUES (5,127,5,127);
+INSERT INTO t2 VALUES (6,128,6,128);
+#CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
+BEGIN
+UPDATE t2 SET i = p2 WHERE i = p1;
+UPDATE v1 SET i = p2 WHERE i = p1;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+CALL stp_t (125, 225);
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result
new file mode 100644
index 00000000000..90383a9489f
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result
@@ -0,0 +1,183 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
+SELECT * FROM v1 ORDER BY i;
+i
+123
+124
+126
+225
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t2 SET t2.i=223 WHERE t2.i=123;
+SELECT * FROM v1 ORDER BY i;
+i
+124
+125
+126
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t2 SET t2.i=226 WHERE t2.i=126;
+SELECT * FROM v1 ORDER BY i;
+i
+123
+124
+225
+226
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t2 SET t2.i=224 WHERE t2.i=124;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+224
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
+DROP VIEW v1;
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result
new file mode 100644
index 00000000000..55793558b21
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result
@@ -0,0 +1,38 @@
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_1.result
new file mode 100644
index 00000000000..248c7d5ea1f
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_1.result
@@ -0,0 +1,139 @@
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_2.result
new file mode 100644
index 00000000000..109d99dd036
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_2.result
@@ -0,0 +1,31 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_3.result b/mysql-test/suite/row_lock/r/ndb_row_lock_3.result
new file mode 100644
index 00000000000..c936ea209ff
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_3.result
@@ -0,0 +1,30 @@
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_4.result b/mysql-test/suite/row_lock/r/ndb_row_lock_4.result
new file mode 100644
index 00000000000..875c783bd81
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_4.result
@@ -0,0 +1,139 @@
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_5.result b/mysql-test/suite/row_lock/r/ndb_row_lock_5.result
new file mode 100644
index 00000000000..0d94f8abf72
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_5.result
@@ -0,0 +1,30 @@
+DROP TABLE IF EXISTS t1, t2;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result
new file mode 100644
index 00000000000..94b67c63d94
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result
@@ -0,0 +1,177 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+CREATE INDEX ixi ON t2 (i);
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT count(*)/2 INTO res FROM t1;
+RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT count(*)/2 INTO res FROM t2;
+RETURN res;
+END;
+|
+CALL fill_t1 (10);
+CALL fill_t2 (10);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
+i i
+connection root1;
+SELECT k from t1 WHERE k < half_t1();
+k
+0
+3
+1
+2
+4
+SELECT k from t1 WHERE k >= half_t1();
+k
+6
+7
+9
+5
+8
+UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+0 1111 0 100
+1 1111 1 101
+2 1111 2 102
+3 1111 3 103
+4 1111 4 104
+5 105 5 105
+6 106 6 106
+7 107 7 107
+8 108 8 108
+9 109 9 109
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+0 2222 0 100
+1 2222 1 101
+2 2222 2 102
+3 2222 3 103
+4 2222 4 104
+5 105 5 105
+6 106 6 106
+7 107 7 107
+8 108 8 108
+9 109 9 109
+connection default;
+UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 3333 5 105
+6 3333 6 106
+7 3333 7 107
+8 3333 8 108
+9 3333 9 109
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 4444 5 105
+6 4444 6 106
+7 4444 7 107
+8 4444 8 108
+9 4444 9 109
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 3333 5 105
+6 3333 6 106
+7 3333 7 107
+8 3333 8 108
+9 3333 9 109
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 4444 5 105
+6 4444 6 106
+7 4444 7 107
+8 4444 8 108
+9 4444 9 109
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 3333 5 105
+6 3333 6 106
+7 3333 7 107
+8 3333 8 108
+9 3333 9 109
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+0 100 0 100
+1 101 1 101
+2 102 2 102
+3 103 3 103
+4 104 4 104
+5 4444 5 105
+6 4444 6 106
+7 4444 7 107
+8 4444 8 108
+9 4444 9 109
+connection default;
+DROP VIEW IF EXISTS v1;
+Warnings:
+Note 1051 Unknown table 'test.v1'
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result
new file mode 100644
index 00000000000..9803895e1a7
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result
@@ -0,0 +1,357 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+CREATE INDEX ixi ON t2 (i);
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t1;
+RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t2;
+RETURN res;
+END;
+|
+CALL fill_t1 (200);
+CALL fill_t2 (200);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 200 Using where
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
+i i
+135 135
+119 119
+211 211
+184 184
+232 232
+105 105
+188 188
+216 216
+255 255
+154 154
+197 197
+279 279
+218 218
+127 127
+203 203
+281 281
+194 194
+161 161
+276 276
+122 122
+139 139
+183 183
+114 114
+247 247
+144 144
+148 148
+174 174
+267 267
+142 142
+168 168
+226 226
+258 258
+231 231
+146 146
+253 253
+189 189
+230 230
+290 290
+178 178
+158 158
+130 130
+214 214
+133 133
+229 229
+294 294
+295 295
+108 108
+112 112
+297 297
+151 151
+251 251
+270 270
+291 291
+159 159
+132 132
+121 121
+244 244
+272 272
+293 293
+186 186
+111 111
+166 166
+201 201
+175 175
+180 180
+209 209
+192 192
+246 246
+195 195
+107 107
+233 233
+239 239
+103 103
+109 109
+128 128
+266 266
+143 143
+160 160
+187 187
+243 243
+273 273
+259 259
+110 110
+176 176
+141 141
+170 170
+215 215
+191 191
+200 200
+271 271
+162 162
+260 260
+106 106
+150 150
+126 126
+147 147
+155 155
+193 193
+207 207
+287 287
+235 235
+252 252
+129 129
+205 205
+268 268
+278 278
+116 116
+137 137
+199 199
+217 217
+234 234
+190 190
+236 236
+257 257
+100 100
+210 210
+212 212
+264 264
+221 221
+241 241
+256 256
+262 262
+265 265
+269 269
+277 277
+173 173
+177 177
+208 208
+219 219
+285 285
+101 101
+164 164
+113 113
+125 125
+202 202
+140 140
+156 156
+282 282
+181 181
+206 206
+299 299
+102 102
+145 145
+227 227
+196 196
+138 138
+198 198
+204 204
+237 237
+171 171
+284 284
+263 263
+292 292
+104 104
+149 149
+250 250
+296 296
+228 228
+280 280
+242 242
+248 248
+185 185
+220 220
+245 245
+275 275
+118 118
+120 120
+152 152
+153 153
+157 157
+182 182
+179 179
+254 254
+288 288
+172 172
+283 283
+286 286
+115 115
+238 238
+289 289
+131 131
+223 223
+134 134
+136 136
+222 222
+225 225
+261 261
+274 274
+123 123
+163 163
+224 224
+117 117
+298 298
+169 169
+124 124
+167 167
+240 240
+249 249
+165 165
+213 213
+connection root1;
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE;
+i i
+209 209
+195 195
+107 107
+233 233
+239 239
+103 103
+109 109
+143 143
+187 187
+243 243
+273 273
+259 259
+141 141
+215 215
+191 191
+271 271
+147 147
+155 155
+193 193
+207 207
+287 287
+235 235
+129 129
+205 205
+137 137
+199 199
+217 217
+257 257
+221 221
+241 241
+265 265
+269 269
+277 277
+173 173
+177 177
+135 135
+119 119
+211 211
+105 105
+255 255
+197 197
+279 279
+127 127
+203 203
+281 281
+161 161
+139 139
+183 183
+247 247
+267 267
+231 231
+253 253
+189 189
+133 133
+229 229
+295 295
+297 297
+151 151
+251 251
+291 291
+159 159
+121 121
+293 293
+111 111
+201 201
+175 175
+185 185
+245 245
+275 275
+153 153
+157 157
+179 179
+283 283
+115 115
+289 289
+131 131
+223 223
+225 225
+261 261
+123 123
+163 163
+117 117
+169 169
+167 167
+249 249
+165 165
+213 213
+219 219
+285 285
+101 101
+113 113
+125 125
+181 181
+299 299
+145 145
+227 227
+237 237
+171 171
+263 263
+149 149
+UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result
new file mode 100644
index 00000000000..adb89b03480
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result
@@ -0,0 +1,255 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+CREATE INDEX ixi ON t2 (i);
+CREATE PROCEDURE fill_t1 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t1() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t1;
+RETURN res;
+END;
+|
+CREATE PROCEDURE fill_t2 (IN upb int)
+BEGIN
+DECLARE cnt int DEFAULT 0;
+WHILE cnt < upb DO
+INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
+SET cnt= cnt+1;
+END WHILE;
+END;
+|
+CREATE FUNCTION half_t2() RETURNS int
+BEGIN
+DECLARE res int DEFAULT 0;
+SELECT MOD(k,2) INTO res FROM t2;
+RETURN res;
+END;
+|
+CALL fill_t1 (200);
+CALL fill_t2 (200);
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 200 Using where
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
+i i
+135 135
+119 119
+211 211
+184 184
+232 232
+105 105
+188 188
+216 216
+255 255
+154 154
+197 197
+279 279
+218 218
+127 127
+203 203
+281 281
+194 194
+161 161
+276 276
+122 122
+139 139
+183 183
+114 114
+247 247
+144 144
+148 148
+174 174
+267 267
+142 142
+168 168
+226 226
+258 258
+231 231
+146 146
+253 253
+189 189
+230 230
+290 290
+178 178
+158 158
+130 130
+214 214
+133 133
+229 229
+294 294
+295 295
+108 108
+112 112
+297 297
+151 151
+251 251
+270 270
+291 291
+159 159
+132 132
+121 121
+244 244
+272 272
+293 293
+186 186
+111 111
+166 166
+201 201
+175 175
+180 180
+209 209
+192 192
+246 246
+195 195
+107 107
+233 233
+239 239
+103 103
+109 109
+128 128
+266 266
+143 143
+160 160
+187 187
+243 243
+273 273
+259 259
+110 110
+176 176
+141 141
+170 170
+215 215
+191 191
+200 200
+271 271
+162 162
+260 260
+106 106
+150 150
+126 126
+147 147
+155 155
+193 193
+207 207
+287 287
+235 235
+252 252
+129 129
+205 205
+268 268
+278 278
+116 116
+137 137
+199 199
+217 217
+234 234
+190 190
+236 236
+257 257
+100 100
+210 210
+212 212
+264 264
+221 221
+241 241
+256 256
+262 262
+265 265
+269 269
+277 277
+173 173
+177 177
+208 208
+219 219
+285 285
+101 101
+164 164
+113 113
+125 125
+202 202
+140 140
+156 156
+282 282
+181 181
+206 206
+299 299
+102 102
+145 145
+227 227
+196 196
+138 138
+198 198
+204 204
+237 237
+171 171
+284 284
+263 263
+292 292
+104 104
+149 149
+250 250
+296 296
+228 228
+280 280
+242 242
+248 248
+185 185
+220 220
+245 245
+275 275
+118 118
+120 120
+152 152
+153 153
+157 157
+182 182
+179 179
+254 254
+288 288
+172 172
+283 283
+286 286
+115 115
+238 238
+289 289
+131 131
+223 223
+134 134
+136 136
+222 222
+225 225
+261 261
+274 274
+123 123
+163 163
+224 224
+117 117
+298 298
+169 169
+124 124
+167 167
+240 240
+249 249
+165 165
+213 213
+connection root1;
+DELETE FROM t1 WHERE t1.k % 2 = 1;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result
new file mode 100644
index 00000000000..eb69fd2e306
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result
@@ -0,0 +1,148 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 225
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t2 SET t2.i=223 WHERE t2.i=123;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t2 SET t2.i=226 WHERE t2.i=126;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 225
+4 126 4 226
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t2 SET t2.i=224 WHERE t2.i=124;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 225
+4 126 4 226
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 223
+2 124 2 224
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result
new file mode 100644
index 00000000000..bedb75da93a
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result
@@ -0,0 +1,35 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result
new file mode 100644
index 00000000000..279f2626c73
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result
@@ -0,0 +1,194 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE v1 SET i=325 where i=125;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+123 123
+123 124
+123 125
+123 126
+124 123
+124 124
+124 125
+124 126
+126 123
+126 124
+126 125
+126 126
+325 123
+325 124
+325 125
+325 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 325 3 125
+4 126 4 126
+connection default;
+UPDATE v1 SET i=323 where i=123;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+124 123
+124 124
+124 125
+124 126
+125 123
+125 124
+125 125
+125 126
+126 123
+126 124
+126 125
+126 126
+323 123
+323 124
+323 125
+323 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE v1 SET i=326 where i=126;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+123 123
+123 124
+123 125
+123 126
+124 123
+124 124
+124 125
+124 126
+325 123
+325 124
+325 125
+325 126
+326 123
+326 124
+326 125
+326 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 325 3 125
+4 326 4 126
+connection default;
+UPDATE v1 SET i=324 where i=124;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+125 123
+125 124
+125 125
+125 126
+126 123
+126 124
+126 125
+126 126
+323 123
+323 124
+323 125
+323 126
+324 123
+324 124
+324 125
+324 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 325 3 125
+4 326 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP VIEW IF EXISTS v1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result
new file mode 100644
index 00000000000..9e74e93b0cc
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result
@@ -0,0 +1,200 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4
+SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+i
+123
+124
+123
+124
+123
+124
+123
+124
+connection root1;
+UPDATE v1 SET i=325 where i=125;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+123 123
+123 124
+123 125
+123 126
+124 123
+124 124
+124 125
+124 126
+126 123
+126 124
+126 125
+126 126
+325 123
+325 124
+325 125
+325 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 325 3 125
+4 126 4 126
+connection default;
+UPDATE v1 SET i=323 where i=123;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+124 123
+124 124
+124 125
+124 126
+125 123
+125 124
+125 125
+125 126
+126 123
+126 124
+126 125
+126 126
+323 123
+323 124
+323 125
+323 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE v1 SET i=326 where i=126;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+123 123
+123 124
+123 125
+123 126
+124 123
+124 124
+124 125
+124 126
+325 123
+325 124
+325 125
+325 126
+326 123
+326 124
+326 125
+326 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 325 3 125
+4 326 4 126
+connection default;
+UPDATE v1 SET i=324 where i=124;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+125 123
+125 124
+125 125
+125 126
+126 123
+126 124
+126 125
+126 126
+323 123
+323 124
+323 125
+323 126
+324 123
+324 124
+324 125
+324 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 325 3 125
+4 326 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP VIEW IF EXISTS v1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result
new file mode 100644
index 00000000000..b5b1c519702
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result
@@ -0,0 +1,169 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where
+SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+i i
+123 123
+124 124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE v1 SET i=323 where i=123;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+124 123
+124 124
+124 125
+124 126
+125 123
+125 124
+125 125
+125 126
+126 123
+126 124
+126 125
+126 126
+323 123
+323 124
+323 125
+323 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE v1 SET i=324 where i=124;
+SELECT * FROM v1 ORDER BY i,l;
+i l
+125 123
+125 124
+125 125
+125 126
+126 123
+126 124
+126 125
+126 126
+323 123
+323 124
+323 125
+323 126
+324 123
+324 124
+324 125
+324 126
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 323 1 123
+2 324 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP VIEW IF EXISTS v1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result
new file mode 100644
index 00000000000..d92f9ad9664
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result
@@ -0,0 +1,38 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4
+SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+i
+123
+124
+123
+124
+123
+124
+123
+124
+connection root1;
+UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result
new file mode 100644
index 00000000000..e2a2a6e7deb
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result
@@ -0,0 +1,309 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+DROP PROCEDURE IF EXISTS stp_t;
+SET autocommit=0;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+INSERT INTO t1 VALUES (5,127,5,127);
+INSERT INTO t1 VALUES (6,128,6,128);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+INSERT INTO t2 VALUES (5,127,5,127);
+INSERT INTO t2 VALUES (6,128,6,128);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
+BEGIN
+UPDATE t2 SET i = p2 WHERE i = p1;
+UPDATE v1 SET i = p2 WHERE i = p1;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+CALL stp_t (125, 225);
+i
+123
+124
+126
+127
+128
+225
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+CALL stp_t (127, 227);
+i
+123
+124
+125
+126
+128
+227
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 128 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 128 6 128
+connection default;
+CALL stp_t (123, 223);
+i
+124
+125
+126
+127
+128
+223
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root1;
+CALL stp_t (126, 226);
+i
+123
+124
+127
+128
+225
+226
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+CALL stp_t (128, 228);
+i
+123
+124
+125
+126
+227
+228
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+connection default;
+CALL stp_t (124, 224);
+i
+125
+126
+127
+128
+223
+224
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+DELETE FROM t1 WHERE t1.i=228;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+COMMIT;
+connection root1;
+ROLLBACK;
+connection root1;
+COMMIT;
+connection default;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+127
+128
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root1;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+127
+128
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 127 5 127
+6 128 6 128
+connection root2;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+227
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+5 227 5 127
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+5 227 5 127
+6 228 6 128
+connection default;
+DROP VIEW v1;
+DROP PROCEDURE stp_t;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result
new file mode 100644
index 00000000000..6dbd5f834ed
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result
@@ -0,0 +1,46 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+DROP PROCEDURE IF EXISTS stp_t;
+SET autocommit=0;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+INSERT INTO t1 VALUES (5,127,5,127);
+INSERT INTO t1 VALUES (6,128,6,128);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+INSERT INTO t2 VALUES (5,127,5,127);
+INSERT INTO t2 VALUES (6,128,6,128);
+#CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
+BEGIN
+UPDATE t2 SET i = p2 WHERE i = p1;
+UPDATE v1 SET i = p2 WHERE i = p1;
+SELECT * FROM v1 ORDER BY i;
+SELECT * FROM t1 ORDER BY t1.k;
+SELECT * FROM t2 ORDER BY t2.k;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+CALL stp_t (125, 225);
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result
new file mode 100644
index 00000000000..f5c745ca41c
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result
@@ -0,0 +1,180 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
+SELECT * FROM v1 ORDER BY i;
+i
+123
+124
+126
+225
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 126 4 126
+connection default;
+UPDATE t2 SET t2.i=223 WHERE t2.i=123;
+SELECT * FROM v1 ORDER BY i;
+i
+124
+125
+126
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 124 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+UPDATE t2 SET t2.i=226 WHERE t2.i=126;
+SELECT * FROM v1 ORDER BY i;
+i
+123
+124
+225
+226
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+UPDATE t2 SET t2.i=224 WHERE t2.i=124;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+224
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+DELETE FROM t1 WHERE t1.i=226;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 123 1 123
+2 124 2 124
+3 225 3 125
+4 226 4 126
+connection default;
+DELETE FROM t1 WHERE t1.i=224;
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+COMMIT;
+connection root1;
+ROLLBACK;
+connection default;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection root1;
+SELECT * FROM v1 ORDER BY i;
+i
+125
+126
+223
+SELECT * FROM t1 ORDER BY t1.k;
+k i j l
+1 223 1 123
+3 125 3 125
+4 126 4 126
+SELECT * FROM t2 ORDER BY t2.k;
+k i j l
+1 223 1 123
+2 224 2 124
+3 125 3 125
+4 126 4 126
+connection default;
+DROP TABLE t1, t2;
+DROP VIEW v1;
diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result
new file mode 100644
index 00000000000..d6a38753c1d
--- /dev/null
+++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result
@@ -0,0 +1,36 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1;
+SET autocommit=0;
+SET autocommit=0;
+connection default;
+CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t1 VALUES (1,123,1,123);
+INSERT INTO t1 VALUES (2,124,2,124);
+INSERT INTO t1 VALUES (3,125,3,125);
+INSERT INTO t1 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t1 (i);
+CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
+INSERT INTO t2 VALUES (1,123,1,123);
+INSERT INTO t2 VALUES (2,124,2,124);
+INSERT INTO t2 VALUES (3,125,3,125);
+INSERT INTO t2 VALUES (4,126,4,126);
+#CREATE INDEX ixi ON t2 (i);
+CREATE VIEW v1 AS SELECT t1.i from t1;
+CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
+FOR EACH ROW BEGIN
+UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
+END;
+|
+COMMIT;
+SELECT @@global.tx_isolation;
+@@global.tx_isolation
+REPEATABLE-READ
+EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+i
+123
+124
+connection root1;
+UPDATE t2 SET t2.i=225 WHERE t2.i=125;
diff --git a/mysql-test/suite/row_lock/readme.txt b/mysql-test/suite/row_lock/readme.txt
new file mode 100644
index 00000000000..b43f04ecda4
--- /dev/null
+++ b/mysql-test/suite/row_lock/readme.txt
@@ -0,0 +1,9 @@
+All row lock test with InnoDB have to be executed with the options
+
+--innodb_lock_wait_timeout=1
+--innodb_locks_unsafe_for_binlog
+
+for example
+
+perl mysql-test-run.pl --mysqld=--innodb_lock_wait_timeout=2 --mysqld=--innodb_locks_unsafe_for_binlog --suite=row_lock innodb_row_lock_2
+
diff --git a/mysql-test/suite/row_lock/summary_of_sel_test.txt b/mysql-test/suite/row_lock/summary_of_sel_test.txt
new file mode 100644
index 00000000000..0fa332e957a
--- /dev/null
+++ b/mysql-test/suite/row_lock/summary_of_sel_test.txt
@@ -0,0 +1,36 @@
+Test plan:
+Create 2 tables with a primary key and 3 integer columns. Both get the same rows (1,123,1,123),(2,124,2,124),(3,125,3,125),(4,126,4,126). The second and third column may get an index to have cases with, without and mutilple index. Create views on the tables. Create an update trigger. Create a stored procedure updating the table. Create a stored function updating the table and deliver the key as result.
+
+The test isself consists of 2 sessions (transactions) running in "parallel" (same user "root") accessing and locking the same tables on basis of a row lock. Expected is that both sessions(transactions) can update the table successfully.
+
+First session
+execute an explain to every select and one of the following selects on the first half of table t1:
+- select <non index columns> ... where ... for update;
+- select <non index columns> ... where ... lock in share mode;
+- select <indexed columns> ... where ... for update;
+- select <indexed columns> ... where ... lock in share mode;
+- select <indexed columns> ... ignore index ... where ... for update;
+- select <indexed columns> ... ignore index ... where ... lock in share mode;
+- select ... where (select...) ... for update;
+- select ... where (select...) ... lock in share mode;
+- (select ... where) union (select ... where) for update;
+- (select ... where) union (select ... where) lock in...;
+- select <view> ... where ... for update;
+- select <view> ... where ... lock in ...;
+- select <join> ... where ... for update;
+- select <join> ... where ... lock in ...;
+Then executes
+- update
+- delete
+- trigger accessing table t1
+- stored procedure accessing table t1
+- stored function accessing table t1
+
+Second session
+executes the same on the last half of table t1
+
+call of mysqld with option
+--innodb_locks_unsafe_for_binlog
+
+As the tests above work with small tables (<10 rows) there must be at least one test with a big table (>1000 rows) doing a table scan.
+
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_1.test
new file mode 100644
index 00000000000..e0440fe2669
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_1.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_2.test
new file mode 100644
index 00000000000..5cb3ea9f2d9
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_2.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_3.test b/mysql-test/suite/row_lock/t/innodb_row_lock_3.test
new file mode 100644
index 00000000000..11f4dc423d6
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_3.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_4.test b/mysql-test/suite/row_lock/t/innodb_row_lock_4.test
new file mode 100644
index 00000000000..0a8ca9c13a0
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_4.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_5.test b/mysql-test/suite/row_lock/t/innodb_row_lock_5.test
new file mode 100644
index 00000000000..7e411d31649
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_5.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test
new file mode 100644
index 00000000000..0c5b8b41bd5
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_big_tab.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test
new file mode 100644
index 00000000000..a12a07d82a9
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test
@@ -0,0 +1,10 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $nbrows= 40;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_big_tab_1.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test
new file mode 100644
index 00000000000..49e834eb2ce
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test
@@ -0,0 +1,10 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $nbrows= 40;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_big_tab_2.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test
new file mode 100644
index 00000000000..225513d3f87
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_trig.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test
new file mode 100644
index 00000000000..88dee5f23f8
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_trig.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test
new file mode 100644
index 00000000000..d6381e1da5b
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test
new file mode 100644
index 00000000000..ee45e683669
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test
new file mode 100644
index 00000000000..49cba88dd23
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_mix.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test
new file mode 100644
index 00000000000..b07f3a3378a
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test
@@ -0,0 +1,10 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+#let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_mix.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test
new file mode 100644
index 00000000000..d507ff3296f
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_storedp.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test
new file mode 100644
index 00000000000..a1bfb16055e
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_storedp.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test
new file mode 100644
index 00000000000..24c76532d17
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_trig.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test
new file mode 100644
index 00000000000..a8a67d77979
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+SELECT @@global.innodb_table_locks into @table_locks;
+SET @@global.innodb_table_locks= OFF;
+let $engine= InnoDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_trig.inc
+SET @@global.innodb_table_locks= @table_locks;
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_1.test
new file mode 100644
index 00000000000..6ac2e829008
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_1.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_2.test
new file mode 100644
index 00000000000..994ecba96b0
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_2.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_3.test b/mysql-test/suite/row_lock/t/ndb_row_lock_3.test
new file mode 100644
index 00000000000..2de43c61c2a
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_3.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_4.test b/mysql-test/suite/row_lock/t/ndb_row_lock_4.test
new file mode 100644
index 00000000000..72b20488c74
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_4.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_5.test b/mysql-test/suite/row_lock/t/ndb_row_lock_5.test
new file mode 100644
index 00000000000..045f127a4ef
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_5.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test
new file mode 100644
index 00000000000..bf2df104e03
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_big_tab.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test
new file mode 100644
index 00000000000..4d32991d379
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test
@@ -0,0 +1,7 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $nbrows= 200;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_big_tab_1.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test
new file mode 100644
index 00000000000..894a83fc1b0
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test
@@ -0,0 +1,7 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $nbrows= 200;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_big_tab_2.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test
new file mode 100644
index 00000000000..a5586a6101e
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_trig.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test
new file mode 100644
index 00000000000..7af13697ccc
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_trig.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test
new file mode 100644
index 00000000000..a1aaf5ab441
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test
@@ -0,0 +1,7 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view.inc
+
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test
new file mode 100644
index 00000000000..b8feef693e7
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test
new file mode 100644
index 00000000000..a97626048d3
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_mix.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test
new file mode 100644
index 00000000000..e7a9a715785
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_mix.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test
new file mode 100644
index 00000000000..f57bcb3dd1b
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_storedp.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test
new file mode 100644
index 00000000000..b0aaa38fb93
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_storedp.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test
new file mode 100644
index 00000000000..9c4128d78bf
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= CREATE INDEX ixi ON t1 (i);
+let $indext2= CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_trig.inc
diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test
new file mode 100644
index 00000000000..38c9472fb3d
--- /dev/null
+++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test
@@ -0,0 +1,6 @@
+--source include/have_ndb.inc
+let $engine= NDB;
+let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
+let $indext1= #CREATE INDEX ixi ON t1 (i);
+let $indext2= #CREATE INDEX ixi ON t2 (i);
+--source suite/row_lock/include/row_lock_view_trig.inc
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index 64bd69c1855..fe39cd95753 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -132,6 +132,8 @@ create table t1 (date char(30), format char(30) not null);
insert into t1 values
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
+('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
+('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 09e49d933fb..ad2c7a6c08c 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -12,6 +12,7 @@
user_limits : Bug#23921 random failure of user_limits.test
im_options : Bug#20294 2006-07-24 stewart Instance manager test im_options fails randomly
+im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance.
concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index 476e4ce7735..7310f98cd16 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -540,3 +540,16 @@ EXPLAIN SELECT a FROM t1 GROUP BY a;
SELECT a FROM t1 GROUP BY a;
DROP TABLE t1;
+
+#
+#Bug #27659: SELECT DISTINCT returns incorrect result set when field is
+#repeated
+#
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES(1,1),(1,2),(1,3);
+SELECT DISTINCT a, b FROM t1;
+SELECT DISTINCT a, a, b FROM t1;
+DROP TABLE t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/federated_server.test b/mysql-test/t/federated_server.test
index 20332f65bff..87b67720104 100644
--- a/mysql-test/t/federated_server.test
+++ b/mysql-test/t/federated_server.test
@@ -2,7 +2,8 @@
# if federated can utilise the servers table
# should work with embedded server after mysqltest is fixed
-- source include/not_embedded.inc
-source include/federated.inc;
+-- source include/federated.inc;
+-- source include/big_test.inc
connection slave;
create database first_db;
@@ -299,7 +300,7 @@ begin
DECLARE i INT;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1;
SET i = sleep(5);
- WHILE v < 20000 do
+ WHILE v < 10000 do
CREATE SERVER s
FOREIGN DATA WRAPPER mysql
OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test
index 77d7366afe6..bb65cbaa774 100644
--- a/mysql-test/t/func_sapdb.test
+++ b/mysql-test/t/func_sapdb.test
@@ -41,6 +41,8 @@ select datediff("1997-11-30 23:59:59.000001",null);
select weekofyear("1997-11-30 23:59:59.000001");
+select makedate(03,1);
+select makedate('0003',1);
select makedate(1997,1);
select makedate(1997,0);
select makedate(9999,365);
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 0008c37646c..cf4e2d0151e 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -3,6 +3,8 @@
# Grant tests not performed with embedded server
-- source include/not_embedded.inc
+SET GLOBAL log_bin_trust_function_creators = 1;
+
# Cleanup
--disable_warnings
drop table if exists t1;
@@ -985,6 +987,233 @@ GRANT PROCESS ON * TO user@localhost;
disconnect con1;
connection default;
+
+#
+# BUG#9504: Stored procedures: execute privilege doesn't make 'use database'
+# okay.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+DROP DATABASE IF EXISTS mysqltest3;
+DROP DATABASE IF EXISTS mysqltest4;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+CREATE DATABASE mysqltest3;
+CREATE DATABASE mysqltest4;
+
+CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
+ SELECT 1;
+
+CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
+ SELECT 1;
+
+CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
+ RETURN 1;
+
+CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
+ RETURN 1;
+
+GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
+GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
+GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
+GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
+
+GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
+
+# Test.
+
+--connect (bug9504_con1,localhost,mysqltest_1,,)
+--echo
+--echo ---> connection: bug9504_con1
+
+# - Check that we can switch to the db;
+
+use mysqltest1;
+
+use mysqltest2;
+
+use mysqltest3;
+
+use mysqltest4;
+
+# - Check that we can call stored routines;
+
+use test;
+
+CALL mysqltest1.p_def();
+
+CALL mysqltest2.p_inv();
+
+SELECT mysqltest3.f_def();
+
+SELECT mysqltest4.f_inv();
+
+# Cleanup.
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect bug9504_con1
+
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP DATABASE mysqltest3;
+DROP DATABASE mysqltest4;
+
+DROP USER mysqltest_1@localhost;
+
+
+#
+# BUG#27337: Privileges are not restored properly.
+#
+# Actually, the patch for this bugs fixes two problems. So, here are two test
+# cases.
+
+# Test case 1: privileges are not restored properly after calling a stored
+# routine defined with SQL SECURITY INVOKER clause.
+
+# Prepare.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+
+GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
+GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
+
+CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
+ SELECT 1;
+
+# Test.
+
+--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest2)
+--echo
+--echo ---> connection: bug27337_con1
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CREATE TABLE t1(c INT);
+
+CALL mysqltest1.p1();
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CREATE TABLE t1(c INT);
+
+--disconnect bug27337_con1
+
+--connect (bug27337_con2,localhost,mysqltest_1,,mysqltest2)
+--echo
+--echo ---> connection: bug27337_con2
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CREATE TABLE t1(c INT);
+
+SHOW TABLES;
+
+# Cleanup.
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect bug27337_con2
+
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+
+DROP USER mysqltest_1@localhost;
+
+# Test case 2: priveleges are not checked properly for prepared statements.
+
+# Prepare.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+
+CREATE TABLE mysqltest1.t1(c INT);
+CREATE TABLE mysqltest2.t2(c INT);
+
+GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
+GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
+
+# Test.
+
+--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest1)
+--echo
+--echo ---> connection: bug27337_con1
+
+SHOW TABLES FROM mysqltest1;
+
+PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
+
+EXECUTE stmt1;
+
+--connect (bug27337_con2,localhost,mysqltest_2,,mysqltest2)
+--echo
+--echo ---> connection: bug27337_con2
+
+SHOW COLUMNS FROM mysqltest2.t2;
+
+PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
+
+EXECUTE stmt2;
+
+--connection default
+--echo
+--echo ---> connection: default
+
+REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
+REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
+
+--connection bug27337_con1
+--echo
+--echo ---> connection: bug27337_con1
+
+--error ER_DBACCESS_DENIED_ERROR
+SHOW TABLES FROM mysqltest1;
+
+--error ER_DBACCESS_DENIED_ERROR
+EXECUTE stmt1;
+
+--connection bug27337_con2
+--echo
+--echo ---> connection: bug27337_con2
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW COLUMNS FROM mysqltest2.t2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+EXECUTE stmt2;
+
+# Cleanup.
+
+--connection default
+--echo
+--echo ---> connection: default
+
+--disconnect bug27337_con2
+
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+
+DROP USER mysqltest_1@localhost;
+
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test
index e15e50e8766..666f331c7b9 100644
--- a/mysql-test/t/information_schema_db.test
+++ b/mysql-test/t/information_schema_db.test
@@ -121,6 +121,28 @@ create table t1 (f1 char(4));
create view v1 as select f1 from t1;
grant insert on v1 to testdb_2@localhost;
+create view v5 as select f1 from t1;
+grant show view on v5 to testdb_2@localhost;
+
+--error 1227
+create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
+
+connection default;
+use testdb_1;
+create view v6 as select f1 from t1;
+grant show view on v6 to testdb_2@localhost;
+
+create table t2 (f1 char(4));
+create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
+
+show fields from testdb_1.v6;
+show create view testdb_1.v6;
+
+show create view testdb_1.v7;
+show fields from testdb_1.v7;
+
+connection testdb_1;
+
create table t3 (f1 char(4), f2 char(4));
create view v3 as select f1,f2 from t3;
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
@@ -129,13 +151,41 @@ connect (testdb_2,localhost,testdb_2,,test);
create view v2 as select f1 from testdb_1.v1;
create view v4 as select f1,f2 from testdb_1.v3;
+show fields from testdb_1.v5;
+show create view testdb_1.v5;
+
+show fields from testdb_1.v6;
+show create view testdb_1.v6;
+
connection testdb_1;
+show fields from testdb_1.v7;
+show create view testdb_1.v7;
+
revoke insert(f1) on v3 from testdb_2@localhost;
+revoke show view on v5 from testdb_2@localhost;
+connection default;
+use testdb_1;
+revoke show view on v6 from testdb_2@localhost;
connection testdb_2;
+--error 1142
+show fields from testdb_1.v5;
+--error 1142
+show create view testdb_1.v5;
+
+--error 1142
+show fields from testdb_1.v6;
+--error 1142
+show create view testdb_1.v6;
+
+--error 1142
+show fields from testdb_1.v7;
+--error 1142
+show create view testdb_1.v7;
+
--error 1345
show create view v4;
---error 1345
+#--error 1345
show fields from v4;
show fields from v2;
@@ -155,7 +205,8 @@ where a.table_name = 'testdb_1.v1';
select * from v2;
connection default;
-drop view testdb_1.v1,v2, testdb_1.v3, v4;
+use test;
+drop view testdb_1.v1, v2, testdb_1.v3, v4;
drop database testdb_1;
drop user testdb_1@localhost;
drop user testdb_2@localhost;
diff --git a/mysql-test/t/myisam-system.test b/mysql-test/t/myisam-system.test
index 43fbaabf698..c4a7651ac7d 100644
--- a/mysql-test/t/myisam-system.test
+++ b/mysql-test/t/myisam-system.test
@@ -7,14 +7,14 @@ drop table if exists t1,t2;
--enable_warnings
create table t1 (a int) engine=myisam;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI
drop table if exists t1;
create table t1 (a int) engine=myisam;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI
--error 1051,6
drop table t1;
create table t1 (a int) engine=myisam;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYD ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD
--error 1105,6,29
drop table t1;
--error 1051
diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test
index cd49d3570e9..ac647f772b1 100644
--- a/mysql-test/t/mysqlbinlog2.test
+++ b/mysql-test/t/mysqlbinlog2.test
@@ -58,6 +58,10 @@ select "--- stop-position --" as "";
--enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLTEST_VARDIR/log/master-bin.000001
--disable_query_log
+select "--- start and stop positions ---" as "";
+--enable_query_log
+--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLTEST_VARDIR/log/master-bin.000001
+--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
@@ -115,6 +119,10 @@ select "--- stop-position --" as "";
--enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
+select "--- start and stop positions ---" as "";
+--enable_query_log
+--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test
index 7424687cd8a..06d47693c10 100644
--- a/mysql-test/t/ndb_autodiscover.test
+++ b/mysql-test/t/ndb_autodiscover.test
@@ -24,7 +24,7 @@ create table t1(
insert into t1 values(1, "Autodiscover");
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
select * from t1;
show status like 'handler_discover%';
@@ -33,13 +33,13 @@ show status like 'handler_discover%';
#
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
insert into t1 values (2, "Auto 2");
show status like 'handler_discover%';
insert into t1 values (3, "Discover 3");
show status like 'handler_discover%';
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
select * from t1 order by id;
show status like 'handler_discover%';
@@ -48,7 +48,7 @@ show status like 'handler_discover%';
#
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
update t1 set name="Autodiscover" where id = 2;
show status like 'handler_discover%';
select * from t1 order by id;
@@ -59,7 +59,7 @@ show status like 'handler_discover%';
#
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
delete from t1 where id = 3;
select * from t1 order by id;
show status like 'handler_discover%';
@@ -111,7 +111,7 @@ show status like 'handler_discover%';
flush tables;
# Remove the frm file from disk
-system rm $MYSQLTEST_VARDIR/master-data/test/t3.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm
--error 1050
create table t3(
@@ -168,14 +168,14 @@ show status like 'handler_discover%';
# Remove the frm file from disk
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
show tables from test;
show status like 'handler_discover%';
# Remove the frm file from disk again
flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
--replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 #
show table status;
@@ -290,8 +290,8 @@ insert into t9 values (9);
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ;
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ;
# Remove t6, t7 from disk
-system rm $MYSQLTEST_VARDIR/master-data/test/t6.frm > /dev/null ;
-system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm > /dev/null ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
SHOW TABLES;
@@ -332,8 +332,8 @@ insert into t9 values (9);
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ;
system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ;
# Remove t6, t7 from disk
-system rm $MYSQLTEST_VARDIR/master-data/test/t6.frm > /dev/null ;
-system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm > /dev/null ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
SHOW TABLES LIKE 't6';
@@ -375,9 +375,9 @@ insert into t3 values (3, "ndb table 3");
insert into t4 values (4);
# Remove t1, t2, t3 from disk
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm > /dev/null ;
-system rm $MYSQLTEST_VARDIR/master-data/test/t2.frm > /dev/null ;
-system rm $MYSQLTEST_VARDIR/master-data/test/t3.frm > /dev/null ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t2.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm
flush tables;
# Select from the table which only exists in NDB.
@@ -530,7 +530,7 @@ CREATE TABLE t9 (
insert t9 values(1, 2), (2,3), (3, 4), (4, 5);
#Don't drop the table, instead remove the frm file
-system rm $MYSQLTEST_VARDIR/master-data/test/t9.frm ;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t9.frm
# Now leave test case, when ndb_autodiscover2 will run, this
# MySQL Server will have been restarted because it has a
diff --git a/mysql-test/t/ndb_dd_basic.test b/mysql-test/t/ndb_dd_basic.test
index 81286d3121f..3acf4669868 100644
--- a/mysql-test/t/ndb_dd_basic.test
+++ b/mysql-test/t/ndb_dd_basic.test
@@ -407,8 +407,16 @@ insert into t1 values(7,'x');
insert into t1 values(8,'x');
delete from t1 where a = 0;
commit;
+
+delete from t1;
+begin;
+insert into t1 values (1, 'x');
+select * from t1;
+rollback;
+
set autocommit = 1;
+
drop table t1;
#############################
# Customer posted order by test case
diff --git a/mysql-test/t/ndb_loaddatalocal.test b/mysql-test/t/ndb_loaddatalocal.test
index 47054ecfbf5..3eae3891f43 100644
--- a/mysql-test/t/ndb_loaddatalocal.test
+++ b/mysql-test/t/ndb_loaddatalocal.test
@@ -25,7 +25,7 @@ create table t1(a int) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
select count(*) from t1;
-system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile ;
+--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
drop table t1;
create table t1(a int) engine=myisam;
@@ -37,7 +37,7 @@ drop table t1;
create table t1(a int primary key) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
-system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile;
+--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
select * from t1 order by a;
drop table t1;
@@ -50,7 +50,7 @@ drop table t1;
create table t1(a int primary key) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
-system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile;
+--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
select * from t1 order by a;
drop table t1;
@@ -63,7 +63,7 @@ drop table t1;
create table t1(a int primary key) engine=ndb;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1;
-system rm $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile;
+--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile
select * from t1 order by a;
drop table t1;
diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test
index 9030dfbe304..662eb43c422 100644
--- a/mysql-test/t/ndb_restore.test
+++ b/mysql-test/t/ndb_restore.test
@@ -8,14 +8,21 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
--enable_warnings
+# Bug #27775 - mediumint auto inc not restored correctly
+# - check mediumint
CREATE TABLE `t1_c` (
- `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment,
+ `capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment,
`goaledatta` char(2) NOT NULL default '',
`maturegarbagefa` varchar(32) NOT NULL default '',
PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
-INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt');
-
+INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt');
+#
+# Bug #27758 Restoring NDB backups makes table usable in SQL nodes
+# - space in key made table unusable after restore
+#
+# Bug #27775 - mediumint auto inc not restored correctly
+# - check smallint
CREATE TABLE `t2_c` (
`capgotod` smallint(5) unsigned NOT NULL auto_increment,
`gotod` smallint(5) unsigned NOT NULL default '0',
@@ -24,9 +31,9 @@ CREATE TABLE `t2_c` (
`descrpooppo` varchar(64) default NULL,
`svcutonsa` varchar(64) NOT NULL default '',
PRIMARY KEY (`capgotod`),
- KEY `i_quadaddsvr` (`gotod`)
+ KEY `i quadaddsvr` (`gotod`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
-INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
+INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
CREATE TABLE `t3_c` (
`CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
@@ -35,6 +42,8 @@ CREATE TABLE `t3_c` (
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3);
+# Bug #27775 - mediumint auto inc not restored correctly
+# - check bigint
CREATE TABLE `t4_c` (
`capfa` bigint(20) unsigned NOT NULL auto_increment,
`realm` varchar(32) NOT NULL default '',
@@ -46,7 +55,7 @@ CREATE TABLE `t4_c` (
KEY `capfa` (`capfa`),
KEY `i_quadentity` (`fa`,`realm`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
-INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
+INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
CREATE TABLE `t5_c` (
`capfa` bigint(20) unsigned NOT NULL default '0',
@@ -64,9 +73,11 @@ CREATE TABLE `t6_c` (
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0);
+# Bug #27775 - mediumint auto inc not restored correctly
+# - check tinyint
CREATE TABLE `t7_c` (
`dardpo` char(15) NOT NULL default '',
- `dardtestard` tinyint(3) unsigned NOT NULL default '0',
+ `dardtestard` tinyint(3) unsigned NOT NULL auto_increment,
`FastFA` char(5) NOT NULL default '',
`FastCode` char(6) NOT NULL default '',
`Fastca` char(1) NOT NULL default '',
@@ -138,6 +149,9 @@ INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','
# seen by select below
CREATE TABLE t10_c (a INT AUTO_INCREMENT KEY) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO t10_c VALUES (1),(2),(3);
+# Bug #27775 - mediumint auto inc not restored correctly
+# - check int
+insert into t10_c values (10000),(2000),(3000);
create table t1 engine=myisam as select * from t1_c;
create table t2 engine=myisam as select * from t2_c;
@@ -215,6 +229,18 @@ select count(*)
# Bug #20820 cont'd
select * from t10_c order by a;
+# Bug #27775 cont'd
+# - auto inc info should be correct
+--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X
+show table status like 't1_c';
+--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X
+show table status like 't2_c';
+--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X
+show table status like 't4_c';
+--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X
+show table status like 't7_c';
+--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X
+show table status like 't10_c';
#
# Try Partitioned tables as well
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
index 1d5c7a543ea..bf25359b7be 100644
--- a/mysql-test/t/row.test
+++ b/mysql-test/t/row.test
@@ -85,6 +85,31 @@ drop table t1;
SELECT ROW(2,10) <=> ROW(3,4);
SELECT ROW(NULL,10) <=> ROW(3,NULL);
+#
+# Bug #27484: nested row expressions in IN predicate
+#
+
+--error 1241
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1));
+--error 1241
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3)));
+--error 1241
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2)));
+--error 1241
+SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2)));
+
+--error 1241
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1));
+--error 1241
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4)));
+--error 1241
+SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3)));
+
+--error 1241
+SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
+--error 1241
+SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
+
# End of 4.1 tests
#
diff --git a/mysql-test/t/rpl_flushlog_loop.test b/mysql-test/t/rpl_flushlog_loop.test
index ded111d769f..471c45a1aa3 100644
--- a/mysql-test/t/rpl_flushlog_loop.test
+++ b/mysql-test/t/rpl_flushlog_loop.test
@@ -5,6 +5,9 @@
#
# Start replication master -> slave
#
+# We have to sync with master, to ensure slave had time to start properly
+# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
+sync_slave_with_master;
connection slave;
--disable_warnings
stop slave;
diff --git a/mysql-test/t/rpl_loaddatalocal.test b/mysql-test/t/rpl_loaddatalocal.test
index 758ac94af24..b10603e7195 100644
--- a/mysql-test/t/rpl_loaddatalocal.test
+++ b/mysql-test/t/rpl_loaddatalocal.test
@@ -25,7 +25,7 @@ eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.sele
truncate table t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
-system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ;
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
save_master_pos;
connection slave;
sync_with_master;
@@ -52,7 +52,7 @@ drop table t1;
create table t1(a int primary key);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
-system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ;
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
SELECT * FROM t1 ORDER BY a;
save_master_pos;
connection slave;
diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test
index ec1c83a9718..b98d89c1dc3 100644
--- a/mysql-test/t/rpl_log_pos.test
+++ b/mysql-test/t/rpl_log_pos.test
@@ -37,7 +37,7 @@ change master to master_log_pos=178;
start slave;
sleep 2;
--replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 8 # 9 # 11 # 23 # 33 #
show slave status;
connection master;
--replace_column 3 <Binlog_Ignore_DB>
diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test
index f00beff583a..db9b557baad 100644
--- a/mysql-test/t/rpl_misc_functions.test
+++ b/mysql-test/t/rpl_misc_functions.test
@@ -99,5 +99,5 @@ DROP TABLE IF EXISTS t1;
--sync_slave_with_master
# If all is good, when can cleanup our dump files.
---system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql
---system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql
diff --git a/mysql-test/t/rpl_ndb_basic.test b/mysql-test/t/rpl_ndb_basic.test
index a230b9da622..04c855f8730 100644
--- a/mysql-test/t/rpl_ndb_basic.test
+++ b/mysql-test/t/rpl_ndb_basic.test
@@ -36,6 +36,37 @@ select * from t1 order by nid;
select * from t1 order by nid;
--connection master
+delete from t1;
+insert into t1 values(1,"AA", "AA");
+insert into t1 values(2,"BB", "BB");
+insert into t1 values(3,"CC", "CC");
+insert into t1 values(4,"DD", "DD");
+
+begin;
+# delete+insert = update
+delete from t1 where nid = 1;
+insert into t1 values (1,"A2", "A2");
+
+# update+delete = delete
+update t1 set nom="B2" where nid = 2;
+delete from t1 where nid = 2;
+
+# multi-update
+update t1 set nom = "D2" where nid = 4;
+delete from t1 where nid = 4;
+insert into t1 values (4, "D3", "D3");
+update t1 set nom = "D4" where nid = 4;
+
+# insert+delete = nothing
+insert into t1 values (5, "EE", "EE");
+delete from t1 where nid = 5;
+
+commit;
+select * from t1 order by 1;
+--sync_slave_with_master
+--connection slave
+select * from t1 order by 1;
+--connection master
DROP table t1;
#
diff --git a/mysql-test/t/rpl_rbr_to_sbr.test b/mysql-test/t/rpl_rbr_to_sbr.test
index 4def515eb13..4f72996671d 100644
--- a/mysql-test/t/rpl_rbr_to_sbr.test
+++ b/mysql-test/t/rpl_rbr_to_sbr.test
@@ -43,5 +43,5 @@ diff_files $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql $MYSQLTEST_VARDIR/tmp
# If all is good, we can remove the files
-system rm $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql;
-system rm $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql;
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql
diff --git a/mysql-test/t/rpl_row_NOW.test b/mysql-test/t/rpl_row_NOW.test
index d0272b35c1f..c28b714277e 100644
--- a/mysql-test/t/rpl_row_NOW.test
+++ b/mysql-test/t/rpl_row_NOW.test
@@ -67,8 +67,8 @@ DROP DATABASE mysqltest1;
diff_files $MYSQLTEST_VARDIR/tmp/NOW_master.sql $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
# If all is good, when can cleanup our dump files.
-system rm $MYSQLTEST_VARDIR/tmp/NOW_master.sql;
-system rm $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
+--remove_file $MYSQLTEST_VARDIR/tmp/NOW_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/NOW_slave.sql
sync_slave_with_master;
# End of 5.1 test case
diff --git a/mysql-test/t/rpl_row_sp001.test b/mysql-test/t/rpl_row_sp001.test
index c6fc29e3750..c12e73b6861 100644
--- a/mysql-test/t/rpl_row_sp001.test
+++ b/mysql-test/t/rpl_row_sp001.test
@@ -140,7 +140,7 @@ sync_slave_with_master;
diff_files $MYSQLTEST_VARDIR/tmp/sp001_master.sql $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
# If all is good, when can cleanup our dump files.
-system rm $MYSQLTEST_VARDIR/tmp/sp001_master.sql;
-system rm $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
+--remove_file $MYSQLTEST_VARDIR/tmp/sp001_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/sp001_slave.sql
# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_sp011.test b/mysql-test/t/rpl_row_sp011.test
index fb87249d93c..25c2fc9ad26 100644
--- a/mysql-test/t/rpl_row_sp011.test
+++ b/mysql-test/t/rpl_row_sp011.test
@@ -105,7 +105,7 @@ sync_slave_with_master;
diff_files $MYSQLTEST_VARDIR/tmp/sp011_master.sql $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
# If all is good, when can cleanup our dump files.
-system rm $MYSQLTEST_VARDIR/tmp/sp011_master.sql;
-system rm $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
+--remove_file $MYSQLTEST_VARDIR/tmp/sp011_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/sp011_slave.sql
# End of 5.0 test case
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index f613b836350..1f8a00409e6 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3346,4 +3346,17 @@ SELECT t2.faq_id
DROP TABLE t1,t2;
+
+#
+# Bug #19372: Optimizer does not use index anymore when WHERE index NOT IN
+# () is added
+#
+CREATE TABLE t1 (a INT, b INT, KEY inx (b,a));
+
+INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7);
+EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
+ ON ( f1.b=f2.b AND f1.a<f2.a )
+ WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 91832ee8af4..60e680c63f3 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -392,7 +392,8 @@ SHOW TABLE STATUS like 't1';
--error 1033
show create table t1;
drop table if exists t1;
-system rm -f $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
+--error 1,0
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
#
# BUG 12183 - SHOW OPEN TABLES behavior doesn't match grammar
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index f994f61a665..91de14116d4 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -28,6 +28,7 @@ drop procedure db1_secret.dummy;
use db1_secret;
create table t1 ( u varchar(64), i int );
+insert into t1 values('test', 0);
# A test procedure and function
create procedure stamp(i int)
@@ -35,7 +36,16 @@ create procedure stamp(i int)
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show procedure status like 'stamp';
-create function db() returns varchar(64) return database();
+delimiter |;
+create function db() returns varchar(64)
+begin
+ declare v varchar(64);
+
+ select u into v from t1 limit 1;
+
+ return v;
+end|
+delimiter ;|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show function status like 'db';
@@ -63,14 +73,18 @@ call db1_secret.stamp(2);
select db1_secret.db();
# ...but not this
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from db1_secret.t1;
# ...and not this
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
create procedure db1_secret.dummy() begin end;
---error 1305
+--error ER_SP_DOES_NOT_EXIST
drop procedure db1_secret.dummy;
+--error ER_PROCACCESS_DENIED_ERROR
+drop procedure db1_secret.stamp;
+--error ER_PROCACCESS_DENIED_ERROR
+drop function db1_secret.db;
#
@@ -83,14 +97,18 @@ call db1_secret.stamp(3);
select db1_secret.db();
# ...but not this
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from db1_secret.t1;
# ...and not this
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
create procedure db1_secret.dummy() begin end;
---error 1305
+--error ER_SP_DOES_NOT_EXIST
drop procedure db1_secret.dummy;
+--error ER_PROCACCESS_DENIED_ERROR
+drop procedure db1_secret.stamp;
+--error ER_PROCACCESS_DENIED_ERROR
+drop function db1_secret.db;
#
@@ -121,9 +139,9 @@ select db();
connection con2user1;
# This should not work
---error 1044
+--error ER_TABLEACCESS_DENIED_ERROR
call db1_secret.stamp(5);
---error 1044
+--error ER_TABLEACCESS_DENIED_ERROR
select db1_secret.db();
#
@@ -132,9 +150,9 @@ select db1_secret.db();
connection con3anon;
# This should not work
---error 1044
+--error ER_TABLEACCESS_DENIED_ERROR
call db1_secret.stamp(6);
---error 1044
+--error ER_TABLEACCESS_DENIED_ERROR
select db1_secret.db();
#
@@ -165,7 +183,7 @@ use db2;
create procedure p () insert into t2 values (1);
# Check that this doesn't work.
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
call p();
connect (con4user2,localhost,user2,,);
@@ -174,7 +192,7 @@ connection con4user2;
use db2;
# This should not work, since p is executed with definer's (user1's) rights.
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
call p();
select * from t2;
@@ -207,9 +225,9 @@ alter procedure p modifies sql data;
drop procedure p;
# This should NOT work
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
alter procedure q modifies sql data;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure q;
connection con1root;
@@ -260,30 +278,30 @@ connect (con4userc,localhost,userc,,);
connection con2usera;
call sptest.p1(1);
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
grant execute on procedure sptest.p1 to userb@localhost;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1;
connection con3userb;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
call sptest.p1(2);
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
grant execute on procedure sptest.p1 to userb@localhost;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1;
connection con4userc;
call sptest.p1(3);
grant execute on procedure sptest.p1 to userb@localhost;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1;
connection con3userb;
call sptest.p1(4);
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
grant execute on procedure sptest.p1 to userb@localhost;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure sptest.p1;
connection con1root;
@@ -332,7 +350,7 @@ delimiter ;//
connect (user1,localhost,user1,,test);
connection user1;
use mysqltest;
--- error 1370
+-- error ER_PROCACCESS_DENIED_ERROR
select bug_9503();
connection root;
@@ -401,13 +419,13 @@ grant usage on *.* to mysqltest_1@localhost;
connect (n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n1;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
call mysqltest_1.p1();
disconnect n1;
# Test also without a current database
connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n2;
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
call mysqltest_1.p1();
disconnect n2;
@@ -433,9 +451,9 @@ end;
create user user_bug12812@localhost IDENTIFIED BY 'ABC'|
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (test_user_12812,localhost,user_bug12812,ABC,test)|
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
SELECT test.bug12812()|
---error 1370
+--error ER_PROCACCESS_DENIED_ERROR
CREATE VIEW v1 AS SELECT test.bug12812()|
# Cleanup
connection default|
@@ -489,7 +507,8 @@ drop database db_bug14834;
#
-# BUG#14533: 'desc tbl' in stored procedure causes error 1142
+# BUG#14533: 'desc tbl' in stored procedure causes error
+# ER_TABLEACCESS_DENIED_ERROR
#
create database db_bug14533;
use db_bug14533;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index f776be40864..591677cd834 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -7021,6 +7021,47 @@ INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
DROP FUNCTION bug25373|
DROP TABLE t3|
+
+
+#
+# BUG#25082: Default database change on trigger execution breaks replication.
+#
+# As it turned out, this bug has actually two bugs. So, here we have two test
+# cases -- one in sp.test, the other in sp-security.test.
+#
+
+#
+# Test case 1: error on dropping the current database.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1|
+CREATE DATABASE mysqltest2|
+
+# Test.
+
+CREATE PROCEDURE mysqltest1.p1()
+ DROP DATABASE mysqltest2|
+
+use mysqltest2|
+
+CALL mysqltest1.p1()|
+
+SELECT DATABASE()|
+
+# Cleanup.
+
+DROP DATABASE mysqltest1|
+
+use test|
+
+
#
# Bug#20777: Function w BIGINT UNSIGNED shows diff. behaviour --ps-protocol
--disable_warnings
@@ -7088,3 +7129,26 @@ delimiter |;
delimiter ;|
drop table t1,t2;
+CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
+CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
+set @a=0;
+
+delimiter |;
+CREATE function bug27354() RETURNS int deterministic
+begin
+insert into t1 values (null);
+set @a=@a+1;
+return @a;
+end|
+
+delimiter ;|
+update t2 set b=1 where a=bug27354();
+select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
+insert into t2 values (1,1),(2,2),(3,3);
+update t2 set b=-b where a=bug27354();
+select * from t2 /* must return 1,-1 ... */;
+select count(*) from t1 /* must be 3 */;
+
+
+drop table t1,t2;
+drop function bug27354;
diff --git a/mysql-test/t/sp_trans_log.test b/mysql-test/t/sp_trans_log.test
new file mode 100644
index 00000000000..cc3b2531bed
--- /dev/null
+++ b/mysql-test/t/sp_trans_log.test
@@ -0,0 +1,43 @@
+# part of sp_trans test that appeared to be sensitive to binlog format
+--source include/have_innodb.inc
+--source include/have_binlog_format_mixed_or_row.inc
+
+delimiter |;
+
+#
+# Bug #13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
+# Bug #23333 stored function + non-transac table + transac table =
+# breaks stmt-based binlog
+# Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
+#
+--disable_warnings
+drop function if exists bug23333|
+drop table if exists t1,t2|
+--enable_warnings
+ CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
+ CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
+
+insert into t2 values (1,1)|
+
+create function bug23333()
+RETURNS int(11)
+DETERMINISTIC
+begin
+ insert into t1 values (null);
+ select count(*) from t1 into @a;
+ return @a;
+end|
+
+reset master|
+--error ER_DUP_ENTRY_WITH_KEY_NAME
+insert into t2 values (bug23333(),1)|
+--replace_column 2 # 5 # 6 #
+show binlog events from 106 /* with fixes for #23333 will show there is the query */|
+select count(*),@a from t1 /* must be 1,1 */|
+
+delimiter ;|
+
+# clean-up
+
+drop table t1,t2;
+drop function if exists bug23333;
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 3ff84c35f16..fe731f4b0a1 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -1249,4 +1249,13 @@ insert into t1 values ('2000a');
insert into t1 values ('2E3x');
drop table t1;
+#
+# Bug#27069 set with identical elements are created
+#
+set sql_mode='traditional';
+--error 1291
+create table t1 (f1 set('a','a'));
+--error 1291
+create table t1 (f1 enum('a','a'));
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 88c34bdb9b9..3b7cc2abb73 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -2784,6 +2784,43 @@ SELECT COUNT(*) c, a,
DROP table t1,t2;
#
+# Bug#27321: Wrong subquery result in a grouping select
+#
+CREATE TABLE t1 (a int, b INT, d INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
+INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'),
+(1,5,0,'e'), (2,1,0,'f'), (2,2,0,'g'), (2,3,0,'h'), (3,4,0,'i'), (3,3,0,'j'),
+(3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p');
+
+SELECT a, MAX(b),
+ (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test
+ FROM t1 GROUP BY a;
+SELECT a x, MAX(b),
+ (SELECT t.c FROM t1 AS t WHERE x=t.a AND t.b=MAX(t1.b + 0)) as test
+ FROM t1 GROUP BY a;
+SELECT a, AVG(b),
+ (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b)) AS test
+ FROM t1 WHERE t1.d=0 GROUP BY a;
+
+SELECT tt.a,
+ (SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
+ LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+ FROM t1 as tt;
+
+SELECT tt.a,
+ (SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
+ LIMIT 1)
+ FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+ FROM t1 as tt GROUP BY tt.a;
+
+SELECT tt.a, MAX(
+ (SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
+ LIMIT 1)
+ FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test
+ FROM t1 as tt GROUP BY tt.a;
+
+DROP TABLE t1;
+
+#
# Bug #27348: SET FUNCTION used in a subquery from WHERE condition
#
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test
index e8eae3e2452..11468cd6759 100644
--- a/mysql-test/t/subselect3.test
+++ b/mysql-test/t/subselect3.test
@@ -507,9 +507,6 @@ SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b))
SELECT * FROM t1 GROUP by t1.a
HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c
HAVING MAX(t2.b+t1.a) < 10));
-#FIXME: Enable this test after fixing bug #27321
-#SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b))
-# AS test FROM t1 GROUP BY a;
SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c;
diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test
index f806bd8ec17..c52260124cb 100644
--- a/mysql-test/t/truncate.test
+++ b/mysql-test/t/truncate.test
@@ -52,3 +52,35 @@ SELECT * from t1;
drop table t1;
# End of 4.1 tests
+
+# Test for Bug#5507 "TRUNCATE should work with views"
+
+create table t1 (s1 int);
+
+insert into t1 (s1) values (1), (2), (3), (4), (5);
+create view v1 as select * from t1;
+truncate table v1;
+select count(*) from t1;
+
+insert into t1 (s1) values (1), (2), (3), (4), (5);
+create view v2 as select * from t1 where s1 > 3;
+truncate table v2;
+select * from t1;
+select * from v2;
+delete from t1;
+
+# The following should fail
+create table t2 (s1 int, s2 int);
+create view v3 as select a.s1, b.s2 from t1 a join t2 b on a.s1 = b.s1 where a.s1 > 3;
+--error 1395
+truncate table v3;
+
+# The following should fail
+create view v4 as select * from t1 limit 1,1;
+--error 1288
+truncate table v4;
+
+drop view v1, v2, v3, v4;
+drop table t1, t2;
+
+# End of 5.0 tests
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index c6050753943..02cd07e3c16 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -123,3 +123,16 @@ insert into t1 values ('2000-01-01','2000-01-02');
select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug #23093: Implicit conversion of 9912101 to date does not match
+# cast(9912101 as date)
+#
+select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date);
+select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date);
+select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date);
+create table t1 (d date , dt datetime , ts timestamp);
+insert into t1 values (9912101,9912101,9912101);
+insert into t1 values (11111,11111,11111);
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 9246080630e..b4c10408b37 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -141,3 +141,25 @@ 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));
+#
+# Test of storing datetime into date fields
+#
+
+set @org_mode=@@sql_mode;
+create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
+show create table t1;
+insert into t1 values ();
+insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
+set @@sql_mode='ansi,traditional';
+insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
+insert into t1 set dt='2007-03-23 13:49:38',da=dt;
+# Test error handling
+--error 1292
+insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
+select * from t1;
+drop table t1;
+--error 1067
+create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
+--error 1067
+create table t1 (t time default '916:00:00 a');
+set @@sql_mode= @org_mode;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 4961d95d0ac..620f292bc12 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2221,6 +2221,8 @@ REPAIR TABLE v1;
DROP TABLE t1;
OPTIMIZE TABLE v1;
+ANALYZE TABLE v1;
+REPAIR TABLE v1;
DROP VIEW v1;
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 64cafe89d10..b3bfd1cf544 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -356,25 +356,6 @@ drop view mysqltest.v3;
connection user1;
create view mysqltest.v3 as select b from mysqltest.t2;
-# give UPDATE and INSERT privilege (to get more privileges then underlying
-# table)
-connection root;
-grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost;
-drop view mysqltest.v3;
-connection user1;
--- error 1143
-create view mysqltest.v3 as select b from mysqltest.t2;
-
-
-# If we would get more privileges on VIEW then we have on
-# underlying tables => creation prohibited
-connection root;
-create table mysqltest.v3 (b int);
-grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
-drop table mysqltest.v3;
-connection user1;
--- error 1143
-create view mysqltest.v3 as select b from mysqltest.t2;
# Expression need select privileges
-- error 1143
@@ -1072,6 +1053,97 @@ DROP USER u26813@localhost;
DROP DATABASE db26813;
disconnect u1;
+#
+# BUG#24040: Create View don't succed with "all privileges" on a database.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+
+# Test.
+
+CREATE TABLE mysqltest1.t1(c1 INT);
+CREATE TABLE mysqltest1.t2(c2 INT);
+CREATE TABLE mysqltest1.t3(c3 INT);
+CREATE TABLE mysqltest1.t4(c4 INT);
+
+INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14);
+INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24);
+INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34);
+INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44);
+
+GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost;
+GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
+GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
+GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
+
+GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
+
+--connect (bug24040_con,localhost,mysqltest_u1,,mysqltest2)
+--echo
+--echo ---> connection: bug24040_con
+
+SELECT * FROM mysqltest1.t1;
+INSERT INTO mysqltest1.t2 VALUES(25);
+UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31;
+DELETE FROM mysqltest1.t4 WHERE c4 = 44;
+
+CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1;
+CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2;
+CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3;
+CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4;
+
+SELECT * FROM v1;
+INSERT INTO v2 VALUES(26);
+UPDATE v3 SET c3 = 332 WHERE c3 = 32;
+DELETE FROM v4 WHERE c4 = 43;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2;
+CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3;
+CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1;
+--error ER_COLUMNACCESS_DENIED_ERROR
+CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3;
+--error ER_COLUMNACCESS_DENIED_ERROR
+CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4;
+
+CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1;
+--error ER_COLUMNACCESS_DENIED_ERROR
+CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2;
+CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4;
+
+CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
+--error ER_COLUMNACCESS_DENIED_ERROR
+CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
+CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
+
+--connection default
+--echo
+--echo ---> connection: default
+
+SELECT * FROM mysqltest1.t1;
+SELECT * FROM mysqltest1.t2;
+SELECT * FROM mysqltest1.t3;
+SELECT * FROM mysqltest1.t4;
+
+# Cleanup.
+
+-- disconnect bug24040_con
+
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER mysqltest_u1@localhost;
+
--echo End of 5.0 tests.
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 5a0ac7b87f7..edf1be1b2b6 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -330,8 +330,6 @@ void free_root(MEM_ROOT *root, myf MyFlags)
DBUG_ENTER("free_root");
DBUG_PRINT("enter",("root: 0x%lx flags: %u", (long) root, (uint) MyFlags));
- if (!root) /* QQ: Should be deleted */
- DBUG_VOID_RETURN; /* purecov: inspected */
if (MyFlags & MY_MARK_BLOCKS_FREE)
{
mark_blocks_free(root);
diff --git a/mysys/my_handler.c b/mysys/my_handler.c
index afc44cc2838..1c3bb20426e 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_handler.c
@@ -557,4 +557,3 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
}
return keyseg;
}
-
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 86b1c2d5851..783a0683731 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -518,7 +518,7 @@ int my_fstat(int Filedes, MY_STAT *stat_area,
myf MyFlags __attribute__((unused)))
{
DBUG_ENTER("my_fstat");
- DBUG_PRINT("my",("fd: %d MyFlags: %d",Filedes,MyFlags));
+ DBUG_PRINT("my",("fd: %d MyFlags: %d", Filedes, MyFlags));
DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area));
}
@@ -527,7 +527,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
{
int m_used;
DBUG_ENTER("my_stat");
- DBUG_PRINT("my", ("path: '%s', stat_area: 0x%lx, MyFlags: %d", path,
+ DBUG_PRINT("my", ("path: '%s' stat_area: 0x%lx MyFlags: %d", path,
(long) stat_area, my_flags));
if ((m_used= (stat_area == NULL)))
diff --git a/mysys/my_seek.c b/mysys/my_seek.c
index e59e205b5f3..6f3c1349722 100644
--- a/mysys/my_seek.c
+++ b/mysys/my_seek.c
@@ -60,7 +60,7 @@ my_off_t my_seek(File fd, my_off_t pos, int whence,
if (newpos == (os_off_t) -1)
{
my_errno=errno;
- DBUG_PRINT("error",("lseek: %lu, errno: %d", (ulong) newpos,errno));
+ DBUG_PRINT("error",("lseek: %lu errno: %d", (ulong) newpos,errno));
DBUG_RETURN(MY_FILEPOS_ERROR);
}
if ((my_off_t) newpos != pos)
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 57670c9ac14..471ec0ab10d 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -76,7 +76,10 @@ void init_thr_alarm(uint max_alarms)
sigfillset(&full_signal_set); /* Neaded to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL);
- thr_client_alarm= thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1;
+ if (thd_lib_detected == THD_LIB_LT)
+ thr_client_alarm= SIGALRM;
+ else
+ thr_client_alarm= SIGUSR1;
#ifndef USE_ALARM_THREAD
if (thd_lib_detected != THD_LIB_LT)
#endif
diff --git a/mysys/typelib.c b/mysys/typelib.c
index dc9f0850bbc..a3b669d2e54 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -20,6 +20,28 @@
#include <m_ctype.h>
+int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option)
+{
+ int res;
+ const char **ptr;
+
+ if ((res= find_type((my_string) x, typelib, 2)) <= 0)
+ {
+ ptr= typelib->type_names;
+ if (!*x)
+ fprintf(stderr, "No option given to %s\n", option);
+ else
+ fprintf(stderr, "Unknown option to %s: %s\n", option, x);
+ fprintf(stderr, "Alternatives are: '%s'", *ptr);
+ while (*++ptr)
+ fprintf(stderr, ",'%s'", *ptr);
+ fprintf(stderr, "\n");
+ exit(1);
+ }
+ return res;
+}
+
+
/*
Search after a string in a list of strings. Endspace in x is not compared.
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index eab3af29ad1..83d7e237a54 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -54,6 +54,21 @@ for arg do
esac
done
+# Avoid too long command lines for cp (bug#27489)
+MCP() {
+ for i
+ do
+ last=$i
+ done
+ for i
+ do
+ if test "x$i" != "x$last"
+ then
+ cp -p $i $last
+ fi
+ done
+}
+
# Remove vendor from $system
system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'`
@@ -117,7 +132,12 @@ if [ $BASE_SYSTEM != "netware" ] ; then
chmod o-rwx $BASE/data $BASE/data/*
fi
-# Copy files if they exists, warn for those that don't
+# Copy files if they exists, warn for those that don't.
+# Note that when listing files to copy, we might list the file name
+# twice, once in the directory location where it is build, and a
+# second time in the ".libs" location. In the case the firs one
+# is a wrapper script, the second one will overwrite it with the
+# binary file.
copyfileto()
{
destdir=$1
@@ -168,6 +188,7 @@ if [ $BASE_SYSTEM = "netware" ] ; then
# For all other platforms:
else
BIN_FILES="$BIN_FILES \
+ server-tools/instance-manager/.libs/mysqlmanager \
client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
client/.libs/mysqlslap \
client/.libs/mysqldump client/.libs/mysqlimport \
@@ -253,25 +274,25 @@ copyfileto $BASE/mysql-test \
mysql-test/valgrind.supp \
netware/mysql_test_run.nlm netware/install_test_db.ncf
-$CP mysql-test/lib/*.pl $BASE/mysql-test/lib
-$CP mysql-test/t/*.def $BASE/mysql-test/t
-$CP mysql-test/include/*.inc $BASE/mysql-test/include
-$CP mysql-test/include/*.test $BASE/mysql-test/include
-$CP mysql-test/t/*.def $BASE/mysql-test/t
-$CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
+MCP mysql-test/lib/*.pl $BASE/mysql-test/lib
+MCP mysql-test/t/*.def $BASE/mysql-test/t
+MCP mysql-test/include/*.inc $BASE/mysql-test/include
+MCP mysql-test/include/*.test $BASE/mysql-test/include
+MCP mysql-test/t/*.def $BASE/mysql-test/t
+MCP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \
mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \
mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \
mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \
$BASE/mysql-test/std_data
-$CP mysql-test/t/*.test $BASE/mysql-test/t
-$CP mysql-test/t/*.imtest mysql-test/t/*.disabled $BASE/mysql-test/t
-$CP mysql-test/t/*.opt mysql-test/t/*.slave-mi $BASE/mysql-test/t
-$CP mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t
-$CP mysql-test/r/*.result $BASE/mysql-test/r
-$CP mysql-test/r/*.require $BASE/mysql-test/r
-$CP mysql-test/extra/binlog_tests/*.test $BASE/mysql-test/extra/binlog_tests
-$CP mysql-test/extra/rpl_tests/*.test $BASE/mysql-test/extra/rpl_tests
+MCP mysql-test/t/*.test $BASE/mysql-test/t
+MCP mysql-test/t/*.imtest mysql-test/t/*.disabled $BASE/mysql-test/t
+MCP mysql-test/t/*.opt mysql-test/t/*.slave-mi $BASE/mysql-test/t
+MCP mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t
+MCP mysql-test/r/*.result $BASE/mysql-test/r
+MCP mysql-test/r/*.require $BASE/mysql-test/r
+MCP mysql-test/extra/binlog_tests/*.test $BASE/mysql-test/extra/binlog_tests
+MCP mysql-test/extra/rpl_tests/*.test $BASE/mysql-test/extra/rpl_tests
if [ $BASE_SYSTEM != "netware" ] ; then
chmod a+x $BASE/bin/*
diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist
index 1cd4141f532..2e10e530ca6 100755
--- a/scripts/make_win_bin_dist
+++ b/scripts/make_win_bin_dist
@@ -127,6 +127,15 @@ if [ -e $DESTDIR ] ; then
fi
# ----------------------------------------------------------------------
+# Adjust target name if needed, release with debug info has another name
+# ----------------------------------------------------------------------
+
+if [ x"$TARGET" = x"release" -a -f "client/relwithdebinfo/mysql.exe" ]
+then
+ TARGET="relwithdebinfo"
+fi
+
+# ----------------------------------------------------------------------
# Copy executables, and client DLL (FIXME why?)
# ----------------------------------------------------------------------
@@ -134,18 +143,27 @@ trap 'echo "Clearning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR
mkdir $DESTDIR
mkdir $DESTDIR/bin
-cp client/$TARGET/*.exe $DESTDIR/bin/
-cp extra/$TARGET/*.exe $DESTDIR/bin/
-cp storage/myisam/$TARGET/*.exe $DESTDIR/bin/
-cp server-tools/instance-manager/$TARGET/*.exe $DESTDIR/bin/
-cp tests/$TARGET/*.exe $DESTDIR/bin/
-cp libmysql/$TARGET/*.exe $DESTDIR/bin/
-cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/
+cp client/$TARGET/*.exe $DESTDIR/bin/
+cp extra/$TARGET/*.exe $DESTDIR/bin/
+cp storage/myisam/$TARGET/*.exe $DESTDIR/bin/
+cp server-tools/instance-manager/$TARGET/*.{exe,map} $DESTDIR/bin/
+if [ x"$TARGET" != x"release" ]
+then
+ cp server-tools/instance-manager/$TARGET/*.pdb $DESTDIR/bin/
+fi
+cp tests/$TARGET/*.exe $DESTDIR/bin/
+cp libmysql/$TARGET/*.exe $DESTDIR/bin/
+cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/
# FIXME really needed?!
mv $DESTDIR/bin/comp_err.exe $DESTDIR/bin/comp-err.exe
cp sql/$TARGET/mysqld.exe $DESTDIR/bin/mysqld$EXE_SUFFIX.exe
+cp sql/$TARGET/mysqld.map $DESTDIR/bin/mysqld$EXE_SUFFIX.map
+if [ x"$TARGET" != x"release" ]
+then
+ cp sql/$TARGET/mysqld.pdb $DESTDIR/bin/mysqld$EXE_SUFFIX.pdb
+fi
if [ x"$PACK_DEBUG" = "" -a -f "sql/debug/mysqld.exe" -o \
x"$PACK_DEBUG" = "yes" ] ; then
@@ -343,6 +361,9 @@ done
cp -pR sql/share $DESTDIR/
+# The SQL initiation code is really expected to be in "share"
+mv $DESTDIR/scripts/*.sql $DESTDIR/share/ || true
+
# ----------------------------------------------------------------------
# Copy other files specified on command line DEST=SOURCE
# ----------------------------------------------------------------------
diff --git a/server-tools/instance-manager/log.cc b/server-tools/instance-manager/log.cc
index 145f99db521..9f276523e49 100644
--- a/server-tools/instance-manager/log.cc
+++ b/server-tools/instance-manager/log.cc
@@ -134,7 +134,10 @@ void log_init()
/*
The function is intended to log error messages. It precedes a message
- with date, time and [ERROR] tag and print it to the stderr.
+ with date, time and [ERROR] tag and print it to the stderr and stdout.
+
+ We want to print it on stdout to be able to know in which context we got the
+ error
SYNOPSIS
log_error()
@@ -146,7 +149,10 @@ void log_error(const char *format, ...)
{
va_list args;
va_start(args, format);
+ log(stdout, "ERROR", format, args);
+ fflush(stdout);
log(stderr, "ERROR", format, args);
+ fflush(stderr);
va_end(args);
}
diff --git a/server-tools/instance-manager/thread_registry.cc b/server-tools/instance-manager/thread_registry.cc
index f3a67c5e127..700ed22afe7 100644
--- a/server-tools/instance-manager/thread_registry.cc
+++ b/server-tools/instance-manager/thread_registry.cc
@@ -18,12 +18,9 @@
#endif
#include "thread_registry.h"
-
-#include <my_global.h>
#include <thr_alarm.h>
-
#include <signal.h>
-
+#include "log.h"
#ifndef __WIN__
/* Kick-off signal handler */
@@ -67,6 +64,8 @@ Thread_registry::~Thread_registry()
/* Check that no one uses the repository. */
pthread_mutex_lock(&LOCK_thread_registry);
+ if (head.next != &head)
+ log_error("Not all threads died properly\n");
/* All threads must unregister */
DBUG_ASSERT(head.next == &head);
diff --git a/sql-common/client.c b/sql-common/client.c
index 89d69b4bd1f..2c09498d8f4 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -2596,24 +2596,32 @@ static void mysql_close_free(MYSQL *mysql)
SYNOPSYS
mysql_detach_stmt_list()
stmt_list pointer to mysql->stmts
+ func_name name of calling function
NOTE
There is similar code in mysql_reconnect(), so changes here
should also be reflected there.
*/
-void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)))
+void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)),
+ const char *func_name __attribute__((unused)))
{
#ifdef MYSQL_CLIENT
/* Reset connection handle in all prepared statements. */
LIST *element= *stmt_list;
+ char buff[MYSQL_ERRMSG_SIZE];
+ DBUG_ENTER("mysql_detach_stmt_list");
+
+ my_snprintf(buff, sizeof(buff)-1, ER(CR_STMT_CLOSED), func_name);
for (; element; element= element->next)
{
MYSQL_STMT *stmt= (MYSQL_STMT *) element->data;
+ set_stmt_errmsg(stmt, buff, CR_STMT_CLOSED, unknown_sqlstate);
stmt->mysql= 0;
/* No need to call list_delete for statement here */
}
*stmt_list= 0;
+ DBUG_VOID_RETURN;
#endif /* MYSQL_CLIENT */
}
@@ -2634,7 +2642,7 @@ void STDCALL mysql_close(MYSQL *mysql)
}
mysql_close_free_options(mysql);
mysql_close_free(mysql);
- mysql_detach_stmt_list(&mysql->stmts);
+ mysql_detach_stmt_list(&mysql->stmts, "mysql_close");
#ifndef TO_BE_DELETED
/* free/close slave list */
if (mysql->rpl_pivot)
@@ -2820,6 +2828,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
result->field_count= mysql->field_count;
/* The rest of result members is bzeroed in malloc */
mysql->fields=0; /* fields is now in result */
+ clear_alloc_root(&mysql->field_alloc);
/* just in case this was mistakenly called after mysql_stmt_execute() */
mysql->unbuffered_fetch_owner= 0;
DBUG_RETURN(result); /* Data fetched */
@@ -2869,6 +2878,7 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql)
result->handle= mysql;
result->current_row= 0;
mysql->fields=0; /* fields is now in result */
+ clear_alloc_root(&mysql->field_alloc);
mysql->status=MYSQL_STATUS_USE_RESULT;
mysql->unbuffered_fetch_owner= &result->unbuffered_fetch_cancelled;
DBUG_RETURN(result); /* Data is read to be fetched */
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 0530482237e..f08e2e00ef3 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -453,7 +453,7 @@ err:
/*
- Convert a time string to a TIME struct.
+ Convert a time string to a MYSQL_TIME struct.
SYNOPSIS
str_to_time()
@@ -639,11 +639,11 @@ fractional:
l_time->second_part= date[4];
l_time->time_type= MYSQL_TIMESTAMP_TIME;
- /* Check if the value is valid and fits into TIME range */
+ /* Check if the value is valid and fits into MYSQL_TIME range */
if (check_time_range(l_time, warning))
return 1;
- /* Check if there is garbage at end of the TIME specification */
+ /* Check if there is garbage at end of the MYSQL_TIME specification */
if (str != end)
{
do
@@ -660,11 +660,11 @@ fractional:
/*
- Check 'time' value to lie in the TIME range
+ Check 'time' value to lie in the MYSQL_TIME range
SYNOPSIS:
check_time_range()
- time pointer to TIME value
+ time pointer to MYSQL_TIME value
warning set MYSQL_TIME_WARN_OUT_OF_RANGE flag if the value is out of range
DESCRIPTION
@@ -727,7 +727,39 @@ void init_time(void)
}
- /* Calculate nr of day since year 0 in new date-system (from 1615) */
+/*
+ Handle 2 digit year conversions
+
+ SYNOPSIS
+ year_2000_handling()
+ year 2 digit year
+
+ RETURN
+ Year between 1970-2069
+*/
+
+uint year_2000_handling(uint year)
+{
+ if ((year=year+1900) < 1900+YY_PART_YEAR)
+ year+=100;
+ return year;
+}
+
+
+/*
+ Calculate nr of day since year 0 in new date-system (from 1615)
+
+ SYNOPSIS
+ calc_daynr()
+ year Year (exact 4 digit year, no year conversions)
+ month Month
+ day Day
+
+ NOTES: 0000-00-00 is a valid date, and will return 0
+
+ RETURN
+ Days since 0000-00-00
+*/
long calc_daynr(uint year,uint month,uint day)
{
@@ -737,11 +769,6 @@ long calc_daynr(uint year,uint month,uint day)
if (year == 0 && month == 0 && day == 0)
DBUG_RETURN(0); /* Skip errors */
- if (year < YY_MAGIC_BELOW)
- {
- if ((year=year+1900) < 1900+YY_PART_YEAR)
- year+=100;
- }
delsum= (long) (365L * year+ 31*(month-1) +day);
if (month <= 2)
year--;
@@ -978,7 +1005,7 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type)
/*
Functions to convert time/date/datetime value to a string,
using default format.
- This functions don't check that given TIME structure members are
+ 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
@@ -1064,7 +1091,7 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to)
DESCRIPTION
Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS,
- YYYYMMDDHHMMSS to broken-down TIME representation. Return value in
+ YYYYMMDDHHMMSS to broken-down MYSQL_TIME representation. Return value in
YYYYMMDDHHMMSS format as side-effect.
This function also checks if datetime value fits in DATETIME range.
@@ -1120,6 +1147,7 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
ok:
part1=(long) (nr/LL(1000000));
part2=(long) (nr - (longlong) part1*LL(1000000));
+ time_res->neg= 0;
time_res->year= (int) (part1/10000L); part1%=10000L;
time_res->month= (int) part1 / 100;
time_res->day= (int) part1 % 100;
@@ -1156,7 +1184,7 @@ ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time)
}
-/* Convert TIME value to integer in YYYYMMDD format */
+/* Convert MYSQL_TIME value to integer in YYYYMMDD format */
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time)
{
@@ -1166,7 +1194,7 @@ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time)
/*
- Convert TIME value to integer in HHMMSS format.
+ Convert MYSQL_TIME value to integer in HHMMSS format.
This function doesn't take into account time->day member:
it's assumed that days have been converted to hours already.
*/
@@ -1180,7 +1208,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time)
/*
- Convert struct TIME (date and time split into year/month/day/hour/...
+ Convert struct MYSQL_TIME (date and time split into year/month/day/hour/...
to a number in format YYYYMMDDHHMMSS (DATETIME),
YYYYMMDD (DATE) or HHMMSS (TIME).
@@ -1194,7 +1222,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time)
SELECT ?+1;
NOTE
- This function doesn't check that given TIME structure members are
+ This function doesn'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.
*/
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 6d0d0473151..fe919d6442d 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -81,7 +81,7 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc
${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc
${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl
- taocrypt strings vio regex wsock32)
+ taocrypt strings vio regex wsock32 ws2_32)
IF(WITH_ARCHIVE_STORAGE_ENGINE)
TARGET_LINK_LIBRARIES(mysqld archive)
ENDIF(WITH_ARCHIVE_STORAGE_ENGINE)
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 3d2a5b277fe..56ac7c1a88d 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -286,7 +286,7 @@ int
Event_parse_data::init_execute_at(THD *thd)
{
my_bool not_used;
- TIME ltime;
+ MYSQL_TIME ltime;
my_time_t ltime_utc;
DBUG_ENTER("Event_parse_data::init_execute_at");
@@ -455,7 +455,7 @@ int
Event_parse_data::init_starts(THD *thd)
{
my_bool not_used;
- TIME ltime;
+ MYSQL_TIME ltime;
my_time_t ltime_utc;
DBUG_ENTER("Event_parse_data::init_starts");
@@ -509,7 +509,7 @@ int
Event_parse_data::init_ends(THD *thd)
{
my_bool not_used;
- TIME ltime;
+ MYSQL_TIME ltime;
my_time_t ltime_utc;
DBUG_ENTER("Event_parse_data::init_ends");
@@ -941,7 +941,7 @@ int
Event_queue_element::load_from_row(THD *thd, TABLE *table)
{
char *ptr;
- TIME time;
+ MYSQL_TIME time;
LEX_STRING tz_name;
DBUG_ENTER("Event_queue_element::load_from_row");
@@ -1136,7 +1136,7 @@ error:
*/
static
my_time_t
-add_interval(TIME *ltime, const Time_zone *time_zone,
+add_interval(MYSQL_TIME *ltime, const Time_zone *time_zone,
interval_type scale, INTERVAL interval)
{
if (date_add_interval(ltime, scale, interval))
@@ -1229,8 +1229,8 @@ bool get_next_time(const Time_zone *time_zone, my_time_t *next,
}
DBUG_PRINT("info", ("seconds: %ld months: %ld", (long) seconds, (long) months));
- TIME local_start;
- TIME local_now;
+ MYSQL_TIME local_start;
+ MYSQL_TIME local_now;
/* Convert times from UTC to local. */
{
@@ -1473,7 +1473,7 @@ Event_queue_element::compute_next_execution_time()
{
/*
Both starts and m_ends are set and time_now is between them (incl.)
- If last_executed is set then increase with m_expression. The new TIME is
+ If last_executed is set then increase with m_expression. The new MYSQL_TIME is
after m_ends set execute_at to 0. And check for on_completion
If not set then schedule for now.
*/
@@ -1615,7 +1615,7 @@ err:
/*
- Set the internal last_executed TIME struct to now. NOW is the
+ Set the internal last_executed MYSQL_TIME struct to now. NOW is the
time according to thd->query_start(), so the THD's clock.
SYNOPSIS
@@ -1686,7 +1686,7 @@ append_datetime(String *buf, Time_zone *time_zone, my_time_t secs,
Pass the buffer and the second param tells fills the buffer and
returns the number of chars to copy.
*/
- TIME time;
+ MYSQL_TIME time;
time_zone->gmt_sec_to_TIME(&time, secs);
buf->append(dtime_buff, my_datetime_to_str(&time, dtime_buff));
buf->append(STRING_WITH_LEN("'"));
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index e3b45d5e0b2..e49fd6791a0 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -218,7 +218,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
if (!et->starts_null)
{
- TIME time;
+ MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->starts);
fields[ET_FIELD_STARTS]->set_notnull();
@@ -227,7 +227,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
if (!et->ends_null)
{
- TIME time;
+ MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->ends);
fields[ET_FIELD_ENDS]->set_notnull();
@@ -246,7 +246,7 @@ mysql_event_fill_row(THD *thd, TABLE *table, Event_parse_data *et,
fields[ET_FIELD_STARTS]->set_null();
fields[ET_FIELD_ENDS]->set_null();
- TIME time;
+ MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, et->execute_at);
fields[ET_FIELD_EXECUTE_AT]->set_notnull();
@@ -940,7 +940,7 @@ update_timing_fields_for_event(THD *thd,
if (update_last_executed)
{
- TIME time;
+ MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, last_executed);
fields[ET_FIELD_LAST_EXECUTED]->set_notnull();
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index 9b14d3cda7e..a7c31429cb3 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -737,7 +737,7 @@ Event_queue::dump_internal_status()
mutex_last_attempted_lock_at_line);
printf("WOC : %s\n", waiting_on_cond? "YES":"NO");
- TIME time;
+ MYSQL_TIME time;
my_tz_UTC->gmt_sec_to_TIME(&time, next_activation_at);
printf("Next activation : %04d-%02d-%02d %02d:%02d:%02d\n",
time.year, time.month, time.day, time.hour, time.minute, time.second);
diff --git a/sql/field.cc b/sql/field.cc
index a48a3ff7bcd..82f8283ba56 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1574,7 +1574,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
}
-bool Field::get_date(TIME *ltime,uint fuzzydate)
+bool Field::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
@@ -1585,7 +1585,7 @@ bool Field::get_date(TIME *ltime,uint fuzzydate)
return 0;
}
-bool Field::get_time(TIME *ltime)
+bool Field::get_time(MYSQL_TIME *ltime)
{
char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
@@ -1602,7 +1602,7 @@ bool Field::get_time(TIME *ltime)
Needs to be changed if/when we want to support different time formats
*/
-int Field::store_time(TIME *ltime, timestamp_type type_arg)
+int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
char buff[MAX_DATE_STRING_REP_LENGTH];
@@ -2550,7 +2550,7 @@ int Field_new_decimal::store_decimal(const my_decimal *decimal_value)
}
-int Field_new_decimal::store_time(TIME *ltime, timestamp_type t_type)
+int Field_new_decimal::store_time(MYSQL_TIME *ltime, timestamp_type t_type)
{
my_decimal decimal_value;
return store_value(date2my_decimal(ltime, &decimal_value));
@@ -4457,7 +4457,7 @@ timestamp_auto_set_type Field_timestamp::get_auto_set_type() const
int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME l_time;
+ MYSQL_TIME l_time;
my_time_t tmp= 0;
int error;
bool have_smth_to_conv;
@@ -4528,7 +4528,7 @@ int Field_timestamp::store(double nr)
int Field_timestamp::store(longlong nr, bool unsigned_val)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME l_time;
+ MYSQL_TIME l_time;
my_time_t timestamp= 0;
int error;
my_bool in_dst_time_gap;
@@ -4587,7 +4587,7 @@ longlong Field_timestamp::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
uint32 temp;
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
THD *thd= table ? table->in_use : current_thd;
#ifdef WORDS_BIGENDIAN
@@ -4613,7 +4613,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
{
ASSERT_COLUMN_MARKED_FOR_READ;
uint32 temp, temp2;
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
THD *thd= table ? table->in_use : current_thd;
char *to;
@@ -4682,7 +4682,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
}
-bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate)
+bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
long temp;
THD *thd= table ? table->in_use : current_thd;
@@ -4706,7 +4706,7 @@ bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate)
return 0;
}
-bool Field_timestamp::get_time(TIME *ltime)
+bool Field_timestamp::get_time(MYSQL_TIME *ltime)
{
return Field_timestamp::get_date(ltime,0);
}
@@ -4714,7 +4714,7 @@ bool Field_timestamp::get_time(TIME *ltime)
bool Field_timestamp::send_binary(Protocol *protocol)
{
- TIME tm;
+ MYSQL_TIME tm;
Field_timestamp::get_date(&tm, 0);
return protocol->store(&tm);
}
@@ -4790,7 +4790,7 @@ void Field_timestamp::set_time()
int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{
- TIME ltime;
+ MYSQL_TIME ltime;
long tmp;
int error= 0;
int warning;
@@ -4805,9 +4805,12 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
else
{
if (warning & MYSQL_TIME_WARN_TRUNCATED)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ {
+ 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,
@@ -4818,8 +4821,6 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
if (ltime.month)
ltime.day=0;
tmp=(ltime.day*24L+ltime.hour)*10000L+(ltime.minute*100+ltime.second);
- if (error > 1)
- error= 2;
}
if (ltime.neg)
@@ -4829,7 +4830,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
}
-int Field_time::store_time(TIME *ltime, timestamp_type time_type)
+int Field_time::store_time(MYSQL_TIME *ltime, timestamp_type time_type)
{
long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L +
(ltime->minute * 100 + ltime->second);
@@ -4938,7 +4939,7 @@ String *Field_time::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
ASSERT_COLUMN_MARKED_FOR_READ;
- TIME ltime;
+ MYSQL_TIME ltime;
val_buffer->alloc(19);
long tmp=(long) sint3korr(ptr);
ltime.neg= 0;
@@ -4962,7 +4963,7 @@ String *Field_time::val_str(String *val_buffer,
DATE_FORMAT(time, "%l.%i %p")
*/
-bool Field_time::get_date(TIME *ltime, uint fuzzydate)
+bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
long tmp;
THD *thd= table ? table->in_use : current_thd;
@@ -4990,7 +4991,7 @@ bool Field_time::get_date(TIME *ltime, uint fuzzydate)
}
-bool Field_time::get_time(TIME *ltime)
+bool Field_time::get_time(MYSQL_TIME *ltime)
{
long tmp=(long) sint3korr(ptr);
ltime->neg=0;
@@ -5012,7 +5013,7 @@ bool Field_time::get_time(TIME *ltime)
bool Field_time::send_binary(Protocol *protocol)
{
- TIME tm;
+ MYSQL_TIME tm;
Field_time::get_time(&tm);
tm.day= tm.hour/24; // Move hours to days
tm.hour-= tm.day*24;
@@ -5170,7 +5171,7 @@ void Field_year::sql_type(String &res) const
int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME l_time;
+ MYSQL_TIME l_time;
uint32 tmp;
int error;
THD *thd= table ? table->in_use : current_thd;
@@ -5227,7 +5228,7 @@ int Field_date::store(double nr)
int Field_date::store(longlong nr, bool unsigned_val)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME not_used;
+ MYSQL_TIME not_used;
int error;
longlong initial_nr= nr;
THD *thd= table ? table->in_use : current_thd;
@@ -5268,7 +5269,7 @@ int Field_date::store(longlong nr, bool unsigned_val)
bool Field_date::send_binary(Protocol *protocol)
{
longlong tmp= Field_date::val_int();
- TIME tm;
+ MYSQL_TIME tm;
tm.year= (uint32) tmp/10000L % 10000;
tm.month= (uint32) tmp/100 % 100;
tm.day= (uint32) tmp % 100;
@@ -5308,7 +5309,7 @@ String *Field_date::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
ASSERT_COLUMN_MARKED_FOR_READ;
- TIME ltime;
+ MYSQL_TIME ltime;
val_buffer->alloc(field_length);
int32 tmp;
#ifdef WORDS_BIGENDIAN
@@ -5377,10 +5378,27 @@ 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)
+*/
+
int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME l_time;
+ long tmp;
+ MYSQL_TIME l_time;
int error;
THD *thd= table ? table->in_use : current_thd;
enum enum_mysql_timestamp_type ret;
@@ -5391,20 +5409,23 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
MODE_INVALID_DATES))),
&error)) <= MYSQL_TIMESTAMP_ERROR)
{
- int3store(ptr,0L);
+ tmp= 0;
error= 2;
}
else
{
- int3store(ptr, l_time.day + l_time.month*32 + l_time.year*16*32);
- if(!error && (ret != MYSQL_TIMESTAMP_DATE))
- return 2;
+ tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
+ if (!error && (ret != MYSQL_TIMESTAMP_DATE))
+ error= 3; // Datetime was cut (note)
}
if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
+ 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;
}
@@ -5425,7 +5446,7 @@ int Field_newdate::store(double nr)
int Field_newdate::store(longlong nr, bool unsigned_val)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME l_time;
+ MYSQL_TIME l_time;
longlong tmp;
int error;
THD *thd= table ? table->in_use : current_thd;
@@ -5452,7 +5473,7 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
}
-int Field_newdate::store_time(TIME *ltime,timestamp_type time_type)
+int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
long tmp;
@@ -5487,7 +5508,7 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type time_type)
bool Field_newdate::send_binary(Protocol *protocol)
{
- TIME tm;
+ MYSQL_TIME tm;
Field_newdate::get_date(&tm,0);
return protocol->store_date(&tm);
}
@@ -5538,7 +5559,7 @@ String *Field_newdate::val_str(String *val_buffer,
}
-bool Field_newdate::get_date(TIME *ltime,uint fuzzydate)
+bool Field_newdate::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
uint32 tmp=(uint32) uint3korr(ptr);
ltime->day= tmp & 31;
@@ -5551,7 +5572,7 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate)
}
-bool Field_newdate::get_time(TIME *ltime)
+bool Field_newdate::get_time(MYSQL_TIME *ltime)
{
return Field_newdate::get_date(ltime,0);
}
@@ -5590,7 +5611,7 @@ void Field_newdate::sql_type(String &res) const
int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
int error;
ulonglong tmp= 0;
enum enum_mysql_timestamp_type func_res;
@@ -5643,7 +5664,7 @@ int Field_datetime::store(double nr)
int Field_datetime::store(longlong nr, bool unsigned_val)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
- TIME not_used;
+ MYSQL_TIME not_used;
int error;
longlong initial_nr= nr;
THD *thd= table ? table->in_use : current_thd;
@@ -5678,7 +5699,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val)
}
-int Field_datetime::store_time(TIME *ltime,timestamp_type time_type)
+int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
longlong tmp;
@@ -5724,7 +5745,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type time_type)
bool Field_datetime::send_binary(Protocol *protocol)
{
- TIME tm;
+ MYSQL_TIME tm;
Field_datetime::get_date(&tm, TIME_FUZZY_DATE);
return protocol->store(&tm);
}
@@ -5798,7 +5819,7 @@ String *Field_datetime::val_str(String *val_buffer,
return val_buffer;
}
-bool Field_datetime::get_date(TIME *ltime, uint fuzzydate)
+bool Field_datetime::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
longlong tmp=Field_datetime::val_int();
uint32 part1,part2;
@@ -5817,7 +5838,7 @@ bool Field_datetime::get_date(TIME *ltime, uint fuzzydate)
return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0;
}
-bool Field_datetime::get_time(TIME *ltime)
+bool Field_datetime::get_time(MYSQL_TIME *ltime)
{
return Field_datetime::get_date(ltime,0);
}
@@ -9354,10 +9375,13 @@ uint32 Field_blob::max_display_length()
NOTE
This function won't produce warning and increase cut fields counter
- if count_cuted_fields == FIELD_CHECK_IGNORE for current thread.
+ if count_cuted_fields == CHECK_FIELD_IGNORE for current thread.
+
+ if count_cuted_fields == CHECK_FIELD_IGNORE then we ignore notes.
+ This allows us to avoid notes in optimisation, like convert_constant_item().
RETURN VALUE
- 1 if count_cuted_fields == FIELD_CHECK_IGNORE
+ 1 if count_cuted_fields == CHECK_FIELD_IGNORE and error level is not NOTE
0 otherwise
*/
@@ -9377,7 +9401,7 @@ Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
thd->row_count);
return 0;
}
- return 1;
+ return level >= MYSQL_ERROR::WARN_LEVEL_WARN;
}
@@ -9405,9 +9429,10 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
timestamp_type ts_type, int cuted_increment)
{
THD *thd= table ? table->in_use : current_thd;
- if (thd->really_abort_on_warning() ||
+ if ((thd->really_abort_on_warning() &&
+ level >= MYSQL_ERROR::WARN_LEVEL_WARN) ||
set_warning(level, code, cuted_increment))
- make_truncated_value_warning(thd, str, str_length, ts_type,
+ make_truncated_value_warning(thd, level, str, str_length, ts_type,
field_name);
}
@@ -9440,7 +9465,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
{
char str_nr[22];
char *str_end= longlong10_to_str(nr, str_nr, -10);
- make_truncated_value_warning(thd, str_nr, (uint) (str_end - str_nr),
+ make_truncated_value_warning(thd, level, str_nr, (uint) (str_end - str_nr),
ts_type, field_name);
}
}
@@ -9473,7 +9498,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
/* 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, str_nr, str_len, ts_type,
+ make_truncated_value_warning(thd, level, str_nr, str_len, ts_type,
field_name);
}
}
diff --git a/sql/field.h b/sql/field.h
index 3d1ac7528c1..441ff9079c1 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -98,7 +98,7 @@ 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(TIME *ltime, timestamp_type t_type);
+ virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
virtual double val_real(void)=0;
virtual longlong val_int(void)=0;
virtual my_decimal *val_decimal(my_decimal *);
@@ -347,8 +347,8 @@ public:
}
void copy_from_tmp(int offset);
uint fill_cache_field(struct st_cache_field *copy);
- virtual bool get_date(TIME *ltime,uint fuzzydate);
- virtual bool get_time(TIME *ltime);
+ virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ virtual bool get_time(MYSQL_TIME *ltime);
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; }
@@ -567,7 +567,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(TIME *ltime, timestamp_type t_type);
+ int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
int store_decimal(const my_decimal *);
double val_real(void);
longlong val_int(void);
@@ -910,8 +910,8 @@ public:
longget(tmp,ptr);
return tmp;
}
- bool get_date(TIME *ltime,uint fuzzydate);
- bool get_time(TIME *ltime);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ bool get_time(MYSQL_TIME *ltime);
timestamp_auto_set_type get_auto_set_type() const;
};
@@ -984,7 +984,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(TIME *ltime, timestamp_type type);
+ int store_time(MYSQL_TIME *ltime, timestamp_type type);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
double val_real(void);
longlong val_int(void);
@@ -996,8 +996,8 @@ public:
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
- bool get_date(TIME *ltime,uint fuzzydate);
- bool get_time(TIME *ltime);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ bool get_time(MYSQL_TIME *ltime);
};
@@ -1016,7 +1016,7 @@ public:
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(TIME *ltime, timestamp_type type);
+ int store_time(MYSQL_TIME *ltime, timestamp_type type);
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
@@ -1024,9 +1024,9 @@ public:
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
- bool get_date(TIME *ltime, uint fuzzydate);
+ bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
bool send_binary(Protocol *protocol);
- bool get_time(TIME *ltime);
+ bool get_time(MYSQL_TIME *ltime);
int cmp(const char *,const char*);
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 3; }
@@ -1057,7 +1057,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(TIME *ltime, timestamp_type type);
+ 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;
@@ -1073,8 +1073,8 @@ public:
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
- bool get_date(TIME *ltime,uint fuzzydate);
- bool get_time(TIME *ltime);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ bool get_time(MYSQL_TIME *ltime);
};
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 05db9cc1660..58d34d99174 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -134,7 +134,7 @@ static uint ndbcluster_alter_table_flags(uint flags)
}
static int ndbcluster_inited= 0;
-static int ndbcluster_terminating= 0;
+int ndbcluster_terminating= 0;
static Ndb* g_ndb= NULL;
Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
@@ -481,7 +481,10 @@ int ha_ndbcluster::records_update()
{
Ndb *ndb= get_ndb();
struct Ndb_statistics stat;
- ndb->setDatabaseName(m_dbname);
+ if (ndb->setDatabaseName(m_dbname))
+ {
+ return my_errno= HA_ERR_OUT_OF_MEM;
+ }
result= ndb_get_table_statistics(this, TRUE, ndb, m_table, &stat);
if (result == 0)
{
@@ -875,7 +878,11 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
DBUG_PRINT("info", ("allocate blobs buffer size %u", offset));
buffer= my_malloc(offset, MYF(MY_WME));
if (buffer == NULL)
+ {
+ sql_print_error("ha_ndbcluster::get_ndb_blobs_value: "
+ "my_malloc(%u) failed", offset);
DBUG_RETURN(-1);
+ }
buffer_size= offset;
}
}
@@ -1067,6 +1074,12 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
if (data.unique_index_attrid_map)
my_free((char*)data.unique_index_attrid_map, MYF(0));
data.unique_index_attrid_map= (uchar*)my_malloc(sz,MYF(MY_WME));
+ if (data.unique_index_attrid_map == 0)
+ {
+ sql_print_error("fix_unique_index_attr_order: my_malloc(%u) failure",
+ (unsigned int)sz);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts;
@@ -3829,7 +3842,10 @@ int ha_ndbcluster::info(uint flag)
Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname);
struct Ndb_statistics stat;
- ndb->setDatabaseName(m_dbname);
+ if (ndb->setDatabaseName(m_dbname))
+ {
+ DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM);
+ }
if (current_thd->variables.ndb_use_exact_count &&
(result= ndb_get_table_statistics(this, TRUE, ndb, m_table, &stat))
== 0)
@@ -4264,8 +4280,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
{
m_transaction_on= FALSE;
/* Would be simpler if has_transactions() didn't always say "yes" */
- thd->options|= OPTION_STATUS_NO_TRANS_UPDATE;
- thd->no_trans_update= TRUE;
+ thd->no_trans_update.all= thd->no_trans_update.stmt= TRUE;
}
else if (!thd->transaction.on)
m_transaction_on= FALSE;
@@ -4601,7 +4616,10 @@ static int create_ndb_column(NDBCOL &col,
HA_CREATE_INFO *info)
{
// Set name
- col.setName(field->field_name);
+ if (col.setName(field->field_name))
+ {
+ return (my_errno= errno);
+ }
// Get char set
CHARSET_INFO *cs= field->charset();
// Set type and sizes
@@ -4959,7 +4977,10 @@ int ha_ndbcluster::create(const char *name,
#endif /* HAVE_NDB_BINLOG */
DBUG_PRINT("table", ("name: %s", m_tabname));
- tab.setName(m_tabname);
+ if (tab.setName(m_tabname))
+ {
+ DBUG_RETURN(my_errno= errno);
+ }
tab.setLogging(!(create_info->options & HA_LEX_CREATE_TMP_TABLE));
tab.setSingleUserMode(single_user_mode);
@@ -4979,7 +5000,7 @@ int ha_ndbcluster::create(const char *name,
for (i= 0; i < form->s->fields; i++)
{
Field *field= form->field[i];
- DBUG_PRINT("info", ("name: %s, type: %u, pack_length: %d",
+ DBUG_PRINT("info", ("name: %s type: %u pack_length: %d",
field->field_name, field->real_type(),
field->pack_length()));
if ((my_errno= create_ndb_column(col, field, create_info)))
@@ -4991,7 +5012,10 @@ int ha_ndbcluster::create(const char *name,
else
col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
- tab.addColumn(col);
+ if (tab.addColumn(col))
+ {
+ DBUG_RETURN(my_errno= errno);
+ }
if (col.getPrimaryKey())
pk_length += (field->pack_length() + 3) / 4;
}
@@ -5033,13 +5057,19 @@ int ha_ndbcluster::create(const char *name,
if (form->s->primary_key == MAX_KEY)
{
DBUG_PRINT("info", ("Generating shadow key"));
- col.setName("$PK");
+ if (col.setName("$PK"))
+ {
+ DBUG_RETURN(my_errno= errno);
+ }
col.setType(NdbDictionary::Column::Bigunsigned);
col.setLength(1);
col.setNullable(FALSE);
col.setPrimaryKey(TRUE);
col.setAutoIncrement(TRUE);
- tab.addColumn(col);
+ if (tab.addColumn(col))
+ {
+ DBUG_RETURN(my_errno= errno);
+ }
pk_length += 2;
}
@@ -5387,13 +5417,19 @@ int ha_ndbcluster::create_ndb_index(const char *name,
// TODO Only temporary ordered indexes supported
ndb_index.setLogging(FALSE);
}
- ndb_index.setTable(m_tabname);
+ if (ndb_index.setTable(m_tabname))
+ {
+ DBUG_RETURN(my_errno= errno);
+ }
for (; key_part != end; key_part++)
{
Field *field= key_part->field;
DBUG_PRINT("info", ("attr: %s", field->field_name));
- ndb_index.addColumnName(field->field_name);
+ if (ndb_index.addColumnName(field->field_name))
+ {
+ DBUG_RETURN(my_errno= errno);
+ }
}
if (dict->createIndex(ndb_index, *m_table))
@@ -5554,7 +5590,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
}
// Change current database to that of target table
set_dbname(to);
- ndb->setDatabaseName(m_dbname);
+ if (ndb->setDatabaseName(m_dbname))
+ {
+ ERR_RETURN(ndb->getNdbError());
+ }
NdbDictionary::Table new_tab= *orig_tab;
new_tab.setName(new_tabname);
@@ -6128,7 +6167,10 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked)
if (!res)
{
Ndb *ndb= get_ndb();
- ndb->setDatabaseName(m_dbname);
+ if (ndb->setDatabaseName(m_dbname))
+ {
+ ERR_RETURN(ndb->getNdbError());
+ }
struct Ndb_statistics stat;
res= ndb_get_table_statistics(NULL, FALSE, ndb, m_table, &stat);
stats.mean_rec_length= stat.row_size;
@@ -6195,6 +6237,11 @@ Thd_ndb* ha_ndbcluster::seize_thd_ndb()
DBUG_ENTER("seize_thd_ndb");
thd_ndb= new Thd_ndb();
+ if (thd_ndb == NULL)
+ {
+ my_errno= HA_ERR_OUT_OF_MEM;
+ return NULL;
+ }
if (thd_ndb->ndb->init(max_transactions) != 0)
{
ERR_PRINT(thd_ndb->ndb->getNdbError());
@@ -6247,7 +6294,10 @@ int ha_ndbcluster::check_ndb_connection(THD* thd)
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION);
- ndb->setDatabaseName(m_dbname);
+ if (ndb->setDatabaseName(m_dbname))
+ {
+ ERR_RETURN(ndb->getNdbError());
+ }
DBUG_RETURN(0);
}
@@ -6285,7 +6335,10 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION);
- ndb->setDatabaseName(db);
+ if (ndb->setDatabaseName(db))
+ {
+ ERR_RETURN(ndb->getNdbError());
+ }
NDBDICT* dict= ndb->getDictionary();
build_table_filename(key, sizeof(key), db, name, "", 0);
/* ndb_share reference temporary */
@@ -6386,7 +6439,6 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(HA_ERR_NO_CONNECTION);
-
NDBDICT* dict= ndb->getDictionary();
NdbDictionary::Dictionary::List list;
if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0)
@@ -6456,8 +6508,10 @@ int ndbcluster_drop_database_impl(const char *path)
char full_path[FN_REFLEN];
char *tmp= full_path +
build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0);
-
- ndb->setDatabaseName(dbname);
+ if (ndb->setDatabaseName(dbname))
+ {
+ ERR_RETURN(ndb->getNdbError());
+ }
List_iterator_fast<char> it(drop_list);
while ((tabname=it++))
{
@@ -6948,6 +7002,7 @@ static int ndbcluster_init(void *p)
{
DBUG_PRINT("error",("Ndb_cluster_connection(%s)",
opt_ndbcluster_connectstring));
+ my_errno= HA_ERR_OUT_OF_MEM;
goto ndbcluster_init_error;
}
{
@@ -6962,6 +7017,7 @@ static int ndbcluster_init(void *p)
if ( (g_ndb= new Ndb(g_ndb_cluster_connection, "sys")) == 0 )
{
DBUG_PRINT("error", ("failed to create global ndb object"));
+ my_errno= HA_ERR_OUT_OF_MEM;
goto ndbcluster_init_error;
}
if (g_ndb->init() != 0)
@@ -7454,7 +7510,10 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
Ndb *ndb;
if (!(ndb= check_ndb_in_thd(thd)))
DBUG_RETURN(1);
- ndb->setDatabaseName(dbname);
+ if (ndb->setDatabaseName(dbname))
+ {
+ ERR_RETURN(ndb->getNdbError());
+ }
uint lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex);
@@ -8670,7 +8729,10 @@ ha_ndbcluster::update_table_comment(
return((char*)comment);
}
- ndb->setDatabaseName(m_dbname);
+ if (ndb->setDatabaseName(m_dbname))
+ {
+ return((char*)comment);
+ }
const NDBTAB* tab= m_table;
DBUG_ASSERT(tab != NULL);
@@ -8679,6 +8741,8 @@ ha_ndbcluster::update_table_comment(
const unsigned fmt_len_plus_extra= length + strlen(fmt);
if ((str= my_malloc(fmt_len_plus_extra, MYF(0))) == NULL)
{
+ sql_print_error("ha_ndbcluster::update_table_comment: "
+ "my_malloc(%u) failed", (unsigned int)fmt_len_plus_extra);
return (char*)comment;
}
@@ -8705,8 +8769,12 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
pthread_mutex_lock(&LOCK_ndb_util_thread);
thd= new THD; /* note that contructor of THD uses DBUG_ */
+ if (thd == NULL)
+ {
+ my_errno= HA_ERR_OUT_OF_MEM;
+ DBUG_RETURN(NULL);
+ }
THD_CHECK_SENTRY(thd);
-
pthread_detach_this_thread();
ndb_util_thread= pthread_self();
@@ -8879,11 +8947,13 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
pthread_mutex_lock(&share->mutex);
lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex);
-
{
/* Contact NDB to get commit count for table */
Ndb* ndb= thd_ndb->ndb;
- ndb->setDatabaseName(share->db);
+ if (ndb->setDatabaseName(share->db))
+ {
+ goto loop_next;
+ }
Ndb_table_guard ndbtab_g(ndb->getDictionary(), share->table_name);
if (ndbtab_g.get_table() &&
ndb_get_table_statistics(NULL, FALSE, ndb,
@@ -8906,7 +8976,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
stat.commit_count= 0;
}
}
-
+ loop_next:
pthread_mutex_lock(&share->mutex);
if (share->commit_count_lock == lock)
share->commit_count= stat.commit_count;
@@ -8986,6 +9056,11 @@ ha_ndbcluster::cond_push(const COND *cond)
{
DBUG_ENTER("cond_push");
Ndb_cond_stack *ndb_cond = new Ndb_cond_stack();
+ if (ndb_cond == NULL)
+ {
+ my_errno= HA_ERR_OUT_OF_MEM;
+ DBUG_RETURN(NULL);
+ }
DBUG_EXECUTE("where",print_where((COND *)cond, m_tabname););
if (m_cond_stack)
ndb_cond->next= m_cond_stack;
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index 57b7203352f..afc781e762c 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -1006,4 +1006,6 @@ void ndbcluster_print_error(int error, const NdbOperation *error_op);
static const char ndbcluster_hton_name[]= "ndbcluster";
static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1;
-
+extern int ndbcluster_terminating;
+extern int ndb_util_thread_running;
+extern pthread_cond_t COND_ndb_util_ready;
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index 55c31d04e0e..c65c81c088c 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -582,10 +582,30 @@ static int ndbcluster_binlog_end(THD *thd)
ndbcluster_binlog_inited= 0;
#ifdef HAVE_NDB_BINLOG
+ if (ndb_util_thread_running > 0)
+ {
+ /*
+ Wait for util thread to die (as this uses the injector mutex)
+ There is a very small change that ndb_util_thread dies and the
+ following mutex is freed before it's accessed. This shouldn't
+ however be a likely case as the ndbcluster_binlog_end is supposed to
+ be called before ndb_cluster_end().
+ */
+ pthread_mutex_lock(&LOCK_ndb_util_thread);
+ /* Ensure mutex are not freed if ndb_cluster_end is running at same time */
+ ndb_util_thread_running++;
+ ndbcluster_terminating= 1;
+ pthread_cond_signal(&COND_ndb_util_thread);
+ while (ndb_util_thread_running > 1)
+ pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread);
+ ndb_util_thread_running--;
+ pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ }
+
/* wait for injector thread to finish */
ndbcluster_binlog_terminating= 1;
- pthread_cond_signal(&injector_cond);
pthread_mutex_lock(&injector_mutex);
+ pthread_cond_signal(&injector_cond);
while (ndb_binlog_thread_running > 0)
pthread_cond_wait(&injector_cond, &injector_mutex);
pthread_mutex_unlock(&injector_mutex);
diff --git a/sql/handler.cc b/sql/handler.cc
index 617bf9ee378..e0018a66400 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -844,7 +844,7 @@ int ha_rollback_trans(THD *thd, bool all)
the error log; but we don't want users to wonder why they have this
message in the error log, so we don't send it.
*/
- if (is_real_trans && (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) &&
+ if (is_real_trans && thd->no_trans_update.all &&
!thd->slave_thread && thd->killed != THD::KILL_CONNECTION)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARNING_NOT_COMPLETE_ROLLBACK,
diff --git a/sql/item.cc b/sql/item.cc
index 613b72ad05e..bd5e0ae1a8f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -267,7 +267,7 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value)
my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
{
my_decimal_set_zero(decimal_value);
@@ -280,7 +280,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_time(&ltime))
{
my_decimal_set_zero(decimal_value);
@@ -315,7 +315,7 @@ longlong Item::val_int_from_decimal()
int Item::save_time_in_field(Field *field)
{
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_time(&ltime))
return set_field_to_null(field);
field->set_notnull();
@@ -325,7 +325,7 @@ int Item::save_time_in_field(Field *field)
int Item::save_date_in_field(Field *field)
{
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
return set_field_to_null(field);
field->set_notnull();
@@ -853,22 +853,40 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const
/*
- Get the value of the function as a TIME structure.
+ Get the value of the function as a MYSQL_TIME structure.
As a extra convenience the time structure is reset on error!
*/
-bool Item::get_date(TIME *ltime,uint fuzzydate)
+bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
- char buff[40];
- String tmp(buff,sizeof(buff), &my_charset_bin),*res;
- if (!(res=val_str(&tmp)) ||
- str_to_datetime_with_warn(res->ptr(), res->length(),
- ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
+ if (result_type() == STRING_RESULT)
{
- bzero((char*) ltime,sizeof(*ltime));
- return 1;
+ char buff[40];
+ String tmp(buff,sizeof(buff), &my_charset_bin),*res;
+ if (!(res=val_str(&tmp)) ||
+ str_to_datetime_with_warn(res->ptr(), res->length(),
+ ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
+ goto err;
+ }
+ 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;
+ }
}
return 0;
+
+err:
+ bzero((char*) ltime,sizeof(*ltime));
+ return 1;
}
/*
@@ -876,7 +894,7 @@ bool Item::get_date(TIME *ltime,uint fuzzydate)
As a extra convenience the time structure is reset on error!
*/
-bool Item::get_time(TIME *ltime)
+bool Item::get_time(MYSQL_TIME *ltime)
{
char buff[40];
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
@@ -1644,7 +1662,7 @@ void Item_ident_for_show::make_field(Send_field *tmp_field)
Item_field::Item_field(Field *f)
:Item_ident(0, NullS, *f->table_name, f->field_name),
item_equal(0), no_const_subst(0),
- have_privileges(0), any_privileges(0), fixed_as_field(0)
+ have_privileges(0), any_privileges(0)
{
set_field(f);
/*
@@ -1659,7 +1677,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
Field *f)
:Item_ident(context_arg, f->table->s->db.str, *f->table_name, f->field_name),
item_equal(0), no_const_subst(0),
- have_privileges(0), any_privileges(0), fixed_as_field(0)
+ have_privileges(0), any_privileges(0)
{
/*
We always need to provide Item_field with a fully qualified field
@@ -1698,7 +1716,7 @@ Item_field::Item_field(Name_resolution_context *context_arg,
const char *field_name_arg)
:Item_ident(context_arg, db_arg,table_name_arg,field_name_arg),
field(0), result_field(0), item_equal(0), no_const_subst(0),
- have_privileges(0), any_privileges(0), fixed_as_field(0)
+ have_privileges(0), any_privileges(0)
{
SELECT_LEX *select= current_thd->lex->current_select;
collation.set(DERIVATION_IMPLICIT);
@@ -1714,8 +1732,7 @@ Item_field::Item_field(THD *thd, Item_field *item)
item_equal(item->item_equal),
no_const_subst(item->no_const_subst),
have_privileges(item->have_privileges),
- any_privileges(item->any_privileges),
- fixed_as_field(item->fixed_as_field)
+ any_privileges(item->any_privileges)
{
collation.set(DERIVATION_IMPLICIT);
}
@@ -1873,7 +1890,7 @@ String *Item_field::str_result(String *str)
return result_field->val_str(str,&str_value);
}
-bool Item_field::get_date(TIME *ltime,uint fuzzydate)
+bool Item_field::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
{
@@ -1883,7 +1900,7 @@ bool Item_field::get_date(TIME *ltime,uint fuzzydate)
return 0;
}
-bool Item_field::get_date_result(TIME *ltime,uint fuzzydate)
+bool Item_field::get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
{
if ((null_value=result_field->is_null()) ||
result_field->get_date(ltime,fuzzydate))
@@ -1894,7 +1911,7 @@ bool Item_field::get_date_result(TIME *ltime,uint fuzzydate)
return 0;
}
-bool Item_field::get_time(TIME *ltime)
+bool Item_field::get_time(MYSQL_TIME *ltime)
{
if ((null_value=field->is_null()) || field->get_time(ltime))
{
@@ -2421,7 +2438,7 @@ void Item_param::set_decimal(const char *str, ulong length)
/*
- Set parameter value from TIME value.
+ Set parameter value from MYSQL_TIME value.
SYNOPSIS
set_time()
@@ -2435,7 +2452,7 @@ void Item_param::set_decimal(const char *str, ulong length)
the fact that even wrong value sent over binary protocol fits into
MAX_DATE_STRING_REP_LENGTH buffer.
*/
-void Item_param::set_time(TIME *tm, timestamp_type time_type,
+void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
uint32 max_length_arg)
{
DBUG_ENTER("Item_param::set_time");
@@ -2450,7 +2467,8 @@ void Item_param::set_time(TIME *tm, timestamp_type time_type,
{
char buff[MAX_DATE_STRING_REP_LENGTH];
uint length= my_TIME_to_str(&value.time, buff);
- make_truncated_value_warning(current_thd, buff, length, time_type, 0);
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ buff, length, time_type, 0);
set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR);
}
@@ -2652,7 +2670,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
}
-bool Item_param::get_time(TIME *res)
+bool Item_param::get_time(MYSQL_TIME *res)
{
if (state == TIME_VALUE)
{
@@ -2667,7 +2685,7 @@ bool Item_param::get_time(TIME *res)
}
-bool Item_param::get_date(TIME *res, uint fuzzydate)
+bool Item_param::get_date(MYSQL_TIME *res, uint fuzzydate)
{
if (state == TIME_VALUE)
{
@@ -3093,7 +3111,7 @@ String* Item_ref_null_helper::val_str(String* s)
}
-bool Item_ref_null_helper::get_date(TIME *ltime, uint fuzzydate)
+bool Item_ref_null_helper::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate));
}
@@ -3483,6 +3501,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
Item **ref= (Item **) not_found_item;
SELECT_LEX *current_sel= (SELECT_LEX *) thd->lex->current_select;
Name_resolution_context *outer_context= 0;
+ SELECT_LEX *select= 0;
/* Currently derived tables cannot be correlated */
if (current_sel->master_unit()->first_select()->linkage !=
DERIVED_TABLE_TYPE)
@@ -3491,7 +3510,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
outer_context;
outer_context= outer_context->outer_context)
{
- SELECT_LEX *select= outer_context->select_lex;
+ select= outer_context->select_lex;
Item_subselect *prev_subselect_item=
last_checked_context->select_lex->master_unit()->item;
last_checked_context= outer_context;
@@ -3534,45 +3553,28 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
}
if (*from_field != view_ref_found)
{
-
prev_subselect_item->used_tables_cache|= (*from_field)->table->map;
prev_subselect_item->const_item_cache= 0;
+ set_field(*from_field);
if (!last_checked_context->select_lex->having_fix_field &&
- !fixed_as_field)
+ select->group_list.elements)
{
Item_outer_ref *rf;
- Query_arena *arena= 0, backup;
/*
- Each outer field is replaced for an Item_outer_ref object.
- This is done in order to get correct results when the outer
- select employs a temporary table.
- The original fields are saved in the inner_fields_list of the
- outer select. This list is created by the following reasons:
- 1. We can't add field items to the outer select list directly
- because the outer select hasn't been fully fixed yet.
- 2. We need a location to refer to in the Item_ref object
- so the inner_fields_list is used as such temporary
- reference storage.
- The new Item_outer_ref object replaces the original field and is
- also saved in the inner_refs_list of the outer select. Here
- it is only created. It can be fixed only after the original
- field has been fixed and this is done in the fix_inner_refs()
- function.
+ If an outer field is resolved in a grouping select then it
+ is replaced for an Item_outer_ref object. Otherwise an
+ Item_field object is used.
+ The new Item_outer_ref object is saved in the inner_refs_list of
+ the outer select. Here it is only created. It can be fixed only
+ after the original field has been fixed and this is done in the
+ fix_inner_refs() function.
*/
- set_field(*from_field);
- arena= thd->activate_stmt_arena_if_needed(&backup);
- rf= new Item_outer_ref(context, this);
- if (!rf)
- {
- if (arena)
- thd->restore_active_arena(arena, &backup);
+ ;
+ if (!(rf= new Item_outer_ref(context, this)))
return -1;
- }
- *reference= rf;
+ thd->change_item_tree(reference, rf);
select->inner_refs_list.push_back(rf);
- if (arena)
- thd->restore_active_arena(arena, &backup);
- fixed_as_field= 1;
+ rf->in_sum_func= thd->lex->in_sum_func;
}
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level ==
@@ -3678,11 +3680,20 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
rf= (place == IN_HAVING ?
new Item_ref(context, ref, (char*) table_name,
(char*) field_name, alias_name_used) :
+ (!select->group_list.elements ?
new Item_direct_ref(context, ref, (char*) table_name,
- (char*) field_name, alias_name_used));
+ (char*) field_name, alias_name_used) :
+ new Item_outer_ref(context, ref, (char*) table_name,
+ (char*) field_name, alias_name_used)));
*ref= save;
if (!rf)
return -1;
+
+ if (place != IN_HAVING && select->group_list.elements)
+ {
+ outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf);
+ ((Item_outer_ref*)rf)->in_sum_func= thd->lex->in_sum_func;
+ }
thd->change_item_tree(reference, rf);
/*
rf is Item_ref => never substitute other items (in this case)
@@ -4931,7 +4942,7 @@ bool Item::send(Protocol *protocol, String *buffer)
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIMESTAMP:
{
- TIME tm;
+ MYSQL_TIME tm;
get_date(&tm, TIME_FUZZY_DATE);
if (!null_value)
{
@@ -4944,7 +4955,7 @@ bool Item::send(Protocol *protocol, String *buffer)
}
case MYSQL_TYPE_TIME:
{
- TIME tm;
+ MYSQL_TIME tm;
get_time(&tm);
if (!null_value)
result= protocol->store_time(&tm);
@@ -5496,7 +5507,7 @@ bool Item_ref::is_null()
}
-bool Item_ref::get_date(TIME *ltime,uint fuzzydate)
+bool Item_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
return (null_value=(*ref)->get_date_result(ltime,fuzzydate));
}
@@ -5595,7 +5606,7 @@ bool Item_direct_ref::is_null()
}
-bool Item_direct_ref::get_date(TIME *ltime,uint fuzzydate)
+bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
return (null_value=(*ref)->get_date(ltime,fuzzydate));
}
@@ -5640,16 +5651,19 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
bool Item_outer_ref::fix_fields(THD *thd, Item **reference)
{
- DBUG_ASSERT(*ref);
- /* outer_field->check_cols() will be made in Item_direct_ref::fix_fields */
- outer_field->fixed_as_field= 1;
- if (!outer_field->fixed &&
- (outer_field->fix_fields(thd, reference)))
+ bool err;
+ /* outer_ref->check_cols() will be made in Item_direct_ref::fix_fields */
+ if ((*ref) && !(*ref)->fixed && ((*ref)->fix_fields(thd, reference)))
return TRUE;
- table_name= outer_field->table_name;
- return Item_direct_ref::fix_fields(thd, reference);
+ err= Item_direct_ref::fix_fields(thd, reference);
+ if (!outer_ref)
+ outer_ref= *ref;
+ if ((*ref)->type() == Item::FIELD_ITEM)
+ table_name= ((Item_field*)outer_ref)->table_name;
+ return err;
}
+
/*
Compare two view column references for equality.
diff --git a/sql/item.h b/sql/item.h
index 429a1d33041..3d20aaf66cd 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -730,9 +730,9 @@ public:
/* Called for items that really have to be split */
void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
Item **ref, bool skip_registered);
- virtual bool get_date(TIME *ltime,uint fuzzydate);
- virtual bool get_time(TIME *ltime);
- virtual bool get_date_result(TIME *ltime,uint fuzzydate)
+ virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ virtual bool get_time(MYSQL_TIME *ltime);
+ virtual bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
{ return get_date(ltime,fuzzydate); }
/*
The method allows to determine nullness of a complex expression
@@ -1316,7 +1316,6 @@ public:
uint have_privileges;
/* field need any privileges (for VIEW creation) */
bool any_privileges;
- bool fixed_as_field;
Item_field(Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg,
const char *field_name_arg);
@@ -1372,9 +1371,9 @@ public:
}
Field *get_tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) { return result_field; }
- bool get_date(TIME *ltime,uint fuzzydate);
- bool get_date_result(TIME *ltime,uint fuzzydate);
- bool get_time(TIME *ltime);
+ 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);
@@ -1498,7 +1497,7 @@ public:
*/
CHARSET_INFO *final_character_set_of_str_value;
} cs_info;
- TIME time;
+ MYSQL_TIME time;
} value;
/* Cached values for virtual methods to save us one switch. */
@@ -1530,8 +1529,8 @@ public:
longlong val_int();
my_decimal *val_decimal(my_decimal*);
String *val_str(String*);
- bool get_time(TIME *tm);
- bool get_date(TIME *tm, uint fuzzydate);
+ bool get_time(MYSQL_TIME *tm);
+ bool get_date(MYSQL_TIME *tm, uint fuzzydate);
int save_in_field(Field *field, bool no_conversions);
void set_null();
@@ -1540,7 +1539,7 @@ public:
void set_decimal(const char *str, ulong length);
bool set_str(const char *str, ulong length);
bool set_longdata(const char *str, ulong length);
- void set_time(TIME *tm, timestamp_type type, uint32 max_length_arg);
+ void set_time(MYSQL_TIME *tm, timestamp_type type, uint32 max_length_arg);
bool set_from_user_var(THD *thd, const user_var_entry *entry);
void reset();
/*
@@ -1979,7 +1978,7 @@ public:
bool val_bool();
String *val_str(String* tmp);
bool is_null();
- bool get_date(TIME *ltime,uint fuzzydate);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
double val_result();
longlong val_int_result();
String *str_result(String* tmp);
@@ -2056,7 +2055,7 @@ public:
my_decimal *val_decimal(my_decimal *);
bool val_bool();
bool is_null();
- bool get_date(TIME *ltime,uint fuzzydate);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
virtual Ref_Type ref_type() { return DIRECT_REF; }
};
@@ -2081,30 +2080,49 @@ public:
};
+/*
+ Class for outer fields.
+ An object of this class is created when the select where the outer field was
+ resolved is a grouping one. After it has been fixed the ref field will point
+ to either an Item_ref or an Item_direct_ref object which will be used to
+ access the field.
+ See also comments for the fix_inner_refs() and the
+ Item_field::fix_outer_field() functions.
+*/
+
+class Item_sum;
class Item_outer_ref :public Item_direct_ref
{
public:
- Item_field *outer_field;
+ Item *outer_ref;
+ /* The aggregate function under which this outer ref is used, if any. */
+ Item_sum *in_sum_func;
+ /*
+ TRUE <=> that the outer_ref is already present in the select list
+ of the outer select.
+ */
+ bool found_in_select_list;
Item_outer_ref(Name_resolution_context *context_arg,
Item_field *outer_field_arg)
:Item_direct_ref(context_arg, 0, outer_field_arg->table_name,
- outer_field_arg->field_name),
- outer_field(outer_field_arg)
+ outer_field_arg->field_name),
+ outer_ref(outer_field_arg), in_sum_func(0),
+ found_in_select_list(0)
{
- ref= (Item**)&outer_field;
+ ref= &outer_ref;
set_properties();
fixed= 0;
}
- void cleanup()
- {
- ref= (Item**)&outer_field;
- fixed= 0;
- Item_direct_ref::cleanup();
- outer_field->cleanup();
- }
+ Item_outer_ref(Name_resolution_context *context_arg, Item **item,
+ const char *table_name_arg, const char *field_name_arg,
+ bool alias_name_used_arg)
+ :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg,
+ alias_name_used_arg),
+ outer_ref(0), in_sum_func(0), found_in_select_list(1)
+ {}
void save_in_result_field(bool no_conversions)
{
- outer_field->save_org_in_field(result_field);
+ outer_ref->save_org_in_field(result_field);
}
bool fix_fields(THD *, Item **);
table_map used_tables() const
@@ -2142,7 +2160,7 @@ public:
String* val_str(String* s);
my_decimal *val_decimal(my_decimal *);
bool val_bool();
- bool get_date(TIME *ltime, uint fuzzydate);
+ bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
void print(String *str);
/*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 36326b46be6..862185e6fce 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -69,26 +69,80 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
/*
+ Compare row signature of two expressions
+
+ SYNOPSIS:
+ cmp_row_type()
+ item1 the first expression
+ item2 the second expression
+
+ DESCRIPTION
+ The function checks that two expressions have compatible row signatures
+ i.e. that the number of columns they return are the same and that if they
+ are both row expressions then each component from the first expression has
+ a row signature compatible with the signature of the corresponding component
+ of the second expression.
+
+ RETURN VALUES
+ 1 type incompatibility has been detected
+ 0 otherwise
+*/
+
+static int cmp_row_type(Item* item1, Item* item2)
+{
+ uint n= item1->cols();
+ if (item2->check_cols(n))
+ return 1;
+ for (uint i=0; i<n; i++)
+ {
+ if (item2->element_index(i)->check_cols(item1->element_index(i)->cols()) ||
+ (item1->element_index(i)->result_type() == ROW_RESULT &&
+ cmp_row_type(item1->element_index(i), item2->element_index(i))))
+ return 1;
+ }
+ return 0;
+}
+
+
+/*
Aggregates result types from the array of items.
- SYNOPSIS
+ SYNOPSIS:
agg_cmp_type()
- items array of items to aggregate the type from
- nitems number of items in the array
+ type [out] the aggregated type
+ items array of items to aggregate the type from
+ nitems number of items in the array
DESCRIPTION
This function aggregates result types from the array of items. Found type
supposed to be used later for comparison of values of these items.
Aggregation itself is performed by the item_cmp_type() function.
+ The function also checks compatibility of row signatures for the
+ submitted items (see the spec for the cmp_row_type function).
+
+ RETURN VALUES
+ 1 type incompatibility has been detected
+ 0 otherwise
*/
-static Item_result agg_cmp_type(Item **items, uint nitems)
+static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
{
uint i;
- Item_result type= items[0]->result_type();
+ type[0]= items[0]->result_type();
for (i= 1 ; i < nitems ; i++)
- type= item_cmp_type(type, items[i]->result_type());
- return type;
+ {
+ type[0]= item_cmp_type(type[0], items[i]->result_type());
+ /*
+ When aggregating types of two row expressions we have to check
+ that they have the same cardinality and that each component
+ of the first row expression has a compatible row signature with
+ the signature of the corresponding component of the second row
+ expression.
+ */
+ if (type[0] == ROW_RESULT && cmp_row_type(items[0], items[i]))
+ return 1; // error found: invalid usage of rows
+ }
+ return 0;
}
@@ -105,7 +159,8 @@ static Item_result agg_cmp_type(Item **items, uint nitems)
item in the list with each of the remaining items in the 'items' array.
RETURN
- Bitmap of collected types
+ 0 - if row type incompatibility has been detected (see cmp_row_type)
+ Bitmap of collected types - otherwise
*/
static uint collect_cmp_types(Item **items, uint nitems)
@@ -116,12 +171,17 @@ static uint collect_cmp_types(Item **items, uint nitems)
DBUG_ASSERT(nitems > 1);
found_types= 0;
for (i= 1; i < nitems ; i++)
+ {
+ if ((left_result == ROW_RESULT ||
+ items[i]->result_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());
+ }
return found_types;
}
-
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
const char *fname)
{
@@ -293,6 +353,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
{
TABLE *table= field->table;
ulong orig_sql_mode= thd->variables.sql_mode;
+ enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
my_bitmap_map *old_write_map;
my_bitmap_map *old_read_map;
@@ -306,6 +367,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
}
/* For comparison purposes allow invalid dates like 2000-01-32 */
thd->variables.sql_mode|= MODE_INVALID_DATES;
+ thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
{
Item *tmp= new Item_int_with_ref(field->val_int(), *item,
@@ -315,6 +377,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
result= 1; // Item was replaced
}
thd->variables.sql_mode= orig_sql_mode;
+ thd->count_cuted_fields= orig_count_cuted_fields;
if (table)
{
dbug_tmp_restore_column_map(table->write_set, old_write_map);
@@ -1355,7 +1418,8 @@ void Item_func_between::fix_length_and_dec()
*/
if (!args[0] || !args[1] || !args[2])
return;
- cmp_type= agg_cmp_type(args, 3);
+ if ( agg_cmp_type(&cmp_type, args, 3))
+ return;
if (cmp_type == STRING_RESULT &&
agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV, 1))
return;
@@ -2044,7 +2108,8 @@ void Item_func_case::fix_length_and_dec()
for (nagg= 0; nagg < ncases/2 ; nagg++)
agg[nagg+1]= args[nagg*2];
nagg++;
- found_types= collect_cmp_types(agg, nagg);
+ if (!(found_types= collect_cmp_types(agg, nagg)))
+ return;
for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
{
@@ -2422,7 +2487,7 @@ byte *in_row::get_value(Item *item)
void in_row::set(uint pos, Item *item)
{
DBUG_ENTER("in_row::set");
- DBUG_PRINT("enter", ("pos %u item 0x%lx", pos, (ulong) item));
+ DBUG_PRINT("enter", ("pos: %u item: 0x%lx", pos, (ulong) item));
((cmp_item_row*) base)[pos].store_value_by_template(&tmp, item);
DBUG_VOID_RETURN;
}
@@ -2748,7 +2813,8 @@ void Item_func_in::fix_length_and_dec()
uint type_cnt= 0, i;
Item_result cmp_type= STRING_RESULT;
left_result_type= args[0]->result_type();
- found_types= collect_cmp_types(args, arg_count);
+ if (!(found_types= collect_cmp_types(args, arg_count)))
+ return;
for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++)
{
diff --git a/sql/item_func.h b/sql/item_func.h
index 610b47d4fca..28f11e27306 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -147,11 +147,11 @@ public:
void count_only_length();
void count_real_length();
void count_decimal_length();
- inline bool get_arg0_date(TIME *ltime, uint fuzzy_date)
+ inline bool get_arg0_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
return (null_value=args[0]->get_date(ltime, fuzzy_date));
}
- inline bool get_arg0_time(TIME *ltime)
+ inline bool get_arg0_time(MYSQL_TIME *ltime)
{
return (null_value=args[0]->get_time(ltime));
}
@@ -1443,7 +1443,7 @@ private:
bool execute();
bool execute_impl(THD *thd);
bool init_result_field(THD *thd);
-
+
public:
Item_func_sp(Name_resolution_context *context_arg, sp_name *name);
@@ -1454,6 +1454,8 @@ public:
virtual ~Item_func_sp()
{}
+ table_map used_tables() const { return RAND_TABLE_BIT; }
+
void cleanup();
const char *func_name() const;
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 7636deab782..4d6ca2a9b3e 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -46,7 +46,7 @@
the microseconds twice.
*/
-static bool make_datetime(date_time_format_types format, TIME *ltime,
+static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime,
String *str)
{
char *buff;
@@ -95,7 +95,7 @@ static bool make_datetime(date_time_format_types format, TIME *ltime,
/*
- Wrapper over make_datetime() with validation of the input TIME value
+ Wrapper over make_datetime() with validation of the input MYSQL_TIME value
NOTE
see make_datetime() for more information
@@ -105,7 +105,7 @@ static bool make_datetime(date_time_format_types format, TIME *ltime,
0 otherwise
*/
-static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime,
+static bool make_datetime_with_warn(date_time_format_types format, MYSQL_TIME *ltime,
String *str)
{
int warning= 0;
@@ -117,14 +117,15 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime,
if (!warning)
return 0;
- make_truncated_value_warning(current_thd, str->ptr(), str->length(),
+ 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 TIME value
+ Wrapper over make_time() with validation of the input MYSQL_TIME value
NOTE
see make_time() for more info
@@ -135,7 +136,7 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime,
*/
static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
- TIME *l_time, String *str)
+ MYSQL_TIME *l_time, String *str)
{
int warning= 0;
make_time(format, l_time, str);
@@ -143,7 +144,8 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
return 1;
if (warning)
{
- make_truncated_value_warning(current_thd, str->ptr(), str->length(),
+ 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);
}
@@ -153,16 +155,16 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
/*
- Convert seconds to TIME value with overflow checking
+ 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 TIME value
+ ltime output MYSQL_TIME value
DESCRIPTION
- If the 'seconds' argument is inside TIME data range, convert it to a
+ 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.
@@ -172,7 +174,7 @@ static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
0 otherwise
*/
-static bool sec_to_time(longlong seconds, bool unsigned_flag, TIME *ltime)
+static bool sec_to_time(longlong seconds, bool unsigned_flag, MYSQL_TIME *ltime)
{
uint sec;
@@ -205,7 +207,8 @@ overflow:
char buf[22];
int len= (int)(longlong10_to_str(seconds, buf, unsigned_flag ? 10 : -10)
- buf);
- make_truncated_value_warning(current_thd, buf, len, MYSQL_TIMESTAMP_TIME,
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ buf, len, MYSQL_TIMESTAMP_TIME,
NullS);
return 1;
@@ -224,7 +227,7 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0,
{(char *)"%H:%i:%S", 8}};
/*
- Extract datetime value to TIME struct from string value
+ Extract datetime value to MYSQL_TIME struct from string value
according to format string.
SYNOPSIS
@@ -257,7 +260,7 @@ static DATE_TIME_FORMAT time_24hrs_format= {{0}, '\0', 0,
*/
static bool extract_date_time(DATE_TIME_FORMAT *format,
- const char *val, uint length, TIME *l_time,
+ const char *val, uint length, MYSQL_TIME *l_time,
timestamp_type cached_timestamp_type,
const char **sub_pattern_end,
const char *date_time_type)
@@ -305,13 +308,15 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
case 'Y':
tmp= (char*) val + min(4, val_len);
l_time->year= (int) my_strtoll10(val, &tmp, &error);
+ if ((int) (tmp-val) <= 2)
+ l_time->year= year_2000_handling(l_time->year);
val= tmp;
break;
case 'y':
tmp= (char*) val + min(2, val_len);
l_time->year= (int) my_strtoll10(val, &tmp, &error);
val= tmp;
- l_time->year+= (l_time->year < YY_PART_YEAR ? 2000 : 1900);
+ l_time->year= year_2000_handling(l_time->year);
break;
/* Month */
@@ -514,7 +519,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
if (yearday > 0)
{
- uint days= calc_daynr(l_time->year,1,1) + yearday - 1;
+ uint days;
+ days= calc_daynr(l_time->year,1,1) + yearday - 1;
if (days <= 0 || days > MAX_DAY_NUMBER)
goto err;
get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day);
@@ -576,7 +582,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
{
if (!my_isspace(&my_charset_latin1,*val))
{
- make_truncated_value_warning(current_thd, val_begin, length,
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ val_begin, length,
cached_timestamp_type, NullS);
break;
}
@@ -600,7 +607,7 @@ err:
Create a formated date/time value in a string
*/
-bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
+bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
timestamp_type type, String *str)
{
char intbuff[15];
@@ -921,7 +928,7 @@ longlong Item_func_period_diff::val_int()
longlong Item_func_to_days::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day);
@@ -958,7 +965,7 @@ enum_monotonicity_info Item_func_to_days::get_monotonicity_info() const
longlong Item_func_dayofyear::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime,TIME_NO_ZERO_DATE))
return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day) -
@@ -968,7 +975,7 @@ longlong Item_func_dayofyear::val_int()
longlong Item_func_dayofmonth::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.day;
}
@@ -976,7 +983,7 @@ longlong Item_func_dayofmonth::val_int()
longlong Item_func_month::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.month;
}
@@ -1006,7 +1013,7 @@ String* Item_func_monthname::val_str(String* str)
longlong Item_func_quarter::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_FUZZY_DATE))
return 0;
return (longlong) ((ltime.month+2)/3);
@@ -1015,7 +1022,7 @@ longlong Item_func_quarter::val_int()
longlong Item_func_hour::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
(void) get_arg0_time(&ltime);
return ltime.hour;
}
@@ -1023,7 +1030,7 @@ longlong Item_func_hour::val_int()
longlong Item_func_minute::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
(void) get_arg0_time(&ltime);
return ltime.minute;
}
@@ -1032,7 +1039,7 @@ longlong Item_func_minute::val_int()
longlong Item_func_second::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
(void) get_arg0_time(&ltime);
return ltime.second;
}
@@ -1079,7 +1086,7 @@ longlong Item_func_week::val_int()
{
DBUG_ASSERT(fixed == 1);
uint year;
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0;
return (longlong) calc_week(&ltime,
@@ -1092,7 +1099,7 @@ longlong Item_func_yearweek::val_int()
{
DBUG_ASSERT(fixed == 1);
uint year,week;
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0;
week= calc_week(&ltime,
@@ -1105,7 +1112,7 @@ longlong Item_func_yearweek::val_int()
longlong Item_func_weekday::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0;
@@ -1135,7 +1142,7 @@ String* Item_func_dayname::val_str(String* str)
longlong Item_func_year::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.year;
}
@@ -1166,7 +1173,7 @@ enum_monotonicity_info Item_func_year::get_monotonicity_info() const
longlong Item_func_unix_timestamp::val_int()
{
- TIME ltime;
+ MYSQL_TIME ltime;
my_bool not_used;
DBUG_ASSERT(fixed == 1);
@@ -1197,7 +1204,7 @@ longlong Item_func_unix_timestamp::val_int()
longlong Item_func_time_to_sec::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
longlong seconds;
(void) get_arg0_time(&ltime);
seconds=ltime.hour*3600L+ltime.minute*60+ltime.second;
@@ -1369,7 +1376,7 @@ bool get_interval_value(Item *args,interval_type int_type,
String *Item_date::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
return (String *) 0;
if (str->alloc(11))
@@ -1385,19 +1392,19 @@ String *Item_date::val_str(String *str)
longlong Item_date::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
return (longlong) (ltime.year*10000L+ltime.month*100+ltime.day);
}
-bool Item_func_from_days::get_date(TIME *ltime, uint fuzzy_date)
+bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
longlong value=args[0]->val_int();
if ((null_value=args[0]->null_value))
return 1;
- bzero(ltime, sizeof(TIME));
+ bzero(ltime, sizeof(MYSQL_TIME));
get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day);
ltime->time_type= MYSQL_TIMESTAMP_DATE;
return 0;
@@ -1431,10 +1438,10 @@ String *Item_func_curdate::val_str(String *str)
}
/*
- Converts current time in my_time_t to TIME represenatation for local
+ Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole CURDATE function.
*/
-void Item_func_curdate_local::store_now_in_TIME(TIME *now_time)
+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,
@@ -1444,10 +1451,10 @@ void Item_func_curdate_local::store_now_in_TIME(TIME *now_time)
/*
- Converts current time in my_time_t to TIME represenatation for UTC
+ Converts current time in my_time_t to MYSQL_TIME represenatation for UTC
time zone. Defines time zone (UTC) used for whole UTC_DATE function.
*/
-void Item_func_curdate_utc::store_now_in_TIME(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()));
@@ -1458,7 +1465,7 @@ void Item_func_curdate_utc::store_now_in_TIME(TIME *now_time)
}
-bool Item_func_curdate::get_date(TIME *res,
+bool Item_func_curdate::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused)))
{
*res=ltime;
@@ -1476,7 +1483,7 @@ String *Item_func_curtime::val_str(String *str)
void Item_func_curtime::fix_length_and_dec()
{
- TIME ltime;
+ MYSQL_TIME ltime;
decimals= DATETIME_DEC;
collation.set(&my_charset_bin);
@@ -1488,10 +1495,10 @@ void Item_func_curtime::fix_length_and_dec()
/*
- Converts current time in my_time_t to TIME represenatation for local
+ Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole CURTIME function.
*/
-void Item_func_curtime_local::store_now_in_TIME(TIME *now_time)
+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,
@@ -1501,10 +1508,10 @@ void Item_func_curtime_local::store_now_in_TIME(TIME *now_time)
/*
- Converts current time in my_time_t to TIME represenatation for UTC
+ Converts current time in my_time_t to MYSQL_TIME represenatation for UTC
time zone. Defines time zone (UTC) used for whole UTC_TIME function.
*/
-void Item_func_curtime_utc::store_now_in_TIME(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()));
@@ -1537,10 +1544,10 @@ void Item_func_now::fix_length_and_dec()
/*
- Converts current time in my_time_t to TIME represenatation for local
+ Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole NOW function.
*/
-void Item_func_now_local::store_now_in_TIME(TIME *now_time)
+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,
@@ -1550,10 +1557,10 @@ void Item_func_now_local::store_now_in_TIME(TIME *now_time)
/*
- Converts current time in my_time_t to TIME represenatation for UTC
+ Converts current time in my_time_t to MYSQL_TIME represenatation for UTC
time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function.
*/
-void Item_func_now_utc::store_now_in_TIME(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()));
@@ -1564,7 +1571,7 @@ void Item_func_now_utc::store_now_in_TIME(TIME *now_time)
}
-bool Item_func_now::get_date(TIME *res,
+bool Item_func_now::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused)))
{
*res= ltime;
@@ -1581,10 +1588,10 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions)
/*
- Converts current time in my_time_t to TIME represenatation for local
+ Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole SYSDATE function.
*/
-void Item_func_sysdate_local::store_now_in_TIME(TIME *now_time)
+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) time(NULL));
@@ -1626,7 +1633,7 @@ void Item_func_sysdate_local::fix_length_and_dec()
}
-bool Item_func_sysdate_local::get_date(TIME *res,
+bool Item_func_sysdate_local::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused)))
{
store_now_in_TIME(&ltime);
@@ -1647,7 +1654,7 @@ int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions)
String *Item_func_sec_to_time::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
longlong arg_val= args[0]->val_int();
if ((null_value=args[0]->null_value) || str->alloc(19))
@@ -1666,7 +1673,7 @@ String *Item_func_sec_to_time::val_str(String *str)
longlong Item_func_sec_to_time::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
longlong arg_val= args[0]->val_int();
if ((null_value=args[0]->null_value))
@@ -1808,7 +1815,7 @@ uint Item_func_date_format::format_length(const String *format)
String *Item_func_date_format::val_str(String *str)
{
String *format;
- TIME l_time;
+ MYSQL_TIME l_time;
uint size;
DBUG_ASSERT(fixed == 1);
@@ -1871,7 +1878,7 @@ void Item_func_from_unixtime::fix_length_and_dec()
String *Item_func_from_unixtime::val_str(String *str)
{
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
DBUG_ASSERT(fixed == 1);
@@ -1891,7 +1898,7 @@ String *Item_func_from_unixtime::val_str(String *str)
longlong Item_func_from_unixtime::val_int()
{
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
DBUG_ASSERT(fixed == 1);
@@ -1901,7 +1908,7 @@ longlong Item_func_from_unixtime::val_int()
return (longlong) TIME_to_ulonglong_datetime(&time_tmp);
}
-bool Item_func_from_unixtime::get_date(TIME *ltime,
+bool Item_func_from_unixtime::get_date(MYSQL_TIME *ltime,
uint fuzzy_date __attribute__((unused)))
{
ulonglong tmp= (ulonglong)(args[0]->val_int());
@@ -1929,7 +1936,7 @@ void Item_func_convert_tz::fix_length_and_dec()
String *Item_func_convert_tz::val_str(String *str)
{
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
if (get_date(&time_tmp, 0))
return 0;
@@ -1947,7 +1954,7 @@ String *Item_func_convert_tz::val_str(String *str)
longlong Item_func_convert_tz::val_int()
{
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
if (get_date(&time_tmp, 0))
return 0;
@@ -1956,7 +1963,7 @@ longlong Item_func_convert_tz::val_int()
}
-bool Item_func_convert_tz::get_date(TIME *ltime,
+bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime,
uint fuzzy_date __attribute__((unused)))
{
my_time_t my_time_tmp;
@@ -2018,7 +2025,7 @@ void Item_date_add_interval::fix_length_and_dec()
- If first arg is a MYSQL_TYPE_DATE and the interval type uses hours,
minutes or seconds then type is MYSQL_TYPE_DATETIME.
- Otherwise the result is MYSQL_TYPE_STRING
- (This is because you can't know if the string contains a DATE, TIME or
+ (This is because you can't know if the string contains a DATE, MYSQL_TIME or
DATETIME argument)
*/
cached_field_type= MYSQL_TYPE_STRING;
@@ -2038,7 +2045,7 @@ void Item_date_add_interval::fix_length_and_dec()
/* Here arg[1] is a Item_interval object */
-bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
+bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
INTERVAL interval;
@@ -2048,8 +2055,6 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
if (date_sub_interval)
interval.neg = !interval.neg;
- if (ltime->year < YY_MAGIC_BELOW)
- return (null_value=1);
return (null_value= date_add_interval(ltime, int_type, interval));
}
@@ -2058,7 +2063,7 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date)
String *Item_date_add_interval::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
enum date_time_format_types format;
if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
@@ -2082,7 +2087,7 @@ String *Item_date_add_interval::val_str(String *str)
longlong Item_date_add_interval::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
longlong date;
if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
return (longlong) 0;
@@ -2172,7 +2177,7 @@ void Item_extract::fix_length_and_dec()
longlong Item_extract::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
uint year;
ulong week_format;
long neg;
@@ -2425,7 +2430,7 @@ void Item_char_typecast::fix_length_and_dec()
String *Item_datetime_typecast::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
!make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME,
&ltime, str))
@@ -2439,7 +2444,7 @@ String *Item_datetime_typecast::val_str(String *str)
longlong Item_datetime_typecast::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime,1))
{
null_value= 1;
@@ -2450,7 +2455,7 @@ longlong Item_datetime_typecast::val_int()
}
-bool Item_time_typecast::get_time(TIME *ltime)
+bool Item_time_typecast::get_time(MYSQL_TIME *ltime)
{
bool res= get_arg0_time(ltime);
/*
@@ -2466,7 +2471,7 @@ bool Item_time_typecast::get_time(TIME *ltime)
longlong Item_time_typecast::val_int()
{
- TIME ltime;
+ MYSQL_TIME ltime;
if (get_time(&ltime))
{
null_value= 1;
@@ -2478,7 +2483,7 @@ longlong Item_time_typecast::val_int()
String *Item_time_typecast::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (!get_arg0_time(&ltime) &&
!make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY,
@@ -2490,7 +2495,7 @@ String *Item_time_typecast::val_str(String *str)
}
-bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date)
+bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
@@ -2502,7 +2507,7 @@ bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date)
String *Item_date_typecast::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && !str->alloc(11))
{
@@ -2517,7 +2522,7 @@ String *Item_date_typecast::val_str(String *str)
longlong Item_date_typecast::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (args[0]->get_date(&ltime, TIME_FUZZY_DATE))
{
null_value= 1;
@@ -2529,21 +2534,29 @@ longlong Item_date_typecast::val_int()
/*
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
*/
String *Item_func_makedate::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME l_time;
+ MYSQL_TIME l_time;
long daynr= (long) args[1]->val_int();
- long yearnr= (long) args[0]->val_int();
+ long year= (long) args[0]->val_int();
long days;
if (args[0]->null_value || args[1]->null_value ||
- yearnr < 0 || daynr <= 0)
+ year < 0 || daynr <= 0)
goto err;
- days= calc_daynr(yearnr,1,1) + daynr - 1;
+ 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)
{
@@ -2561,19 +2574,32 @@ err:
}
+/*
+ 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);
- TIME l_time;
+ MYSQL_TIME l_time;
long daynr= (long) args[1]->val_int();
- long yearnr= (long) args[0]->val_int();
+ long year= (long) args[0]->val_int();
long days;
if (args[0]->null_value || args[1]->null_value ||
- yearnr < 0 || daynr <= 0)
+ year < 0 || daynr <= 0)
goto err;
- days= calc_daynr(yearnr,1,1) + daynr - 1;
+ 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)
{
@@ -2628,7 +2654,7 @@ void Item_func_add_time::fix_length_and_dec()
String *Item_func_add_time::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME l_time1, l_time2, l_time3;
+ MYSQL_TIME l_time1, l_time2, l_time3;
bool is_time= 0;
long days, microseconds;
longlong seconds;
@@ -2730,7 +2756,7 @@ String *Item_func_timediff::val_str(String *str)
longlong seconds;
long microseconds;
int l_sign= 1;
- TIME l_time1 ,l_time2, l_time3;
+ MYSQL_TIME l_time1 ,l_time2, l_time3;
null_value= 0;
if (args[0]->get_time(&l_time1) ||
@@ -2775,7 +2801,7 @@ null_date:
String *Item_func_maketime::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
bool overflow= 0;
longlong hour= args[0]->val_int();
@@ -2819,7 +2845,8 @@ String *Item_func_maketime::val_str(String *str)
char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
int len = (int)(ptr - buf) +
my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second));
- make_truncated_value_warning(current_thd, buf, len, MYSQL_TIMESTAMP_TIME,
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ buf, len, MYSQL_TIMESTAMP_TIME,
NullS);
}
@@ -2843,7 +2870,7 @@ String *Item_func_maketime::val_str(String *str)
longlong Item_func_microsecond::val_int()
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (!get_arg0_time(&ltime))
return ltime.second_part;
return 0;
@@ -2852,7 +2879,7 @@ longlong Item_func_microsecond::val_int()
longlong Item_func_timestamp_diff::val_int()
{
- TIME ltime1, ltime2;
+ MYSQL_TIME ltime1, ltime2;
longlong seconds;
long microseconds;
long months= 0;
@@ -3158,7 +3185,7 @@ void Item_func_str_to_date::fix_length_and_dec()
}
}
-bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date)
+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];
@@ -3199,7 +3226,7 @@ null_date:
String *Item_func_str_to_date::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- TIME ltime;
+ MYSQL_TIME ltime;
if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE))
return 0;
@@ -3212,7 +3239,7 @@ String *Item_func_str_to_date::val_str(String *str)
}
-bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date)
+bool Item_func_last_day::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
(ltime->month == 0))
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index ea93619e59a..992b79753ca 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -449,9 +449,9 @@ public:
/*
Abstract method that defines which time zone is used for conversion.
Converts time current time in my_time_t representation to broken-down
- TIME representation using UTC-SYSTEM or per-thread time zone.
+ MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
*/
- virtual void store_now_in_TIME(TIME *now_time)=0;
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
bool result_as_longlong() { return TRUE; }
};
@@ -462,7 +462,7 @@ public:
Item_func_curtime_local() :Item_func_curtime() {}
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
const char *func_name() const { return "curtime"; }
- virtual void store_now_in_TIME(TIME *now_time);
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -472,7 +472,7 @@ public:
Item_func_curtime_utc() :Item_func_curtime() {}
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
const char *func_name() const { return "utc_time"; }
- virtual void store_now_in_TIME(TIME *now_time);
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -481,14 +481,14 @@ public:
class Item_func_curdate :public Item_date
{
longlong value;
- TIME ltime;
+ MYSQL_TIME ltime;
public:
Item_func_curdate() :Item_date() {}
longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
String *val_str(String *str);
void fix_length_and_dec();
- bool get_date(TIME *res, uint fuzzy_date);
- virtual void store_now_in_TIME(TIME *now_time)=0;
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
};
@@ -497,7 +497,7 @@ class Item_func_curdate_local :public Item_func_curdate
public:
Item_func_curdate_local() :Item_func_curdate() {}
const char *func_name() const { return "curdate"; }
- void store_now_in_TIME(TIME *now_time);
+ void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -506,7 +506,7 @@ class Item_func_curdate_utc :public Item_func_curdate
public:
Item_func_curdate_utc() :Item_func_curdate() {}
const char *func_name() const { return "utc_date"; }
- void store_now_in_TIME(TIME *now_time);
+ void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -518,7 +518,7 @@ protected:
longlong value;
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
uint buff_length;
- TIME ltime;
+ MYSQL_TIME ltime;
public:
Item_func_now() :Item_date_func() {}
Item_func_now(Item *a) :Item_date_func(a) {}
@@ -527,8 +527,8 @@ public:
int save_in_field(Field *to, bool no_conversions);
String *val_str(String *str);
void fix_length_and_dec();
- bool get_date(TIME *res, uint fuzzy_date);
- virtual void store_now_in_TIME(TIME *now_time)=0;
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
};
@@ -538,7 +538,7 @@ public:
Item_func_now_local() :Item_func_now() {}
Item_func_now_local(Item *a) :Item_func_now(a) {}
const char *func_name() const { return "now"; }
- virtual void store_now_in_TIME(TIME *now_time);
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time);
virtual enum Functype functype() const { return NOW_FUNC; }
};
@@ -549,7 +549,7 @@ public:
Item_func_now_utc() :Item_func_now() {}
Item_func_now_utc(Item *a) :Item_func_now(a) {}
const char *func_name() const { return "utc_timestamp"; }
- virtual void store_now_in_TIME(TIME *now_time);
+ virtual void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -564,13 +564,13 @@ public:
Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
bool const_item() const { return 0; }
const char *func_name() const { return "sysdate"; }
- void store_now_in_TIME(TIME *now_time);
+ 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(TIME *res, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void update_used_tables()
{
Item_func_now::update_used_tables();
@@ -584,7 +584,7 @@ class Item_func_from_days :public Item_date
public:
Item_func_from_days(Item *a) :Item_date(a) {}
const char *func_name() const { return "from_days"; }
- bool get_date(TIME *res, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
};
@@ -616,7 +616,7 @@ class Item_func_from_unixtime :public Item_date_func
String *val_str(String *str);
const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec();
- bool get_date(TIME *res, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
};
@@ -652,7 +652,7 @@ class Item_func_convert_tz :public Item_date_func
String *val_str(String *str);
const char *func_name() const { return "convert_tz"; }
void fix_length_and_dec();
- bool get_date(TIME *res, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void cleanup();
};
@@ -695,7 +695,7 @@ public:
void fix_length_and_dec();
enum_field_types field_type() const { return cached_field_type; }
longlong val_int();
- bool get_date(TIME *res, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const;
void print(String *str);
bool check_partition_func_processor(byte *int_arg) {return FALSE;}
@@ -783,7 +783,7 @@ public:
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
const char *func_name() const { return "cast_as_date"; }
String *val_str(String *str);
- bool get_date(TIME *ltime, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
const char *cast_type() const { return "date"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
Field *tmp_table_field(TABLE *table)
@@ -817,7 +817,7 @@ public:
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
const char *func_name() const { return "cast_as_time"; }
String *val_str(String *str);
- bool get_time(TIME *ltime);
+ bool get_time(MYSQL_TIME *ltime);
const char *cast_type() const { return "time"; }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
Field *tmp_table_field(TABLE *table)
@@ -1020,7 +1020,7 @@ public:
:Item_str_func(a, b)
{}
String *val_str(String *str);
- bool get_date(TIME *ltime, uint fuzzy_date);
+ 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();
@@ -1037,5 +1037,5 @@ class Item_func_last_day :public Item_date
public:
Item_func_last_day(Item *a) :Item_date(a) {}
const char *func_name() const { return "last_day"; }
- bool get_date(TIME *res, uint fuzzy_date);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
};
diff --git a/sql/log.cc b/sql/log.cc
index a93ce03d9e9..94c744f3f93 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -575,7 +575,7 @@ bool Log_to_csv_event_handler::
lock_time may be truncated without warning here, if greater than
839 hours (~35 days)
*/
- TIME t;
+ MYSQL_TIME t;
t.neg= 0;
/* fill in query_time field */
@@ -1598,8 +1598,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
table. Such cases should be rare (updating a
non-transactional table inside a transaction...)
*/
- if (unlikely(thd->options & (OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG)))
+ if (unlikely(thd->no_trans_update.all || (thd->options & OPTION_KEEP_LOG)))
{
Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE);
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
@@ -1654,8 +1653,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
non-transactional table. Otherwise, truncate the binlog cache starting
from the SAVEPOINT command.
*/
- if (unlikely(thd->options &
- (OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG)))
+ if (unlikely(thd->no_trans_update.all || (thd->options & OPTION_KEEP_LOG)))
{
int error=
thd->binlog_query(THD::STMT_QUERY_TYPE,
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 511942e9a5d..7b2d271639f 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -191,7 +191,7 @@ int str2my_decimal(uint mask, const char *from, uint length,
}
-my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec)
+my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec)
{
longlong date;
date = (ltime->year*100L + ltime->month)*100L + ltime->day;
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index cefc5ee00fd..eade029677f 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -296,7 +296,7 @@ int string2my_decimal(uint mask, const String *str, my_decimal *d)
}
-my_decimal *date2my_decimal(TIME *ltime, my_decimal *dec);
+my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec);
#endif /*defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) */
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 6ac12b90d9a..3a01ed27f61 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -341,9 +341,6 @@ MY_LOCALE *my_locale_by_number(uint number);
/* The following is used to detect a conflict with DISTINCT */
#define SELECT_ALL (ULL(1) << 24) // SELECT, user, parser
-/* Set if we are updating a non-transaction safe table */
-#define OPTION_STATUS_NO_TRANS_UPDATE (ULL(1) << 25) // THD, intern
-
/* The following can be set when importing tables in a 'wrong order'
to suppress foreign key checks */
#define OPTION_NO_FOREIGN_KEY_CHECKS (ULL(1) << 26) // THD, user, binlog
@@ -839,7 +836,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
char *new_table_name, char *new_table_alias,
bool skip_error);
-bool mysql_change_db(THD *thd,const char *name,bool no_access_check);
+bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
+ bool force_switch);
void mysql_parse(THD *thd,char *inBuf,uint length);
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
bool is_update_query(enum enum_sql_command command);
@@ -1119,7 +1117,7 @@ void init_status_vars();
void free_status_vars();
/* information schema */
-extern LEX_STRING information_schema_name;
+extern LEX_STRING INFORMATION_SCHEMA_NAME;
extern const LEX_STRING partition_keywords[];
LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
const char* str, uint length,
@@ -1137,8 +1135,10 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
bool get_schema_tables_result(JOIN *join,
enum enum_schema_table_state executed_place);
+enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
+
#define is_schema_db(X) \
- !my_strcasecmp(system_charset_info, information_schema_name.str, (X))
+ !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
/* sql_prepare.cc */
@@ -1843,19 +1843,20 @@ 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 TIME *t, my_bool *not_exist);
-bool str_to_time_with_warn(const char *str,uint length,TIME *l_time);
+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);
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
- TIME *l_time, uint flags);
-void localtime_to_TIME(TIME *to, struct tm *from);
-void calc_time_from_sec(TIME *to, long seconds, long microseconds);
+ MYSQL_TIME *l_time, uint 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, const char *str_val,
+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);
-bool date_add_interval(TIME *ltime, interval_type int_type, INTERVAL interval);
-bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign,
+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,
longlong *seconds_out, long *microseconds_out);
extern LEX_STRING interval_type_to_name[];
@@ -1867,15 +1868,15 @@ extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
DATE_TIME_FORMAT *format);
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
timestamp_type type);
-extern bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
+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 TIME *l_time,
+void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str);
-void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time,
+void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str);
-void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time,
+void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
String *str);
-int my_time_compare(TIME *a, TIME *b);
+int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
int test_if_number(char *str,int *res,bool allow_wildcards);
void change_byte(byte *,uint,char,char);
@@ -1895,7 +1896,7 @@ double my_double_round(double value, int dec, bool truncate);
int get_quick_record(SQL_SELECT *select);
int calc_weekday(long daynr,bool sunday_first_day_of_week);
-uint calc_week(TIME *l_time, uint week_behaviour, uint *year);
+uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
void find_date(char *pos,uint *vek,uint flag);
TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end);
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1b322dbea86..b7ea52fbef6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -275,7 +275,11 @@ static TYPELIB tc_heuristic_recover_typelib=
};
static const char *thread_handling_names[]=
-{ "one-thread-per-connection", "no-threads", "pool-of-threads", NullS};
+{ "one-thread-per-connection", "no-threads",
+#if HAVE_POOL_OF_THREADS == 1
+ "pool-of-threads",
+#endif
+ NullS};
TYPELIB thread_handling_typelib=
{
@@ -736,6 +740,8 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
#endif
pthread_handler_t handle_slave(void *arg);
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
+static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
+ const char *option);
static void clean_up(bool print_message);
static int test_if_case_insensitive(const char *dir_name);
@@ -787,7 +793,6 @@ static void close_connections(void)
DBUG_PRINT("info",("Waiting for select thread"));
#ifndef DONT_USE_THR_ALARM
- if (pthread_kill(select_thread, thr_client_alarm))
break; // allready dead
#endif
set_timespec(abstime, 2);
@@ -7469,11 +7474,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_INIT_RPL_ROLE:
{
int role;
- if ((role=find_type(argument, &rpl_role_typelib, 2)) <= 0)
- {
- fprintf(stderr, "Unknown replication role: %s\n", argument);
- exit(1);
- }
+ role= find_type_or_exit(argument, &rpl_role_typelib, opt->name);
rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE;
break;
}
@@ -7529,17 +7530,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BINLOG_FORMAT:
{
int id;
- if ((id= find_type(argument, &binlog_format_typelib, 2)) <= 0)
- {
- fprintf(stderr,
- "Unknown binary log format: '%s' "
- "(should be one of '%s', '%s', '%s')\n",
- argument,
- binlog_format_names[BINLOG_FORMAT_STMT],
- binlog_format_names[BINLOG_FORMAT_ROW],
- binlog_format_names[BINLOG_FORMAT_MIXED]);
- exit(1);
- }
+ id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
break;
}
@@ -7599,13 +7590,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else
{
log_output_str= argument;
- if ((log_output_options=
- find_bit_type(argument, &log_output_typelib)) == ~(ulong) 0)
- {
- fprintf(stderr, "Unknown option to log-output: %s\n", argument);
- exit(1);
- }
- }
+ log_output_options=
+ find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
+ }
break;
}
#endif
@@ -7748,11 +7735,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else
{
int type;
- if ((type=find_type(argument, &delay_key_write_typelib, 2)) <= 0)
- {
- fprintf(stderr,"Unknown delay_key_write type: %s\n",argument);
- exit(1);
- }
+ type= find_type_or_exit(argument, &delay_key_write_typelib, opt->name);
delay_key_write_options= (uint) type-1;
}
break;
@@ -7763,11 +7746,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_TX_ISOLATION:
{
int type;
- if ((type=find_type(argument, &tx_isolation_typelib, 2)) <= 0)
- {
- fprintf(stderr,"Unknown transaction isolation type: %s\n",argument);
- exit(1);
- }
+ type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
global_system_variables.tx_isolation= (type-1);
break;
}
@@ -7808,16 +7787,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case OPT_NDB_DISTRIBUTION:
int id;
- if ((id= find_type(argument, &ndb_distribution_typelib, 2)) <= 0)
- {
- fprintf(stderr,
- "Unknown ndb distribution type: '%s' "
- "(should be '%s' or '%s')\n",
- argument,
- ndb_distribution_names[ND_KEYHASH],
- ndb_distribution_names[ND_LINHASH]);
- exit(1);
- }
+ id= find_type_or_exit(argument, &ndb_distribution_typelib, opt->name);
opt_ndb_distribution_id= (enum ndb_distribution)(id-1);
break;
case OPT_NDB_EXTRA_LOGGING:
@@ -7857,12 +7827,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else
{
myisam_recover_options_str=argument;
- if ((myisam_recover_options=
- find_bit_type(argument, &myisam_recover_typelib)) == ~(ulong) 0)
- {
- fprintf(stderr, "Unknown option to myisam-recover: %s\n",argument);
- exit(1);
- }
+ myisam_recover_options=
+ find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
}
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
break;
@@ -7875,14 +7841,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
myisam_concurrent_insert= 0; /* --skip-concurrent-insert */
break;
case OPT_TC_HEURISTIC_RECOVER:
- {
- if ((tc_heuristic_recover=find_type(argument,
- &tc_heuristic_recover_typelib, 2)) <=0)
- {
- fprintf(stderr, "Unknown option to tc-heuristic-recover: %s\n",argument);
- exit(1);
- }
- }
+ tc_heuristic_recover= find_type_or_exit(argument,
+ &tc_heuristic_recover_typelib,
+ opt->name);
+ break;
case OPT_MYISAM_STATS_METHOD:
{
ulong method_conv;
@@ -7890,11 +7852,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
LINT_INIT(method_conv);
myisam_stats_method_str= argument;
- if ((method=find_type(argument, &myisam_stats_method_typelib, 2)) <= 0)
- {
- fprintf(stderr, "Invalid value of myisam_stats_method: %s.\n", argument);
- exit(1);
- }
+ method= find_type_or_exit(argument, &myisam_stats_method_typelib,
+ opt->name);
switch (method-1) {
case 2:
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
@@ -7913,12 +7872,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_SQL_MODE:
{
sql_mode_str= argument;
- if ((global_system_variables.sql_mode=
- find_bit_type(argument, &sql_mode_typelib)) == ~(ulong) 0)
- {
- fprintf(stderr, "Unknown option to sql-mode: %s\n", argument);
- exit(1);
- }
+ global_system_variables.sql_mode=
+ find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name);
global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
sql_mode);
break;
@@ -7928,16 +7883,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case OPT_THREAD_HANDLING:
{
- if ((global_system_variables.thread_handling=
- find_type(argument, &thread_handling_typelib, 2)) <= 0 ||
- (global_system_variables.thread_handling == SCHEDULER_POOL_OF_THREADS
- && !HAVE_POOL_OF_THREADS))
- {
- /* purecov: begin tested */
- fprintf(stderr,"Unknown/unsupported thread-handling: %s\n",argument);
- exit(1);
- /* purecov: end */
- }
+ global_system_variables.thread_handling=
+ find_type_or_exit(argument, &thread_handling_typelib, opt->name);
break;
}
case OPT_FT_BOOLEAN_SYNTAX:
@@ -8226,6 +8173,30 @@ static void fix_paths(void)
}
+static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
+ const char *option)
+{
+ ulong res;
+
+ const char **ptr;
+
+ if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
+ {
+ ptr= bit_lib->type_names;
+ if (!*x)
+ fprintf(stderr, "No option given to %s\n", option);
+ else
+ fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x);
+ fprintf(stderr, "Alternatives are: '%s'", *ptr);
+ while (*++ptr)
+ fprintf(stderr, ",'%s'", *ptr);
+ fprintf(stderr, "\n");
+ exit(1);
+ }
+ return res;
+}
+
+
/*
Return a bitfield from a string of substrings separated by ','
returns ~(ulong) 0 on error.
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 2156888b8cf..719e2ee0d3c 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -298,8 +298,8 @@ void net_clear(NET *net, my_bool clear_buffer)
{
DBUG_PRINT("info",("skipped %d bytes from file: %s",
count, vio_description(net->vio)));
-#if defined(EXTRA_DEBUG) && (MYSQL_VERSION_ID < 51000)
- fprintf(stderr,"Error: net_clear() skipped %d bytes from file: %s\n",
+#if defined(EXTRA_DEBUG)
+ fprintf(stderr,"Note: net_clear() skipped %d bytes from file: %s\n",
count, vio_description(net->vio));
#endif
}
@@ -818,7 +818,7 @@ my_real_read(NET *net, ulong *complen)
{
my_bool interrupted = vio_should_retry(net->vio);
- DBUG_PRINT("info",("vio_read returned %ld, errno: %d",
+ DBUG_PRINT("info",("vio_read returned %ld errno: %d",
length, vio_errno(net->vio)));
#if !defined(__WIN__) || defined(MYSQL_SERVER)
/*
@@ -903,9 +903,12 @@ my_real_read(NET *net, ulong *complen)
(int) net->buff[net->where_b + 3],
net->pkt_nr));
#ifdef EXTRA_DEBUG
+ fflush(stdout);
fprintf(stderr,"Error: Packets out of order (Found: %d, expected %d)\n",
(int) net->buff[net->where_b + 3],
(uint) (uchar) net->pkt_nr);
+ fflush(stderr);
+ DBUG_ASSERT(0);
#endif
}
len= packet_error;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 5aa3b7b5055..d537fd346f9 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -961,7 +961,7 @@ bool Protocol_text::store(Field *field)
*/
-bool Protocol_text::store(TIME *tm)
+bool Protocol_text::store(MYSQL_TIME *tm)
{
#ifndef DBUG_OFF
DBUG_ASSERT(field_types == 0 ||
@@ -984,7 +984,7 @@ bool Protocol_text::store(TIME *tm)
}
-bool Protocol_text::store_date(TIME *tm)
+bool Protocol_text::store_date(MYSQL_TIME *tm)
{
#ifndef DBUG_OFF
DBUG_ASSERT(field_types == 0 ||
@@ -1003,7 +1003,7 @@ bool Protocol_text::store_date(TIME *tm)
we support 0-6 decimals for time.
*/
-bool Protocol_text::store_time(TIME *tm)
+bool Protocol_text::store_time(MYSQL_TIME *tm)
{
#ifndef DBUG_OFF
DBUG_ASSERT(field_types == 0 ||
@@ -1176,7 +1176,7 @@ bool Protocol_binary::store(Field *field)
}
-bool Protocol_binary::store(TIME *tm)
+bool Protocol_binary::store(MYSQL_TIME *tm)
{
char buff[12],*pos;
uint length;
@@ -1202,7 +1202,7 @@ bool Protocol_binary::store(TIME *tm)
return packet->append(buff, length+1, PACKET_BUFFER_EXTRA_ALLOC);
}
-bool Protocol_binary::store_date(TIME *tm)
+bool Protocol_binary::store_date(MYSQL_TIME *tm)
{
tm->hour= tm->minute= tm->second=0;
tm->second_part= 0;
@@ -1210,7 +1210,7 @@ bool Protocol_binary::store_date(TIME *tm)
}
-bool Protocol_binary::store_time(TIME *tm)
+bool Protocol_binary::store_time(MYSQL_TIME *tm)
{
char buff[13], *pos;
uint length;
diff --git a/sql/protocol.h b/sql/protocol.h
index da49cf769ae..e0672240e0e 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -88,9 +88,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(TIME *time)=0;
- virtual bool store_date(TIME *time)=0;
- virtual bool store_time(TIME *time)=0;
+ virtual bool store(MYSQL_TIME *time)=0;
+ virtual bool store_date(MYSQL_TIME *time)=0;
+ virtual bool store_time(MYSQL_TIME *time)=0;
virtual bool store(Field *field)=0;
#ifdef EMBEDDED_LIBRARY
int begin_dataset();
@@ -127,9 +127,9 @@ public:
virtual bool store(const char *from, uint length, CHARSET_INFO *cs);
virtual bool store(const char *from, uint length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
- virtual bool store(TIME *time);
- virtual bool store_date(TIME *time);
- virtual bool store_time(TIME *time);
+ virtual bool store(MYSQL_TIME *time);
+ virtual bool store_date(MYSQL_TIME *time);
+ virtual bool store_time(MYSQL_TIME *time);
virtual bool store(float nr, uint32 decimals, String *buffer);
virtual bool store(double from, uint32 decimals, String *buffer);
virtual bool store(Field *field);
@@ -162,9 +162,9 @@ public:
virtual bool store(const char *from,uint length, CHARSET_INFO *cs);
virtual bool store(const char *from, uint length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
- virtual bool store(TIME *time);
- virtual bool store_date(TIME *time);
- virtual bool store_time(TIME *time);
+ virtual bool store(MYSQL_TIME *time);
+ virtual bool store_date(MYSQL_TIME *time);
+ virtual bool store_time(MYSQL_TIME *time);
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/set_var.cc b/sql/set_var.cc
index 046705f26b1..325167ff9fa 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -878,7 +878,7 @@ SHOW_VAR init_vars[]= {
#ifdef HAVE_REPLICATION
{"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
#endif
- {"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL},
+ {"log_slow_queries", (char*) &opt_slow_log, SHOW_MY_BOOL},
{sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
{sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
{sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
@@ -3095,16 +3095,15 @@ static bool set_option_autocommit(THD *thd, set_var *var)
if ((org_options & OPTION_NOT_AUTOCOMMIT))
{
/* We changed to auto_commit mode */
- thd->options&= ~(ulonglong) (OPTION_BEGIN |
- OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG);
+ thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
+ thd->no_trans_update.all= FALSE;
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
if (ha_commit(thd))
return 1;
}
else
{
- thd->options&= ~(ulonglong) (OPTION_STATUS_NO_TRANS_UPDATE);
+ thd->no_trans_update.all= FALSE;
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
}
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 0a3672c1dea..f689f663c6b 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -795,8 +795,10 @@ static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi)
else
{
mi->clock_diff_with_master= 0; /* The "most sensible" value */
- sql_print_warning("\"SELECT UNIX_TIMESTAMP()\" failed on master, \
-do not trust column Seconds_Behind_Master of SHOW SLAVE STATUS");
+ sql_print_warning("\"SELECT UNIX_TIMESTAMP()\" failed on master, "
+ "do not trust column Seconds_Behind_Master of SHOW "
+ "SLAVE STATUS. Error: %s (%d)",
+ mysql_error(mysql), mysql_errno(mysql));
}
if (master_res)
mysql_free_result(master_res);
diff --git a/sql/sp.cc b/sql/sp.cc
index a59e3507eac..49b8b304e76 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -391,14 +391,14 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
{
sp_head *sp= newlex.sphead;
- if (dbchanged && (ret= mysql_change_db(thd, old_db.str, 1)))
+ if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE)))
goto end;
delete sp;
ret= SP_PARSE_ERROR;
}
else
{
- if (dbchanged && (ret= mysql_change_db(thd, old_db.str, 1)))
+ if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE)))
goto end;
*sphp= newlex.sphead;
(*sphp)->set_definer(&definer_user_name, &definer_host_name);
@@ -724,7 +724,7 @@ print_field_values(THD *thd, TABLE *table,
switch (used_field->field_type) {
case MYSQL_TYPE_TIMESTAMP:
{
- TIME tmp_time;
+ MYSQL_TIME tmp_time;
bzero((char *)&tmp_time, sizeof(tmp_time));
((Field_timestamp *) used_field->field)->get_time(&tmp_time);
@@ -1861,7 +1861,7 @@ sp_use_new_db(THD *thd, LEX_STRING new_db, LEX_STRING *old_db,
DBUG_RETURN(0);
}
- ret= mysql_change_db(thd, new_db.str, no_access_check);
+ ret= mysql_change_db(thd, &new_db, no_access_check);
*dbchangedp= ret == 0;
DBUG_RETURN(ret);
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index e3138d02ca5..a2ce5111a25 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -349,13 +349,13 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr)
enum_check_fields save_count_cuted_fields= thd->count_cuted_fields;
bool save_abort_on_warning= thd->abort_on_warning;
- bool save_no_trans_update= thd->no_trans_update;
+ bool save_no_trans_update_stmt= thd->no_trans_update.stmt;
thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
thd->abort_on_warning=
thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES);
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
/* Save the value in the field. Convert the value if needed. */
@@ -363,7 +363,7 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr)
thd->count_cuted_fields= save_count_cuted_fields;
thd->abort_on_warning= save_abort_on_warning;
- thd->no_trans_update= save_no_trans_update;
+ thd->no_trans_update.stmt= save_no_trans_update_stmt;
if (thd->net.report_error)
{
@@ -1189,7 +1189,7 @@ sp_head::execute(THD *thd)
(It would generate an error from mysql_change_db() when old_db=="")
*/
if (! thd->killed)
- err_status|= mysql_change_db(thd, old_db.str, 1);
+ err_status|= mysql_change_db(thd, &old_db, TRUE);
}
m_flags&= ~IS_INVOKED;
DBUG_PRINT("info",
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index aaa88071173..ba1ec66fb02 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -4052,6 +4052,26 @@ err2:
}
+static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash)
+{
+ Security_context *sctx= thd->security_ctx;
+
+ for (uint idx= 0; idx < hash->records; ++idx)
+ {
+ GRANT_NAME *item= (GRANT_NAME*) hash_element(hash, idx);
+
+ if (strcmp(item->user, sctx->priv_user) == 0 &&
+ strcmp(item->db, db) == 0 &&
+ compare_hostname(&item->host, sctx->host, sctx->ip))
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
/*
Check if a user has the right to access a database
Access is accepted if he has a grant for any table/routine in the database
@@ -4063,9 +4083,10 @@ bool check_grant_db(THD *thd,const char *db)
Security_context *sctx= thd->security_ctx;
char helping [NAME_LEN+USERNAME_LENGTH+2];
uint len;
- bool error= 1;
+ bool error= TRUE;
len= (uint) (strmov(strmov(helping, sctx->priv_user) + 1, db) - helping) + 1;
+
rw_rdlock(&LOCK_grant);
for (uint idx=0 ; idx < column_priv_hash.records ; idx++)
@@ -4076,11 +4097,17 @@ bool check_grant_db(THD *thd,const char *db)
!memcmp(grant_table->hash_key,helping,len) &&
compare_hostname(&grant_table->host, sctx->host, sctx->ip))
{
- error=0; // Found match
+ error= FALSE; /* Found match. */
break;
}
}
+
+ if (error)
+ error= check_grant_db_routine(thd, db, &proc_priv_hash) &&
+ check_grant_db_routine(thd, db, &func_priv_hash);
+
rw_unlock(&LOCK_grant);
+
return error;
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 8cc54aa3c8c..0f428da1fdb 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4559,14 +4559,35 @@ find_field_in_tables(THD *thd, Item_ident *item,
{
Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length,
item->name, db, table_name, ref,
- check_privileges, allow_rowid,
+ check_privileges,
+ allow_rowid,
&(item->cached_field_index),
register_tree_change,
&actual_table);
if (cur_field)
{
if (cur_field == WRONG_GRANT)
- return (Field*) 0;
+ {
+ if (thd->lex->sql_command != SQLCOM_SHOW_FIELDS)
+ return (Field*) 0;
+
+ thd->clear_error();
+ cur_field= find_field_in_table_ref(thd, cur_table, name, length,
+ item->name, db, table_name, ref,
+ false,
+ allow_rowid,
+ &(item->cached_field_index),
+ register_tree_change,
+ &actual_table);
+ if (cur_field)
+ {
+ Field *nf=new Field_null(NULL,0,Field::NONE,
+ cur_field->field_name,
+ &my_charset_bin);
+ nf->init(cur_table->table);
+ cur_field= nf;
+ }
+ }
/*
Store the original table of the field, which may be different from
@@ -4589,7 +4610,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
report_error == IGNORE_EXCEPT_NON_UNIQUE)
my_error(ER_NON_UNIQ_ERROR, MYF(0),
table_name ? item->full_name() : name, thd->where);
- return (Field*) 0;
+ return (Field*) 0;
}
found= cur_field;
}
@@ -6390,7 +6411,7 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
table= field->table;
if (field == table->next_number_field)
table->auto_increment_field_not_null= TRUE;
- if (value->save_in_field(field, 0) == -1)
+ if (value->save_in_field(field, 0) < 0)
goto err;
}
DBUG_RETURN(thd->net.report_error);
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 89b7a25033f..8d8838d4585 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -377,7 +377,7 @@ inline Query_cache_block * Query_cache_block_table::block()
void Query_cache_block::init(ulong block_length)
{
DBUG_ENTER("Query_cache_block::init");
- DBUG_PRINT("qcache", ("init block 0x%lx length: %lu", (ulong) this,
+ DBUG_PRINT("qcache", ("init block: 0x%lx length: %lu", (ulong) this,
block_length));
length = block_length;
used = 0;
@@ -3685,7 +3685,7 @@ void Query_cache::queries_dump()
Query_cache_query_flags flags;
memcpy(&flags, str+len, QUERY_CACHE_FLAGS_SIZE);
str[len]= 0; // make zero ending DB name
- DBUG_PRINT("qcache", ("F:%u C:%u L:%lu T:'%s' (%u) '%s' '%s'",
+ DBUG_PRINT("qcache", ("F: %u C: %u L: %lu T: '%s' (%u) '%s' '%s'",
flags.client_long_flag,
flags.character_set_client_num,
(ulong)flags.limit,
@@ -4008,7 +4008,7 @@ my_bool Query_cache::check_integrity(bool locked)
} while (block != bins[i].free_blocks);
if (count != bins[i].number)
{
- DBUG_PRINT("error", ("bins[%d].number = %d, but bin have %d blocks",
+ DBUG_PRINT("error", ("bins[%d].number= %d, but bin have %d blocks",
i, bins[i].number, count));
result = 1;
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 8ea6bb4de2a..4ee36f5864c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -369,6 +369,7 @@ void THD::init(void)
if (variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)
server_status|= SERVER_STATUS_NO_BACKSLASH_ESCAPES;
options= thd_startup_options;
+ no_trans_update.stmt= no_trans_update.all= FALSE;
open_options=ha_open_options;
update_lock_default= (variables.low_priority_updates ?
TL_WRITE_LOW_PRIORITY :
@@ -420,6 +421,7 @@ void THD::init_for_queries()
void THD::change_user(void)
{
cleanup();
+ killed= NOT_KILLED;
cleanup_done= 0;
init();
stmt_map.reset();
@@ -438,6 +440,7 @@ void THD::cleanup(void)
DBUG_ENTER("THD::cleanup");
DBUG_ASSERT(cleanup_done == 0);
+ killed= KILL_CONNECTION;
#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
if (transaction.xid_state.xa_state == XA_PREPARED)
{
@@ -842,7 +845,8 @@ void THD::add_changed_table(const char *key, long key_length)
{
list_include(prev_changed, curr, changed_table_dup(key, key_length));
DBUG_PRINT("info",
- ("key_length %ld %u", key_length, (*prev_changed)->key_length));
+ ("key_length: %ld %u", key_length,
+ (*prev_changed)->key_length));
DBUG_VOID_RETURN;
}
else if (cmp == 0)
@@ -852,7 +856,7 @@ void THD::add_changed_table(const char *key, long key_length)
{
list_include(prev_changed, curr, changed_table_dup(key, key_length));
DBUG_PRINT("info",
- ("key_length %ld %u", key_length,
+ ("key_length: %ld %u", key_length,
(*prev_changed)->key_length));
DBUG_VOID_RETURN;
}
@@ -864,7 +868,7 @@ void THD::add_changed_table(const char *key, long key_length)
}
}
*prev_changed = changed_table_dup(key, key_length);
- DBUG_PRINT("info", ("key_length %ld %u", key_length,
+ DBUG_PRINT("info", ("key_length: %ld %u", key_length,
(*prev_changed)->key_length));
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index ad08fc194c9..3d53c19633e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -280,7 +280,7 @@ struct system_variables
Time_zone *time_zone;
- /* DATE, DATETIME and TIME formats */
+ /* DATE, DATETIME and MYSQL_TIME formats */
DATE_TIME_FORMAT *date_format;
DATE_TIME_FORMAT *datetime_format;
DATE_TIME_FORMAT *time_format;
@@ -1355,7 +1355,11 @@ public:
bool charset_is_system_charset, charset_is_collation_connection;
bool charset_is_character_set_filesystem;
bool enable_slow_log; /* enable slow log for current statement */
- bool no_trans_update, abort_on_warning;
+ struct {
+ bool all:1;
+ bool stmt:1;
+ } no_trans_update;
+ bool abort_on_warning;
bool got_warning; /* Set on call to push_warning() */
bool no_warnings_for_error; /* no warnings on call to my_error() */
/* set during loop of derived table processing */
@@ -1583,7 +1587,7 @@ public:
inline bool really_abort_on_warning()
{
return (abort_on_warning &&
- (!no_trans_update ||
+ (!no_trans_update.stmt ||
(variables.sql_mode & MODE_STRICT_ALL_TABLES)));
}
void set_status_var_init();
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 09ee4962235..d03a17079d8 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -315,6 +315,7 @@ int check_user(THD *thd, enum enum_server_command command,
bool check_count)
{
DBUG_ENTER("check_user");
+ LEX_STRING db_str= { (char *) db, db ? strlen(db) : 0 };
#ifdef NO_EMBEDDED_ACCESS_CHECKS
thd->main_security_ctx.master_access= GLOBAL_ACLS; // Full rights
@@ -326,7 +327,7 @@ int check_user(THD *thd, enum enum_server_command command,
function returns 0
*/
thd->reset_db(NULL, 0);
- if (mysql_change_db(thd, db, FALSE))
+ if (mysql_change_db(thd, &db_str, FALSE))
{
/* Send the error to the client */
net_send_error(thd);
@@ -472,7 +473,7 @@ int check_user(THD *thd, enum enum_server_command command,
/* Change database if necessary */
if (db && db[0])
{
- if (mysql_change_db(thd, db, FALSE))
+ if (mysql_change_db(thd, &db_str, FALSE))
{
/* Send error to the client */
net_send_error(thd);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index cc9dc4c1fec..cfd610638ce 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -22,6 +22,7 @@
#include "events.h"
#include <my_dir.h>
#include <m_ctype.h>
+#include "log.h"
#ifdef __WIN__
#include <direct.h>
#endif
@@ -577,7 +578,7 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
DBUG_ENTER("mysql_create_db");
/* do not create 'information_schema' db */
- if (!my_strcasecmp(system_charset_info, db, information_schema_name.str))
+ if (!my_strcasecmp(system_charset_info, db, INFORMATION_SCHEMA_NAME.str))
{
my_error(ER_DB_CREATE_EXISTS, MYF(0), db);
DBUG_RETURN(-1);
@@ -1256,155 +1257,251 @@ err:
}
-/*
- Change the current database.
+/**
+ @brief Internal implementation: switch current database to a valid one.
- SYNOPSIS
- mysql_change_db()
- thd thread handle
- name database name
- no_access_check if TRUE, don't do access check. In this
- case name may be ""
+ @param thd Thread context.
+ @param new_db_name Name of the database to switch to. The function will
+ take ownership of the name (the caller must not free
+ the allocated memory). If the name is NULL, we're
+ going to switch to NULL db.
+ @param new_db_access Privileges of the new database.
+ @param new_db_charset Character set of the new database.
+*/
- DESCRIPTION
- Check that the database name corresponds to a valid and
- existent database, check access rights (unless called with
- no_access_check), and set the current database. This function
- is called to change the current database upon user request
- (COM_CHANGE_DB command) or temporarily, to execute a stored
- routine.
+static void mysql_change_db_impl(THD *thd,
+ LEX_STRING *new_db_name,
+ ulong new_db_access,
+ CHARSET_INFO *new_db_charset)
+{
+ /* 1. Change current database in THD. */
- NOTES
- This function is not the only way to switch the database that
- is currently employed. When the replication slave thread
- switches the database before executing a query, it calls
- thd->set_db directly. However, if the query, in turn, uses
- a stored routine, the stored routine will use this function,
- even if it's run on the slave.
-
- This function allocates the name of the database on the system
- heap: this is necessary to be able to uniformly change the
- database from any module of the server. Up to 5.0 different
- modules were using different memory to store the name of the
- database, and this led to memory corruption: a stack pointer
- set by Stored Procedures was used by replication after the
- stack address was long gone.
-
- This function does not send anything, including error
- messages, to the client. If that should be sent to the client,
- call net_send_error after this function.
+ if (new_db_name == NULL)
+ {
+ /*
+ THD::set_db() does all the job -- it frees previous database name and
+ sets the new one.
+ */
- RETURN VALUES
- 0 OK
- 1 error
+ thd->set_db(NULL, 0);
+ }
+ else if (new_db_name == &INFORMATION_SCHEMA_NAME)
+ {
+ /*
+ Here we must use THD::set_db(), because we want to copy
+ INFORMATION_SCHEMA_NAME constant.
+ */
+
+ thd->set_db(INFORMATION_SCHEMA_NAME.str, INFORMATION_SCHEMA_NAME.length);
+ }
+ else
+ {
+ /*
+ Here we already have a copy of database name to be used in THD. So,
+ we just call THD::reset_db(). Since THD::reset_db() does not releases
+ the previous database name, we should do it explicitly.
+ */
+
+ x_free(thd->db);
+
+ thd->reset_db(new_db_name->str, new_db_name->length);
+ }
+
+ /* 2. Update security context. */
+
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ thd->security_ctx->db_access= new_db_access;
+#endif
+
+ /* 3. Update db-charset environment variables. */
+
+ thd->db_charset= new_db_charset;
+ thd->variables.collation_database= new_db_charset;
+}
+
+
+/**
+ @brief Change the current database.
+
+ @param thd thread handle
+ @param name database name
+ @param force_switch if this flag is set (TRUE), mysql_change_db() will
+ switch to NULL db if the specified database is not
+ available anymore. Corresponding warning will be
+ thrown in this case. This flag is used to change
+ database in stored-routine-execution code.
+
+ @details Check that the database name corresponds to a valid and existent
+ database, check access rights (unless called with no_access_check), and
+ set the current database. This function is called to change the current
+ database upon user request (COM_CHANGE_DB command) or temporarily, to
+ execute a stored routine.
+
+ This function is not the only way to switch the database that is
+ currently employed. When the replication slave thread switches the
+ database before executing a query, it calls thd->set_db directly.
+ However, if the query, in turn, uses a stored routine, the stored routine
+ will use this function, even if it's run on the slave.
+
+ This function allocates the name of the database on the system heap: this
+ is necessary to be able to uniformly change the database from any module
+ of the server. Up to 5.0 different modules were using different memory to
+ store the name of the database, and this led to memory corruption:
+ a stack pointer set by Stored Procedures was used by replication after
+ the stack address was long gone.
+
+ @return Operation status
+ @retval FALSE Success
+ @retval TRUE Error
*/
-bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
+bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
{
- LEX_STRING db_name;
- bool system_db= 0;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- ulong db_access;
+ LEX_STRING new_db_file_name;
+
Security_context *sctx= thd->security_ctx;
- LINT_INIT(db_access);
-#endif
+ ulong db_access= sctx->db_access;
+
DBUG_ENTER("mysql_change_db");
- DBUG_PRINT("enter",("name: '%s'",name));
+ DBUG_PRINT("enter",("name: '%s'", new_db_name->str));
- if (name == NULL || name[0] == '\0' && no_access_check == FALSE)
+ if (new_db_name == NULL ||
+ new_db_name->length == 0)
{
- my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
- DBUG_RETURN(1); /* purecov: inspected */
+ if (force_switch)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR));
+
+ /* Change db to NULL. */
+
+ mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
+
+ DBUG_RETURN(FALSE);
+ }
+ else
+ {
+ my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
+
+ DBUG_RETURN(TRUE);
+ }
}
- else if (name[0] == '\0')
+
+ if (my_strcasecmp(system_charset_info, new_db_name->str,
+ INFORMATION_SCHEMA_NAME.str) == 0)
{
- /* Called from SP to restore the original database, which was NULL */
- DBUG_ASSERT(no_access_check);
- system_db= 1;
- db_name.str= NULL;
- db_name.length= 0;
- goto end;
+ /* Switch database to INFORMATION_SCHEMA. */
+
+ mysql_change_db_impl(thd, &INFORMATION_SCHEMA_NAME, SELECT_ACL,
+ system_charset_info);
+
+ DBUG_RETURN(FALSE);
}
+
/*
Now we need to make a copy because check_db_name requires a
- non-constant argument. TODO: fix check_db_name.
+ non-constant argument. Actually, it takes database file name.
+
+ TODO: fix check_db_name().
+ */
+
+ new_db_file_name.str= my_strndup(new_db_name->str, new_db_name->length,
+ MYF(MY_WME));
+ new_db_file_name.length= new_db_name->length;
+
+ if (new_db_file_name.str == NULL)
+ DBUG_RETURN(TRUE); /* the error is set */
+
+ /*
+ NOTE: if check_db_name() fails, we should throw an error in any case,
+ even if we are called from sp_head::execute().
+
+ It's next to impossible however to get this error when we are called
+ from sp_head::execute(). But let's switch database to NULL in this case
+ to be sure.
*/
- if ((db_name.str= my_strdup(name, MYF(MY_WME))) == NULL)
- DBUG_RETURN(1); /* the error is set */
- db_name.length= strlen(db_name.str);
- if (check_db_name(&db_name))
+
+ if (check_db_name(&new_db_file_name))
{
- my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
- my_free(db_name.str, MYF(0));
- DBUG_RETURN(1);
+ my_error(ER_WRONG_DB_NAME, MYF(0), new_db_file_name.str);
+ my_free(new_db_file_name.str, MYF(0));
+
+ if (force_switch)
+ {
+ /* Change db to NULL. */
+ mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
+ }
+ DBUG_RETURN(TRUE);
}
- DBUG_PRINT("info",("Use database: %s", db_name.str));
- if (!my_strcasecmp(system_charset_info, db_name.str,
- information_schema_name.str))
- {
- system_db= 1;
+
+ DBUG_PRINT("info",("Use database: %s", new_db_file_name.str));
+
#ifndef NO_EMBEDDED_ACCESS_CHECKS
- db_access= SELECT_ACL;
-#endif
- goto end;
+ db_access=
+ test_all_bits(sctx->master_access, DB_ACLS) ?
+ DB_ACLS :
+ acl_get(sctx->host,
+ sctx->ip,
+ sctx->priv_user,
+ new_db_file_name.str,
+ FALSE) | sctx->master_access;
+
+ if (!force_switch &&
+ !(db_access & DB_ACLS) &&
+ (!grant_option || check_grant_db(thd, new_db_file_name.str)))
+ {
+ my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
+ sctx->priv_user,
+ sctx->priv_host,
+ new_db_file_name.str);
+ general_log_print(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
+ sctx->priv_user, sctx->priv_host, new_db_file_name.str);
+ my_free(new_db_file_name.str, MYF(0));
+ DBUG_RETURN(TRUE);
}
+#endif
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- if (!no_access_check)
+ if (check_db_dir_existence(new_db_file_name.str))
{
- if (test_all_bits(sctx->master_access, DB_ACLS))
- db_access=DB_ACLS;
+ if (force_switch)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR),
+ new_db_file_name.str);
+
+ my_free(new_db_file_name.str, MYF(0));
+
+ /* Change db to NULL. */
+
+ mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
+
+ DBUG_RETURN(FALSE);
+ }
else
- db_access= (acl_get(sctx->host, sctx->ip, sctx->priv_user,
- db_name.str, 0) |
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option ||
- check_grant_db(thd, db_name.str)))
{
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
- db_name.str);
- general_log_print(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
- sctx->priv_user, sctx->priv_host, db_name.str);
- my_free(db_name.str, MYF(0));
- DBUG_RETURN(1);
+ my_error(ER_BAD_DB_ERROR, MYF(0), new_db_file_name.str);
+ my_free(new_db_file_name.str, MYF(0));
+ DBUG_RETURN(TRUE);
}
}
-#endif
- if (check_db_dir_existence(db_name.str))
- {
- my_error(ER_BAD_DB_ERROR, MYF(0), db_name.str);
- my_free(db_name.str, MYF(0));
- DBUG_RETURN(1);
- }
+ /*
+ NOTE: in mysql_change_db_impl() new_db_file_name is assigned to THD
+ attributes and will be freed in THD::~THD().
+ */
-end:
- x_free(thd->db);
- DBUG_ASSERT(db_name.str == NULL || db_name.str[0] != '\0');
- thd->reset_db(db_name.str, db_name.length); // THD::~THD will free this
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- if (!no_access_check)
- sctx->db_access= db_access;
-#endif
- if (system_db)
- {
- thd->db_charset= system_charset_info;
- thd->variables.collation_database= system_charset_info;
- }
- else
{
- HA_CREATE_INFO create;
+ HA_CREATE_INFO db_options;
- load_db_opt_by_name(thd, db_name.str, &create);
+ load_db_opt_by_name(thd, new_db_name->str, &db_options);
- thd->db_charset= create.default_table_charset ?
- create.default_table_charset :
- thd->variables.collation_server;
- thd->variables.collation_database= thd->db_charset;
+ mysql_change_db_impl(thd, &new_db_file_name, db_access,
+ db_options.default_table_charset ?
+ db_options.default_table_charset :
+ thd->variables.collation_server);
}
- DBUG_RETURN(0);
+
+ DBUG_RETURN(FALSE);
}
@@ -1581,8 +1678,8 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db)
Failed to move all tables from the old database to the new one.
In the best case mysql_rename_tables() moved all tables back to the old
database. In the worst case mysql_rename_tables() moved some tables
- to the new database, then failed, then started to move the tables back, and
- then failed again. In this situation we have some tables in the
+ to the new database, then failed, then started to move the tables back,
+ and then failed again. In this situation we have some tables in the
old database and some tables in the new database.
Let's delete the option file, and then the new database directory.
If some tables were left in the new directory, rmdir() will fail.
@@ -1703,7 +1800,7 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db)
/* Step9: Let's do "use newdb" if we renamed the current database */
if (change_to_newdb)
- error|= mysql_change_db(thd, new_db->str, 0);
+ error|= mysql_change_db(thd, new_db, 0);
exit:
pthread_mutex_lock(&LOCK_lock_db);
@@ -1718,6 +1815,8 @@ exit:
DBUG_RETURN(error);
}
+
+
/*
Check if there is directory for the database name.
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 4e865a12b66..92f38d57330 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -353,7 +353,7 @@ cleanup:
}
}
if (!transactional_table)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
free_underlaid_joins(thd, select_lex);
if (transactional_table)
@@ -394,6 +394,8 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
{
Item *fake_conds= 0;
SELECT_LEX *select_lex= &thd->lex->select_lex;
+ const char *operation = thd->lex->sql_command == SQLCOM_TRUNCATE ?
+ "TRUNCATE" : "DELETE";
DBUG_ENTER("mysql_prepare_delete");
List<Item> all_fields;
@@ -408,14 +410,14 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
DBUG_RETURN(TRUE);
if (!table_list->updatable || check_key_in_view(thd, table_list))
{
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, operation);
DBUG_RETURN(TRUE);
}
{
TABLE_LIST *duplicate;
if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
{
- update_non_unique_table_error(table_list, "DELETE", duplicate);
+ update_non_unique_table_error(table_list, operation, duplicate);
DBUG_RETURN(TRUE);
}
}
@@ -856,7 +858,7 @@ bool multi_delete::send_eof()
}
}
if (!transactional_tables)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
/* Commit or rollback the current SQL statement */
if (transactional_tables)
@@ -933,7 +935,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
if (!dont_send_ok)
{
enum legacy_db_type table_type;
- mysql_frm_type(thd, path, &table_type);
+ if (mysql_frm_type(thd, path, &table_type) == FRMTYPE_VIEW)
+ goto trunc_by_del;
if (table_type == DB_TYPE_UNKNOWN)
{
my_error(ER_NO_SUCH_TABLE, MYF(0),
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 70882d8f4e8..61442c52de7 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -147,15 +147,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
if (thd->warn_list.elements < thd->variables.max_error_count)
{
- /*
- The following code is here to change the allocation to not
- use the thd->mem_root, which is freed after each query
- */
- MEM_ROOT *old_root= thd->mem_root;
- thd->mem_root= &thd->warn_root;
- if ((err= new MYSQL_ERROR(thd, code, level, msg)))
- thd->warn_list.push_back(err);
- thd->mem_root= old_root;
+ /* We have to use warn_root, as mem_root is freed after each query */
+ if ((err= new (&thd->warn_root) MYSQL_ERROR(thd, code, level, msg)))
+ thd->warn_list.push_back(err, &thd->warn_root);
}
thd->warn_count[(uint) level]++;
thd->total_warn_count++;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index cda49d9bf62..f6ae2df3750 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -612,7 +612,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (lock_type != TL_WRITE_DELAYED && !thd->prelocked_mode)
table->file->ha_start_bulk_insert(values_list.elements);
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= (!ignore && (thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
@@ -755,7 +755,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
}
if (!transactional_table)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
}
if (transactional_table)
@@ -1163,7 +1163,7 @@ static int last_uniq_key(TABLE *table,uint keynr)
then both on update triggers will work instead. Similarly both on
delete triggers will be invoked if we will delete conflicting records.
- Sets thd->no_trans_update if table which is updated didn't have
+ Sets thd->no_trans_update.stmt to TRUE if table which is updated didn't have
transactions.
RETURN VALUE
@@ -1366,7 +1366,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
goto err;
info->deleted++;
if (!table->file->has_transactions())
- thd->no_trans_update= 1;
+ thd->no_trans_update.stmt= TRUE;
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_AFTER, TRUE))
@@ -1407,7 +1407,7 @@ ok_or_after_trg_err:
if (key)
my_safe_afree(key,table->s->max_unique_length,MAX_KEY_LENGTH);
if (!table->file->has_transactions())
- thd->no_trans_update= 1;
+ thd->no_trans_update.stmt= TRUE;
DBUG_RETURN(trg_error);
err:
@@ -2680,7 +2680,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (info.handle_duplicates == DUP_REPLACE &&
(!table->triggers || !table->triggers->has_delete_triggers()))
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
@@ -2861,7 +2861,7 @@ void select_insert::send_error(uint errcode,const char *err)
table->file->has_transactions(), FALSE);
if (!thd->current_stmt_binlog_row_based && !table->s->tmp_table &&
!can_rollback_data())
- thd->options|= OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
query_cache_invalidate3(thd, table, 1);
}
}
@@ -2902,7 +2902,7 @@ bool select_insert::send_eof()
*/
if (!trans_table &&
(!table->s->tmp_table || !thd->current_stmt_binlog_row_based))
- thd->options|= OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
/*
@@ -3209,7 +3209,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
if (!thd->prelocked_mode)
table->file->ha_start_bulk_insert((ha_rows) 0);
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 26955c18342..4a162478388 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1835,6 +1835,7 @@ bool st_lex::can_use_merged()
case SQLCOM_UPDATE_MULTI:
case SQLCOM_DELETE:
case SQLCOM_DELETE_MULTI:
+ case SQLCOM_TRUNCATE:
case SQLCOM_INSERT:
case SQLCOM_INSERT_SELECT:
case SQLCOM_REPLACE:
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 41de2c86740..71cc4c0507c 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -376,7 +376,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table->file->ha_start_bulk_insert((ha_rows) 0);
table->copy_blobs=1;
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= (!ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
@@ -470,7 +470,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
if (!transactional_table)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
#ifndef EMBEDDED_LIBRARY
if (mysql_bin_log.is_open())
{
@@ -552,7 +552,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
Item_field *sql_field;
TABLE *table= table_list->table;
ulonglong id;
- bool no_trans_update, err;
+ bool no_trans_update_stmt, err;
DBUG_ENTER("read_fixed_length");
id= 0;
@@ -580,7 +580,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
#ifdef HAVE_purify
read_info.row_end[0]=0;
#endif
- no_trans_update= !table->file->has_transactions();
+ no_trans_update_stmt= !table->file->has_transactions();
restore_record(table, s->default_values);
/*
@@ -648,7 +648,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
table->auto_increment_field_not_null= FALSE;
if (err)
DBUG_RETURN(1);
- thd->no_trans_update= no_trans_update;
+ thd->no_trans_update.stmt= no_trans_update_stmt;
/*
We don't need to reset auto-increment field since we are restoring
@@ -683,12 +683,12 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
TABLE *table= table_list->table;
uint enclosed_length;
ulonglong id;
- bool no_trans_update, err;
+ bool no_trans_update_stmt, err;
DBUG_ENTER("read_sep_field");
enclosed_length=enclosed.length();
id= 0;
- no_trans_update= !table->file->has_transactions();
+ no_trans_update_stmt= !table->file->has_transactions();
for (;;it.rewind())
{
@@ -823,7 +823,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
We don't need to reset auto-increment field since we are restoring
its default value at the beginning of each loop iteration.
*/
- thd->no_trans_update= no_trans_update;
+ thd->no_trans_update.stmt= no_trans_update_stmt;
if (read_info.next_line()) // Skip to next line
break;
if (read_info.line_cuted)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 9d02053ec00..df2ac4d72fa 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -118,8 +118,8 @@ bool end_active_trans(THD *thd)
if (ha_commit(thd))
error=1;
}
- thd->options&= ~(OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG);
+ thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
+ thd->no_trans_update.all= FALSE;
DBUG_RETURN(error);
}
@@ -545,8 +545,8 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion)
*/
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
res= ha_commit(thd);
- thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG);
+ thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_KEEP_LOG);
+ thd->no_trans_update.all= FALSE;
break;
case COMMIT_RELEASE:
do_release= 1; /* fall through */
@@ -563,8 +563,8 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion)
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
if (ha_rollback(thd))
res= -1;
- thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG);
+ thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_KEEP_LOG);
+ thd->no_trans_update.all= FALSE;
if (!res && (completion == ROLLBACK_AND_CHAIN))
res= begin_trans(thd);
break;
@@ -719,7 +719,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
&LOCK_status);
thd->convert_string(&tmp, system_charset_info,
packet, packet_length-1, thd->charset());
- if (!mysql_change_db(thd, tmp.str, FALSE))
+ if (!mysql_change_db(thd, &tmp, FALSE))
{
general_log_print(thd, command, "%s",thd->db);
send_ok(thd);
@@ -784,7 +784,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *save_db;
uint passwd_len= (thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
*passwd++ : strlen(passwd));
- uint dummy_errors, save_db_length, db_length, res;
+ uint dummy_errors, save_db_length, db_length;
+ int res;
Security_context save_security_ctx= *thd->security_ctx;
USER_CONN *save_user_connect;
@@ -831,6 +832,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
/* authentication failure, we shall restore old user */
if (res > 0)
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
+ else
+ thd->clear_error(); // Error already sent to client
x_free(thd->security_ctx->user);
*thd->security_ctx= save_security_ctx;
thd->user_connect= save_user_connect;
@@ -960,7 +963,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
packet= arg_end + 1;
if (!my_strcasecmp(system_charset_info, table_list.db,
- information_schema_name.str))
+ INFORMATION_SCHEMA_NAME.str))
{
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, table_list.alias);
if (schema_table)
@@ -1140,6 +1143,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
STATUS_VAR current_global_status_var;
ulong uptime;
uint length;
+ ulonglong queries_per_second1000;
#ifndef EMBEDDED_LIBRARY
char buff[250];
uint buff_len= sizeof(buff);
@@ -1152,19 +1156,23 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS],
&LOCK_status);
calc_sum_of_all_status(&current_global_status_var);
- uptime= (ulong) (thd->start_time - server_start_time);
+ if (!(uptime= (ulong) (thd->start_time - server_start_time)))
+ queries_per_second1000= 0;
+ else
+ queries_per_second1000= thd->query_id * LL(1000) / uptime;
+
length= my_snprintf((char*) buff, buff_len - 1,
"Uptime: %lu Threads: %d Questions: %lu "
"Slow queries: %lu Opens: %lu Flush tables: %lu "
- "Open tables: %u Queries per second avg: %.3f",
+ "Open tables: %u Queries per second avg: %u.%u",
uptime,
(int) thread_count, (ulong) thd->query_id,
current_global_status_var.long_query_count,
current_global_status_var.opened_tables,
refresh_version,
cached_open_tables(),
- (uptime ? (ulonglong2double(thd->query_id) /
- (double) uptime) : (double) 0));
+ (uint) (queries_per_second1000 / 1000),
+ (uint) (queries_per_second1000 % 1000));
#ifdef SAFEMALLOC
if (sf_malloc_cur_memory) // Using SAFEMALLOC
{
@@ -1350,8 +1358,9 @@ void log_slow_statement(THD *thd)
int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
enum enum_schema_tables schema_table_idx)
{
+ SELECT_LEX *schema_select_lex= NULL;
DBUG_ENTER("prepare_schema_table");
- SELECT_LEX *sel= 0;
+
switch (schema_table_idx) {
case SCH_SCHEMATA:
#if defined(DONT_ALLOW_SHOW_COMMANDS)
@@ -1359,11 +1368,9 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */
DBUG_RETURN(1);
#else
- if ((specialflag & SPECIAL_SKIP_SHOW_DB) &&
- check_global_access(thd, SHOW_DB_ACL))
- DBUG_RETURN(1);
break;
#endif
+
case SCH_TABLE_NAMES:
case SCH_TABLES:
case SCH_VIEWS:
@@ -1382,54 +1389,38 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
{
DBUG_RETURN(1);
}
- db.str= lex->select_lex.db;
+ schema_select_lex= new SELECT_LEX();
+ db.str= schema_select_lex->db= lex->select_lex.db;
+ schema_select_lex->table_list.first= NULL;
db.length= strlen(db.str);
+
if (check_db_name(&db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
DBUG_RETURN(1);
}
- if (check_access(thd, SELECT_ACL, db.str, &thd->col_access, 0, 0,
- is_schema_db(db.str)))
- DBUG_RETURN(1); /* purecov: inspected */
- if (!thd->col_access && check_grant_db(thd, db.str))
- {
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user, thd->security_ctx->priv_host,
- db.str);
- DBUG_RETURN(1);
- }
break;
}
#endif
case SCH_COLUMNS:
case SCH_STATISTICS:
+ {
#ifdef DONT_ALLOW_SHOW_COMMANDS
my_message(ER_NOT_ALLOWED_COMMAND,
ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */
DBUG_RETURN(1);
#else
- if (table_ident)
- {
- TABLE_LIST **query_tables_last= lex->query_tables_last;
- sel= new SELECT_LEX();
- /* 'parent_lex' is used in init_query() so it must be before it. */
- sel->parent_lex= lex;
- sel->init_query();
- if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ))
- DBUG_RETURN(1);
- lex->query_tables_last= query_tables_last;
- TABLE_LIST *table_list= (TABLE_LIST*) sel->table_list.first;
- char *db= table_list->db;
- if (check_access(thd,SELECT_ACL | EXTRA_ACL,db,
- &table_list->grant.privilege, 0, 0,
- test(table_list->schema_table)))
- DBUG_RETURN(1); /* purecov: inspected */
- if (grant_option && check_grant(thd, SELECT_ACL, table_list, 2,
- UINT_MAX, 0))
- DBUG_RETURN(1);
- break;
- }
+ DBUG_ASSERT(table_ident);
+ TABLE_LIST **query_tables_last= lex->query_tables_last;
+ schema_select_lex= new SELECT_LEX();
+ /* 'parent_lex' is used in init_query() so it must be before it. */
+ schema_select_lex->parent_lex= lex;
+ schema_select_lex->init_query();
+ if (!schema_select_lex->add_table_to_list(thd, table_ident, 0, 0, TL_READ))
+ DBUG_RETURN(1);
+ lex->query_tables_last= query_tables_last;
+ break;
+ }
#endif
case SCH_OPEN_TABLES:
case SCH_VARIABLES:
@@ -1455,7 +1446,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
DBUG_RETURN(1);
}
TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first;
- table_list->schema_select_lex= sel;
+ table_list->schema_select_lex= schema_select_lex;
table_list->schema_table_reformed= 1;
DBUG_RETURN(0);
}
@@ -2843,7 +2834,7 @@ end_with_restore_list:
we silently add IF EXISTS if TEMPORARY was used.
*/
if (thd->slave_thread)
- lex->drop_if_exists= 1;
+ lex->drop_if_exists= 1;
/* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */
thd->options|= OPTION_KEEP_LOG;
@@ -2900,9 +2891,14 @@ end_with_restore_list:
}
#endif
case SQLCOM_CHANGE_DB:
- if (!mysql_change_db(thd,select_lex->db,FALSE))
+ {
+ LEX_STRING db_str= { (char *) select_lex->db, strlen(select_lex->db) };
+
+ if (!mysql_change_db(thd, &db_str, FALSE))
send_ok(thd);
+
break;
+ }
case SQLCOM_LOAD:
{
@@ -3545,8 +3541,7 @@ end_with_restore_list:
res= TRUE; // cannot happen
else
{
- if ((thd->options &
- (OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG)) &&
+ if (((thd->options & OPTION_KEEP_LOG) || thd->no_trans_update.all) &&
!thd->slave_thread)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARNING_NOT_COMPLETE_ROLLBACK,
@@ -4103,9 +4098,8 @@ create_sp_error:
thd->transaction.xid_state.xa_state=XA_ACTIVE;
thd->transaction.xid_state.xid.set(thd->lex->xid);
xid_cache_insert(&thd->transaction.xid_state);
- thd->options= ((thd->options & ~(OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG)) |
- OPTION_BEGIN);
+ thd->options= ((thd->options & ~(OPTION_KEEP_LOG)) | OPTION_BEGIN);
+ thd->no_trans_update.all= FALSE;
thd->server_status|= SERVER_STATUS_IN_TRANS;
send_ok(thd);
break;
@@ -4198,8 +4192,8 @@ create_sp_error:
xa_state_names[thd->transaction.xid_state.xa_state]);
break;
}
- thd->options&= ~(OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG);
+ thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
+ thd->no_trans_update.all= FALSE;
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
xid_cache_delete(&thd->transaction.xid_state);
thd->transaction.xid_state.xa_state=XA_NOTR;
@@ -4229,8 +4223,8 @@ create_sp_error:
my_error(ER_XAER_RMERR, MYF(0));
else
send_ok(thd);
- thd->options&= ~(OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
- OPTION_KEEP_LOG);
+ thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
+ thd->no_trans_update.all= FALSE;
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
xid_cache_delete(&thd->transaction.xid_state);
thd->transaction.xid_state.xa_state=XA_NOTR;
@@ -4467,7 +4461,10 @@ bool check_single_table_access(THD *thd, ulong privilege,
goto deny;
/* Show only 1 table for check_grant */
- if (grant_option && check_grant(thd, privilege, all_tables, 0, 1, no_errors))
+ if (grant_option &&
+ !(all_tables->belong_to_view &&
+ (thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
+ check_grant(thd, privilege, all_tables, 0, 1, no_errors))
goto deny;
thd->security_ctx= backup_ctx;
@@ -4684,6 +4681,66 @@ bool check_global_access(THD *thd, ulong want_access)
}
+static bool check_show_access(THD *thd, TABLE_LIST *table)
+{
+ switch (get_schema_table_idx(table->schema_table)) {
+ case SCH_SCHEMATA:
+ return (specialflag & SPECIAL_SKIP_SHOW_DB) &&
+ check_global_access(thd, SHOW_DB_ACL);
+
+ case SCH_TABLE_NAMES:
+ case SCH_TABLES:
+ case SCH_VIEWS:
+ case SCH_TRIGGERS:
+ case SCH_EVENTS:
+ {
+ const char *dst_db_name= table->schema_select_lex->db;
+
+ DBUG_ASSERT(dst_db_name);
+
+ if (check_access(thd, SELECT_ACL, dst_db_name,
+ &thd->col_access, FALSE, FALSE,
+ is_schema_db(dst_db_name)))
+ return TRUE;
+
+ if (!thd->col_access && check_grant_db(thd, dst_db_name))
+ {
+ my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
+ thd->security_ctx->priv_user,
+ thd->security_ctx->priv_host,
+ dst_db_name);
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ case SCH_COLUMNS:
+ case SCH_STATISTICS:
+ {
+ TABLE_LIST *dst_table;
+ dst_table= (TABLE_LIST *) table->schema_select_lex->table_list.first;
+
+ DBUG_ASSERT(dst_table);
+
+ if (check_access(thd, SELECT_ACL | EXTRA_ACL,
+ dst_table->db,
+ &dst_table->grant.privilege,
+ FALSE, FALSE,
+ test(dst_table->schema_table)))
+ return FALSE;
+
+ return (grant_option &&
+ check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE));
+ }
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+
/*
Check the privilege for all used tables.
@@ -4736,7 +4793,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
if (!no_errors)
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
sctx->priv_user, sctx->priv_host,
- information_schema_name.str);
+ INFORMATION_SCHEMA_NAME.str);
return TRUE;
}
/*
@@ -4744,7 +4801,16 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
Remove SHOW_VIEW_ACL, because it will be checked during making view
*/
tables->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
- if (tables->derived || tables->schema_table ||
+
+ if (tables->schema_table_reformed)
+ {
+ if (check_show_access(thd, tables))
+ goto deny;
+
+ continue;
+ }
+
+ if (tables->derived ||
(tables->table && (int)tables->table->s->tmp_table))
continue;
thd->security_ctx= sctx;
@@ -5024,8 +5090,10 @@ void mysql_reset_thd_for_next_command(THD *thd)
in ha_rollback_trans() about some tables couldn't be rolled back.
*/
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
- thd->options&= ~(OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG);
-
+ {
+ thd->options&= ~OPTION_KEEP_LOG;
+ thd->no_trans_update.all= FALSE;
+ }
DBUG_ASSERT(thd->security_ctx== &thd->main_security_ctx);
thd->tmp_table_used= 0;
if (!thd->in_sub_stmt)
@@ -5526,7 +5594,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
ptr->derived= table->sel;
if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db,
- information_schema_name.str))
+ INFORMATION_SCHEMA_NAME.str))
{
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name);
if (!schema_table ||
@@ -5534,7 +5602,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0))
{
my_error(ER_UNKNOWN_TABLE, MYF(0),
- ptr->table_name, information_schema_name.str);
+ ptr->table_name, INFORMATION_SCHEMA_NAME.str);
DBUG_RETURN(0);
}
ptr->schema_table_name= ptr->table_name;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index e97670ab2b1..31a6c7af04a 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1670,7 +1670,7 @@ static bool check_prepared_statement(Prepared_statement *stmt,
enum enum_sql_command sql_command= lex->sql_command;
int res= 0;
DBUG_ENTER("check_prepared_statement");
- DBUG_PRINT("enter",("command: %d, param_count: %u",
+ DBUG_PRINT("enter",("command: %d param_count: %u",
sql_command, stmt->param_count));
lex->first_lists_tables_same();
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index eb6f4efccc3..da2c8e96b0f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -280,15 +280,30 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
ref_pointer_array Array of references to Items used in current select
DESCRIPTION
- The function fixes fields referenced from inner selects and
- also fixes references (Item_ref objects) to these fields. Each field
- is fixed as a usual hidden field of the current select - it is added
- to the all_fields list and the pointer to it is saved in the
- ref_pointer_array if latter is provided.
- After the field has been fixed we proceed with fixing references
- (Item_ref objects) to this field from inner subqueries. If the
- ref_pointer_array is provided then Item_ref objects is set to
- reference element in that array with the pointer to the field.
+ 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.
+
+ If a field isn't already in 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.
+ 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.
+ 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
@@ -301,33 +316,64 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
{
Item_outer_ref *ref;
bool res= FALSE;
+ bool direct_ref= FALSE;
+
List_iterator<Item_outer_ref> ref_it(select->inner_refs_list);
while ((ref= ref_it++))
{
- Item_field *item= ref->outer_field;
+ Item *item= ref->outer_ref;
+ Item **item_ref= ref->ref;
+ Item_ref *new_ref;
/*
TODO: this field item already might be present in the select list.
In this case instead of adding new field item we could use an
existing one. The change will lead to less operations for copying fields,
smaller temporary tables and less data passed through filesort.
*/
- if (ref_pointer_array)
+ if (ref_pointer_array && !ref->found_in_select_list)
{
int el= all_fields.elements;
- ref_pointer_array[el]= (Item*)item;
+ ref_pointer_array[el]= item;
/* Add the field item to the select list of the current select. */
- all_fields.push_front((Item*)item);
+ all_fields.push_front(item);
/*
If it's needed reset each Item_ref item that refers this field with
a new reference taken from ref_pointer_array.
*/
- ref->ref= ref_pointer_array + el;
+ item_ref= ref_pointer_array + el;
}
- if (!ref->fixed && ref->fix_fields(thd, 0))
+
+ if (ref->in_sum_func)
{
- res= TRUE;
- break;
+ Item_sum *sum_func;
+ if (ref->in_sum_func->nest_level > select->nest_level)
+ direct_ref= TRUE;
+ else
+ {
+ for (sum_func= ref->in_sum_func; sum_func &&
+ sum_func->aggr_level >= select->nest_level;
+ sum_func= sum_func->in_sum_func)
+ {
+ if (sum_func->aggr_level == select->nest_level)
+ {
+ direct_ref= TRUE;
+ break;
+ }
+ }
+ }
}
+ new_ref= direct_ref ?
+ new Item_direct_ref(ref->context, item_ref, ref->field_name,
+ ref->table_name, ref->alias_name_used) :
+ new Item_ref(ref->context, item_ref, ref->field_name,
+ ref->table_name, ref->alias_name_used);
+ if (!new_ref)
+ return TRUE;
+ ref->outer_ref= new_ref;
+ ref->ref= &ref->outer_ref;
+
+ if (!ref->fixed && ref->fix_fields(thd, 0))
+ return TRUE;
thd->used_tables|= item->used_tables();
}
return res;
@@ -479,10 +525,6 @@ JOIN::prepare(Item ***rref_pointer_array,
if (having && having->with_sum_func)
having->split_sum_func2(thd, ref_pointer_array, all_fields,
&having, TRUE);
- if (select_lex->inner_refs_list.elements &&
- fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array))
- DBUG_RETURN(-1);
-
if (select_lex->inner_sum_func_list)
{
Item_sum *end=select_lex->inner_sum_func_list;
@@ -495,6 +537,10 @@ JOIN::prepare(Item ***rref_pointer_array,
} while (item_sum != end);
}
+ if (select_lex->inner_refs_list.elements &&
+ fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array))
+ DBUG_RETURN(-1);
+
if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
DBUG_RETURN(-1);
@@ -5379,7 +5425,9 @@ 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*)keyuse->val)->ref_type() == Item_ref::OUTER_REF &&
+ (*(Item_ref**)((Item_ref*)keyuse->val)->ref)->ref_type() ==
+ Item_ref::DIRECT_REF) )
return new store_key_field(thd,
key_part->field,
key_buff + maybe_null,
@@ -13799,9 +13847,7 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
ORDER *ord_iter;
for (ord_iter= group; ord_iter; ord_iter= ord_iter->next)
if ((*ord_iter->item)->eq(item, 1))
- break;
- if (ord_iter)
- continue;
+ goto next_item;
ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
if (!ord)
@@ -13816,6 +13862,7 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
*prev=ord;
prev= &ord->next;
}
+next_item:
ref_pointer_array++;
}
*prev=0;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 0d620d33dbb..0a04ba3e8cf 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -715,9 +715,9 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
}
#endif
if (!my_strcasecmp(system_charset_info, dbname,
- information_schema_name.str))
+ INFORMATION_SCHEMA_NAME.str))
{
- dbname= information_schema_name.str;
+ dbname= INFORMATION_SCHEMA_NAME.str;
create.default_table_charset= system_charset_info;
}
else
@@ -1800,7 +1800,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
else
table->field[4]->store(command_name[tmp->command].str,
command_name[tmp->command].length, cs);
- /* TIME */
+ /* MYSQL_TIME */
table->field[5]->store((uint32)(tmp->start_time ?
now - tmp->start_time : 0), TRUE);
/* STATE */
@@ -2197,7 +2197,7 @@ LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
/* INFORMATION_SCHEMA name */
-LEX_STRING information_schema_name= { C_STRING_WITH_LEN("information_schema")};
+LEX_STRING INFORMATION_SCHEMA_NAME= { C_STRING_WITH_LEN("information_schema")};
/* This is only used internally, but we need it here as a forward reference */
extern ST_SCHEMA_TABLE schema_tables[];
@@ -2413,11 +2413,11 @@ int make_db_list(THD *thd, List<char> *files,
*/
if (!idx_field_vals->db_value ||
!wild_case_compare(system_charset_info,
- information_schema_name.str,
+ INFORMATION_SCHEMA_NAME.str,
idx_field_vals->db_value))
{
*with_i_schema= 1;
- if (files->push_back(thd->strdup(information_schema_name.str)))
+ if (files->push_back(thd->strdup(INFORMATION_SCHEMA_NAME.str)))
return 1;
}
return (find_files(thd, files, NullS, mysql_data_home,
@@ -2431,11 +2431,11 @@ int make_db_list(THD *thd, List<char> *files,
*/
if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND)
{
- if (!my_strcasecmp(system_charset_info, information_schema_name.str,
+ if (!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str,
idx_field_vals->db_value))
{
*with_i_schema= 1;
- return files->push_back(thd->strdup(information_schema_name.str));
+ return files->push_back(thd->strdup(INFORMATION_SCHEMA_NAME.str));
}
return files->push_back(thd->strdup(idx_field_vals->db_value));
}
@@ -2444,7 +2444,7 @@ int make_db_list(THD *thd, List<char> *files,
Create list of existing databases. It is used in case
of select from information schema table
*/
- if (files->push_back(thd->strdup(information_schema_name.str)))
+ if (files->push_back(thd->strdup(INFORMATION_SCHEMA_NAME.str)))
return 1;
*with_i_schema= 1;
return (find_files(thd, files, NullS,
@@ -2564,7 +2564,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
*/
thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
- if (lsel)
+ if (lsel && lsel->table_list.first)
{
TABLE_LIST *show_table_list= (TABLE_LIST*) lsel->table_list.first;
bool res;
@@ -2837,7 +2837,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
const char *file_name)
{
const char *tmp_buff;
- TIME time;
+ MYSQL_TIME time;
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_tables_record");
@@ -3396,7 +3396,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
{
String tmp_string;
String sp_db, sp_name, definer;
- TIME time;
+ MYSQL_TIME time;
LEX *lex= thd->lex;
CHARSET_INFO *cs= system_charset_info;
get_field(thd->mem_root, proc_table->field[0], &sp_db);
@@ -3965,7 +3965,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
TABLE* table= schema_table;
CHARSET_INFO *cs= system_charset_info;
PARTITION_INFO stat_info;
- TIME time;
+ MYSQL_TIME time;
file->get_dynamic_partition_info(&stat_info, part_id);
table->field[12]->store((longlong) stat_info.records, TRUE);
table->field[13]->store((longlong) stat_info.mean_rec_length, TRUE);
@@ -4303,7 +4303,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
{
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
- TIME time;
+ MYSQL_TIME time;
Event_timed et;
DBUG_ENTER("copy_event_to_schema_table");
@@ -5052,8 +5052,8 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
We have to make non const db_name & table_name
because of lower_case_table_names
*/
- make_lex_string(thd, &db, information_schema_name.str,
- information_schema_name.length, 0);
+ make_lex_string(thd, &db, INFORMATION_SCHEMA_NAME.str,
+ INFORMATION_SCHEMA_NAME.length, 0);
make_lex_string(thd, &table, schema_table->table_name,
strlen(schema_table->table_name), 0);
if (schema_table->old_format(thd, schema_table) || /* Handle old syntax */
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0ec0a8e0f86..a2b25f0ffd0 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1929,10 +1929,11 @@ static int sort_keys(KEY *a, KEY *b)
which has some duplicates on its right
RETURN VALUES
- void
+ 0 ok
+ 1 Error
*/
-void check_duplicates_in_interval(const char *set_or_name,
+bool check_duplicates_in_interval(const char *set_or_name,
const char *name, TYPELIB *typelib,
CHARSET_INFO *cs, unsigned int *dup_val_count)
{
@@ -1948,6 +1949,13 @@ void check_duplicates_in_interval(const char *set_or_name,
tmp.count--;
if (find_type2(&tmp, (const char*)*cur_value, *cur_length, cs))
{
+ if ((current_thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+ {
+ my_error(ER_DUPLICATED_VALUE_IN_TYPE, MYF(0),
+ name,*cur_value,set_or_name);
+ return 1;
+ }
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_DUPLICATED_VALUE_IN_TYPE,
ER(ER_DUPLICATED_VALUE_IN_TYPE),
@@ -1955,6 +1963,7 @@ void check_duplicates_in_interval(const char *set_or_name,
(*dup_val_count)++;
}
}
+ return 0;
}
@@ -2090,9 +2099,10 @@ int prepare_create_field(create_field *sql_field,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::INTERVAL_FIELD;
- check_duplicates_in_interval("ENUM",sql_field->field_name,
- sql_field->interval,
- sql_field->charset, &dup_val_count);
+ if (check_duplicates_in_interval("ENUM",sql_field->field_name,
+ sql_field->interval,
+ sql_field->charset, &dup_val_count))
+ DBUG_RETURN(1);
break;
case MYSQL_TYPE_SET:
sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
@@ -2100,9 +2110,10 @@ int prepare_create_field(create_field *sql_field,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::BIT_FIELD;
- check_duplicates_in_interval("SET",sql_field->field_name,
- sql_field->interval,
- sql_field->charset, &dup_val_count);
+ if (check_duplicates_in_interval("SET",sql_field->field_name,
+ sql_field->interval,
+ sql_field->charset, &dup_val_count))
+ DBUG_RETURN(1);
/* Check that count of unique members is not more then 64 */
if (sql_field->interval->count - dup_val_count > sizeof(longlong)*8)
{
@@ -6782,7 +6793,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff);
/* We can abort alter table for any table type */
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= !ignore && test(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES));
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index c3635e24407..bc81679a7fd 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -745,6 +745,7 @@ bool st_select_lex::cleanup()
error= (bool) ((uint) error | (uint) lex_unit->cleanup());
}
non_agg_fields.empty();
+ inner_refs_list.empty();
DBUG_RETURN(error);
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 56c952f34ce..d0da52827e0 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -449,7 +449,7 @@ int mysql_update(THD *thd,
thd->proc_info="Updating";
transactional_table= table->file->has_transactions();
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= test(!ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
@@ -489,7 +489,7 @@ int mysql_update(THD *thd,
if (fill_record_n_invoke_before_triggers(thd, fields, values, 0,
table->triggers,
TRG_EVENT_UPDATE))
- break; /* purecov: inspected */
+ break; /* purecov: inspected */
found++;
@@ -550,7 +550,7 @@ int mysql_update(THD *thd,
if (!error)
{
updated++;
- thd->no_trans_update= !transactional_table;
+ thd->no_trans_update.stmt= !transactional_table;
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
@@ -676,11 +676,11 @@ int mysql_update(THD *thd,
transactional_table, FALSE) &&
transactional_table)
{
- error=1; // Rollback update
+ error=1; // Rollback update
}
}
if (!transactional_table)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
free_underlaid_joins(thd, select_lex);
if (transactional_table)
@@ -1045,7 +1045,7 @@ bool mysql_multi_update(THD *thd,
handle_duplicates, ignore)))
DBUG_RETURN(TRUE);
- thd->no_trans_update= 0;
+ thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= test(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES));
@@ -1370,7 +1370,7 @@ multi_update::~multi_update()
delete [] copy_field;
thd->count_cuted_fields= CHECK_FIELD_IGNORE; // Restore this setting
if (!trans_safe)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
@@ -1431,40 +1431,40 @@ bool multi_update::send_data(List<Item> &not_used_values)
else if (error == VIEW_CHECK_ERROR)
DBUG_RETURN(1);
}
- if (!updated++)
- {
- /*
- Inform the main table that we are going to update the table even
- while we may be scanning it. This will flush the read cache
- if it's used.
- */
- main_table->file->extra(HA_EXTRA_PREPARE_FOR_UPDATE);
- }
- if ((error=table->file->ha_update_row(table->record[1],
- table->record[0])))
- {
- updated--;
+ if (!updated++)
+ {
+ /*
+ Inform the main table that we are going to update the table even
+ while we may be scanning it. This will flush the read cache
+ if it's used.
+ */
+ main_table->file->extra(HA_EXTRA_PREPARE_FOR_UPDATE);
+ }
+ if ((error=table->file->ha_update_row(table->record[1],
+ table->record[0])))
+ {
+ updated--;
if (!ignore ||
table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
- {
+ {
/*
If (ignore && error == is ignorable) we don't have to
do anything; otherwise...
*/
if (table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
thd->fatal_error(); /* Other handler errors are fatal */
- table->file->print_error(error,MYF(0));
- DBUG_RETURN(1);
- }
- }
+ table->file->print_error(error,MYF(0));
+ DBUG_RETURN(1);
+ }
+ }
else
{
if (!table->file->has_transactions())
- thd->no_trans_update= 1;
+ thd->no_trans_update.stmt= TRUE;
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_AFTER, TRUE))
- DBUG_RETURN(1);
+ DBUG_RETURN(1);
}
}
}
@@ -1700,7 +1700,7 @@ bool multi_update::send_eof()
}
}
if (!transactional_tables)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->no_trans_update.all= TRUE;
}
if (transactional_tables)
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index f84847f2f9c..c02fb7bcdc0 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -496,35 +496,46 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
/*
Compare/check grants on view with grants of underlying tables
*/
+
+ fill_effective_table_privileges(thd, &view->grant, view->db,
+ view->table_name);
+
+ {
+ Item *report_item= NULL;
+ uint final_priv= VIEW_ANY_ACL;
+
for (sl= select_lex; sl; sl= sl->next_select())
{
DBUG_ASSERT(view->db); /* Must be set in the parser */
List_iterator_fast<Item> it(sl->item_list);
Item *item;
- fill_effective_table_privileges(thd, &view->grant, view->db,
- view->table_name);
while ((item= it++))
{
- Item_field *fld;
+ Item_field *fld= item->filed_for_view_update();
uint priv= (get_column_grant(thd, &view->grant, view->db,
view->table_name, item->name) &
VIEW_ANY_ACL);
- if ((fld= item->filed_for_view_update()))
+
+ if (fld && !fld->field->table->s->tmp_table)
{
- /*
- Do we have more privileges on view field then underlying table field?
- */
- if (!fld->field->table->s->tmp_table && (~fld->have_privileges & priv))
+ final_priv&= fld->have_privileges;
+
+ if (~fld->have_privileges & priv)
+ report_item= item;
+ }
+ }
+ }
+
+ if (!final_priv)
{
- /* VIEW column has more privileges */
+ DBUG_ASSERT(report_item);
+
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
"create view", thd->security_ctx->priv_user,
- thd->security_ctx->priv_host, item->name,
+ thd->security_ctx->priv_host, report_item->name,
view->table_name);
res= TRUE;
goto err;
- }
- }
}
}
#endif
@@ -1008,6 +1019,11 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
CHARSET_INFO *save_cs= thd->variables.character_set_client;
thd->variables.character_set_client= system_charset_info;
res= MYSQLparse((void *)thd);
+
+ if ((old_lex->sql_command == SQLCOM_SHOW_FIELDS) ||
+ (old_lex->sql_command == SQLCOM_SHOW_CREATE))
+ lex->sql_command= old_lex->sql_command;
+
thd->variables.character_set_client= save_cs;
thd->variables.sql_mode= save_mode;
}
@@ -1033,7 +1049,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
}
}
else if (!table->prelocking_placeholder &&
- old_lex->sql_command == SQLCOM_SHOW_CREATE &&
+ (old_lex->sql_command == SQLCOM_SHOW_CREATE) &&
!table->belong_to_view)
{
if (check_table_access(thd, SHOW_VIEW_ACL, table, 0))
diff --git a/sql/structs.h b/sql/structs.h
index 377d337dcfa..4cf9379d2bb 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -136,12 +136,11 @@ typedef struct st_read_record { /* Parameter to read_record */
/*
- Originally MySQL used TIME structure inside server only, but since
+ Originally MySQL used MYSQL_TIME structure inside server only, but since
4.1 it's exported to user in the new client API. Define aliases for
new names to keep existing code simple.
*/
-typedef struct st_mysql_time TIME;
typedef enum enum_mysql_timestamp_type timestamp_type;
diff --git a/sql/table.cc b/sql/table.cc
index c0b04093f36..39bdbb4cbb9 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2967,7 +2967,7 @@ void st_table_list::hide_view_error(THD *thd)
thd->net.last_errno == ER_NO_SUCH_TABLE)
{
TABLE_LIST *top= top_table();
- thd->clear_error();
+ thd->clear_error();
my_error(ER_VIEW_INVALID, MYF(0), top->view_db.str, top->view_name.str);
}
else if (thd->net.last_errno == ER_NO_DEFAULT_FOR_FIELD)
@@ -3323,7 +3323,8 @@ bool st_table_list::prepare_view_securety_context(THD *thd)
definer.host.str,
thd->db))
{
- if (thd->lex->sql_command == SQLCOM_SHOW_CREATE)
+ if ((thd->lex->sql_command == SQLCOM_SHOW_CREATE) ||
+ (thd->lex->sql_command == SQLCOM_SHOW_FIELDS))
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_NO_SUCH_USER,
diff --git a/sql/time.cc b/sql/time.cc
index ef2c87673d5..249de3b879b 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -96,7 +96,7 @@ int calc_weekday(long daynr,bool sunday_first_day_of_week)
next week is week 1.
*/
-uint calc_week(TIME *l_time, uint week_behaviour, uint *year)
+uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year)
{
uint days;
ulong daynr=calc_daynr(l_time->year,l_time->month,l_time->day);
@@ -214,7 +214,7 @@ ulong convert_month_to_period(ulong month)
/*
- Convert a timestamp string to a TIME value and produce a warning
+ Convert a timestamp string to a MYSQL_TIME value and produce a warning
if string was truncated during conversion.
NOTE
@@ -222,7 +222,7 @@ ulong convert_month_to_period(ulong month)
*/
timestamp_type
-str_to_datetime_with_warn(const char *str, uint length, TIME *l_time,
+str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time,
uint flags)
{
int was_cut;
@@ -235,13 +235,14 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time,
MODE_NO_ZERO_DATE))),
&was_cut);
if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR)
- make_truncated_value_warning(current_thd, str, length, ts_type, NullS);
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ str, length, ts_type, NullS);
return ts_type;
}
/*
- Convert a datetime from broken-down TIME representation to corresponding
+ Convert a datetime from broken-down MYSQL_TIME representation to corresponding
TIMESTAMP value.
SYNOPSIS
@@ -257,7 +258,7 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time,
0 - t contains datetime value which is out of TIMESTAMP range.
*/
-my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *in_dst_time_gap)
+my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_gap)
{
my_time_t timestamp;
@@ -276,20 +277,20 @@ my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *in_dst_time_gap)
/*
- Convert a time string to a TIME struct and produce a warning
+ Convert a time string to a MYSQL_TIME struct and produce a warning
if string was cut during conversion.
NOTE
See str_to_time() for more info.
*/
bool
-str_to_time_with_warn(const char *str, uint length, TIME *l_time)
+str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time)
{
int warning;
bool ret_val= str_to_time(str, length, l_time, &warning);
if (ret_val || warning)
- make_truncated_value_warning(current_thd, str, length,
- MYSQL_TIMESTAMP_TIME, NullS);
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ str, length, MYSQL_TIMESTAMP_TIME, NullS);
return ret_val;
}
@@ -298,7 +299,7 @@ str_to_time_with_warn(const char *str, uint length, TIME *l_time)
Convert a system time structure to TIME
*/
-void localtime_to_TIME(TIME *to, struct tm *from)
+void localtime_to_TIME(MYSQL_TIME *to, struct tm *from)
{
to->neg=0;
to->second_part=0;
@@ -310,7 +311,7 @@ void localtime_to_TIME(TIME *to, struct tm *from)
to->second= (int) from->tm_sec;
}
-void calc_time_from_sec(TIME *to, long seconds, long microseconds)
+void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds)
{
long t_seconds;
// to->neg is not cleared, it may already be set to a useful value
@@ -684,7 +685,7 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
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 TIME structure members are
+ 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
@@ -692,7 +693,7 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
****************************************************************************/
void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)),
- const TIME *l_time, String *str)
+ const MYSQL_TIME *l_time, String *str)
{
uint length= (uint) my_time_to_str(l_time, (char*) str->ptr());
str->length(length);
@@ -701,7 +702,7 @@ void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)),
void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)),
- const TIME *l_time, String *str)
+ const MYSQL_TIME *l_time, String *str)
{
uint length= (uint) my_date_to_str(l_time, (char*) str->ptr());
str->length(length);
@@ -710,7 +711,7 @@ void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)),
void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)),
- const TIME *l_time, String *str)
+ const MYSQL_TIME *l_time, String *str)
{
uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr());
str->length(length);
@@ -718,7 +719,8 @@ void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)),
}
-void make_truncated_value_warning(THD *thd, const char *str_val,
+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)
{
@@ -757,14 +759,14 @@ void make_truncated_value_warning(THD *thd, const char *str_val,
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
ER(ER_WRONG_VALUE), type_str, str.c_ptr());
}
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ 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(TIME *ltime, interval_type int_type, INTERVAL interval)
+bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval)
{
long period, sign;
@@ -888,7 +890,7 @@ invalid_date:
NOTE
This function calculates difference between l_time1 and l_time2 absolute
values. So one should set l_sign and correct result if he want to take
- signs into account (i.e. for TIME values).
+ signs into account (i.e. for MYSQL_TIME values).
RETURN VALUES
Returns sign of difference.
@@ -898,7 +900,7 @@ invalid_date:
*/
bool
-calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, longlong *seconds_out,
+calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, longlong *seconds_out,
long *microseconds_out)
{
long days;
@@ -948,7 +950,7 @@ calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, longlong *seconds_out,
/*
- Compares 2 TIME structures
+ Compares 2 MYSQL_TIME structures
SYNOPSIS
my_time_compare()
@@ -966,7 +968,7 @@ calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, longlong *seconds_out,
*/
int
-my_time_compare(TIME *a, TIME *b)
+my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b)
{
my_ulonglong a_t= TIME_to_ulonglong_datetime(a);
my_ulonglong b_t= TIME_to_ulonglong_datetime(b);
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 65a1a59a5d0..08b93cfd203 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -77,7 +77,7 @@ typedef struct lsinfo
/*
Structure with information describing ranges of my_time_t shifted to local
- time (my_time_t + offset). Used for local TIME -> my_time_t conversion.
+ time (my_time_t + offset). Used for local MYSQL_TIME -> my_time_t conversion.
See comments for TIME_to_gmt_sec() for more info.
*/
typedef struct revtinfo
@@ -292,9 +292,9 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
be used if there are no transitions or we have moment in time before
any transitions.
Second task is to build "shifted my_time_t" -> my_time_t map used in
- TIME -> my_time_t conversion.
+ MYSQL_TIME -> my_time_t conversion.
Note: See description of TIME_to_gmt_sec() function first.
- In order to perform TIME -> my_time_t conversion we need to build table
+ In order to perform MYSQL_TIME -> my_time_t conversion we need to build table
which defines "shifted by tz offset and leap seconds my_time_t" ->
my_time_t function wich is almost the same (except ranges of ambiguity)
as reverse function to piecewise linear function used for my_time_t ->
@@ -531,14 +531,14 @@ static const uint year_lengths[2]=
offset - local time zone offset
DESCRIPTION
- Convert my_time_t with offset to TIME struct. Differs from timesub
+ Convert my_time_t with offset to MYSQL_TIME struct. Differs from timesub
(from elsie code) because doesn't contain any leap correction and
TM_GMTOFF and is_dst setting and contains some MySQL specific
initialization. Funny but with removing of these we almost have
glibc's offtime function.
*/
static void
-sec_to_TIME(TIME * tmp, my_time_t t, long offset)
+sec_to_TIME(MYSQL_TIME * tmp, my_time_t t, long offset)
{
long days;
long rem;
@@ -594,7 +594,7 @@ sec_to_TIME(TIME * tmp, my_time_t t, long offset)
tmp->month++;
tmp->day= (uint)(days + 1);
- /* filling MySQL specific TIME members */
+ /* filling MySQL specific MYSQL_TIME members */
tmp->neg= 0; tmp->second_part= 0;
tmp->time_type= MYSQL_TIMESTAMP_DATETIME;
}
@@ -686,7 +686,7 @@ find_transition_type(my_time_t t, const TIME_ZONE_INFO *sp)
/*
Converts time in my_time_t representation (seconds in UTC since Epoch) to
- broken down TIME representation in local time zone.
+ broken down MYSQL_TIME representation in local time zone.
SYNOPSIS
gmt_sec_to_TIME()
@@ -701,12 +701,12 @@ find_transition_type(my_time_t t, const TIME_ZONE_INFO *sp)
(60th and 61st second, look how we calculate them as "hit" in this
function).
Under realistic assumptions about frequency of transitions the same array
- can be used fot TIME -> my_time_t conversion. For this we need to
+ can be used fot MYSQL_TIME -> my_time_t conversion. For this we need to
implement tweaked binary search which will take into account that some
- TIME has two matching my_time_t ranges and some of them have none.
+ MYSQL_TIME has two matching my_time_t ranges and some of them have none.
*/
static void
-gmt_sec_to_TIME(TIME *tmp, my_time_t sec_in_utc, const TIME_ZONE_INFO *sp)
+gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t sec_in_utc, const TIME_ZONE_INFO *sp)
{
const TRAN_TYPE_INFO *ttisp;
const LS_INFO *lp;
@@ -809,11 +809,11 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec)
/*
- Works like sec_since_epoch but expects TIME structure as parameter.
+ Works like sec_since_epoch but expects MYSQL_TIME structure as parameter.
*/
my_time_t
-sec_since_epoch_TIME(TIME *t)
+sec_since_epoch_TIME(MYSQL_TIME *t)
{
return sec_since_epoch(t->year, t->month, t->day,
t->hour, t->minute, t->second);
@@ -821,7 +821,7 @@ sec_since_epoch_TIME(TIME *t)
/*
- Converts local time in broken down TIME representation to my_time_t
+ Converts local time in broken down MYSQL_TIME representation to my_time_t
representation.
SYNOPSIS
@@ -863,7 +863,7 @@ sec_since_epoch_TIME(TIME *t)
We use completely different approach. It is better since it is both
faster than iterative implementations and fully determenistic. If you
- look at my_time_t to TIME conversion then you'll find that it consist
+ look at my_time_t to MYSQL_TIME conversion then you'll find that it consist
of two steps:
The first is calculating shifted my_time_t value and the second - TIME
calculation from shifted my_time_t value (well it is a bit simplified
@@ -893,7 +893,7 @@ sec_since_epoch_TIME(TIME *t)
0 in case of error.
*/
static my_time_t
-TIME_to_gmt_sec(const TIME *t, const TIME_ZONE_INFO *sp,
+TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
my_bool *in_dst_time_gap)
{
my_time_t local_t;
@@ -1020,20 +1020,20 @@ class Time_zone_system : public Time_zone
{
public:
Time_zone_system() {} /* Remove gcc warning */
- virtual my_time_t TIME_to_gmt_sec(const TIME *t,
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
my_bool *in_dst_time_gap) const;
- virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const;
+ virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
};
/*
- Converts local time in system time zone in TIME representation
+ Converts local time in system time zone in MYSQL_TIME representation
to its my_time_t representation.
SYNOPSIS
TIME_to_gmt_sec()
- t - pointer to TIME structure with local time in
+ 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
@@ -1041,7 +1041,7 @@ public:
DESCRIPTION
This method uses system function (localtime_r()) for conversion
- local time in system time zone in TIME structure to its my_time_t
+ local time in system time zone in MYSQL_TIME structure to its my_time_t
representation. Unlike the same function for Time_zone_db class
it it won't handle unnormalized input properly. Still it will
return lowest possible my_time_t in case of ambiguity or if we
@@ -1053,7 +1053,7 @@ public:
Corresponding my_time_t value or 0 in case of error
*/
my_time_t
-Time_zone_system::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_system::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
{
long not_used;
return my_system_gmt_sec(t, &not_used, in_dst_time_gap);
@@ -1066,7 +1066,7 @@ Time_zone_system::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
SYNOPSIS
gmt_sec_to_TIME()
- tmp - pointer to TIME structure to fill-in
+ tmp - pointer to MYSQL_TIME structure to fill-in
t - my_time_t value to be converted
NOTE
@@ -1077,7 +1077,7 @@ Time_zone_system::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
the 1902 easily.
*/
void
-Time_zone_system::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const
+Time_zone_system::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
{
struct tm tmp_tm;
time_t tmp_t= (time_t)t;
@@ -1107,26 +1107,26 @@ Time_zone_system::get_name() const
/*
Instance of this class represents UTC time zone. It uses system gmtime_r
function for conversions and is always available. It is used only for
- my_time_t -> TIME conversions in various UTC_... functions, it is not
- intended for TIME -> my_time_t conversions and shouldn't be exposed to user.
+ my_time_t -> MYSQL_TIME conversions in various UTC_... functions, it is not
+ intended for MYSQL_TIME -> my_time_t conversions and shouldn't be exposed to user.
*/
class Time_zone_utc : public Time_zone
{
public:
Time_zone_utc() {} /* Remove gcc warning */
- virtual my_time_t TIME_to_gmt_sec(const TIME *t,
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
my_bool *in_dst_time_gap) const;
- virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const;
+ virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
};
/*
- Convert UTC time from TIME representation to its my_time_t representation.
+ Convert UTC time from MYSQL_TIME representation to its my_time_t representation.
SYNOPSIS
TIME_to_gmt_sec()
- t - pointer to TIME structure with local time
+ 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
@@ -1141,7 +1141,7 @@ public:
0
*/
my_time_t
-Time_zone_utc::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_utc::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
{
/* Should be never called */
DBUG_ASSERT(0);
@@ -1155,14 +1155,14 @@ Time_zone_utc::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
SYNOPSIS
gmt_sec_to_TIME()
- tmp - pointer to TIME structure to fill-in
+ tmp - pointer to MYSQL_TIME structure to fill-in
t - my_time_t value to be converted
NOTE
See note for apropriate Time_zone_system method.
*/
void
-Time_zone_utc::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const
+Time_zone_utc::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
{
struct tm tmp_tm;
time_t tmp_t= (time_t)t;
@@ -1203,9 +1203,9 @@ 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 TIME *t,
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
my_bool *in_dst_time_gap) const;
- virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const;
+ virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
private:
TIME_ZONE_INFO *tz_info;
@@ -1239,7 +1239,7 @@ Time_zone_db::Time_zone_db(TIME_ZONE_INFO *tz_info_arg,
SYNOPSIS
TIME_to_gmt_sec()
- t - pointer to TIME structure with local time
+ 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
@@ -1253,7 +1253,7 @@ 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 TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_db::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
{
return ::TIME_to_gmt_sec(t, tz_info, in_dst_time_gap);
}
@@ -1265,11 +1265,11 @@ Time_zone_db::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
SYNOPSIS
gmt_sec_to_TIME()
- tmp - pointer to TIME structure to fill-in
+ tmp - pointer to MYSQL_TIME structure to fill-in
t - my_time_t value to be converted
*/
void
-Time_zone_db::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const
+Time_zone_db::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
{
::gmt_sec_to_TIME(tmp, t, tz_info);
}
@@ -1299,9 +1299,9 @@ class Time_zone_offset : public Time_zone
{
public:
Time_zone_offset(long tz_offset_arg);
- virtual my_time_t TIME_to_gmt_sec(const TIME *t,
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
my_bool *in_dst_time_gap) const;
- virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const;
+ virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
/*
This have to be public because we want to be able to access it from
@@ -1336,11 +1336,11 @@ Time_zone_offset::Time_zone_offset(long tz_offset_arg):
/*
Converts local time in time zone described as offset from UTC
- from TIME representation to its my_time_t representation.
+ from MYSQL_TIME representation to its my_time_t representation.
SYNOPSIS
TIME_to_gmt_sec()
- t - pointer to TIME structure with local time
+ 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
@@ -1352,7 +1352,7 @@ Time_zone_offset::Time_zone_offset(long tz_offset_arg):
Corresponding my_time_t value or 0 in case of error
*/
my_time_t
-Time_zone_offset::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
{
my_time_t local_t;
int shift= 0;
@@ -1397,11 +1397,11 @@ Time_zone_offset::TIME_to_gmt_sec(const TIME *t, my_bool *in_dst_time_gap) const
SYNOPSIS
gmt_sec_to_TIME()
- tmp - pointer to TIME structure to fill-in
+ tmp - pointer to MYSQL_TIME structure to fill-in
t - my_time_t value to be converted
*/
void
-Time_zone_offset::gmt_sec_to_TIME(TIME *tmp, my_time_t t) const
+Time_zone_offset::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const
{
sec_to_TIME(tmp, t, offset);
}
@@ -2564,7 +2564,7 @@ main(int argc, char **argv)
my_bool localtime_negative;
TIME_ZONE_INFO tz_info;
struct tm tmp;
- TIME time_tmp;
+ MYSQL_TIME time_tmp;
time_t t, t1, t2;
char fullname[FN_REFLEN+1];
char *str_end;
diff --git a/sql/tztime.h b/sql/tztime.h
index b6af4b37468..f7cc7042d79 100644
--- a/sql/tztime.h
+++ b/sql/tztime.h
@@ -22,7 +22,7 @@
/*
This class represents abstract time zone and provides
- basic interface for TIME <-> my_time_t conversion.
+ basic interface for MYSQL_TIME <-> my_time_t conversion.
Actual time zones which are specified by DB, or via offset
or use system functions are its descendants.
*/
@@ -31,18 +31,18 @@ class Time_zone: public Sql_alloc
public:
Time_zone() {} /* Remove gcc warning */
/*
- Converts local time in broken down TIME representation to
+ 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).
*/
- virtual my_time_t TIME_to_gmt_sec(const TIME *t,
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
my_bool *in_dst_time_gap) const = 0;
/*
Converts time in my_time_t representation to local time in
- broken down TIME representation.
+ broken down MYSQL_TIME representation.
*/
- virtual void gmt_sec_to_TIME(TIME *tmp, my_time_t t) const = 0;
+ virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const = 0;
/*
Because of constness of String returned by get_name() time zone name
have to be already zeroended to be able to use String::ptr() instead
@@ -62,7 +62,7 @@ extern Time_zone * my_tz_SYSTEM;
extern Time_zone * my_tz_find(THD *thd, const String *name);
extern my_bool my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap);
extern void my_tz_free();
-extern my_time_t sec_since_epoch_TIME(TIME *t);
+extern my_time_t sec_since_epoch_TIME(MYSQL_TIME *t);
/*
Number of elements in table list produced by my_tz_get_table_list()
diff --git a/sql/unireg.cc b/sql/unireg.cc
index d90420313a6..a69a9be6a43 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -936,7 +936,9 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
(regfield->real_type() != MYSQL_TYPE_YEAR ||
field->def->val_int() != 0))
{
- if (field->def->save_in_field(regfield, 1))
+ int res= field->def->save_in_field(regfield, 1);
+ /* If not ok or warning of level 'note' */
+ if (res != 0 && res != 3)
{
my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name);
error= 1;
diff --git a/storage/ndb/include/kernel/AttributeHeader.hpp b/storage/ndb/include/kernel/AttributeHeader.hpp
index 8ee1e33d851..613e3d19d1b 100644
--- a/storage/ndb/include/kernel/AttributeHeader.hpp
+++ b/storage/ndb/include/kernel/AttributeHeader.hpp
@@ -47,6 +47,7 @@ public:
STATIC_CONST( FRAGMENT_VARSIZED_MEMORY = 0xFFF4 );
// 0xFFF3 to be used for read packed when merged
STATIC_CONST( ANY_VALUE = 0xFFF2 );
+ STATIC_CONST( COPY_ROWID = 0xFFF1 );
// NOTE: in 5.1 ctors and init take size in bytes
diff --git a/storage/ndb/include/kernel/signaldata/SumaImpl.hpp b/storage/ndb/include/kernel/signaldata/SumaImpl.hpp
index 2ed9d8cddc6..94775a5f3f4 100644
--- a/storage/ndb/include/kernel/signaldata/SumaImpl.hpp
+++ b/storage/ndb/include/kernel/signaldata/SumaImpl.hpp
@@ -119,7 +119,8 @@ struct SubStartRef {
Undefined = 1,
NF_FakeErrorREF = 11,
Busy = 701,
- NotMaster = 702
+ NotMaster = 702,
+ PartiallyConnected = 1421
};
STATIC_CONST( SignalLength = 7 );
diff --git a/storage/ndb/include/ndbapi/Ndb.hpp b/storage/ndb/include/ndbapi/Ndb.hpp
index 80662f901b1..10b7b0ea581 100644
--- a/storage/ndb/include/ndbapi/Ndb.hpp
+++ b/storage/ndb/include/ndbapi/Ndb.hpp
@@ -1055,6 +1055,18 @@ class Ndb
friend class NdbDictInterface;
friend class NdbBlob;
friend class NdbImpl;
+ friend class Ndb_free_list_t<NdbRecAttr>;
+ friend class Ndb_free_list_t<NdbApiSignal>;
+ friend class Ndb_free_list_t<NdbLabel>;
+ friend class Ndb_free_list_t<NdbBranch>;
+ friend class Ndb_free_list_t<NdbSubroutine>;
+ friend class Ndb_free_list_t<NdbCall>;
+ friend class Ndb_free_list_t<NdbBlob>;
+ friend class Ndb_free_list_t<NdbReceiver>;
+ friend class Ndb_free_list_t<NdbIndexScanOperation>;
+ friend class Ndb_free_list_t<NdbOperation>;
+ friend class Ndb_free_list_t<NdbIndexOperation>;
+ friend class Ndb_free_list_t<NdbTransaction>;
#endif
public:
@@ -1104,7 +1116,7 @@ public:
*
* @param aCatalogName is the new name of the current catalog
*/
- void setCatalogName(const char * aCatalogName);
+ int setCatalogName(const char * aCatalogName);
/**
* The current schema name can be fetched by getSchemaName.
@@ -1118,7 +1130,7 @@ public:
*
* @param aSchemaName is the new name of the current schema
*/
- void setSchemaName(const char * aSchemaName);
+ int setSchemaName(const char * aSchemaName);
#endif
/**
@@ -1133,7 +1145,7 @@ public:
*
* @param aDatabaseName is the new name of the current database
*/
- void setDatabaseName(const char * aDatabaseName);
+ int setDatabaseName(const char * aDatabaseName);
/**
* The current database schema name can be fetched by getDatabaseSchemaName.
@@ -1147,7 +1159,7 @@ public:
*
* @param aDatabaseSchemaName is the new name of the current database schema
*/
- void setDatabaseSchemaName(const char * aDatabaseSchemaName);
+ int setDatabaseSchemaName(const char * aDatabaseSchemaName);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** Set database and schema name to match previously retrieved table
diff --git a/storage/ndb/include/ndbapi/NdbDictionary.hpp b/storage/ndb/include/ndbapi/NdbDictionary.hpp
index b1bdec6cace..02dcf81a413 100644
--- a/storage/ndb/include/ndbapi/NdbDictionary.hpp
+++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp
@@ -429,7 +429,7 @@ public:
* Set name of column
* @param name Name of the column
*/
- void setName(const char * name);
+ int setName(const char * name);
/**
* Set whether column is nullable or not
@@ -520,7 +520,7 @@ public:
void setAutoIncrement(bool);
bool getAutoIncrement() const;
void setAutoIncrementInitialValue(Uint64 val);
- void setDefaultValue(const char*);
+ int setDefaultValue(const char*);
const char* getDefaultValue() const;
static const Column * FRAGMENT;
@@ -535,6 +535,7 @@ public:
static const Column * ROWID;
static const Column * ROW_GCI;
static const Column * ANY_VALUE;
+ static const Column * COPY_ROWID;
int getSizeInBytes() const;
#endif
@@ -759,13 +760,13 @@ public:
* Name of table
* @param name Name of table
*/
- void setName(const char * name);
+ int setName(const char * name);
/**
* Add a column definition to a table
* @note creates a copy
*/
- void addColumn(const Column &);
+ int addColumn(const Column &);
/**
* @see NdbDictionary::Table::getLogging.
@@ -819,9 +820,9 @@ public:
*/
void setMaxLoadFactor(int);
- void setTablespaceName(const char * name);
+ int setTablespaceName(const char * name);
const char * getTablespaceName() const;
- void setTablespace(const class Tablespace &);
+ int setTablespace(const class Tablespace &);
bool getTablespace(Uint32 *id= 0, Uint32 *version= 0) const;
/**
@@ -854,7 +855,7 @@ public:
/**
* Set frm file to store with this table
*/
- void setFrm(const void* data, Uint32 len);
+ int setFrm(const void* data, Uint32 len);
/**
* Set array of fragment information containing
@@ -862,12 +863,12 @@ public:
* Node group identity
* Fragment State
*/
- void setFragmentData(const void* data, Uint32 len);
+ int setFragmentData(const void* data, Uint32 len);
/**
* Set/Get tablespace names per fragment
*/
- void setTablespaceNames(const void* data, Uint32 len);
+ int setTablespaceNames(const void* data, Uint32 len);
const void *getTablespaceNames();
Uint32 getTablespaceNamesLen() const;
@@ -875,7 +876,7 @@ public:
* Set tablespace information per fragment
* Contains a tablespace id and a tablespace version
*/
- void setTablespaceData(const void* data, Uint32 len);
+ int setTablespaceData(const void* data, Uint32 len);
/**
* Set array of information mapping range values and list values
@@ -884,7 +885,7 @@ public:
* one pair per fragment. For list partitions it could be any number
* of pairs, at least as many as there are fragments.
*/
- void setRangeListData(const void* data, Uint32 len);
+ int setRangeListData(const void* data, Uint32 len);
/**
* Set table object type
@@ -1099,26 +1100,26 @@ public:
/**
* Set the name of an index
*/
- void setName(const char * name);
+ int setName(const char * name);
/**
* Define the name of the table to be indexed
*/
- void setTable(const char * name);
+ int setTable(const char * name);
/**
* Add a column to the index definition
* Note that the order of columns will be in
* the order they are added (only matters for ordered indexes).
*/
- void addColumn(const Column & c);
+ int addColumn(const Column & c);
/**
* Add a column name to the index definition
* Note that the order of indexes will be in
* the order they are added (only matters for ordered indexes).
*/
- void addColumnName(const char * name);
+ int addColumnName(const char * name);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
@@ -1127,7 +1128,7 @@ public:
* the order they are added (only matters for ordered indexes).
* Depricated, use addColumnName instead.
*/
- void addIndexColumn(const char * name);
+ int addIndexColumn(const char * name);
#endif
/**
@@ -1135,7 +1136,7 @@ public:
* Note that the order of indexes will be in
* the order they are added (only matters for ordered indexes).
*/
- void addColumnNames(unsigned noOfNames, const char ** names);
+ int addColumnNames(unsigned noOfNames, const char ** names);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
@@ -1144,7 +1145,7 @@ public:
* the order they are added (only matters for ordered indexes).
* Depricated, use addColumnNames instead.
*/
- void addIndexColumns(int noOfNames, const char ** names);
+ int addIndexColumns(int noOfNames, const char ** names);
#endif
/**
@@ -1281,7 +1282,7 @@ public:
/**
* Set unique identifier for the event
*/
- void setName(const char *name);
+ int setName(const char *name);
/**
* Get unique identifier for the event
*/
@@ -1308,7 +1309,7 @@ public:
* @note preferred way is using setTable(const NdbDictionary::Table&)
* or constructor with table object parameter
*/
- void setTable(const char *tableName);
+ int setTable(const char *tableName);
/**
* Get table name for events
*
@@ -1534,8 +1535,8 @@ public:
Uint64 getSize() const;
Uint64 getFree() const;
- void setTablespace(const char * name);
- void setTablespace(const class Tablespace &);
+ int setTablespace(const char * name);
+ int setTablespace(const class Tablespace &);
const char * getTablespace() const;
void getTablespaceId(ObjectId * dst) const;
diff --git a/storage/ndb/include/ndbapi/NdbRecAttr.hpp b/storage/ndb/include/ndbapi/NdbRecAttr.hpp
index adaddd2dab3..ac098831180 100644
--- a/storage/ndb/include/ndbapi/NdbRecAttr.hpp
+++ b/storage/ndb/include/ndbapi/NdbRecAttr.hpp
@@ -302,13 +302,6 @@ NdbRecAttr::int32_value() const
}
inline
-Int32
-NdbRecAttr::medium_value() const
-{
- return sint3korr((unsigned char *)theRef);
-}
-
-inline
short
NdbRecAttr::short_value() const
{
@@ -330,13 +323,6 @@ NdbRecAttr::u_32_value() const
}
inline
-Uint32
-NdbRecAttr::u_medium_value() const
-{
- return uint3korr((unsigned char*)theRef);
-}
-
-inline
Uint16
NdbRecAttr::u_short_value() const
{
diff --git a/storage/ndb/include/ndbapi/NdbReceiver.hpp b/storage/ndb/include/ndbapi/NdbReceiver.hpp
index 0af55c88f68..b8abd281496 100644
--- a/storage/ndb/include/ndbapi/NdbReceiver.hpp
+++ b/storage/ndb/include/ndbapi/NdbReceiver.hpp
@@ -38,7 +38,7 @@ public:
};
NdbReceiver(Ndb *aNdb);
- void init(ReceiverType type, void* owner);
+ int init(ReceiverType type, void* owner);
void release();
~NdbReceiver();
@@ -75,7 +75,7 @@ private:
* At setup
*/
class NdbRecAttr * getValue(const class NdbColumnImpl*, char * user_dst_ptr);
- void do_get_value(NdbReceiver*, Uint32 rows, Uint32 key_size, Uint32 range);
+ int do_get_value(NdbReceiver*, Uint32 rows, Uint32 key_size, Uint32 range);
void prepareSend();
void calculate_batch_size(Uint32, Uint32, Uint32&, Uint32&, Uint32&);
diff --git a/storage/ndb/include/ndbapi/NdbTransaction.hpp b/storage/ndb/include/ndbapi/NdbTransaction.hpp
index 56d0801d507..07a46199ecc 100644
--- a/storage/ndb/include/ndbapi/NdbTransaction.hpp
+++ b/storage/ndb/include/ndbapi/NdbTransaction.hpp
@@ -575,7 +575,7 @@ private:
NdbTransaction(Ndb* aNdb);
~NdbTransaction();
- void init(); // Initialize connection object for new transaction
+ int init(); // Initialize connection object for new transaction
int executeNoBlobs(ExecType execType,
NdbOperation::AbortOption = NdbOperation::DefaultAbortOption,
diff --git a/storage/ndb/include/util/BaseString.hpp b/storage/ndb/include/util/BaseString.hpp
index 50abecc6e90..0c41f254edc 100644
--- a/storage/ndb/include/util/BaseString.hpp
+++ b/storage/ndb/include/util/BaseString.hpp
@@ -188,6 +188,7 @@ public:
private:
char* m_chr;
unsigned m_len;
+ friend bool operator!(const BaseString& str);
};
inline const char*
@@ -261,6 +262,12 @@ BaseString::operator!=(const char *str) const
return strcmp(m_chr, str) != 0;
}
+inline bool
+operator!(const BaseString& str)
+{
+ return str.m_chr == NULL;
+}
+
inline BaseString&
BaseString::assign(const BaseString& str)
{
diff --git a/storage/ndb/include/util/Vector.hpp b/storage/ndb/include/util/Vector.hpp
index 1a3767402e3..7ae4228985d 100644
--- a/storage/ndb/include/util/Vector.hpp
+++ b/storage/ndb/include/util/Vector.hpp
@@ -29,7 +29,7 @@ public:
const T& operator[](unsigned i) const;
unsigned size() const { return m_size; };
- void push_back(const T &);
+ int push_back(const T &);
void push(const T&, unsigned pos);
T& set(T&, unsigned pos, T& fill_obj);
T& back();
@@ -38,7 +38,7 @@ public:
void clear();
- void fill(unsigned new_size, T & obj);
+ int fill(unsigned new_size, T & obj);
Vector<T>& operator=(const Vector<T>&);
@@ -54,6 +54,14 @@ private:
template<class T>
Vector<T>::Vector(int i){
m_items = new T[i];
+ if (m_items == NULL)
+ {
+ errno = ENOMEM;
+ m_size = 0;
+ m_arraySize = 0;
+ m_incSize = 0;
+ return;
+ }
m_size = 0;
m_arraySize = i;
m_incSize = 50;
@@ -91,12 +99,15 @@ Vector<T>::back(){
}
template<class T>
-void
+int
Vector<T>::push_back(const T & t){
if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize];
- if(!tmp)
- abort();
+ if(tmp == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k];
delete[] m_items;
@@ -105,6 +116,7 @@ Vector<T>::push_back(const T & t){
}
m_items[m_size] = t;
m_size++;
+ return 0;
}
template<class T>
@@ -150,10 +162,12 @@ Vector<T>::clear(){
}
template<class T>
-void
+int
Vector<T>::fill(unsigned new_size, T & obj){
while(m_size <= new_size)
- push_back(obj);
+ if (push_back(obj))
+ return -1;
+ return 0;
}
template<class T>
@@ -177,8 +191,8 @@ struct MutexVector : public NdbLockable {
const T& operator[](unsigned i) const;
unsigned size() const { return m_size; };
- void push_back(const T &);
- void push_back(const T &, bool lockMutex);
+ int push_back(const T &);
+ int push_back(const T &, bool lockMutex);
T& back();
void erase(unsigned index);
@@ -187,7 +201,7 @@ struct MutexVector : public NdbLockable {
void clear();
void clear(bool lockMutex);
- void fill(unsigned new_size, T & obj);
+ int fill(unsigned new_size, T & obj);
private:
T * m_items;
unsigned m_size;
@@ -198,6 +212,14 @@ private:
template<class T>
MutexVector<T>::MutexVector(int i){
m_items = new T[i];
+ if (m_items == NULL)
+ {
+ errno = ENOMEM;
+ m_size = 0;
+ m_arraySize = 0;
+ m_incSize = 0;
+ return;
+ }
m_size = 0;
m_arraySize = i;
m_incSize = 50;
@@ -235,11 +257,17 @@ MutexVector<T>::back(){
}
template<class T>
-void
+int
MutexVector<T>::push_back(const T & t){
lock();
if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize];
+ if (tmp == NULL)
+ {
+ errno = ENOMEM;
+ unlock();
+ return -1;
+ }
for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k];
delete[] m_items;
@@ -249,15 +277,23 @@ MutexVector<T>::push_back(const T & t){
m_items[m_size] = t;
m_size++;
unlock();
+ return 0;
}
template<class T>
-void
+int
MutexVector<T>::push_back(const T & t, bool lockMutex){
if(lockMutex)
lock();
if(m_size == m_arraySize){
T * tmp = new T [m_arraySize + m_incSize];
+ if (tmp == NULL)
+ {
+ errno = ENOMEM;
+ if(lockMutex)
+ unlock();
+ return -1;
+ }
for (unsigned k = 0; k < m_size; k++)
tmp[k] = m_items[k];
delete[] m_items;
@@ -268,6 +304,7 @@ MutexVector<T>::push_back(const T & t, bool lockMutex){
m_size++;
if(lockMutex)
unlock();
+ return 0;
}
template<class T>
@@ -315,10 +352,12 @@ MutexVector<T>::clear(bool l){
}
template<class T>
-void
+int
MutexVector<T>::fill(unsigned new_size, T & obj){
while(m_size <= new_size)
- push_back(obj);
+ if (push_back(obj))
+ return -1;
+ return 0;
}
#endif
diff --git a/storage/ndb/src/common/util/BaseString.cpp b/storage/ndb/src/common/util/BaseString.cpp
index 6f20ae6a002..7e5adf0e9ef 100644
--- a/storage/ndb/src/common/util/BaseString.cpp
+++ b/storage/ndb/src/common/util/BaseString.cpp
@@ -16,19 +16,36 @@
/* -*- c-basic-offset: 4; -*- */
#include <ndb_global.h>
#include <BaseString.hpp>
-#include <basestring_vsnprintf.h>
+#include "basestring_vsnprintf.h"
BaseString::BaseString()
{
m_chr = new char[1];
+ if (m_chr == NULL)
+ {
+ errno = ENOMEM;
+ m_len = 0;
+ return;
+ }
m_chr[0] = 0;
m_len = 0;
}
BaseString::BaseString(const char* s)
{
+ if (s == NULL)
+ {
+ m_chr = NULL;
+ m_len = 0;
+ }
const size_t n = strlen(s);
m_chr = new char[n + 1];
+ if (m_chr == NULL)
+ {
+ errno = ENOMEM;
+ m_len = 0;
+ return;
+ }
memcpy(m_chr, s, n + 1);
m_len = n;
}
@@ -37,7 +54,20 @@ BaseString::BaseString(const BaseString& str)
{
const char* const s = str.m_chr;
const size_t n = str.m_len;
+ if (s == NULL)
+ {
+ m_chr = NULL;
+ m_len = 0;
+ return;
+ }
char* t = new char[n + 1];
+ if (t == NULL)
+ {
+ errno = ENOMEM;
+ m_chr = NULL;
+ m_len = 0;
+ return;
+ }
memcpy(t, s, n + 1);
m_chr = t;
m_len = n;
@@ -51,9 +81,23 @@ BaseString::~BaseString()
BaseString&
BaseString::assign(const char* s)
{
- const size_t n = strlen(s);
+ if (s == NULL)
+ {
+ m_chr = NULL;
+ m_len = 0;
+ return *this;
+ }
+ size_t n = strlen(s);
char* t = new char[n + 1];
- memcpy(t, s, n + 1);
+ if (t)
+ {
+ memcpy(t, s, n + 1);
+ }
+ else
+ {
+ errno = ENOMEM;
+ n = 0;
+ }
delete[] m_chr;
m_chr = t;
m_len = n;
@@ -64,8 +108,16 @@ BaseString&
BaseString::assign(const char* s, size_t n)
{
char* t = new char[n + 1];
- memcpy(t, s, n);
- t[n] = 0;
+ if (t)
+ {
+ memcpy(t, s, n);
+ t[n] = 0;
+ }
+ else
+ {
+ errno = ENOMEM;
+ n = 0;
+ }
delete[] m_chr;
m_chr = t;
m_len = n;
@@ -83,10 +135,19 @@ BaseString::assign(const BaseString& str, size_t n)
BaseString&
BaseString::append(const char* s)
{
- const size_t n = strlen(s);
+ size_t n = strlen(s);
char* t = new char[m_len + n + 1];
- memcpy(t, m_chr, m_len);
- memcpy(t + m_len, s, n + 1);
+ if (t)
+ {
+ memcpy(t, m_chr, m_len);
+ memcpy(t + m_len, s, n + 1);
+ }
+ else
+ {
+ errno = ENOMEM;
+ m_len = 0;
+ n = 0;
+ }
delete[] m_chr;
m_chr = t;
m_len += n;
@@ -130,8 +191,14 @@ BaseString::assfmt(const char *fmt, ...)
l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap);
if(l > (int)m_len) {
+ char *t = new char[l];
+ if (t == NULL)
+ {
+ errno = ENOMEM;
+ return *this;
+ }
delete[] m_chr;
- m_chr = new char[l];
+ m_chr = t;
}
va_start(ap, fmt);
basestring_vsnprintf(m_chr, l, fmt, ap);
@@ -155,6 +222,11 @@ BaseString::appfmt(const char *fmt, ...)
l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap);
char *tmp = new char[l];
+ if (tmp == NULL)
+ {
+ errno = ENOMEM;
+ return *this;
+ }
va_start(ap, fmt);
basestring_vsnprintf(tmp, l, fmt, ap);
va_end(ap);
@@ -242,9 +314,28 @@ BaseString::argify(const char *argv0, const char *src) {
Vector<char *> vargv;
if(argv0 != NULL)
- vargv.push_back(strdup(argv0));
+ {
+ char *t = strdup(argv0);
+ if (t == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (vargv.push_back(t))
+ {
+ free(t);
+ return NULL;
+ }
+ }
char *tmp = new char[strlen(src)+1];
+ if (tmp == NULL)
+ {
+ for(size_t i = 0; i < vargv.size(); i++)
+ free(vargv[i]);
+ errno = ENOMEM;
+ return NULL;
+ }
char *dst = tmp;
const char *end = src + strlen(src);
/* Copy characters from src to destination, while compacting them
@@ -287,20 +378,48 @@ BaseString::argify(const char *argv0, const char *src) {
/* Make sure the string is properly terminated */
*dst++ = '\0';
src++;
-
- vargv.push_back(strdup(begin));
+
+ {
+ char *t = strdup(begin);
+ if (t == NULL)
+ {
+ delete[] tmp;
+ for(size_t i = 0; i < vargv.size(); i++)
+ free(vargv[i]);
+ errno = ENOMEM;
+ return NULL;
+ }
+ if (vargv.push_back(t))
+ {
+ free(t);
+ delete[] tmp;
+ for(size_t i = 0; i < vargv.size(); i++)
+ free(vargv[i]);
+ return NULL;
+ }
+ }
}
end:
delete[] tmp;
- vargv.push_back(NULL);
+ if (vargv.push_back(NULL))
+ {
+ for(size_t i = 0; i < vargv.size(); i++)
+ free(vargv[i]);
+ return NULL;
+ }
/* Convert the C++ Vector into a C-vector of strings, suitable for
* calling execv().
*/
char **argv = (char **)malloc(sizeof(*argv) * (vargv.size()));
if(argv == NULL)
+ {
+ for(size_t i = 0; i < vargv.size(); i++)
+ free(vargv[i]);
+ errno = ENOMEM;
return NULL;
+ }
for(size_t i = 0; i < vargv.size(); i++){
argv[i] = vargv[i];
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
index 37c2d26d119..2b6f4785fca 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
@@ -105,8 +105,7 @@ void Dbtup::removeActiveOpList(Operationrec* const regOperPtr,
/**
* Release copy tuple
*/
- if(regOperPtr->op_struct.op_type != ZDELETE &&
- !regOperPtr->m_copy_tuple_location.isNull())
+ if(!regOperPtr->m_copy_tuple_location.isNull())
c_undo_buffer.free_copy_tuple(&regOperPtr->m_copy_tuple_location);
if (regOperPtr->op_struct.in_active_list) {
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
index 0a028ad512f..c89d78d23cf 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
@@ -1214,6 +1214,10 @@ Dbtup::read_pseudo(Uint32 attrId,
return 2;
}
return 0;
+ case AttributeHeader::COPY_ROWID:
+ outBuffer[0] = operPtr.p->m_copy_tuple_location.m_page_no;
+ outBuffer[0] = operPtr.p->m_copy_tuple_location.m_page_idx;
+ return 2;
default:
return 0;
}
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
index 1334cbebe3e..107633b3adf 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
@@ -62,11 +62,15 @@ Dbtup::execACC_SCANREQ(Signal* signal)
jam();
break;
}
+
+#if BUG_27776_FIXED
if (!AccScanReq::getNoDiskScanFlag(req->requestInfo)
&& tablePtr.p->m_no_of_disk_attributes)
{
bits |= ScanOp::SCAN_DD;
}
+#endif
+
bool mm = (bits & ScanOp::SCAN_DD);
if (tablePtr.p->m_attributes[mm].m_no_of_varsize > 0) {
bits |= ScanOp::SCAN_VS;
@@ -594,7 +598,6 @@ Dbtup::scanNext(Signal* signal, ScanOpPtr scanPtr)
const bool mm = (bits & ScanOp::SCAN_DD);
const bool lcp = (bits & ScanOp::SCAN_LCP);
- const bool dirty = (bits & ScanOp::SCAN_LOCK) == 0;
Uint32 lcp_list = fragPtr.p->m_lcp_keep_list;
Uint32 size = table.m_offsets[mm].m_fix_header_size +
@@ -765,8 +768,7 @@ Dbtup::scanNext(Signal* signal, ScanOpPtr scanPtr)
jam();
if (! (thbits & Tuple_header::FREE))
{
- if (! ((thbits & Tuple_header::ALLOC) && dirty))
- goto found_tuple;
+ goto found_tuple;
}
}
else
diff --git a/storage/ndb/src/kernel/blocks/suma/Suma.cpp b/storage/ndb/src/kernel/blocks/suma/Suma.cpp
index 6de0a00d844..b8cc438f514 100644
--- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp
+++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp
@@ -2396,6 +2396,16 @@ Suma::execSUB_START_REQ(Signal* signal){
sendSubStartRef(signal, 1412);
DBUG_VOID_RETURN;
}
+
+ if (c_startup.m_restart_server_node_id == 0 &&
+ !c_connected_nodes.get(refToNode(subscriberRef)))
+
+ {
+ jam();
+ sendSubStartRef(signal, SubStartRef::PartiallyConnected);
+ return;
+ }
+
DBUG_PRINT("info",("c_subscriberPool size: %d free: %d",
c_subscriberPool.getSize(),
c_subscriberPool.getNoOfFree()));
diff --git a/storage/ndb/src/ndbapi/DictCache.cpp b/storage/ndb/src/ndbapi/DictCache.cpp
index ed3bde38d4a..04be3711847 100644
--- a/storage/ndb/src/ndbapi/DictCache.cpp
+++ b/storage/ndb/src/ndbapi/DictCache.cpp
@@ -154,7 +154,7 @@ void GlobalDictCache::printCache()
}
NdbTableImpl *
-GlobalDictCache::get(const char * name)
+GlobalDictCache::get(const char * name, int *error)
{
DBUG_ENTER("GlobalDictCache::get");
DBUG_PRINT("enter", ("name: %s", name));
@@ -165,6 +165,11 @@ GlobalDictCache::get(const char * name)
versions = m_tableHash.getData(name, len);
if(versions == 0){
versions = new Vector<TableVersion>(2);
+ if (versions == NULL)
+ {
+ *error = -1;
+ DBUG_RETURN(0);
+ }
m_tableHash.insertKey(name, len, 0, versions);
}
@@ -211,7 +216,11 @@ GlobalDictCache::get(const char * name)
tmp.m_impl = 0;
tmp.m_status = RETREIVING;
tmp.m_refCount = 1; // The one retreiving it
- versions->push_back(tmp);
+ if (versions->push_back(tmp))
+ {
+ *error = -1;
+ DBUG_RETURN(0);
+ }
DBUG_PRINT("info", ("No table found"));
DBUG_RETURN(0);
}
diff --git a/storage/ndb/src/ndbapi/DictCache.hpp b/storage/ndb/src/ndbapi/DictCache.hpp
index bab027de0c8..9250ec7b196 100644
--- a/storage/ndb/src/ndbapi/DictCache.hpp
+++ b/storage/ndb/src/ndbapi/DictCache.hpp
@@ -67,7 +67,7 @@ public:
~GlobalDictCache();
NdbTableImpl * get(NdbTableImpl *tab);
- NdbTableImpl * get(const char * name);
+ NdbTableImpl * get(const char * name, int *error);
NdbTableImpl* put(const char * name, NdbTableImpl *);
void release(NdbTableImpl *, int invalidate = 0);
diff --git a/storage/ndb/src/ndbapi/Makefile.am b/storage/ndb/src/ndbapi/Makefile.am
index 8469110fddb..8ff427772b0 100644
--- a/storage/ndb/src/ndbapi/Makefile.am
+++ b/storage/ndb/src/ndbapi/Makefile.am
@@ -55,7 +55,8 @@ libndbapi_la_SOURCES = \
ndb_cluster_connection.cpp \
NdbBlob.cpp \
NdbIndexStat.cpp \
- SignalSender.cpp
+ SignalSender.cpp \
+ ObjectMap.cpp
INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp
index 495b848645f..78b7af5522b 100644
--- a/storage/ndb/src/ndbapi/Ndb.cpp
+++ b/storage/ndb/src/ndbapi/Ndb.cpp
@@ -436,7 +436,11 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId)
theRemainingStartTransactions--;
NdbTransaction* tConNext = theTransactionList;
- tConnection->init();
+ if (tConnection->init())
+ {
+ theError.code = tConnection->theError.code;
+ DBUG_RETURN(NULL);
+ }
theTransactionList = tConnection; // into a transaction list.
tConnection->next(tConNext); // Add the active connection object
tConnection->setTransactionId(tFirstTransId);
@@ -1200,13 +1204,18 @@ const char * Ndb::getCatalogName() const
return theImpl->m_dbname.c_str();
}
-void Ndb::setCatalogName(const char * a_catalog_name)
+int Ndb::setCatalogName(const char * a_catalog_name)
{
// TODO can table_name_separator be escaped?
if (a_catalog_name && ! strchr(a_catalog_name, table_name_separator)) {
- theImpl->m_dbname.assign(a_catalog_name);
- theImpl->update_prefix();
+ if (!theImpl->m_dbname.assign(a_catalog_name) ||
+ theImpl->update_prefix())
+ {
+ theError.code = 4000;
+ return -1;
+ }
}
+ return 0;
}
const char * Ndb::getSchemaName() const
@@ -1214,13 +1223,18 @@ const char * Ndb::getSchemaName() const
return theImpl->m_schemaname.c_str();
}
-void Ndb::setSchemaName(const char * a_schema_name)
+int Ndb::setSchemaName(const char * a_schema_name)
{
// TODO can table_name_separator be escaped?
if (a_schema_name && ! strchr(a_schema_name, table_name_separator)) {
- theImpl->m_schemaname.assign(a_schema_name);
- theImpl->update_prefix();
+ if (!theImpl->m_schemaname.assign(a_schema_name) ||
+ theImpl->update_prefix())
+ {
+ theError.code = 4000;
+ return -1;
+ }
}
+ return 0;
}
// </internal>
@@ -1229,9 +1243,9 @@ const char * Ndb::getDatabaseName() const
return getCatalogName();
}
-void Ndb::setDatabaseName(const char * a_catalog_name)
+int Ndb::setDatabaseName(const char * a_catalog_name)
{
- setCatalogName(a_catalog_name);
+ return setCatalogName(a_catalog_name);
}
const char * Ndb::getDatabaseSchemaName() const
@@ -1239,9 +1253,9 @@ const char * Ndb::getDatabaseSchemaName() const
return getSchemaName();
}
-void Ndb::setDatabaseSchemaName(const char * a_schema_name)
+int Ndb::setDatabaseSchemaName(const char * a_schema_name)
{
- setSchemaName(a_schema_name);
+ return setSchemaName(a_schema_name);
}
int Ndb::setDatabaseAndSchemaName(const NdbDictionary::Table* t)
@@ -1411,6 +1425,11 @@ const BaseString
Ndb::getDatabaseFromInternalName(const char * internalName)
{
char * databaseName = new char[strlen(internalName) + 1];
+ if (databaseName == NULL)
+ {
+ errno = ENOMEM;
+ return BaseString(NULL);
+ }
strcpy(databaseName, internalName);
register char *ptr = databaseName;
@@ -1427,6 +1446,11 @@ const BaseString
Ndb::getSchemaFromInternalName(const char * internalName)
{
char * schemaName = new char[strlen(internalName)];
+ if (schemaName == NULL)
+ {
+ errno = ENOMEM;
+ return BaseString(NULL);
+ }
register const char *ptr1 = internalName;
/* Scan name for the second table_name_separator */
diff --git a/storage/ndb/src/ndbapi/NdbDictionary.cpp b/storage/ndb/src/ndbapi/NdbDictionary.cpp
index b7a7087c302..b3ee41358d9 100644
--- a/storage/ndb/src/ndbapi/NdbDictionary.cpp
+++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp
@@ -78,9 +78,9 @@ NdbDictionary::Column::operator=(const NdbDictionary::Column& column)
return *this;
}
-void
+int
NdbDictionary::Column::setName(const char * name){
- m_impl.m_name.assign(name);
+ return !m_impl.m_name.assign(name);
}
const char*
@@ -234,10 +234,10 @@ NdbDictionary::Column::setAutoIncrementInitialValue(Uint64 val){
m_impl.m_autoIncrementInitialValue = val;
}
-void
+int
NdbDictionary::Column::setDefaultValue(const char* defaultValue)
{
- m_impl.m_defaultValue.assign(defaultValue);
+ return !m_impl.m_defaultValue.assign(defaultValue);
}
const char*
@@ -327,9 +327,9 @@ NdbDictionary::Table::operator=(const NdbDictionary::Table& table)
return *this;
}
-void
+int
NdbDictionary::Table::setName(const char * name){
- m_impl.setName(name);
+ return m_impl.setName(name);
}
const char *
@@ -347,12 +347,24 @@ NdbDictionary::Table::getTableId() const {
return m_impl.m_id;
}
-void
+int
NdbDictionary::Table::addColumn(const Column & c){
NdbColumnImpl* col = new NdbColumnImpl;
+ if (col == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
(* col) = NdbColumnImpl::getImpl(c);
- m_impl.m_columns.push_back(col);
- m_impl.buildColumnHash();
+ if (m_impl.m_columns.push_back(col))
+ {
+ return -1;
+ }
+ if (m_impl.buildColumnHash())
+ {
+ return -1;
+ }
+ return 0;
}
const NdbDictionary::Column*
@@ -507,10 +519,10 @@ NdbDictionary::Table::setSingleUserMode(enum NdbDictionary::Table::SingleUserMod
m_impl.m_single_user_mode = (Uint8)mode;
}
-void
+int
NdbDictionary::Table::setTablespaceNames(const void *data, Uint32 len)
{
- m_impl.setTablespaceNames(data, len);
+ return m_impl.setTablespaceNames(data, len);
}
const void*
@@ -549,9 +561,9 @@ NdbDictionary::Table::getFragmentCount() const
return m_impl.getFragmentCount();
}
-void
+int
NdbDictionary::Table::setFrm(const void* data, Uint32 len){
- m_impl.setFrm(data, len);
+ return m_impl.setFrm(data, len);
}
const void*
@@ -564,10 +576,10 @@ NdbDictionary::Table::getFragmentDataLen() const {
return m_impl.getFragmentDataLen();
}
-void
+int
NdbDictionary::Table::setFragmentData(const void* data, Uint32 len)
{
- m_impl.setFragmentData(data, len);
+ return m_impl.setFragmentData(data, len);
}
const void*
@@ -580,10 +592,10 @@ NdbDictionary::Table::getTablespaceDataLen() const {
return m_impl.getTablespaceDataLen();
}
-void
+int
NdbDictionary::Table::setTablespaceData(const void* data, Uint32 len)
{
- m_impl.setTablespaceData(data, len);
+ return m_impl.setTablespaceData(data, len);
}
const void*
@@ -596,10 +608,10 @@ NdbDictionary::Table::getRangeListDataLen() const {
return m_impl.getRangeListDataLen();
}
-void
+int
NdbDictionary::Table::setRangeListData(const void* data, Uint32 len)
{
- m_impl.setRangeListData(data, len);
+ return m_impl.setRangeListData(data, len);
}
NdbDictionary::Object::Status
@@ -681,18 +693,18 @@ NdbDictionary::Table::getTablespaceName() const
return m_impl.m_tablespace_name.c_str();
}
-void
+int
NdbDictionary::Table::setTablespaceName(const char * name){
m_impl.m_tablespace_id = ~0;
m_impl.m_tablespace_version = ~0;
- m_impl.m_tablespace_name.assign(name);
+ return !m_impl.m_tablespace_name.assign(name);
}
-void
+int
NdbDictionary::Table::setTablespace(const NdbDictionary::Tablespace & ts){
m_impl.m_tablespace_id = NdbTablespaceImpl::getImpl(ts).m_id;
m_impl.m_tablespace_version = ts.getObjectVersion();
- m_impl.m_tablespace_name.assign(ts.getName());
+ return !m_impl.m_tablespace_name.assign(ts.getName());
}
void
@@ -731,6 +743,7 @@ NdbDictionary::Table::validate(NdbError& error)
/*****************************************************************
* Index facade
*/
+
NdbDictionary::Index::Index(const char * name)
: m_impl(* new NdbIndexImpl(* this))
{
@@ -749,9 +762,9 @@ NdbDictionary::Index::~Index(){
}
}
-void
+int
NdbDictionary::Index::setName(const char * name){
- m_impl.setName(name);
+ return m_impl.setName(name);
}
const char *
@@ -759,9 +772,9 @@ NdbDictionary::Index::getName() const {
return m_impl.getName();
}
-void
+int
NdbDictionary::Index::setTable(const char * table){
- m_impl.setTable(table);
+ return m_impl.setTable(table);
}
const char *
@@ -796,39 +809,56 @@ NdbDictionary::Index::getIndexColumn(int no) const {
return NULL;
}
-void
+int
NdbDictionary::Index::addColumn(const Column & c){
NdbColumnImpl* col = new NdbColumnImpl;
+ if (col == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
(* col) = NdbColumnImpl::getImpl(c);
- m_impl.m_columns.push_back(col);
+ if (m_impl.m_columns.push_back(col))
+ {
+ return -1;
+ }
+ return 0;
}
-void
+int
NdbDictionary::Index::addColumnName(const char * name){
const Column c(name);
- addColumn(c);
+ return addColumn(c);
}
-void
+int
NdbDictionary::Index::addIndexColumn(const char * name){
const Column c(name);
- addColumn(c);
+ return addColumn(c);
}
-void
+int
NdbDictionary::Index::addColumnNames(unsigned noOfNames, const char ** names){
for(unsigned i = 0; i < noOfNames; i++) {
const Column c(names[i]);
- addColumn(c);
+ if (addColumn(c))
+ {
+ return -1;
+ }
}
+ return 0;
}
-void
+int
NdbDictionary::Index::addIndexColumns(int noOfNames, const char ** names){
for(int i = 0; i < noOfNames; i++) {
const Column c(names[i]);
- addColumn(c);
+ if (addColumn(c))
+ {
+ return -1;
+ }
}
+ return 0;
}
void
@@ -906,10 +936,10 @@ NdbDictionary::Event::~Event()
}
}
-void
+int
NdbDictionary::Event::setName(const char * name)
{
- m_impl.setName(name);
+ return m_impl.setName(name);
}
const char *
@@ -930,10 +960,10 @@ NdbDictionary::Event::getTable() const
return m_impl.getTable();
}
-void
+int
NdbDictionary::Event::setTable(const char * table)
{
- m_impl.setTable(table);
+ return m_impl.setTable(table);
}
const char*
@@ -1265,18 +1295,18 @@ NdbDictionary::Datafile::getFree() const {
return m_impl.m_free;
}
-void
+int
NdbDictionary::Datafile::setTablespace(const char * tablespace){
m_impl.m_filegroup_id = ~0;
m_impl.m_filegroup_version = ~0;
- m_impl.m_filegroup_name.assign(tablespace);
+ return !m_impl.m_filegroup_name.assign(tablespace);
}
-void
+int
NdbDictionary::Datafile::setTablespace(const NdbDictionary::Tablespace & ts){
m_impl.m_filegroup_id = NdbTablespaceImpl::getImpl(ts).m_id;
m_impl.m_filegroup_version = ts.getObjectVersion();
- m_impl.m_filegroup_name.assign(ts.getName());
+ return !m_impl.m_filegroup_name.assign(ts.getName());
}
const char *
diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index 180747bfb9b..41b1dbc06e4 100644
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -383,6 +383,11 @@ NdbColumnImpl::create_pseudo(const char * name){
col->m_impl.m_attrId = AttributeHeader::ANY_VALUE;
col->m_impl.m_attrSize = 4;
col->m_impl.m_arraySize = 1;
+ } else if(!strcmp(name, "NDB$COPY_ROWID")){
+ col->setType(NdbDictionary::Column::Bigunsigned);
+ col->m_impl.m_attrId = AttributeHeader::COPY_ROWID;
+ col->m_impl.m_attrSize = 4;
+ col->m_impl.m_arraySize = 2;
} else {
abort();
}
@@ -681,15 +686,18 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const
DBUG_RETURN(true);
}
-void
+int
NdbTableImpl::assign(const NdbTableImpl& org)
{
DBUG_ENTER("NdbColumnImpl::assign");
DBUG_PRINT("info", ("this: %p &org: %p", this, &org));
/* m_changeMask intentionally not copied */
m_primaryTableId = org.m_primaryTableId;
- m_internalName.assign(org.m_internalName);
- updateMysqlName();
+ if (!m_internalName.assign(org.m_internalName) ||
+ updateMysqlName())
+ {
+ return -1;
+ }
// If the name has been explicitly set, use that name
// otherwise use the fetched name
if (!org.m_newExternalName.empty())
@@ -721,9 +729,18 @@ NdbTableImpl::assign(const NdbTableImpl& org)
for(i = 0; i < org.m_columns.size(); i++)
{
NdbColumnImpl * col = new NdbColumnImpl();
+ if (col == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
const NdbColumnImpl * iorg = org.m_columns[i];
(* col) = (* iorg);
- m_columns.push_back(col);
+ if (m_columns.push_back(col))
+ {
+ delete col;
+ return -1;
+ }
}
m_fragments = org.m_fragments;
@@ -765,12 +782,12 @@ NdbTableImpl::assign(const NdbTableImpl& org)
m_tablespace_name = org.m_tablespace_name;
m_tablespace_id= org.m_tablespace_id;
m_tablespace_version = org.m_tablespace_version;
- DBUG_VOID_RETURN;
+ DBUG_RETURN(0);
}
-void NdbTableImpl::setName(const char * name)
+int NdbTableImpl::setName(const char * name)
{
- m_newExternalName.assign(name);
+ return !m_newExternalName.assign(name);
}
const char *
@@ -869,9 +886,9 @@ NdbTableImpl::getTablespaceNamesLen() const
return m_new_ts_name.length();
}
-void NdbTableImpl::setTablespaceNames(const void *data, Uint32 len)
+int NdbTableImpl::setTablespaceNames(const void *data, Uint32 len)
{
- m_new_ts_name.assign(data, len);
+ return !m_new_ts_name.assign(data, len);
}
void NdbTableImpl::setFragmentCount(Uint32 count)
@@ -884,9 +901,9 @@ Uint32 NdbTableImpl::getFragmentCount() const
return m_fragmentCount;
}
-void NdbTableImpl::setFrm(const void* data, Uint32 len)
+int NdbTableImpl::setFrm(const void* data, Uint32 len)
{
- m_newFrm.assign(data, len);
+ return m_newFrm.assign(data, len);
}
const void *
@@ -907,9 +924,9 @@ NdbTableImpl::getFrmLength() const
return m_newFrm.length();
}
-void NdbTableImpl::setFragmentData(const void* data, Uint32 len)
+int NdbTableImpl::setFragmentData(const void* data, Uint32 len)
{
- m_new_fd.assign(data, len);
+ return m_new_fd.assign(data, len);
}
const void *
@@ -930,9 +947,9 @@ NdbTableImpl::getFragmentDataLen() const
return m_new_fd.length();
}
-void NdbTableImpl::setTablespaceData(const void* data, Uint32 len)
+int NdbTableImpl::setTablespaceData(const void* data, Uint32 len)
{
- m_new_ts.assign(data, len);
+ return !m_new_ts.assign(data, len);
}
const void *
@@ -953,9 +970,9 @@ NdbTableImpl::getTablespaceDataLen() const
return m_new_ts.length();
}
-void NdbTableImpl::setRangeListData(const void* data, Uint32 len)
+int NdbTableImpl::setRangeListData(const void* data, Uint32 len)
{
- m_new_range.assign(data, len);
+ return m_new_range.assign(data, len);
}
const void *
@@ -976,19 +993,18 @@ NdbTableImpl::getRangeListDataLen() const
return m_new_range.length();
}
-void
+int
NdbTableImpl::updateMysqlName()
{
Vector<BaseString> v;
if (m_internalName.split(v,"/") == 3)
{
- m_mysqlName.assfmt("%s/%s",v[0].c_str(),v[2].c_str());
- return;
+ return !m_mysqlName.assfmt("%s/%s",v[0].c_str(),v[2].c_str());
}
- m_mysqlName.assign("");
+ return !m_mysqlName.assign("");
}
-void
+int
NdbTableImpl::buildColumnHash(){
const Uint32 size = m_columns.size();
int i;
@@ -1000,19 +1016,29 @@ NdbTableImpl::buildColumnHash(){
}
Vector<Uint32> hashValues;
- Vector<Vector<Uint32> > chains; chains.fill(size, hashValues);
+ Vector<Vector<Uint32> > chains;
+ if (chains.fill(size, hashValues))
+ {
+ return -1;
+ }
for(i = 0; i< (int) size; i++){
Uint32 hv = Hash(m_columns[i]->getName()) & 0xFFFE;
Uint32 bucket = hv & m_columnHashMask;
bucket = (bucket < size ? bucket : bucket - size);
assert(bucket < size);
- hashValues.push_back(hv);
- chains[bucket].push_back(i);
+ if (hashValues.push_back(hv) ||
+ chains[bucket].push_back(i))
+ {
+ return -1;
+ }
}
m_columnHash.clear();
Uint32 tmp = 1;
- m_columnHash.fill((unsigned)size-1, tmp); // Default no chaining
+ if (m_columnHash.fill((unsigned)size-1, tmp)) // Default no chaining
+ {
+ return -1;
+ }
Uint32 pos = 0; // In overflow vector
for(i = 0; i< (int) size; i++){
@@ -1032,12 +1058,18 @@ NdbTableImpl::buildColumnHash(){
for(size_t j = 0; j<sz; j++, pos++){
Uint32 col = chains[i][j];
Uint32 hv = hashValues[col];
- m_columnHash.push_back((col << 16) | hv);
+ if (m_columnHash.push_back((col << 16) | hv))
+ {
+ return -1;
+ }
}
}
}
- m_columnHash.push_back(0); // Overflow when looping in end of array
+ if (m_columnHash.push_back(0)) // Overflow when looping in end of array
+ {
+ return -1;
+ }
#if 0
for(size_t i = 0; i<m_columnHash.size(); i++){
@@ -1052,6 +1084,7 @@ NdbTableImpl::buildColumnHash(){
i, col > 0 ? m_columns[col]->getName() : "" , m_columnHash[i]);
}
#endif
+ return 0;
}
Uint32
@@ -1170,9 +1203,9 @@ NdbIndexImpl::~NdbIndexImpl(){
delete m_columns[i];
}
-void NdbIndexImpl::setName(const char * name)
+int NdbIndexImpl::setName(const char * name)
{
- m_externalName.assign(name);
+ return !m_externalName.assign(name);
}
const char *
@@ -1181,10 +1214,10 @@ NdbIndexImpl::getName() const
return m_externalName.c_str();
}
-void
+int
NdbIndexImpl::setTable(const char * table)
{
- m_tableName.assign(table);
+ return !m_tableName.assign(table);
}
const char *
@@ -1245,9 +1278,9 @@ NdbEventImpl::~NdbEventImpl()
DBUG_VOID_RETURN;
}
-void NdbEventImpl::setName(const char * name)
+int NdbEventImpl::setName(const char * name)
{
- m_name.assign(name);
+ return !m_name.assign(name);
}
const char *NdbEventImpl::getName() const
@@ -1255,11 +1288,11 @@ const char *NdbEventImpl::getName() const
return m_name.c_str();
}
-void
+int
NdbEventImpl::setTable(const NdbDictionary::Table& table)
{
setTable(&NdbTableImpl::getImpl(table));
- m_tableName.assign(m_tableImpl->getName());
+ return !m_tableName.assign(m_tableImpl->getName());
}
void
@@ -1284,10 +1317,10 @@ NdbEventImpl::getTable() const
return NULL;
}
-void
+int
NdbEventImpl::setTable(const char * table)
{
- m_tableName.assign(table);
+ return !m_tableName.assign(table);
}
const char *
@@ -1407,14 +1440,18 @@ NdbDictionaryImpl::fetchGlobalTableImplRef(const GlobalCacheInitObject &obj)
{
DBUG_ENTER("fetchGlobalTableImplRef");
NdbTableImpl *impl;
+ int error= 0;
m_globalHash->lock();
- impl = m_globalHash->get(obj.m_name.c_str());
+ impl = m_globalHash->get(obj.m_name.c_str(), &error);
m_globalHash->unlock();
if (impl == 0){
- impl = m_receiver.getTable(obj.m_name.c_str(),
- m_ndb.usingFullyQualifiedNames());
+ if (error == 0)
+ impl = m_receiver.getTable(obj.m_name.c_str(),
+ m_ndb.usingFullyQualifiedNames());
+ else
+ m_error.code = 4000;
if (impl != 0 && obj.init(*impl))
{
delete impl;
@@ -1434,10 +1471,11 @@ NdbDictionaryImpl::putTable(NdbTableImpl *impl)
NdbTableImpl *old;
int ret = getBlobTables(*impl);
+ int error = 0;
assert(ret == 0);
m_globalHash->lock();
- if ((old= m_globalHash->get(impl->m_internalName.c_str())))
+ if ((old= m_globalHash->get(impl->m_internalName.c_str(), &error)))
{
m_globalHash->alter_table_rep(old->m_internalName.c_str(),
impl->m_id,
@@ -1877,12 +1915,20 @@ NdbDictInterface::getTable(const BaseString& name, bool fullyQualifiedNames)
// Copy name to m_buffer to get a word sized buffer
m_buffer.clear();
- m_buffer.grow(namelen_words*4+4);
- m_buffer.append(name.c_str(), namelen);
+ if (m_buffer.grow(namelen_words*4+4) ||
+ m_buffer.append(name.c_str(), namelen))
+ {
+ m_error.code= 4000;
+ return NULL;
+ }
#ifndef IGNORE_VALGRIND_WARNINGS
Uint32 pad = 0;
- m_buffer.append(&pad, 4);
+ if (m_buffer.append(&pad, 4))
+ {
+ m_error.code= 4000;
+ return NULL;
+ }
#endif
LinearSectionPtr ptr[1];
@@ -1913,7 +1959,14 @@ NdbDictInterface::getTable(class NdbApiSignal * signal,
m_buffer.length() / 4,
fullyQualifiedNames);
if(rt)
- rt->buildColumnHash();
+ {
+ if (rt->buildColumnHash())
+ {
+ m_error.code = 4000;
+ delete rt;
+ return NULL;
+ }
+ }
return rt;
}
@@ -1923,18 +1976,25 @@ NdbDictInterface::execGET_TABINFO_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
const GetTabInfoConf* conf = CAST_CONSTPTR(GetTabInfoConf, signal->getDataPtr());
+ const Uint32 i = GetTabInfoConf::DICT_TAB_INFO;
if(signal->isFirstFragment()){
m_fragmentId = signal->getFragmentId();
- m_buffer.grow(4 * conf->totalLen);
+ if (m_buffer.grow(4 * conf->totalLen))
+ {
+ m_error.code= 4000;
+ goto end;
+ }
} else {
if(m_fragmentId != signal->getFragmentId()){
abort();
}
}
- const Uint32 i = GetTabInfoConf::DICT_TAB_INFO;
- m_buffer.append(ptr[i].p, 4 * ptr[i].sz);
-
+ if (m_buffer.append(ptr[i].p, 4 * ptr[i].sz))
+ {
+ m_error.code= 4000;
+ }
+end:
if(!signal->isLastFragment()){
return;
}
@@ -2081,13 +2141,15 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
impl->m_id = tableDesc->TableId;
impl->m_version = tableDesc->TableVersion;
impl->m_status = NdbDictionary::Object::Retrieved;
- impl->m_internalName.assign(internalName);
- impl->updateMysqlName();
- impl->m_externalName.assign(externalName);
-
- impl->m_frm.assign(tableDesc->FrmData, tableDesc->FrmLen);
- impl->m_fd.assign(tableDesc->FragmentData, tableDesc->FragmentDataLen);
- impl->m_range.assign(tableDesc->RangeListData, tableDesc->RangeListDataLen);
+ if (!impl->m_internalName.assign(internalName) ||
+ impl->updateMysqlName() ||
+ !impl->m_externalName.assign(externalName) ||
+ impl->m_frm.assign(tableDesc->FrmData, tableDesc->FrmLen) ||
+ impl->m_fd.assign(tableDesc->FragmentData, tableDesc->FragmentDataLen) ||
+ impl->m_range.assign(tableDesc->RangeListData, tableDesc->RangeListDataLen))
+ {
+ DBUG_RETURN(4000);
+ }
impl->m_fragmentCount = tableDesc->FragmentCount;
/*
@@ -2131,7 +2193,10 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
} else {
const char * externalPrimary =
Ndb::externalizeTableName(tableDesc->PrimaryTable, fullyQualifiedNames);
- impl->m_primaryTable.assign(externalPrimary);
+ if (!impl->m_primaryTable.assign(externalPrimary))
+ {
+ DBUG_RETURN(4000);
+ }
}
Uint32 i;
@@ -2154,6 +2219,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
// check type and compute attribute size and array size
if (! attrDesc.translateExtType()) {
+ delete col;
delete impl;
NdbMem_Free((void*)tableDesc);
DBUG_RETURN(703);
@@ -2166,6 +2232,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
unsigned cs_number = (attrDesc.AttributeExtPrecision >> 16);
// charset is defined exactly for char types
if (col->getCharType() != (cs_number != 0)) {
+ delete col;
delete impl;
NdbMem_Free((void*)tableDesc);
DBUG_RETURN(703);
@@ -2173,6 +2240,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
if (col->getCharType()) {
col->m_cs = get_charset(cs_number, MYF(0));
if (col->m_cs == NULL) {
+ delete col;
delete impl;
NdbMem_Free((void*)tableDesc);
DBUG_RETURN(743);
@@ -2193,7 +2261,12 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
col->m_nullable = attrDesc.AttributeNullableFlag;
col->m_autoIncrement = (attrDesc.AttributeAutoIncrement != 0);
col->m_autoIncrementInitialValue = ~0;
- col->m_defaultValue.assign(attrDesc.AttributeDefaultValue);
+ if (!col->m_defaultValue.assign(attrDesc.AttributeDefaultValue))
+ {
+ delete col;
+ delete impl;
+ DBUG_RETURN(4000);
+ }
col->m_column_no = impl->m_columns.size();
impl->m_columns.push_back(col);
@@ -2216,7 +2289,11 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
pos++; // skip logpart
for (Uint32 j = 0; j<(Uint32)replicaCount; j++)
{
- impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[pos++]));
+ if (impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[pos++])))
+ {
+ delete impl;
+ DBUG_RETURN(4000);
+ }
}
}
@@ -2262,8 +2339,13 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t)
// if the new name has not been set, use the copied name
if (t.m_newExternalName.empty())
- t.m_newExternalName.assign(t.m_externalName);
-
+ {
+ if (!t.m_newExternalName.assign(t.m_externalName))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
+ }
// create table
if (m_receiver.createTable(m_ndb, t) != 0)
DBUG_RETURN(-1);
@@ -2438,7 +2520,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
{
AlterTableReq::setNameFlag(impl.m_changeMask, true);
}
- impl.m_externalName.assign(impl.m_newExternalName);
+ if (!impl.m_externalName.assign(impl.m_newExternalName))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.m_newExternalName.clear();
}
// Definition change (frm)
@@ -2448,7 +2534,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
{
AlterTableReq::setFrmFlag(impl.m_changeMask, true);
}
- impl.m_frm.assign(impl.m_newFrm.get_data(), impl.m_newFrm.length());
+ if (impl.m_frm.assign(impl.m_newFrm.get_data(), impl.m_newFrm.length()))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.m_newFrm.clear();
}
// Change FragmentData (fragment identity, state, tablespace id)
@@ -2458,7 +2548,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
{
AlterTableReq::setFragDataFlag(impl.m_changeMask, true);
}
- impl.m_fd.assign(impl.m_new_fd.get_data(), impl.m_new_fd.length());
+ if (impl.m_fd.assign(impl.m_new_fd.get_data(), impl.m_new_fd.length()))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.m_new_fd.clear();
}
// Change Tablespace Name Data
@@ -2468,8 +2562,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
{
AlterTableReq::setTsNameFlag(impl.m_changeMask, true);
}
- impl.m_ts_name.assign(impl.m_new_ts_name.get_data(),
- impl.m_new_ts_name.length());
+ if (impl.m_ts_name.assign(impl.m_new_ts_name.get_data(),
+ impl.m_new_ts_name.length()))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.m_new_ts_name.clear();
}
// Change Range/List Data
@@ -2479,8 +2577,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
{
AlterTableReq::setRangeListFlag(impl.m_changeMask, true);
}
- impl.m_range.assign(impl.m_new_range.get_data(),
- impl.m_new_range.length());
+ if (impl.m_range.assign(impl.m_new_range.get_data(),
+ impl.m_new_range.length()))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.m_new_range.clear();
}
// Change Tablespace Data
@@ -2490,8 +2592,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
{
AlterTableReq::setTsFlag(impl.m_changeMask, true);
}
- impl.m_ts.assign(impl.m_new_ts.get_data(),
- impl.m_new_ts.length());
+ if (impl.m_ts.assign(impl.m_new_ts.get_data(),
+ impl.m_new_ts.length()))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.m_new_ts.clear();
}
@@ -2506,7 +2612,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
const BaseString internalName(
ndb.internalize_table_name(impl.m_externalName.c_str()));
- impl.m_internalName.assign(internalName);
+ if (!impl.m_internalName.assign(internalName))
+ {
+ m_error.code= 4000;
+ DBUG_RETURN(-1);
+ }
impl.updateMysqlName();
DictTabInfo::Table *tmpTab;
@@ -3079,11 +3189,21 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst,
{
DBUG_ENTER("NdbDictInterface::create_index_obj_from_table");
NdbIndexImpl *idx = new NdbIndexImpl();
+ if (idx == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
idx->m_version = tab->m_version;
idx->m_status = tab->m_status;
idx->m_id = tab->m_id;
- idx->m_externalName.assign(tab->getName());
- idx->m_tableName.assign(prim->m_externalName);
+ if (!idx->m_externalName.assign(tab->getName()) ||
+ !idx->m_tableName.assign(prim->m_externalName))
+ {
+ delete idx;
+ errno = ENOMEM;
+ return -1;
+ }
NdbDictionary::Object::Type type = idx->m_type = tab->m_indexType;
idx->m_logging = tab->m_logging;
idx->m_temporary = tab->m_temporary;
@@ -3097,9 +3217,20 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst,
NdbColumnImpl* org = tab->m_columns[i];
NdbColumnImpl* col = new NdbColumnImpl;
+ if (col == NULL)
+ {
+ errno = ENOMEM;
+ delete idx;
+ return -1;
+ }
// Copy column definition
*col = * org;
- idx->m_columns.push_back(col);
+ if (idx->m_columns.push_back(col))
+ {
+ delete col;
+ delete idx;
+ return -1;
+ }
/**
* reverse map
@@ -4168,34 +4299,72 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list,
BaseString databaseName;
BaseString schemaName;
BaseString objectName;
+ if (!databaseName || !schemaName || !objectName)
+ {
+ m_error.code= 4000;
+ return -1;
+ }
if ((element.type == NdbDictionary::Object::UniqueHashIndex) ||
(element.type == NdbDictionary::Object::OrderedIndex)) {
char * indexName = new char[n << 2];
+ if (indexName == NULL)
+ {
+ m_error.code= 4000;
+ return -1;
+ }
memcpy(indexName, &data[pos], n << 2);
- databaseName = Ndb::getDatabaseFromInternalName(indexName);
- schemaName = Ndb::getSchemaFromInternalName(indexName);
+ if (!(databaseName = Ndb::getDatabaseFromInternalName(indexName)) ||
+ !(schemaName = Ndb::getSchemaFromInternalName(indexName)))
+ {
+ delete [] indexName;
+ m_error.code= 4000;
+ return -1;
+ }
objectName = BaseString(Ndb::externalizeIndexName(indexName, fullyQualifiedNames));
delete [] indexName;
} else if ((element.type == NdbDictionary::Object::SystemTable) ||
(element.type == NdbDictionary::Object::UserTable)) {
char * tableName = new char[n << 2];
+ if (tableName == NULL)
+ {
+ m_error.code= 4000;
+ return -1;
+ }
memcpy(tableName, &data[pos], n << 2);
- databaseName = Ndb::getDatabaseFromInternalName(tableName);
- schemaName = Ndb::getSchemaFromInternalName(tableName);
+ if (!(databaseName = Ndb::getDatabaseFromInternalName(tableName)) ||
+ !(schemaName = Ndb::getSchemaFromInternalName(tableName)))
+ {
+ delete [] tableName;
+ m_error.code= 4000;
+ return -1;
+ }
objectName = BaseString(Ndb::externalizeTableName(tableName, fullyQualifiedNames));
delete [] tableName;
}
else {
char * otherName = new char[n << 2];
+ if (otherName == NULL)
+ {
+ m_error.code= 4000;
+ return -1;
+ }
memcpy(otherName, &data[pos], n << 2);
- objectName = BaseString(otherName);
+ if (!(objectName = BaseString(otherName)))
+ {
+ m_error.code= 4000;
+ return -1;
+ }
delete [] otherName;
}
- element.database = new char[databaseName.length() + 1];
+ if (!(element.database = new char[databaseName.length() + 1]) ||
+ !(element.schema = new char[schemaName.length() + 1]) ||
+ !(element.name = new char[objectName.length() + 1]))
+ {
+ m_error.code= 4000;
+ return -1;
+ }
strcpy(element.database, databaseName.c_str());
- element.schema = new char[schemaName.length() + 1];
strcpy(element.schema, schemaName.c_str());
- element.name = new char[objectName.length() + 1];
strcpy(element.name, objectName.c_str());
pos += n;
count++;
@@ -4244,7 +4413,10 @@ NdbDictInterface::execLIST_TABLES_CONF(NdbApiSignal* signal,
{
const unsigned off = ListTablesConf::HeaderLength;
const unsigned len = (signal->getLength() - off);
- m_buffer.append(signal->getDataPtr() + off, len << 2);
+ if (m_buffer.append(signal->getDataPtr() + off, len << 2))
+ {
+ m_error.code= 4000;
+ }
if (signal->getLength() < ListTablesConf::SignalLength) {
// last signal has less than full length
m_waiter.signal(NO_WAIT);
@@ -4331,7 +4503,7 @@ NdbTablespaceImpl::NdbTablespaceImpl(NdbDictionary::Tablespace & f) :
NdbTablespaceImpl::~NdbTablespaceImpl(){
}
-void
+int
NdbTablespaceImpl::assign(const NdbTablespaceImpl& org)
{
m_id = org.m_id;
@@ -4339,14 +4511,17 @@ NdbTablespaceImpl::assign(const NdbTablespaceImpl& org)
m_status = org.m_status;
m_type = org.m_type;
- m_name.assign(org.m_name);
+ if (!m_name.assign(org.m_name))
+ return -1;
m_grow_spec = org.m_grow_spec;
m_extent_size = org.m_extent_size;
m_undo_free_words = org.m_undo_free_words;
m_logfile_group_id = org.m_logfile_group_id;
m_logfile_group_version = org.m_logfile_group_version;
- m_logfile_group_name.assign(org.m_logfile_group_name);
+ if (!m_logfile_group_name.assign(org.m_logfile_group_name))
+ return -1;
m_undo_free_words = org.m_undo_free_words;
+ return 0;
}
NdbLogfileGroupImpl::NdbLogfileGroupImpl() :
@@ -4364,7 +4539,7 @@ NdbLogfileGroupImpl::NdbLogfileGroupImpl(NdbDictionary::LogfileGroup & f) :
NdbLogfileGroupImpl::~NdbLogfileGroupImpl(){
}
-void
+int
NdbLogfileGroupImpl::assign(const NdbLogfileGroupImpl& org)
{
m_id = org.m_id;
@@ -4372,14 +4547,17 @@ NdbLogfileGroupImpl::assign(const NdbLogfileGroupImpl& org)
m_status = org.m_status;
m_type = org.m_type;
- m_name.assign(org.m_name);
+ if (!m_name.assign(org.m_name))
+ return -1;
m_grow_spec = org.m_grow_spec;
m_extent_size = org.m_extent_size;
m_undo_free_words = org.m_undo_free_words;
m_logfile_group_id = org.m_logfile_group_id;
m_logfile_group_version = org.m_logfile_group_version;
- m_logfile_group_name.assign(org.m_logfile_group_name);
+ if (!m_logfile_group_name.assign(org.m_logfile_group_name))
+ return -1;
m_undo_free_words = org.m_undo_free_words;
+ return 0;
}
NdbFileImpl::NdbFileImpl(NdbDictionary::Object::Type t)
@@ -4406,7 +4584,7 @@ NdbDatafileImpl::NdbDatafileImpl(NdbDictionary::Datafile & f) :
NdbDatafileImpl::~NdbDatafileImpl(){
}
-void
+int
NdbDatafileImpl::assign(const NdbDatafileImpl& org)
{
m_id = org.m_id;
@@ -4418,8 +4596,10 @@ NdbDatafileImpl::assign(const NdbDatafileImpl& org)
m_free = org.m_free;
m_filegroup_id = org.m_filegroup_id;
m_filegroup_version = org.m_filegroup_version;
- m_path.assign(org.m_path);
- m_filegroup_name.assign(org.m_filegroup_name);
+ if (!m_path.assign(org.m_path) ||
+ !m_filegroup_name.assign(org.m_filegroup_name))
+ return -1;
+ return 0;
}
NdbUndofileImpl::NdbUndofileImpl() :
@@ -4437,7 +4617,7 @@ NdbUndofileImpl::NdbUndofileImpl(NdbDictionary::Undofile & f) :
NdbUndofileImpl::~NdbUndofileImpl(){
}
-void
+int
NdbUndofileImpl::assign(const NdbUndofileImpl& org)
{
m_id = org.m_id;
@@ -4449,8 +4629,10 @@ NdbUndofileImpl::assign(const NdbUndofileImpl& org)
m_free = org.m_free;
m_filegroup_id = org.m_filegroup_id;
m_filegroup_version = org.m_filegroup_version;
- m_path.assign(org.m_path);
- m_filegroup_name.assign(org.m_filegroup_name);
+ if (!m_path.assign(org.m_path) ||
+ !m_filegroup_name.assign(org.m_filegroup_name))
+ return 4000;
+ return 0;
}
int
@@ -4882,7 +5064,8 @@ NdbDictInterface::get_filegroup(NdbFilegroupImpl & dst,
get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
NdbDictionary::Object::LogfileGroup,
dst.m_logfile_group_id);
- dst.m_logfile_group_name.assign(tmp.getName());
+ if (!dst.m_logfile_group_name.assign(tmp.getName()))
+ DBUG_RETURN(m_error.code = 4000);
}
if(dst.m_type == type)
@@ -4916,7 +5099,8 @@ NdbDictInterface::parseFilegroupInfo(NdbFilegroupImpl &dst,
dst.m_type = (NdbDictionary::Object::Type)fg.FilegroupType;
dst.m_status = NdbDictionary::Object::Retrieved;
- dst.m_name.assign(fg.FilegroupName);
+ if (!dst.m_name.assign(fg.FilegroupName))
+ return 4000;
dst.m_extent_size = fg.TS_ExtentSize;
dst.m_undo_buffer_size = fg.LF_UndoBufferSize;
dst.m_logfile_group_id = fg.TS_LogfileGroupId;
@@ -5035,7 +5219,8 @@ NdbDictInterface::get_file(NdbFileImpl & dst,
get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
NdbDictionary::Object::LogfileGroup,
dst.m_filegroup_id);
- dst.m_filegroup_name.assign(tmp.getName());
+ if (!dst.m_filegroup_name.assign(tmp.getName()))
+ DBUG_RETURN(m_error.code = 4000);
}
else if(dst.m_type == NdbDictionary::Object::Datafile)
{
@@ -5043,7 +5228,8 @@ NdbDictInterface::get_file(NdbFileImpl & dst,
get_filegroup(NdbTablespaceImpl::getImpl(tmp),
NdbDictionary::Object::Tablespace,
dst.m_filegroup_id);
- dst.m_filegroup_name.assign(tmp.getName());
+ if (!dst.m_filegroup_name.assign(tmp.getName()))
+ DBUG_RETURN(m_error.code = 4000);
dst.m_free *= tmp.getExtentSize();
}
else
@@ -5079,7 +5265,8 @@ NdbDictInterface::parseFileInfo(NdbFileImpl &dst,
dst.m_version = f.FileVersion;
dst.m_size= ((Uint64)f.FileSizeHi << 32) | (f.FileSizeLo);
- dst.m_path.assign(f.FileName);
+ if (!dst.m_path.assign(f.FileName))
+ return 4000;
dst.m_filegroup_id= f.FilegroupId;
dst.m_filegroup_version= f.FilegroupVersion;
@@ -5106,3 +5293,4 @@ const NdbDictionary::Column * NdbDictionary::Column::RECORDS_IN_RANGE = 0;
const NdbDictionary::Column * NdbDictionary::Column::ROWID = 0;
const NdbDictionary::Column * NdbDictionary::Column::ROW_GCI = 0;
const NdbDictionary::Column * NdbDictionary::Column::ANY_VALUE = 0;
+const NdbDictionary::Column * NdbDictionary::Column::COPY_ROWID = 0;
diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
index b474b6e7fc0..c904b9d65c3 100644
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
@@ -131,28 +131,28 @@ public:
~NdbTableImpl();
void init();
- void setName(const char * name);
+ int setName(const char * name);
const char * getName() const;
void setFragmentCount(Uint32 count);
Uint32 getFragmentCount() const;
- void setFrm(const void* data, Uint32 len);
+ int setFrm(const void* data, Uint32 len);
const void * getFrmData() const;
Uint32 getFrmLength() const;
- void setFragmentData(const void* data, Uint32 len);
+ int setFragmentData(const void* data, Uint32 len);
const void * getFragmentData() const;
Uint32 getFragmentDataLen() const;
- void setTablespaceNames(const void* data, Uint32 len);
+ int setTablespaceNames(const void* data, Uint32 len);
Uint32 getTablespaceNamesLen() const;
const void * getTablespaceNames() const;
- void setTablespaceData(const void* data, Uint32 len);
+ int setTablespaceData(const void* data, Uint32 len);
const void * getTablespaceData() const;
Uint32 getTablespaceDataLen() const;
- void setRangeListData(const void* data, Uint32 len);
+ int setRangeListData(const void* data, Uint32 len);
const void * getRangeListData() const;
Uint32 getRangeListDataLen() const;
const char * getMysqlName() const;
- void updateMysqlName();
+ int updateMysqlName();
int aggregate(NdbError& error);
int validate(NdbError& error);
@@ -182,7 +182,7 @@ public:
Vector<Uint32> m_columnHash;
Vector<NdbColumnImpl *> m_columns;
void computeAggregates();
- void buildColumnHash();
+ int buildColumnHash();
/**
* Fragment info
@@ -232,7 +232,7 @@ public:
* Equality/assign
*/
bool equal(const NdbTableImpl&) const;
- void assign(const NdbTableImpl&);
+ int assign(const NdbTableImpl&);
static NdbTableImpl & getImpl(NdbDictionary::Table & t);
static NdbTableImpl & getImpl(const NdbDictionary::Table & t);
@@ -258,9 +258,9 @@ public:
~NdbIndexImpl();
void init();
- void setName(const char * name);
+ int setName(const char * name);
const char * getName() const;
- void setTable(const char * table);
+ int setTable(const char * table);
const char * getTable() const;
const NdbTableImpl * getIndexTable() const;
@@ -296,11 +296,11 @@ public:
~NdbEventImpl();
void init();
- void setName(const char * name);
+ int setName(const char * name);
const char * getName() const;
- void setTable(const NdbDictionary::Table& table);
+ int setTable(const NdbDictionary::Table& table);
const NdbDictionary::Table * getTable() const;
- void setTable(const char * table);
+ int setTable(const char * table);
const char * getTableName() const;
void addTableEvent(const NdbDictionary::Event::TableEvent t);
bool getTableEvent(const NdbDictionary::Event::TableEvent t) const;
@@ -364,7 +364,7 @@ public:
NdbTablespaceImpl(NdbDictionary::Tablespace &);
~NdbTablespaceImpl();
- void assign(const NdbTablespaceImpl&);
+ int assign(const NdbTablespaceImpl&);
static NdbTablespaceImpl & getImpl(NdbDictionary::Tablespace & t);
static const NdbTablespaceImpl & getImpl(const NdbDictionary::Tablespace &);
@@ -378,7 +378,7 @@ public:
NdbLogfileGroupImpl(NdbDictionary::LogfileGroup &);
~NdbLogfileGroupImpl();
- void assign(const NdbLogfileGroupImpl&);
+ int assign(const NdbLogfileGroupImpl&);
static NdbLogfileGroupImpl & getImpl(NdbDictionary::LogfileGroup & t);
static const NdbLogfileGroupImpl& getImpl(const
@@ -403,7 +403,7 @@ public:
NdbDatafileImpl(NdbDictionary::Datafile &);
~NdbDatafileImpl();
- void assign(const NdbDatafileImpl&);
+ int assign(const NdbDatafileImpl&);
static NdbDatafileImpl & getImpl(NdbDictionary::Datafile & t);
static const NdbDatafileImpl & getImpl(const NdbDictionary::Datafile & t);
@@ -416,7 +416,7 @@ public:
NdbUndofileImpl(NdbDictionary::Undofile &);
~NdbUndofileImpl();
- void assign(const NdbUndofileImpl&);
+ int assign(const NdbUndofileImpl&);
static NdbUndofileImpl & getImpl(NdbDictionary::Undofile & t);
static const NdbUndofileImpl & getImpl(const NdbDictionary::Undofile & t);
@@ -994,8 +994,9 @@ public:
if(NdbDictInterface::create_index_obj_from_table(&idx, &tab, &m_prim) == 0)
{
idx->m_table = &tab;
- idx->m_externalName.assign(m_index_name);
- idx->m_internalName.assign(m_name);
+ if (!idx->m_externalName.assign(m_index_name) ||
+ !idx->m_internalName.assign(m_name))
+ DBUG_RETURN(4000);
tab.m_index = idx;
DBUG_RETURN(0);
}
diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp
index c7221b88132..00acfe62ad9 100644
--- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp
+++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp
@@ -983,7 +983,7 @@ NdbEventOperationImpl::printAll()
NdbEventBuffer::NdbEventBuffer(Ndb *ndb) :
m_system_nodes(ndb->theImpl->theNoOfDBnodes),
m_ndb(ndb),
- m_latestGCI(0),
+ m_latestGCI(0), m_latest_complete_GCI(0),
m_total_alloc(0),
m_free_thresh(10),
m_min_free_thresh(10),
@@ -1475,7 +1475,7 @@ NdbEventBuffer::execSUB_GCP_COMPLETE_REP(const SubGcpCompleteRep * const rep)
, m_flush_gci
#endif
);
-
+ Uint32 idx = bucket - (Gci_container*)m_active_gci.getBase();
if (unlikely(bucket == 0))
{
/**
@@ -1520,8 +1520,20 @@ NdbEventBuffer::execSUB_GCP_COMPLETE_REP(const SubGcpCompleteRep * const rep)
}
reportStatus();
bzero(bucket, sizeof(Gci_container));
- bucket->m_gci = gci + ACTIVE_GCI_DIRECTORY_SIZE;
- bucket->m_gcp_complete_rep_count = m_system_nodes;
+ if (likely(idx < ACTIVE_GCI_DIRECTORY_SIZE))
+ {
+ /**
+ * Only "prepare" next GCI if we're in
+ * the first 4 highest GCI's...else
+ * this is somekind of "late" GCI...
+ * which is only initialized to 0
+ *
+ * This to make sure we dont get several buckets with same GCI
+ */
+ bucket->m_gci = gci + ACTIVE_GCI_DIRECTORY_SIZE;
+ bucket->m_gcp_complete_rep_count = m_system_nodes;
+ }
+
if(unlikely(m_latest_complete_GCI > gci))
{
complete_outof_order_gcis();
diff --git a/storage/ndb/src/ndbapi/NdbImpl.hpp b/storage/ndb/src/ndbapi/NdbImpl.hpp
index 083871061b4..33dfde58c49 100644
--- a/storage/ndb/src/ndbapi/NdbImpl.hpp
+++ b/storage/ndb/src/ndbapi/NdbImpl.hpp
@@ -37,7 +37,7 @@ struct Ndb_free_list_t
Ndb_free_list_t();
~Ndb_free_list_t();
- void fill(Ndb*, Uint32 cnt);
+ int fill(Ndb*, Uint32 cnt);
T* seize(Ndb*);
void release(T*);
void clear();
@@ -86,10 +86,14 @@ public:
BaseString m_prefix; // Buffer for preformatted internal name <db>/<schema>/
- void update_prefix()
+ int update_prefix()
{
- m_prefix.assfmt("%s%c%s%c", m_dbname.c_str(), table_name_separator,
- m_schemaname.c_str(), table_name_separator);
+ if (!m_prefix.assfmt("%s%c%s%c", m_dbname.c_str(), table_name_separator,
+ m_schemaname.c_str(), table_name_separator))
+ {
+ return -1;
+ }
+ return 0;
}
BaseString m_systemPrefix; // Buffer for preformatted for <sys>/<def>/
@@ -203,7 +207,7 @@ Ndb_free_list_t<T>::~Ndb_free_list_t()
template<class T>
inline
-void
+int
Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt)
{
if (m_free_list == 0)
@@ -211,18 +215,28 @@ Ndb_free_list_t<T>::fill(Ndb* ndb, Uint32 cnt)
m_free_cnt++;
m_alloc_cnt++;
m_free_list = new T(ndb);
+ if (m_free_list == 0)
+ {
+ ndb->theError.code = 4000;
+ assert(false);
+ return -1;
+ }
}
while(m_alloc_cnt < cnt)
{
T* obj= new T(ndb);
if(obj == 0)
- return;
-
+ {
+ ndb->theError.code = 4000;
+ assert(false);
+ return -1;
+ }
obj->next(m_free_list);
m_free_cnt++;
m_alloc_cnt++;
m_free_list = obj;
}
+ return 0;
}
template<class T>
@@ -243,7 +257,11 @@ Ndb_free_list_t<T>::seize(Ndb* ndb)
{
m_alloc_cnt++;
}
-
+ else
+ {
+ ndb->theError.code = 4000;
+ assert(false);
+ }
return tmp;
}
diff --git a/storage/ndb/src/ndbapi/NdbOperation.cpp b/storage/ndb/src/ndbapi/NdbOperation.cpp
index 9b3d20a1c33..903372ddb9d 100644
--- a/storage/ndb/src/ndbapi/NdbOperation.cpp
+++ b/storage/ndb/src/ndbapi/NdbOperation.cpp
@@ -177,7 +177,11 @@ NdbOperation::init(const NdbTableImpl* tab, NdbTransaction* myConnection){
tcKeyReq->scanInfo = 0;
theKEYINFOptr = &tcKeyReq->keyInfo[0];
theATTRINFOptr = &tcKeyReq->attrInfo[0];
- theReceiver.init(NdbReceiver::NDB_OPERATION, this);
+ if (theReceiver.init(NdbReceiver::NDB_OPERATION, this))
+ {
+ // theReceiver sets the error code of its owner
+ return -1;
+ }
return 0;
}
diff --git a/storage/ndb/src/ndbapi/NdbRecAttr.cpp b/storage/ndb/src/ndbapi/NdbRecAttr.cpp
index 20fa83e849d..7615ee71c65 100644
--- a/storage/ndb/src/ndbapi/NdbRecAttr.cpp
+++ b/storage/ndb/src/ndbapi/NdbRecAttr.cpp
@@ -81,6 +81,7 @@ NdbRecAttr::setup(const NdbColumnImpl* anAttrInfo, char* aValue)
theRef = tRef;
return 0;
}
+ errno = ENOMEM;
return -1;
}
@@ -100,7 +101,11 @@ NdbRecAttr::copyout()
NdbRecAttr *
NdbRecAttr::clone() const {
NdbRecAttr * ret = new NdbRecAttr(0);
-
+ if (ret == NULL)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
ret->theAttrId = theAttrId;
ret->m_size_in_bytes = m_size_in_bytes;
ret->m_column = m_column;
@@ -112,6 +117,12 @@ NdbRecAttr::clone() const {
ret->theValue = 0;
} else {
ret->theStorageX = new Uint64[((n + 7) >> 3)];
+ if (ret->theStorageX == NULL)
+ {
+ delete ret;
+ errno = ENOMEM;
+ return NULL;
+ }
ret->theRef = (char*)ret->theStorageX;
ret->theValue = 0;
}
@@ -506,3 +517,15 @@ NdbRecAttr::double_value() const
memcpy(&val,theRef,sizeof(val));
return val;
}
+
+Int32
+NdbRecAttr::medium_value() const
+{
+ return sint3korr((unsigned char *)theRef);
+}
+
+Uint32
+NdbRecAttr::u_medium_value() const
+{
+ return uint3korr((unsigned char*)theRef);
+}
diff --git a/storage/ndb/src/ndbapi/NdbReceiver.cpp b/storage/ndb/src/ndbapi/NdbReceiver.cpp
index 8f91cd10be0..34b3a14ac6e 100644
--- a/storage/ndb/src/ndbapi/NdbReceiver.cpp
+++ b/storage/ndb/src/ndbapi/NdbReceiver.cpp
@@ -32,7 +32,7 @@ NdbReceiver::NdbReceiver(Ndb *aNdb) :
{
theCurrentRecAttr = theFirstRecAttr = 0;
m_defined_rows = 0;
- m_rows = new NdbRecAttr*[0];
+ m_rows = NULL;
}
NdbReceiver::~NdbReceiver()
@@ -45,19 +45,26 @@ NdbReceiver::~NdbReceiver()
DBUG_VOID_RETURN;
}
-void
+int
NdbReceiver::init(ReceiverType type, void* owner)
{
theMagicNumber = 0x11223344;
m_type = type;
m_owner = owner;
+ theFirstRecAttr = NULL;
+ theCurrentRecAttr = NULL;
if (m_id == NdbObjectIdMap::InvalidId) {
if (m_ndb)
+ {
m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this);
+ if (m_id == NdbObjectIdMap::InvalidId)
+ {
+ setErrorCode(4000);
+ return -1;
+ }
+ }
}
-
- theFirstRecAttr = NULL;
- theCurrentRecAttr = NULL;
+ return 0;
}
void
@@ -146,7 +153,7 @@ NdbReceiver::calculate_batch_size(Uint32 key_size,
return;
}
-void
+int
NdbReceiver::do_get_value(NdbReceiver * org,
Uint32 rows,
Uint32 key_size,
@@ -154,7 +161,11 @@ NdbReceiver::do_get_value(NdbReceiver * org,
if(rows > m_defined_rows){
delete[] m_rows;
m_defined_rows = rows;
- m_rows = new NdbRecAttr*[rows + 1];
+ if ((m_rows = new NdbRecAttr*[rows + 1]) == NULL)
+ {
+ setErrorCode(4000);
+ return -1;
+ }
}
m_rows[rows] = 0;
@@ -174,7 +185,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
// Put key-recAttr fir on each row
if(key_size && !getValue(&key, (char*)0)){
abort();
- return ; // -1
+ return -1;
}
if(range_no &&
@@ -193,7 +204,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
if(tRecAttr){
abort();
- return ;// -1;
+ return -1;
}
// Store first recAttr for each row in m_rows[i]
@@ -205,7 +216,7 @@ NdbReceiver::do_get_value(NdbReceiver * org,
}
prepareSend();
- return;
+ return 0;
}
NdbRecAttr*
diff --git a/storage/ndb/src/ndbapi/NdbScanFilter.cpp b/storage/ndb/src/ndbapi/NdbScanFilter.cpp
index eb0ef4ba391..fb47772fdea 100644
--- a/storage/ndb/src/ndbapi/NdbScanFilter.cpp
+++ b/storage/ndb/src/ndbapi/NdbScanFilter.cpp
@@ -78,7 +78,11 @@ NdbScanFilter::~NdbScanFilter(){
int
NdbScanFilter::begin(Group group){
- m_impl.m_stack2.push_back(m_impl.m_negative);
+ if (m_impl.m_stack2.push_back(m_impl.m_negative))
+ {
+ m_impl.m_operation->setErrorCodeAbort(4000);
+ return -1;
+ }
switch(group){
case NdbScanFilter::AND:
INT_DEBUG(("Begin(AND)"));
@@ -127,7 +131,11 @@ NdbScanFilter::begin(Group group){
}
NdbScanFilterImpl::State tmp = m_impl.m_current;
- m_impl.m_stack.push_back(m_impl.m_current);
+ if (m_impl.m_stack.push_back(m_impl.m_current))
+ {
+ m_impl.m_operation->setErrorCodeAbort(4000);
+ return -1;
+ }
m_impl.m_current.m_group = group;
m_impl.m_current.m_ownLabel = m_impl.m_label++;
m_impl.m_current.m_popCount = 0;
diff --git a/storage/ndb/src/ndbapi/NdbScanOperation.cpp b/storage/ndb/src/ndbapi/NdbScanOperation.cpp
index 30f9873c59f..c253dca8c61 100644
--- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp
+++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp
@@ -820,9 +820,12 @@ int NdbScanOperation::prepareSendScan(Uint32 aTC_ConnectPtr,
req->requestInfo = reqInfo;
for(Uint32 i = 0; i<theParallelism; i++){
- m_receivers[i]->do_get_value(&theReceiver, batch_size,
- key_size,
- m_read_range_no);
+ if (m_receivers[i]->do_get_value(&theReceiver, batch_size,
+ key_size,
+ m_read_range_no))
+ {
+ return -1;
+ }
}
return 0;
}
diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp
index 9d337c05fd9..a90c658c49b 100644
--- a/storage/ndb/src/ndbapi/NdbTransaction.cpp
+++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp
@@ -81,6 +81,7 @@ NdbTransaction::NdbTransaction( Ndb* aNdb ) :
{
theListState = NotInList;
theError.code = 0;
+ //theId = NdbObjectIdMap::InvalidId;
theId = theNdb->theImpl->theNdbObjectIdMap.map(this);
#define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz)
@@ -106,7 +107,7 @@ void init();
Remark: Initialise connection object for new transaction.
*****************************************************************************/
-void
+int
NdbTransaction::init()
{
theListState = NotInList;
@@ -148,6 +149,17 @@ NdbTransaction::init()
//
theBlobFlag = false;
thePendingBlobOps = 0;
+ if (theId == NdbObjectIdMap::InvalidId)
+ {
+ theId = theNdb->theImpl->theNdbObjectIdMap.map(this);
+ if (theId == NdbObjectIdMap::InvalidId)
+ {
+ theError.code = 4000;
+ return -1;
+ }
+ }
+ return 0;
+
}//NdbTransaction::init()
/*****************************************************************************
diff --git a/storage/ndb/src/ndbapi/Ndbif.cpp b/storage/ndb/src/ndbapi/Ndbif.cpp
index fba40659ec7..aa50a87dea8 100644
--- a/storage/ndb/src/ndbapi/Ndbif.cpp
+++ b/storage/ndb/src/ndbapi/Ndbif.cpp
@@ -940,8 +940,9 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
InvalidSignal:
#ifdef VM_TRACE
ndbout_c("Ndbif: Error Ndb::handleReceivedSignal "
- "(GSN=%d, theImpl->theWaiter.m_state=%d)"
+ "(tFirstDataPtr=%p, GSN=%d, theImpl->theWaiter.m_state=%d)"
" sender = (Block: %d Node: %d)",
+ tFirstDataPtr,
tSignalNumber,
tWaitState,
refToBlock(aSignal->theSendersBlockRef),
diff --git a/storage/ndb/src/ndbapi/Ndblist.cpp b/storage/ndb/src/ndbapi/Ndblist.cpp
index 6a8fabbcb30..a9e9124edd0 100644
--- a/storage/ndb/src/ndbapi/Ndblist.cpp
+++ b/storage/ndb/src/ndbapi/Ndblist.cpp
@@ -74,7 +74,10 @@ Ndb::checkFailedNode()
int
Ndb::createConIdleList(int aNrOfCon)
{
- theImpl->theConIdleList.fill(this, aNrOfCon);
+ if (theImpl->theConIdleList.fill(this, aNrOfCon))
+ {
+ return -1;
+ }
return aNrOfCon;
}
@@ -90,7 +93,10 @@ Ndb::createConIdleList(int aNrOfCon)
int
Ndb::createOpIdleList(int aNrOfOp)
{
- theImpl->theOpIdleList.fill(this, aNrOfOp);
+ if (theImpl->theOpIdleList.fill(this, aNrOfOp))
+ {
+ return -1;
+ }
return aNrOfOp;
}
diff --git a/storage/ndb/src/ndbapi/ObjectMap.cpp b/storage/ndb/src/ndbapi/ObjectMap.cpp
new file mode 100644
index 00000000000..c87911a10d4
--- /dev/null
+++ b/storage/ndb/src/ndbapi/ObjectMap.cpp
@@ -0,0 +1,62 @@
+/* Copyright (C) 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.
+
+ 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 */
+
+#include "ObjectMap.hpp"
+
+NdbObjectIdMap::NdbObjectIdMap(NdbMutex* mutex, Uint32 sz, Uint32 eSz)
+{
+ m_size = 0;
+ m_firstFree = InvalidId;
+ m_map = 0;
+ m_mutex = mutex;
+ m_expandSize = eSz;
+ expand(sz);
+#ifdef DEBUG_OBJECTMAP
+ ndbout_c("NdbObjectIdMap:::NdbObjectIdMap(%u)", sz);
+#endif
+}
+
+NdbObjectIdMap::~NdbObjectIdMap()
+{
+ free(m_map);
+}
+
+int NdbObjectIdMap::expand(Uint32 incSize)
+{
+ NdbMutex_Lock(m_mutex);
+ Uint32 newSize = m_size + incSize;
+ MapEntry * tmp = (MapEntry*)realloc(m_map, newSize * sizeof(MapEntry));
+
+ if (likely(tmp != 0))
+ {
+ m_map = tmp;
+
+ for(Uint32 i = m_size; i < newSize; i++){
+ m_map[i].m_next = i + 1;
+ }
+ m_firstFree = m_size;
+ m_map[newSize-1].m_next = InvalidId;
+ m_size = newSize;
+ }
+ else
+ {
+ NdbMutex_Unlock(m_mutex);
+ g_eventLogger.error("NdbObjectIdMap::expand: realloc(%u*%u) failed",
+ newSize, sizeof(MapEntry));
+ return -1;
+ }
+ NdbMutex_Unlock(m_mutex);
+ return 0;
+}
diff --git a/storage/ndb/src/ndbapi/ObjectMap.hpp b/storage/ndb/src/ndbapi/ObjectMap.hpp
index 9113a70798a..bc171649840 100644
--- a/storage/ndb/src/ndbapi/ObjectMap.hpp
+++ b/storage/ndb/src/ndbapi/ObjectMap.hpp
@@ -20,6 +20,9 @@
//#include <NdbMutex.h>
#include <NdbOut.hpp>
+#include <EventLogger.hpp>
+extern EventLogger g_eventLogger;
+
//#define DEBUG_OBJECTMAP
/**
@@ -50,24 +53,6 @@ private:
};
inline
-NdbObjectIdMap::NdbObjectIdMap(NdbMutex* mutex, Uint32 sz, Uint32 eSz) {
- m_size = 0;
- m_firstFree = InvalidId;
- m_map = 0;
- m_mutex = mutex;
- m_expandSize = eSz;
- expand(sz);
-#ifdef DEBUG_OBJECTMAP
- ndbout_c("NdbObjectIdMap:::NdbObjectIdMap(%u)", sz);
-#endif
-}
-
-inline
-NdbObjectIdMap::~NdbObjectIdMap(){
- free(m_map);
-}
-
-inline
Uint32
NdbObjectIdMap::map(void * object){
@@ -100,8 +85,8 @@ NdbObjectIdMap::unmap(Uint32 id, void *object){
m_map[i].m_next = m_firstFree;
m_firstFree = i;
} else {
- ndbout_c("Error: NdbObjectIdMap::::unmap(%u, 0x%lx) obj=0x%lx",
- id, (long) object, (long) obj);
+ g_eventLogger.error("NdbObjectIdMap::unmap(%u, 0x%x) obj=0x%x",
+ id, (long) object, (long) obj);
DBUG_PRINT("error",("NdbObjectIdMap::unmap(%u, 0x%lx) obj=0x%lx",
id, (long) object, (long) obj));
return 0;
@@ -125,31 +110,4 @@ NdbObjectIdMap::getObject(Uint32 id){
}
return 0;
}
-
-inline int
-NdbObjectIdMap::expand(Uint32 incSize){
- NdbMutex_Lock(m_mutex);
- Uint32 newSize = m_size + incSize;
- MapEntry * tmp = (MapEntry*)realloc(m_map, newSize * sizeof(MapEntry));
-
- if (likely(tmp != 0))
- {
- m_map = tmp;
-
- for(Uint32 i = m_size; i<newSize; i++){
- m_map[i].m_next = i + 1;
- }
- m_firstFree = m_size;
- m_map[newSize-1].m_next = InvalidId;
- m_size = newSize;
- }
- else
- {
- NdbMutex_Unlock(m_mutex);
- return -1;
- }
- NdbMutex_Unlock(m_mutex);
- return 0;
-}
-
#endif
diff --git a/storage/ndb/src/ndbapi/SignalSender.cpp b/storage/ndb/src/ndbapi/SignalSender.cpp
index d6d9f4446ce..70e65200942 100644
--- a/storage/ndb/src/ndbapi/SignalSender.cpp
+++ b/storage/ndb/src/ndbapi/SignalSender.cpp
@@ -137,7 +137,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t)
{
SimpleSignal * s = t.check(m_jobBuffer);
if(s != 0){
- m_usedBuffer.push_back(s);
+ if (m_usedBuffer.push_back(s))
+ {
+ return 0;
+ }
return s;
}
@@ -152,7 +155,10 @@ SignalSender::waitFor(Uint32 timeOutMillis, T & t)
SimpleSignal * s = t.check(m_jobBuffer);
if(s != 0){
- m_usedBuffer.push_back(s);
+ if (m_usedBuffer.push_back(s))
+ {
+ return 0;
+ }
return s;
}
diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
index 964037017f1..38744fbdeba 100644
--- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
+++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
@@ -330,6 +330,8 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
NdbColumnImpl::create_pseudo("NDB$ROW_GCI");
NdbDictionary::Column::ANY_VALUE=
NdbColumnImpl::create_pseudo("NDB$ANY_VALUE");
+ NdbDictionary::Column::COPY_ROWID=
+ NdbColumnImpl::create_pseudo("NDB$COPY_ROWID");
}
NdbMutex_Unlock(g_ndb_connection_mutex);
@@ -397,6 +399,9 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
NdbDictionary::Column::ROWID= 0;
NdbDictionary::Column::ROW_GCI= 0;
NdbDictionary::Column::ANY_VALUE= 0;
+
+ delete NdbDictionary::Column::COPY_ROWID;
+ NdbDictionary::Column::COPY_ROWID = 0;
}
NdbMutex_Unlock(g_ndb_connection_mutex);
@@ -419,7 +424,7 @@ Ndb_cluster_connection_impl::set_name(const char *name)
}
}
-void
+int
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
const ndb_mgm_configuration
&config)
@@ -465,7 +470,10 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
break;
}
}
- m_impl.m_all_nodes.push_back(Node(group,remoteNodeId));
+ if (m_impl.m_all_nodes.push_back(Node(group,remoteNodeId)))
+ {
+ DBUG_RETURN(-1);
+ }
DBUG_PRINT("info",("saved %d %d", group,remoteNodeId));
for (int i= m_impl.m_all_nodes.size()-2;
i >= 0 && m_impl.m_all_nodes[i].group > m_impl.m_all_nodes[i+1].group;
@@ -512,7 +520,7 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
do_test();
#endif
- DBUG_VOID_RETURN;
+ DBUG_RETURN(0);
}
void
@@ -595,7 +603,11 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
break;
m_impl.m_transporter_facade->start_instance(nodeId, props);
- m_impl.init_nodes_vector(nodeId, *props);
+ if (m_impl.init_nodes_vector(nodeId, *props))
+ {
+ ndbout_c("Ndb_cluster_connection::connect: malloc failure");
+ DBUG_RETURN(-1);
+ }
for(unsigned i=0;
i<m_impl.m_transporter_facade->get_registry()->m_transporter_interface.size();
diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp
index a8b774ec2b8..ba488c56ec7 100644
--- a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp
+++ b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp
@@ -66,7 +66,7 @@ private:
};
Vector<Node> m_all_nodes;
- void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
+ int init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
void connect_thread();
void set_name(const char *name);
diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c
index b21b64156c8..df9778b1c73 100644
--- a/storage/ndb/src/ndbapi/ndberror.c
+++ b/storage/ndb/src/ndbapi/ndberror.c
@@ -491,6 +491,7 @@ ErrorBundle ErrorCodes[] = {
{ 1419, DMEC, SE, "Subscription already dropped" },
{ 1420, DMEC, TR, "Subscriber manager busy with adding/removing a table" },
+ { 1421, DMEC, SE, "Partially connected API in NdbOperation::execute()" },
{ 4004, DMEC, AE, "Attribute name or id not found in the table" },
diff --git a/storage/ndb/test/include/HugoOperations.hpp b/storage/ndb/test/include/HugoOperations.hpp
index 3147ee57d4d..a0766af4b50 100644
--- a/storage/ndb/test/include/HugoOperations.hpp
+++ b/storage/ndb/test/include/HugoOperations.hpp
@@ -83,6 +83,8 @@ public:
int equalForAttr(NdbOperation*,
int attrId,
int rowId);
+
+ int equalForRow(NdbOperation*, int rowid);
int setValues(NdbOperation*, int rowId, int updateId);
diff --git a/storage/ndb/test/ndbapi/testBasic.cpp b/storage/ndb/test/ndbapi/testBasic.cpp
index 83c2628f8b0..a032e29bc74 100644
--- a/storage/ndb/test/ndbapi/testBasic.cpp
+++ b/storage/ndb/test/ndbapi/testBasic.cpp
@@ -1318,6 +1318,64 @@ runDeleteRead(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK;
}
+int
+runBug27756(NDBT_Context* ctx, NDBT_Step* step)
+{
+
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary * dict = pNdb->getDictionary();
+
+ HugoOperations ops(*ctx->getTab());
+
+ int loops = ctx->getNumLoops();
+ const int rows = ctx->getNumRecords();
+
+ Vector<Uint64> copies;
+ while (loops--)
+ {
+ ops.startTransaction(pNdb);
+ ops.pkInsertRecord(pNdb, 1, 1);
+ ops.execute_NoCommit(pNdb);
+
+ NdbTransaction* pTrans = ops.getTransaction();
+ NdbOperation* op = pTrans->getNdbOperation(ctx->getTab()->getName());
+ op->interpretedUpdateTuple();
+ ops.equalForRow(op, 1);
+ NdbRecAttr* attr = op->getValue(NdbDictionary::Column::COPY_ROWID);
+ ops.execute_NoCommit(pNdb);
+
+ copies.push_back(attr->u_64_value());
+ ndbout_c("copy at: %llx", copies.back());
+ ops.execute_NoCommit(pNdb);
+
+ ops.pkDeleteRecord(pNdb, 1, 1);
+ ops.execute_NoCommit(pNdb);
+
+ if (loops & 1)
+ {
+ ops.execute_Rollback(pNdb);
+ ops.closeTransaction(pNdb);
+ }
+ else
+ {
+ ops.execute_Commit(pNdb);
+ ops.closeTransaction(pNdb);
+ ops.clearTable(pNdb, 100);
+ }
+ }
+
+ for (Uint32 i = 0; i<copies.size(); i++)
+ if (copies[i] != copies.back())
+ {
+ ndbout_c("Memleak detected");
+ return NDBT_FAILED;
+ }
+
+ return NDBT_OK;
+}
+
+template class Vector<Uint64>;
+
NDBT_TESTSUITE(testBasic);
TESTCASE("PkInsert",
"Verify that we can insert and delete from this table using PK"
@@ -1594,6 +1652,10 @@ TESTCASE("DeleteRead",
INITIALIZER(runDeleteRead);
FINALIZER(runClearTable2);
}
+TESTCASE("Bug27756",
+ "Verify what happens when we fill the db" ){
+ STEP(runBug27756);
+}
NDBT_TESTSUITE_END(testBasic);
#if 0
diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt
index 59535958249..4693dbfa781 100644
--- a/storage/ndb/test/run-test/daily-basic-tests.txt
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt
@@ -239,6 +239,10 @@ max-time: 500
cmd: testBasic
args: -n Bug25090 T1
+max-time: 1000
+cmd: testBasic
+args: -n Bug27756
+
max-time: 500
cmd: testIndex
args: -n Bug25059 -r 3000 T1
diff --git a/storage/ndb/test/src/HugoAsynchTransactions.cpp b/storage/ndb/test/src/HugoAsynchTransactions.cpp
index 6926c8a973e..0a5991d9e20 100644
--- a/storage/ndb/test/src/HugoAsynchTransactions.cpp
+++ b/storage/ndb/test/src/HugoAsynchTransactions.cpp
@@ -188,14 +188,11 @@ HugoAsynchTransactions::pkUpdateRecordsAsynch(Ndb* pNdb,
// Read
// Define primary keys
check = pOp->readTupleExclusive();
- for (a = 0; a < tab.getNoOfColumns(); a++) {
- if (tab.getColumn(a)->getPrimaryKey() == true) {
- if (equalForAttr(pOp, a, cReadRecords) != 0){
- ERR(transactions[t]->getNdbError());
- pNdb->closeTransaction(transactions[t]);
- return NDBT_FAILED;
- }
- }
+ if (equalForRow(pOp, cReadRecords) != 0)
+ {
+ ERR(transactions[t]->getNdbError());
+ pNdb->closeTransaction(transactions[t]);
+ return NDBT_FAILED;
}
// Define attributes to read
for (a = 0; a < tab.getNoOfColumns(); a++) {
@@ -259,15 +256,12 @@ HugoAsynchTransactions::pkUpdateRecordsAsynch(Ndb* pNdb,
}
// Set search condition for the record
- for (a = 0; a < tab.getNoOfColumns(); a++) {
- if (tab.getColumn(a)->getPrimaryKey() == true) {
- if (equalForAttr(pOp, a, cRecords) != 0) {
- ERR(transactions[t]->getNdbError());
- pNdb->closeTransaction(transactions[t]);
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, cReadRecords) != 0)
+ {
+ ERR(transactions[t]->getNdbError());
+ pNdb->closeTransaction(transactions[t]);
+ return NDBT_FAILED;
+ }
// Update the record
for (a = 0; a < tab.getNoOfColumns(); a++) {
@@ -396,15 +390,12 @@ HugoAsynchTransactions::executeAsynchOperation(Ndb* pNdb,
case NO_READ:
// Define primary keys
check = pOp->readTuple();
- for (a = 0; a < tab.getNoOfColumns(); a++) {
- if (tab.getColumn(a)->getPrimaryKey() == true) {
- if (equalForAttr(pOp, a, cRecords) != 0){
- ERR(transactions[t]->getNdbError());
- pNdb->closeTransaction(transactions[t]);
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, cRecords) != 0)
+ {
+ ERR(transactions[t]->getNdbError());
+ pNdb->closeTransaction(transactions[t]);
+ return NDBT_FAILED;
+ }
// Define attributes to read
for (a = 0; a < tab.getNoOfColumns(); a++) {
if ((rows[cIndex]->attributeStore(a) =
@@ -425,15 +416,12 @@ HugoAsynchTransactions::executeAsynchOperation(Ndb* pNdb,
}
// Define primary keys
- for (a = 0; a < tab.getNoOfColumns(); a++) {
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if (equalForAttr(pOp, a, cRecords) != 0) {
- ERR(transactions[t]->getNdbError());
- pNdb->closeTransaction(transactions[t]);
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, cRecords) != 0)
+ {
+ ERR(transactions[t]->getNdbError());
+ pNdb->closeTransaction(transactions[t]);
+ return NDBT_FAILED;
+ }
break;
default:
// Should not happen...
diff --git a/storage/ndb/test/src/HugoOperations.cpp b/storage/ndb/test/src/HugoOperations.cpp
index 9a286a71b91..481ce0c0567 100644
--- a/storage/ndb/test/src/HugoOperations.cpp
+++ b/storage/ndb/test/src/HugoOperations.cpp
@@ -111,14 +111,8 @@ rand_lock_mode:
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+recordNo) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, r+recordNo) != 0)
+ return NDBT_FAILED;
if(pIndexScanOp)
pIndexScanOp->end_of_bound(r);
@@ -143,7 +137,6 @@ int HugoOperations::pkUpdateRecord(Ndb* pNdb,
int recordNo,
int numRecords,
int updatesValue){
- int a;
allocRows(numRecords);
int check;
for(int r=0; r < numRecords; r++){
@@ -172,14 +165,8 @@ HugoOperations::setValues(NdbOperation* pOp, int rowId, int updateId)
{
// Define primary keys
int a;
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, rowId) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, rowId) != 0)
+ return NDBT_FAILED;
for(a = 0; a<tab.getNoOfColumns(); a++){
if (tab.getColumn(a)->getPrimaryKey() == false){
@@ -198,7 +185,7 @@ int HugoOperations::pkInsertRecord(Ndb* pNdb,
int numRecords,
int updatesValue){
- int a, check;
+ int check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = getOperation(pTrans, NdbOperation::InsertRequest);
if (pOp == NULL) {
@@ -240,14 +227,8 @@ int HugoOperations::pkWriteRecord(Ndb* pNdb,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+recordNo) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, r+recordNo) != 0)
+ return NDBT_FAILED;
// Define attributes to update
for(a = 0; a<tab.getNoOfColumns(); a++){
@@ -266,7 +247,7 @@ int HugoOperations::pkWritePartialRecord(Ndb* pNdb,
int recordNo,
int numRecords){
- int a, check;
+ int check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());
if (pOp == NULL) {
@@ -281,14 +262,8 @@ int HugoOperations::pkWritePartialRecord(Ndb* pNdb,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+recordNo) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, r+recordNo) != 0)
+ return NDBT_FAILED;
}
return NDBT_OK;
}
@@ -297,7 +272,7 @@ int HugoOperations::pkDeleteRecord(Ndb* pNdb,
int recordNo,
int numRecords){
- int a, check;
+ int check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = getOperation(pTrans, NdbOperation::DeleteRequest);
if (pOp == NULL) {
@@ -312,14 +287,8 @@ int HugoOperations::pkDeleteRecord(Ndb* pNdb,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+recordNo) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, r+recordNo) != 0)
+ return NDBT_FAILED;
}
return NDBT_OK;
}
@@ -521,6 +490,22 @@ HugoOperations::~HugoOperations(){
}
}
+int
+HugoOperations::equalForRow(NdbOperation* pOp, int row)
+{
+ for(int a = 0; a<tab.getNoOfColumns(); a++)
+ {
+ if (tab.getColumn(a)->getPrimaryKey() == true)
+ {
+ if(equalForAttr(pOp, a, row) != 0)
+ {
+ ERR(pOp->getNdbError());
+ return NDBT_FAILED;
+ }
+ }
+ }
+ return NDBT_OK;
+}
int HugoOperations::equalForAttr(NdbOperation* pOp,
int attrId,
@@ -679,14 +664,8 @@ int HugoOperations::indexReadRecords(Ndb*, const char * idxName, int recordNo,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+recordNo) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, r+recordNo) != 0)
+ return NDBT_FAILED;
// Define attributes to read
for(a = 0; a<tab.getNoOfColumns(); a++){
@@ -723,14 +702,8 @@ HugoOperations::indexUpdateRecord(Ndb*,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+recordNo) != 0){
- ERR(pTrans->getNdbError());
- return NDBT_FAILED;
- }
- }
- }
+ if (equalForRow(pOp, r+recordNo) != 0)
+ return NDBT_FAILED;
// Define attributes to update
for(a = 0; a<tab.getNoOfColumns(); a++){
diff --git a/storage/ndb/test/src/HugoTransactions.cpp b/storage/ndb/test/src/HugoTransactions.cpp
index 34f77d9a2da..f0f042d306b 100644
--- a/storage/ndb/test/src/HugoTransactions.cpp
+++ b/storage/ndb/test/src/HugoTransactions.cpp
@@ -520,10 +520,9 @@ HugoTransactions::loadTable(Ndb* pNdb,
bool oneTrans,
int value,
bool abort){
- int check, a;
+ int check;
int retryAttempt = 0;
int retryMax = 5;
- NdbOperation *pOp;
bool first_batch = true;
const int org = batch;
@@ -667,10 +666,9 @@ HugoTransactions::loadTable(Ndb* pNdb,
int
HugoTransactions::fillTable(Ndb* pNdb,
int batch){
- int check, a, b;
+ int check;
int retryAttempt = 0;
int retryMax = 5;
- NdbOperation *pOp;
const int org = batch;
const int cols = tab.getNoOfColumns();
@@ -791,7 +789,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb,
int reads = 0;
int r = 0;
int retryAttempt = 0;
- int check, a;
+ int check;
if (batch == 0) {
g_info << "ERROR: Argument batch == 0 in pkReadRecords(). Not allowed." << endl;
@@ -910,8 +908,7 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb,
int updated = 0;
int r = 0;
int retryAttempt = 0;
- int check, a, b;
- NdbOperation *pOp;
+ int check, b;
allocRows(batch);
@@ -1097,14 +1094,10 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r) != 0){
- ERR(pTrans->getNdbError());
- closeTransaction(pNdb);
- return NDBT_FAILED;
- }
- }
+ if (equalForRow(pOp, r) != 0)
+ {
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
}
// Read update value
@@ -1153,14 +1146,10 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
}
// PKs
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pUpdOp, a, r) != 0){
- ERR(pTrans->getNdbError());
- closeTransaction(pNdb);
- return NDBT_FAILED;
- }
- }
+ if (equalForRow(pOp, r) != 0)
+ {
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
}
// Update col
@@ -1236,8 +1225,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb,
int deleted = 0;
int r = 0;
int retryAttempt = 0;
- int check, a;
- NdbOperation *pOp;
+ int check;
g_info << "|- Deleting records..." << endl;
while (r < records){
@@ -1335,8 +1323,7 @@ HugoTransactions::lockRecords(Ndb* pNdb,
// and lock som other records
int r = 0;
int retryAttempt = 0;
- int check, a, b;
- NdbOperation *pOp;
+ int check;
NdbOperation::LockMode lm = NdbOperation::LM_Exclusive;
// Calculate how many records to lock in each batch
@@ -1522,14 +1509,10 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+b) != 0){
- ERR(pTrans->getNdbError());
- closeTransaction(pNdb);
- return NDBT_FAILED;
- }
- }
+ if (equalForRow(pOp, r+b) != 0)
+ {
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
}
// Define attributes to read
@@ -1663,14 +1646,10 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
}
// Define primary keys
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pOp, a, r+b) != 0){
- ERR(pTrans->getNdbError());
- closeTransaction(pNdb);
- return NDBT_FAILED;
- }
- }
+ if (equalForRow(pOp, r+b) != 0)
+ {
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
}
// Define attributes to read
@@ -1733,16 +1712,13 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
return NDBT_FAILED;
}
- if(!ordered){
- for(a = 0; a<tab.getNoOfColumns(); a++){
- if (tab.getColumn(a)->getPrimaryKey() == true){
- if(equalForAttr(pUpdOp, a, r+b) != 0){
- ERR(pTrans->getNdbError());
- closeTransaction(pNdb);
- return NDBT_FAILED;
- }
- }
- }
+ if(!ordered)
+ {
+ if (equalForRow(pOp, r+b) != 0)
+ {
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
+ }
}
for(a = 0; a<tab.getNoOfColumns(); a++){
diff --git a/storage/ndb/test/tools/Makefile.am b/storage/ndb/test/tools/Makefile.am
index 386a59f723f..25b4e20a682 100644
--- a/storage/ndb/test/tools/Makefile.am
+++ b/storage/ndb/test/tools/Makefile.am
@@ -13,7 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-ndbtest_PROGRAMS = hugoLoad hugoFill hugoLockRecords hugoPkDelete hugoPkRead hugoPkReadRecord hugoPkUpdate hugoScanRead hugoScanUpdate restart verify_index copy_tab create_index ndb_cpcc listen_event
+ndbtest_PROGRAMS = hugoLoad hugoFill hugoLockRecords hugoPkDelete hugoPkRead hugoPkReadRecord hugoPkUpdate hugoScanRead hugoScanUpdate restart verify_index copy_tab create_index ndb_cpcc listen_event eventlog
# transproxy
@@ -33,6 +33,7 @@ copy_tab_SOURCES = copy_tab.cpp
create_index_SOURCES = create_index.cpp
ndb_cpcc_SOURCES = cpcc.cpp
listen_event_SOURCES = listen.cpp
+eventlog_SOURCES = log_listner.cpp
include $(top_srcdir)/storage/ndb/config/common.mk.am
include $(top_srcdir)/storage/ndb/config/type_ndbapitest.mk.am
diff --git a/storage/ndb/test/tools/log_listner.cpp b/storage/ndb/test/tools/log_listner.cpp
new file mode 100644
index 00000000000..c5125ef7414
--- /dev/null
+++ b/storage/ndb/test/tools/log_listner.cpp
@@ -0,0 +1,88 @@
+#include <mgmapi.h>
+#include <ndb_global.h>
+#include <ndb_opts.h>
+#include <NDBT.hpp>
+
+NDB_STD_OPTS_VARS;
+
+static struct my_option my_long_options[] =
+{
+ NDB_STD_OPTS("ndb_logevent_listen"),
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+static void usage()
+{
+ char desc[] =
+ "tabname\n"\
+ "This program list all properties of table(s) in NDB Cluster.\n"\
+ " ex: desc T1 T2 T4\n";
+ ndb_std_print_version();
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+}
+
+int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP,
+ 15, NDB_MGM_EVENT_CATEGORY_CONNECTION,
+ 15, NDB_MGM_EVENT_CATEGORY_NODE_RESTART,
+ 15, NDB_MGM_EVENT_CATEGORY_STARTUP,
+ 15, NDB_MGM_EVENT_CATEGORY_SHUTDOWN,
+ 15, NDB_MGM_EVENT_CATEGORY_STATISTIC,
+ 15, NDB_MGM_EVENT_CATEGORY_ERROR,
+ 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT,
+ 15, NDB_MGM_EVENT_CATEGORY_CONGESTION,
+ 0 };
+
+int
+main(int argc, char** argv)
+{
+ NDB_INIT(argv[0]);
+ const char *load_default_groups[]= { "mysql_cluster",0 };
+ load_defaults("my",load_default_groups,&argc,&argv);
+ int ho_error;
+#ifndef DBUG_OFF
+ opt_debug= "d:t:O,/tmp/ndb_desc.trace";
+#endif
+ if ((ho_error=handle_options(&argc, &argv, my_long_options,
+ ndb_std_get_one_option)))
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+
+ NdbMgmHandle handle= ndb_mgm_create_handle();
+ ndb_mgm_set_connectstring(handle, opt_connect_str);
+
+ while (true)
+ {
+ if (ndb_mgm_connect(handle,0,0,0) == -1)
+ {
+ ndbout_c("Failed to connect");
+ exit(0);
+ }
+
+ NdbLogEventHandle le = ndb_mgm_create_logevent_handle(handle, filter);
+ if (le == 0)
+ {
+ ndbout_c("Failed to create logevent handle");
+ exit(0);
+ }
+
+ struct ndb_logevent event;
+ while (true)
+ {
+ int r= ndb_logevent_get_next(le, &event,5000);
+ if (r < 0)
+ {
+ ndbout_c("Error while getting next event");
+ break;
+ }
+ if (r == 0)
+ {
+ continue;
+ }
+ ndbout_c("Got event: %d", event.type);
+ }
+
+ ndb_mgm_destroy_logevent_handle(&le);
+ ndb_mgm_disconnect(handle);
+ }
+
+ return 0;
+}
diff --git a/storage/ndb/tools/restore/Restore.hpp b/storage/ndb/tools/restore/Restore.hpp
index 406899b2b4d..5455fa17aa0 100644
--- a/storage/ndb/tools/restore/Restore.hpp
+++ b/storage/ndb/tools/restore/Restore.hpp
@@ -217,6 +217,9 @@ public:
memcpy(&val.u32,data,4);
v= val.u32;
break;
+ case 24:
+ v= uint3korr((unsigned char*)data);
+ break;
case 16:
memcpy(&val.u16,data,2);
v= val.u16;
diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp
index e8f9842e554..3aa36089e42 100644
--- a/storage/ndb/tools/restore/consumer_restore.cpp
+++ b/storage/ndb/tools/restore/consumer_restore.cpp
@@ -813,7 +813,7 @@ BackupRestore::table(const TableS & table){
BaseString tmp(name);
Vector<BaseString> split;
if(tmp.split(split, "/") != 3){
- err << "Invalid table name format " << name << endl;
+ err << "Invalid table name format `" << name << "`" << endl;
return false;
}
@@ -881,7 +881,7 @@ BackupRestore::table(const TableS & table){
if (dict->createTable(copy) == -1)
{
- err << "Create table " << table.getTableName() << " failed: "
+ err << "Create table `" << table.getTableName() << "` failed: "
<< dict->getNdbError() << endl;
if (dict->getNdbError().code == 771)
{
@@ -898,12 +898,13 @@ BackupRestore::table(const TableS & table){
}
return false;
}
- info << "Successfully restored table " << table.getTableName()<< endl ;
+ info << "Successfully restored table `"
+ << table.getTableName() << "`" << endl;
}
const NdbDictionary::Table* tab = dict->getTable(split[2].c_str());
if(tab == 0){
- err << "Unable to find table: " << split[2].c_str() << endl;
+ err << "Unable to find table: `" << split[2].c_str() << "`" << endl;
return false;
}
if(m_restore_meta)
@@ -965,12 +966,15 @@ BackupRestore::endOfTables(){
for(size_t i = 0; i<m_indexes.size(); i++){
NdbTableImpl & indtab = NdbTableImpl::getImpl(* m_indexes[i]);
- BaseString tmp(indtab.m_primaryTable.c_str());
Vector<BaseString> split;
- if(tmp.split(split, "/") != 3){
- err << "Invalid table name format " << indtab.m_primaryTable.c_str()
- << endl;
- return false;
+ {
+ BaseString tmp(indtab.m_primaryTable.c_str());
+ if (tmp.split(split, "/") != 3)
+ {
+ err << "Invalid table name format `" << indtab.m_primaryTable.c_str()
+ << "`" << endl;
+ return false;
+ }
}
m_ndb->setDatabaseName(split[0].c_str());
@@ -978,39 +982,41 @@ BackupRestore::endOfTables(){
const NdbDictionary::Table * prim = dict->getTable(split[2].c_str());
if(prim == 0){
- err << "Unable to find base table \"" << split[2].c_str()
- << "\" for index "
- << indtab.getName() << endl;
+ err << "Unable to find base table `" << split[2].c_str()
+ << "` for index `"
+ << indtab.getName() << "`" << endl;
return false;
}
NdbTableImpl& base = NdbTableImpl::getImpl(*prim);
NdbIndexImpl* idx;
- int id;
- char idxName[255], buf[255];
- if(sscanf(indtab.getName(), "%[^/]/%[^/]/%d/%s",
- buf, buf, &id, idxName) != 4){
- err << "Invalid index name format " << indtab.getName() << endl;
- return false;
+ Vector<BaseString> split_idx;
+ {
+ BaseString tmp(indtab.getName());
+ if (tmp.split(split_idx, "/") != 4)
+ {
+ err << "Invalid index name format `" << indtab.getName() << "`" << endl;
+ return false;
+ }
}
if(NdbDictInterface::create_index_obj_from_table(&idx, &indtab, &base))
{
- err << "Failed to create index " << idxName
- << " on " << split[2].c_str() << endl;
+ err << "Failed to create index `" << split_idx[3]
+ << "` on " << split[2].c_str() << endl;
return false;
}
- idx->setName(idxName);
+ idx->setName(split_idx[3].c_str());
if(dict->createIndex(* idx) != 0)
{
delete idx;
- err << "Failed to create index " << idxName
- << " on " << split[2].c_str() << endl
+ err << "Failed to create index `" << split_idx[3].c_str()
+ << "` on `" << split[2].c_str() << "`" << endl
<< dict->getNdbError() << endl;
return false;
}
delete idx;
- info << "Successfully created index " << idxName
- << " on " << split[2].c_str() << endl;
+ info << "Successfully created index `" << split_idx[3].c_str()
+ << "` on `" << split[2].c_str() << "`" << endl;
}
return true;
}
@@ -1122,7 +1128,7 @@ void BackupRestore::tuple_a(restore_callback_t *cb)
Uint32 length = attr_data->size;
if (j == 0 && tup.getTable()->have_auto_inc(i))
- tup.getTable()->update_max_auto_val(dataPtr,size);
+ tup.getTable()->update_max_auto_val(dataPtr,size*arraySize);
if (attr_desc->m_column->getPrimaryKey())
{
@@ -1378,7 +1384,7 @@ BackupRestore::logEntry(const LogEntry & tup)
const char * dataPtr = attr->Data.string_value;
if (tup.m_table->have_auto_inc(attr->Desc->attrId))
- tup.m_table->update_max_auto_val(dataPtr,size);
+ tup.m_table->update_max_auto_val(dataPtr,size*arraySize);
const Uint32 length = (size / 8) * arraySize;
if (attr->Desc->m_column->getPrimaryKey())
diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp
index 8353f049647..adccd024d88 100644
--- a/storage/ndb/tools/restore/restore_main.cpp
+++ b/storage/ndb/tools/restore/restore_main.cpp
@@ -783,8 +783,8 @@ main(int argc, char** argv)
for(Uint32 j= 0; j < g_consumers.size(); j++)
if (!g_consumers[j]->table(* table))
{
- err << "Restore: Failed to restore table: ";
- err << table->getTableName() << " ... Exiting " << endl;
+ err << "Restore: Failed to restore table: `";
+ err << table->getTableName() << "` ... Exiting " << endl;
exitHandler(NDBT_FAILED);
}
} else {
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 1bdab2495c2..f9770cf8058 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -565,7 +565,6 @@ fi
%attr(755, root, root) %{_bindir}/myisamlog
%attr(755, root, root) %{_bindir}/myisampack
%attr(755, root, root) %{_bindir}/mysql_convert_table_format
-%attr(755, root, root) %{_bindir}/mysql_create_system_tables
%attr(755, root, root) %{_bindir}/mysql_fix_extensions
%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables
%attr(755, root, root) %{_bindir}/mysql_install_db
@@ -726,7 +725,20 @@ fi
# The spec file changelog only includes changes made to the spec file
# itself - note that they must be ordered by date (important when
# merging BK trees)
-%changelog
+%changelog
+* Sat Apr 07 2007 Kent Boortz <kent@mysql.com>
+
+- Removed man page for "mysql_create_system_tables"
+
+* Wed Mar 21 2007 Daniel Fischer <df@mysql.com>
+
+- Add debug server.
+
+* Mon Mar 19 2007 Daniel Fischer <df@mysql.com>
+
+- Remove Max RPMs; the server RPMs contain a mysqld compiled with all
+ features that previously only were built into Max.
+
* Fri Mar 02 2007 Joerg Bruehe <joerg@mysql.com>
- Add several man pages for NDB which are now created.
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 6b0092e3880..534f7a51e05 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -83,6 +83,7 @@ struct my_tests_st
};
#define myheader(str) \
+DBUG_PRINT("test", ("name: %s", str)); \
if (opt_silent < 2) \
{ \
fprintf(stdout, "\n\n#####################################\n"); \
@@ -90,7 +91,9 @@ if (opt_silent < 2) \
opt_count, str); \
fprintf(stdout, " \n#####################################\n"); \
}
+
#define myheader_r(str) \
+DBUG_PRINT("test", ("name: %s", str)); \
if (!opt_silent) \
{ \
fprintf(stdout, "\n\n#####################################\n"); \
@@ -298,7 +301,7 @@ static void client_connect(ulong flag)
mysql->reconnect= 1;
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
/* set AUTOCOMMIT to ON*/
mysql_autocommit(mysql, TRUE);
@@ -321,7 +324,7 @@ static void client_connect(ulong flag)
have_innodb= check_have_innodb(mysql);
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
}
@@ -341,12 +344,13 @@ static void client_disconnect()
mysql_query(mysql, query);
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
if (!opt_silent)
fprintf(stdout, "\n closing the connection ...");
mysql_close(mysql);
- fprintf(stdout, " OK\n");
+ if (!opt_silent)
+ fprintf(stdout, "OK\n");
}
}
@@ -2498,7 +2502,7 @@ static void test_ps_query_cache()
exit(1);
}
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
mysql= lmysql;
}
@@ -4940,7 +4944,7 @@ static void test_stmt_close()
}
lmysql->reconnect= 1;
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
/* set AUTOCOMMIT to ON*/
@@ -7471,7 +7475,7 @@ static void test_prepare_grant()
}
lmysql->reconnect= 1;
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
mysql= lmysql;
rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)");
@@ -7932,7 +7936,7 @@ static void test_drop_temp()
}
lmysql->reconnect= 1;
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
mysql= lmysql;
rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')");
@@ -12018,16 +12022,24 @@ static void test_bug5315()
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
DIE_UNLESS(rc == 0);
+ if (!opt_silent)
+ printf("Excuting mysql_change_user\n");
mysql_change_user(mysql, opt_user, opt_password, current_db);
+ if (!opt_silent)
+ printf("Excuting mysql_stmt_execute\n");
rc= mysql_stmt_execute(stmt);
DIE_UNLESS(rc != 0);
if (rc)
{
if (!opt_silent)
- printf("Got error (as expected):\n%s", mysql_stmt_error(stmt));
+ printf("Got error (as expected): '%s'\n", mysql_stmt_error(stmt));
}
/* check that connection is OK */
+ if (!opt_silent)
+ printf("Excuting mysql_stmt_close\n");
mysql_stmt_close(stmt);
+ if (!opt_silent)
+ printf("Excuting mysql_stmt_init\n");
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
DIE_UNLESS(rc == 0);
@@ -12716,6 +12728,7 @@ static void test_rewind(void)
/* retreive all result sets till we are at the end */
while(!mysql_stmt_fetch(stmt))
+ if (!opt_silent)
printf("fetched result:%ld\n", Data);
DIE_UNLESS(rc != MYSQL_NO_DATA);
@@ -12726,6 +12739,7 @@ static void test_rewind(void)
/* now we should be able to fetch the results again */
/* but mysql_stmt_fetch returns MYSQL_NO_DATA */
while(!(rc= mysql_stmt_fetch(stmt)))
+ if (!opt_silent)
printf("fetched result after seek:%ld\n", Data);
DIE_UNLESS(rc == MYSQL_NO_DATA);
@@ -13276,7 +13290,7 @@ static void test_bug8378()
exit(1);
}
if (!opt_silent)
- fprintf(stdout, " OK");
+ fprintf(stdout, "OK");
len= mysql_real_escape_string(mysql, out, TEST_BUG8378_IN, 4);
@@ -13445,7 +13459,8 @@ static void test_bug9520()
DIE_UNLESS(rc == MYSQL_NO_DATA);
- printf("Fetched %d rows\n", row_count);
+ if (!opt_silent)
+ printf("Fetched %d rows\n", row_count);
DBUG_ASSERT(row_count == 3);
mysql_stmt_close(stmt);
@@ -15345,8 +15360,28 @@ static void test_bug17667()
myheader("test_bug17667");
+ master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1);
+ strxmov(master_log_filename, opt_vardir, "/log/master.log", NullS);
+ if (!opt_silent)
+ printf("Opening '%s'\n", master_log_filename);
+ log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(0));
+ free(master_log_filename);
+
+ if (log_file == NULL)
+ {
+ if (!opt_silent)
+ {
+ printf("Could not find the log file, VARDIR/log/master.log, so "
+ "test_bug17667 is not run.\n"
+ "Run test from the mysql-test/mysql-test-run* program to set up "
+ "correct environment for this test.\n\n");
+ }
+ return;
+ }
+
for (statement_cursor= statements; statement_cursor->buffer != NULL;
- statement_cursor++) {
+ statement_cursor++)
+ {
if (statement_cursor->qt == QT_NORMAL)
{
/* Run statement as normal query */
@@ -15357,10 +15392,10 @@ static void test_bug17667()
else if (statement_cursor->qt == QT_PREPARED)
{
/*
- Run as prepared statement
+ Run as prepared statement
- NOTE! All these queries should be in the log twice,
- one time for prepare and one time for execute
+ NOTE! All these queries should be in the log twice,
+ one time for prepare and one time for execute
*/
stmt= mysql_stmt_init(mysql);
@@ -15383,66 +15418,49 @@ static void test_bug17667()
rc= mysql_query(mysql, "flush logs");
myquery(rc);
- master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1);
- strcpy(master_log_filename, opt_vardir);
- strcat(master_log_filename, "/log/master.log");
- printf("Opening '%s'\n", master_log_filename);
- log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(MY_WME));
- free(master_log_filename);
+ for (statement_cursor= statements; statement_cursor->buffer != NULL;
+ statement_cursor++)
+ {
+ int expected_hits= 1, hits= 0;
+ char line_buffer[MAX_TEST_QUERY_LENGTH*2];
+ /* more than enough room for the query and some marginalia. */
- if (log_file != NULL) {
+ /* Prepared statments always occurs twice in log */
+ if (statement_cursor->qt == QT_PREPARED)
+ expected_hits++;
- for (statement_cursor= statements; statement_cursor->buffer != NULL;
- statement_cursor++) {
- int expected_hits= 1, hits= 0;
- char line_buffer[MAX_TEST_QUERY_LENGTH*2];
- /* more than enough room for the query and some marginalia. */
+ /* Loop until we found expected number of log entries */
+ do {
+ /* Loop until statement is found in log */
+ do {
+ memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2);
- /* Prepared statments always occurs twice in log */
- if (statement_cursor->qt == QT_PREPARED)
- expected_hits++;
+ if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL)
+ {
+ /* If fgets returned NULL, it indicates either error or EOF */
+ if (feof(log_file))
+ DIE("Found EOF before all statements where found");
- /* Loop until we found expected number of log entries */
- do {
- /* Loop until statement is found in log */
- do {
- memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2);
-
- if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL)
- {
- /* If fgets returned NULL, it indicates either error or EOF */
- if (feof(log_file))
- DIE("Found EOF before all statements where found");
-
- fprintf(stderr, "Got error %d while reading from file\n",
- ferror(log_file));
- DIE("Read error");
- }
-
- } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2,
- statement_cursor->buffer,
- statement_cursor->length) == NULL);
- hits++;
- } while (hits < expected_hits);
+ fprintf(stderr, "Got error %d while reading from file\n",
+ ferror(log_file));
+ DIE("Read error");
+ }
+
+ } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2,
+ statement_cursor->buffer,
+ statement_cursor->length) == NULL);
+ hits++;
+ } while (hits < expected_hits);
+ if (!opt_silent)
printf("Found statement starting with \"%s\"\n",
statement_cursor->buffer);
- }
-
- printf("success. All queries found intact in the log.\n");
-
- }
- else
- {
- fprintf(stderr, "Could not find the log file, VARDIR/log/master.log, so "
- "test_bug17667 is \ninconclusive. Run test from the "
- "mysql-test/mysql-test-run* program \nto set up the correct "
- "environment for this test.\n\n");
}
- if (log_file != NULL)
- my_fclose(log_file, MYF(0));
+ if (!opt_silent)
+ printf("success. All queries found intact in the log.\n");
+ my_fclose(log_file, MYF(0));
}
@@ -16008,12 +16026,14 @@ static void test_bug21635()
for (i= 0; i < field_count; ++i)
{
field= mysql_fetch_field_direct(result, i);
- printf("%s -> %s ... ", expr[i * 2], field->name);
+ if (!opt_silent)
+ printf("%s -> %s ... ", expr[i * 2], field->name);
fflush(stdout);
DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 &&
field->table[0] == 0 && field->org_name[0] == 0);
DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0);
- puts("OK");
+ if (!opt_silent)
+ puts("OK");
}
mysql_free_result(result);
diff --git a/win/README b/win/README
index 9218b63b05e..88677029e0b 100644
--- a/win/README
+++ b/win/README
@@ -58,7 +58,7 @@ The options right now are
MYSQL_SERVER_SUFFIX=<suffix> Server suffix, default none
COMPILATION_COMMENT=<comment> Server comment, default "Source distribution"
MYSQL_TCP_PORT=<port> Server port, default 3306
- CYBOZU
+ CYBOZU Default character set is UTF8
So the command line could look like:
diff --git a/zlib/Makefile.am b/zlib/Makefile.am
index c40c922851e..edcbd5f4a75 100644
--- a/zlib/Makefile.am
+++ b/zlib/Makefile.am
@@ -19,16 +19,18 @@ INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include
LIBS= $(NON_THREADED_LIBS)
-pkglib_LTLIBRARIES=libz.la
+pkglib_LTLIBRARIES = libz.la
+noinst_LTLIBRARIES = libzlt.la
-libz_la_LDFLAGS= -version-info 3:3:2
+libz_la_LDFLAGS = -static
-noinst_HEADERS= crc32.h deflate.h inffast.h inffixed.h inflate.h \
- inftrees.h trees.h zconf.h zlib.h zutil.h
+noinst_HEADERS = crc32.h deflate.h inffast.h inffixed.h inflate.h \
+ inftrees.h trees.h zconf.h zlib.h zutil.h
-libz_la_SOURCES= adler32.c compress.c crc32.c deflate.c gzio.c \
- infback.c inffast.c inflate.c inftrees.c trees.c \
- uncompr.c zutil.c
+libz_la_SOURCES = adler32.c compress.c crc32.c deflate.c gzio.c \
+ infback.c inffast.c inflate.c inftrees.c trees.c \
+ uncompr.c zutil.c
+libzlt_la_SOURCES = $(libz_la_SOURCES)
EXTRA_DIST= README FAQ INDEX ChangeLog algorithm.txt zlib.3 CMakeLists.txt