From 6e9ebc2a9f013ea5ae5b87fd73787c9b9b3646d6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Mar 2007 10:17:21 +0100 Subject: [PATCH 01/83] BUG#25601 Missing m4 macro MYSQL_CHECK_TIME_T config/ac-macros/misc.m4: BUG#25601 MYSQL_CHECK_TIME_T macro is missing in 5.0 and upward, likely incorrectly merged up from 4.1. This patch is a verbatim copy from 4.1's acinclude.m4 (except for typos in comment). --- config/ac-macros/misc.m4 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4 index d8199f5970e..09081fb3eac 100644 --- a/config/ac-macros/misc.m4 +++ b/config/ac-macros/misc.m4 @@ -790,3 +790,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 + ]], + [[ + 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)] + ) +]) + From 3615debeb1377b1ddf51b546ed7342186c18db59 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Mar 2007 11:19:51 +0200 Subject: [PATCH 02/83] Added find_type_or_exit and find_bit_type_or_exit as wrappers around the original functions. These will ensure that error message is always in unique form, reduce code and print the right alternatives automatically in an error case. client/mysql.cc: Changed find_type to find_type_or_exit client/mysqladmin.cc: Changed find_type to find_type_or_exit client/mysqlbinlog.cc: Changed find_type to find_type_or_exit client/mysqlcheck.c: Changed find_type to find_type_or_exit client/mysqldump.c: Changed find_type to find_type_or_exit client/mysqlimport.c: Changed find_type to find_type_or_exit client/mysqlshow.c: Changed find_type to find_type_or_exit client/mysqlslap.c: Changed find_type to find_type_or_exit include/typelib.h: Added find_type_or_exit mysql-test/r/mysql_protocols.result: Fixed result. mysys/typelib.c: Added find_type_or_exit sql/mysqld.cc: Added use of find_type_or_exit and find_bit_type_or_exit Fixed a missing break; from an option handling. (Bug in --tc-heuristic-recover) --- client/mysql.cc | 9 +-- client/mysqladmin.cc | 9 +-- client/mysqlbinlog.cc | 9 +-- client/mysqlcheck.c | 9 +-- client/mysqldump.c | 11 +-- client/mysqlimport.c | 9 +-- client/mysqlshow.c | 9 +-- client/mysqlslap.c | 11 +-- include/typelib.h | 2 + mysql-test/r/mysql_protocols.result | 1 + mysys/typelib.c | 22 ++++++ sql/mysqld.cc | 118 +++++++++++----------------- 12 files changed, 89 insertions(+), 130 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 48172d97f56..c13fb958a1a 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 ccfff4d7a03..4670cb98caf 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -284,15 +284,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 940fac6da38..a0a7572d92e 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -948,14 +948,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; diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1a9d07804b4..41c5cde4023 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -310,15 +310,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 5f2749eef77..4a6c9e64151 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -790,14 +790,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; } 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 ad2c8685ba1..d673f8f6f81 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -568,14 +568,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/include/typelib.h b/include/typelib.h index 75d170e59d3..c973d1747fd 100644 --- a/include/typelib.h +++ b/include/typelib.h @@ -26,6 +26,8 @@ typedef struct st_typelib { /* Different types saved here */ unsigned int *type_lengths; } TYPELIB; +extern int find_type_or_exit(const char *x, TYPELIB *typelib, + const char *option); extern int find_type(char *x,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); 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/mysys/typelib.c b/mysys/typelib.c index 4fab6f20493..780e63b4b04 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -20,6 +20,28 @@ #include +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/sql/mysqld.cc b/sql/mysqld.cc index 758dc54316e..0457dbb8c69 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -737,6 +737,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); @@ -7411,11 +7413,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; } @@ -7471,17 +7469,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; } @@ -7541,13 +7529,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 @@ -7561,10 +7545,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), type= 5 1 2 3 4 (DISABLE ) - (OFF | ON) - (0 | 1) */ - switch ((type=find_type(argument, &Events::opt_typelib, 1))) { - case 0: - fprintf(stderr, "Unknown option to event-scheduler: %s\n",argument); - exit(1); + type= find_type_or_exit(argument, &Events::opt_typelib, opt->name); + switch (type) { case 5: /* OPT_DISABLED */ Events::opt_event_scheduler= Events::EVENTS_DISABLED; break; @@ -7714,11 +7696,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; @@ -7729,11 +7707,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; } @@ -7774,16 +7748,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: @@ -7823,12 +7788,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; @@ -7841,14 +7802,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; @@ -7856,11 +7813,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; @@ -7879,12 +7833,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; @@ -8192,6 +8142,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. From b444f808828e42b64cdd4fa8bc9e901b1ae6e119 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Mar 2007 00:34:15 +0300 Subject: [PATCH 03/83] Fix for BUG#24040: Create View don't succed with "all privileges" on a database. The problem was that we required not less privileges on the base tables than we have on the view. The fix is to be more flexible and allow to create such a view (necessary privileges will be checked at the runtime). mysql-test/r/view_grant.result: Updated result file. mysql-test/t/view_grant.test: Added test case for BUG#24040 (Create View don't succed with "all privileges" on a database). sql/sql_view.cc: Implement flexible privilege check for CREATE VIEW. --- mysql-test/r/view_grant.result | 97 +++++++++++++++++++++++++--- mysql-test/t/view_grant.test | 111 +++++++++++++++++++++++++++------ sql/sql_view.cc | 35 +++++++---- 3 files changed, 203 insertions(+), 40 deletions(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 45cf5076fe1..3ddf4ca979c 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -282,15 +282,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; @@ -773,4 +764,92 @@ DROP DATABASE mysqltest_db1; DROP DATABASE mysqltest_db2; DROP USER mysqltest_u1@localhost; DROP USER mysqltest_u2@localhost; +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. diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 0785b74dd47..815b07badf8 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -350,25 +350,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 @@ -1035,4 +1016,96 @@ DROP USER mysqltest_u1@localhost; DROP USER mysqltest_u2@localhost; +# +# 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/sql/sql_view.cc b/sql/sql_view.cc index 7143df8474a..cb3570105a7 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -492,35 +492,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 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 From df3a48ea43b93ad91546d71c49963665f13179db Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Mar 2007 19:17:15 +0200 Subject: [PATCH 04/83] Bug #27354 stored function in where condition was always treated as const Possible problems: function call could be eliminated from where class and only be evaluated once; function can be evaluated during table and item setup phase which could cause side effects not to be registered in binlog. Fixed with introducing func_item_sp::used_tables() returning the correct table_map constant. mysql-test/r/sp.result: results changed mysql-test/t/sp.test: regression test demonstrating that function's returns match where condition of the top-level query table. sql/item_func.h: private used_tables() method returning the correct table_bit with meaning the item is not a constant --- mysql-test/r/sp.result | 25 +++++++++++++++++++++++++ mysql-test/t/sp.test | 24 ++++++++++++++++++++++++ sql/item_func.h | 4 +++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 34f2aa94000..eae5c3a38d6 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5779,3 +5779,28 @@ SUM(f2) bug25373(f1) DROP FUNCTION bug25373| DROP TABLE t3| 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/t/sp.test b/mysql-test/t/sp.test index 9af24ee0337..0875c61ef0f 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6770,3 +6770,27 @@ DROP TABLE t3| # practical, or create table t3, t4 etc temporarily (and drop them). 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/sql/item_func.h b/sql/item_func.h index 68591f9c6f5..24f30994b22 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1411,7 +1411,7 @@ private: bool execute(Field **flp); bool execute_impl(THD *thd, Field *return_value_fld); Field *sp_result_field(void) const; - + public: Item_func_sp(Name_resolution_context *context_arg, sp_name *name); @@ -1422,6 +1422,8 @@ public: virtual ~Item_func_sp() {} + table_map used_tables() const { return RAND_TABLE_BIT; } + void cleanup(); const char *func_name() const; From 7eb3881bd8c6b5c8dc705558414dbbe444804694 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Mar 2007 20:32:07 +0200 Subject: [PATCH 05/83] Fixed compiler warnings. mysys/default.c: Fixed bug. ndb/src/mgmclient/CommandInterpreter.cpp: Added parenthesis around the expression. sql/mysqld.cc: Fixed compiler warnings. Added a missing component in options struct (bug). sql-common/my_time.c: Removed garbage. sql/sql_table.cc: A possible use of a variable uninitialized. support-files/compiler_warnings.supp: BitKeeper file /home/my/bk/mysql-4.1-main/support-files/compiler_warnings.supp --- client/mysqlbinlog.cc | 2 +- client/mysqldump.c | 2 +- client/sql_string.cc | 4 +- extra/perror.c | 4 +- heap/_check.c | 10 ++--- heap/hp_delete.c | 4 +- heap/hp_hash.c | 2 +- heap/hp_open.c | 7 +-- heap/hp_rkey.c | 2 +- heap/hp_rrnd.c | 8 ++-- heap/hp_write.c | 6 +-- include/raid.h | 4 +- isam/_dynrec.c | 4 +- isam/_page.c | 4 +- isam/_search.c | 15 ++++--- isam/close.c | 6 +-- isam/delete.c | 9 ++-- isam/open.c | 2 +- isam/rkey.c | 4 +- isam/sort.c | 2 +- isam/write.c | 14 +++--- libmysql/libmysql.c | 15 ++++--- libmysqld/libmysqld.c | 2 +- myisam/mi_close.c | 5 ++- myisam/mi_delete.c | 11 ++--- myisam/mi_dynrec.c | 5 ++- myisam/mi_keycache.c | 5 ++- myisam/mi_page.c | 4 +- myisam/mi_statrec.c | 2 +- myisam/myisamchk.c | 1 + myisammrg/myrg_extra.c | 2 +- mysys/default.c | 2 +- mysys/hash.c | 16 ++++--- mysys/list.c | 3 +- mysys/mf_iocache.c | 11 +++-- mysys/mf_keycache.c | 30 ++++++------- mysys/mf_keycaches.c | 4 +- mysys/my_alloc.c | 5 ++- mysys/my_dup.c | 2 +- mysys/my_fopen.c | 6 +-- mysys/my_fstream.c | 8 ++-- mysys/my_getwd.c | 3 +- mysys/my_handler.c | 5 ++- mysys/my_lib.c | 2 +- mysys/my_lread.c | 4 +- mysys/my_lwrite.c | 4 +- mysys/my_malloc.c | 4 +- mysys/my_pread.c | 8 ++-- mysys/my_read.c | 4 +- mysys/my_realloc.c | 6 +-- mysys/my_seek.c | 2 +- mysys/my_tempnam.c | 2 +- mysys/my_write.c | 2 +- mysys/raid.cc | 37 ++++++++-------- mysys/safemalloc.c | 10 ++--- mysys/thr_lock.c | 15 ++++--- mysys/tree.c | 4 +- mysys/typelib.c | 2 +- ndb/src/mgmclient/CommandInterpreter.cpp | 4 +- regex/regexec.c | 3 +- sql-common/client.c | 12 ++--- sql-common/my_time.c | 2 +- sql/examples/ha_archive.cc | 3 +- sql/ha_innodb.cc | 4 +- sql/ha_ndbcluster.cc | 36 ++++++++------- sql/item.cc | 2 + sql/item_cmpfunc.cc | 6 +-- sql/item_subselect.cc | 2 +- sql/log.cc | 4 +- sql/log_event.cc | 6 +-- sql/mysqld.cc | 9 ++-- sql/net_serv.cc | 2 +- sql/opt_range.cc | 2 +- sql/slave.cc | 12 ++--- sql/sql_cache.cc | 22 +++++----- sql/sql_class.cc | 12 ++--- sql/sql_delete.cc | 2 +- sql/sql_parse.cc | 8 ++-- sql/sql_prepare.cc | 2 +- sql/sql_repl.cc | 4 +- sql/sql_select.cc | 1 + sql/sql_table.cc | 2 +- sql/sql_update.cc | 4 +- sql/strfunc.cc | 2 +- sql/table.cc | 2 +- sql/tztime.cc | 4 +- sql/unireg.cc | 4 +- support-files/compiler_warnings.supp | 56 ++++++++++++++++++++++++ tests/mysql_client_test.c | 5 ++- 89 files changed, 353 insertions(+), 254 deletions(-) create mode 100644 support-files/compiler_warnings.supp diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 77240a2c750..3f3771e6441 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -834,7 +834,7 @@ static int dump_remote_log_entries(const char* logname) } if (len < 8 && net->read_pos[0] == 254) break; // end of data - DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n", + DBUG_PRINT("info",( "len: %lu net->read_pos[5]: %d\n", len, net->read_pos[5])); Log_event *ev = Log_event::read_log_event((const char*) net->read_pos + 1 , len - 1, &error_msg, old_format); diff --git a/client/mysqldump.c b/client/mysqldump.c index 3bf9fff1b86..e9d48f3edfa 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2654,7 +2654,7 @@ int main(int argc, char **argv) default_charset= (char *)mysql_universal_client_charset; bzero((char*) &ignore_table, sizeof(ignore_table)); - MY_INIT("mysqldump"); + MY_INIT(argv[0]); if (get_options(&argc, &argv)) { my_end(0); diff --git a/client/sql_string.cc b/client/sql_string.cc index 690997152f1..1f007fd3a17 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -103,7 +103,7 @@ bool String::set(longlong num, CHARSET_INFO *cs) } else { - str_length=cs->cset->snprintf(cs,Ptr,l,"%d",num); + str_length=cs->cset->snprintf(cs,Ptr,l,"%ld", (long) num); } str_charset=cs; return FALSE; @@ -121,7 +121,7 @@ bool String::set(ulonglong num, CHARSET_INFO *cs) } else { - str_length=cs->cset->snprintf(cs,Ptr,l,"%d",num); + str_length=cs->cset->snprintf(cs,Ptr,l,"%ld", (long) num); } str_charset=cs; return FALSE; diff --git a/extra/perror.c b/extra/perror.c index 764f54eafe3..e5c256aadf3 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -253,7 +253,9 @@ int main(int argc,char *argv[]) 'Unknown Error' (without regard to case). */ if (msg && - my_strnncoll(&my_charset_latin1, msg, 13, "Unknown Error", 13) && + my_strnncoll(&my_charset_latin1, + (const uchar *) msg, 13, + (const uchar *) "Unknown Error", 13) && (!unknown_error || strcmp(msg, unknown_error))) { found=1; diff --git a/heap/_check.c b/heap/_check.c index ad432856a69..6540f46454b 100644 --- a/heap/_check.c +++ b/heap/_check.c @@ -87,7 +87,7 @@ int heap_check_heap(HP_INFO *info, my_bool print_status) if (records != share->records || deleted != share->deleted) { - DBUG_PRINT("error",("Found rows: %lu (%lu) deleted %lu (%lu)", + DBUG_PRINT("error",("Found rows: %lu (%u) deleted %lu (%u)", records, share->records, deleted, share->deleted)); error= 1; } @@ -123,7 +123,7 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, blength, records)) != i) { - DBUG_PRINT("error",("Record in wrong link: Link %d Record: %lx Record-link %d", i,hash_info->ptr_to_rec,rec_link)); + DBUG_PRINT("error",("Record in wrong link: Link %d Record: %lx Record-link %d", i, (ulong) hash_info->ptr_to_rec, rec_link)); error=1; } else @@ -135,12 +135,12 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, } if (found != records) { - DBUG_PRINT("error",("Found %ld of %ld records", found, records)); + DBUG_PRINT("error",("Found %u of %ld records", found, records)); error=1; } if (keydef->hash_buckets != hash_buckets_found) { - DBUG_PRINT("error",("Found %ld buckets, stats shows %ld buckets", + DBUG_PRINT("error",("Found %u buckets, stats shows %ld buckets", hash_buckets_found, keydef->hash_buckets)); error=1; } @@ -181,7 +181,7 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, { error= 1; DBUG_PRINT("error",("Record in wrong link: key: %d Record: %lx\n", - keynr, recpos)); + keynr, (ulong) recpos)); } else found++; diff --git a/heap/hp_delete.c b/heap/hp_delete.c index 266a9da6ca3..2e57d6393e9 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -24,7 +24,7 @@ int heap_delete(HP_INFO *info, const byte *record) HP_SHARE *share=info->s; HP_KEYDEF *keydef, *end, *p_lastinx; DBUG_ENTER("heap_delete"); - DBUG_PRINT("enter",("info: %lx record: %lx",info,record)); + DBUG_PRINT("enter",("info: %lx record: %lx", (ulong) info, (ulong) record)); test_active(info); @@ -143,7 +143,7 @@ int hp_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, info->current_hash_ptr=last_ptr; info->current_ptr = last_ptr ? last_ptr->ptr_to_rec : 0; DBUG_PRINT("info",("Corrected current_ptr to point at: %lx", - info->current_ptr)); + (ulong) info->current_ptr)); } empty=pos; if (gpos) diff --git a/heap/hp_hash.c b/heap/hp_hash.c index ee5b4958e62..8d2aa5e9fe9 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -120,7 +120,7 @@ byte *hp_search(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *key, { switch (nextflag) { case 0: /* Search after key */ - DBUG_PRINT("exit",("found key at %d",pos->ptr_to_rec)); + DBUG_PRINT("exit",("found key at %lu", (ulong) pos->ptr_to_rec)); info->current_hash_ptr=pos; DBUG_RETURN(info->current_ptr= pos->ptr_to_rec); case 1: /* Search next */ diff --git a/heap/hp_open.c b/heap/hp_open.c index 1fa832208fb..a51c458171e 100644 --- a/heap/hp_open.c +++ b/heap/hp_open.c @@ -63,8 +63,9 @@ HP_INFO *heap_open(const char *name, int mode) #ifndef DBUG_OFF info->opt_flag= READ_CHECK_USED; /* Check when changing */ #endif - DBUG_PRINT("exit",("heap: %lx reclength: %d records_in_block: %d", - info,share->reclength,share->block.records_in_block)); + DBUG_PRINT("exit",("heap: 0x%lx reclength: %d records_in_block: %d", + (ulong) info, share->reclength, + share->block.records_in_block)); DBUG_RETURN(info); } @@ -82,7 +83,7 @@ HP_SHARE *hp_find_named_heap(const char *name) info= (HP_SHARE*) pos->data; if (!strcmp(name, info->name)) { - DBUG_PRINT("exit", ("Old heap_database: %lx",info)); + DBUG_PRINT("exit", ("Old heap_database: 0x%lx", (ulong) info)); DBUG_RETURN(info); } } diff --git a/heap/hp_rkey.c b/heap/hp_rkey.c index 2c23d9d721e..eac8dbd6903 100644 --- a/heap/hp_rkey.c +++ b/heap/hp_rkey.c @@ -23,7 +23,7 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, HP_SHARE *share= info->s; HP_KEYDEF *keyinfo= share->keydef + inx; DBUG_ENTER("heap_rkey"); - DBUG_PRINT("enter",("base: %lx inx: %d",info,inx)); + DBUG_PRINT("enter",("base: 0x%lx inx: %d", (ulong) info, inx)); if ((uint) inx >= share->keys) { diff --git a/heap/hp_rrnd.c b/heap/hp_rrnd.c index cce3ce24e51..51bbbfc141e 100644 --- a/heap/hp_rrnd.c +++ b/heap/hp_rrnd.c @@ -29,7 +29,7 @@ int heap_rrnd(register HP_INFO *info, byte *record, byte *pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); - DBUG_PRINT("enter",("info: %lx pos: %lx",info,pos)); + DBUG_PRINT("enter",("info: 0x%lx pos: 0x%lx", (ulong) info, (ulong) pos)); info->lastinx= -1; if (!(info->current_ptr= pos)) @@ -44,7 +44,7 @@ int heap_rrnd(register HP_INFO *info, byte *record, byte *pos) } info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; memcpy(record,info->current_ptr,(size_t) share->reclength); - DBUG_PRINT("exit",("found record at %lx",info->current_ptr)); + DBUG_PRINT("exit",("found record at 0x%lx", (ulong) info->current_ptr)); info->current_hash_ptr=0; /* Can't use rnext */ DBUG_RETURN(0); } /* heap_rrnd */ @@ -64,7 +64,7 @@ int heap_rrnd_old(register HP_INFO *info, byte *record, ulong pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); - DBUG_PRINT("enter",("info: %lx pos: %ld",info,pos)); + DBUG_PRINT("enter",("info: 0x%lx pos: %ld",info,pos)); info->lastinx= -1; if (pos == (ulong) -1) @@ -98,7 +98,7 @@ end: } info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; memcpy(record,info->current_ptr,(size_t) share->reclength); - DBUG_PRINT("exit",("found record at %lx",info->current_ptr)); + DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr)); info->current_hash_ptr=0; /* Can't use rnext */ DBUG_RETURN(0); } /* heap_rrnd */ diff --git a/heap/hp_write.c b/heap/hp_write.c index 841dda6264e..b79b03477f5 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -144,7 +144,7 @@ static byte *next_free_record_pos(HP_SHARE *info) pos=info->del_link; info->del_link= *((byte**) pos); info->deleted--; - DBUG_PRINT("exit",("Used old position: %lx",pos)); + DBUG_PRINT("exit",("Used old position: 0x%lx", (ulong) pos)); DBUG_RETURN(pos); } if (!(block_pos=(info->records % info->block.records_in_block))) @@ -159,8 +159,8 @@ static byte *next_free_record_pos(HP_SHARE *info) DBUG_RETURN(NULL); info->data_length+=length; } - DBUG_PRINT("exit",("Used new position: %lx", - (byte*) info->block.level_info[0].last_blocks+block_pos* + DBUG_PRINT("exit",("Used new position: 0x%lx", + (ulong) info->block.level_info[0].last_blocks+block_pos* info->block.recbuffer)); DBUG_RETURN((byte*) info->block.level_info[0].last_blocks+ block_pos*info->block.recbuffer); diff --git a/include/raid.h b/include/raid.h index c840afcbaab..ec27eccdf3e 100644 --- a/include/raid.h +++ b/include/raid.h @@ -141,7 +141,7 @@ class RaidFd { inline void Calculate() { DBUG_ENTER("RaidFd::_Calculate"); - DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu", + DBUG_PRINT("info",("_position: %lu _raid_chunksize: %lu _size: %lu", (ulong) _position, _raid_chunksize, (ulong) _size)); _total_block = (ulong) (_position / _raid_chunksize); @@ -149,7 +149,7 @@ class RaidFd { _remaining_bytes = (uint) (_raid_chunksize - (_position - _total_block * _raid_chunksize)); DBUG_PRINT("info", - ("_total_block: %d this_block: %d _remaining_bytes:%d", + ("_total_block: %lu this_block: %d _remaining_bytes: %d", _total_block, _this_block, _remaining_bytes)); DBUG_VOID_RETURN; } diff --git a/isam/_dynrec.c b/isam/_dynrec.c index 25fe01e23f2..c158068eb83 100644 --- a/isam/_dynrec.c +++ b/isam/_dynrec.c @@ -713,8 +713,8 @@ uint _nisam_rec_unpack(register N_INFO *info, register byte *to, byte *from, DBUG_RETURN((info->packed_length=found_length)); err: my_errno=HA_ERR_RECORD_DELETED; - DBUG_PRINT("error",("to_end: %lx -> %lx from_end: %lx -> %lx", - to,to_end,from,from_end)); + DBUG_PRINT("error",("to_end: 0x%lx -> 0x%lx from_end: 0x%lx -> 0x%lx", + (long) to, (long) to_end, (long) from, (long) from_end)); DBUG_DUMP("from",(byte*) info->rec_buff,info->s->base.min_pack_length); DBUG_RETURN(MY_FILE_ERROR); } /* _nisam_rec_unpack */ diff --git a/isam/_page.c b/isam/_page.c index e31115e624f..36626ba186b 100644 --- a/isam/_page.c +++ b/isam/_page.c @@ -70,7 +70,7 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo, my_errno=EINVAL; return(-1); } - DBUG_PRINT("page",("write page at: %lu",(long) page,buff)); + DBUG_PRINT("page",("write page at: %lu", (long) page)); DBUG_DUMP("buff",(byte*) buff,getint(buff)); #endif @@ -138,6 +138,6 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo) (uint) keyinfo->base.block_length,0)) pos= NI_POS_ERROR; } - DBUG_PRINT("exit",("Pos: %d",pos)); + DBUG_PRINT("exit",("Pos: %lu", pos)); DBUG_RETURN(pos); } /* _nisam_new */ diff --git a/isam/_search.c b/isam/_search.c index fbffd6786e1..a2a3b096ea1 100644 --- a/isam/_search.c +++ b/isam/_search.c @@ -208,14 +208,15 @@ int _nisam_seq_search(N_INFO *info, register N_KEYDEF *keyinfo, uchar *page, uch if ((flag=_nisam_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag)) >= 0) break; #ifdef EXTRA_DEBUG - DBUG_PRINT("loop",("page: %lx key: '%s' flag: %d",page,t_buff,flag)); + DBUG_PRINT("loop",("page: 0x%lx key: '%s' flag: %d", + (long) page, t_buff, flag)); #endif memcpy(buff,t_buff,length); *ret_pos=page; } if (flag == 0) memcpy(buff,t_buff,length); /* Result is first key */ - DBUG_PRINT("exit",("flag: %d ret_pos: %lx",flag,*ret_pos)); + DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos)); DBUG_RETURN(flag); } /* _nisam_seq_search */ @@ -754,8 +755,8 @@ int _nisam_search_next(register N_INFO *info, register N_KEYDEF *keyinfo, uint nod_flag; uchar lastkey[N_MAX_KEY_BUFF]; DBUG_ENTER("_nisam_search_next"); - DBUG_PRINT("enter",("nextflag: %d lastpos: %d int_keypos: %lx", - nextflag,info->lastpos,info->int_keypos)); + DBUG_PRINT("enter",("nextflag: %u lastpos: %lu int_keypos: 0x%lx", + nextflag, info->lastpos, (long) info->int_keypos)); DBUG_EXECUTE("key",_nisam_print_key(DBUG_FILE,keyinfo->seg,key);); if ((nextflag & SEARCH_BIGGER && info->int_keypos >= info->int_maxpos) || @@ -807,7 +808,7 @@ int _nisam_search_next(register N_INFO *info, register N_KEYDEF *keyinfo, VOID(_nisam_move_key(keyinfo,info->lastkey,lastkey)); VOID((*keyinfo->get_key)(keyinfo,nod_flag,&info->int_keypos,info->lastkey)); info->lastpos=_nisam_dpos(info,nod_flag,info->int_keypos); - DBUG_PRINT("exit",("found key at %d",info->lastpos)); + DBUG_PRINT("exit",("found key at %lu", info->lastpos)); DBUG_RETURN(0); } /* _nisam_search_next */ @@ -845,7 +846,7 @@ int _nisam_search_first(register N_INFO *info, register N_KEYDEF *keyinfo, regis info->page_changed=info->buff_used=0; info->last_search_keypage=info->int_pos; - DBUG_PRINT("exit",("found key at %d",info->lastpos)); + DBUG_PRINT("exit",("found key at %lu", info->lastpos)); DBUG_RETURN(0); } /* _nisam_search_first */ @@ -884,6 +885,6 @@ int _nisam_search_last(register N_INFO *info, register N_KEYDEF *keyinfo, regist info->page_changed=info->buff_used=0; info->last_search_keypage=info->int_pos; - DBUG_PRINT("exit",("found key at %d",info->lastpos)); + DBUG_PRINT("exit",("found key at %lu", info->lastpos)); DBUG_RETURN(0); } /* _nisam_search_last */ diff --git a/isam/close.c b/isam/close.c index 37425653a5d..59ab91d944e 100644 --- a/isam/close.c +++ b/isam/close.c @@ -23,9 +23,9 @@ int nisam_close(register N_INFO *info) int error=0,flag; ISAM_SHARE *share=info->s; DBUG_ENTER("nisam_close"); - DBUG_PRINT("enter",("base: %lx reopen: %u locks: %u", - info,(uint) share->reopen, - (uint) (share->w_locks+share->r_locks))); + DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u", + (long) info, (uint) share->reopen, + (uint) (share->w_locks + share->r_locks))); pthread_mutex_lock(&THR_LOCK_isam); if (info->lock_type == F_EXTRA_LCK) diff --git a/isam/delete.c b/isam/delete.c index 5aa542561c1..d6dbd19bd53 100644 --- a/isam/delete.c +++ b/isam/delete.c @@ -258,7 +258,8 @@ static int del(register N_INFO *info, register N_KEYDEF *keyinfo, uchar *key, ISAM_SHARE *share=info->s; S_PARAM s_temp; DBUG_ENTER("del"); - DBUG_PRINT("enter",("leaf_page: %ld keypos: %lx",leaf_page,keypos)); + DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", + (long) leaf_page, (long) keypos)); DBUG_DUMP("leaf_buff",(byte*) leaf_buff,getint(leaf_buff)); endpos=leaf_buff+getint(leaf_buff); @@ -349,7 +350,8 @@ static int underflow(register N_INFO *info, register N_KEYDEF *keyinfo, S_PARAM s_temp; ISAM_SHARE *share=info->s; DBUG_ENTER("underflow"); - DBUG_PRINT("enter",("leaf_page: %ld keypos: %lx",leaf_page,keypos)); + DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", + leaf_page, (long) keypos)); DBUG_DUMP("anc_buff",(byte*) anc_buff,getint(anc_buff)); DBUG_DUMP("leaf_buff",(byte*) leaf_buff,getint(leaf_buff)); @@ -558,7 +560,8 @@ static uint remove_key(N_KEYDEF *keyinfo, uint nod_flag, int r_length,s_length,first,diff_flag; uchar *start; DBUG_ENTER("remove_key"); - DBUG_PRINT("enter",("keypos: %lx page_end: %lx",keypos,page_end)); + DBUG_PRINT("enter",("keypos: 0x%lx page_end: 0x%lx", + (long) keypos, (long) page_end)); start=keypos; if (!(keyinfo->base.flag & (HA_PACK_KEY | HA_SPACE_PACK_USED))) diff --git a/isam/open.c b/isam/open.c index be62fd86192..39c33c877af 100644 --- a/isam/open.c +++ b/isam/open.c @@ -116,7 +116,7 @@ N_INFO *nisam_open(const char *name, int mode, uint handle_locking) HA_OPTION_TEMP_COMPRESS_RECORD)) { DBUG_PRINT("error",("wrong options: 0x%lx", - uint2korr(share->state.header.options))); + (long) uint2korr(share->state.header.options))); my_errno=HA_ERR_OLD_FILE; goto err; } diff --git a/isam/rkey.c b/isam/rkey.c index bbe4576418b..ee7b9d3ad40 100644 --- a/isam/rkey.c +++ b/isam/rkey.c @@ -27,8 +27,8 @@ int nisam_rkey(N_INFO *info, byte *buf, int inx, const byte *key, uint key_len, uchar *key_buff; ISAM_SHARE *share=info->s; DBUG_ENTER("nisam_rkey"); - DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d", - info,inx,search_flag)); + DBUG_PRINT("enter",("base: 0x%lx inx: %d search_flag: %d", + (long) info, inx, search_flag)); if ((inx = _nisam_check_index(info,inx)) < 0) DBUG_RETURN(-1); diff --git a/isam/sort.c b/isam/sort.c index 5d13f8085d2..64dcb405157 100644 --- a/isam/sort.c +++ b/isam/sort.c @@ -542,7 +542,7 @@ my_string name; #if O_TEMPORARY == 0 && !defined(CANT_DELETE_OPEN_FILES) VOID(my_delete(name,MYF(MY_WME | ME_NOINPUT))); #endif - DBUG_PRINT("exit",("stream: %lx",stream)); + DBUG_PRINT("exit",("stream: 0x%lx", (long) stream)); DBUG_RETURN (stream); } /* opentemp */ diff --git a/isam/write.c b/isam/write.c index f2c0d8dbc45..2147c7cd59e 100644 --- a/isam/write.c +++ b/isam/write.c @@ -226,7 +226,7 @@ int _nisam_insert(register N_INFO *info, register N_KEYDEF *keyinfo, int key_offset; S_PARAM s_temp; DBUG_ENTER("_nisam_insert"); - DBUG_PRINT("enter",("key_pos: %lx",key_pos)); + DBUG_PRINT("enter",("key_pos: 0x%lx", (long) key_pos)); DBUG_EXECUTE("key",_nisam_print_key(DBUG_FILE,keyinfo->seg,key);); nod_flag=test_if_nod(anc_buff); @@ -243,8 +243,9 @@ int _nisam_insert(register N_INFO *info, register N_KEYDEF *keyinfo, { DBUG_PRINT("test",("t_length: %d ref_len: %d", t_length,s_temp.ref_length)); - DBUG_PRINT("test",("n_ref_len: %d n_length: %d key: %lx", - s_temp.n_ref_length,s_temp.n_length,s_temp.key)); + DBUG_PRINT("test",("n_ref_len: %d n_length: %d key: 0x%lx", + s_temp.n_ref_length, s_temp.n_length, + (long) s_temp.key)); } #endif key_offset = (uint)(endpos-key_pos); @@ -430,7 +431,7 @@ uint _nisam_get_pack_key_length(N_KEYDEF *keyinfo, uint nod_flag, uchar *key_pos if (*start == *key_pos && diff_flag && start != key_end) length++; /* One new pos for ref.len */ - DBUG_PRINT("test",("length: %d key_pos: %lx",length,key_pos)); + DBUG_PRINT("test",("length: %d key_pos: 0x%lx",length,key_pos)); if (n_length != 128) { /* Not same key after */ key=start+ref_length; @@ -597,7 +598,7 @@ _nisam_get_pack_key_length(N_KEYDEF *keyinfo, if (*start == *key_pos && diff_flag && start != key_end) length++; /* One new pos for ref.len */ } - DBUG_PRINT("test",("length: %d key_pos: %lx",length,key_pos)); + DBUG_PRINT("test",("length: %d key_pos: 0x%lx", length, (long) key_pos)); key=start+ref_length; while (n_length > 0 && key < key_end && *key == *key_pos) @@ -696,7 +697,8 @@ uchar *_nisam_find_half_pos(N_INFO *info, N_KEYDEF *keyinfo, uchar *page, uchar VOID((*keyinfo->get_key)(keyinfo,nod_flag,&page,key)); } while (page < end); - DBUG_PRINT("exit",("returns: %lx page: %lx half: %lx",lastpos,page,end)); + DBUG_PRINT("exit",("returns: 0x%lx page: 0x%lx half: 0x%lx", + (long) lastpos, (long) page, (long) end)); DBUG_RETURN(lastpos); } /* _nisam_find_half_pos */ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e963c0e429c..3102476a803 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2124,7 +2124,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) } stmt->bind= stmt->params + stmt->param_count; stmt->state= MYSQL_STMT_PREPARE_DONE; - DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count)); + DBUG_PRINT("info", ("Parameter count: %u", stmt->param_count)); DBUG_RETURN(0); } @@ -2461,9 +2461,10 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param) { NET *net= &stmt->mysql->net; DBUG_ENTER("store_param"); - DBUG_PRINT("enter",("type: %d, buffer:%lx, length: %lu is_null: %d", + DBUG_PRINT("enter",("type: %d buffer: 0x%lx length: %lu is_null: %d", param->buffer_type, - param->buffer ? param->buffer : "0", *param->length, + (long) (param->buffer ? param->buffer : NullS), + *param->length, *param->is_null)); if (*param->is_null) @@ -2499,7 +2500,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) my_bool res; DBUG_ENTER("execute"); - DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length)); + DBUG_PRINT("enter",("packet: %s, length :%lu", packet ? packet : " ", length)); mysql->last_used_con= mysql; int4store(buff, stmt->stmt_id); /* Send stmt id to server */ @@ -3239,8 +3240,8 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, MYSQL_BIND *param; DBUG_ENTER("mysql_stmt_send_long_data"); DBUG_ASSERT(stmt != 0); - DBUG_PRINT("enter",("param no : %d, data : %lx, length : %ld", - param_number, data, length)); + DBUG_PRINT("enter",("param no: %d data: 0x%lx length: %ld", + param_number, (ulong) data, length)); /* We only need to check for stmt->param_count, if it's not null @@ -3960,7 +3961,7 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) ulong bind_count= stmt->field_count; uint param_count= 0; DBUG_ENTER("mysql_stmt_bind_result"); - DBUG_PRINT("enter",("field_count: %d", bind_count)); + DBUG_PRINT("enter",("field_count: %lu", bind_count)); if (!bind_count) { diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 0b21d11df31..9e88085a616 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -191,7 +191,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, } } - DBUG_PRINT("exit",("Mysql handler: %lx",mysql)); + DBUG_PRINT("exit",("Mysql handler: 0x%lx", (ulong) mysql)); DBUG_RETURN(mysql); error: diff --git a/myisam/mi_close.c b/myisam/mi_close.c index 62f5617de1a..8a4f6ee7f5d 100644 --- a/myisam/mi_close.c +++ b/myisam/mi_close.c @@ -28,8 +28,9 @@ int mi_close(register MI_INFO *info) int error=0,flag; MYISAM_SHARE *share=info->s; DBUG_ENTER("mi_close"); - DBUG_PRINT("enter",("base: %lx reopen: %u locks: %u", - info,(uint) share->reopen, (uint) share->tot_locks)); + DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u", + (long) info, (uint) share->reopen, + (uint) share->tot_locks)); pthread_mutex_lock(&THR_LOCK_myisam); if (info->lock_type == F_EXTRA_LCK) diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index 9bbf10bc38a..76e6a9d7f91 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -152,7 +152,7 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("error",("Couldn't allocate memory")); DBUG_RETURN(my_errno=ENOMEM); } - DBUG_PRINT("info",("root_page: %ld",old_root)); + DBUG_PRINT("info",("root_page: %lu", (ulong) old_root)); if (!_mi_fetch_keypage(info,keyinfo,old_root,DFLT_INIT_HITS,root_buff,0)) { error= -1; @@ -392,7 +392,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, MYISAM_SHARE *share=info->s; MI_KEY_PARAM s_temp; DBUG_ENTER("del"); - DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", leaf_page, + DBUG_PRINT("enter",("leaf_page: %lu keypos: 0x%lx", (ulong) leaf_page, (ulong) keypos)); DBUG_DUMP("leaf_buff",(byte*) leaf_buff,mi_getint(leaf_buff)); @@ -579,7 +579,8 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, else { /* Page is full */ endpos=anc_buff+anc_length; - DBUG_PRINT("test",("anc_buff: %lx endpos: %lx",anc_buff,endpos)); + DBUG_PRINT("test",("anc_buff: 0x%lx endpos: 0x%lx", (long) anc_buff, + (long) endpos)); if (keypos != anc_buff+2+key_reflength && !_mi_get_last_key(info,keyinfo,anc_buff,anc_key,keypos,&length)) goto err; @@ -756,8 +757,8 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag, int s_length; uchar *start; DBUG_ENTER("remove_key"); - DBUG_PRINT("enter",("keypos: %lx page_end: %lx",keypos,page_end)); - + DBUG_PRINT("enter",("keypos: 0x%lx page_end: 0x%lx", (long) keypos, + (long) page_end)); start=keypos; if (!(keyinfo->flag & (HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY | diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index 260f461685e..7e57202c38d 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -1029,8 +1029,9 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, DBUG_RETURN(found_length); err: my_errno=HA_ERR_RECORD_DELETED; - DBUG_PRINT("error",("to_end: %lx -> %lx from_end: %lx -> %lx", - to,to_end,from,from_end)); + DBUG_PRINT("error",("to_end: 0x%lx -> 0x%lx from_end: 0x%lx -> 0x%lx", + (ulong) to, (ulong) to_end, (ulong) from, + (ulong) from_end)); DBUG_DUMP("from",(byte*) info->rec_buff,info->s->base.min_pack_length); DBUG_RETURN(MY_FILE_ERROR); } /* _mi_rec_unpack */ diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index 99a2fd6db15..a1c4f841dd2 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -54,8 +54,9 @@ int mi_assign_to_key_cache(MI_INFO *info, int error= 0; MYISAM_SHARE* share= info->s; DBUG_ENTER("mi_assign_to_key_cache"); - DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx", - share->key_cache, key_cache)); + DBUG_PRINT("enter", + ("old_key_cache_handle: 0x%lx new_key_cache_handle: 0x%lx", + (long) share->key_cache, (long) key_cache)); /* Skip operation if we didn't change key cache. This can happen if we diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 16713c87e10..103f6f536f4 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -27,7 +27,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, uchar *tmp; uint page_size; DBUG_ENTER("_mi_fetch_keypage"); - DBUG_PRINT("enter",("page: %ld",page)); + DBUG_PRINT("enter",("page: %ld", (long) page)); tmp=(uchar*) key_cache_read(info->s->key_cache, info->s->kfile, page, level, (byte*) buff, @@ -78,7 +78,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_errno=EINVAL; DBUG_RETURN((-1)); } - DBUG_PRINT("page",("write page at: %lu",(long) page,buff)); + DBUG_PRINT("page",("write page at: %lu",(long) page)); DBUG_DUMP("buff",(byte*) buff,mi_getint(buff)); #endif diff --git a/myisam/mi_statrec.c b/myisam/mi_statrec.c index 8f5cde45e24..951d390ba4f 100644 --- a/myisam/mi_statrec.c +++ b/myisam/mi_statrec.c @@ -254,7 +254,7 @@ int _mi_read_rnd_static_record(MI_INFO *info, byte *buf, if (filepos >= info->state->data_file_length) { DBUG_PRINT("test",("filepos: %ld (%ld) records: %ld del: %ld", - filepos/share->base.reclength,filepos, + (long) filepos/share->base.reclength, (long) filepos, info->state->records, info->state->del)); fast_mi_writeinfo(info); DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE); diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 49e3ea0f142..962d6a0c383 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -721,6 +721,7 @@ get_one_option(int optid, case 2: method_conv= MI_STATS_METHOD_IGNORE_NULLS; break; + default: assert(0); /* Impossible */ } check_param.stats_method= method_conv; break; diff --git a/myisammrg/myrg_extra.c b/myisammrg/myrg_extra.c index 62cf5f01aba..3f133780e23 100644 --- a/myisammrg/myrg_extra.c +++ b/myisammrg/myrg_extra.c @@ -28,7 +28,7 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function, int error,save_error=0; MYRG_TABLE *file; DBUG_ENTER("myrg_extra"); - DBUG_PRINT("info",("function: %d",(ulong) function)); + DBUG_PRINT("info",("function: %lu",(ulong) function)); if (function == HA_EXTRA_CACHE) { diff --git a/mysys/default.c b/mysys/default.c index fadf6efbc5b..4c99ae4cbf9 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -491,7 +491,7 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, ext= fn_ext(search_file->name); /* check extension */ - for (tmp_ext= (char**) f_extensions; *tmp_ext; *tmp_ext++) + for (tmp_ext= (char**) f_extensions; *tmp_ext; tmp_ext++) { if (!strcmp(ext, *tmp_ext)) break; diff --git a/mysys/hash.c b/mysys/hash.c index 75135a470c9..5d83dae0faa 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -53,7 +53,7 @@ _hash_init(HASH *hash,CHARSET_INFO *charset, void (*free_element)(void*),uint flags CALLER_INFO_PROTO) { DBUG_ENTER("hash_init"); - DBUG_PRINT("enter",("hash: 0x%lx size: %d",hash,size)); + DBUG_PRINT("enter",("hash: 0x%lx size: %d", (long) hash, size)); hash->records=0; if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0)) @@ -109,7 +109,7 @@ static inline void hash_free_elements(HASH *hash) void hash_free(HASH *hash) { DBUG_ENTER("hash_free"); - DBUG_PRINT("enter",("hash: 0x%lxd",hash)); + DBUG_PRINT("enter",("hash: 0x%lxd", (long) hash)); hash_free_elements(hash); hash->free= 0; @@ -129,7 +129,7 @@ void hash_free(HASH *hash) void my_hash_reset(HASH *hash) { DBUG_ENTER("my_hash_reset"); - DBUG_PRINT("enter",("hash: 0x%lxd",hash)); + DBUG_PRINT("enter",("hash: 0x%lxd", (long) hash)); hash_free_elements(hash); reset_dynamic(&hash->array); @@ -645,7 +645,9 @@ my_bool hash_check(HASH *hash) if ((rec_link=hash_rec_mask(hash,hash_info,blength,records)) != i) { DBUG_PRINT("error", - ("Record in wrong link at %d: Start %d Record: 0x%lx Record-link %d", idx,i,hash_info->data,rec_link)); + ("Record in wrong link at %d: " + "Start %d Record: 0x%lx Record-link %d", + idx, i, (long) hash_info->data, rec_link)); error=1; } else @@ -656,13 +658,13 @@ my_bool hash_check(HASH *hash) } if (found != records) { - DBUG_PRINT("error",("Found %ld of %ld records")); + DBUG_PRINT("error",("Found %u of %u records", found, records)); error=1; } if (records) DBUG_PRINT("info", - ("records: %ld seeks: %d max links: %d hitrate: %.2f", - records,seek,max_links,(float) seek / (float) records)); + ("records: %u seeks: %u max links: %d hitrate: %.2f", + records, seek, max_links, (float) seek / (float) records)); return error; } #endif diff --git a/mysys/list.c b/mysys/list.c index 480c1080a45..9755dbcde84 100644 --- a/mysys/list.c +++ b/mysys/list.c @@ -28,7 +28,8 @@ LIST *list_add(LIST *root, LIST *element) { DBUG_ENTER("list_add"); - DBUG_PRINT("enter",("root: 0x%lx element: %lx", root, element)); + DBUG_PRINT("enter",("root: 0x%lx element: 0x%lx", (long) root, + (long) element)); if (root) { if (root->prev) /* If add in mid of list */ diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index a91002d3b4c..8bf9ad84e34 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -589,7 +589,9 @@ void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare, DBUG_ENTER("init_io_cache_share"); DBUG_PRINT("io_cache_share", ("read_cache: 0x%lx share: 0x%lx " "write_cache: 0x%lx threads: %u", - read_cache, cshare, write_cache, num_threads)); + (long) read_cache, + (long) cshare, + (long) write_cache, num_threads)); DBUG_ASSERT(num_threads > 1); DBUG_ASSERT(read_cache->type == READ_CACHE); @@ -651,7 +653,7 @@ void remove_io_thread(IO_CACHE *cache) pthread_mutex_lock(&cshare->mutex); DBUG_PRINT("io_cache_share", ("%s: 0x%lx", (cache == cshare->source_cache) ? - "writer" : "reader", cache)); + "writer" : "reader", (long) cache)); /* Remove from share. */ total= --cshare->total_threads; @@ -727,7 +729,8 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos) cshare->running_threads--; DBUG_PRINT("io_cache_share", ("%s: 0x%lx pos: %lu running: %u", (cache == cshare->source_cache) ? - "writer" : "reader", cache, (ulong) pos, + "writer" : "reader", + (long) cache, (ulong) pos, cshare->running_threads)); if (cshare->source_cache) @@ -866,7 +869,7 @@ static void unlock_io_cache(IO_CACHE *cache) DBUG_PRINT("io_cache_share", ("%s: 0x%lx pos: %lu running: %u", (cache == cshare->source_cache) ? "writer" : "reader", - cache, (ulong) cshare->pos_in_file, + (long) cache, (ulong) cshare->pos_in_file, cshare->total_threads)); cshare->running_threads= cshare->total_threads; diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 88b5051c52b..8ce3a6dde5c 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -410,9 +410,9 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, DBUG_PRINT("exit", ("disk_blocks: %d block_root: 0x%lx hash_entries: %d\ hash_root: 0x%lx hash_links: %d hash_link_root: 0x%lx", - keycache->disk_blocks, keycache->block_root, - keycache->hash_entries, keycache->hash_root, - keycache->hash_links, keycache->hash_link_root)); + keycache->disk_blocks, (long) keycache->block_root, + keycache->hash_entries, (long) keycache->hash_root, + keycache->hash_links, (long) keycache->hash_link_root)); bzero((gptr) keycache->changed_blocks, sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); bzero((gptr) keycache->file_blocks, @@ -613,7 +613,7 @@ void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) { DBUG_ENTER("end_key_cache"); - DBUG_PRINT("enter", ("key_cache: 0x%lx", keycache)); + DBUG_PRINT("enter", ("key_cache: 0x%lx", (long) keycache)); if (!keycache->key_cache_inited) DBUG_VOID_RETURN; @@ -632,7 +632,7 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) keycache->blocks_changed= 0; } - DBUG_PRINT("status", ("used: %d changed: %d w_requests: %lu " + DBUG_PRINT("status", ("used: %lu changed: %lu w_requests: %lu " "writes: %lu r_requests: %lu reads: %lu", keycache->blocks_used, keycache->global_blocks_changed, (ulong) keycache->global_cache_w_requests, @@ -1058,7 +1058,7 @@ static void unreg_request(KEY_CACHE *keycache, if (block->temperature == BLOCK_WARM) keycache->warm_blocks--; block->temperature= BLOCK_HOT; - KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks=%u", + KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu", keycache->warm_blocks)); } link_block(keycache, block, hot, (my_bool)at_end); @@ -1077,7 +1077,7 @@ static void unreg_request(KEY_CACHE *keycache, keycache->warm_blocks++; block->temperature= BLOCK_WARM; } - KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks=%u", + KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu", keycache->warm_blocks)); } } @@ -1313,11 +1313,11 @@ static BLOCK_LINK *find_key_block(KEY_CACHE *keycache, DBUG_ENTER("find_key_block"); KEYCACHE_THREAD_TRACE("find_key_block:begin"); - DBUG_PRINT("enter", ("fd: %u pos %lu wrmode: %lu", - (uint) file, (ulong) filepos, (uint) wrmode)); - KEYCACHE_DBUG_PRINT("find_key_block", ("fd: %u pos: %lu wrmode: %lu", + DBUG_PRINT("enter", ("fd: %u pos: %lu wrmode: %d", + (uint) file, (ulong) filepos, wrmode)); + KEYCACHE_DBUG_PRINT("find_key_block", ("fd: %u pos: %lu wrmode: %d", (uint) file, (ulong) filepos, - (uint) wrmode)); + wrmode)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_keycache2", test_key_cache(keycache, "start of find_key_block", 0);); @@ -1587,9 +1587,9 @@ restart: KEYCACHE_DBUG_ASSERT(page_status != -1); *page_st=page_status; KEYCACHE_DBUG_PRINT("find_key_block", - ("fd: %u pos %lu block->status %u page_status %lu", + ("fd: %u pos: %lu block->status: %u page_status: %d", (uint) file, (ulong) filepos, block->status, - (uint) page_status)); + page_status)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_keycache2", @@ -2274,7 +2274,7 @@ static int flush_key_blocks_int(KEY_CACHE *keycache, BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache; int last_errno= 0; DBUG_ENTER("flush_key_blocks_int"); - DBUG_PRINT("enter",("file: %d blocks_used: %d blocks_changed: %d", + DBUG_PRINT("enter",("file: %d blocks_used: %lu blocks_changed: %lu", file, keycache->blocks_used, keycache->blocks_changed)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) @@ -2474,7 +2474,7 @@ int flush_key_blocks(KEY_CACHE *keycache, { int res; DBUG_ENTER("flush_key_blocks"); - DBUG_PRINT("enter", ("keycache: 0x%lx", keycache)); + DBUG_PRINT("enter", ("keycache: 0x%lx", (long) keycache)); if (keycache->disk_blocks <= 0) DBUG_RETURN(0); diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index 38fef31fdd4..e5086014a27 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -159,7 +159,7 @@ static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length) result= hash->default_value; else result= ((SAFE_HASH_ENTRY*) result)->data; - DBUG_PRINT("exit",("data: 0x%lx", result)); + DBUG_PRINT("exit",("data: 0x%lx", (long) result)); DBUG_RETURN(result); } @@ -190,7 +190,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length, SAFE_HASH_ENTRY *entry; my_bool error= 0; DBUG_ENTER("safe_hash_set"); - DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, data)); + DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, (long) data)); rw_wrlock(&hash->mutex); entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length); diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index d52a8efeed2..62fcbd491f9 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -47,7 +47,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size __attribute__((unused))) { DBUG_ENTER("init_alloc_root"); - DBUG_PRINT("enter",("root: 0x%lx", mem_root)); + DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root)); mem_root->free= mem_root->used= mem_root->pre_alloc= 0; mem_root->min_malloc= 32; mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE; @@ -263,7 +263,8 @@ void free_root(MEM_ROOT *root, myf MyFlags) { reg1 USED_MEM *next,*old; DBUG_ENTER("free_root"); - DBUG_PRINT("enter",("root: 0x%lx flags: %u", root, (uint) MyFlags)); + DBUG_PRINT("enter",("root: 0x%lx flags: %u", + (long) root, (uint) MyFlags)); if (!root) /* QQ: Should be deleted */ DBUG_VOID_RETURN; /* purecov: inspected */ diff --git a/mysys/my_dup.c b/mysys/my_dup.c index 4b7434e29ea..cdc15b3ebce 100644 --- a/mysys/my_dup.c +++ b/mysys/my_dup.c @@ -30,7 +30,7 @@ File my_dup(File file, myf MyFlags) File fd; const char *filename; DBUG_ENTER("my_dup"); - DBUG_PRINT("my",("file: %d MyFlags: %d", MyFlags)); + DBUG_PRINT("my",("file: %d MyFlags: %d", file, MyFlags)); fd = dup(file); filename= (((uint) file < my_file_limit) ? my_file_info[(int) file].name : "Unknown"); diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index f07beec9f39..6e81d40a2d6 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -79,7 +79,7 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags) my_stream_opened++; my_file_info[fileno(fd)].type = STREAM_BY_FOPEN; pthread_mutex_unlock(&THR_LOCK_open); - DBUG_PRINT("exit",("stream: 0x%lx",fd)); + DBUG_PRINT("exit",("stream: 0x%lx", (long) fd)); DBUG_RETURN(fd); } pthread_mutex_unlock(&THR_LOCK_open); @@ -103,7 +103,7 @@ int my_fclose(FILE *fd, myf MyFlags) { int err,file; DBUG_ENTER("my_fclose"); - DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d",fd, MyFlags)); + DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) fd, MyFlags)); pthread_mutex_lock(&THR_LOCK_open); file=fileno(fd); @@ -163,7 +163,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags) pthread_mutex_unlock(&THR_LOCK_open); } - DBUG_PRINT("exit",("stream: 0x%lx",fd)); + DBUG_PRINT("exit",("stream: 0x%lx", (long) fd)); DBUG_RETURN(fd); } /* my_fdopen */ diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c index 5b17e3ff51c..7ac2cc0d89e 100644 --- a/mysys/my_fstream.c +++ b/mysys/my_fstream.c @@ -40,7 +40,7 @@ uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags) uint readbytes; DBUG_ENTER("my_fread"); DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d", - stream, Buffer, Count, MyFlags)); + (long) stream, (long) Buffer, Count, MyFlags)); if ((readbytes = (uint) fread(Buffer,sizeof(char),(size_t) Count,stream)) != Count) @@ -81,7 +81,7 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags) #endif DBUG_ENTER("my_fwrite"); DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d", - stream, Buffer, Count, MyFlags)); + (long) stream, (long) Buffer, Count, MyFlags)); #if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM) errors=0; @@ -153,7 +153,7 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence, { DBUG_ENTER("my_fseek"); DBUG_PRINT("my",("stream: 0x%lx pos: %lu whence: %d MyFlags: %d", - stream, pos, whence, MyFlags)); + (long) stream, (ulong) pos, whence, MyFlags)); DBUG_RETURN(fseek(stream, (off_t) pos, whence) ? MY_FILEPOS_ERROR : (my_off_t) ftell(stream)); } /* my_seek */ @@ -166,7 +166,7 @@ my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused))) { off_t pos; DBUG_ENTER("my_ftell"); - DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d",stream, MyFlags)); + DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) stream, MyFlags)); pos=ftell(stream); DBUG_PRINT("exit",("ftell: %lu",(ulong) pos)); DBUG_RETURN((my_off_t) pos); diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index 5663ceaa60e..9c9b9cf7bbb 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -45,7 +45,8 @@ int my_getwd(my_string buf, uint size, myf MyFlags) { my_string pos; DBUG_ENTER("my_getwd"); - DBUG_PRINT("my",("buf: 0x%lx size: %d MyFlags %d", buf,size,MyFlags)); + DBUG_PRINT("my",("buf: 0x%lx size: %d MyFlags %d", + (long) buf, size, MyFlags)); #if ! defined(MSDOS) if (curr_dir[0]) /* Current pos is saved here */ diff --git a/mysys/my_handler.c b/mysys/my_handler.c index 156e7892580..3d90b7f892a 100644 --- a/mysys/my_handler.c +++ b/mysys/my_handler.c @@ -543,8 +543,11 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a) case HA_KEYTYPE_DOUBLE: a= end; break; + case HA_KEYTYPE_END: /* purecov: inspected */ + /* keep compiler happy */ + DBUG_ASSERT(0); + break; } } return keyseg; } - diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 1908c70f407..41bfbc83b35 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -625,7 +625,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, - (byte *) stat_area, my_flags)); + (long) stat_area, my_flags)); if ((m_used= (stat_area == NULL))) if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags))) diff --git a/mysys/my_lread.c b/mysys/my_lread.c index a96febe4474..02ed3b5d213 100644 --- a/mysys/my_lread.c +++ b/mysys/my_lread.c @@ -27,8 +27,8 @@ uint32 my_lread(int Filedes, byte *Buffer, uint32 Count, myf MyFlags) { uint32 readbytes; DBUG_ENTER("my_lread"); - DBUG_PRINT("my",("Fd: %d Buffer: %ld Count: %ld MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); + DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", + Filedes, (long) Buffer, Count, MyFlags)); DBUG_PRINT("error", ("Deprecated my_lread() function should not be used.")); diff --git a/mysys/my_lwrite.c b/mysys/my_lwrite.c index 02c56a69ba4..f012e9d6a85 100644 --- a/mysys/my_lwrite.c +++ b/mysys/my_lwrite.c @@ -23,8 +23,8 @@ uint32 my_lwrite(int Filedes, const byte *Buffer, uint32 Count, myf MyFlags) { uint32 writenbytes; DBUG_ENTER("my_lwrite"); - DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %ld MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); + DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", + Filedes, (long) Buffer, Count, MyFlags)); DBUG_PRINT("error", ("Deprecated my_lwrite() function should not be used.")); diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index 3f601a42dc9..a146b9ddd27 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -44,7 +44,7 @@ gptr my_malloc(unsigned int size, myf my_flags) } else if (my_flags & MY_ZEROFILL) bzero(point,size); - DBUG_PRINT("exit",("ptr: 0x%lx",point)); + DBUG_PRINT("exit",("ptr: 0x%lx", (long) point)); DBUG_RETURN(point); } /* my_malloc */ @@ -55,7 +55,7 @@ gptr my_malloc(unsigned int size, myf my_flags) void my_no_flags_free(gptr ptr) { DBUG_ENTER("my_free"); - DBUG_PRINT("my",("ptr: 0x%lx",ptr)); + DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr)); if (ptr) free(ptr); DBUG_VOID_RETURN; diff --git a/mysys/my_pread.c b/mysys/my_pread.c index f378d548731..f4218fac65f 100644 --- a/mysys/my_pread.c +++ b/mysys/my_pread.c @@ -30,7 +30,7 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, int error; DBUG_ENTER("my_pread"); DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d", - Filedes, (ulong) offset, Buffer, Count, MyFlags)); + Filedes, (ulong) offset, (long) Buffer, Count, MyFlags)); for (;;) { @@ -49,8 +49,8 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, if (error) { my_errno=errno; - DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d", - readbytes,Count,Filedes,my_errno)); + DBUG_PRINT("warning",("Read only %u bytes off %u from %d, errno: %d", + readbytes, Count, Filedes, my_errno)); #ifdef THREAD if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) { @@ -87,7 +87,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset, ulong written; DBUG_ENTER("my_pwrite"); DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %d MyFlags: %d", - Filedes, (ulong) offset,Buffer, Count, MyFlags)); + Filedes, (ulong) offset, (long) Buffer, Count, MyFlags)); errors=0; written=0L; for (;;) diff --git a/mysys/my_read.c b/mysys/my_read.c index 8b88e483fef..a08a008de6f 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -39,7 +39,7 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) uint readbytes, save_count; DBUG_ENTER("my_read"); DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); + Filedes, (long) Buffer, Count, MyFlags)); save_count= Count; for (;;) @@ -48,7 +48,7 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count) { my_errno= errno ? errno : -1; - DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d", + DBUG_PRINT("warning",("Read only %u bytes off %u from %d, errno: %d", readbytes, Count, Filedes, my_errno)); #ifdef THREAD if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c index c8edb172890..872518f2b0b 100644 --- a/mysys/my_realloc.c +++ b/mysys/my_realloc.c @@ -27,8 +27,8 @@ gptr my_realloc(gptr oldpoint, uint size, myf my_flags) { gptr point; DBUG_ENTER("my_realloc"); - DBUG_PRINT("my",("ptr: 0x%lx size: %u my_flags: %d",oldpoint, size, - my_flags)); + DBUG_PRINT("my",("ptr: 0x%lx size: %u my_flags: %d", + (long) oldpoint, size, my_flags)); if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR)) DBUG_RETURN(my_malloc(size,my_flags)); @@ -60,6 +60,6 @@ gptr my_realloc(gptr oldpoint, uint size, myf my_flags) my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size); } #endif - DBUG_PRINT("exit",("ptr: 0x%lx",point)); + DBUG_PRINT("exit",("ptr: 0x%lx", (long) point)); DBUG_RETURN(point); } /* my_realloc */ diff --git a/mysys/my_seek.c b/mysys/my_seek.c index a9ae68cd5f0..5f8318cd729 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -55,7 +55,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",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/my_tempnam.c b/mysys/my_tempnam.c index 9f765298fb6..4b4ab8de242 100644 --- a/mysys/my_tempnam.c +++ b/mysys/my_tempnam.c @@ -106,7 +106,7 @@ my_string my_tempnam(const char *dir, const char *pfx, #ifdef OS2 /* changing environ variable doesn't work with VACPP */ char buffer[256], *end; - buffer[sizeof[buffer)-1]= 0; + buffer[sizeof(buffer)-1]= 0; end= strxnmov(buffer, sizeof(buffer)-1, (char*) "TMP=", dir, NullS); /* remove ending backslash */ if (end[-1] == '\\') diff --git a/mysys/my_write.c b/mysys/my_write.c index ae8cb4ab02b..26b9a4f2444 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -27,7 +27,7 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) ulong written; DBUG_ENTER("my_write"); DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %d MyFlags: %d", - Filedes, Buffer, Count, MyFlags)); + Filedes, (long) Buffer, Count, MyFlags)); errors=0; written=0L; for (;;) diff --git a/mysys/raid.cc b/mysys/raid.cc index 62587c438ca..4f1be0103e9 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -185,8 +185,8 @@ extern "C" { uint my_raid_write(File fd,const byte *Buffer, uint Count, myf MyFlags) { DBUG_ENTER("my_raid_write"); - DBUG_PRINT("enter",("Fd: %d Buffer: %lx Count: %u MyFlags: %d", - fd, Buffer, Count, MyFlags)); + DBUG_PRINT("enter",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", + fd, (long) Buffer, Count, MyFlags)); if (is_raid(fd)) { RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**)); @@ -198,8 +198,8 @@ extern "C" { uint my_raid_read(File fd, byte *Buffer, uint Count, myf MyFlags) { DBUG_ENTER("my_raid_read"); - DBUG_PRINT("enter",("Fd: %d Buffer: %lx Count: %u MyFlags: %d", - fd, Buffer, Count, MyFlags)); + DBUG_PRINT("enter",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", + fd, (long) Buffer, Count, MyFlags)); if (is_raid(fd)) { RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**)); @@ -212,8 +212,9 @@ extern "C" { myf MyFlags) { DBUG_ENTER("my_raid_pread"); - DBUG_PRINT("enter",("Fd: %d Buffer: %lx Count: %u offset: %u MyFlags: %d", - Filedes, Buffer, Count, offset, MyFlags)); + DBUG_PRINT("enter", + ("Fd: %d Buffer: 0x%lx Count: %u offset: %lu MyFlags: %d", + Filedes, (long) Buffer, Count, (ulong) offset, MyFlags)); if (is_raid(Filedes)) { assert(offset != MY_FILEPOS_ERROR); @@ -231,8 +232,8 @@ extern "C" { my_off_t offset, myf MyFlags) { DBUG_ENTER("my_raid_pwrite"); - DBUG_PRINT("enter",("Fd: %d Buffer: %lx Count: %u offset: %u MyFlags: %d", - Filedes, Buffer, Count, offset, MyFlags)); + DBUG_PRINT("enter",("Fd: %d Buffer: 0x%lx Count: %u offset: %lu MyFlags: %d", + Filedes, (long) Buffer, Count, (ulong) offset, MyFlags)); if (is_raid(Filedes)) { assert(offset != MY_FILEPOS_ERROR); @@ -250,8 +251,8 @@ extern "C" { myf MyFlags) { DBUG_ENTER("my_raid_lock"); - DBUG_PRINT("enter",("Fd: %d start: %u length: %u MyFlags: %d", - fd, start, length, MyFlags)); + DBUG_PRINT("enter",("Fd: %d start: %lu length: %lu MyFlags: %d", + fd, (ulong) start, (ulong) length, MyFlags)); if (my_disable_locking) DBUG_RETURN(0); if (is_raid(fd)) @@ -284,8 +285,8 @@ extern "C" { int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { DBUG_ENTER("my_raid_chsize"); - DBUG_PRINT("enter",("Fd: %d newlength: %u MyFlags: %d", - fd, newlength, MyFlags)); + DBUG_PRINT("enter",("Fd: %d newlength: %lu MyFlags: %d", + fd, (ulong) newlength, MyFlags)); if (is_raid(fd)) { RaidFd *raid= (*dynamic_element(&RaidFd::_raid_map,fd,RaidFd**)); @@ -413,7 +414,7 @@ RaidFd(uint raid_type, uint raid_chunks, ulong raid_chunksize) _fd_vector(0) { DBUG_ENTER("RaidFd::RaidFd"); - DBUG_PRINT("enter",("RaidFd_type: %u Disks: %u Chunksize: %d", + DBUG_PRINT("enter",("RaidFd_type: %u Disks: %u Chunksize: %lu", raid_type, raid_chunks, raid_chunksize)); /* TODO: Here we should add checks if the malloc fails */ @@ -622,7 +623,7 @@ Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags) { DBUG_ENTER("RaidFd::Lock"); DBUG_PRINT("enter",("locktype: %d start: %lu length: %lu MyFlags: %d", - locktype, start, length, MyFlags)); + locktype, (ulong) start, (ulong) length, MyFlags)); my_off_t bufptr = start; // Loop until all data is locked while(length) @@ -732,8 +733,8 @@ my_off_t RaidFd:: Tell(myf MyFlags) { DBUG_ENTER("RaidFd::Tell"); - DBUG_PRINT("enter",("MyFlags: %d _position %d", - MyFlags,_position)); + DBUG_PRINT("enter",("MyFlags: %d _position: %lu", + MyFlags, (ulong) _position)); DBUG_RETURN(_position); } @@ -741,8 +742,8 @@ int RaidFd:: Chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { DBUG_ENTER("RaidFd::Chsize"); - DBUG_PRINT("enter",("Fd: %d, newlength: %d, MyFlags: %d", - fd, newlength,MyFlags)); + DBUG_PRINT("enter",("Fd: %d newlength: %lu MyFlags: %d", + fd, (ulong) newlength, MyFlags)); _position = newlength; Calculate(); uint _rounds = _total_block / _raid_chunks; // INT() assumed diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 6cdf98c5f5f..5f93b861b31 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -194,7 +194,7 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick) bfill(data, size, (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL)); /* Return a pointer to the real data */ - DBUG_PRINT("exit",("ptr: 0x%lx", data)); + DBUG_PRINT("exit",("ptr: 0x%lx", (long) data)); if (sf_min_adress > data) sf_min_adress= data; if (sf_max_adress < data) @@ -259,7 +259,7 @@ void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags) { struct st_irem *irem; DBUG_ENTER("_myfree"); - DBUG_PRINT("enter",("ptr: 0x%lx", ptr)); + DBUG_PRINT("enter",("ptr: 0x%lx", (long) ptr)); if (!sf_malloc_quick) (void) _sanity (filename, lineno); @@ -410,7 +410,7 @@ void TERMINATE(FILE *file) } DBUG_PRINT("safe", ("%6u bytes at 0x%09lx, allocated at line %4d in '%s'", - irem->datasize, data, irem->linenum, irem->filename)); + irem->datasize, (long) data, irem->linenum, irem->filename)); irem= irem->next; } } @@ -447,7 +447,7 @@ static int _checkchunk(register struct st_irem *irem, const char *filename, fprintf(stderr, " discovered at %s:%d\n", filename, lineno); (void) fflush(stderr); DBUG_PRINT("safe",("Underrun at 0x%lx, allocated at %s:%d", - data, irem->filename, irem->linenum)); + (long) data, irem->filename, irem->linenum)); flag=1; } @@ -463,7 +463,7 @@ static int _checkchunk(register struct st_irem *irem, const char *filename, fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno); (void) fflush(stderr); DBUG_PRINT("safe",("Overrun at 0x%lx, allocated at %s:%d", - data, + (long) data, irem->filename, irem->linenum)); flag=1; diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index d6443539216..fb1c2ca6409 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -436,7 +436,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) data->thread_id=my_thread_id(); /* Must be reset ! */ VOID(pthread_mutex_lock(&lock->mutex)); DBUG_PRINT("lock",("data: 0x%lx thread: %ld lock: 0x%lx type: %d", - data,data->thread_id,lock,(int) lock_type)); + (long) data, data->thread_id, (long) lock, + (int) lock_type)); check_locks(lock,(uint) lock_type <= (uint) TL_READ_NO_INSERT ? "enter read_lock" : "enter write_lock",0); if ((int) lock_type <= (int) TL_READ_NO_INSERT) @@ -598,8 +599,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) goto end; } } - DBUG_PRINT("lock",("write locked by thread: %ld, type: %ld", - lock->read.data->thread_id,data->type)); + DBUG_PRINT("lock",("write locked by thread: %ld type: %d", + lock->read.data->thread_id, (int) data->type)); } DBUG_RETURN(wait_for_lock(&lock->write_wait,data,0)); } @@ -665,7 +666,7 @@ void thr_unlock(THR_LOCK_DATA *data) enum thr_lock_type lock_type=data->type; DBUG_ENTER("thr_unlock"); DBUG_PRINT("lock",("data: 0x%lx thread: %ld lock: 0x%lx", - data,data->thread_id,lock)); + (long) data, data->thread_id, (long) lock)); pthread_mutex_lock(&lock->mutex); check_locks(lock,"start of release lock",0); @@ -835,7 +836,7 @@ int thr_multi_lock(THR_LOCK_DATA **data,uint count) { THR_LOCK_DATA **pos,**end; DBUG_ENTER("thr_multi_lock"); - DBUG_PRINT("lock",("data: 0x%lx count: %d",data,count)); + DBUG_PRINT("lock",("data: 0x%lx count: %d", (long) data, count)); if (count > 1) sort_locks(data,count); /* lock everything */ @@ -907,7 +908,7 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count) { THR_LOCK_DATA **pos,**end; DBUG_ENTER("thr_multi_unlock"); - DBUG_PRINT("lock",("data: 0x%lx count: %d",data,count)); + DBUG_PRINT("lock",("data: 0x%lx count: %d", (long) data, count)); for (pos=data,end=data+count; pos < end ; pos++) { @@ -921,7 +922,7 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count) else { DBUG_PRINT("lock",("Free lock: data: 0x%lx thread: %ld lock: 0x%lx", - *pos,(*pos)->thread_id,(*pos)->lock)); + (long) *pos, (*pos)->thread_id, (long) (*pos)->lock)); } } DBUG_VOID_RETURN; diff --git a/mysys/tree.c b/mysys/tree.c index bec1ec680f1..4eae086ab96 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -89,7 +89,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, tree_element_free free_element, void *custom_arg) { DBUG_ENTER("init_tree"); - DBUG_PRINT("enter",("tree: 0x%lx size: %d",tree,size)); + DBUG_PRINT("enter",("tree: 0x%lx size: %d", (long) tree, size)); if (default_alloc_size < DEFAULT_ALLOC_SIZE) default_alloc_size= DEFAULT_ALLOC_SIZE; @@ -137,7 +137,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, static void free_tree(TREE *tree, myf free_flags) { DBUG_ENTER("free_tree"); - DBUG_PRINT("enter",("tree: 0x%lx",tree)); + DBUG_PRINT("enter",("tree: 0x%lx", (long) tree)); if (tree->root) /* If initialized */ { diff --git a/mysys/typelib.c b/mysys/typelib.c index 90a093b0b32..d329b687668 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -49,7 +49,7 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name) reg1 my_string i; reg2 const char *j; DBUG_ENTER("find_type"); - DBUG_PRINT("enter",("x: '%s' lib: 0x%lx",x,typelib)); + DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) typelib)); if (!typelib->count) { diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index ea5dc218898..3b47abd7cd3 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1263,8 +1263,8 @@ CommandInterpreter::executeConnect(char* parameters) int retval; disconnect(); if (!emptyString(parameters)) { - if (retval = ndb_mgm_set_connectstring(m_mgmsrv, - BaseString(parameters).trim().c_str())) + if ((retval = ndb_mgm_set_connectstring(m_mgmsrv, + BaseString(parameters).trim().c_str()))) { printError(); return retval; diff --git a/regex/regexec.c b/regex/regexec.c index b7ad83ba883..13c253ca4f6 100644 --- a/regex/regexec.c +++ b/regex/regexec.c @@ -15,7 +15,8 @@ #include "utils.h" #include "regex2.h" -static int nope = 0; /* for use in asserts; shuts lint up */ +/* for use in asserts */ +#define nope 0 /* macros for manipulating states, small version */ #define states long diff --git a/sql-common/client.c b/sql-common/client.c index 431c1bdf418..27ed5cf4dbd 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -601,7 +601,7 @@ net_safe_read(MYSQL *mysql) if (len == packet_error || len == 0) { - DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", + DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %lu", vio_description(net->vio),len)); #ifdef MYSQL_SERVER if (vio_was_interrupted(net->vio)) @@ -858,7 +858,7 @@ void STDCALL mysql_free_result(MYSQL_RES *result) { DBUG_ENTER("mysql_free_result"); - DBUG_PRINT("enter",("mysql_res: %lx",result)); + DBUG_PRINT("enter",("mysql_res: 0x%lx", (ulong) result)); if (result) { MYSQL *mysql= result->handle; @@ -1174,7 +1174,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, { uchar *pos; /* fields count may be wrong */ - DBUG_ASSERT ((field - result) < fields); + DBUG_ASSERT ((uint) (field - result) < fields); cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); field->catalog = strdup_root(alloc,(char*) row->data[0]); field->db = strdup_root(alloc,(char*) row->data[1]); @@ -1350,7 +1350,7 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, DBUG_PRINT("info",("status: %u warning_count: %u", mysql->server_status, mysql->warning_count)); } - DBUG_PRINT("exit",("Got %d rows",result->rows)); + DBUG_PRINT("exit",("Got %lu rows", (ulong) result->rows)); DBUG_RETURN(result); } @@ -2178,7 +2178,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, goto error; #endif - DBUG_PRINT("exit",("Mysql handler: %lx",mysql)); + DBUG_PRINT("exit",("Mysql handler: 0x%lx", (ulong) mysql)); reset_sigpipe(mysql); DBUG_RETURN(mysql); @@ -2533,7 +2533,7 @@ int STDCALL mysql_real_query(MYSQL *mysql, const char *query, ulong length) { DBUG_ENTER("mysql_real_query"); - DBUG_PRINT("enter",("handle: %lx",mysql)); + DBUG_PRINT("enter",("handle: 0x%lx", (ulong) mysql)); DBUG_PRINT("query",("Query = '%-.4096s'",query)); if (mysql_send_query(mysql,query,length)) diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 77226da3dc8..532a8f843e5 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -902,7 +902,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, */ if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE)) tmp= 0; -end: + return (my_time_t) tmp; } /* my_system_gmt_sec */ diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 16ba7605415..02d27b398f1 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -573,7 +573,8 @@ int ha_archive::write_row(byte * buf) table->timestamp_field->set_time(); pthread_mutex_lock(&share->mutex); written= gzwrite(share->archive_write, buf, table->reclength); - DBUG_PRINT("ha_archive::get_row", ("Wrote %d bytes expected %d", written, table->reclength)); + DBUG_PRINT("ha_archive::get_row", ("Wrote %d bytes expected %d", (int) written, + table->reclength)); share->dirty= TRUE; if (written != (z_off_t)table->reclength) goto error; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 3d1724efb91..d7219bb0b1c 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3594,7 +3594,7 @@ ha_innobase::rnd_pos( } if (error) { - DBUG_PRINT("error",("Got error: %ld",error)); + DBUG_PRINT("error",("Got error: %d", error)); DBUG_RETURN(error); } @@ -3604,7 +3604,7 @@ ha_innobase::rnd_pos( error = index_read(buf, pos, ref_length, HA_READ_KEY_EXACT); if (error) { - DBUG_PRINT("error",("Got error: %ld",error)); + DBUG_PRINT("error",("Got error: %d", error)); } change_active_index(keynr); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d16e00f4e52..d61c8242677 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -692,8 +692,8 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob) { char *buf= m_blobs_buffer + offset; uint32 len= 0xffffffff; // Max uint32 - DBUG_PRINT("value", ("read blob ptr=%x len=%u", - (UintPtr)buf, (uint)blob_len)); + DBUG_PRINT("value", ("read blob ptr: 0x%lx len: %u", + (ulong)buf, (uint)blob_len)); if (ndb_blob->readData(buf, len) != 0) DBUG_RETURN(-1); DBUG_ASSERT(len == blob_len); @@ -1484,7 +1484,7 @@ inline int ha_ndbcluster::next_result(byte *buf) all pending update or delete operations should be sent to NDB */ - DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending)); + DBUG_PRINT("info", ("ops_pending: %lu", (ulong) m_ops_pending)); if (m_ops_pending) { // if (current_thd->transaction.on) @@ -2026,7 +2026,7 @@ int ha_ndbcluster::write_row(byte *record) (ulong) next_val)); if (ndb->setAutoIncrementValue((const NDBTAB *) m_table, next_val, TRUE)) DBUG_PRINT("info", - ("Setting next auto increment value to %u", next_val)); + ("Setting next auto increment value to %u", (uint) next_val)); } m_skip_auto_increment= TRUE; @@ -2417,7 +2417,7 @@ void ha_ndbcluster::print_results() break; } case NdbDictionary::Column::Int: { - fprintf(DBUG_FILE, "Int\t%lld", field->val_int()); + fprintf(DBUG_FILE, "Int\t%ld", (long) field->val_int()); break; } case NdbDictionary::Column::Unsigned: { @@ -2787,7 +2787,7 @@ int ha_ndbcluster::close_scan() Take over any pending transactions to the deleteing/updating transaction before closing the scan */ - DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending)); + DBUG_PRINT("info", ("ops_pending: %lu", (ulong) m_ops_pending)); if (execute_no_commit(this,trans) != 0) { no_uncommitted_rows_execute_failure(); DBUG_RETURN(ndb_err(trans)); @@ -3823,7 +3823,7 @@ static int create_ndb_column(NDBCOL &col, col.setAutoIncrement(TRUE); ulonglong value= info->auto_increment_value ? info->auto_increment_value : (ulonglong) 1; - DBUG_PRINT("info", ("Autoincrement key, initial: %llu", value)); + DBUG_PRINT("info", ("Autoincrement key, initial: %lu", (ulong) value)); col.setAutoIncrementInitialValue(value); } else @@ -3926,7 +3926,8 @@ int ha_ndbcluster::create(const char *name, if (packfrm(data, length, &pack_data, &pack_length)) DBUG_RETURN(2); - DBUG_PRINT("info", ("setFrm data=%x, len=%d", pack_data, pack_length)); + DBUG_PRINT("info", ("setFrm data: 0x%lx len: %u", (ulong) pack_data, + pack_length)); tab.setFrm(pack_data, pack_length); my_free((char*)data, MYF(0)); my_free((char*)pack_data, MYF(0)); @@ -3934,7 +3935,7 @@ int ha_ndbcluster::create(const char *name, for (i= 0; i < form->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, info))) @@ -5221,14 +5222,14 @@ static int packfrm(const void *data, uint len, uint blob_len; frm_blob_struct* blob; DBUG_ENTER("packfrm"); - DBUG_PRINT("enter", ("data: %x, len: %d", data, len)); + DBUG_PRINT("enter", ("data: 0x%lx len: %u", (ulong) data, len)); error= 1; org_len= len; if (my_compress((byte*)data, &org_len, &comp_len)) goto err; - DBUG_PRINT("info", ("org_len: %d, comp_len: %d", org_len, comp_len)); + DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len)); DBUG_DUMP("compressed", (char*)data, org_len); error= 2; @@ -5248,7 +5249,8 @@ static int packfrm(const void *data, uint len, *pack_len= blob_len; error= 0; - DBUG_PRINT("exit", ("pack_data: %x, pack_len: %d", *pack_data, *pack_len)); + DBUG_PRINT("exit", ("pack_data: 0x%lx pack_len: %u", (ulong) *pack_data, + *pack_len)); err: DBUG_RETURN(error); @@ -5262,13 +5264,13 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len, byte *data; ulong complen, orglen, ver; DBUG_ENTER("unpackfrm"); - DBUG_PRINT("enter", ("pack_data: %x", pack_data)); + DBUG_PRINT("enter", ("pack_data: 0x%lx", (ulong) pack_data)); complen= uint4korr((char*)&blob->head.complen); orglen= uint4korr((char*)&blob->head.orglen); ver= uint4korr((char*)&blob->head.ver); - DBUG_PRINT("blob",("ver: %d complen: %d orglen: %d", + DBUG_PRINT("blob",("ver: %lu complen: %lu orglen: %lu", ver,complen,orglen)); DBUG_DUMP("blob->data", (char*) blob->data, complen); @@ -5287,7 +5289,8 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len, *unpack_data= data; *unpack_len= complen; - DBUG_PRINT("exit", ("frmdata: %x, len: %d", *unpack_data, *unpack_len)); + DBUG_PRINT("exit", ("frmdata: 0x%lx len: %u", (ulong) *unpack_data, + *unpack_len)); DBUG_RETURN(0); } @@ -5367,7 +5370,8 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, * row_count= sum_rows; if(commit_count) * commit_count= sum_commits; - DBUG_PRINT("exit", ("records: %u commits: %u", sum_rows, sum_commits)); + DBUG_PRINT("exit", ("records: %u commits: %u", (uint) sum_rows, + (uint) sum_commits)); DBUG_RETURN(0); retry: diff --git a/sql/item.cc b/sql/item.cc index bf96fdf3f43..a43f9c092ec 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -649,6 +649,8 @@ bool agg_item_charsets(DTCollation &coll, const char *fname, doesn't display each argument's characteristics. - if nargs is 1, then this error cannot happen. */ + LINT_INIT(safe_args[0]); + LINT_INIT(safe_args[1]); if (nargs >=2 && nargs <= 3) { safe_args[0]= args[0]; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index ffb60754381..bd763ccec2f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1738,7 +1738,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; } @@ -1820,7 +1820,7 @@ cmp_item* cmp_item_row::make_same() cmp_item_row::~cmp_item_row() { DBUG_ENTER("~cmp_item_row"); - DBUG_PRINT("enter",("this: %lx", this)); + DBUG_PRINT("enter",("this: 0x%lx", (long) this)); if (comparators) { for (uint i= 0; i < n; i++) @@ -2413,7 +2413,7 @@ longlong Item_is_not_null_test::val_int() if (!used_tables_cache && !with_subselect) { owner->was_null|= (!cached_value); - DBUG_PRINT("info", ("cached :%d", cached_value)); + DBUG_PRINT("info", ("cached :%ld", (long) cached_value)); DBUG_RETURN(cached_value); } if (args[0]->is_null()) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index cdbcde8b56b..f17a2d2c8d3 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -54,7 +54,7 @@ void Item_subselect::init(st_select_lex *select_lex, { DBUG_ENTER("Item_subselect::init"); - DBUG_PRINT("subs", ("select_lex 0x%xl", (ulong) select_lex)); + DBUG_PRINT("subs", ("select_lex: 0x%lx", (ulong) select_lex)); unit= select_lex->master_unit(); if (unit->item) diff --git a/sql/log.cc b/sql/log.cc index b91ec2b3dee..0fc06653e00 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2255,8 +2255,8 @@ void MYSQL_LOG::report_pos_in_innodb() if (is_open() && have_innodb == SHOW_OPTION_YES) { DBUG_PRINT("info", ("Reporting binlog info into InnoDB - " - "name: '%s' position: %d", - log_file_name, my_b_tell(&log_file))); + "name: '%s' position: %lu", + log_file_name, (ulong) my_b_tell(&log_file))); innobase_store_binlog_offset_and_flush_log(log_file_name, my_b_tell(&log_file)); } diff --git a/sql/log_event.cc b/sql/log_event.cc index 412ebbce0ac..d02bb2a5483 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2043,8 +2043,8 @@ Rotate_log_event::Rotate_log_event(THD* thd_arg, #ifndef DBUG_OFF char buff[22]; DBUG_ENTER("Rotate_log_event::Rotate_log_event(THD*,...)"); - DBUG_PRINT("enter",("new_log_ident %s pos %s flags %lu", new_log_ident_arg, - llstr(pos_arg, buff), flags)); + DBUG_PRINT("enter",("new_log_ident: %s pos: %s flags: %u", + new_log_ident_arg, llstr(pos_arg, buff), flags)); #endif if (flags & DUP_NAME) new_log_ident= my_strdup_with_length((byte*) new_log_ident_arg, @@ -2673,7 +2673,7 @@ Slave_log_event::Slave_log_event(THD* thd_arg, memcpy(master_log, rli->group_master_log_name, master_log_len + 1); master_port = mi->port; master_pos = rli->group_master_log_pos; - DBUG_PRINT("info", ("master_log: %s pos: %d", master_log, + DBUG_PRINT("info", ("master_log: %s pos: %lu", master_log, (ulong) master_pos)); } else diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 20f20a0a86b..91e124743ce 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1443,7 +1443,7 @@ static void server_init(void) if (strlen(mysqld_unix_port) > (sizeof(UNIXaddr.sun_path) - 1)) { - sql_print_error("The socket file path is too long (> %lu): %s", + sql_print_error("The socket file path is too long (> %u): %s", sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port); unireg_abort(1); } @@ -3189,7 +3189,7 @@ int main(int argc, char **argv) { if (global_system_variables.log_warnings) sql_print_warning("Asked for %ld thread stack, but got %ld", - thread_stack, stack_size); + thread_stack, (long) stack_size); thread_stack= stack_size; } } @@ -3669,7 +3669,7 @@ static void create_new_thread(THD *thd) threads.append(thd); if (thread_count-delayed_insert_threads > max_used_connections) max_used_connections=thread_count-delayed_insert_threads; - DBUG_PRINT("info",(("creating thread %d"), thd->thread_id)); + DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id)); thd->connect_time = time(NULL); if ((error=pthread_create(&thd->real_id,&connection_attrib, handle_one_connection, @@ -4767,7 +4767,8 @@ master-ssl", (gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"merge", OPT_MERGE, "Enable Merge storage engine. Disable with \ --skip-merge.", - (gptr*) &opt_merge, (gptr*) &opt_merge, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0}, + (gptr*) &opt_merge, (gptr*) &opt_merge, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, + 0, 0}, {"myisam-recover", OPT_MYISAM_RECOVER, "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.", (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0, diff --git a/sql/net_serv.cc b/sql/net_serv.cc index a5a05d381cd..ead10fe7674 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -697,7 +697,7 @@ my_real_read(NET *net, ulong *complen) { my_bool interrupted = vio_should_retry(net->vio); - DBUG_PRINT("info",("vio_read returned %d, errno: %d", + DBUG_PRINT("info",("vio_read returned %ld errno: %d", length, vio_errno(net->vio))); #if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) /* diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 06e42ff363f..4ead85620cf 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -806,7 +806,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, double scan_time; DBUG_ENTER("test_quick_select"); DBUG_PRINT("enter",("keys_to_use: %lu prev_tables: %lu const_tables: %lu", - keys_to_use.to_ulonglong(), (ulong) prev_tables, + (ulong) keys_to_use.to_ulonglong(), (ulong) prev_tables, (ulong) const_tables)); delete quick; diff --git a/sql/slave.cc b/sql/slave.cc index 75b18f6f307..c18e457471f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2822,7 +2822,7 @@ server_errno=%d)", return packet_error; } - DBUG_PRINT("info",( "len=%u, net->read_pos[4] = %d\n", + DBUG_PRINT("info",( "len: %lu net->read_pos[4]: %d\n", len, mysql->net.read_pos[4])); return len - 1; } @@ -3743,7 +3743,7 @@ static int process_io_rotate(MASTER_INFO *mi, Rotate_log_event *rev) /* Safe copy as 'rev' has been "sanitized" in Rotate_log_event's ctor */ memcpy(mi->master_log_name, rev->new_log_ident, rev->ident_len+1); mi->master_log_pos= rev->pos; - DBUG_PRINT("info", ("master_log_pos: '%s' %d", + DBUG_PRINT("info", ("master_log_pos: '%s' %lu", mi->master_log_name, (ulong) mi->master_log_pos)); #ifndef DBUG_OFF /* @@ -3849,7 +3849,7 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, position in the master's log, we must use the original value. */ mi->master_log_pos += --event_len; - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); pthread_mutex_unlock(&mi->data_lock); my_free((char*)tmp_buf, MYF(0)); DBUG_RETURN(error); @@ -3870,7 +3870,7 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, } delete ev; mi->master_log_pos+= inc_pos; - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); pthread_mutex_unlock(&mi->data_lock); DBUG_RETURN(0); } @@ -3963,7 +3963,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) DBUG_ASSERT(rli->ign_master_log_name_end[0]); rli->ign_master_log_pos_end= mi->master_log_pos; rli->relay_log.signal_update(); // the slave SQL thread needs to re-check - DBUG_PRINT("info", ("master_log_pos: %d, event originating from the same server, ignored", (ulong) mi->master_log_pos)); + DBUG_PRINT("info", ("master_log_pos: %lu event originating from the same server, ignored", (ulong) mi->master_log_pos)); } else { @@ -3971,7 +3971,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) if (likely(!(error= rli->relay_log.appendv(buf,event_len,0)))) { mi->master_log_pos+= inc_pos; - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); rli->relay_log.harvest_bytes_written(&rli->log_space_total); } rli->ign_master_log_name_end[0]= 0; // last event is not ignored diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index fc03e03dee7..9f7807aabc7 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -383,7 +383,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; @@ -528,7 +528,8 @@ void Query_cache_query::init_n_lock() my_rwlock_init(&lock, NULL); lock_writing(); DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx", - ((byte*) this)-ALIGN_SIZE(sizeof(Query_cache_block)))); + (long) ((byte*) this) - + ALIGN_SIZE(sizeof(Query_cache_block)))); DBUG_VOID_RETURN; } @@ -537,7 +538,8 @@ void Query_cache_query::unlock_n_destroy() { DBUG_ENTER("Query_cache_query::unlock_n_destroy"); DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx", - ((byte*)this)-ALIGN_SIZE(sizeof(Query_cache_block)))); + (long) ((byte*) this) - + ALIGN_SIZE(sizeof(Query_cache_block)))); /* The following call is not needed on system where one can destroy an active semaphore @@ -1140,7 +1142,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) #ifndef EMBEDDED_LIBRARY do { - DBUG_PRINT("qcache", ("Results (len %lu, used %lu, headers %lu)", + DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %u)", result_block->length, result_block->used, result_block->headers_len()+ ALIGN_SIZE(sizeof(Query_cache_result)))); @@ -1832,8 +1834,8 @@ Query_cache::append_result_data(Query_cache_block **current_block, Query_cache_block *query_block) { DBUG_ENTER("Query_cache::append_result_data"); - DBUG_PRINT("qcache", ("append %lu bytes to 0x%lx query", - data_len, query_block)); + DBUG_PRINT("qcache", ("append: %lu bytes to: 0x%lx query", + data_len, (ulong) query_block)); if (query_block->query()->add(data_len) > query_cache_limit) { @@ -3336,10 +3338,10 @@ 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, flags.time_zone->get_name(), + (ulong)flags.limit, flags.time_zone->get_name()->ptr(), len, str, strend(str)+1)); DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block, (ulong) block->next, (ulong) block->prev, @@ -3569,7 +3571,7 @@ my_bool Query_cache::check_integrity(bool not_locked) default: DBUG_PRINT("error", ("block 0x%lx have incorrect type %u", - block, block->type)); + (ulong) block, block->type)); result = 1; } @@ -3668,7 +3670,7 @@ my_bool Query_cache::check_integrity(bool not_locked) if (count != bins[i].number) { DBUG_PRINT("error", ("bin[%d].number is %d, but bin have %d blocks", - bins[i].number, count)); + i, bins[i].number, count)); result = 1; } } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c8d90848f6e..fc20d7b38e1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -156,9 +156,8 @@ bool foreign_key_prefix(Key *a, Key *b) THD::THD() :user_time(0), global_read_lock(0), is_fatal_error(0), - last_insert_id_used(0), - insert_id_used(0), rand_used(0), time_zone_used(0), - in_lock_tables(0), bootstrap(0) + rand_used(0), last_insert_id_used(0), insert_id_used(0), + time_zone_used(0), in_lock_tables(0), bootstrap(0) { current_arena= this; host= user= priv_user= db= ip=0; @@ -616,7 +615,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 %u %u", key_length, (*prev_changed)->key_length)); + ("key_length: %ld %u", key_length, + (*prev_changed)->key_length)); DBUG_VOID_RETURN; } else if (cmp == 0) @@ -626,7 +626,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 %u %u", key_length, + ("key_length: %ld %u", key_length, (*prev_changed)->key_length)); DBUG_VOID_RETURN; } @@ -638,7 +638,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 %u %u", key_length, + DBUG_PRINT("info", ("key_length: %ld %u", key_length, (*prev_changed)->key_length)); DBUG_VOID_RETURN; } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index b84b2f7eef4..3aa37a9935d 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -272,7 +272,7 @@ cleanup: else { send_ok(thd,deleted); - DBUG_PRINT("info",("%d records deleted",deleted)); + DBUG_PRINT("info",("%lu records deleted", (ulong) deleted)); } DBUG_RETURN(0); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 66b68cfc2f1..8f735641e55 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -306,9 +306,9 @@ int check_user(THD *thd, enum enum_server_command command, if (!(thd->master_access & NO_ACCESS)) // authentification is OK { DBUG_PRINT("info", - ("Capabilities: %d packet_length: %ld Host: '%s' " + ("Capabilities: %lu packet_length: %ld Host: '%s' " "Login user: '%s' Priv_user: '%s' Using password: %s " - "Access: %u db: '%s'", + "Access: %lu db: '%s'", thd->client_capabilities, thd->max_client_packet_length, thd->host_or_ip, thd->user, thd->priv_user, passwd_len ? "yes": "no", @@ -857,7 +857,7 @@ static int check_connection(THD *thd) if (thd->client_capabilities & CLIENT_IGNORE_SPACE) thd->variables.sql_mode|= MODE_IGNORE_SPACE; #ifdef HAVE_OPENSSL - DBUG_PRINT("info", ("client capabilities: %d", thd->client_capabilities)); + DBUG_PRINT("info", ("client capabilities: %lu", thd->client_capabilities)); if (thd->client_capabilities & CLIENT_SSL) { /* Do the SSL layering. */ @@ -1003,7 +1003,7 @@ pthread_handler_decl(handle_one_connection,arg) of handle_one_connection, which is thd. We need to know the start of the stack so that we could check for stack overruns. */ - DBUG_PRINT("info", ("handle_one_connection called by thread %d\n", + DBUG_PRINT("info", ("handle_one_connection called by thread %lu\n", thd->thread_id)); // now that we've called my_thread_init(), it is safe to call DBUG_* diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index b5aed0bbc4e..9b6d6bdd92e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1394,7 +1394,7 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) enum enum_sql_command sql_command= lex->sql_command; int res= 0; DBUG_ENTER("send_prepare_results"); - DBUG_PRINT("enter",("command: %d, param_count: %ld", + DBUG_PRINT("enter",("command: %d param_count: %u", sql_command, stmt->param_count)); if ((&lex->select_lex != lex->all_selects_list || diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index f83313a8fd8..9d35d822b8e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1017,7 +1017,7 @@ int change_master(THD* thd, MASTER_INFO* mi) { mi->master_log_pos= lex_mi->pos; } - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); if (lex_mi->host) strmake(mi->host, lex_mi->host, sizeof(mi->host)-1); @@ -1129,7 +1129,7 @@ int change_master(THD* thd, MASTER_INFO* mi) } } mi->rli.group_master_log_pos = mi->master_log_pos; - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos)); /* Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index af3ad782ee3..b4d9749911a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6052,6 +6052,7 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) JOIN_TAB *join_tab; int (*end_select)(JOIN *, struct st_join_table *,bool); DBUG_ENTER("do_select"); + LINT_INIT(join_tab); List *columns_list= procedure ? &join->procedure_fields_list : fields; join->procedure=procedure; /* diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0316d6a3c10..3e9323ec086 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2711,7 +2711,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, enum enum_duplicates handle_duplicates, bool ignore) { TABLE *table,*new_table; - int error; + int error= 0; char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; char index_file[FN_REFLEN], data_file[FN_REFLEN]; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 7ed1b48d7aa..fcce3ad64b3 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -407,7 +407,7 @@ int mysql_update(THD *thd, send_ok(thd, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, thd->insert_id_used ? thd->last_insert_id : 0L,buff); - DBUG_PRINT("info",("%d records updated",updated)); + DBUG_PRINT("info",("%lu records updated", (ulong) updated)); } thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */ free_io_cache(table); @@ -495,7 +495,7 @@ static table_map get_table_map(List *items) while ((item= (Item_field *) item_it++)) map|= item->used_tables(); - DBUG_PRINT("info",("table_map: 0x%08x", map)); + DBUG_PRINT("info",("table_map: 0x%08lx", (long) map)); return map; } diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 81aca092cec..1b718e511ad 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -150,7 +150,7 @@ uint find_type2(TYPELIB *typelib, const char *x, uint length, CHARSET_INFO *cs) int find,pos; const char *j; DBUG_ENTER("find_type2"); - DBUG_PRINT("enter",("x: '%s' lib: 0x%lx",x,typelib)); + DBUG_PRINT("enter",("x: '%s' lib: 0x%lx",x, (long) typelib)); if (!typelib->count) { diff --git a/sql/table.cc b/sql/table.cc index a85da8395e7..c1d43af2eec 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -87,7 +87,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, SQL_CRYPT *crypted=0; MEM_ROOT **root_ptr, *old_root; DBUG_ENTER("openfrm"); - DBUG_PRINT("enter",("name: '%s' form: %lx",name,outparam)); + DBUG_PRINT("enter",("name: '%s' form: 0x%lx", name, (ulong) outparam)); bzero((char*) outparam,sizeof(*outparam)); outparam->blob_ptr_size=sizeof(char*); diff --git a/sql/tztime.cc b/sql/tztime.cc index 9af33526c98..bfbc1ae0b30 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -948,8 +948,8 @@ TIME_to_gmt_sec(const TIME *t, const TIME_ZONE_INFO *sp, bool *in_dst_time_gap) */ if (shift) { - if (local_t > (TIMESTAMP_MAX_VALUE - shift*86400L + - sp->revtis[i].rt_offset - saved_seconds)) + if (local_t > (my_time_t) (TIMESTAMP_MAX_VALUE - shift*86400L + + sp->revtis[i].rt_offset - saved_seconds)) { DBUG_RETURN(0); /* my_time_t overflow */ } diff --git a/sql/unireg.cc b/sql/unireg.cc index e5ee0222f20..c9c39f38842 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -358,14 +358,14 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo, key_parts+=key->key_parts; DBUG_PRINT("loop",("flags: %d key_parts: %d at %lx", key->flags,key->key_parts, - key->key_part)); + (long) key->key_part)); for (key_part=key->key_part,key_part_end=key_part+key->key_parts ; key_part != key_part_end ; key_part++) { uint offset; - DBUG_PRINT("loop",("field: %d startpos: %lu length: %ld", + DBUG_PRINT("loop",("field: %d startpos: %lu length: %d", key_part->fieldnr, key_part->offset + data_offset, key_part->length)); int2store(pos,key_part->fieldnr+1+FIELD_NAME_USED); diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp new file mode 100644 index 00000000000..b18c925dae1 --- /dev/null +++ b/support-files/compiler_warnings.supp @@ -0,0 +1,56 @@ +# +# cmd-line-utils is not important in 4.1 +# +.*/cmd-line-utils/readline/* : .*comparison is always true.* +.*/cmd-line-utils/readline/* : .*discards qualifiers from pointer target type.* +.*/cmd-line-utils/readline/* : .*may be used uninitialized in this.* + +# +# not important in 4.1 +# +my_tempnam.c: .*the use of `tempnam' is dangerous, better use `mkstemp'.* + +# +# bdb is not critical to keep up to date +# +.*/bdb/.* : .*discards qualifiers from pointer target type.* +.*/bdb/.* : .*unused parameter.* +.*/bdb/.* : .*may be used uninitialized.* +.*/bdb/.* : .*empty body in an if-statement.* +db_vrfy.c : .*comparison is always false due to limited range of data type.* + +# +# Ignore all conversion warnings on windows 64 +# (Is safe as we are not yet supporting strings >= 2G) +# +.* : conversion from '__int64' to .*int'.* +.* : conversion from '__int64' to 'uint8'.* +.* : conversion from '__int64' to 'uint32'.* +.* : conversion from '__int64' to 'u.*long'.* +.* : conversion from '__int64' to 'long'.* +.* : conversion from '__int64' to 'off_t'.* +.* : conversion from '.*size_t' to .*int'.* +.* : conversion from '.*size_t' to 'TaoCrypt::word32'.* +.* : conversion from '.*size_t' to 'u.*long'.* +.* : conversion from '.*size_t' to 'uint32'.* +.* : conversion from '.*size_t' to 'off_t'.* +.* : conversion from '.*size_t' to 'size_s'.* + +# +# innobase is not critical in 4.1 to be kept up-to-date +# +.*/innobase/.* : .*unused parameter.* +.*/innobase/.* : .*may be used uninitialized in.* + +# +# The following should be fixed by the ndb team +# +.*/ndb/.* : .*used uninitialized in this function.* +.*/ndb/.* : .*unused variable.* +.*/ndb/.* : .*defined but not used.* +.*/ndb/.* : .*format.*expects type.* +.*/ndb/.* : .*has virtual functions but non-virtual destructor.* +.*/ndb/.* : .*comparison between signed and unsigned integer expressions.* +.*/ndb/.* : .*deprecated conversion from string constant to.* +.*/ndb/.* : .*enumeration value.*not handled in switch.* +.*/ndb/.* : .*enumeral and non-enumeral type in conditional expression.* diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 98d7182d46f..fb2dc879c28 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -767,6 +767,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count) /* Utility function to execute a query using prepare-execute */ +#ifndef EMBEDDED_LIBRARY static void execute_prepare_query(const char *query, ulonglong exp_count) { MYSQL_STMT *stmt; @@ -787,7 +788,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) DIE_UNLESS(affected_rows == exp_count); mysql_stmt_close(stmt); } - +#endif /* Store result processing */ @@ -11716,6 +11717,7 @@ static void test_bug12001() DIE_UNLESS(res==1); } +#ifndef EMBEDDED_LIBRARY static void test_bug12744() { MYSQL_STMT *prep_stmt = NULL; @@ -11746,6 +11748,7 @@ static void test_bug12744() } rc= mysql_stmt_close(prep_stmt); } +#endif /* Bug#11718: query with function, join and order by returns wrong type From e2e06e3abe52aa1ec7432522d82ec1d0b2b1959e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Mar 2007 20:55:59 +0200 Subject: [PATCH 06/83] Bug#27171 mysqlbinlog produces different output depends from option -R Server starts any binlog dump from Format_description_log_event, this shifted all offset calculations in mysqlbinlog and made it to stop the dump earlier than --stop-position. Now mysqlbinlog takes Format_description_log_event into account mysql-test/r/mysqlbinlog2.result: Bug#27171 mysqlbinlog produces different output depends from option -R mysql-test/t/mysqlbinlog2.test: Bug#27171 mysqlbinlog produces different output depends from option -R --- client/mysqlbinlog.cc | 15 +++++++++---- mysql-test/r/mysqlbinlog2.result | 36 ++++++++++++++++++++++++++++++++ mysql-test/t/mysqlbinlog2.test | 8 +++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 7489cdb334c..d8ea3d5f255 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1040,7 +1040,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, uint logname_len; NET* net; int error= 0; - my_off_t old_off= start_position_mot; + my_off_t old_off= min(start_position_mot, BIN_LOG_HEADER_SIZE); char fname[FN_REFLEN+1]; DBUG_ENTER("dump_remote_log_entries"); @@ -1192,10 +1192,17 @@ 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. + + Exception - the server sends Format_description_log_event + in the beginning of the dump, and only after it the event from + start_position. Let the old_off reflect it. */ - old_off+= len-1; + if (old_off < start_position_mot) + old_off= start_position_mot; + else + old_off+= len-1; } err: diff --git a/mysql-test/r/mysqlbinlog2.result b/mysql-test/r/mysqlbinlog2.result index 51ca19654c7..03b0e16d32a 100644 --- a/mysql-test/r/mysqlbinlog2.result +++ b/mysql-test/r/mysqlbinlog2.result @@ -122,6 +122,24 @@ 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")/*!*/; +SET INSERT_ID=5/*!*/; +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*/; @@ -481,6 +499,24 @@ 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")/*!*/; +SET INSERT_ID=5/*!*/; +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/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index 6afae538f04..14b213cd9cc 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -55,6 +55,10 @@ select "--- stop-position --" as ""; --enable_query_log --exec $MYSQL_BINLOG --short-form --stop-position=600 $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=600 --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 @@ -111,6 +115,10 @@ select "--- stop-position --" as ""; --enable_query_log --exec $MYSQL_BINLOG --short-form --stop-position=600 --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=600 --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 From bd49d8debfc1821cb9d158efb9cdfc55231e54ee Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Mar 2007 14:12:11 +0300 Subject: [PATCH 07/83] Fix for BUG#9504: Stored procedures: execute privilege doesn't make 'use database' okay. The problem was that we didn't check stored-routine privileges in check_grant_db(). The patch adds this check. mysql-test/r/grant.result: Update result file. mysql-test/r/sp-security.result: Update result fil. mysql-test/t/grant.test: Added test case for BUG#9504. mysql-test/t/sp-security.test: Update test. sql/sql_acl.cc: Check stored routines privileges. --- mysql-test/r/grant.result | 47 +++++++++++++++++++ mysql-test/r/sp-security.result | 35 ++++++++++---- mysql-test/t/grant.test | 83 +++++++++++++++++++++++++++++++++ mysql-test/t/sp-security.test | 77 ++++++++++++++++++------------ sql/sql_acl.cc | 31 +++++++++++- 5 files changed, 233 insertions(+), 40 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index d63e4181026..73d5bf94264 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -972,4 +972,51 @@ REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij123456789 ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) 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; End of 5.0 tests diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result index 26b3f352a1f..8462bafe0e3 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/t/grant.test b/mysql-test/t/grant.test index 82bf011d32f..92ed69d3f4b 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -875,4 +875,87 @@ 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; + + --echo End of 5.0 tests diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index a5d509f29b7..38c72fd4fa6 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/sql/sql_acl.cc b/sql/sql_acl.cc index ee15f95f305..ebf9385d177 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3893,6 +3893,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 @@ -3904,9 +3924,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++) @@ -3917,11 +3938,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; } From 4a76ac5fa6e844c78ec565c2e15ac88f0bb9a8a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Mar 2007 17:12:58 +0200 Subject: [PATCH 08/83] Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit was not restored at the end of SF() invocation, where SF() modified non-ta table. As the result of this artifact it was not possible to detect whether there were any side-effects when top-level query ends. If the top level query table was not modified and the bit is lost there would be no binlogging. Fixed with preserving the bit inside of thd->no_trans_update struct. The struct agregates two bool flags telling whether the current query and the current transaction modified any non-ta table. The flags stmt, all are dropped at the end of the query and the transaction. mysql-test/r/sp_trans.result: results will be changed once again after bug#23333 will be fixed. mysql-test/t/sp_trans.test: regression test added sql/ha_ndbcluster.cc: replacing thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit and bool thd->no_trans_update with thd->no_trans_update as struct sql/handler.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/log.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/set_var.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sp_head.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_class.h: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_delete.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_insert.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_load.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_parse.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_table.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. sql/sql_update.cc: replacing operations with thd->options' OPTION_STATUS_NO_TRANS_UPDATE bit with the member thd->no_trans_update.all; converting thd->no_trans_update into struct of bools. --- mysql-test/r/sp_trans.result | 32 ++++++++++++++++++++++++ mysql-test/t/sp_trans.test | 30 ++++++++++++++++++++++ sql/ha_ndbcluster.cc | 3 +-- sql/handler.cc | 2 +- sql/log.cc | 4 +-- sql/set_var.cc | 5 ++-- sql/sp_head.cc | 6 ++--- sql/sql_class.h | 8 ++++-- sql/sql_delete.cc | 4 +-- sql/sql_insert.cc | 18 +++++++------- sql/sql_load.cc | 16 ++++++------ sql/sql_parse.cc | 31 +++++++++++++---------- sql/sql_table.cc | 2 +- sql/sql_update.cc | 48 ++++++++++++++++++------------------ 14 files changed, 140 insertions(+), 69 deletions(-) diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index 564e31c9e32..513bbc43ce3 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -530,3 +530,35 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| +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| +reset master| +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| +insert into t2 values (bug23333(),1)| +ERROR 23000: Duplicate entry '1' for key 1 +show binlog events /* must show the insert */| +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 4 Format_desc 1 98 Server ver: 5.0.40-debug-log, Binlog ver: 4 +master-bin.000001 98 Query 1 90 use `test`; insert into t2 values (1,1) +master-bin.000001 188 Xid 1 215 COMMIT /* xid=1165 */ +master-bin.000001 215 Query 1 446 use `test`; CREATE DEFINER=`root`@`localhost` function bug23333() +RETURNS int(11) +DETERMINISTIC +begin +insert into t1 values (null); +select count(*) from t1 into @a; +return @a; +end +select count(*),@a from t1 /* must be 1,1 */| +count(*) @a +1 1 diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index 1ea32316f1e..579af44f28d 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -553,6 +553,36 @@ drop procedure bug14210| set @@session.max_heap_table_size=default| +# +# 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| + +reset master| +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| + +--error ER_DUP_ENTRY +insert into t2 values (bug23333(),1)| +show binlog events /* must show the insert */| +select count(*),@a from t1 /* must be 1,1 */| + # # BUG#NNNN: New bug synopsis # diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7a9c7d0d021..10567ca2d70 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3636,8 +3636,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= {TRUE, TRUE}; } else if (!thd->transaction.on) m_transaction_on= FALSE; diff --git a/sql/handler.cc b/sql/handler.cc index 5a27e470d70..076c6628fa0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -830,7 +830,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) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, diff --git a/sql/log.cc b/sql/log.cc index 7d0bef5ca2c..a0068dce1c5 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -162,7 +162,7 @@ static int binlog_rollback(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)) + if (unlikely(thd->no_trans_update.all)) { Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE); qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) @@ -217,7 +217,7 @@ static int binlog_savepoint_rollback(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)) + if (unlikely(thd->no_trans_update.all)) { Query_log_event qinfo(thd, thd->query, thd->query_length, TRUE, FALSE); DBUG_RETURN(mysql_bin_log.write(&qinfo)); diff --git a/sql/set_var.cc b/sql/set_var.cc index 46c2a775d8a..ca5b6471bec 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2873,14 +2873,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&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); + thd->options&= ~(ulong) OPTION_BEGIN; + thd->no_trans_update.all= FALSE; thd->server_status|= SERVER_STATUS_AUTOCOMMIT; if (ha_commit(thd)) return 1; } else { - thd->options&= ~(ulong) (OPTION_STATUS_NO_TRANS_UPDATE); + thd->no_trans_update.all= FALSE; thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT; } } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 4cb56e003ee..50945f43c1a 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -337,13 +337,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. */ @@ -351,7 +351,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) { diff --git a/sql/sql_class.h b/sql/sql_class.h index 99803802001..12d7cb2368f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1440,7 +1440,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 */ @@ -1664,7 +1668,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_delete.cc b/sql/sql_delete.cc index fe89f0f28f0..8cf07f328bf 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -311,7 +311,7 @@ cleanup: error=1; } 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) @@ -791,7 +791,7 @@ bool multi_delete::send_eof() local_error=1; // Log write failed: roll back the SQL statement } 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) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d9d32d14321..e586779a431 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -584,7 +584,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (lock_type != TL_WRITE_DELAYED && !thd->prelocked_mode) table->file->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))); @@ -731,7 +731,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, error=1; } if (!transactional_table) - thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; + thd->no_trans_update.all= TRUE; } } if (transactional_table) @@ -1129,7 +1129,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 @@ -1295,7 +1295,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)) @@ -1327,7 +1327,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: @@ -2518,7 +2518,7 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); } - 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 | @@ -2676,7 +2676,7 @@ void select_insert::send_error(uint errcode,const char *err) mysql_bin_log.write(&qinfo); } if (!table->s->tmp_table) - thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; + thd->no_trans_update.all= TRUE; } if (info.copied || info.deleted || info.updated) { @@ -2705,7 +2705,7 @@ bool select_insert::send_eof() { query_cache_invalidate3(thd, table, 1); if (!(table->file->has_transactions() || table->s->tmp_table)) - thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; + thd->no_trans_update.all= TRUE; } if (last_insert_id) @@ -2931,7 +2931,7 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) } if (!thd->prelocked_mode) table->file->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_load.cc b/sql/sql_load.cc index 3f67a0c3f5d..8848c2c5e5b 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -377,7 +377,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, table->file->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 | @@ -467,7 +467,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()) { @@ -531,7 +531,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; + bool no_trans_update_stmt; DBUG_ENTER("read_fixed_length"); id= 0; @@ -559,7 +559,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); /* @@ -627,7 +627,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, if (write_record(thd, table, &info)) DBUG_RETURN(1); - thd->no_trans_update= no_trans_update; + thd->no_trans_update.stmt= no_trans_update_stmt; /* If auto_increment values are used, save the first one for @@ -670,12 +670,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; + bool no_trans_update_stmt; 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()) { @@ -817,7 +817,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 1b8bfd38fc4..52b17c23b92 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -147,7 +147,8 @@ static bool end_active_trans(THD *thd) thd->server_status&= ~SERVER_STATUS_IN_TRANS; if (ha_commit(thd)) error=1; - thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); + thd->options&= ~(ulong) OPTION_BEGIN; + thd->no_trans_update.all= FALSE; } DBUG_RETURN(error); } @@ -171,8 +172,8 @@ static bool begin_trans(THD *thd) else { LEX *lex= thd->lex; - thd->options= ((thd->options & (ulong) ~(OPTION_STATUS_NO_TRANS_UPDATE)) | - OPTION_BEGIN); + thd->no_trans_update.all= FALSE; + thd->options|= (ulong) OPTION_BEGIN; thd->server_status|= SERVER_STATUS_IN_TRANS; if (lex->start_transaction_opt & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT) error= ha_start_consistent_snapshot(thd); @@ -1463,7 +1464,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); + thd->options&= ~(ulong) OPTION_BEGIN; + thd->no_trans_update.all= FALSE; break; case COMMIT_RELEASE: do_release= 1; /* fall through */ @@ -1480,7 +1482,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); + thd->options&= ~(ulong) OPTION_BEGIN; + thd->no_trans_update.all= FALSE; if (!res && (completion == ROLLBACK_AND_CHAIN)) res= begin_trans(thd); break; @@ -2933,7 +2936,7 @@ mysql_execute_command(THD *thd) else { /* So that CREATE TEMPORARY TABLE gets to binlog at commit/rollback */ - thd->options|= OPTION_STATUS_NO_TRANS_UPDATE; + thd->no_trans_update.all= TRUE; } DBUG_ASSERT(first_table == all_tables && first_table != 0); bool link_to_local; @@ -3707,10 +3710,10 @@ 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_STATUS_NO_TRANS_UPDATE; + thd->no_trans_update.all= TRUE; } /* DDL and binlog write order protected by LOCK_open */ res= mysql_rm_table(thd, first_table, lex->drop_if_exists, @@ -4296,7 +4299,7 @@ end_with_restore_list: res= TRUE; // cannot happen else { - if ((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) && + if (thd->no_trans_update.all && !thd->slave_thread) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, @@ -4939,8 +4942,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 & (ulong) ~(OPTION_STATUS_NO_TRANS_UPDATE)) | - OPTION_BEGIN); + thd->no_trans_update.all= FALSE; + thd->options|= (ulong) OPTION_BEGIN; thd->server_status|= SERVER_STATUS_IN_TRANS; send_ok(thd); break; @@ -5033,7 +5036,8 @@ create_sp_error: xa_state_names[thd->transaction.xid_state.xa_state]); break; } - thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); + thd->options&= ~(ulong) OPTION_BEGIN; + 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; @@ -5063,7 +5067,8 @@ create_sp_error: my_error(ER_XAER_RMERR, MYF(0)); else send_ok(thd); - thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); + thd->options&= ~(ulong) OPTION_BEGIN; + 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; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 14b9e0aa25d..98b12cc1de4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3968,7 +3968,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_update.cc b/sql/sql_update.cc index 27d38114885..860d00b5bdd 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -429,7 +429,7 @@ int mysql_update(THD *thd, query_id=thd->query_id; 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 | @@ -452,7 +452,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++; @@ -470,12 +470,12 @@ int mysql_update(THD *thd, break; } } - if (!(error=table->file->update_row((byte*) table->record[1], - (byte*) table->record[0]))) - { - updated++; - thd->no_trans_update= !transactional_table; - + if (!(error=table->file->update_row((byte*) table->record[1], + (byte*) table->record[0]))) + { + updated++; + thd->no_trans_update.stmt= !transactional_table; + if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_AFTER, TRUE)) @@ -483,25 +483,25 @@ int mysql_update(THD *thd, error= 1; break; } - } - else if (!ignore || error != HA_ERR_FOUND_DUPP_KEY) - { + } + else if (!ignore || error != HA_ERR_FOUND_DUPP_KEY) + { /* If (ignore && error == HA_ERR_FOUND_DUPP_KEY) we don't have to do anything; otherwise... */ if (error != HA_ERR_FOUND_DUPP_KEY) thd->fatal_error(); /* Other handler errors are fatal */ - table->file->print_error(error,MYF(0)); - error= 1; - break; - } + table->file->print_error(error,MYF(0)); + error= 1; + break; + } } - + if (!--limit && using_limit) { - error= -1; // Simulate end of file - break; + error= -1; // Simulate end of file + break; } } else @@ -546,7 +546,7 @@ int mysql_update(THD *thd, 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) @@ -910,7 +910,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)); @@ -1224,7 +1224,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; } @@ -1311,7 +1311,7 @@ bool multi_update::send_data(List ¬_used_values) 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)) @@ -1541,10 +1541,10 @@ bool multi_update::send_eof() Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_tables, FALSE); if (mysql_bin_log.write(&qinfo) && trans_safe) - local_error= 1; // Rollback update + local_error= 1; // Rollback update } if (!transactional_tables) - thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; + thd->no_trans_update.all= TRUE; } if (transactional_tables) From b765a8af9bb0417a8bbb12cef44014de9badd938 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Mar 2007 19:24:03 +0100 Subject: [PATCH 09/83] Bug #26817: mysqldump fails to backup database containing view with invalid definer give some leeway on required permissions for SHOW FIELDS on views so an unknonwn DEFINER will no longer break mysqldump client/client_priv.h: Bug #26817: mysqldump fails to backup database containing view with invalid definer New option for mysqldump: redirect stderr to file ("2> for Windows") client/mysqldump.c: Bug #26817: mysqldump fails to backup database containing view with invalid definer New option for mysqldump: redirect stderr to file ("2> for Windows") mysql-test/r/information_schema_db.result: Bug #26817: mysqldump fails to backup database containing view with invalid definer New option for mysqldump: redirect stderr to file ("2> for Windows") mysql-test/t/information_schema_db.test: Bug #26817: mysqldump fails to backup database containing view with invalid definer New option for mysqldump: redirect stderr to file ("2> for Windows") sql/sql_base.cc: Bug #26817: mysqldump fails to backup database containing view with invalid definer be a little more lenient for SHOW FIELDS FROM sql/sql_parse.cc: Bug #26817: mysqldump fails to backup database containing view with invalid definer be a little more lenient for SHOW FIELDS FROM on views on views sql/sql_view.cc: Bug #26817: mysqldump fails to backup database containing view with invalid definer give SHOW FIELDS the same perks as SHOW CREATE sql/table.cc: Bug #26817: mysqldump fails to backup database containing view with invalid definer give SHOW FIELDS the same perks as SHOW CREATE --- client/client_priv.h | 2 +- client/mysqldump.c | 24 +++++++- mysql-test/r/information_schema_db.result | 71 ++++++++++++++++++++++- mysql-test/t/information_schema_db.test | 55 +++++++++++++++++- sql/sql_base.cc | 27 ++++++++- sql/sql_parse.cc | 5 +- sql/sql_view.cc | 7 ++- sql/table.cc | 5 +- 8 files changed, 182 insertions(+), 14 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 7748dc612d6..418bf86f2c8 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -51,5 +51,5 @@ enum options_client OPT_TRIGGERS, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT, - OPT_DEBUG_INFO + OPT_DEBUG_INFO, OPT_ERROR_LOG_FILE }; diff --git a/client/mysqldump.c b/client/mysqldump.c index 94ab9dac5ac..0d7c0c3a0bf 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -105,7 +105,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; @@ -116,7 +117,9 @@ static my_string opt_mysql_unix_port=0; static int first_error=0; static DYNAMIC_STRING extended_row; #include -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 @@ -293,6 +296,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" @@ -3694,6 +3700,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); @@ -3746,5 +3762,9 @@ err: if (!path) write_footer(md_result_file); free_resources(); + + if (stderror_file) + fclose(stderror_file); + return(first_error); } /* main */ diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index 47efe1d17ad..2d330dda333 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -106,16 +106,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 @@ -140,7 +206,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/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/sql/sql_base.cc b/sql/sql_base.cc index 77bb1d9642b..1693c98bab7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3573,14 +3573,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, + cur_field->table, + &my_charset_bin); + cur_field= nf; + } + } /* Store the original table of the field, which may be different from @@ -3603,7 +3624,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; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1b8bfd38fc4..40914339cf1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5159,7 +5159,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, 0)) + if (grant_option && + !(all_tables->belong_to_view && + (thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) && + check_grant(thd, privilege, all_tables, 0, 1, 0)) goto deny; thd->security_ctx= backup_ctx; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 7143df8474a..32231a93ef7 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1003,6 +1003,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; } @@ -1028,7 +1033,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/table.cc b/sql/table.cc index 960534bf7d4..6d13514e782 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2085,7 +2085,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) @@ -2441,7 +2441,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, From 212ecf348cbb43f71cfd14a51ca19b7ef987859f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Mar 2007 22:08:31 +0200 Subject: [PATCH 10/83] Removed not used define YY_MAGIC_BELOW Made year 2000 handling more uniform Removed year 2000 handling out from calc_days() The above removes some bugs in date/datetimes with year between 0 and 200 Now we get a note when we insert a datetime value into a date column For default values to CREATE, don't give errors for warning level NOTE Fixed some compiler failures Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support) Removed duplicate typedef TIME and replaced it with MYSQL_TIME Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE" Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value" Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)" include/my_time.h: Removed not used define YY_MAGIC_BELOW Added prototype for year_2000_handling() mysql-test/r/date_formats.result: Updated results (fixed bug in date_format() with year < 99) mysql-test/r/func_sapdb.result: Added more testing of make_date() mysql-test/r/func_time.result: Fixed bug in date_sub() with years < 200 mysql-test/r/ps_2myisam.result: Now we get a note when we insert a datetime value into a date column mysql-test/r/ps_3innodb.result: Now we get a note when we insert a datetime value into a date column mysql-test/r/ps_4heap.result: Now we get a note when we insert a datetime value into a date column mysql-test/r/ps_5merge.result: Now we get a note when we insert a datetime value into a date column mysql-test/r/ps_7ndb.result: Now we get a note when we insert a datetime value into a date column mysql-test/r/type_date.result: Added test for date conversions mysql-test/r/type_datetime.result: Added testcase for datetime to date conversion. mysql-test/t/date_formats.test: Added testing of dates < 200 mysql-test/t/func_sapdb.test: More testing of makedate() mysql-test/t/type_date.test: Added test for date conversions mysql-test/t/type_datetime.test: Added testcase for datetime to date conversion. sql/CMakeLists.txt: Added library ws2_32 (needed if we want to compile with IOCP support) sql/event_data_objects.cc: TIME -> MYSQL_TIME sql/event_db_repository.cc: TIME -> MYSQL_TIME sql/event_queue.cc: TIME -> MYSQL_TIME sql/field.cc: Give note if we insert a datetime value in a date field Don't give notes if we are doing internal test conversions (like from convert_constant_item()) More documentation (store functions can now return '3' to inform that the function did return a NOTE (not warning or error)) Revert some changes in Field_newdate::store() to get more optimal code Field::set_warning() will now ignore notes if CHECK_FIELD_IGNORE is set. New parameters to make_truncated_value_warning() sql/field.h: TIME -> MYSQL_TIME sql/item.cc: New parameters to make_truncated_value_warning() Fixed get_date() to call number_to_datetime() if argument is not a string. Fixes Bug#23093 Implicit conversion of 9912101 to date does not match cast(9912101 as date) sql/item.h: TIME -> MYSQL_TIME sql/item_cmpfunc.cc: Don't print notes in convert_constant_item() sql/item_func.h: TIME -> MYSQL_TIME sql/item_timefunc.cc: New parameters to make_truncated_value_warning() Moved year 2000 handling out from calc_days() Don't return NULL for years < 200 in date_add/date_sub sql/item_timefunc.h: TIME -> MYSQL_TIME sql/my_decimal.cc: TIME -> MYSQL_TIME sql/my_decimal.h: TIME -> MYSQL_TIME sql/mysql_priv.h: Added error level to make_truncated_value_warning() sql/protocol.cc: TIME -> MYSQL_TIME sql/protocol.h: TIME -> MYSQL_TIME sql/sp.cc: TIME -> MYSQL_TIME sql/sql_base.cc: Make testing of result value of save_in_field() uniform sql-common/my_time.c: Added year_2000_handling() Removed year 2000 handling from calc_daynr() sql/sql_class.h: TIME -> MYSQL_TIME sql/sql_show.cc: TIME -> MYSQL_TIME sql/structs.h: TIME -> MYSQL_TIME sql/time.cc: Added error level to make_truncated_value_warning() sql/tztime.cc: TIME -> MYSQL_TIME sql/tztime.h: TIME -> MYSQL_TIME sql/unireg.cc: For default values to CREATE, don't give errors for warning level NOTE (Fixed failed CREATE when we give a datetime value to a date field) strings/ctype-utf8.c: Fixed compiler failures win/README: More comments --- include/my_time.h | 3 +- mysql-test/r/date_formats.result | 18 ++- mysql-test/r/func_sapdb.result | 6 + mysql-test/r/func_time.result | 10 +- mysql-test/r/ps_2myisam.result | 19 ++- mysql-test/r/ps_3innodb.result | 19 ++- mysql-test/r/ps_4heap.result | 19 ++- mysql-test/r/ps_5merge.result | 38 ++++-- mysql-test/r/ps_7ndb.result | 19 ++- mysql-test/r/type_date.result | 26 ++++ mysql-test/r/type_datetime.result | 35 +++++ mysql-test/t/date_formats.test | 2 + mysql-test/t/func_sapdb.test | 2 + mysql-test/t/type_date.test | 13 ++ mysql-test/t/type_datetime.test | 22 +++ sql-common/my_time.c | 39 +++++- sql/CMakeLists.txt | 2 +- sql/event_data_objects.cc | 22 +-- sql/event_db_repository.cc | 6 +- sql/event_queue.cc | 2 +- sql/field.cc | 121 ++++++++++------- sql/field.h | 30 ++--- sql/item.cc | 73 ++++++---- sql/item.h | 26 ++-- sql/item_cmpfunc.cc | 3 + sql/item_func.h | 4 +- sql/item_timefunc.cc | 217 +++++++++++++++++------------- sql/item_timefunc.h | 48 +++---- sql/my_decimal.cc | 2 +- sql/my_decimal.h | 2 +- sql/mysql_priv.h | 29 ++-- sql/protocol.cc | 12 +- sql/protocol.h | 18 +-- sql/sp.cc | 2 +- sql/sql_base.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_show.cc | 10 +- sql/structs.h | 3 +- sql/time.cc | 48 +++---- sql/tztime.cc | 92 ++++++------- sql/tztime.h | 12 +- sql/unireg.cc | 4 +- strings/ctype-utf8.c | 2 + win/README | 2 +- 44 files changed, 677 insertions(+), 409 deletions(-) diff --git a/include/my_time.h b/include/my_time.h index d96c5822069..ce9f45ad6a4 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 @@ -93,6 +91,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/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index cf3495ef26d..92170a64b29 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 @@ -222,6 +230,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 @@ -253,6 +263,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 @@ -291,6 +303,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 @@ -423,14 +437,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/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/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: -Warning 1265 Data truncated for column 'c17' at row 1 -Warnings: -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: -Warning 1265 Data truncated for column 'c17' at row 1 -Warnings: -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: -Warning 1265 Data truncated for column 'c17' at row 1 -Warnings: -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: -Warning 1265 Data truncated for column 'c17' at row 1 -Warnings: -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: -Warning 1265 Data truncated for column 'c17' at row 1 -Warnings: -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: -Warning 1265 Data truncated for column 'c17' at row 1 -Warnings: -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/type_date.result b/mysql-test/r/type_date.result index 12ce742eab4..4b651c137ad 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 b54bd155c7d..56770371a1e 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -194,3 +194,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/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/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/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/sql-common/my_time.c b/sql-common/my_time.c index e62003d13ed..4aad97f8249 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -730,7 +730,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) { @@ -740,11 +772,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--; diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 002aabb91b0..6569d06743e 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -79,7 +79,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 67ba371772a..cc8768bc58f 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"); @@ -909,7 +909,7 @@ int Event_queue_element::load_from_row(THD *thd, TABLE *table) { char *ptr; - TIME time; + MYSQL_TIME time; DBUG_ENTER("Event_queue_element::load_from_row"); @@ -1079,7 +1079,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)) @@ -1172,8 +1172,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. */ { @@ -1417,7 +1417,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. */ @@ -1559,7 +1559,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 @@ -1626,7 +1626,7 @@ Event_queue_element::update_timing_fields(THD *thd) if (last_executed_changed) { - TIME time; + MYSQL_TIME time; my_tz_UTC->gmt_sec_to_TIME(&time, last_executed); fields[ET_FIELD_LAST_EXECUTED]->set_notnull(); @@ -1665,7 +1665,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 0c59d3e92f8..7232390ef69 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -210,7 +210,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(); @@ -219,7 +219,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(); @@ -238,7 +238,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(); diff --git a/sql/event_queue.cc b/sql/event_queue.cc index ef9dddf9195..f64509ee25c 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -749,7 +749,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 7240a59c75f..56e60d81e64 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1500,7 +1500,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; @@ -1511,7 +1511,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; @@ -1528,7 +1528,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]; @@ -2476,7 +2476,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)); @@ -4522,7 +4522,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; @@ -4593,7 +4593,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; @@ -4652,7 +4652,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 @@ -4678,7 +4678,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; @@ -4747,7 +4747,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; @@ -4771,7 +4771,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); } @@ -4779,7 +4779,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); } @@ -4855,7 +4855,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; @@ -4870,9 +4870,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, @@ -4883,8 +4886,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) @@ -4894,7 +4895,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); @@ -5003,7 +5004,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; @@ -5027,7 +5028,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; @@ -5055,7 +5056,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; @@ -5077,7 +5078,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; @@ -5226,7 +5227,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; @@ -5283,7 +5284,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; @@ -5324,7 +5325,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; @@ -5364,7 +5365,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 @@ -5433,10 +5434,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; @@ -5447,20 +5465,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; } @@ -5481,7 +5502,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; @@ -5508,7 +5529,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; @@ -5543,7 +5564,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); } @@ -5594,7 +5615,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; @@ -5607,7 +5628,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); } @@ -5646,7 +5667,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; @@ -5699,7 +5720,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; @@ -5734,7 +5755,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; @@ -5780,7 +5801,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); } @@ -5854,7 +5875,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; @@ -5873,7 +5894,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); } @@ -9414,10 +9435,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 */ @@ -9437,7 +9461,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; } @@ -9465,9 +9489,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); } @@ -9500,7 +9525,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); } } @@ -9533,7 +9558,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 b96be208e41..a302fd6ce18 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; } @@ -564,7 +564,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); @@ -907,8 +907,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; }; @@ -981,7 +981,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); @@ -993,8 +993,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); }; @@ -1013,7 +1013,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); @@ -1021,9 +1021,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; } @@ -1054,7 +1054,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; @@ -1070,8 +1070,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/item.cc b/sql/item.cc index c7935607130..3e3ef2a0bbe 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(<ime, 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(<ime)) { 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(<ime)) 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(<ime, 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; @@ -1868,7 +1886,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)) { @@ -1878,7 +1896,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)) @@ -1889,7 +1907,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)) { @@ -2416,7 +2434,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() @@ -2430,7 +2448,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"); @@ -2445,7 +2463,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); } @@ -2647,7 +2666,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) { @@ -2662,7 +2681,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) { @@ -3088,7 +3107,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)); } @@ -4923,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) { @@ -4936,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); @@ -5488,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)); } @@ -5587,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)); } diff --git a/sql/item.h b/sql/item.h index 87380b53bfb..ee178a1e379 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 &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); } /* This function is used only in Item_func_isnull/Item_func_isnotnull @@ -1373,9 +1373,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); @@ -1499,7 +1499,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. */ @@ -1531,8 +1531,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(); @@ -1541,7 +1541,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(); /* @@ -1980,7 +1980,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); @@ -2057,7 +2057,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; } }; @@ -2143,7 +2143,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 ffa6b4caf2a..747d37c18d2 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -293,6 +293,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 +307,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 +317,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); diff --git a/sql/item_func.h b/sql/item_func.h index 3306b059097..6464b5757c8 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)); } 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(<ime, 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(<ime,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(<ime, 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(<ime, 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(<ime, 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(<ime); 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(<ime); 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(<ime); 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(<ime, TIME_NO_ZERO_DATE)) return 0; return (longlong) calc_week(<ime, @@ -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(<ime, TIME_NO_ZERO_DATE)) return 0; week= calc_week(<ime, @@ -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(<ime, 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(<ime, 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(<ime); 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(<ime, 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(<ime, 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, <ime->year, <ime->month, <ime->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(<ime); @@ -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(<ime, 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(<ime, 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(<ime, TIME_FUZZY_DATE) && !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, <ime, 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(<ime,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(<ime)) { 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(<ime) && !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(<ime, 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(<ime, 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(<ime)) 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(<ime, 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/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 9a0bed8d318..0dcdea5c4f4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1833,19 +1833,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[]; @@ -1857,15 +1858,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); @@ -1885,7 +1886,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 &strings); 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/sp.cc b/sql/sp.cc index c1a9aac0c24..aa6d40f5fc0 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -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); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4d7c2c485ab..b7ab996105b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6274,7 +6274,7 @@ fill_record(THD *thd, Field **ptr, List &values, bool ignore_errors) TABLE *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) DBUG_RETURN(TRUE); } DBUG_RETURN(thd->net.report_error); diff --git a/sql/sql_class.h b/sql/sql_class.h index a9915fce4ef..6b79917f772 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -278,7 +278,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; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ea9b835df4d..5558b02ad78 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1799,7 +1799,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 */ @@ -2836,7 +2836,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"); @@ -3395,7 +3395,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); @@ -3967,7 +3967,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); @@ -4305,7 +4305,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("fill_events_copy_to_schema_tab"); 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/time.cc b/sql/time.cc index 4854206b1c8..b6c91ff2148 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->hour= seconds/3600L; @@ -679,7 +680,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 @@ -687,7 +688,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); @@ -696,7 +697,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); @@ -705,7 +706,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); @@ -713,7 +714,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) { @@ -752,14 +754,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; @@ -883,7 +885,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. @@ -893,7 +895,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; @@ -943,7 +945,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() @@ -961,7 +963,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, ¬_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/strings/ctype-utf8.c b/strings/ctype-utf8.c index 0536d445533..aa3689c1b72 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2769,6 +2769,7 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, const uchar *te=t+tlen; int save_diff = 0; int diff; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; while ( s < se && t < te ) { @@ -2812,6 +2813,7 @@ static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, const uchar *se= s+slen; const uchar *te= t+tlen; int save_diff = 0; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; while ( s < se && t < te ) { 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= Server suffix, default none COMPILATION_COMMENT= Server comment, default "Source distribution" MYSQL_TCP_PORT= Server port, default 3306 - CYBOZU + CYBOZU Default character set is UTF8 So the command line could look like: From c59dba87b64179fdaca7519f1433f0547cdcbb68 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Mar 2007 09:59:15 +0100 Subject: [PATCH 11/83] Bug #26817: mysqldump fails to backup database containing view with invalid definer manual merge 5.0->5.1 --- sql/sql_base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 5fd48f9d356..ce928035b83 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4514,8 +4514,8 @@ find_field_in_tables(THD *thd, Item_ident *item, { Field *nf=new Field_null(NULL,0,Field::NONE, cur_field->field_name, - cur_field->table, &my_charset_bin); + nf->init(cur_table->table); cur_field= nf; } } From d18945535d24107c865239d7c3f071e98f5cd31b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Mar 2007 14:40:38 +0200 Subject: [PATCH 12/83] Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() eliminating the unnecessary option; and replacing site-dependant stuff in the test mysql-test/r/sp_trans.result: results changed, will be changed again after bug#23333 fixed mysql-test/t/sp_trans.test: replacing sensitive stuff sql/mysql_priv.h: removal, as part of Bug#27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() --- mysql-test/r/sp_trans.result | 9 ++++----- mysql-test/t/sp_trans.test | 3 ++- sql/mysql_priv.h | 3 --- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index 513bbc43ce3..57c73bea86e 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -546,12 +546,11 @@ return @a; end| insert into t2 values (bug23333(),1)| ERROR 23000: Duplicate entry '1' for key 1 -show binlog events /* must show the insert */| +show binlog events from 98 /* must show the insert */| Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 98 Server ver: 5.0.40-debug-log, Binlog ver: 4 -master-bin.000001 98 Query 1 90 use `test`; insert into t2 values (1,1) -master-bin.000001 188 Xid 1 215 COMMIT /* xid=1165 */ -master-bin.000001 215 Query 1 446 use `test`; CREATE DEFINER=`root`@`localhost` function bug23333() +master-bin.000001 # Query 1 # use `test`; insert into t2 values (1,1) +master-bin.000001 # Xid 1 # COMMIT /* xid=1165 */ +master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` function bug23333() RETURNS int(11) DETERMINISTIC begin diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index 579af44f28d..f2ed39c093e 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -580,7 +580,8 @@ end| --error ER_DUP_ENTRY insert into t2 values (bug23333(),1)| -show binlog events /* must show the insert */| +--replace_column 2 # 5 # +show binlog events from 98 /* must show the insert */| select count(*),@a from t1 /* must be 1,1 */| # diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 88bd8576965..cb0586a5e7c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -347,9 +347,6 @@ MY_LOCALE *my_locale_by_number(uint number); in the user query has requested */ #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 From 79bfd0b958f4bade19e0f49ae379b6502cc145fe Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Mar 2007 15:30:32 +0200 Subject: [PATCH 13/83] Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() fixing wrong written assignment sql/ha_ndbcluster.cc: fixing assignment --- sql/ha_ndbcluster.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 10567ca2d70..0456f5697a9 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3636,7 +3636,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->no_trans_update= {TRUE, TRUE}; + thd->no_trans_update.all= thd->no_trans_update.stmt= TRUE; } else if (!thd->transaction.on) m_transaction_on= FALSE; From ae7283a64b4cbecb9c638979fe63e68d222b2fa1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Mar 2007 19:20:00 +0200 Subject: [PATCH 14/83] Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() removing test host sensitive stuff for pushbuild mysql-test/r/sp_trans.result: results changed, will be changed again after bug#23333 fixed mysql-test/t/sp_trans.test: replacing sensitive stuff --- mysql-test/r/sp_trans.result | 14 ++------------ mysql-test/t/sp_trans.test | 6 +++--- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index 57c73bea86e..f09645703ba 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -534,7 +534,6 @@ 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| -reset master| insert into t2 values (1,1)| create function bug23333() RETURNS int(11) @@ -544,20 +543,11 @@ 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 1 -show binlog events from 98 /* must show the insert */| +show binlog events from 98 /* with fixes for #23333 will show there is the query */| Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; insert into t2 values (1,1) -master-bin.000001 # Xid 1 # COMMIT /* xid=1165 */ -master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` function bug23333() -RETURNS int(11) -DETERMINISTIC -begin -insert into t1 values (null); -select count(*) from t1 into @a; -return @a; -end select count(*),@a from t1 /* must be 1,1 */| count(*) @a 1 1 diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index f2ed39c093e..d9b34c303ae 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -566,7 +566,6 @@ 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| -reset master| insert into t2 values (1,1)| create function bug23333() @@ -578,10 +577,11 @@ begin return @a; end| +reset master| --error ER_DUP_ENTRY insert into t2 values (bug23333(),1)| ---replace_column 2 # 5 # -show binlog events from 98 /* must show the insert */| +--replace_column 2 # 5 # 6 # +show binlog events from 98 /* with fixes for #23333 will show there is the query */| select count(*),@a from t1 /* must be 1,1 */| # From d25dd07363cbe54d813c2d9cd9cc16ff32e9bde4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Mar 2007 13:44:58 +0300 Subject: [PATCH 15/83] Fixed error found by valgrind in numerical date handling Fixed comments to say MYSQL_TIME instead of old typedef TIME --- sql-common/my_time.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 4aad97f8249..08c3c0f8adc 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -456,7 +456,7 @@ err: /* - Convert a time string to a TIME struct. + Convert a time string to a MYSQL_TIME struct. SYNOPSIS str_to_time() @@ -642,11 +642,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 @@ -663,11 +663,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 @@ -1008,7 +1008,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 @@ -1094,7 +1094,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. @@ -1150,6 +1150,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; @@ -1186,7 +1187,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) { @@ -1196,7 +1197,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. */ @@ -1210,7 +1211,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). @@ -1224,7 +1225,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. */ From 57693826d1d2d8347a738a33083c9588caa6b78b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Mar 2007 18:48:05 +0300 Subject: [PATCH 16/83] Small fixes. sql/mysqld.cc: Added use of find_type_or_exit() for another option. sql/net_serv.cc: Bug in version number check, could occassionally make a tree red. --- sql/mysqld.cc | 18 +++++++----------- sql/net_serv.cc | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 083f0eb1373..65c4e360c4c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -280,7 +280,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= { @@ -7860,16 +7864,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: diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 2156888b8cf..041a7fb67f6 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -298,7 +298,7 @@ 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) +#if defined(EXTRA_DEBUG) && (MYSQL_VERSION_ID < 50100) fprintf(stderr,"Error: net_clear() skipped %d bytes from file: %s\n", count, vio_description(net->vio)); #endif From 454e889f44912774738b96ab9c1dcd5fb1c96288 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Mar 2007 18:51:02 +0300 Subject: [PATCH 17/83] Fixes for 4.1 to be as in 5.0 and above. client/mysql.cc: Fixed to be as in 5.0 and above. client/mysqldump.c: Fixed to be as in 5.0 and above. include/my_sys.h: Fixed to be as in 5.0 and above. mysys/my_static.c: Fixed to be as in 5.0 and above. --- client/mysql.cc | 2 +- client/mysqldump.c | 2 +- include/my_sys.h | 2 +- mysys/my_static.c | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index d8810ba3c28..babfa870829 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -440,7 +440,7 @@ int main(int argc,char *argv[]) put_info((char*) glob_buffer.ptr(),INFO_INFO); #ifdef HAVE_READLINE - initialize_readline(my_progname); + initialize_readline((char*) my_progname); if (!status.batch && !quick && !opt_html && !opt_xml) { /* read-history from file, default ~/.mysql_history*/ diff --git a/client/mysqldump.c b/client/mysqldump.c index e9d48f3edfa..3bf9fff1b86 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2654,7 +2654,7 @@ int main(int argc, char **argv) default_charset= (char *)mysql_universal_client_charset; bzero((char*) &ignore_table, sizeof(ignore_table)); - MY_INIT(argv[0]); + MY_INIT("mysqldump"); if (get_options(&argc, &argv)) { my_end(0); diff --git a/include/my_sys.h b/include/my_sys.h index 4c9a7a7964c..e44f29ffdd8 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -203,7 +203,7 @@ extern int errno; /* declare errno */ extern const char ** NEAR my_errmsg[]; extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; extern char *home_dir; /* Home directory for user */ -extern char *my_progname; /* program-name (printed in errors) */ +extern const char *my_progname; /* program-name (printed in errors) */ extern char NEAR curr_dir[]; /* Current directory for user */ extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); extern int (*fatal_error_handler_hook)(uint my_err, const char *str, diff --git a/mysys/my_static.c b/mysys/my_static.c index 5f034555156..041569c7f07 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -26,7 +26,8 @@ #endif /* from my_init */ -my_string home_dir=0,my_progname=0; +my_string home_dir=0; +const char *my_progname=0; char NEAR curr_dir[FN_REFLEN]= {0}, NEAR home_dir_buff[FN_REFLEN]= {0}; ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0; From 6a594ffd18f52b4bf825eed9714c94207235d22c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Mar 2007 21:55:01 +0400 Subject: [PATCH 18/83] Fix for BUG#25082: default database change on trigger execution breaks replication. When a stored routine is executed, we switch current database to the database, in which the routine has been created. When the stored routine finishes, we switch back to the original database. The problem was that if the original database does not exist (anymore) after routine execution, we raised an error. The fix is to report a warning, and switch to the NULL database. mysql-test/r/sp.result: Updated result file. mysql-test/t/sp.test: Added test case for BUG#25082. sql/mysql_priv.h: 1. Change mysql_change_db() prototype; 2. Polishing. sql/sp.cc: Polishing. sql/sp_head.cc: Polishing. sql/sql_db.cc: 1. Polishing. 2. Fix mysql_change_db(). sql/sql_parse.cc: Polishing. sql/sql_show.cc: Polishing. --- mysql-test/r/sp.result | 15 ++ mysql-test/t/sp.test | 41 +++++ sql/mysql_priv.h | 7 +- sql/sp.cc | 6 +- sql/sp_head.cc | 2 +- sql/sql_db.cc | 336 +++++++++++++++++++++++++++-------------- sql/sql_parse.cc | 24 +-- sql/sql_show.cc | 21 +-- 8 files changed, 309 insertions(+), 143 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index ddd2369d36d..6773facb641 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5969,6 +5969,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 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; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index fd158408fb6..6aab1ae3c6a 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6929,6 +6929,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| + + # # NOTE: The delimiter is `|`, and not `;`. It is changed to `;` # at the end of the file! diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4d08b381a2e..5e37cd8987f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -693,7 +693,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list); 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); @@ -937,7 +938,7 @@ void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user, /* information schema */ -extern LEX_STRING information_schema_name; +extern LEX_STRING INFORMATION_SCHEMA_NAME; LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str, const char* str, uint length, bool allocate_lex_string); @@ -955,7 +956,7 @@ 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); #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 */ diff --git a/sql/sp.cc b/sql/sp.cc index 2bb13b02e14..506b0bcd92b 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -441,14 +441,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); @@ -1896,7 +1896,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 9d7fc55ff70..bba231ba685 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1130,7 +1130,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_db.cc b/sql/sql_db.cc index f95ed8b6fc9..d7aecb78363 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -461,7 +461,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); @@ -1126,154 +1126,256 @@ 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 "" - - 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. - - 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. - - RETURN VALUES - 0 OK - 1 error + @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. */ -bool mysql_change_db(THD *thd, const char *name, bool no_access_check) +static void mysql_change_db_impl(THD *thd, + LEX_STRING *new_db_name, + ulong new_db_access, + CHARSET_INFO *new_db_charset) { - int db_length; - char *db_name; - bool system_db= 0; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - ulong db_access; - Security_context *sctx= thd->security_ctx; - LINT_INIT(db_access); -#endif - DBUG_ENTER("mysql_change_db"); - DBUG_PRINT("enter",("name: '%s'",name)); + /* 1. Change current database in THD. */ - if (name == NULL || name[0] == '\0' && no_access_check == FALSE) + if (new_db_name == NULL) { - my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); - DBUG_RETURN(1); /* purecov: inspected */ + /* + THD::set_db() does all the job -- it frees previous database name and + sets the new one. + */ + + thd->set_db(NULL, 0); } - else if (name[0] == '\0') + else if (new_db_name == &INFORMATION_SCHEMA_NAME) { - /* Called from SP to restore the original database, which was NULL */ - DBUG_ASSERT(no_access_check); - system_db= 1; - db_name= NULL; - db_length= 0; - goto end; + /* + 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 LEX_STRING *new_db_name, bool force_switch) +{ + LEX_STRING new_db_file_name; + + Security_context *sctx= thd->security_ctx; + ulong db_access= sctx->db_access; + + DBUG_ENTER("mysql_change_db"); + DBUG_PRINT("enter",("name: '%s'", new_db_name->str)); + + if (new_db_name == NULL || + new_db_name->length == 0 || + new_db_name->str == NULL) + { + 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); + } + } + + if (my_strcasecmp(system_charset_info, new_db_name->str, + INFORMATION_SCHEMA_NAME.str) == 0) + { + /* 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(). */ - if ((db_name= my_strdup(name, MYF(MY_WME))) == NULL) - DBUG_RETURN(1); /* the error is set */ - db_length= strlen(db_name); - if (check_db_name(db_name)) + + new_db_file_name.str= my_strdup(new_db_name->str, 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 (check_db_name(new_db_file_name.str)) { - my_error(ER_WRONG_DB_NAME, MYF(0), db_name); - my_free(db_name, MYF(0)); - DBUG_RETURN(1); - } - DBUG_PRINT("info",("Use database: %s", db_name)); - if (!my_strcasecmp(system_charset_info, db_name, information_schema_name.str)) - { - system_db= 1; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - db_access= SELECT_ACL; -#endif - goto end; + 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", new_db_file_name.str)); + #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (!no_access_check) + if (!force_switch) /* FIXME: this is BUG#27337. */ { - if (test_all_bits(sctx->master_access, DB_ACLS)) - db_access=DB_ACLS; - else - db_access= (acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name, 0) | - sctx->master_access); - if (!(db_access & DB_ACLS) && (!grant_option || - check_grant_db(thd,db_name))) + 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, - db_name); + new_db_file_name.str); mysql_log.write(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR), - sctx->priv_user, sctx->priv_host, db_name); - my_free(db_name, MYF(0)); - DBUG_RETURN(1); + sctx->priv_user, sctx->priv_host, 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)) + if (check_db_dir_existence(new_db_file_name.str)) { - my_error(ER_BAD_DB_ERROR, MYF(0), db_name); - my_free(db_name, MYF(0)); - DBUG_RETURN(1); + 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 + { + 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); + } } -end: - x_free(thd->db); - DBUG_ASSERT(db_name == NULL || db_name[0] != '\0'); - thd->reset_db(db_name, db_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; + /* + NOTE: in mysql_change_db_impl() new_db_file_name is assigned to THD + attributes and will be freed in THD::~THD(). + */ - load_db_opt_by_name(thd, db_name, &create); + { + HA_CREATE_INFO db_options; - thd->db_charset= create.default_table_charset ? - create.default_table_charset : - thd->variables.collation_server; - thd->variables.collation_database= thd->db_charset; + load_db_opt_by_name(thd, new_db_name->str, &db_options); + + 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); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 486942a8bb9..cbf9e374dac 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -290,7 +290,8 @@ 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 /* Change database if necessary */ @@ -301,7 +302,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); @@ -443,7 +444,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); @@ -1638,7 +1639,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, &LOCK_status); thd->convert_string(&tmp, system_charset_info, packet, strlen(packet), thd->charset()); - if (!mysql_change_db(thd, tmp.str, FALSE)) + if (!mysql_change_db(thd, &tmp, FALSE)) { mysql_log.write(thd,command,"%s",thd->db); send_ok(thd); @@ -1862,7 +1863,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, packet= pend+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) @@ -3753,9 +3754,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: { @@ -5436,7 +5442,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; } /* @@ -6256,7 +6262,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 || @@ -6264,7 +6270,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, lex->orig_sql_command == SQLCOM_END)) // not a 'show' command { 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_show.cc b/sql/sql_show.cc index 286799a44f6..cf0cb9ba8d2 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -496,9 +496,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 @@ -1823,7 +1823,8 @@ LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str, /* INFORMATION_SCHEMA name */ -LEX_STRING information_schema_name= {(char*)"information_schema", 18}; +LEX_STRING INFORMATION_SCHEMA_NAME= + { (char *) 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[]; @@ -2039,11 +2040,11 @@ int make_db_list(THD *thd, List *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, @@ -2058,11 +2059,11 @@ int make_db_list(THD *thd, List *files, */ if (lex->orig_sql_command != SQLCOM_END) { - 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)); } @@ -2071,7 +2072,7 @@ int make_db_list(THD *thd, List *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, @@ -3927,8 +3928,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 */ From 0fdd64ba6391e556c3438733cb4f479f2c3395cf Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Mar 2007 19:31:42 +0300 Subject: [PATCH 19/83] Merged from 5.0 --- mysys/thr_alarm.c | 5 ++++- sql/mysqld.cc | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) 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/sql/mysqld.cc b/sql/mysqld.cc index cf9a139c0f9..b7858b3178d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2351,7 +2351,8 @@ static void init_signals(void) #ifdef SIGTSTP sigaddset(&set,SIGTSTP); #endif - sigaddset(&set,THR_SERVER_ALARM); + if (thd_lib_detected != THD_LIB_LT) + sigaddset(&set,THR_SERVER_ALARM); if (test_flags & TEST_SIGINT) { // May be SIGINT From 442afcf452c9211efecccd3e7c60e5ee0c9f05be Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Mar 2007 19:51:42 +0300 Subject: [PATCH 20/83] Fixed memory leak in mysql_upgrade client/mysql_upgrade.c: Fixed memory leak Fixed indentation --- client/mysql_upgrade.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 21242818b21..33dab4e1909 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -171,7 +171,7 @@ void set_extra_default(int id, const struct my_option *opt) } d= (extra_default_t *)my_malloc(sizeof(extra_default_t), - MYF(MY_FAE|MY_ZEROFILL)); + MYF(MY_FAE | MY_ZEROFILL)); d->id= id; d->name= opt->name; d->n_len= strlen(opt->name); @@ -345,15 +345,17 @@ static int create_defaults_file(const char *path, const char *forced_path) } dynstr_set(&buf, NULL); } - if (dynstr_append_mem(&buf, "\n", 1) - || dynstr_append_mem(&buf, d->name, d->n_len) - || (d->v_len && (dynstr_append_mem(&buf, "=", 1) - || dynstr_append_mem(&buf, d->value, d->v_len)))) + if (dynstr_append_mem(&buf, "\n", 1) || + dynstr_append_mem(&buf, d->name, d->n_len) || + (d->v_len && (dynstr_append_mem(&buf, "=", 1) || + dynstr_append_mem(&buf, d->value, d->v_len)))) { ret= 1; goto error; } my_delete((gptr)d, MYF(0)); + my_free((gptr) d, MYF(0)); + list_pop(extra_defaults); /* pop off the head */ } if (my_write(defaults_file, buf.str, buf.length, MYF(MY_FNABP | MY_WME))) @@ -451,10 +453,10 @@ int main(int argc, char **argv) char *forced_extra_defaults; char *local_defaults_group_suffix; const char *script_line; - char *upgrade_defaults_path; + char *upgrade_defaults_path= NULL; char *defaults_to_use= NULL; int upgrade_defaults_created= 0; - + int no_defaults; char path[FN_REFLEN]; DYNAMIC_STRING cmdline; @@ -464,6 +466,10 @@ int main(int argc, char **argv) #endif /* Check if we are forced to use specific defaults */ + no_defaults= 0; + if (argc >= 2 && !strcmp(argv[1],"--no-defaults")) + no_defaults= 1; + get_defaults_options(argc, argv, &forced_defaults_file, &forced_extra_defaults, &local_defaults_group_suffix); @@ -652,7 +658,9 @@ fix_priv_tables: if (defaults_to_use) { dynstr_append(&cmdline, " "); - dynstr_append_os_quoted(&cmdline, "--defaults-extra-file=", + dynstr_append_os_quoted(&cmdline, + (no_defaults ? "--defaults-file=" : + "--defaults-extra-file="), defaults_to_use, NullS); } dynstr_append(&cmdline, " "); @@ -684,6 +692,7 @@ error: if (upgrade_defaults_created) my_delete(upgrade_defaults_path, MYF(0)); + my_free(upgrade_defaults_path, MYF(MY_ALLOW_ZERO_PTR)); my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); return ret; } From a9f4be70547229da701fb3f7c91c38096e31b00d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Mar 2007 21:06:32 +0300 Subject: [PATCH 21/83] Initialize thd->no_trans_update (Fixes valgrind warnings) --- sql/sql_class.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 971d7e9d1b1..07f94ce768a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -333,6 +333,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 : From e57c8007a4e2c7d1f8bda44b0af6599126673ef4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Mar 2007 21:11:17 +0300 Subject: [PATCH 22/83] Manual merge from 5.0 --- sql/event_db_repository.cc | 4 ++-- sql/set_var.cc | 5 +---- sql/sql_connect.cc | 5 +++-- sql/sql_db.cc | 10 ++++++---- sql/sql_insert.cc | 6 +++--- sql/sql_parse.cc | 12 +++++++----- sql/sql_update.cc | 2 +- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 7232390ef69..7328e2184e4 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -644,7 +644,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data, ok: if (dbchanged) - (void) mysql_change_db(thd, old_db.str, 1); + (void) mysql_change_db(thd, &old_db, 1); /* This statement may cause a spooky valgrind warning at startup inside init_key_cache on my system (ahristov, 2006/08/10) @@ -654,7 +654,7 @@ ok: err: if (dbchanged) - (void) mysql_change_db(thd, old_db.str, 1); + (void) mysql_change_db(thd, &old_db, 1); if (table) close_thread_tables(thd); DBUG_RETURN(TRUE); diff --git a/sql/set_var.cc b/sql/set_var.cc index b8459c33bc2..de214164c0a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3083,9 +3083,7 @@ 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)) @@ -3094,7 +3092,6 @@ static bool set_option_autocommit(THD *thd, set_var *var) else { thd->no_trans_update.all= FALSE; - thd->options&= ~(ulonglong) (OPTION_STATUS_NO_TRANS_UPDATE); thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT; } } 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 4e96a987d99..f529a21b109 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -22,6 +22,7 @@ #include "events.h" #include #include +#include "log.h" #ifdef __WIN__ #include #endif @@ -1420,7 +1421,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) to be sure. */ - if (check_db_name(new_db_file_name.str)) + if (check_db_name(&new_db_file_name)) { my_error(ER_WRONG_DB_NAME, MYF(0), new_db_file_name.str); my_free(new_db_file_name.str, MYF(0)); @@ -1454,8 +1455,9 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) sctx->priv_user, sctx->priv_host, new_db_file_name.str); - mysql_log.write(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR), - 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); } @@ -1801,7 +1803,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); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4eff7e4edeb..9c20ad6922b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -712,7 +712,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) @@ -1322,7 +1322,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)) @@ -2638,7 +2638,7 @@ select_insert::prepare(List &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 | diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ff7e06e1875..3665d7f0b03 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -720,7 +720,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); @@ -4208,8 +4208,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; @@ -5023,8 +5023,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) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index f438e04e6c9..988e81033c7 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -535,7 +535,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, From 6bcf19c80a4457aba977926ce4f386a2773630d6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Apr 2007 15:19:06 +0200 Subject: [PATCH 23/83] build fix for bug#27049 --- mysql-test/t/mysqlbinlog.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 9a27c4cbdb2..ef314bced71 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -205,7 +205,7 @@ select hex(a) from t1; drop table t1; flush logs; --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000010 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000010 --echo End of 5.0 tests From 30cb61d0572bf055df2e14dc8ad9015def21af01 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Apr 2007 15:20:46 +0200 Subject: [PATCH 24/83] BUG#27489 build fix scripts/make_binary_distribution.sh: BUG#27489 make_binary_distribution doesn't copy all files --- scripts/make_binary_distribution.sh | 43 +++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index eab3af29ad1..9101f7f0948 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'` @@ -253,25 +268,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/* From 5c0bbbe8ea17a8f5772415be548163027276d213 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Apr 2007 15:36:59 +0200 Subject: [PATCH 25/83] BUG#25303 log_state fails sql/set_var.cc: BUG#25303 opt_slow_log is really a my_bool --- sql/set_var.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index fef6fccfd06..a0869fb2984 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -875,7 +875,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}, From 08c186490259c4c32001b1e0526fe8564df7458c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Apr 2007 18:08:11 +0200 Subject: [PATCH 26/83] fix previous mysqlbinlog test case fix mysql-test/r/mysqlbinlog.result: adjust to change in test file mysql-test/t/mysqlbinlog.test: substitute correct directory --- mysql-test/r/mysqlbinlog.result | 14 +++++++------- mysql-test/t/mysqlbinlog.test | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 5a7dcca2420..57961698034 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -290,23 +290,23 @@ SET @@session.sql_mode=0/*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; create table t1 (a varchar(64) character set utf8)/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-6-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-7-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-8-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-9-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; SET TIMESTAMP=1000000000/*!*/; drop table t1/*!*/; DELIMITER ; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index ef314bced71..630e56ccfd1 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -204,7 +204,7 @@ load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8 select hex(a) from t1; drop table t1; flush logs; ---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000010 --echo End of 5.0 tests From 7e08016a91dc8d24110a73b5286f947718a9379e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Apr 2007 15:11:34 +0400 Subject: [PATCH 27/83] Fix for BUG#27337: Privileges are not properly restored. The problem was that THD::db_access variable was not restored after database switch in stored-routine-execution code. The fix is to restore THD::db_access in this case. Unfortunately, this fix requires additional changes, because in prepare_schema_table(), called on the parsing stage, we checked privileges. That was wrong according to our design, but this flaw haven't struck so far, because it was masked. All privilege checkings must be done on the execution stage in order to be compatible with prepared statements and stored routines. So, this patch also contains patch for prepare_schema_table(), which moves the checkings to the execution phase. mysql-test/r/grant.result: Updated result file. mysql-test/t/grant.test: Added test case for BUG#27337. sql/mysql_priv.h: Added function declaration. sql/sql_db.cc: Fix for BUG#27337 -- set THD::db_access even if we're called from stored-routine-execution code. sql/sql_parse.cc: Split prepare_schema_table() into two functions: - prepare_schema_table(), which is called from the parser (parsing stage); - check_show_access(), which is called on the execution stage. sql/sql_show.cc: Ignore schema_select_lex member if its table is NULL. --- mysql-test/r/grant.result | 75 +++++++++++++++++ mysql-test/t/grant.test | 144 ++++++++++++++++++++++++++++++++ sql/mysql_priv.h | 2 + sql/sql_db.cc | 43 +++++----- sql/sql_parse.cc | 167 +++++++++++++++++++++++++++----------- sql/sql_show.cc | 2 +- 6 files changed, 362 insertions(+), 71 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 73d5bf94264..ae550649951 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1019,4 +1019,79 @@ 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 diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 92ed69d3f4b..623bd4363cb 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -958,4 +958,148 @@ 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/sql/mysql_priv.h b/sql/mysql_priv.h index 5e37cd8987f..629ffb93b97 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -955,6 +955,8 @@ 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)) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index d7aecb78363..963457cc896 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1308,30 +1308,27 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) DBUG_PRINT("info",("Use database: %s", new_db_file_name.str)); #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (!force_switch) /* FIXME: this is BUG#27337. */ - { - 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; + 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); - mysql_log.write(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); - } + 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); + mysql_log.write(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 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cbf9e374dac..ac75e6ea2fa 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2237,7 +2237,8 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, enum enum_schema_tables schema_table_idx) { DBUG_ENTER("prepare_schema_table"); - SELECT_LEX *sel= 0; + SELECT_LEX *schema_select_lex= NULL; + switch (schema_table_idx) { case SCH_SCHEMATA: #if defined(DONT_ALLOW_SHOW_COMMANDS) @@ -2245,11 +2246,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: @@ -2259,32 +2258,25 @@ 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 (lex->select_lex.db == NULL && + thd->copy_db_to(&lex->select_lex.db, NULL)) { - char *db; - if (lex->select_lex.db == NULL && - thd->copy_db_to(&lex->select_lex.db, 0)) - { - DBUG_RETURN(1); - } - db= lex->select_lex.db; - remove_escape(db); // Fix escaped '_' - if (check_db_name(db)) - { - my_error(ER_WRONG_DB_NAME, MYF(0), db); - DBUG_RETURN(1); - } - if (check_access(thd, SELECT_ACL, db, &thd->col_access, 0, 0, - is_schema_db(db))) - DBUG_RETURN(1); /* purecov: inspected */ - if (!thd->col_access && check_grant_db(thd,db)) - { - my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), - thd->security_ctx->priv_user, thd->security_ctx->priv_host, - db); - DBUG_RETURN(1); - } - break; + DBUG_RETURN(1); } + + schema_select_lex= new SELECT_LEX(); + schema_select_lex->db= lex->select_lex.db; + schema_select_lex->table_list.first= NULL; + remove_escape(schema_select_lex->db); // Fix escaped '_' + + if (check_db_name(schema_select_lex->db)) + { + my_error(ER_WRONG_DB_NAME, MYF(0), schema_select_lex->db); + DBUG_RETURN(1); + } + + + break; #endif case SCH_COLUMNS: case SCH_STATISTICS: @@ -2293,28 +2285,23 @@ 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 (table_ident) { + DBUG_ASSERT(table_ident); + TABLE_LIST **query_tables_last= lex->query_tables_last; - sel= new SELECT_LEX(); + schema_select_lex= 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, - (List *) 0, (List *) 0)) + 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, + (List *) 0, (List *) 0)) 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; - remove_escape(db); // Fix escaped '_' - remove_escape(table_list->table_name); - 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); + + TABLE_LIST *dst_table= (TABLE_LIST*) schema_select_lex->table_list.first; + remove_escape(dst_table->db); // Fix escaped '_' + remove_escape(dst_table->table_name); + break; } #endif @@ -2341,7 +2328,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; statistic_increment(thd->status_var.com_stat[lex->orig_sql_command], &LOCK_status); @@ -5390,6 +5377,83 @@ 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: + { + 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= + (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); + } + + case SCH_OPEN_TABLES: + case SCH_VARIABLES: + case SCH_STATUS: + case SCH_PROCEDURES: + case SCH_CHARSETS: + case SCH_COLLATIONS: + case SCH_COLLATION_CHARACTER_SET_APPLICABILITY: + case SCH_USER_PRIVILEGES: + case SCH_SCHEMA_PRIVILEGES: + case SCH_TABLE_PRIVILEGES: + case SCH_COLUMN_PRIVILEGES: + case SCH_TABLE_CONSTRAINTS: + case SCH_KEY_COLUMN_USAGE: + break; + } + + return FALSE; +} + + /* Check the privilege for all used tables. @@ -5450,7 +5514,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) || my_tz_check_n_skip_implicit_tables(&tables, thd->lex->time_zone_tables_used)) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index cf0cb9ba8d2..fa78db50532 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2148,7 +2148,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; From 8845cbb8b6e497fd063d8f4ca68c82b0e69f49bc Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Apr 2007 18:04:24 +0200 Subject: [PATCH 28/83] no Max rpms anymore, but a debug binary support-files/mysql.spec.sh: remove Max rpms and add a debug server --- support-files/mysql.spec.sh | 179 +++++++++++++----------------------- 1 file changed, 64 insertions(+), 115 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index ce1335e1bc4..61682428046 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -14,7 +14,7 @@ # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston # MA 02110-1301 USA. -%define mysql_version @VERSION@ +%define mysql_version @VERSION@ # use "rpmbuild --with static" or "rpm --define '_with_static 1'" (for RPM 3.x) # to enable static linking (off by default) @@ -32,10 +32,10 @@ %define release 0.glibc23 %endif %define license GPL -%define mysqld_user mysql -%define mysqld_group mysql -%define server_suffix -standard -%define mysqldatadir /var/lib/mysql +%define mysqld_user mysql +%define mysqld_group mysql +%define server_suffix -community +%define mysqldatadir /var/lib/mysql # We don't package all files installed into the build root by intention - # See BUG#998 for details. @@ -99,7 +99,7 @@ Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases Requires: coreutils grep procps /usr/sbin/useradd /usr/sbin/groupadd /sbin/chkconfig Provides: msqlormysql mysql-server mysql MySQL -Obsoletes: MySQL mysql mysql-server +Obsoletes: MySQL mysql mysql-server mysql-Max %description server The MySQL(TM) software delivers a very fast, multi-threaded, multi-user, @@ -120,7 +120,7 @@ This package includes the MySQL server binary (incl. InnoDB) as well as related utilities to run and administrate a MySQL server. If you want to access and work with the database, you have to install -package "MySQL-client" as well! +the package "MySQL-client" as well! %package client Summary: MySQL - Client @@ -141,8 +141,6 @@ Group: Applications/Databases This package contains the ndbcluster storage engine. It is necessary to have this package installed on all computers that should store ndbcluster table data. -Note that this storage engine can only be used in conjunction -with the MySQL Max server. %{see_base} @@ -211,29 +209,6 @@ Obsoletes: mysql-shared This package contains the shared libraries (*.so*) which certain languages and applications need to dynamically load and use MySQL. -%package Max -Summary: MySQL - server with extended functionality -Group: Applications/Databases -Provides: mysql-Max -Obsoletes: mysql-Max -Requires: MySQL-server >= @MYSQL_BASE_VERSION@ - -%description Max -Optional MySQL server binary that supports additional features like: - - - Berkeley DB Storage Engine - - Ndbcluster Storage Engine interface - - Archive Storage Engine - - CSV Storage Engine - - Example Storage Engine - - Federated Storage Engine - - User Defined Functions (UDFs). - -To activate this binary, just install this package in addition to -the standard MySQL package. - -Please note that this is a dynamically linked binary! - #%package embedded #Requires: %{name}-devel #Summary: MySQL - embedded library @@ -323,9 +298,6 @@ mkdir -p $RBR%{_libdir}/mysql PATH=${MYSQL_BUILD_PATH:-/bin:/usr/bin} export PATH -# Build the Max binary (includes BDB and UDFs and therefore -# cannot be linked statically against the patched glibc) - # Use gcc for C and C++ code (to avoid a dependency on libstdc++ and # including exceptions into the code if [ -z "$CXX" -a -z "$CC" ] @@ -334,81 +306,48 @@ then export CXX="gcc" fi -BuildMySQL "--enable-shared \ - --with-extra-charsets=all \ - --with-berkeley-db \ - --with-innodb \ - --with-ndbcluster \ - --with-archive-storage-engine \ - --with-csv-storage-engine \ - --with-example-storage-engine \ - --with-blackhole-storage-engine \ - --with-federated-storage-engine \ - --with-big-tables \ - --with-comment=\"MySQL Community Edition - Experimental (GPL)\" \ - --with-server-suffix='-max'" - -# We might want to save the config log file -if test -n "$MYSQL_MAXCONFLOG_DEST" -then - cp -fp config.log "$MYSQL_MAXCONFLOG_DEST" -fi - -( cd mysql-test - MTR_BUILD_THREAD=auto - export MTR_BUILD_THREAD - perl ./mysql-test-run.pl --force --report-features - perl ./mysql-test-run.pl --force --ps-protocol - true ) - -# Save mysqld-max -./libtool --mode=execute cp sql/mysqld sql/mysqld-max -./libtool --mode=execute nm --numeric-sort sql/mysqld-max > sql/mysqld-max.sym - -# Save the perror binary so it supports the NDB error codes (BUG#13740) -./libtool --mode=execute cp extra/perror extra/perror.ndb - -# Install the ndb binaries -(cd ndb; make install DESTDIR=$RBR) - -# Include libgcc.a in the devel subpackage (BUG 4921) -if expr "$CC" : ".*gcc.*" > /dev/null ; -then - libgcc=`$CC $CFLAGS --print-libgcc-file` - if [ -f $libgcc ] - then - %define have_libgcc 1 - install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a - fi -fi - -# Save libraries -(cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) -(cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*) -(cd ndb/src/.libs; tar rf $RBR/shared-libs.tar *.so*) - -# Now clean up -make clean - # # Only link statically on our i386 build host (which has a specially # patched static glibc installed) - ia64 and x86_64 run glibc-2.3 (unpatched) # so don't link statically there # -BuildMySQL "--disable-shared \ +for servertype in '--with-debug=full' ' ' +do + BuildMySQL "\ %if %{STATIC_BUILD} + --disable-shared \ --with-mysqld-ldflags='-all-static' \ --with-client-ldflags='-all-static' \ $USE_OTHER_LIBC_DIR \ %else + --enable-shared \ --with-zlib-dir=bundled \ %endif --with-extra-charsets=complex \ - --with-comment=\"MySQL Community Edition - Standard (GPL)\" \ + --with-comment=\"MySQL Community Edition (GPL)\" \ --with-server-suffix='%{server_suffix}' \ --with-archive-storage-engine \ --with-innodb \ - --with-big-tables" + --with-ndbcluster \ + --with-csv-storage-engine \ + --with-example-storage-engine \ + --with-blackhole-storage-engine \ + --with-federated-storage-engine \ + --with-big-tables $servertype" + if test "$servertype" != ' ' + then + # if this is not the regular build, we save the server binary + ./libtool --mode=execute cp sql/mysqld sql/mysqld-debug + ./libtool --mode=execute nm --numeric-sort sql/mysqld-debug > sql/mysqld-debug.sym + echo "# debug" + ( cd mysql-test + MTR_BUILD_THREAD=auto + export MTR_BUILD_THREAD + perl ./mysql-test-run.pl --force --report-features + true ) + make clean + fi +done ./libtool --mode=execute nm --numeric-sort sql/mysqld > sql/mysqld.sym @@ -418,6 +357,7 @@ then cp -fp config.log "$MYSQL_CONFLOG_DEST" fi +echo "# standard" ( cd mysql-test MTR_BUILD_THREAD=auto export MTR_BUILD_THREAD @@ -438,22 +378,33 @@ install -d $RBR%{_libdir} install -d $RBR%{_mandir} install -d $RBR%{_sbindir} - # Install all binaries stripped make install-strip DESTDIR=$RBR benchdir_root=%{_datadir} +# Install the ndb binaries +(cd ndb; make install DESTDIR=$RBR) + +# Install the saved debug server +install -s -m 755 $MBD/sql/mysqld-debug $RBR%{_sbindir}/mysqld-debug + # Install shared libraries (Disable for architectures that don't support it) -(cd $RBR%{_libdir}; tar xf $RBR/shared-libs.tar; rm -f $RBR/shared-libs.tar) +# (cd $RBR%{_libdir}; tar xf $RBR/shared-libs.tar; rm -f $RBR/shared-libs.tar) -# install saved mysqld-max -install -s -m 755 $MBD/sql/mysqld-max $RBR%{_sbindir}/mysqld-max - -# install saved perror binary with NDB support (BUG#13740) -install -s -m 755 $MBD/extra/perror.ndb $RBR%{_bindir}/perror +# Include libgcc.a in the devel subpackage (BUG 4921) +if expr "$CC" : ".*gcc.*" > /dev/null ; +then + libgcc=`$CC $CFLAGS --print-libgcc-file` + if [ -f $libgcc ] + then + %define have_libgcc 1 + install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a + fi +fi # install symbol files ( for stack trace resolution) -install -m 644 $MBD/sql/mysqld-max.sym $RBR%{_libdir}/mysql/mysqld-max.sym +# install -m 644 $MBD/sql/mysqld-max.sym $RBR%{_libdir}/mysql/mysqld-max.sym install -m 644 $MBD/sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld.sym +install -m 644 $MBD/sql/mysqld-debug.sym $RBR%{_libdir}/mysql/mysqld-debug.sym # Install logrotate and autostart install -m 644 $MBD/support-files/mysql-log-rotate $RBR%{_sysconfdir}/logrotate.d/mysql @@ -539,19 +490,12 @@ chmod -R og-rw $mysql_datadir/mysql # Allow safe_mysqld to start mysqld and print a message before we exit sleep 2 - %post ndb-storage mysql_clusterdir=/var/lib/mysql-cluster # Create cluster directory if needed if test ! -d $mysql_clusterdir; then mkdir -m 755 $mysql_clusterdir; fi - -%post Max -# Restart mysqld, to use the new binary. -echo "Restarting mysqld." -%{_sysconfdir}/init.d/mysql restart > /dev/null 2>&1 - %preun server if test $1 = 0 then @@ -644,6 +588,7 @@ fi %attr(755, root, root) %{_bindir}/safe_mysqld %attr(755, root, root) %{_sbindir}/mysqld +%attr(755, root, root) %{_sbindir}/mysqld-debug %attr(755, root, root) %{_sbindir}/mysqlmanager %attr(755, root, root) %{_sbindir}/rcmysql %attr(644, root, root) %{_libdir}/mysql/mysqld.sym @@ -772,11 +717,6 @@ fi %doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1* -%files Max -%defattr(-, root, root, 0755) -%attr(755, root, root) %{_sbindir}/mysqld-max -%attr(644, root, root) %{_libdir}/mysql/mysqld-max.sym - #%files embedded #%defattr(-, root, root, 0755) # %attr(644, root, root) %{_libdir}/mysql/libmysqld.a @@ -784,7 +724,16 @@ 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 +* Wed Mar 21 2007 Daniel Fischer + +- Add debug server. + +* Mon Mar 19 2007 Daniel Fischer + +- 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 - Add several man pages for NDB which are now created. From fe0716d0378994caee61b6fd6ad15059a2fabdc0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Apr 2007 14:19:47 +0200 Subject: [PATCH 29/83] build fixes for 5.1.17 CMakeLists.txt: use correct runtime library for RelWithDebugInfo target and always generate .map files scripts/make_win_bin_dist: use RelWithDebInfo target output if exists, include copy mysqld and mysqlmanager debug info in distribution --- CMakeLists.txt | 8 ++++++++ scripts/make_win_bin_dist | 28 +++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb4d77db73f..ab7a7887c94 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/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 146dcad95f1..9916d71e724 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -126,6 +126,15 @@ if [ -e $DESTDIR ] ; then usage 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,20 @@ 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,pdb} $DESTDIR/bin/ +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.pdb $DESTDIR/bin/mysqld$EXE_SUFFIX.pdb +cp sql/$TARGET/mysqld.map $DESTDIR/bin/mysqld$EXE_SUFFIX.map if [ x"$PACK_DEBUG" = "" -a -f "sql/debug/mysqld.exe" -o \ x"$PACK_DEBUG" = "yes" ] ; then @@ -342,6 +353,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 # ---------------------------------------------------------------------- From 0b4db8addd6aa9fbb87d2cc8eac8331e69d1b0f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Apr 2007 20:32:31 +0300 Subject: [PATCH 30/83] Fixed previous patch, wrong if() -test. --- sql/sql_parse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 60cb4f09071..2445bccdc21 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3571,8 +3571,8 @@ end_with_restore_list: res= TRUE; // cannot happen else { - if ((thd->options & OPTION_KEEP_LOG) && - thd->no_trans_update.all && !thd->slave_thread) + 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, ER(ER_WARNING_NOT_COMPLETE_ROLLBACK)); From f76ab0c46937a0d53ee0907c2a17daca6106c52a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 08:30:16 +0200 Subject: [PATCH 31/83] Deleted reject files accidently checked in configure.in.rej include/my_global.h.rej BUILD/SETUP.sh.rej mysys/thr_alarm.c.rej include/my_pthread.h.rej BitKeeper/deleted/.del-SETUP.sh.rej: Delete: BUILD/SETUP.sh.rej BitKeeper/deleted/.del-configure.in.rej: Delete: configure.in.rej BitKeeper/deleted/.del-my_global.h.rej: Delete: include/my_global.h.rej BitKeeper/deleted/.del-my_pthread.h.rej: Delete: include/my_pthread.h.rej BitKeeper/deleted/.del-thr_alarm.c.rej: Delete: mysys/thr_alarm.c.rej --- BUILD/SETUP.sh.rej | 19 --- configure.in.rej | 299 --------------------------------------- include/my_global.h.rej | 17 --- include/my_pthread.h.rej | 80 ----------- mysys/thr_alarm.c.rej | 220 ---------------------------- 5 files changed, 635 deletions(-) delete mode 100644 BUILD/SETUP.sh.rej delete mode 100644 configure.in.rej delete mode 100644 include/my_global.h.rej delete mode 100644 include/my_pthread.h.rej delete mode 100644 mysys/thr_alarm.c.rej diff --git a/BUILD/SETUP.sh.rej b/BUILD/SETUP.sh.rej deleted file mode 100644 index ccbcaa4404f..00000000000 --- a/BUILD/SETUP.sh.rej +++ /dev/null @@ -1,19 +0,0 @@ -*************** -*** 39,46 **** - c_warnings="$global_warnings -Wunused" - cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" - -! alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet -! pentium_cflags="-mcpu=pentiumpro" - sparc_cflags="" - - # be as fast as we can be without losing our ability to backtrace ---- 39,46 ---- - c_warnings="$global_warnings -Wunused" - cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" - -! #alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet -! #pentium_cflags="-mcpu=pentiumpro" - sparc_cflags="" - - # be as fast as we can be without losing our ability to backtrace diff --git a/configure.in.rej b/configure.in.rej deleted file mode 100644 index 46fbf83b198..00000000000 --- a/configure.in.rej +++ /dev/null @@ -1,299 +0,0 @@ -*************** -*** 388,402 **** - if expr "$target_os" : "[[Ll]]inux.*" > /dev/null - then - MYSQLD_DEFAULT_SWITCHES="--skip-locking" -! IS_LINUX="true" - AC_MSG_RESULT("yes"); - else - MYSQLD_DEFAULT_SWITCHES="" -! IS_LINUX="false" - AC_MSG_RESULT("no"); - fi - AC_SUBST(MYSQLD_DEFAULT_SWITCHES) -! AC_SUBST(IS_LINUX) - - dnl Find paths to some shell programs - AC_PATH_PROG(LN, ln, ln) ---- 388,403 ---- - if expr "$target_os" : "[[Ll]]inux.*" > /dev/null - then - MYSQLD_DEFAULT_SWITCHES="--skip-locking" -! TARGET_LINUX="true" - AC_MSG_RESULT("yes"); -+ AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux]) - else - MYSQLD_DEFAULT_SWITCHES="" -! TARGET_LINUX="false" - AC_MSG_RESULT("no"); - fi - AC_SUBST(MYSQLD_DEFAULT_SWITCHES) -! AC_SUBST(TARGET_LINUX) - - dnl Find paths to some shell programs - AC_PATH_PROG(LN, ln, ln) -*************** -*** 576,582 **** - # (this is true on the MySQL build machines to avoid NSS problems) - # - -! if test "$IS_LINUX" = "true" -a "$static_nss" = "" - then - tmp=`nm /usr/lib/libc.a | grep _nss_files_getaliasent_r` - if test -n "$tmp" ---- 577,583 ---- - # (this is true on the MySQL build machines to avoid NSS problems) - # - -! if test "$TARGET_LINUX" = "true" -a "$static_nss" = "" - then - tmp=`nm /usr/lib/libc.a | grep _nss_files_getaliasent_r` - if test -n "$tmp" -*************** -*** 827,833 **** - ]) - AC_SUBST(WRAPLIBS) - -! if test "$IS_LINUX" = "true"; then - AC_MSG_CHECKING([for atomic operations]) - - AC_LANG_SAVE ---- 828,834 ---- - ]) - AC_SUBST(WRAPLIBS) - -! if test "$TARGET_LINUX" = "true"; then - AC_MSG_CHECKING([for atomic operations]) - - AC_LANG_SAVE -*************** -*** 870,876 **** - [ USE_PSTACK=no ]) - pstack_libs= - pstack_dirs= -! if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no" - then - have_libiberty= have_libbfd= - my_save_LIBS="$LIBS" ---- 871,877 ---- - [ USE_PSTACK=no ]) - pstack_libs= - pstack_dirs= -! if test "$USE_PSTACK" = yes -a "$TARGET_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no" - then - have_libiberty= have_libbfd= - my_save_LIBS="$LIBS" -*************** -*** 1239,1301 **** - # Hack for DEC-UNIX (OSF1) - if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no" - then -! # Look for LinuxThreads. -! AC_MSG_CHECKING("LinuxThreads") -! grepres=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l` -! getconfres=`which getconf >/dev/null && getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |grep LINUXTHREADS | wc -l || echo 0` -! if test "$grepres" -gt 0 -o "$getconfres" -gt 0 - then -! AC_MSG_RESULT("Found") -! AC_DEFINE(HAVE_LINUXTHREADS) -! # Linux 2.0 sanity check -! AC_TRY_COMPILE([#include ], [int a = sched_get_priority_min(1);], , -! AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual])) -! # RedHat 5.0 does not work with dynamic linking of this. -static also -! # gives a speed increase in linux so it does not hurt on other systems. -! with_named_thread="-lpthread" -! else -! AC_MSG_RESULT("Not found") -! # If this is a linux machine we should barf -! AC_MSG_CHECKING("NPTL") -! if test "$IS_LINUX" = "true" -! then -! getconfres=`which getconf >/dev/null && getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |grep NPTL | wc -l || echo 0` -! if test "$getconfres" -gt 0 - then -! AC_DEFINE(HAVE_LINUXTHREADS) dnl All this code predates NPTL, so "have linuxthreads" is a poor name. -! with_named_thread="-lpthread" - else -! AC_MSG_ERROR([This is a Linux system and neither Linuxthreads nor NPTL were -! found. Please install Linuxthreads or a new glibc and try -! again. See the Installation chapter in the Reference Manual for -! more information.]) - fi -! else -! AC_MSG_CHECKING("DEC threads") -! if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a -! then -! with_named_thread="-lpthread -lmach -lexc" -! CFLAGS="$CFLAGS -D_REENTRANT" -! CXXFLAGS="$CXXFLAGS -D_REENTRANT" -! AC_DEFINE(HAVE_DEC_THREADS) -! AC_MSG_RESULT("yes") -! else -! AC_MSG_RESULT("no") -! AC_MSG_CHECKING("DEC 3.2 threads") -! if test -f /usr/shlib/libpthreads.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a -! then -! with_named_thread="-lpthreads -lmach -lc_r" -! AC_DEFINE(HAVE_DEC_THREADS) -! AC_DEFINE(HAVE_DEC_3_2_THREADS) -! with_osf32_threads="yes" -! MYSQLD_DEFAULT_SWITCHES="--skip-thread-priority" -! AC_MSG_RESULT("yes") -! else -! AC_MSG_RESULT("no") -! fi -! fi -! fi -! fi - fi - - ---- 1240,1337 ---- - # Hack for DEC-UNIX (OSF1) - if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no" - then -! AC_MSG_CHECKING("Linux threads") -! if test "$TARGET_LINUX" = "true" - then -! AC_MSG_RESULT("starting") -! # use getconf to check glibc contents -! AC_MSG_CHECKING("getconf GNU_LIBPTHREAD_VERSION") -! case `getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` in -! NPTL* ) -! AC_MSG_RESULT("NPTL") -! AC_DEFINE([HAVE_NPTL], [1], [NPTL threads implementation]) -! with_named_thread="-lpthread" -! ;; -! LINUXTHREADS* ) -! AC_MSG_RESULT("Linuxthreads") -! AC_DEFINE([HAVE_LINUXTHREADS], [1], -! [Whether we are using Xavier Leroy's LinuxThreads]) -! with_named_thread="-lpthread" -! ;; -! * ) -! AC_MSG_RESULT("unknown") -! ;; -! esac -! if test "$with_named_thread" = "no" - then -! # old method, check headers -! # Look for LinuxThreads. -! AC_MSG_CHECKING("LinuxThreads in header file comment") -! res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l` -! if test "$res" -gt 0 -! then -! AC_MSG_RESULT("Found") -! AC_DEFINE([HAVE_LINUXTHREADS], [1], -! [Whether we are using Xavier Leroy's LinuxThreads]) -! # Linux 2.0 sanity check -! AC_TRY_COMPILE([#include ], [int a = sched_get_priority_min(1);], , -! AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual])) -! # RedHat 5.0 does not work with dynamic linking of this. -static also -! # gives a speed increase in linux so it does not hurt on other systems. -! with_named_thread="-lpthread" -! else -! AC_MSG_RESULT("Not found") -! # If this is a linux machine we should barf -! AC_MSG_ERROR([This is a Linux system without a working getconf, -! and Linuxthreads was not found. Please install it (or a new glibc) and try again. -! See the Installation chapter in the Reference Manual for more information.]) -! fi - else -! AC_MSG_RESULT("no need to check headers") - fi -! AC_MSG_CHECKING("for pthread_create in -lpthread"); -! ac_save_LIBS="$LIBS" -! LIBS="$LIBS -lpthread" -! AC_TRY_LINK( [#include ], -! [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ], -! AC_MSG_RESULT("yes"), -! [ AC_MSG_RESULT("no") -! AC_MSG_ERROR([ -! This is a Linux system claiming to support threads, either Linuxthreads or NPTL, but linking a test program failed. -! Please install one of these (or a new glibc) and try again. -! See the Installation chapter in the Reference Manual for more information.]) ] -! ) -! LIBS="$ac_save_LIBS" -! else -! AC_MSG_RESULT("no") -! fi # "$TARGET_LINUX" -! fi # "$with_named_thread" = "no" -a "$with_mit_threads" = "no" -! -! if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no" -! then -! AC_MSG_CHECKING("DEC threads") -! if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a -! then -! with_named_thread="-lpthread -lmach -lexc" -! CFLAGS="$CFLAGS -D_REENTRANT" -! CXXFLAGS="$CXXFLAGS -D_REENTRANT" -! AC_DEFINE(HAVE_DEC_THREADS) -! AC_MSG_RESULT("yes") -! else -! AC_MSG_RESULT("no") -! AC_MSG_CHECKING("DEC 3.2 threads") -! if test -f /usr/shlib/libpthreads.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a -! then -! with_named_thread="-lpthreads -lmach -lc_r" -! AC_DEFINE(HAVE_DEC_THREADS) -! AC_DEFINE(HAVE_DEC_3_2_THREADS) -! with_osf32_threads="yes" -! MYSQLD_DEFAULT_SWITCHES="--skip-thread-priority" -! AC_MSG_RESULT("yes") -! else -! AC_MSG_RESULT("no") -! fi -! fi - fi - - -*************** -*** 1720,1726 **** - AC_SUBST(COMPILATION_COMMENT) - - AC_MSG_CHECKING("need of special linking flags") -! if test "$IS_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes" - then - LDFLAGS="$LDFLAGS -rdynamic" - AC_MSG_RESULT("-rdynamic") ---- 1756,1762 ---- - AC_SUBST(COMPILATION_COMMENT) - - AC_MSG_CHECKING("need of special linking flags") -! if test "$TARGET_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes" - then - LDFLAGS="$LDFLAGS -rdynamic" - AC_MSG_RESULT("-rdynamic") -*************** -*** 1873,1878 **** - tell atod memcpy memmove \ - setupterm strcasecmp sighold vidattr lrand48 localtime_r \ - sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \ - pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \ - pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \ - pthread_attr_getstacksize pthread_key_delete \ ---- 1909,1915 ---- - tell atod memcpy memmove \ - setupterm strcasecmp sighold vidattr lrand48 localtime_r \ - sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \ -+ sigaction sigemptyset sigaddset \ - pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \ - pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \ - pthread_attr_getstacksize pthread_key_delete \ -*************** -*** 1884,1890 **** - # Sanity check: We chould not have any fseeko symbol unless - # large_file_support=yes - AC_CHECK_FUNCS(fseeko, -! [if test "$large_file_support" = no -a "$IS_LINUX" = "true"; - then - AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!"); - fi] ---- 1921,1927 ---- - # Sanity check: We chould not have any fseeko symbol unless - # large_file_support=yes - AC_CHECK_FUNCS(fseeko, -! [if test "$large_file_support" = no -a "$TARGET_LINUX" = "true"; - then - AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!"); - fi] diff --git a/include/my_global.h.rej b/include/my_global.h.rej deleted file mode 100644 index f2953d169e7..00000000000 --- a/include/my_global.h.rej +++ /dev/null @@ -1,17 +0,0 @@ -*************** -*** 97,103 **** - - - /* Fix problem with S_ISLNK() on Linux */ -! #if defined(HAVE_LINUXTHREADS) - #undef _GNU_SOURCE - #define _GNU_SOURCE 1 - #endif ---- 97,103 ---- - - - /* Fix problem with S_ISLNK() on Linux */ -! #if defined(TARGET_OS_LINUX) || defined(__GLIBC__) - #undef _GNU_SOURCE - #define _GNU_SOURCE 1 - #endif diff --git a/include/my_pthread.h.rej b/include/my_pthread.h.rej deleted file mode 100644 index 1f73655b0bd..00000000000 --- a/include/my_pthread.h.rej +++ /dev/null @@ -1,80 +0,0 @@ -*************** -*** 286,293 **** - #undef HAVE_PTHREAD_RWLOCK_RDLOCK - #undef HAVE_SNPRINTF - -! #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B)) -! #define signal(A,B) pthread_signal((A),(void (*)(int)) (B)) - #define my_pthread_attr_setprio(A,B) - #endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */ - ---- 294,301 ---- - #undef HAVE_PTHREAD_RWLOCK_RDLOCK - #undef HAVE_SNPRINTF - -! #define my_sigset(A,B) pthread_signal((A),(void (*)(int)) (B)) -! #define my_signal(A,B) pthread_signal((A),(void (*)(int)) (B)) - #define my_pthread_attr_setprio(A,B) - #endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */ - -*************** -*** 324,337 **** - #if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX) - int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ - #endif -! #if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset) -! #define sigset(A,B) do { struct sigaction s; sigset_t set; \ -! sigemptyset(&set); \ -! s.sa_handler = (B); \ -! s.sa_mask = set; \ -! s.sa_flags = 0; \ -! sigaction((A), &s, (struct sigaction *) NULL); \ - } while (0) - #endif - - #ifndef my_pthread_setprio ---- 332,358 ---- - #if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX) - int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ - #endif -! -! /* -! We define my_sigset() and use that instead of the system sigset() so that -! we can favor an implementation based on sigaction(). On some systems, such -! as Mac OS X, sigset() results in flags such as SA_RESTART being set, and -! we want to make sure that no such flags are set. -! */ -! #if defined(HAVE_SIGACTION) && !defined(my_sigset) -! #define my_sigset(A,B) do { struct sigaction s; sigset_t set; int rc; \ -! DBUG_ASSERT((A) != 0); \ -! sigemptyset(&set); \ -! s.sa_handler = (B); \ -! s.sa_mask = set; \ -! s.sa_flags = 0; \ -! rc= sigaction((A), &s, (struct sigaction *) NULL); \ -! DBUG_ASSERT(rc == 0); \ - } while (0) -+ #elif defined(HAVE_SIGSET) && !defined(my_sigset) -+ #define my_sigset(A,B) sigset((A),(B)) -+ #elif !defined(my_sigset) -+ #define my_sigset(A,B) signal((A),(B)) - #endif - - #ifndef my_pthread_setprio -*************** -*** 416,422 **** - #undef pthread_detach_this_thread - #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); } - #undef sigset -! #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B)) - #endif - - #if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER) ---- 437,443 ---- - #undef pthread_detach_this_thread - #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); } - #undef sigset -! #define my_sigset(A,B) pthread_signal((A),(void (*)(int)) (B)) - #endif - - #if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER) diff --git a/mysys/thr_alarm.c.rej b/mysys/thr_alarm.c.rej deleted file mode 100644 index c991121052e..00000000000 --- a/mysys/thr_alarm.c.rej +++ /dev/null @@ -1,220 +0,0 @@ -*************** -*** 76,96 **** - alarm_aborted=0; - init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0, - compare_ulong,NullS); -! sigfillset(&full_signal_set); /* Neaded to block signals */ - pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_alarm,NULL); -! #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD) -! #if defined(HAVE_mit_thread) -! sigset(THR_CLIENT_ALARM,thread_alarm); /* int. thread system calls */ -! #else - { -! struct sigaction sact; -! sact.sa_flags = 0; -! sact.sa_handler = thread_alarm; -! sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0); - } -- #endif -- #endif - sigemptyset(&s); - sigaddset(&s, THR_SERVER_ALARM); - alarm_thread=pthread_self(); ---- 74,89 ---- - alarm_aborted=0; - init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0, - compare_ulong,NullS); -! sigfillset(&full_signal_set); /* Needed to block signals */ - pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_alarm,NULL); -! #ifndef USE_ALARM_THREAD -! if (thd_lib_detected != THD_LIB_LT) -! #endif - { -! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1, -! thread_alarm); - } - sigemptyset(&s); - sigaddset(&s, THR_SERVER_ALARM); - alarm_thread=pthread_self(); -*************** -*** 108,120 **** - } - #elif defined(USE_ONE_SIGNAL_HAND) - pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */ -! #if THR_SERVER_ALARM == THR_CLIENT_ALARM -! sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */ -! pthread_sigmask(SIG_UNBLOCK, &s, NULL); -! #endif - #else - pthread_sigmask(SIG_UNBLOCK, &s, NULL); -- sigset(THR_SERVER_ALARM,process_alarm); - #endif - DBUG_VOID_RETURN; - } ---- 101,115 ---- - } - #elif defined(USE_ONE_SIGNAL_HAND) - pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */ -! if (thd_lib_detected == THD_LIB_LT) -! { -! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1, -! process_alarm); /* Linuxthreads */ -! pthread_sigmask(SIG_UNBLOCK, &s, NULL); -! } - #else -+ my_sigset(THR_SERVER_ALARM, process_alarm); - pthread_sigmask(SIG_UNBLOCK, &s, NULL); - #endif - DBUG_VOID_RETURN; - } -*************** -*** 240,246 **** - if (alarm_data->malloced) - my_free((gptr) alarm_data,MYF(0)); - found++; -! #ifndef DBUG_OFF - break; - #endif - } ---- 235,241 ---- - if (alarm_data->malloced) - my_free((gptr) alarm_data,MYF(0)); - found++; -! #ifdef DBUG_OFF - break; - #endif - } -*************** -*** 249,258 **** - if (!found) - { - if (*alarmed) -! fprintf(stderr,"Warning: Didn't find alarm %lx in queue of %d alarms\n", -! (long) *alarmed, alarm_queue.elements); -! DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n", -! (long) *alarmed)); - } - pthread_mutex_unlock(&LOCK_alarm); - pthread_sigmask(SIG_SETMASK,&old_mask,NULL); ---- 244,254 ---- - if (!found) - { - if (*alarmed) -! fprintf(stderr, -! "Warning: Didn't find alarm 0x%lx in queue of %d alarms\n", -! (long) *alarmed, alarm_queue.elements); -! DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n", -! (long) *alarmed)); - } - pthread_mutex_unlock(&LOCK_alarm); - pthread_sigmask(SIG_SETMASK,&old_mask,NULL); -*************** -*** 274,291 **** - This must be first as we can't call DBUG inside an alarm for a normal thread - */ - -! #if THR_SERVER_ALARM == THR_CLIENT_ALARM -! if (!pthread_equal(pthread_self(),alarm_thread)) - { - #if defined(MAIN) && !defined(__bsdi__) -! printf("thread_alarm\n"); fflush(stdout); - #endif - #ifdef DONT_REMEMBER_SIGNAL -! sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */ - #endif - return; - } -- #endif - - /* - We have to do do the handling of the alarm in a sub function, ---- 270,287 ---- - This must be first as we can't call DBUG inside an alarm for a normal thread - */ - -! if (thd_lib_detected == THD_LIB_LT && -! !pthread_equal(pthread_self(),alarm_thread)) - { - #if defined(MAIN) && !defined(__bsdi__) -! printf("thread_alarm in process_alarm\n"); fflush(stdout); - #endif - #ifdef DONT_REMEMBER_SIGNAL -! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1, -! process_alarm); /* int. thread system calls */ - #endif - return; - } - - /* - We have to do do the handling of the alarm in a sub function, -*************** -*** 301,307 **** - process_alarm_part2(sig); - #ifndef USE_ALARM_THREAD - #if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND) -! sigset(THR_SERVER_ALARM,process_alarm); - #endif - pthread_mutex_unlock(&LOCK_alarm); - pthread_sigmask(SIG_SETMASK,&old_mask,NULL); ---- 297,303 ---- - process_alarm_part2(sig); - #ifndef USE_ALARM_THREAD - #if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND) -! my_sigset(THR_SERVER_ALARM, process_alarm); - #endif - pthread_mutex_unlock(&LOCK_alarm); - pthread_sigmask(SIG_SETMASK,&old_mask,NULL); -*************** -*** 504,520 **** - ARGSUSED - */ - -- #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD) - static sig_handler thread_alarm(int sig) - { - #ifdef MAIN - printf("thread_alarm\n"); fflush(stdout); - #endif - #ifdef DONT_REMEMBER_SIGNAL -! sigset(sig,thread_alarm); /* int. thread system calls */ - #endif - } -- #endif - - - #ifdef HAVE_TIMESPEC_TS_SEC ---- 499,513 ---- - ARGSUSED - */ - - static sig_handler thread_alarm(int sig) - { - #ifdef MAIN - printf("thread_alarm\n"); fflush(stdout); - #endif - #ifdef DONT_REMEMBER_SIGNAL -! my_sigset(sig, thread_alarm); /* int. thread system calls */ - #endif - } - - - #ifdef HAVE_TIMESPEC_TS_SEC -*************** -*** 915,921 **** - printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name()); - fflush(stdout); - #ifdef DONT_REMEMBER_SIGNAL -! sigset(sig,print_signal_warning); /* int. thread system calls */ - #endif - #ifndef OS2 - if (sig == SIGALRM) ---- 908,914 ---- - printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name()); - fflush(stdout); - #ifdef DONT_REMEMBER_SIGNAL -! my_sigset(sig, print_signal_warning); /* int. thread system calls */ - #endif - #ifndef OS2 - if (sig == SIGALRM) From 60289fba0ba697e2bbab6136e7840216bea0633d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 08:36:56 +0200 Subject: [PATCH 32/83] zlib.m4: Only require the more recent zlibCompileFlags() when building the server, client zlib don't need it. Makefile.am: Always build the bundled zlib static only configure.in: Look for dlopen() even if --with-mysqld-ldflags constains "-static", as this is not the same as the flag to "ld", it just informs "libtool" to link static with libraries created part of the build, even if there exists shared versions. make_binary_distribution.sh: Real "mysqlmanager" executable might be in ".libs" configure.in: Look for dlopen() even if --with-mysqld-ldflags constains "-static", as this is not the same as the flag to "ld", it just informs "libtool" to link static with libraries created part of the build, even if there exists shared versions. config/ac-macros/zlib.m4: Only require the more recent zlibCompileFlags() when building the server, client zlib don't need it. scripts/make_binary_distribution.sh: Real "mysqlmanager" executable might be in ".libs" zlib/Makefile.am: Always build the bundled zlib static only --- config/ac-macros/zlib.m4 | 13 +++++++++++-- configure.in | 4 ++-- scripts/make_binary_distribution.sh | 8 +++++++- zlib/Makefile.am | 3 ++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/config/ac-macros/zlib.m4 b/config/ac-macros/zlib.m4 index a01d13937ff..74de715e424 100644 --- a/config/ac-macros/zlib.m4 +++ b/config/ac-macros/zlib.m4 @@ -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 ], - [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 9b0505a594f..bcf561c02ef 100644 --- a/configure.in +++ b/configure.in @@ -1601,9 +1601,9 @@ fi # dlopen, dlerror case "$with_mysqld_ldflags " in - *"-static "*) + *"-all-static "*) # No need to check for dlopen when mysqld is linked with - # -all-static or -static as it won't be able to load any functions. + # -all-static as it won't be able to load any functions. # NOTE! It would be better if it was possible to test if dlopen # can be used, but a good way to test it couldn't be found diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 7d7918975f2..e8bf39bd016 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -115,7 +115,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 @@ -165,6 +170,7 @@ if [ $BASE_SYSTEM = "netware" ] ; then # For all other platforms: else BIN_FILES="$BIN_FILES \ + server-tools/instance-manager/.libs/mysqlmanager \ client/mysqltestmanagerc \ client/mysqltestmanager-pwgen tools/mysqltestmanager \ client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \ diff --git a/zlib/Makefile.am b/zlib/Makefile.am index c40c922851e..f5741a782fb 100644 --- a/zlib/Makefile.am +++ b/zlib/Makefile.am @@ -21,7 +21,8 @@ LIBS= $(NON_THREADED_LIBS) pkglib_LTLIBRARIES=libz.la -libz_la_LDFLAGS= -version-info 3:3:2 +# We are never interested in a shared version +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 From 046b4bb53c0e62485d2d604f31d33f38a0ee5b46 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 10:00:04 +0200 Subject: [PATCH 33/83] remove manual pages that don't exist from rpm spec file support-files/mysql.spec.sh: remove vanished manual pages --- support-files/mysql.spec.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 0671bd8a58c..99fcfdc9b39 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -556,7 +556,6 @@ fi %doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1* -%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1 %doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1* @@ -577,7 +576,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 @@ -739,6 +737,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Thu Apr 05 2007 Daniel Fischer + +- Remove several man pages that vanished after last release. + * Fri Mar 02 2007 Joerg Bruehe - Add several man pages for NDB which are now created. From e996362040f5733c9296d74ecfb00ca6d552e3ff Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 16:04:31 +0200 Subject: [PATCH 34/83] test of row locking. --- .../suite/row_lock/include/row_lock.inc | 83 ++++ .../row_lock/include/row_lock_big_tab.inc | 94 +++++ .../row_lock/include/row_lock_big_tab_1.inc | 93 +++++ .../row_lock/include/row_lock_big_tab_2.inc | 93 +++++ .../suite/row_lock/include/row_lock_trig.inc | 96 +++++ .../suite/row_lock/include/row_lock_view.inc | 89 +++++ .../row_lock/include/row_lock_view_mix.inc | 92 +++++ .../include/row_lock_view_storedp.inc | 126 +++++++ .../row_lock/include/row_lock_view_trig.inc | 99 +++++ .../suite/row_lock/r/innodb_row_lock_1.result | 142 +++++++ .../suite/row_lock/r/innodb_row_lock_2.result | 32 ++ .../suite/row_lock/r/innodb_row_lock_3.result | 32 ++ .../suite/row_lock/r/innodb_row_lock_4.result | 142 +++++++ .../suite/row_lock/r/innodb_row_lock_5.result | 32 ++ .../row_lock/r/innodb_row_lock_big_tab.result | 97 +++++ .../r/innodb_row_lock_big_tab_1.result | 145 +++++++ .../r/innodb_row_lock_big_tab_2.result | 113 ++++++ .../row_lock/r/innodb_row_lock_trig_1.result | 151 ++++++++ .../row_lock/r/innodb_row_lock_trig_2.result | 37 ++ .../row_lock/r/innodb_row_lock_view_1.result | 34 ++ .../row_lock/r/innodb_row_lock_view_2.result | 40 ++ .../r/innodb_row_lock_view_mix_1.result | 48 +++ .../r/innodb_row_lock_view_mix_2.result | 40 ++ .../r/innodb_row_lock_view_storedp_1.result | 312 +++++++++++++++ .../r/innodb_row_lock_view_storedp_2.result | 47 +++ .../r/innodb_row_lock_view_trig_1.result | 183 +++++++++ .../r/innodb_row_lock_view_trig_2.result | 38 ++ .../suite/row_lock/r/ndb_row_lock_1.result | 139 +++++++ .../suite/row_lock/r/ndb_row_lock_2.result | 31 ++ .../suite/row_lock/r/ndb_row_lock_3.result | 30 ++ .../suite/row_lock/r/ndb_row_lock_4.result | 139 +++++++ .../suite/row_lock/r/ndb_row_lock_5.result | 30 ++ .../row_lock/r/ndb_row_lock_big_tab.result | 177 +++++++++ .../row_lock/r/ndb_row_lock_big_tab_1.result | 357 ++++++++++++++++++ .../row_lock/r/ndb_row_lock_big_tab_2.result | 255 +++++++++++++ .../row_lock/r/ndb_row_lock_trig_1.result | 148 ++++++++ .../row_lock/r/ndb_row_lock_trig_2.result | 35 ++ .../row_lock/r/ndb_row_lock_view_1.result | 194 ++++++++++ .../row_lock/r/ndb_row_lock_view_2.result | 200 ++++++++++ .../row_lock/r/ndb_row_lock_view_mix_1.result | 169 +++++++++ .../row_lock/r/ndb_row_lock_view_mix_2.result | 38 ++ .../r/ndb_row_lock_view_storedp_1.result | 309 +++++++++++++++ .../r/ndb_row_lock_view_storedp_2.result | 46 +++ .../r/ndb_row_lock_view_trig_1.result | 180 +++++++++ .../r/ndb_row_lock_view_trig_2.result | 36 ++ mysql-test/suite/row_lock/readme.txt | 9 + .../suite/row_lock/summary_of_sel_test.txt | 36 ++ .../suite/row_lock/t/innodb_row_lock_1.test | 9 + .../suite/row_lock/t/innodb_row_lock_2.test | 9 + .../suite/row_lock/t/innodb_row_lock_3.test | 9 + .../suite/row_lock/t/innodb_row_lock_4.test | 9 + .../suite/row_lock/t/innodb_row_lock_5.test | 9 + .../row_lock/t/innodb_row_lock_big_tab.test | 9 + .../row_lock/t/innodb_row_lock_big_tab_1.test | 10 + .../row_lock/t/innodb_row_lock_big_tab_2.test | 10 + .../row_lock/t/innodb_row_lock_trig_1.test | 9 + .../row_lock/t/innodb_row_lock_trig_2.test | 9 + .../row_lock/t/innodb_row_lock_view_1.test | 9 + .../row_lock/t/innodb_row_lock_view_2.test | 9 + .../t/innodb_row_lock_view_mix_1.test | 9 + .../t/innodb_row_lock_view_mix_2.test | 10 + .../t/innodb_row_lock_view_storedp_1.test | 9 + .../t/innodb_row_lock_view_storedp_2.test | 9 + .../t/innodb_row_lock_view_trig_1.test | 9 + .../t/innodb_row_lock_view_trig_2.test | 9 + .../suite/row_lock/t/ndb_row_lock_1.test | 6 + .../suite/row_lock/t/ndb_row_lock_2.test | 6 + .../suite/row_lock/t/ndb_row_lock_3.test | 6 + .../suite/row_lock/t/ndb_row_lock_4.test | 6 + .../suite/row_lock/t/ndb_row_lock_5.test | 6 + .../row_lock/t/ndb_row_lock_big_tab.test | 6 + .../row_lock/t/ndb_row_lock_big_tab_1.test | 7 + .../row_lock/t/ndb_row_lock_big_tab_2.test | 7 + .../suite/row_lock/t/ndb_row_lock_trig_1.test | 6 + .../suite/row_lock/t/ndb_row_lock_trig_2.test | 6 + .../suite/row_lock/t/ndb_row_lock_view_1.test | 7 + .../suite/row_lock/t/ndb_row_lock_view_2.test | 6 + .../row_lock/t/ndb_row_lock_view_mix_1.test | 6 + .../row_lock/t/ndb_row_lock_view_mix_2.test | 6 + .../t/ndb_row_lock_view_storedp_1.test | 6 + .../t/ndb_row_lock_view_storedp_2.test | 6 + .../row_lock/t/ndb_row_lock_view_trig_1.test | 6 + .../row_lock/t/ndb_row_lock_view_trig_2.test | 6 + 83 files changed, 5364 insertions(+) create mode 100644 mysql-test/suite/row_lock/include/row_lock.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_big_tab.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_trig.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_view.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_view_mix.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_view_storedp.inc create mode 100644 mysql-test/suite/row_lock/include/row_lock_view_trig.inc create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_2.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_3.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_4.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_5.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result create mode 100644 mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_3.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_4.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_5.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result create mode 100644 mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result create mode 100644 mysql-test/suite/row_lock/readme.txt create mode 100644 mysql-test/suite/row_lock/summary_of_sel_test.txt create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_2.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_3.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_4.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_5.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test create mode 100644 mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_3.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_4.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_5.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test create mode 100644 mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test 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 ... where ... for update; +- select ... where ... lock in share mode; +- select ... where ... for update; +- select ... where ... lock in share mode; +- select ... ignore index ... where ... for update; +- select ... 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 ... where ... for update; +- select ... where ... lock in ...; +- select ... where ... for update; +- select ... 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 From 1686a01a268f64182c8b7a70841dd72ad2517348 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 17:54:37 +0200 Subject: [PATCH 35/83] changed supported sql function to inpuzt files. mysql-test/suite/funcs_1/r/a_version_check.result: new version mysql-test/suite/partitions/include/partition_supported_sql_funcs.inc: read data from file. mysql-test/suite/partitions/include/partition_supported_sql_funcs_delete.inc: read data from file. mysql-test/suite/partitions/include/partition_supported_sql_funcs_main.inc: read data from file. mysql-test/suite/partitions/r/partition_supported_sql_func_innodb.result: read data from file. mysql-test/suite/partitions/r/partition_supported_sql_func_myisam.result: read data from file. mysql-test/suite/partitions/t/disabled.def: added not executable test program. mysql-test/suite/partitions/t/partition_supported_sql_func_innodb.test: switched to long test. mysql-test/suite/partitions/t/partition_supported_sql_func_myisam.test: switched to long test BitKeeper/etc/ignore: Added mysql-test/suite/partitions/t/partition.test mysql-test/suite/partitions/r/dif mysql-test/suite/partitions/r/partition.result mysql-test/suite/partitions/r/partition_t55.out mysql-test/suite/partitions/r/partition_t55.refout to the ignore list mysql-test/suite/partitions/r/partition_supported_sql_func_ndb.result: new result file. mysql-test/suite/partitions/t/partition_supported_sql_func_ndb.test: ndb wrapper. mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in: inpu file. mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_date.in: input file mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_float.in: input file mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_int.in: input file mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_time.in: input file mysql-test/suite/partitions/r/partition_t55.out: reference fiel for output data to compare --- .bzrignore | 5 + .../suite/funcs_1/r/a_version_check.result | 2 +- .../include/partition_supported_sql_funcs.inc | 93 +- .../partition_supported_sql_funcs_delete.inc | 53 +- .../partition_supported_sql_funcs_int_ch1.in | 4 + .../partition_supported_sql_funcs_int_date.in | 4 + ...partition_supported_sql_funcs_int_float.in | 4 + .../partition_supported_sql_funcs_int_int.in | 45 + .../partition_supported_sql_funcs_int_time.in | 4 + .../partition_supported_sql_funcs_main.inc | 39 +- ...partition_supported_sql_func_innodb.result | 11023 +++++++++++-- ...partition_supported_sql_func_myisam.result | 11023 +++++++++++-- .../r/partition_supported_sql_func_ndb.result | 13724 ++++++++++++++++ .../suite/partitions/r/partition_t55.out | 68 + mysql-test/suite/partitions/t/disabled.def | 2 +- .../partition_supported_sql_func_innodb.test | 10 +- .../partition_supported_sql_func_myisam.test | 6 +- .../t/partition_supported_sql_func_ndb.test | 40 + 18 files changed, 34205 insertions(+), 1944 deletions(-) create mode 100644 mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_ch1.in create mode 100644 mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_date.in create mode 100644 mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_float.in create mode 100644 mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_int.in create mode 100644 mysql-test/suite/partitions/include/partition_supported_sql_funcs_int_time.in create mode 100644 mysql-test/suite/partitions/r/partition_supported_sql_func_ndb.result create mode 100644 mysql-test/suite/partitions/r/partition_t55.out create mode 100644 mysql-test/suite/partitions/t/partition_supported_sql_func_ndb.test diff --git a/.bzrignore b/.bzrignore index c04ce91b355..bb7712a277c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -2956,3 +2956,8 @@ win/vs71cache.txt win/vs8cache.txt zlib/*.ds? zlib/*.vcproj +mysql-test/suite/partitions/t/partition.test +mysql-test/suite/partitions/r/dif +mysql-test/suite/partitions/r/partition.result +mysql-test/suite/partitions/r/partition_t55.out +mysql-test/suite/partitions/r/partition_t55.refout 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 -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 +select * from t55 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 +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 +--------------------------- +---- 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 +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 ; @@ -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; -colint col1 -1 1 -2 9 -select * from t5; +9 +select * from t4 order by colint; colint col1 1 1 2 9 3 3 -select * from t6; +4 8 +select * from t5 order by colint; colint col1 -1 9 -2 3 +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) ------------------------------------------------------------------------- @@ -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 -9 3 -select * from t33; -col1 -1 +8 9 +select * from t33 order by col1; +col1 3 -select * from t44; +8 +9 +select * from t44 order by colint; colint col1 -1 1 -2 9 -select * from t55; -colint col1 -1 1 +1 8 2 9 3 3 -select * from t66; +4 8 +select * from t55 order by colint; colint col1 -1 9 -2 3 +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=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 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 ; @@ -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; -colint col1 -1 5.1230 -2 13.3450 -select * from t5; +select * from t4 order by colint; colint col1 1 5.1230 2 13.3450 3 17.9870 -select * from t6; +4 15.6540 +select * from t5 order by colint; colint col1 -1 13.3450 -2 17.9870 +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) ------------------------------------------------------------------------- @@ -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 -2 13.3450 -select * from t55; -colint col1 -1 5.1230 +1 15.6540 2 13.3450 3 17.9870 -select * from t66; +4 15.6540 +select * from t55 order by colint; colint col1 -1 13.3450 -2 17.9870 +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 +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 ; @@ -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; -colint col1 -1 5.1230 -2 13.3450 -select * from t5; +select * from t4 order by colint; colint col1 1 5.1230 2 13.3450 3 17.9870 -select * from t6; +4 15.6540 +select * from t5 order by colint; colint col1 -1 13.3450 -2 17.9870 +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) ------------------------------------------------------------------------- @@ -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 -2 13.3450 -select * from t55; -colint col1 -1 5.1230 +1 15.6540 2 13.3450 3 17.9870 -select * from t66; +4 15.6540 +select * from t55 order by colint; colint col1 -1 13.3450 -2 17.9870 +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 +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 ; @@ -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 -19.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 +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) ------------------------------------------------------------------------- @@ -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 -19.0000 +15.0000 17.0000 -select * from t33; -col1 -5.0000 19.0000 +select * from t33 order by col1; +col1 +15.0000 17.0000 -select * from t44; +19.0000 +select * from t44 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 t55 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 +select * from t66 order by colint; colint col1 -1 19.0000 -2 17.0000 +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=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 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 ; @@ -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; -colint col1 -1 1 -2 9 -select * from t5; +9 +select * from t4 order by colint; colint col1 1 1 2 9 3 3 -select * from t6; +4 8 +select * from t5 order by colint; colint col1 -1 9 -2 3 +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) ------------------------------------------------------------------------- @@ -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 -9 3 -select * from t33; -col1 -1 +8 9 +select * from t33 order by col1; +col1 3 -select * from t44; +8 +9 +select * from t44 order by colint; colint col1 -1 1 -2 9 -select * from t55; -colint col1 -1 1 +1 8 2 9 3 3 -select * from t66; +4 8 +select * from t55 order by colint; colint col1 -1 9 -2 3 +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=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 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 ; @@ -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; -colint col1 -1 2006-02-03 -2 2006-01-17 -select * from t5; +2006-02-03 +select * from t4 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 t5 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 +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) ------------------------------------------------------------------------- @@ -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 -2 2006-01-17 -select * from t55; -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 t55 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 +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 +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; -colint col1 -1 2006-02-03 -2 2006-01-17 -select * from t5; +2006-02-03 +select * from t4 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 t5 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 +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) ------------------------------------------------------------------------- @@ -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 -2 2006-01-17 -select * from t55; -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 t55 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 +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=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-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-02-17 2006-01-25 -select * from t4; +2006-02-17 +select * from t4 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t5; -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 t5 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 +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) ------------------------------------------------------------------------- @@ -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-02-17 2006-01-25 -select * from t33; -col1 -2006-01-03 +2006-02-05 2006-02-17 +select * from t33 order by col1; +col1 2006-01-25 -select * from t44; +2006-02-05 +2006-02-17 +select * from t44 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t55; -colint col1 -2 2006-02-17 +1 2006-02-03 +2 2006-01-17 3 2006-01-25 -1 2006-01-03 -select * from t66; +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 +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=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 +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 ; @@ -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 -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) ------------------------------------------------------------------------- @@ -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-02-17 2006-01-25 -select * from t4; +2006-02-17 +select * from t4 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t5; -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 t5 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 +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) ------------------------------------------------------------------------- @@ -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-02-17 2006-01-25 -select * from t33; -col1 -2006-01-03 +2006-02-05 2006-02-17 +select * from t33 order by col1; +col1 2006-01-25 -select * from t44; +2006-02-05 +2006-02-17 +select * from t44 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t55; -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 +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 +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=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 +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 ; @@ -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 -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 +select * from t6 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 +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) ------------------------------------------------------------------------- @@ -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; +select * from t44 order by colint; colint col1 -2 14:30:00 -1 09:09:00 -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 -2 14:30:00 -1 09:09:00 -3 21:59:00 -select * from t66; +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 14:30:00 -2 21:59:00 +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 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 ; @@ -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 -09:09:15 04:30:01 -select * from t2; +09:09:15 +select * from t2 order by col1; col1 -09:09:15 -04:30:01 00:59:22 -select * from t3; -col1 -09:09:15 04:30:01 +09:09:15 +select * from t3 order by col1; +col1 00:59:22 -select * from t4; -colint col1 -1 09:09:15 -2 04:30:01 -select * from t5; +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 -select * from t6; +4 05:30:34 +select * from t5 order by colint; colint col1 -1 04:30:01 -2 00:59:22 +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) ------------------------------------------------------------------------- @@ -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 -04:30:01 00:59:22 -select * from t33; -col1 -09:09:15 04:30:01 +05:30:34 +select * from t33 order by col1; +col1 00:59:22 -select * from t44; +04:30:01 +05:30:34 +select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -select * from t55; -colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 -select * from t66; +4 05:30:34 +select * from t55 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 +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=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 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 ; @@ -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 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: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) ------------------------------------------------------------------------- @@ -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 -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 +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) ------------------------------------------------------------------------- @@ -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 -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 t66 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 +--------------------------- +---- 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 +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 ; @@ -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 -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 +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) ------------------------------------------------------------------------- @@ -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 -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 +select * from t55 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 +select * from t66 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 +--------------------------- +---- 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 +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 ; @@ -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-12-17 2006-05-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-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 +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) ------------------------------------------------------------------------- @@ -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-12-17 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; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +select * from t55 order by colint; colint col1 -2 2006-12-17 -1 2006-01-03 -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-12-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-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 +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 ; @@ -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-12-17 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 +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) ------------------------------------------------------------------------- @@ -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-12-17 +2006-07-30 2006-09-25 -select * from t33; -col1 -2006-01-03 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 +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 +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 +--------------------------- +---- 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=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 +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 ; @@ -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 14:30:45 -2 21:59:22 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +--------------------------- +---- some alter table begin +--------------------------- +alter table t11 +reorganize partition p0,p1 into +(partition s1 values less than maxvalue); +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +alter table t11 +reorganize partition s1 into +(partition p0 values less than (15), +partition p1 values less than maxvalue); +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +alter table t55 +partition by list(colint) +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 +(partition p0 values in (1,2,3,4,5,6,7,8,9,10), +partition p1 values in (11,12,13,14,15,16,17,18,19,20), +partition p2 values in (21,22,23,24,25,26,27,28,29,30), +partition p3 values in (31,32,33,34,35,36,37,38,39,40), +partition p4 values in (41,42,43,44,45,46,47,48,49,50), +partition p5 values in (51,52,53,54,55,56,57,58,59,60) +); +show create table t55; +Table Create Table +t55 CREATE TABLE `t55` ( + `colint` int(11) DEFAULT NULL, + `col1` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ +select * from t55 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition p0,p1 into +(partition s1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition s1 into +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), +partition p1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition p0,p1 into +(partition s1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition s1 into +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), +partition p1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +------------------------------------------------------------------------- +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) +------------------------------------------------------------------------- +delete from t1 where col1='14:30:45'; +delete from t2 where col1='14:30:45'; +delete from t3 where col1='14:30:45'; +delete from t4 where col1='14:30:45'; +delete from t5 where col1='14:30:45'; +delete from t6 where col1='14:30:45'; +select * from t1 order by col1; +col1 +10:33:11 +select * from t2 order by col1; +col1 +10:33:11 +21:59:22 +select * from t3 order by col1; +col1 +10:33:11 +21:59:22 +select * from t4 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +select * from t5 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t1 values ('14:30:45'); +insert into t2 values ('14:30:45'); +insert into t3 values ('14:30:45'); +insert into t4 values (60,'14:30:45'); +insert into t5 values (60,'14:30:45'); +insert into t6 values (60,'14:30:45'); +select * from t1 order by col1; +col1 +10:33:11 +14:30:45 +select * from t2 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t3 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t4 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t5 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t6 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +alter table t1 drop partition p0; +alter table t2 drop partition p0; +alter table t4 drop partition p0; +alter table t5 drop partition p0; +alter table t6 drop partition p0; +select * from t1 order by col1; +col1 +10:33:11 +14:30:45 +select * from t2 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t3 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t4 order by colint; +colint col1 +60 14:30:45 +select * from t5 order by colint; +colint col1 +60 14:30:45 +select * from t6 order by colint; +colint col1 +------------------------------------------------------------------------- +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) +------------------------------------------------------------------------- +delete from t11 where col1='14:30:45'; +delete from t22 where col1='14:30:45'; +delete from t33 where col1='14:30:45'; +delete from t44 where col1='14:30:45'; +delete from t55 where col1='14:30:45'; +delete from t66 where col1='14:30:45'; +select * from t11 order by col1; +col1 +10:33:11 +select * from t22 order by col1; +col1 +10:33:11 +21:59:22 +select * from t33 order by col1; +col1 +10:33:11 +21:59:22 +select * from t44 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +select * from t55 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t11 values ('14:30:45'); +insert into t22 values ('14:30:45'); +insert into t33 values ('14:30:45'); +insert into t44 values (60,'14:30:45'); +insert into t55 values (60,'14:30:45'); +insert into t66 values (60,'14:30:45'); +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +select * from t22 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t33 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t44 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t55 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +alter table t11 drop partition p0; +alter table t22 drop partition p0; +alter table t44 drop partition p0; +alter table t55 drop partition p0; +alter table t66 drop partition p0; +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +select * from t22 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t33 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t44 order by colint; +colint col1 +60 14:30:45 +select * from t55 order by colint; +colint col1 +60 14:30:45 +select * from t66 order by colint; +colint col1 +------------------------- +---- some alter table end +------------------------- drop table if exists t1 ; drop table if exists t2 ; drop table if exists t3 ; @@ -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; -colint col1 2 2006-01-17 3 2006-01-25 -1 2006-02-03 -select * from t6; +4 2006-02-05 +select * from t5 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 +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') ------------------------------------------------------------------------- @@ -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; -colint col1 -2 2006-01-17 -1 2006-02-03 -select * from t55; +2006-02-06 +select * from t44 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 t55 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 +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=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-12-03 2006-11-17 -select * from t2; +2006-12-03 +select * from t2 order by col1; col1 -2006-12-03 -2006-11-17 2006-05-25 -select * from t3; -col1 -2006-12-03 2006-11-17 +2006-12-03 +select * from t3 order by col1; +col1 2006-05-25 -select * from t4; +2006-11-17 +2006-12-03 +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 +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) ------------------------------------------------------------------------- @@ -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-11-17 +2006-02-06 2006-05-25 -select * from t33; -col1 -2006-12-03 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 +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 +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 +--------------------------- +---- 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=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 +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 ; @@ -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 2000-02-17 -2 2004-05-25 +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 ------------------------------------------------------------------------- @@ -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 -1996-01-03 2000-02-17 +2002-02-15 2004-05-25 -select * from t44; +select * from t44 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 +select * from t55 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 +select * from t66 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 +--------------------------- +---- 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 +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 ; @@ -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-08-17 2006-03-25 -select * from t4; +2006-08-17 +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 +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 ------------------------------------------------------------------------- @@ -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-01-03 -2006-08-17 2006-03-25 -select * from t44; +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; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +select * from t55 order by colint; colint col1 -3 2006-03-25 -1 2006-01-03 -2 2006-08-17 -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-08-17 -2 2006-03-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-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 +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 ; 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 -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 +select * from t55 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 +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 +--------------------------- +---- 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 +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 ; @@ -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; -colint col1 -1 1 -2 9 -select * from t5; +9 +select * from t4 order by colint; colint col1 1 1 2 9 3 3 -select * from t6; +4 8 +select * from t5 order by colint; colint col1 -1 9 -2 3 +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) ------------------------------------------------------------------------- @@ -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 -9 3 -select * from t33; -col1 -1 +8 9 +select * from t33 order by col1; +col1 3 -select * from t44; +8 +9 +select * from t44 order by colint; colint col1 -1 1 -2 9 -select * from t55; -colint col1 -1 1 +1 8 2 9 3 3 -select * from t66; +4 8 +select * from t55 order by colint; colint col1 -1 9 -2 3 +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=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 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 ; @@ -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; -colint col1 -1 5.1230 -2 13.3450 -select * from t5; +select * from t4 order by colint; colint col1 1 5.1230 2 13.3450 3 17.9870 -select * from t6; +4 15.6540 +select * from t5 order by colint; colint col1 -1 13.3450 -2 17.9870 +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) ------------------------------------------------------------------------- @@ -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 -2 13.3450 -select * from t55; -colint col1 -1 5.1230 +1 15.6540 2 13.3450 3 17.9870 -select * from t66; +4 15.6540 +select * from t55 order by colint; colint col1 -1 13.3450 -2 17.9870 +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 +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 ; @@ -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; -colint col1 -1 5.1230 -2 13.3450 -select * from t5; +select * from t4 order by colint; colint col1 1 5.1230 2 13.3450 3 17.9870 -select * from t6; +4 15.6540 +select * from t5 order by colint; colint col1 -1 13.3450 -2 17.9870 +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) ------------------------------------------------------------------------- @@ -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 -2 13.3450 -select * from t55; -colint col1 -1 5.1230 +1 15.6540 2 13.3450 3 17.9870 -select * from t66; +4 15.6540 +select * from t55 order by colint; colint col1 -1 13.3450 -2 17.9870 +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 +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 ; @@ -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 -19.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 +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) ------------------------------------------------------------------------- @@ -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 -19.0000 +15.0000 17.0000 -select * from t33; -col1 -5.0000 19.0000 +select * from t33 order by col1; +col1 +15.0000 17.0000 -select * from t44; +19.0000 +select * from t44 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 t55 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 +select * from t66 order by colint; colint col1 -1 19.0000 -2 17.0000 +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=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 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 ; @@ -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; -colint col1 -1 1 -2 9 -select * from t5; +9 +select * from t4 order by colint; colint col1 1 1 2 9 3 3 -select * from t6; +4 8 +select * from t5 order by colint; colint col1 -1 9 -2 3 +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) ------------------------------------------------------------------------- @@ -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 -9 3 -select * from t33; -col1 -1 +8 9 +select * from t33 order by col1; +col1 3 -select * from t44; +8 +9 +select * from t44 order by colint; colint col1 -1 1 -2 9 -select * from t55; -colint col1 -1 1 +1 8 2 9 3 3 -select * from t66; +4 8 +select * from t55 order by colint; colint col1 -1 9 -2 3 +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=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 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 ; @@ -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; -colint col1 -1 2006-02-03 -2 2006-01-17 -select * from t5; +2006-02-03 +select * from t4 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 t5 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 +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) ------------------------------------------------------------------------- @@ -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 -2 2006-01-17 -select * from t55; -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 t55 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 +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 +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; -colint col1 -1 2006-02-03 -2 2006-01-17 -select * from t5; +2006-02-03 +select * from t4 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 t5 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 +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) ------------------------------------------------------------------------- @@ -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 -2 2006-01-17 -select * from t55; -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 t55 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 +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=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-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-02-17 2006-01-25 -select * from t4; +2006-02-17 +select * from t4 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t5; -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 t5 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 +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) ------------------------------------------------------------------------- @@ -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-02-17 2006-01-25 -select * from t33; -col1 -2006-01-03 +2006-02-05 2006-02-17 +select * from t33 order by col1; +col1 2006-01-25 -select * from t44; +2006-02-05 +2006-02-17 +select * from t44 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t55; -colint col1 -2 2006-02-17 +1 2006-02-03 +2 2006-01-17 3 2006-01-25 -1 2006-01-03 -select * from t66; +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 +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=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 +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 ; @@ -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 -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) ------------------------------------------------------------------------- @@ -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-02-17 2006-01-25 -select * from t4; +2006-02-17 +select * from t4 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t5; -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 t5 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 +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) ------------------------------------------------------------------------- @@ -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-02-17 2006-01-25 -select * from t33; -col1 -2006-01-03 +2006-02-05 2006-02-17 +select * from t33 order by col1; +col1 2006-01-25 -select * from t44; +2006-02-05 +2006-02-17 +select * from t44 order by colint; colint col1 -2 2006-02-17 -1 2006-01-03 -select * from t55; -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 +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 +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=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 +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 ; @@ -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 -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 +select * from t6 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 +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) ------------------------------------------------------------------------- @@ -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; +select * from t44 order by colint; colint col1 -2 14:30:00 -1 09:09:00 -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 -2 14:30:00 -1 09:09:00 -3 21:59:00 -select * from t66; +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 14:30:00 -2 21:59:00 +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 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 ; @@ -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 -09:09:15 04:30:01 -select * from t2; +09:09:15 +select * from t2 order by col1; col1 -09:09:15 -04:30:01 00:59:22 -select * from t3; -col1 -09:09:15 04:30:01 +09:09:15 +select * from t3 order by col1; +col1 00:59:22 -select * from t4; -colint col1 -1 09:09:15 -2 04:30:01 -select * from t5; +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 -select * from t6; +4 05:30:34 +select * from t5 order by colint; colint col1 -1 04:30:01 -2 00:59:22 +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) ------------------------------------------------------------------------- @@ -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 -04:30:01 00:59:22 -select * from t33; -col1 -09:09:15 04:30:01 +05:30:34 +select * from t33 order by col1; +col1 00:59:22 -select * from t44; +04:30:01 +05:30:34 +select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -select * from t55; -colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 -select * from t66; +4 05:30:34 +select * from t55 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 +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=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 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 ; @@ -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 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: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) ------------------------------------------------------------------------- @@ -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 -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 +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) ------------------------------------------------------------------------- @@ -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 -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 t66 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 +--------------------------- +---- 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 +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 ; @@ -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 -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 +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) ------------------------------------------------------------------------- @@ -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 -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 +select * from t55 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 +select * from t66 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 +--------------------------- +---- 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 +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 ; @@ -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-12-17 2006-05-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-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 +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) ------------------------------------------------------------------------- @@ -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-12-17 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; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +select * from t55 order by colint; colint col1 -2 2006-12-17 -1 2006-01-03 -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-12-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-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 +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 ; @@ -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-12-17 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 +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) ------------------------------------------------------------------------- @@ -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-12-17 +2006-07-30 2006-09-25 -select * from t33; -col1 -2006-01-03 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 +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 +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 +--------------------------- +---- 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=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 +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 ; @@ -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 14:30:45 -2 21:59:22 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +--------------------------- +---- some alter table begin +--------------------------- +alter table t11 +reorganize partition p0,p1 into +(partition s1 values less than maxvalue); +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +alter table t11 +reorganize partition s1 into +(partition p0 values less than (15), +partition p1 values less than maxvalue); +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +alter table t55 +partition by list(colint) +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 +(partition p0 values in (1,2,3,4,5,6,7,8,9,10), +partition p1 values in (11,12,13,14,15,16,17,18,19,20), +partition p2 values in (21,22,23,24,25,26,27,28,29,30), +partition p3 values in (31,32,33,34,35,36,37,38,39,40), +partition p4 values in (41,42,43,44,45,46,47,48,49,50), +partition p5 values in (51,52,53,54,55,56,57,58,59,60) +); +show create table t55; +Table Create Table +t55 CREATE TABLE `t55` ( + `colint` int(11) DEFAULT NULL, + `col1` time DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM, PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = MyISAM, PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = MyISAM, PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ +select * from t55 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition p0,p1 into +(partition s1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition s1 into +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), +partition p1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition p0,p1 into +(partition s1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +alter table t66 +reorganize partition s1 into +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), +partition p1 values less than maxvalue); +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +------------------------------------------------------------------------- +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) +------------------------------------------------------------------------- +delete from t1 where col1='14:30:45'; +delete from t2 where col1='14:30:45'; +delete from t3 where col1='14:30:45'; +delete from t4 where col1='14:30:45'; +delete from t5 where col1='14:30:45'; +delete from t6 where col1='14:30:45'; +select * from t1 order by col1; +col1 +10:33:11 +select * from t2 order by col1; +col1 +10:33:11 +21:59:22 +select * from t3 order by col1; +col1 +10:33:11 +21:59:22 +select * from t4 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +select * from t5 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t1 values ('14:30:45'); +insert into t2 values ('14:30:45'); +insert into t3 values ('14:30:45'); +insert into t4 values (60,'14:30:45'); +insert into t5 values (60,'14:30:45'); +insert into t6 values (60,'14:30:45'); +select * from t1 order by col1; +col1 +10:33:11 +14:30:45 +select * from t2 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t3 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t4 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t5 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t6 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +alter table t1 drop partition p0; +alter table t2 drop partition p0; +alter table t4 drop partition p0; +alter table t5 drop partition p0; +alter table t6 drop partition p0; +select * from t1 order by col1; +col1 +10:33:11 +14:30:45 +select * from t2 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t3 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t4 order by colint; +colint col1 +60 14:30:45 +select * from t5 order by colint; +colint col1 +60 14:30:45 +select * from t6 order by colint; +colint col1 +------------------------------------------------------------------------- +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) +------------------------------------------------------------------------- +delete from t11 where col1='14:30:45'; +delete from t22 where col1='14:30:45'; +delete from t33 where col1='14:30:45'; +delete from t44 where col1='14:30:45'; +delete from t55 where col1='14:30:45'; +delete from t66 where col1='14:30:45'; +select * from t11 order by col1; +col1 +10:33:11 +select * from t22 order by col1; +col1 +10:33:11 +21:59:22 +select * from t33 order by col1; +col1 +10:33:11 +21:59:22 +select * from t44 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +select * from t55 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t11 values ('14:30:45'); +insert into t22 values ('14:30:45'); +insert into t33 values ('14:30:45'); +insert into t44 values (60,'14:30:45'); +insert into t55 values (60,'14:30:45'); +insert into t66 values (60,'14:30:45'); +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +select * from t22 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t33 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t44 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t55 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +select * from t66 order by colint; +colint col1 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 +alter table t11 drop partition p0; +alter table t22 drop partition p0; +alter table t44 drop partition p0; +alter table t55 drop partition p0; +alter table t66 drop partition p0; +select * from t11 order by col1; +col1 +10:33:11 +14:30:45 +select * from t22 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t33 order by col1; +col1 +10:33:11 +14:30:45 +21:59:22 +select * from t44 order by colint; +colint col1 +60 14:30:45 +select * from t55 order by colint; +colint col1 +60 14:30:45 +select * from t66 order by colint; +colint col1 +------------------------- +---- some alter table end +------------------------- drop table if exists t1 ; drop table if exists t2 ; drop table if exists t3 ; @@ -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; -colint col1 2 2006-01-17 3 2006-01-25 -1 2006-02-03 -select * from t6; +4 2006-02-05 +select * from t5 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 +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') ------------------------------------------------------------------------- @@ -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; -colint col1 -2 2006-01-17 -1 2006-02-03 -select * from t55; +2006-02-06 +select * from t44 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 t55 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 +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=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-12-03 2006-11-17 -select * from t2; +2006-12-03 +select * from t2 order by col1; col1 -2006-12-03 -2006-11-17 2006-05-25 -select * from t3; -col1 -2006-12-03 2006-11-17 +2006-12-03 +select * from t3 order by col1; +col1 2006-05-25 -select * from t4; +2006-11-17 +2006-12-03 +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 +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) ------------------------------------------------------------------------- @@ -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-11-17 +2006-02-06 2006-05-25 -select * from t33; -col1 -2006-12-03 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 +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 +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 +--------------------------- +---- 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=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 +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 ; @@ -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 2000-02-17 -2 2004-05-25 +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 ------------------------------------------------------------------------- @@ -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 -1996-01-03 2000-02-17 +2002-02-15 2004-05-25 -select * from t44; +select * from t44 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 +select * from t55 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 +select * from t66 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 +--------------------------- +---- 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 +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 ; @@ -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-08-17 2006-03-25 -select * from t4; +2006-08-17 +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 +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 ------------------------------------------------------------------------- @@ -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-01-03 -2006-08-17 2006-03-25 -select * from t44; +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; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +select * from t55 order by colint; colint col1 -3 2006-03-25 -1 2006-01-03 -2 2006-08-17 -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-08-17 -2 2006-03-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-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 +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 ; 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 + From b89367f2f8ad437551a449825f0e03dea553fcce Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Apr 2007 22:34:33 +0300 Subject: [PATCH 36/83] Fixes for tests after merge from 5.0 mysql-test/r/grant.result: Fixed a result. Editor added wrong characters. mysql-test/r/mysqlbinlog2.result: Fixed mysql-test/r/sp.result: Fixed a result, moved lines around. mysql-test/r/sp_trans.result: Fixed a result, moved lines around. mysql-test/t/mysqlbinlog2.test: Merged tests from 5.0 mysql-test/t/sp_trans.test: Merged test from 5.0 and fixed to be compatible with 5.1 sql/sql_class.cc: Merged from 5.0 sql/sql_error.cc: Fixed push_warning() --- mysql-test/r/grant.result | 60 +++++------ mysql-test/r/mysqlbinlog2.result | 2 - mysql-test/r/sp.result | 169 ++++++++++++++++--------------- mysql-test/r/sp_trans.result | 46 +++++---- mysql-test/t/mysqlbinlog2.test | 10 +- mysql-test/t/sp_trans.test | 4 +- sql/sql_class.cc | 2 + sql/sql_error.cc | 10 +- 8 files changed, 151 insertions(+), 152 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 7bfe8a33f02..4fa61210339 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -260,29 +260,29 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C GRANT SELECT, INSERT, UPDATE ON `test`.* TO 'mysqltest_1'@'localhost' drop user mysqltest_1@localhost; SET NAMES koi8r; -CREATE DATABASE ツト; -USE ツト; -CREATE TABLE ï¾”ï¾ï¾‚ (ヒï¾ï¾Œ int); -GRANT SELECT ON ツト.* TO タレナメ@localhost; -SHOW GRANTS FOR タレナメ@localhost; -Grants for タレナメ@localhost -GRANT USAGE ON *.* TO 'タレナメ'@'localhost' -GRANT SELECT ON `ツト`.* TO 'タレナメ'@'localhost' -REVOKE SELECT ON ツト.* FROM タレナメ@localhost; -GRANT SELECT ON ツト.ï¾”ï¾ï¾‚ TO タレナメ@localhost; -SHOW GRANTS FOR タレナメ@localhost; -Grants for タレナメ@localhost -GRANT USAGE ON *.* TO 'タレナメ'@'localhost' -GRANT SELECT ON `ツト`.`ï¾”ï¾ï¾‚` TO 'タレナメ'@'localhost' -REVOKE SELECT ON ツト.ï¾”ï¾ï¾‚ FROM タレナメ@localhost; -GRANT SELECT (ヒï¾ï¾Œ) ON ツト.ï¾”ï¾ï¾‚ TO タレナメ@localhost; -SHOW GRANTS FOR タレナメ@localhost; -Grants for タレナメ@localhost -GRANT USAGE ON *.* TO 'タレナメ'@'localhost' -GRANT SELECT (ヒï¾ï¾Œ) ON `ツト`.`ï¾”ï¾ï¾‚` TO 'タレナメ'@'localhost' -REVOKE SELECT (ヒï¾ï¾Œ) ON ツト.ï¾”ï¾ï¾‚ FROM タレナメ@localhost; -DROP USER タレナメ@localhost; -DROP DATABASE ツト; +CREATE DATABASE ÂÄ; +USE ÂÄ; +CREATE TABLE ÔÁ (ËÏÌ int); +GRANT SELECT ON ÂÄ.* TO ÀÚÅÒ@localhost; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +Grants for ÀÚÅÒ@localhost +GRANT USAGE ON *.* TO 'ÀÚÅÒ'@'localhost' +GRANT SELECT ON `ÂÄ`.* TO 'ÀÚÅÒ'@'localhost' +REVOKE SELECT ON ÂÄ.* FROM ÀÚÅÒ@localhost; +GRANT SELECT ON ÂÄ.ÔÁ TO ÀÚÅÒ@localhost; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +Grants for ÀÚÅÒ@localhost +GRANT USAGE ON *.* TO 'ÀÚÅÒ'@'localhost' +GRANT SELECT ON `ÂÄ`.`ÔÁÂ` TO 'ÀÚÅÒ'@'localhost' +REVOKE SELECT ON ÂÄ.ÔÁ FROM ÀÚÅÒ@localhost; +GRANT SELECT (ËÏÌ) ON ÂÄ.ÔÁ TO ÀÚÅÒ@localhost; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +Grants for ÀÚÅÒ@localhost +GRANT USAGE ON *.* TO 'ÀÚÅÒ'@'localhost' +GRANT SELECT (ËÏÌ) ON `ÂÄ`.`ÔÁÂ` TO 'ÀÚÅÒ'@'localhost' +REVOKE SELECT (ËÏÌ) ON ÂÄ.ÔÁ FROM ÀÚÅÒ@localhost; +DROP USER ÀÚÅÒ@localhost; +DROP DATABASE ÂÄ; SET NAMES latin1; USE test; CREATE TABLE t1 (a int ); @@ -613,22 +613,22 @@ set @user123="non-existent"; select * from mysql.db where user=@user123; Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Execute_priv Event_priv Trigger_priv set names koi8r; -create database ツト; -grant select on ツト.* to root@localhost; -select hex(Db) from mysql.db where Db='ツト'; +create database ÂÄ; +grant select on ÂÄ.* to root@localhost; +select hex(Db) from mysql.db where Db='ÂÄ'; hex(Db) D0B1D0B4 show grants for root@localhost; Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION -GRANT SELECT ON `ツト`.* TO 'root'@'localhost' +GRANT SELECT ON `ÂÄ`.* TO 'root'@'localhost' flush privileges; show grants for root@localhost; Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION -GRANT SELECT ON `ツト`.* TO 'root'@'localhost' -drop database ツト; -revoke all privileges on ツト.* from root@localhost; +GRANT SELECT ON `ÂÄ`.* TO 'root'@'localhost' +drop database ÂÄ; +revoke all privileges on ÂÄ.* from root@localhost; show grants for root@localhost; Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION diff --git a/mysql-test/r/mysqlbinlog2.result b/mysql-test/r/mysqlbinlog2.result index 8ca18b70e69..ef6e4ee80fd 100644 --- a/mysql-test/r/mysqlbinlog2.result +++ b/mysql-test/r/mysqlbinlog2.result @@ -134,7 +134,6 @@ 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")/*!*/; -SET INSERT_ID=5/*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -512,7 +511,6 @@ 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")/*!*/; -SET INSERT_ID=5/*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index aa3d7b160c9..676332e6f03 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5643,90 +5643,6 @@ t3_id_1 t3_id_2 t4_id DROP PROCEDURE p1| DROP VIEW v1, v2| DROP TABLE t3, t4| -drop function if exists bug20777| -drop table if exists examplebug20777| -create function bug20777(f1 bigint unsigned) returns bigint unsigned -begin -set f1 = (f1 - 10); set f1 = (f1 10); -return f1; -end| -select bug20777(9223372036854775803) as '9223372036854775803 2**63-5'; -9223372036854775803 2**63-5 -9223372036854775803 -select bug20777(9223372036854775804) as '9223372036854775804 2**63-4'; -9223372036854775804 2**63-4 -9223372036854775804 -select bug20777(9223372036854775805) as '9223372036854775805 2**63-3'; -9223372036854775805 2**63-3 -9223372036854775805 -select bug20777(9223372036854775806) as '9223372036854775806 2**63-2'; -9223372036854775806 2**63-2 -9223372036854775806 -select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; -9223372036854775807 2**63-1 -9223372036854775807 -select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; -9223372036854775808 2**63+0 -9223372036854775808 -select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; -9223372036854775809 2**63+1 -9223372036854775809 -select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; -9223372036854775810 2**63+2 -9223372036854775810 -select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; -lower bounds signed bigint -0 -select bug20777(9223372036854775807) as 'upper bounds signed bigint'; -upper bounds signed bigint -9223372036854775807 -select bug20777(0) as 'lower bounds unsigned bigint'; -lower bounds unsigned bigint -0 -select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; -upper bounds unsigned bigint -18446744073709551615 -select bug20777(18446744073709551616) as 'upper bounds unsigned bigint 1'; -upper bounds unsigned bigint 1 -18446744073709551615 -select bug20777(-1) as 'lower bounds unsigned bigint - 1'; -lower bounds unsigned bigint - 1 -0 -create table examplebug20777 as select -0 as 'i', -bug20777(9223372036854775806) as '2**63-2', -bug20777(9223372036854775807) as '2**63-1', -bug20777(9223372036854775808) as '2**63', -bug20777(9223372036854775809) as '2**63+1', -bug20777(18446744073709551614) as '2**64-2', -bug20777(18446744073709551615) as '2**64-1', -bug20777(18446744073709551616) as '2**64', -bug20777(0) as '0', -bug20777(-1) as '-1'; -insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1); -show create table examplebug20777; -Table Create Table -examplebug20777 CREATE TABLE `examplebug20777` ( - `i` int(1) NOT NULL DEFAULT '0', - `2**63-2` bigint(20) unsigned DEFAULT NULL, - `2**63-1` bigint(20) unsigned DEFAULT NULL, - `2**63` bigint(20) unsigned DEFAULT NULL, - `2**63+1` bigint(20) unsigned DEFAULT NULL, - `2**64-2` bigint(20) unsigned DEFAULT NULL, - `2**64-1` bigint(20) unsigned DEFAULT NULL, - `2**64` bigint(20) unsigned DEFAULT NULL, - `0` bigint(20) unsigned DEFAULT NULL, - `-1` bigint(20) unsigned DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -select * from examplebug20777 order by i; -i 2**63-2 2**63-1 2**63 2**63+1 2**64-2 2**64-1 2**64 0 -1 -0 9223372036854775806 9223372036854775807 9223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 18446744073709551615 0 0 -1 9223372036854775806 9223372036854775807 223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 8446744073709551616 0 0 -drop table examplebug20777; -select bug20777(18446744073709551613)+1; -bug20777(18446744073709551613)+1 -18446744073709551614 -drop function bug20777; End of 5.0 tests Begin of 5.1 tests drop function if exists pi; @@ -6160,6 +6076,91 @@ 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 +begin +set f1 = (f1 - 10); set f1 = (f1 + 10); +return f1; +end| +select bug20777(9223372036854775803) as '9223372036854775803 2**63-5'; +9223372036854775803 2**63-5 +9223372036854775803 +select bug20777(9223372036854775804) as '9223372036854775804 2**63-4'; +9223372036854775804 2**63-4 +9223372036854775804 +select bug20777(9223372036854775805) as '9223372036854775805 2**63-3'; +9223372036854775805 2**63-3 +9223372036854775805 +select bug20777(9223372036854775806) as '9223372036854775806 2**63-2'; +9223372036854775806 2**63-2 +9223372036854775806 +select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; +9223372036854775807 2**63-1 +9223372036854775807 +select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; +9223372036854775808 2**63+0 +9223372036854775808 +select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; +9223372036854775809 2**63+1 +9223372036854775809 +select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; +9223372036854775810 2**63+2 +9223372036854775810 +select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; +lower bounds signed bigint +0 +select bug20777(9223372036854775807) as 'upper bounds signed bigint'; +upper bounds signed bigint +9223372036854775807 +select bug20777(0) as 'lower bounds unsigned bigint'; +lower bounds unsigned bigint +0 +select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; +upper bounds unsigned bigint +18446744073709551615 +select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; +upper bounds unsigned bigint + 1 +18446744073709551615 +select bug20777(-1) as 'lower bounds unsigned bigint - 1'; +lower bounds unsigned bigint - 1 +0 +create table examplebug20777 as select +0 as 'i', +bug20777(9223372036854775806) as '2**63-2', +bug20777(9223372036854775807) as '2**63-1', +bug20777(9223372036854775808) as '2**63', +bug20777(9223372036854775809) as '2**63+1', +bug20777(18446744073709551614) as '2**64-2', +bug20777(18446744073709551615) as '2**64-1', +bug20777(18446744073709551616) as '2**64', +bug20777(0) as '0', +bug20777(-1) as '-1'; +insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1); +show create table examplebug20777; +Table Create Table +examplebug20777 CREATE TABLE `examplebug20777` ( + `i` int(1) NOT NULL DEFAULT '0', + `2**63-2` bigint(20) unsigned DEFAULT NULL, + `2**63-1` bigint(20) unsigned DEFAULT NULL, + `2**63` bigint(20) unsigned DEFAULT NULL, + `2**63+1` bigint(20) unsigned DEFAULT NULL, + `2**64-2` bigint(20) unsigned DEFAULT NULL, + `2**64-1` bigint(20) unsigned DEFAULT NULL, + `2**64` bigint(20) unsigned DEFAULT NULL, + `0` bigint(20) unsigned DEFAULT NULL, + `-1` bigint(20) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from examplebug20777 order by i; +i 2**63-2 2**63-1 2**63 2**63+1 2**64-2 2**64-1 2**64 0 -1 +0 9223372036854775806 9223372036854775807 9223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 18446744073709551615 0 0 +1 9223372036854775806 9223372036854775807 223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 8446744073709551616 0 0 +drop table examplebug20777; +select bug20777(18446744073709551613)+1; +bug20777(18446744073709551613)+1 +18446744073709551614 +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; diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index daf77b80d6e..c976ea7a415 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -530,27 +530,6 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| -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 1 -show binlog events from 98 /* with fixes for #23333 will show there is the query */| -Log_name Pos Event_type Server_id End_log_pos Info -select count(*),@a from t1 /* must be 1,1 */| -count(*) @a -1 1 CREATE DATABASE db_bug7787| use db_bug7787| CREATE PROCEDURE p1() @@ -577,3 +556,28 @@ f1 bug13575(f1) 3 ccc drop function bug13575| drop table t3| +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 diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index a7014706f09..ac647f772b1 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -60,7 +60,7 @@ select "--- stop-position --" as ""; --disable_query_log select "--- start and stop positions ---" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 $MYSQLTEST_VARDIR/log/master-bin.000001 +--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 @@ -115,14 +115,14 @@ select "--- start-position --" as ""; --enable_query_log --exec $MYSQL_BINLOG --short-form --start-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=600 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 ---disable_query_log 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/sp_trans.test b/mysql-test/t/sp_trans.test index 4925dc0eba2..d57fb980956 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -617,10 +617,10 @@ begin end| reset master| ---error ER_DUP_ENTRY +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 values (bug23333(),1)| --replace_column 2 # 5 # 6 # -show binlog events from 98 /* with fixes for #23333 will show there is the query */| +show binlog events from 106 /* with fixes for #23333 will show there is the query */| select count(*),@a from t1 /* must be 1,1 */| # diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b952251ce09..944d343164f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -367,6 +367,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 : @@ -437,6 +438,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) { diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 70882d8f4e8..f551a7ef4b2 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))) + /* 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->mem_root= old_root; } thd->warn_count[(uint) level]++; thd->total_warn_count++; From e6e1ce7abca03736a4c1fb187ce522ef6d817bb9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 7 Apr 2007 04:14:44 +0200 Subject: [PATCH 37/83] mysql.spec.sh: Removed man page for "mysql_create_system_tables" support-files/mysql.spec.sh: Removed man page for "mysql_create_system_tables" --- support-files/mysql.spec.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 39e3ada88d6..54e2a6adba6 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -556,7 +556,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_explain_log %attr(755, root, root) %{_bindir}/mysql_fix_extensions %attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables @@ -716,6 +715,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Sat Apr 07 2007 Kent Boortz + +- Removed man page for "mysql_create_system_tables" + * Wed Mar 21 2007 Daniel Fischer - Add debug server. From eaff83cb0ace80ec2165d5dba9b45284b4500e15 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 10:05:01 +0200 Subject: [PATCH 38/83] ndb - bug#27728 (5.1) Make sure API is connected to nodes when subscribing storage/ndb/include/kernel/signaldata/SumaImpl.hpp: new error code storage/ndb/src/kernel/blocks/suma/Suma.cpp: make sure API is connected in SUB_START_REQ storage/ndb/src/ndbapi/ndberror.c: new error code --- storage/ndb/include/kernel/signaldata/SumaImpl.hpp | 3 ++- storage/ndb/src/kernel/blocks/suma/Suma.cpp | 10 ++++++++++ storage/ndb/src/ndbapi/ndberror.c | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/storage/ndb/include/kernel/signaldata/SumaImpl.hpp b/storage/ndb/include/kernel/signaldata/SumaImpl.hpp index 077ea8e879c..072c3955ac4 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/src/kernel/blocks/suma/Suma.cpp b/storage/ndb/src/kernel/blocks/suma/Suma.cpp index 1197ffdad94..717448ca03b 100644 --- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp @@ -2394,6 +2394,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/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index 13e6c95644c..ed3829ed74f 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -490,6 +490,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" }, From 01a007a5663adf2d63fbfbb55138642eb624fd1e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 10:15:35 +0200 Subject: [PATCH 39/83] ndb - bug#27651 (5.1) Only prepare "next" GCI if we're in the first 4 highest GCI's to avoid we can get several buckets with same GCI storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp: Only prepare "next" GCI if we're in the first 4 highest GCI's to avoid we can get several buckets with same GCI --- .../ndb/src/ndbapi/NdbEventOperationImpl.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index 828ba51bc21..b75bfb16dd2 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -979,7 +979,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), @@ -1470,7 +1470,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)) { /** @@ -1515,8 +1515,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(); From 05285a62ae635e42b787ab014128e84aea84abfb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 10:27:02 +0200 Subject: [PATCH 40/83] ndb - add event log listener test tool storage/ndb/test/tools/Makefile.am: add event log listener test tool storage/ndb/test/tools/log_listner.cpp: New BitKeeper file ``storage/ndb/test/tools/log_listner.cpp'' --- storage/ndb/test/tools/Makefile.am | 3 +- storage/ndb/test/tools/log_listner.cpp | 88 ++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 storage/ndb/test/tools/log_listner.cpp diff --git a/storage/ndb/test/tools/Makefile.am b/storage/ndb/test/tools/Makefile.am index 8c451c0b6a1..1ec6246ce74 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 +#include +#include +#include + +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; +} From d6a3989a2325e8882fc0d725a220155e33af7ff4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 11:31:45 +0200 Subject: [PATCH 41/83] add a manual page back support-files/mysql.spec.sh: add mysql_install_db.1 back --- support-files/mysql.spec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 99fcfdc9b39..506cdf70604 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -556,6 +556,7 @@ fi %doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1* +%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1 %doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1* From 5ded16c5d0830b4b84830e3e17bc63dd099492aa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 15:01:04 +0500 Subject: [PATCH 42/83] Bug#27069 set with identical elements are created(additional fix) issue an error in strict mode if enum|set column has duplicates members in 'create table' mysql-test/r/strict.result: test case mysql-test/t/strict.test: test case sql/sql_table.cc: issue an error in strict mode if enum|set has duplicates members --- mysql-test/r/strict.result | 5 +++++ mysql-test/t/strict.test | 9 +++++++++ sql/sql_table.cc | 27 +++++++++++++++++++-------- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 636a00a4343..f9d84df5d9f 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -1386,4 +1386,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/t/strict.test b/mysql-test/t/strict.test index 5e4d956527b..1792c0fccbc 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/sql/sql_table.cc b/sql/sql_table.cc index 607fc4c5040..f498d33191b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -414,10 +414,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) { @@ -433,6 +434,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), @@ -440,6 +448,7 @@ void check_duplicates_in_interval(const char *set_or_name, (*dup_val_count)++; } } + return 0; } @@ -575,9 +584,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 FIELD_TYPE_SET: sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) | @@ -585,9 +595,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) { From d75aa05538993927ccdba80641d092b319529bb5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 15:26:35 +0200 Subject: [PATCH 43/83] Bug#27171 mysqlbinlog produces different output depends from option -R a better fix, that works with 4.1 servers which don't send a fake Format_description_log_event. --- client/mysqlbinlog.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index bb417293e8c..a371981e24d 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1042,7 +1042,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, uint logname_len; NET* net; int error= 0; - my_off_t old_off= min(start_position_mot, BIN_LOG_HEADER_SIZE); + my_off_t old_off= start_position_mot; char fname[FN_REFLEN+1]; DBUG_ENTER("dump_remote_log_entries"); @@ -1160,6 +1160,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); @@ -1172,16 +1184,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; } @@ -1196,15 +1208,8 @@ could be out of memory"); /* Let's adjust offset for remote log as for local log to produce similar text and to have --stop-position to work identically. - - Exception - the server sends Format_description_log_event - in the beginning of the dump, and only after it the event from - start_position. Let the old_off reflect it. */ - if (old_off < start_position_mot) - old_off= start_position_mot; - else - old_off+= len-1; + old_off+= len-1; } err: From 041767e12319c1f4e72a862408f87e97bc6bd587 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 16:55:48 +0300 Subject: [PATCH 44/83] Bug #27659: The optimizer transforms DISTINCT into a GROUP BY when possible. It does that by constructing the same structure (a list of ORDER instances) the parser makes when parsing GROUP BY. While doing that it also eliminates duplicates. But if a duplicate is found it doesn't advance the pointer to ref_pointer array, so the next (and subsequent) ORDER structures point to the wrong element in the SELECT list. Fixed by advancing the pointer in ref_pointer_array even in the case of a duplicate. mysql-test/r/distinct.result: Bug #27659: test case mysql-test/t/distinct.test: Bug #27659: test case sql/sql_select.cc: Bug #27659: use correct ref_pointer_array element --- mysql-test/r/distinct.result | 14 ++++++++++++++ mysql-test/t/distinct.test | 13 +++++++++++++ sql/sql_select.cc | 5 ++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 3508a83a810..190e8595126 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/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/sql/sql_select.cc b/sql/sql_select.cc index d65ecb6fa3b..79ae4ade8ab 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13539,9 +13539,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) @@ -13556,6 +13554,7 @@ create_distinct_group(THD *thd, Item **ref_pointer_array, *prev=ord; prev= &ord->next; } +next_item: ref_pointer_array++; } *prev=0; From d66e47213d4553c76985ba5ef85b3bd8a249e5e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 18:01:29 +0300 Subject: [PATCH 45/83] Small fixes for merge. mysql-test/include/not_embedded.inc: Fixed a typo. mysql-test/lib/mtr_cases.pl: Fixed typo and wrong error message. mysql-test/r/binlog_statement_insert_delayed.result: Fixed result file. sql/event_db_repository.cc: Fixed type. sql/log.cc: Fixed type. --- mysql-test/include/not_embedded.inc | 2 +- mysql-test/lib/mtr_cases.pl | 4 ++-- mysql-test/r/binlog_statement_insert_delayed.result | 12 ++++++------ sql/event_db_repository.cc | 2 +- sql/log.cc | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) 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/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 ; 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/sql/event_db_repository.cc b/sql/event_db_repository.cc index 864fa094190..e49fd6791a0 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -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/log.cc b/sql/log.cc index 694a80ba57b..6adb765966c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -574,7 +574,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 */ From 6c15d02a37a7770335ec746a25a8bb5479e52372 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 19:07:06 +0300 Subject: [PATCH 46/83] Patch for displaying questions per second average correctly. --- sql/sql_parse.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0c50a6212ad..46f76db28ad 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1140,6 +1140,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 +1153,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(¤t_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 { From 8e72b760aa0a407f68bf37df37d31caa382d2f82 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Apr 2007 19:08:08 +0300 Subject: [PATCH 47/83] Bug #19372: Added a test case. The problem was fixed by the fix for bug #17379. The problem was that because of some conditions the optimizer always preferred range or full index scan access methods to lookup access methods even when the latter were much cheaper. mysql-test/r/select.result: Bug #19372: test case. The problem was fixed by the patch for bug #17379 mysql-test/t/select.test: Bug #19372: test case. The problem was fixed by the patch for bug #17379 --- mysql-test/r/select.result | 9 +++++++++ mysql-test/t/select.test | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index b501d547e0a..bfe0b9d19df 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3986,4 +3986,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 Date: Wed, 11 Apr 2007 01:47:42 +0200 Subject: [PATCH 48/83] my_memmem.c: Back port of include change and copyright from 5.1 Makefile.am, zlib.m4: Use separate libtool convenience library for the bundled zlib to embed into executables and shared libraries created, and one to install into the pkglib directory zlib/Makefile.am: Use separate libtool convenience library for the bundled zlib to embed into executables and shared libraries created, and one to install into the pkglib directory config/ac-macros/zlib.m4: Use separate libtool convenience library for the bundled zlib to embed into executables and shared libraries created, and one to install into the pkglib directory mysys/my_memmem.c: Back port of include change and copyright from 5.1 --- config/ac-macros/zlib.m4 | 2 +- mysys/my_memmem.c | 18 +++++++++++++++++- zlib/Makefile.am | 17 +++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/config/ac-macros/zlib.m4 b/config/ac-macros/zlib.m4 index 74de715e424..5defdfd6749 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" diff --git a/mysys/my_memmem.c b/mysys/my_memmem.c index 682a1314f09..9230337409d 100644 --- a/mysys/my_memmem.c +++ b/mysys/my_memmem.c @@ -1,4 +1,20 @@ -#include "my_base.h" +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include /* my_memmem, port of a GNU extension. diff --git a/zlib/Makefile.am b/zlib/Makefile.am index f5741a782fb..edcbd5f4a75 100644 --- a/zlib/Makefile.am +++ b/zlib/Makefile.am @@ -19,17 +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 -# We are never interested in a shared version -libz_la_LDFLAGS= -static +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 From f159d066b5b1751dd92c4cbc3649246f7426c4bf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 07:56:11 +0200 Subject: [PATCH 49/83] ndb - bug#27748 testcase --- mysql-test/r/rpl_ndb_basic.result | 27 +++++++++++++++++++++++++++ mysql-test/t/rpl_ndb_basic.test | 31 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/mysql-test/r/rpl_ndb_basic.result b/mysql-test/r/rpl_ndb_basic.result index 32a1c790c99..c2f31465294 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/t/rpl_ndb_basic.test b/mysql-test/t/rpl_ndb_basic.test index 5290dc377c2..f0a0b9b0436 100644 --- a/mysql-test/t/rpl_ndb_basic.test +++ b/mysql-test/t/rpl_ndb_basic.test @@ -35,6 +35,37 @@ select * from t1 order by nid; # Bug #11087 would have row with nid 2 missing 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; From a908db7b74eb5925bf3ca6ab019b44df346bf4f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 08:23:16 +0200 Subject: [PATCH 50/83] ndb - bug#27748 fix commit trigger on multi-update ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp: fix commit trigger on multi-update --- ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp index e16d3df6d8d..37bf33f0313 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp @@ -390,6 +390,7 @@ Dbtup::commitRecord(Signal* signal, fragptr.p = regFragPtr; tabptr.p = regTabPtr; + Uint32 hashValue = firstOpPtr.p->hashValue; if (opType == ZINSERT_DELETE) { ljam(); @@ -412,6 +413,7 @@ Dbtup::commitRecord(Signal* signal, //-------------------------------------------------------------------- Uint32 saveOpType = regOperPtr->optype; regOperPtr->optype = ZINSERT; + regOperPtr->hashValue = hashValue; operPtr.p = regOperPtr; checkDetachedTriggers(signal, @@ -444,6 +446,8 @@ Dbtup::commitRecord(Signal* signal, befOpPtr.p->changeMask.clear(); befOpPtr.p->changeMask.bitOR(attributeMask); befOpPtr.p->gci = regOperPtr->gci; + befOpPtr.p->optype = ZUPDATE; + befOpPtr.p->hashValue = hashValue; befOpPtr.p->optype = opType; operPtr.p = befOpPtr.p; @@ -478,11 +482,13 @@ Dbtup::commitRecord(Signal* signal, Uint32 fragPageId = befOpPtr.p->fragPageId; Uint32 pageIndex = befOpPtr.p->pageIndex; + befOpPtr.p->optype = ZDELETE; befOpPtr.p->realPageId = befOpPtr.p->realPageIdC; befOpPtr.p->pageOffset = befOpPtr.p->pageOffsetC; befOpPtr.p->fragPageId = befOpPtr.p->fragPageIdC; befOpPtr.p->pageIndex = befOpPtr.p->pageIndexC; befOpPtr.p->gci = regOperPtr->gci; + befOpPtr.p->hashValue = hashValue; befOpPtr.p->optype = opType; operPtr.p = befOpPtr.p; From 2c840daa953b68823b5681cdf68adb640139515b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 13:27:36 +0300 Subject: [PATCH 51/83] Added warn_root as argument for push_back() --- sql/sql_error.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_error.cc b/sql/sql_error.cc index f551a7ef4b2..61442c52de7 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -149,7 +149,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, { /* 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_list.push_back(err, &thd->warn_root); } thd->warn_count[(uint) level]++; thd->total_warn_count++; From f89df01cc00bf612ffb0575fe0258a6b0769db1b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 13:01:11 +0200 Subject: [PATCH 52/83] make configure handle service pack version strings configure.in: recognize service pack version strings --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index a447732a06a..d3da80c2a16 100644 --- a/configure.in +++ b/configure.in @@ -30,7 +30,7 @@ NDB_VERSION_STATUS="" # 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 From 056e6ba495b9978dcfb208dfd995471a39a2f6a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 14:27:03 +0200 Subject: [PATCH 53/83] don't copy pdb files from the release target output folder, since this target does not build them scripts/make_win_bin_dist: don't try to copy the pdb files from the release output folder --- scripts/make_win_bin_dist | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 862c572a75a..2e10e530ca6 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -146,7 +146,11 @@ 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,map,pdb} $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/ @@ -155,8 +159,11 @@ cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/ 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.pdb $DESTDIR/bin/mysqld$EXE_SUFFIX.pdb 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 From 8187aaa851791fd2a7177437d2763d942a7fea73 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 15:21:11 +0200 Subject: [PATCH 54/83] Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11 - try to catch as many malloc failures as possible and give error messages ndb/src/ndbapi/ObjectMap.cpp: New BitKeeper file ``ndb/src/ndbapi/ObjectMap.cpp'' --- ndb/include/ndbapi/Ndb.hpp | 20 +- ndb/include/ndbapi/NdbDictionary.hpp | 24 +- ndb/include/ndbapi/NdbReceiver.hpp | 4 +- ndb/include/ndbapi/NdbTransaction.hpp | 2 +- ndb/include/util/BaseString.hpp | 7 + ndb/include/util/Vector.hpp | 68 ++++- ndb/src/common/util/BaseString.cpp | 145 +++++++++- ndb/src/ndbapi/DictCache.cpp | 13 +- ndb/src/ndbapi/DictCache.hpp | 2 +- ndb/src/ndbapi/Makefile.am | 3 +- ndb/src/ndbapi/Ndb.cpp | 47 +++- ndb/src/ndbapi/NdbDictionary.cpp | 80 ++++-- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 262 ++++++++++++++---- ndb/src/ndbapi/NdbDictionaryImpl.hpp | 10 +- ndb/src/ndbapi/NdbImpl.hpp | 34 ++- ndb/src/ndbapi/NdbOperation.cpp | 6 +- ndb/src/ndbapi/NdbRecAttr.cpp | 13 +- ndb/src/ndbapi/NdbReceiver.cpp | 35 ++- ndb/src/ndbapi/NdbScanFilter.cpp | 12 +- ndb/src/ndbapi/NdbScanOperation.cpp | 9 +- ndb/src/ndbapi/NdbTransaction.cpp | 14 +- ndb/src/ndbapi/Ndbif.cpp | 3 +- ndb/src/ndbapi/Ndblist.cpp | 10 +- ndb/src/ndbapi/ObjectMap.cpp | 62 +++++ ndb/src/ndbapi/ObjectMap.hpp | 51 +--- ndb/src/ndbapi/SignalSender.cpp | 10 +- ndb/src/ndbapi/ndb_cluster_connection.cpp | 15 +- .../ndbapi/ndb_cluster_connection_impl.hpp | 2 +- sql/ha_ndbcluster.cc | 176 +++++++++--- 29 files changed, 878 insertions(+), 261 deletions(-) create mode 100644 ndb/src/ndbapi/ObjectMap.cpp diff --git a/ndb/include/ndbapi/Ndb.hpp b/ndb/include/ndbapi/Ndb.hpp index 516333d1834..5af86cd09a8 100644 --- a/ndb/include/ndbapi/Ndb.hpp +++ b/ndb/include/ndbapi/Ndb.hpp @@ -1051,6 +1051,18 @@ class Ndb friend class NdbDictionaryImpl; friend class NdbDictInterface; friend class NdbBlob; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; + friend class Ndb_free_list_t; #endif public: @@ -1091,7 +1103,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. @@ -1105,7 +1117,7 @@ public: * * @param aSchemaName is the new name of the current schema */ - void setSchemaName(const char * aSchemaName); + int setSchemaName(const char * aSchemaName); #endif /** @@ -1120,7 +1132,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. @@ -1134,7 +1146,7 @@ public: * * @param aDatabaseSchemaName is the new name of the current database schema */ - void setDatabaseSchemaName(const char * aDatabaseSchemaName); + int setDatabaseSchemaName(const char * aDatabaseSchemaName); /** * Initializes the Ndb object diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 34686dd4db1..445bb513ffc 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -358,7 +358,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 @@ -446,7 +446,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; @@ -661,13 +661,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. @@ -723,7 +723,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 table object type @@ -875,26 +875,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 /** @@ -903,7 +903,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 /** @@ -911,7 +911,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 /** @@ -920,7 +920,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 /** diff --git a/ndb/include/ndbapi/NdbReceiver.hpp b/ndb/include/ndbapi/NdbReceiver.hpp index 0af55c88f68..b8abd281496 100644 --- a/ndb/include/ndbapi/NdbReceiver.hpp +++ b/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/ndb/include/ndbapi/NdbTransaction.hpp b/ndb/include/ndbapi/NdbTransaction.hpp index 1a9c7158adf..d3405633f80 100644 --- a/ndb/include/ndbapi/NdbTransaction.hpp +++ b/ndb/include/ndbapi/NdbTransaction.hpp @@ -585,7 +585,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, AbortOption abortOption = AbortOnError, diff --git a/ndb/include/util/BaseString.hpp b/ndb/include/util/BaseString.hpp index 44e1e4614be..34ca2d2be3d 100644 --- a/ndb/include/util/BaseString.hpp +++ b/ndb/include/util/BaseString.hpp @@ -185,6 +185,7 @@ public: private: char* m_chr; unsigned m_len; + friend bool operator!(const BaseString& str); }; inline const char* @@ -249,6 +250,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/ndb/include/util/Vector.hpp b/ndb/include/util/Vector.hpp index aeddbbb22f0..8f403b435dd 100644 --- a/ndb/include/util/Vector.hpp +++ b/ndb/include/util/Vector.hpp @@ -29,14 +29,14 @@ public: const T& operator[](unsigned i) const; unsigned size() const { return m_size; }; - void push_back(const T &); + int push_back(const T &); T& back(); void erase(unsigned index); void clear(); - void fill(unsigned new_size, T & obj); + int fill(unsigned new_size, T & obj); Vector& operator=(const Vector&); @@ -52,6 +52,14 @@ private: template Vector::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; @@ -89,12 +97,15 @@ Vector::back(){ } template -void +int Vector::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; @@ -103,6 +114,8 @@ Vector::push_back(const T & t){ } m_items[m_size] = t; m_size++; + + return 0; } template @@ -123,10 +136,12 @@ Vector::clear(){ } template -void +int Vector::fill(unsigned new_size, T & obj){ while(m_size <= new_size) - push_back(obj); + if (push_back(obj)) + return -1; + return 0; } template @@ -150,8 +165,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); @@ -160,7 +175,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; @@ -171,6 +186,14 @@ private: template MutexVector::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; @@ -208,11 +231,17 @@ MutexVector::back(){ } template -void +int MutexVector::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; @@ -222,15 +251,23 @@ MutexVector::push_back(const T & t){ m_items[m_size] = t; m_size++; unlock(); + return 0; } template -void +int MutexVector::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; @@ -241,6 +278,7 @@ MutexVector::push_back(const T & t, bool lockMutex){ m_size++; if(lockMutex) unlock(); + return 0; } template @@ -288,10 +326,12 @@ MutexVector::clear(bool l){ } template -void +int MutexVector::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/ndb/src/common/util/BaseString.cpp b/ndb/src/common/util/BaseString.cpp index 6f20ae6a002..7e5adf0e9ef 100644 --- a/ndb/src/common/util/BaseString.cpp +++ b/ndb/src/common/util/BaseString.cpp @@ -16,19 +16,36 @@ /* -*- c-basic-offset: 4; -*- */ #include #include -#include +#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 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/ndb/src/ndbapi/DictCache.cpp b/ndb/src/ndbapi/DictCache.cpp index 82e8d82bc24..6a815067233 100644 --- a/ndb/src/ndbapi/DictCache.cpp +++ b/ndb/src/ndbapi/DictCache.cpp @@ -141,7 +141,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)); @@ -151,6 +151,11 @@ GlobalDictCache::get(const char * name) versions = m_tableHash.getData(name, len); if(versions == 0){ versions = new Vector(2); + if (versions == NULL) + { + *error = -1; + DBUG_RETURN(0); + } m_tableHash.insertKey(name, len, 0, versions); } @@ -180,7 +185,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_RETURN(0); } diff --git a/ndb/src/ndbapi/DictCache.hpp b/ndb/src/ndbapi/DictCache.hpp index 4b569c114c9..db90a07d487 100644 --- a/ndb/src/ndbapi/DictCache.hpp +++ b/ndb/src/ndbapi/DictCache.hpp @@ -67,7 +67,7 @@ public: GlobalDictCache(); ~GlobalDictCache(); - NdbTableImpl * get(const char * name); + NdbTableImpl * get(const char * name, int *error); NdbTableImpl* put(const char * name, NdbTableImpl *); void drop(NdbTableImpl *); diff --git a/ndb/src/ndbapi/Makefile.am b/ndb/src/ndbapi/Makefile.am index 85013b540dc..1a5d10eae5b 100644 --- a/ndb/src/ndbapi/Makefile.am +++ b/ndb/src/ndbapi/Makefile.am @@ -48,7 +48,8 @@ libndbapi_la_SOURCES = \ DictCache.cpp \ ndb_cluster_connection.cpp \ NdbBlob.cpp \ - SignalSender.cpp + SignalSender.cpp \ + ObjectMap.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 57077559c49..3e407c43ca1 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -182,6 +182,7 @@ Ndb::NDB_connect(Uint32 tNode) nodeSequence = tp->getNodeSequence(tNode); bool node_is_alive = tp->get_node_alive(tNode); if (node_is_alive) { + DBUG_PRINT("info",("Sending signal to node %u", tNode)); tReturnCode = tp->sendSignal(tSignal, tNode); releaseSignal(tSignal); if (tReturnCode != -1) { @@ -449,7 +450,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); @@ -1129,27 +1134,35 @@ const char * Ndb::getCatalogName() const } -void Ndb::setCatalogName(const char * a_catalog_name) +int Ndb::setCatalogName(const char * a_catalog_name) { if (a_catalog_name) { - 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 { return theImpl->m_schemaname.c_str(); } -void Ndb::setSchemaName(const char * a_schema_name) +int Ndb::setSchemaName(const char * a_schema_name) { if (a_schema_name) { - 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; + } } } @@ -1161,9 +1174,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 @@ -1171,9 +1184,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); } bool Ndb::usingFullyQualifiedNames() @@ -1287,6 +1300,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; @@ -1303,6 +1321,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/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index 0a52f62aa01..86a6624959e 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -52,9 +52,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* @@ -208,10 +208,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* @@ -273,9 +273,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 * @@ -288,18 +288,30 @@ NdbDictionary::Table::getTableId() const { return m_impl.m_tableId; } -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); + if (m_impl.m_columns.push_back(col)) + { + return -1; + } if(c.getPrimaryKey()){ m_impl.m_noOfKeys++; } if (col->getBlobType()) { m_impl.m_noOfBlobs++; } - m_impl.buildColumnHash(); + if (m_impl.buildColumnHash()) + { + return -1; + } + return 0; } const NdbDictionary::Column* @@ -442,9 +454,9 @@ NdbDictionary::Table::setSingleUserMode(enum NdbDictionary::Table::SingleUserMod m_impl.m_single_user_mode = (Uint8)mode; } -void +int NdbDictionary::Table::setFrm(const void* data, Uint32 len){ - m_impl.m_frm.assign(data, len); + return m_impl.m_frm.assign(data, len); } NdbDictionary::Object::Status @@ -491,6 +503,7 @@ NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const { /***************************************************************** * Index facade */ + NdbDictionary::Index::Index(const char * name) : m_impl(* new NdbIndexImpl(* this)) { @@ -509,9 +522,9 @@ NdbDictionary::Index::~Index(){ } } -void +int NdbDictionary::Index::setName(const char * name){ - m_impl.setName(name); + return m_impl.setName(name); } const char * @@ -519,9 +532,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 * @@ -556,39 +569,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 diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 8604d50830d..3fed04de26d 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -390,22 +390,34 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const DBUG_RETURN(true); } -void +int NdbTableImpl::assign(const NdbTableImpl& org) { m_tableId = org.m_tableId; - m_internalName.assign(org.m_internalName); - m_externalName.assign(org.m_externalName); - m_newExternalName.assign(org.m_newExternalName); - m_frm.assign(org.m_frm.get_data(), org.m_frm.length()); + if (!m_internalName.assign(org.m_internalName) || + !m_externalName.assign(org.m_externalName) || + !m_newExternalName.assign(org.m_newExternalName) || + m_frm.assign(org.m_frm.get_data(), org.m_frm.length())) + { + return -1; + } m_fragmentType = org.m_fragmentType; m_fragmentCount = org.m_fragmentCount; for(unsigned i = 0; i hashValues; - Vector > chains; chains.fill(size, hashValues); + Vector > 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++){ @@ -490,12 +514,18 @@ NdbTableImpl::buildColumnHash(){ for(size_t j = 0; j 0 ? m_columns[col]->getName() : "" , m_columnHash[i]); } #endif + return 0; } Uint32 @@ -563,9 +594,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 * @@ -574,10 +605,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 * @@ -657,14 +688,18 @@ Ndb_local_table_info * NdbDictionaryImpl::fetchGlobalTableImpl(const BaseString& internalTableName) { NdbTableImpl *impl; + int error= 0; m_globalHash->lock(); - impl = m_globalHash->get(internalTableName.c_str()); + impl = m_globalHash->get(internalTableName.c_str(), &error); m_globalHash->unlock(); if (impl == 0){ - impl = m_receiver.getTable(internalTableName, - m_ndb.usingFullyQualifiedNames()); + if (error == 0) + impl = m_receiver.getTable(internalTableName, + m_ndb.usingFullyQualifiedNames()); + else + m_error.code = 4000; m_globalHash->lock(); m_globalHash->put(internalTableName.c_str(), impl); m_globalHash->unlock(); @@ -998,12 +1033,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]; @@ -1034,7 +1077,14 @@ NdbDictInterface::getTable(class NdbApiSignal * signal, (Uint32*)m_buffer.get_data(), m_buffer.length() / 4, fullyQualifiedNames); if (rt != 0) - rt->buildColumnHash(); + { + if (rt->buildColumnHash()) + { + m_error.code = 4000; + delete rt; + return NULL; + } + } return rt; } @@ -1043,18 +1093,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; } @@ -1185,10 +1242,12 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, impl->m_tableId = tableDesc.TableId; impl->m_version = tableDesc.TableVersion; impl->m_status = NdbDictionary::Object::Retrieved; - impl->m_internalName.assign(internalName); - impl->m_externalName.assign(externalName); - - impl->m_frm.assign(tableDesc.FrmData, tableDesc.FrmLen); + if (!impl->m_internalName.assign(internalName) || + !impl->m_externalName.assign(externalName) || + impl->m_frm.assign(tableDesc.FrmData, tableDesc.FrmLen)) + { + DBUG_RETURN(4000); + } impl->m_fragmentType = (NdbDictionary::Object::FragmentType) getApiConstant(tableDesc.FragmentType, @@ -1216,7 +1275,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 keyInfoPos = 0; @@ -1243,6 +1305,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, // check type and compute attribute size and array size if (! attrDesc.translateExtType()) { + delete col; delete impl; DBUG_RETURN(703); } @@ -1254,12 +1317,14 @@ 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; DBUG_RETURN(703); } if (col->getCharType()) { col->m_cs = get_charset(cs_number, MYF(0)); if (col->m_cs == NULL) { + delete col; delete impl; DBUG_RETURN(743); } @@ -1277,7 +1342,12 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, col->m_nullable = attrDesc.AttributeNullableFlag; col->m_autoIncrement = (attrDesc.AttributeAutoIncrement ? true : false); col->m_autoIncrementInitialValue = ~0; - col->m_defaultValue.assign(attrDesc.AttributeDefaultValue); + if (!col->m_defaultValue.assign(attrDesc.AttributeDefaultValue)) + { + delete col; + delete impl; + DBUG_RETURN(4000); + } if(attrDesc.AttributeKeyFlag){ col->m_keyInfoPos = keyInfoPos + 1; @@ -1317,7 +1387,11 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, for(i = 0; i<(fragCount*replicaCount); i++) { - impl->m_fragments.push_back(tableDesc.FragmentData[i+2]); + if (impl->m_fragments.push_back(tableDesc.FragmentData[i+2])) + { + delete impl; + DBUG_RETURN(4000); + } } Uint32 topBit = (1 << 31); @@ -1481,7 +1555,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, } if (!impl.m_newExternalName.empty()) { - impl.m_externalName.assign(impl.m_newExternalName); + if (!impl.m_externalName.assign(impl.m_newExternalName)) + { + m_error.code= 4000; + DBUG_RETURN(-1); + } AlterTableReq::setNameFlag(impl.m_changeMask, true); } @@ -1490,7 +1568,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); + } UtilBufferWriter w(m_buffer); DictTabInfo::Table tmpTab; tmpTab.init(); BaseString::snprintf(tmpTab.TableName, @@ -1967,13 +2049,19 @@ NdbDictionaryImpl::getIndexImpl(const char * externalName, NdbIndexImpl* idx; if(NdbDictInterface::create_index_obj_from_table(&idx, tab, prim) == 0){ idx->m_table = tab; - idx->m_externalName.assign(externalName); - idx->m_internalName.assign(internalName); + if (!idx->m_externalName.assign(externalName) || + !idx->m_internalName.assign(internalName)) + { + delete idx; + m_error.code = 4000; + return 0; + } // TODO Assign idx to tab->m_index // Don't do it right now since assign can't asign a table with index // tab->m_index = idx; return idx; } + m_error.code = 4000; return 0; } @@ -1982,11 +2070,21 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst, NdbTableImpl* tab, const NdbTableImpl* prim){ 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_indexId = tab->m_tableId; - 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::Index::Type type = idx->m_type = tab->m_indexType; idx->m_logging = tab->m_logging; // skip last attribute (NDB$PK or NDB$TNODE) @@ -1999,9 +2097,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 @@ -2067,7 +2176,11 @@ NdbDictInterface::createIndex(Ndb & ndb, } const BaseString internalName( ndb.internalize_index_name(&table, impl.getName())); - impl.m_internalName.assign(internalName); + if (!impl.m_internalName.assign(internalName)) + { + m_error.code = 4000; + return -1; + } w.add(DictTabInfo::TableName, internalName.c_str()); w.add(DictTabInfo::TableLoggedFlag, impl.m_logging); @@ -2353,34 +2466,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++; @@ -2427,7 +2578,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); diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 6d58a703a3c..819de921235 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -103,7 +103,7 @@ public: ~NdbTableImpl(); void init(); - void setName(const char * name); + int setName(const char * name); const char * getName() const; Uint32 m_changeMask; @@ -120,7 +120,7 @@ public: Uint32 m_columnHashMask; Vector m_columnHash; Vector m_columns; - void buildColumnHash(); + int buildColumnHash(); /** * Fragment info @@ -166,7 +166,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); @@ -185,9 +185,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; diff --git a/ndb/src/ndbapi/NdbImpl.hpp b/ndb/src/ndbapi/NdbImpl.hpp index 90b81dabff6..ec386074692 100644 --- a/ndb/src/ndbapi/NdbImpl.hpp +++ b/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(); @@ -79,10 +79,14 @@ public: BaseString m_prefix; // Buffer for preformatted internal name // - 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; } /** @@ -194,7 +198,7 @@ Ndb_free_list_t::~Ndb_free_list_t() template inline -void +int Ndb_free_list_t::fill(Ndb* ndb, Uint32 cnt) { if (m_free_list == 0) @@ -202,18 +206,28 @@ Ndb_free_list_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 @@ -234,7 +248,11 @@ Ndb_free_list_t::seize(Ndb* ndb) { m_alloc_cnt++; } - + else + { + ndb->theError.code = 4000; + assert(false); + } return tmp; } diff --git a/ndb/src/ndbapi/NdbOperation.cpp b/ndb/src/ndbapi/NdbOperation.cpp index 3ab1b56a717..51b6a3f6dab 100644 --- a/ndb/src/ndbapi/NdbOperation.cpp +++ b/ndb/src/ndbapi/NdbOperation.cpp @@ -176,7 +176,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/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 90808a706d4..77578147d99 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -83,6 +83,7 @@ NdbRecAttr::setup(const NdbColumnImpl* anAttrInfo, char* aValue) theRef = tRef; return 0; } + errno = ENOMEM; return -1; } @@ -102,7 +103,11 @@ NdbRecAttr::copyout() NdbRecAttr * NdbRecAttr::clone() const { NdbRecAttr * ret = new NdbRecAttr(0); - + if (ret == NULL) + { + errno = ENOMEM; + return NULL; + } ret->theAttrId = theAttrId; ret->theNULLind = theNULLind; ret->theAttrSize = theAttrSize; @@ -116,6 +121,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; } diff --git a/ndb/src/ndbapi/NdbReceiver.cpp b/ndb/src/ndbapi/NdbReceiver.cpp index 9322f88a351..46ca59f2f42 100644 --- a/ndb/src/ndbapi/NdbReceiver.cpp +++ b/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; - if (m_id == NdbObjectIdMap::InvalidId) { - if (m_ndb) - m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this); - } - 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; + } + } + } + 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/ndb/src/ndbapi/NdbScanFilter.cpp b/ndb/src/ndbapi/NdbScanFilter.cpp index eb0ef4ba391..fb47772fdea 100644 --- a/ndb/src/ndbapi/NdbScanFilter.cpp +++ b/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/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index 8433b70f0b2..91c788b0088 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -797,9 +797,12 @@ int NdbScanOperation::prepareSendScan(Uint32 aTC_ConnectPtr, req->requestInfo = reqInfo; for(Uint32 i = 0; ido_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/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index 2fe43b8cc21..258330b3967 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/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; @@ -147,6 +148,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/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index 75ec5df60cb..bcc0d9d997c 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -816,8 +816,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=%x, GSN=%d, theImpl->theWaiter.m_state=%d)" " sender = (Block: %d Node: %d)", + tFirstDataPtr, tSignalNumber, tWaitState, refToBlock(aSignal->theSendersBlockRef), diff --git a/ndb/src/ndbapi/Ndblist.cpp b/ndb/src/ndbapi/Ndblist.cpp index 812410e283f..443f9bb42fc 100644 --- a/ndb/src/ndbapi/Ndblist.cpp +++ b/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/ndb/src/ndbapi/ObjectMap.cpp b/ndb/src/ndbapi/ObjectMap.cpp new file mode 100644 index 00000000000..c87911a10d4 --- /dev/null +++ b/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/ndb/src/ndbapi/ObjectMap.hpp b/ndb/src/ndbapi/ObjectMap.hpp index 0e0c9668164..6a8dbcbeef5 100644 --- a/ndb/src/ndbapi/ObjectMap.hpp +++ b/ndb/src/ndbapi/ObjectMap.hpp @@ -20,6 +20,9 @@ //#include #include +#include +extern EventLogger g_eventLogger; + //#define DEBUG_OBJECTMAP /** @@ -49,24 +52,6 @@ private: int expand(Uint32 newSize); }; -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){ @@ -102,7 +87,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%x) obj=0x%x", id, object, obj); + g_eventLogger.error("NdbObjectIdMap::unmap(%u, 0x%x) obj=0x%x", + id, object, obj); return 0; } @@ -128,31 +114,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= 0 && m_impl.m_all_nodes[i].group > m_impl.m_all_nodes[i+1].group; @@ -449,7 +452,7 @@ Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, do_test(); #endif - DBUG_VOID_RETURN; + DBUG_RETURN(0); } void @@ -532,7 +535,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; iget_registry()->m_transporter_interface.size(); diff --git a/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp b/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp index 5bb5f0a0fca..d3ff7610e18 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp +++ b/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp @@ -68,7 +68,7 @@ private: }; Vector 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/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 93ca6b7f96d..16bdf4da132 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -203,6 +203,7 @@ static const err_code_mapping err_map[]= { 284, HA_ERR_TABLE_DEF_CHANGED, 0 }, + {4000, HA_ERR_OUT_OF_MEM, 1 }, {4009, HA_ERR_NO_CONNECTION, 1 }, { 0, 1, 0 }, @@ -372,7 +373,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_tabname, &stat); if (result == 0) { @@ -841,7 +845,11 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob, DBUG_PRINT("value", ("allocate blobs buffer size %u", offset)); m_blobs_buffer= my_malloc(offset, MYF(MY_WME)); if (m_blobs_buffer == NULL) + { + sql_print_error("ha_ndbcluster::get_ndb_blobs_value: " + "my_malloc(%u) failed", offset); DBUG_RETURN(-1); + } m_blobs_buffer_size= offset; } } @@ -1026,6 +1034,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= (unsigned char*)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; @@ -3228,7 +3242,10 @@ int ha_ndbcluster::info(uint flag) DBUG_RETURN(my_errno); Ndb *ndb= get_ndb(); 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_tabname, &stat)) == 0) @@ -4038,7 +4055,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 @@ -4410,7 +4430,10 @@ int ha_ndbcluster::create(const char *name, } 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)); // Save frm data for this table @@ -4435,7 +4458,10 @@ int ha_ndbcluster::create(const char *name, field->pack_length())); if ((my_errno= create_ndb_column(col, field, create_info))) DBUG_RETURN(my_errno); - tab.addColumn(col); + if (tab.addColumn(col)) + { + DBUG_RETURN(my_errno= errno); + } if (col.getPrimaryKey()) pk_length += (field->pack_length() + 3) / 4; } @@ -4444,13 +4470,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; } @@ -4556,13 +4588,19 @@ int ha_ndbcluster::create_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)) @@ -4617,7 +4655,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) m_table= (void *)orig_tab; // Change current database to that of target table set_dbname(to); - ndb->setDatabaseName(m_dbname); + if (ndb->setDatabaseName(m_dbname)) + { + ERR_RETURN(ndb->getNdbError()); + } if (!(result= alter_table_name(new_tabname))) { // Rename .ndb file @@ -4636,10 +4677,16 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) for (unsigned i = 0; i < index_list.count; i++) { NDBDICT::List::Element& index_el = index_list.elements[i]; set_dbname(from); - ndb->setDatabaseName(m_dbname); + if (ndb->setDatabaseName(m_dbname)) + { + ERR_RETURN(ndb->getNdbError()); + } const NDBINDEX * index= dict->getIndex(index_el.name, *new_tab); set_dbname(to); - ndb->setDatabaseName(m_dbname); + if (ndb->setDatabaseName(m_dbname)) + { + ERR_RETURN(ndb->getNdbError()); + } DBUG_PRINT("info", ("Creating index %s/%s", m_dbname, index->getName())); dict->createIndex(*index); @@ -4647,7 +4694,10 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) m_dbname, index->getName())); set_dbname(from); - ndb->setDatabaseName(m_dbname); + if (ndb->setDatabaseName(m_dbname)) + { + ERR_RETURN(ndb->getNdbError()); + } dict->dropIndex(*index); } } @@ -4668,7 +4718,10 @@ int ha_ndbcluster::alter_table_name(const char *to) DBUG_ENTER("alter_table_name_table"); NdbDictionary::Table new_tab= *orig_tab; - new_tab.setName(to); + if (new_tab.setName(to)) + { + DBUG_RETURN(my_errno= errno); + } if (dict->alterTable(new_tab) != 0) ERR_RETURN(dict->getNdbError()); @@ -4914,7 +4967,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_tabname, &stat); records= stat.row_count; @@ -4946,6 +5002,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; + } thd_ndb->ndb->getDictionary()->set_local_table_data_size( sizeof(Ndb_local_table_statistics) ); @@ -5001,7 +5062,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); } @@ -5035,8 +5099,10 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, 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(); dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics)); dict->invalidateTable(name); @@ -5082,8 +5148,10 @@ int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name 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(); dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics)); dict->invalidateTable(name); @@ -5144,7 +5212,10 @@ int ndbcluster_drop_database(const char *path) drop_list.push_back(thd->strdup(t.name)); } // Drop any tables belonging to database - ndb->setDatabaseName(dbname); + if (ndb->setDatabaseName(dbname)) + { + ERR_RETURN(ndb->getNdbError()); + } List_iterator_fast it(drop_list); while ((tabname=it++)) { @@ -5373,6 +5444,7 @@ bool ndbcluster_init() { DBUG_PRINT("error",("Ndb_cluster_connection(%s)", opt_ndbcluster_connectstring)); + my_errno= HA_ERR_OUT_OF_MEM; goto ndbcluster_init_error; } { @@ -5387,6 +5459,7 @@ bool ndbcluster_init() 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; } g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_local_table_statistics)); @@ -5742,7 +5815,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); @@ -5955,6 +6031,8 @@ static NDB_SHARE* get_share(const char *table_name) { DBUG_PRINT("error", ("Failed to alloc share")); pthread_mutex_unlock(&ndbcluster_mutex); + sql_print_error("get_share: my_malloc(%u) failed", + (unsigned int)(sizeof(*share)+length+1)); return 0; } } @@ -6015,16 +6093,22 @@ static int packfrm(const void *data, uint len, error= 1; org_len= len; if (my_compress((byte*)data, &org_len, &comp_len)) + { + sql_print_error("packfrm: my_compress(org_len: %u)", + (unsigned int)org_len); goto err; - + } + DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len)); DBUG_DUMP("compressed", (char*)data, org_len); error= 2; blob_len= sizeof(frm_blob_struct::frm_blob_header)+org_len; if (!(blob= (frm_blob_struct*) my_malloc(blob_len,MYF(MY_WME)))) + { + sql_print_error("packfrm: my_malloc(%u)", blob_len); goto err; - + } // Store compressed blob in machine independent format int4store((char*)(&blob->head.ver), 1); int4store((char*)(&blob->head.orglen), comp_len); @@ -6062,14 +6146,23 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len, DBUG_DUMP("blob->data", (char*) blob->data, complen); if (ver != 1) + { + sql_print_error("unpackfrm: ver != 1"); DBUG_RETURN(1); + } if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME)))) - DBUG_RETURN(2); + { + sql_print_error("unpackfrm: my_malloc(%u)", + (unsigned int)max(orglen, complen)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } memcpy(data, blob->data, complen); if (my_uncompress(data, &complen, &orglen)) { my_free((char*)data, MYF(0)); + sql_print_error("unpackfrm: my_uncompress(complen: %u, orglen: %u)", + (unsigned int)complen, (unsigned int)orglen); DBUG_RETURN(3); } @@ -6663,7 +6756,10 @@ ha_ndbcluster::update_table_comment( return((char*)comment); } - ndb->setDatabaseName(m_dbname); + if (ndb->setDatabaseName(m_dbname)) + { + return((char*)comment); + } NDBDICT* dict= ndb->getDictionary(); const NDBTAB* tab; if (!(tab= dict->getTable(m_tabname))) @@ -6676,6 +6772,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; } @@ -6698,9 +6796,19 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) DBUG_PRINT("enter", ("ndb_cache_check_time: %lu", ndb_cache_check_time)); 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); ndb= new Ndb(g_ndb_cluster_connection, ""); - + if (ndb == NULL) + { + thd->cleanup(); + delete thd; + DBUG_RETURN(NULL); + } pthread_detach_this_thread(); ndb_util_thread= pthread_self(); @@ -6789,14 +6897,15 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) share->table_name)); /* Contact NDB to get commit count for table */ - ndb->setDatabaseName(db); struct Ndb_statistics stat; - uint lock; pthread_mutex_lock(&share->mutex); lock= share->commit_count_lock; pthread_mutex_unlock(&share->mutex); - + if (ndb->setDatabaseName(db)) + { + goto loop_next; + } if (ndb_get_table_statistics(NULL, false, ndb, tabname, &stat) == 0) { #ifndef DBUG_OFF @@ -6815,7 +6924,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) share->table_name)); stat.commit_count= 0; } - + loop_next: pthread_mutex_lock(&share->mutex); if (share->commit_count_lock == lock) share->commit_count= stat.commit_count; @@ -6884,6 +6993,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; From f8c9cef1cd2389677c4dced15d569f6845e1a3f7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 18:10:45 +0200 Subject: [PATCH 55/83] Bug#26176 NdbObjectIdMap::expand unable to expand!! mysqld got signal 11 - try to catch as many malloc failures as possible and give error messages (more for 5.1) storage/ndb/src/ndbapi/ObjectMap.cpp: Rename: ndb/src/ndbapi/ObjectMap.cpp -> storage/ndb/src/ndbapi/ObjectMap.cpp --- storage/ndb/include/ndbapi/NdbDictionary.hpp | 20 +-- storage/ndb/include/util/Vector.hpp | 1 + storage/ndb/src/ndbapi/NdbDictionary.cpp | 40 ++--- storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 138 +++++++++++------- storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp | 31 ++-- {ndb => storage/ndb}/src/ndbapi/ObjectMap.cpp | 0 6 files changed, 136 insertions(+), 94 deletions(-) rename {ndb => storage/ndb}/src/ndbapi/ObjectMap.cpp (100%) diff --git a/storage/ndb/include/ndbapi/NdbDictionary.hpp b/storage/ndb/include/ndbapi/NdbDictionary.hpp index 0770a2164ce..626a82eaef4 100644 --- a/storage/ndb/include/ndbapi/NdbDictionary.hpp +++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp @@ -819,9 +819,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; /** @@ -862,12 +862,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 +875,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 +884,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 @@ -1281,7 +1281,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 +1308,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 +1534,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/util/Vector.hpp b/storage/ndb/include/util/Vector.hpp index 7530bca3b38..7ae4228985d 100644 --- a/storage/ndb/include/util/Vector.hpp +++ b/storage/ndb/include/util/Vector.hpp @@ -116,6 +116,7 @@ Vector::push_back(const T & t){ } m_items[m_size] = t; m_size++; + return 0; } template diff --git a/storage/ndb/src/ndbapi/NdbDictionary.cpp b/storage/ndb/src/ndbapi/NdbDictionary.cpp index b268490db23..b3ee41358d9 100644 --- a/storage/ndb/src/ndbapi/NdbDictionary.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp @@ -519,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* @@ -576,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* @@ -592,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* @@ -608,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 @@ -693,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 @@ -936,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 * @@ -960,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* @@ -1295,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 9f1866729a0..6bd09e02297 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -881,9 +881,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) @@ -896,9 +896,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 * @@ -919,9 +919,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 * @@ -942,9 +942,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 * @@ -965,9 +965,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 * @@ -988,16 +988,15 @@ NdbTableImpl::getRangeListDataLen() const return m_new_range.length(); } -void +int NdbTableImpl::updateMysqlName() { Vector 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(""); } int @@ -1274,9 +1273,9 @@ NdbEventImpl::~NdbEventImpl() DBUG_VOID_RETURN; } -void NdbEventImpl::setName(const char * name) +int NdbEventImpl::setName(const char * name) { - m_name.assign(name); + !m_name.assign(name); } const char *NdbEventImpl::getName() const @@ -1284,11 +1283,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 @@ -1313,10 +1312,10 @@ NdbEventImpl::getTable() const return NULL; } -void +int NdbEventImpl::setTable(const char * table) { - m_tableName.assign(table); + return !m_tableName.assign(table); } const char * @@ -1467,10 +1466,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, @@ -2334,8 +2334,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); @@ -2510,7 +2515,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, { AlterTableReq::setNameFlag(impl.m_changeMask, true); } - if (impl.m_externalName.assign(impl.m_newExternalName)) + if (!impl.m_externalName.assign(impl.m_newExternalName)) { m_error.code= 4000; DBUG_RETURN(-1); @@ -2524,7 +2529,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) @@ -2534,7 +2543,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 @@ -2544,8 +2557,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 @@ -2555,8 +2572,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 @@ -2566,8 +2587,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(); } @@ -4473,7 +4498,7 @@ NdbTablespaceImpl::NdbTablespaceImpl(NdbDictionary::Tablespace & f) : NdbTablespaceImpl::~NdbTablespaceImpl(){ } -void +int NdbTablespaceImpl::assign(const NdbTablespaceImpl& org) { m_id = org.m_id; @@ -4481,14 +4506,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() : @@ -4506,7 +4534,7 @@ NdbLogfileGroupImpl::NdbLogfileGroupImpl(NdbDictionary::LogfileGroup & f) : NdbLogfileGroupImpl::~NdbLogfileGroupImpl(){ } -void +int NdbLogfileGroupImpl::assign(const NdbLogfileGroupImpl& org) { m_id = org.m_id; @@ -4514,14 +4542,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) @@ -4548,7 +4579,7 @@ NdbDatafileImpl::NdbDatafileImpl(NdbDictionary::Datafile & f) : NdbDatafileImpl::~NdbDatafileImpl(){ } -void +int NdbDatafileImpl::assign(const NdbDatafileImpl& org) { m_id = org.m_id; @@ -4560,8 +4591,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() : @@ -4579,7 +4612,7 @@ NdbUndofileImpl::NdbUndofileImpl(NdbDictionary::Undofile & f) : NdbUndofileImpl::~NdbUndofileImpl(){ } -void +int NdbUndofileImpl::assign(const NdbUndofileImpl& org) { m_id = org.m_id; @@ -4591,8 +4624,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 @@ -5024,7 +5059,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) @@ -5058,7 +5094,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; @@ -5177,7 +5214,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) { @@ -5185,7 +5223,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 @@ -5221,7 +5260,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; diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 72576bbd273..c904b9d65c3 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -135,24 +135,24 @@ public: 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); @@ -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/ndb/src/ndbapi/ObjectMap.cpp b/storage/ndb/src/ndbapi/ObjectMap.cpp similarity index 100% rename from ndb/src/ndbapi/ObjectMap.cpp rename to storage/ndb/src/ndbapi/ObjectMap.cpp From 48acb9de58d1a6162a24c53d86a6bd856afdb766 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 19:29:32 +0200 Subject: [PATCH 56/83] missing return --- ndb/src/ndbapi/Ndb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 3e407c43ca1..449f287dc1d 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -1164,6 +1164,7 @@ int Ndb::setSchemaName(const char * a_schema_name) return -1; } } + return 0; } /* From 96d1ae8b4b3bbaf26928586a7946dcc6d809bd33 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 19:38:29 +0200 Subject: [PATCH 57/83] correct merge error --- sql/ha_ndbcluster.cc | 16 +++++----------- storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 385432c0732..5a0f27073d4 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -881,6 +881,7 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, sql_print_error("ha_ndbcluster::get_ndb_blobs_value: " "my_malloc(%u) failed", offset); DBUG_RETURN(-1); + } buffer_size= offset; } } @@ -8739,12 +8740,6 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) DBUG_RETURN(NULL); } THD_CHECK_SENTRY(thd); - if (ndb == NULL) - { - thd->cleanup(); - delete thd; - DBUG_RETURN(NULL); - } pthread_detach_this_thread(); ndb_util_thread= pthread_self(); @@ -8917,14 +8912,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); - if (ndb->setDatabaseName(db)) - { - goto loop_next; - } { /* 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, diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 6bd09e02297..0d9be372903 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1275,7 +1275,7 @@ NdbEventImpl::~NdbEventImpl() int NdbEventImpl::setName(const char * name) { - !m_name.assign(name); + return !m_name.assign(name); } const char *NdbEventImpl::getName() const From 2671ba02300bf94df7d987c1e594ca2e022e9a69 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 21:16:10 +0300 Subject: [PATCH 58/83] Fixed result. --- mysql-test/r/strict.result | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 74cd723e130..be5473f621e 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')); From 1810062ef13cde77f1dc23f1251b5b47b22e2194 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 20:22:31 +0200 Subject: [PATCH 59/83] remove warning --- ndb/src/ndbapi/Ndbif.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index bcc0d9d997c..d404436be59 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -816,7 +816,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) InvalidSignal: #ifdef VM_TRACE ndbout_c("Ndbif: Error Ndb::handleReceivedSignal " - "(tFirstDataPtr=%x, GSN=%d, theImpl->theWaiter.m_state=%d)" + "(tFirstDataPtr=%p, GSN=%d, theImpl->theWaiter.m_state=%d)" " sender = (Block: %d Node: %d)", tFirstDataPtr, tSignalNumber, From aa051961c9ac4629fd7dca9f236172e47660bbeb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 11:41:12 -0700 Subject: [PATCH 60/83] Fixed bug #27484: a crash when incompatible row expressions with nested rows are used as arguments of the IN predicate. Added a function to check compatibility of row expressions. Made sure that this function to be called for Item_func_in objects by fix_length_and_dec(). mysql-test/r/row.result: Added a test case for bug #27484. mysql-test/t/row.test: Added a test case for bug #27484. --- mysql-test/r/row.result | 18 ++++++++++++ mysql-test/t/row.test | 25 ++++++++++++++++ sql/item_cmpfunc.cc | 65 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 104 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result index 76d6fa13766..1c1c4809f36 100644 --- a/mysql-test/r/row.result +++ b/mysql-test/r/row.result @@ -170,3 +170,21 @@ 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) diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index d8d9a244134..6c66d45b942 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -83,4 +83,29 @@ 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/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4d54dfc2b39..ce3096da778 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -61,6 +61,42 @@ 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; iel(i)->check_cols(item1->el(i)->cols()) || + (item1->el(i)->result_type() == ROW_RESULT && + cmp_row_type(item1->el(i), item2->el(i)))) + return 1; + } + return 0; +} + + /* Aggregates result types from the array of items. @@ -75,14 +111,32 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) 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 void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) +static int agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) { uint i; type[0]= items[0]->result_type(); for (i= 1 ; i < nitems ; i++) + { 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; } static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, @@ -984,7 +1038,8 @@ void Item_func_between::fix_length_and_dec() */ if (!args[0] || !args[1] || !args[2]) return; - agg_cmp_type(thd, &cmp_type, args, 3); + if ( agg_cmp_type(thd, &cmp_type, args, 3)) + return; if (cmp_type == STRING_RESULT && agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV)) return; @@ -1532,7 +1587,8 @@ void Item_func_case::fix_length_and_dec() for (nagg= 0; nagg < ncases/2 ; nagg++) agg[nagg+1]= args[nagg*2]; nagg++; - agg_cmp_type(current_thd, &cmp_type, agg, nagg); + if (agg_cmp_type(current_thd, &cmp_type, agg, nagg)) + return; if ((cmp_type == STRING_RESULT) && agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV)) return; @@ -2013,7 +2069,8 @@ void Item_func_in::fix_length_and_dec() uint const_itm= 1; THD *thd= current_thd; - agg_cmp_type(thd, &cmp_type, args, arg_count); + if (agg_cmp_type(thd, &cmp_type, args, arg_count)) + return; if (cmp_type == STRING_RESULT && agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV)) From 8d40fa58edab227caa66c3977a7efe3f0fc5876f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 12:45:27 -0700 Subject: [PATCH 61/83] Post-merge fix. --- mysql-test/r/row.result | 6 ++++++ sql/item_cmpfunc.cc | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result index 3a8ab6b8346..bb9e2109f0f 100644 --- a/mysql-test/r/row.result +++ b/mysql-test/r/row.result @@ -193,6 +193,12 @@ 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 +select row(NULL,1)=(2,0); +row(NULL,1)=(2,0) +0 CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b)); INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3); EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 071762419fc..f9844f6d36e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -95,9 +95,9 @@ static int cmp_row_type(Item* item1, Item* item2) return 1; for (uint i=0; iel(i)->check_cols(item1->el(i)->cols()) || - (item1->el(i)->result_type() == ROW_RESULT && - cmp_row_type(item1->el(i), item2->el(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; From a6d18d56f45ab56a14816f46d7bb02fa6bfcf940 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Apr 2007 17:10:44 -0700 Subject: [PATCH 62/83] Post-merge fixes. --- sql/item_cmpfunc.cc | 61 ++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index fb17fde99da..277c306f4f2 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -125,7 +125,7 @@ static int cmp_row_type(Item* item1, Item* item2) 0 otherwise */ -static int agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) +static int agg_cmp_type(Item_result *type, Item **items, uint nitems) { uint i; type[0]= items[0]->result_type(); @@ -146,6 +146,42 @@ static int agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } +/* + Collects different types for comparison of first item with each other items + + SYNOPSIS + collect_cmp_types() + items Array of items to collect types from + nitems Number of items in the array + + DESCRIPTION + This function collects different result types for comparison of the first + item in the list with each of the remaining items in the 'items' array. + + RETURN + 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) +{ + uint i; + uint found_types; + Item_result left_result= items[0]->result_type(); + 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) { @@ -2069,24 +2105,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); - - for (i= 0; i <= (uint)DECIMAL_RESULT; i++) - { - if (found_types & (1 << i) && !cmp_items[i]) - { - DBUG_ASSERT((Item_result)i != ROW_RESULT); - if ((Item_result)i == STRING_RESULT && - agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV, 1)) - return; - if (!(cmp_items[i]= - cmp_item::get_comparator((Item_result)i, - cmp_collation.collation))) - return; - } - } - - found_types= collect_cmp_types(agg, nagg); + if (!(found_types= collect_cmp_types(agg, nagg))) + return; for (i= 0; i <= (uint)DECIMAL_RESULT; i++) { @@ -2790,7 +2810,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++) { From 7cde212bead19f6ad5a7f4030396b49e59ce9fb1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 06:59:56 +0200 Subject: [PATCH 63/83] ndb - bug#27757 tupscan misses uncommitted inserts by own transaction let tupkeyreq handle dirty/savepoint also siable diskscan as temporary fix for bug#27776 storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: let tupkeyreq handle dirty/savepoint --- storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp index 653a24ba6a1..be80ac487e2 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp @@ -61,11 +61,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; @@ -593,7 +597,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 + @@ -764,8 +767,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 From 7b3751fcede63619205c7d9bad35a61543e7ffef Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 07:19:10 +0200 Subject: [PATCH 64/83] ndb - mysql-test-run testcase for bug#27757 mysql-test/r/ndb_dd_basic.result: testcase mysql-test/t/ndb_dd_basic.test: testcase --- mysql-test/r/ndb_dd_basic.result | 7 +++++++ mysql-test/t/ndb_dd_basic.test | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result index 724b42b6db3..361d282e6d9 100644 --- a/mysql-test/r/ndb_dd_basic.result +++ b/mysql-test/r/ndb_dd_basic.result @@ -440,6 +440,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/t/ndb_dd_basic.test b/mysql-test/t/ndb_dd_basic.test index 5d43d7997b0..bbfc3704673 100644 --- a/mysql-test/t/ndb_dd_basic.test +++ b/mysql-test/t/ndb_dd_basic.test @@ -367,8 +367,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 From d7dadcd7c7668cf871f3b5cc00825dfaa6450c45 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 11:07:30 +0200 Subject: [PATCH 65/83] Bug #27758 Restoring NDB backups makes table usable in SQL nodes - parse indexname using "split" instead of sscanf, as not to break at space - test case with space in key - enclose names in printout mysql-test/r/ndb_restore.result: Bug #27758 Restoring NDB backups makes table usable in SQL nodes - change to using an index with space to reproduce bug mysql-test/t/ndb_restore.test: Bug #27758 Restoring NDB backups makes table usable in SQL nodes - change to using an index with space to reproduce bug ndb/tools/restore/consumer_restore.cpp: Bug #27758 Restoring NDB backups makes table usable in SQL nodes - parse indexname using "split" instead of sscanf, as not to break at space - enclose names in printout ndb/tools/restore/restore_main.cpp: Bug #27758 Restoring NDB backups makes table usable in SQL nodes - enclose names in printout sql/ha_ndbcluster.cc: Bug #27758 Restoring NDB backups makes table usable in SQL nodes - correct error message --- mysql-test/r/ndb_restore.result | 80 ++++++++++++------------ mysql-test/t/ndb_restore.test | 85 +++++++++++++------------- ndb/tools/restore/consumer_restore.cpp | 56 +++++++++-------- ndb/tools/restore/restore_main.cpp | 4 +- sql/ha_ndbcluster.cc | 6 +- 5 files changed, 121 insertions(+), 110 deletions(-) diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index e5bf4315e5c..be1f74a32e9 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -1,14 +1,14 @@ 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` ( +CREATE TABLE `t1_c` ( `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, `goaledatta` char(2) NOT NULL default '', `maturegarbagefa` varchar(32) NOT NULL default '', PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); -CREATE TABLE `t2` ( +) 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'); +CREATE TABLE `t2_c` ( `capgotod` smallint(5) unsigned NOT NULL auto_increment, `gotod` smallint(5) unsigned NOT NULL default '0', `goaledatta` char(2) default NULL, @@ -16,16 +16,16 @@ CREATE TABLE `t2` ( `descrpooppo` varchar(64) default NULL, `svcutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capgotod`), -KEY `i_quadaddsvr` (`gotod`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t2` 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'); -CREATE TABLE `t3` ( +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'); +CREATE TABLE `t3_c` ( `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', `capgotod` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capgotod`,`CapGoaledatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3); -CREATE TABLE `t4` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); +CREATE TABLE `t4_c` ( `capfa` bigint(20) unsigned NOT NULL auto_increment, `realm` varchar(32) NOT NULL default '', `authpwchap` varchar(32) default NULL, @@ -35,23 +35,23 @@ CREATE TABLE `t4` ( PRIMARY KEY (`fa`,`realm`), KEY `capfa` (`capfa`), KEY `i_quadentity` (`fa`,`realm`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t4` 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); -CREATE TABLE `t5` ( +) 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); +CREATE TABLE `t5_c` ( `capfa` bigint(20) unsigned NOT NULL default '0', `gotod` smallint(5) unsigned NOT NULL default '0', `orderutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,''); -CREATE TABLE `t6` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); +CREATE TABLE `t6_c` ( `capfa_parent` bigint(20) unsigned NOT NULL default '0', `capfa_child` bigint(20) unsigned NOT NULL default '0', `relatta` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t6` 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` ( +) 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); +CREATE TABLE `t7_c` ( `dardpo` char(15) NOT NULL default '', `dardtestard` tinyint(3) unsigned NOT NULL default '0', `FastFA` char(5) NOT NULL default '', @@ -60,9 +60,9 @@ CREATE TABLE `t7` ( `Fastmag` char(1) NOT NULL default '', `Beareratta` char(2) NOT NULL default '', PRIMARY KEY (`dardpo`,`dardtestard`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); -CREATE TABLE `t8` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +CREATE TABLE `t8_c` ( `kattjame` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', `realm_entered` varchar(32) NOT NULL default '', @@ -88,9 +88,9 @@ CREATE TABLE `t8` ( `acctinputoctets` bigint(20) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), KEY `squardporoot` (`squardporoot`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); -CREATE TABLE `t9` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +CREATE TABLE `t9_c` ( `kattjame` varchar(32) NOT NULL default '', `kattjame_entered` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', @@ -114,20 +114,20 @@ CREATE TABLE `t9` ( `actinputocctets` bigint(20) unsigned default NULL, `terminateraste` tinyint(3) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t9` 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 (a int auto_increment key); -insert into t10 values (1),(2),(3); -create table t1_c engine=ndbcluster as select * from t1; -create table t2_c engine=ndbcluster as select * from t2; -create table t3_c engine=ndbcluster as select * from t3; -create table t4_c engine=ndbcluster as select * from t4; -create table t5_c engine=ndbcluster as select * from t5; -create table t6_c engine=ndbcluster as select * from t6; -create table t7_c engine=ndbcluster as select * from t7; -create table t8_c engine=ndbcluster as select * from t8; -create table t9_c engine=ndbcluster as select * from t9; -create table t10_c engine=ndbcluster as select * from t10; +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +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; +insert into t10_c values (1),(2),(3); +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; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +create table t10 engine=myisam as select * from t10_c; drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; show tables; Tables_in_test diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 39c7ab67efb..1169cc52b15 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -8,15 +8,18 @@ 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 -CREATE TABLE `t1` ( +CREATE TABLE `t1_c` ( `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, `goaledatta` char(2) NOT NULL default '', `maturegarbagefa` varchar(32) NOT NULL default '', PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); - -CREATE TABLE `t2` ( +) 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'); +# +# Bug #27758 Restoring NDB backups makes table usable in SQL nodes +# - space in key made table unusable after restore +# +CREATE TABLE `t2_c` ( `capgotod` smallint(5) unsigned NOT NULL auto_increment, `gotod` smallint(5) unsigned NOT NULL default '0', `goaledatta` char(2) default NULL, @@ -24,18 +27,18 @@ CREATE TABLE `t2` ( `descrpooppo` varchar(64) default NULL, `svcutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capgotod`), - KEY `i_quadaddsvr` (`gotod`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t2` 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'); + 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'); -CREATE TABLE `t3` ( +CREATE TABLE `t3_c` ( `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', `capgotod` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capgotod`,`CapGoaledatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); -CREATE TABLE `t4` ( +CREATE TABLE `t4_c` ( `capfa` bigint(20) unsigned NOT NULL auto_increment, `realm` varchar(32) NOT NULL default '', `authpwchap` varchar(32) default NULL, @@ -45,26 +48,26 @@ CREATE TABLE `t4` ( PRIMARY KEY (`fa`,`realm`), KEY `capfa` (`capfa`), KEY `i_quadentity` (`fa`,`realm`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t4` 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); +) 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); -CREATE TABLE `t5` ( +CREATE TABLE `t5_c` ( `capfa` bigint(20) unsigned NOT NULL default '0', `gotod` smallint(5) unsigned NOT NULL default '0', `orderutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,''); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); -CREATE TABLE `t6` ( +CREATE TABLE `t6_c` ( `capfa_parent` bigint(20) unsigned NOT NULL default '0', `capfa_child` bigint(20) unsigned NOT NULL default '0', `relatta` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t6` 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); +) 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); -CREATE TABLE `t7` ( +CREATE TABLE `t7_c` ( `dardpo` char(15) NOT NULL default '', `dardtestard` tinyint(3) unsigned NOT NULL default '0', `FastFA` char(5) NOT NULL default '', @@ -73,10 +76,10 @@ CREATE TABLE `t7` ( `Fastmag` char(1) NOT NULL default '', `Beareratta` char(2) NOT NULL default '', PRIMARY KEY (`dardpo`,`dardtestard`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); -CREATE TABLE `t8` ( +CREATE TABLE `t8_c` ( `kattjame` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', `realm_entered` varchar(32) NOT NULL default '', @@ -102,10 +105,10 @@ CREATE TABLE `t8` ( `acctinputoctets` bigint(20) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), KEY `squardporoot` (`squardporoot`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); -CREATE TABLE `t9` ( +CREATE TABLE `t9_c` ( `kattjame` varchar(32) NOT NULL default '', `kattjame_entered` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', @@ -129,26 +132,26 @@ CREATE TABLE `t9` ( `actinputocctets` bigint(20) unsigned default NULL, `terminateraste` tinyint(3) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t9` 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); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +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); # Bug #20820 # auto inc table not handled correctly when restored from cluster backup # - before fix ndb_restore would not set auto inc value correct, # seen by select below -create table t10 (a int auto_increment key); -insert into t10 values (1),(2),(3); +create table t10_c (a int auto_increment key) ENGINE=ndbcluster; +insert into t10_c values (1),(2),(3); -create table t1_c engine=ndbcluster as select * from t1; -create table t2_c engine=ndbcluster as select * from t2; -create table t3_c engine=ndbcluster as select * from t3; -create table t4_c engine=ndbcluster as select * from t4; -create table t5_c engine=ndbcluster as select * from t5; -create table t6_c engine=ndbcluster as select * from t6; -create table t7_c engine=ndbcluster as select * from t7; -create table t8_c engine=ndbcluster as select * from t8; -create table t9_c engine=ndbcluster as select * from t9; -create table t10_c engine=ndbcluster as select * from t10; +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; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +create table t10 engine=myisam as select * from t10_c; --exec $NDB_MGM --no-defaults -e "start backup" >> $NDB_TOOLS_OUTPUT diff --git a/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp index c955570eaa3..d15cfea07df 100644 --- a/ndb/tools/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -205,7 +205,7 @@ BackupRestore::table(const TableS & table){ BaseString tmp(name); Vector split; if(tmp.split(split, "/") != 3){ - err << "Invalid table name format " << name << endl; + err << "Invalid table name format `" << name << "`" << endl; return false; } @@ -230,16 +230,17 @@ 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; 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; } const NdbDictionary::Table* null = 0; @@ -257,12 +258,15 @@ BackupRestore::endOfTables(){ for(size_t i = 0; i 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()); @@ -270,39 +274,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 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; } diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp index 52a913d73b4..9ec59b9b4a6 100644 --- a/ndb/tools/restore/restore_main.cpp +++ b/ndb/tools/restore/restore_main.cpp @@ -559,8 +559,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); } } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 16bdf4da132..71050bc73e4 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1148,14 +1148,16 @@ int ha_ndbcluster::build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase) { DBUG_PRINT("info", ("Get handle to index %s", index_name)); const NDBINDEX *index= dict->getIndex(index_name, m_tabname); - if (!index) DBUG_RETURN(1); + if (!index) + ERR_RETURN(dict->getNdbError()); m_index[i].index= (void *) index; } if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX) { DBUG_PRINT("info", ("Get handle to unique_index %s", unique_index_name)); const NDBINDEX *index= dict->getIndex(unique_index_name, m_tabname); - if (!index) DBUG_RETURN(1); + if (!index) + ERR_RETURN(dict->getNdbError()); m_index[i].unique_index= (void *) index; error= fix_unique_index_attr_order(m_index[i], index, key_info); } From 01d6b13c8b96fcb567a34947380827bce5c0ed03 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 11:43:56 +0200 Subject: [PATCH 66/83] ndb - hugo - add new method for setting primary key(s) storage/ndb/test/include/HugoOperations.hpp: Add method for setting of primary key storage/ndb/test/src/HugoAsynchTransactions.cpp: Add method for setting of primary key storage/ndb/test/src/HugoOperations.cpp: Add method for setting of primary key storage/ndb/test/src/HugoTransactions.cpp: Add method for setting of primary key --- storage/ndb/test/include/HugoOperations.hpp | 2 + .../ndb/test/src/HugoAsynchTransactions.cpp | 58 +++++------- storage/ndb/test/src/HugoOperations.cpp | 93 +++++++------------ storage/ndb/test/src/HugoTransactions.cpp | 82 ++++++---------- 4 files changed, 87 insertions(+), 148 deletions(-) diff --git a/storage/ndb/test/include/HugoOperations.hpp b/storage/ndb/test/include/HugoOperations.hpp index b5014380eec..8b98ead37c3 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/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 50234cea351..38f7b703723 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; agetPrimaryKey() == 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; agetPrimaryKey() == true){ - if(equalForAttr(pOp, a, rowId) != 0){ - ERR(pTrans->getNdbError()); - return NDBT_FAILED; - } - } - } + if (equalForRow(pOp, rowId) != 0) + return NDBT_FAILED; for(a = 0; agetPrimaryKey() == 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; agetPrimaryKey() == 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; agetNdbOperation(tab.getName()); if (pOp == NULL) { @@ -281,14 +262,8 @@ int HugoOperations::pkWritePartialRecord(Ndb* pNdb, } // Define primary keys - for(a = 0; agetPrimaryKey() == 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; agetPrimaryKey() == 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; } @@ -518,6 +487,22 @@ HugoOperations::~HugoOperations(){ } } +int +HugoOperations::equalForRow(NdbOperation* pOp, int row) +{ + for(int a = 0; agetPrimaryKey() == true) + { + if(equalForAttr(pOp, a, row) != 0) + { + ERR(pOp->getNdbError()); + return NDBT_FAILED; + } + } + } + return NDBT_OK; +} int HugoOperations::equalForAttr(NdbOperation* pOp, int attrId, @@ -676,14 +661,8 @@ int HugoOperations::indexReadRecords(Ndb*, const char * idxName, int recordNo, } // Define primary keys - for(a = 0; agetPrimaryKey() == 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; agetPrimaryKey() == 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; agetPrimaryKey() == 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; agetPrimaryKey() == 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; agetPrimaryKey() == 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; agetPrimaryKey() == 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; agetPrimaryKey() == 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 Date: Thu, 12 Apr 2007 11:47:38 +0200 Subject: [PATCH 67/83] ndb - bug#27756 testcase only new pseudo column NDB$COPY_ROWID storage/ndb/include/kernel/AttributeHeader.hpp: Add new pseudo column for reading location of copy tuple storage/ndb/include/ndbapi/NdbDictionary.hpp: Add new pseudo column for reading location of copy tuple storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: Add new pseudo column for reading location of copy tuple storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Add new pseudo column for reading location of copy tuple storage/ndb/src/ndbapi/ndb_cluster_connection.cpp: Add new pseudo column for reading location of copy tuple storage/ndb/test/ndbapi/testBasic.cpp: add testcase for bug#27756 --- .../ndb/include/kernel/AttributeHeader.hpp | 2 + storage/ndb/include/ndbapi/NdbDictionary.hpp | 1 + .../src/kernel/blocks/dbtup/DbtupRoutines.cpp | 4 ++ storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 6 ++ .../ndb/src/ndbapi/ndb_cluster_connection.cpp | 5 ++ storage/ndb/test/ndbapi/testBasic.cpp | 62 +++++++++++++++++++ 6 files changed, 80 insertions(+) diff --git a/storage/ndb/include/kernel/AttributeHeader.hpp b/storage/ndb/include/kernel/AttributeHeader.hpp index ad2ca582914..a8b811e4efa 100644 --- a/storage/ndb/include/kernel/AttributeHeader.hpp +++ b/storage/ndb/include/kernel/AttributeHeader.hpp @@ -46,6 +46,8 @@ public: STATIC_CONST( ROW_GCI = 0xFFF5 ); STATIC_CONST( FRAGMENT_VARSIZED_MEMORY = 0xFFF4 ); + STATIC_CONST( COPY_ROWID = 0xFFF1 ); + // NOTE: in 5.1 ctors and init take size in bytes /** Initialize AttributeHeader at location aHeaderPtr */ diff --git a/storage/ndb/include/ndbapi/NdbDictionary.hpp b/storage/ndb/include/ndbapi/NdbDictionary.hpp index aada314e454..0687733df03 100644 --- a/storage/ndb/include/ndbapi/NdbDictionary.hpp +++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp @@ -534,6 +534,7 @@ public: static const Column * RECORDS_IN_RANGE; static const Column * ROWID; static const Column * ROW_GCI; + static const Column * COPY_ROWID; int getSizeInBytes() const; #endif diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index c8546209f94..faa565f781a 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -1198,6 +1198,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/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index c999c7ed919..76f0cf81823 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -378,6 +378,11 @@ NdbColumnImpl::create_pseudo(const char * name){ col->m_impl.m_attrSize = 8; col->m_impl.m_arraySize = 1; col->m_impl.m_nullable = true; + } 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(); } @@ -5089,3 +5094,4 @@ const NdbDictionary::Column * NdbDictionary::Column::DISK_REF = 0; 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::COPY_ROWID = 0; diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp index 0e8a5f54c6e..66e3fe92e81 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -326,6 +326,8 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * NdbColumnImpl::create_pseudo("NDB$ROWID"); NdbDictionary::Column::ROW_GCI= NdbColumnImpl::create_pseudo("NDB$ROW_GCI"); + NdbDictionary::Column::COPY_ROWID= + NdbColumnImpl::create_pseudo("NDB$COPY_ROWID"); } NdbMutex_Unlock(g_ndb_connection_mutex); @@ -391,6 +393,9 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() NdbDictionary::Column::RECORDS_IN_RANGE= 0; NdbDictionary::Column::ROWID= 0; NdbDictionary::Column::ROW_GCI= 0; + + delete NdbDictionary::Column::COPY_ROWID; + NdbDictionary::Column::COPY_ROWID = 0; } NdbMutex_Unlock(g_ndb_connection_mutex); diff --git a/storage/ndb/test/ndbapi/testBasic.cpp b/storage/ndb/test/ndbapi/testBasic.cpp index e8e4548a91c..3b515476d67 100644 --- a/storage/ndb/test/ndbapi/testBasic.cpp +++ b/storage/ndb/test/ndbapi/testBasic.cpp @@ -1272,6 +1272,64 @@ runBug25090(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 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; + NDBT_TESTSUITE(testBasic); TESTCASE("PkInsert", "Verify that we can insert and delete from this table using PK" @@ -1542,6 +1600,10 @@ TESTCASE("Bug25090", "Verify what happens when we fill the db" ){ STEP(runBug25090); } +TESTCASE("Bug27756", + "Verify what happens when we fill the db" ){ + STEP(runBug27756); +} NDBT_TESTSUITE_END(testBasic); #if 0 From 80b532e20e11dc6c89d91df6d498b707e5419055 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 15:55:39 +0200 Subject: [PATCH 68/83] ndb - bug#27756 make sure that copy tuple is released in all cases storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp: make sure that copy tuple is released in all cases storage/ndb/test/run-test/daily-basic-tests.txt: add testcase --- storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp | 3 +-- storage/ndb/test/run-test/daily-basic-tests.txt | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp index 1f703599cf5..b36c12bb032 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp @@ -107,8 +107,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(®OperPtr->m_copy_tuple_location); if (regOperPtr->op_struct.in_active_list) { diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt index 5a7a6ee6e47..8c9d24ffcf2 100644 --- a/storage/ndb/test/run-test/daily-basic-tests.txt +++ b/storage/ndb/test/run-test/daily-basic-tests.txt @@ -235,6 +235,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 From 0b54001b21e56ceb04d80eeeadbb62a04b04d34f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 23:21:37 +0500 Subject: [PATCH 69/83] Bug#5507: TRUNCATE does not work with views. Support of views wasn't implemented for the TRUNCATE statement. Now TRUNCATE on views has the same semantics as DELETE FROM view: mysql_truncate() checks whether the table is a view and falls back to delete if so. In order to initialize properly the LEX::updatable for a view st_lex::can_use_merged() now allows usage of merged views for the TRUNCATE statement. mysql-test/r/truncate.result: Added a test case for the Bug#5507: TRUNCATE does not work with views. mysql-test/t/truncate.test: Added a test case for the Bug#5507: TRUNCATE does not work with views. sql/sql_lex.cc: Bug#5507: TRUNCATE does not work with views. can_use_merged() was denying of usage of merged views for a TRUNCATE statement. This results in improper initialization of view LEX::updatable. Fixed. sql/sql_delete.cc: Bug#5507: TRUNCATE does not work with views. 1.mysql_truncate() was lacking of check whether the table is view. Added. 2.mysql_truncate() calls mysql_delete(), but mysql_delete() always reports errors as "DELETE" errors. Fixed. mysql-test/t/view.test: Updated test case for Bug#14540: OPTIMIZE, ANALYZE, REPAIR applied to not a view. mysql-test/r/view.result: Updated test case for Bug#14540: OPTIMIZE, ANALYZE, REPAIR applied to not a view. --- mysql-test/r/truncate.result | 27 +++++++++++++++++++++++++++ mysql-test/r/view.result | 10 ++++++++++ mysql-test/t/truncate.test | 32 ++++++++++++++++++++++++++++++++ mysql-test/t/view.test | 2 ++ sql/sql_delete.cc | 9 ++++++--- sql/sql_lex.cc | 1 + 6 files changed, 78 insertions(+), 3 deletions(-) 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/view.result b/mysql-test/r/view.result index dc87f97b322..71d743f37b9 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2395,6 +2395,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/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/view.test b/mysql-test/t/view.test index 1b229298896..920fcee3b24 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2228,6 +2228,8 @@ REPAIR TABLE v1; DROP TABLE t1; OPTIMIZE TABLE v1; +ANALYZE TABLE v1; +REPAIR TABLE v1; DROP VIEW v1; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 19f3135c594..6956e5cfe91 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -369,6 +369,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 all_fields; @@ -383,14 +385,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); } } @@ -895,7 +897,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) if (!dont_send_ok) { 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_lex.cc b/sql/sql_lex.cc index 3be844b6761..4be0aca3ea7 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1834,6 +1834,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: From dc3c54706f1d9f96584bc139ded10b56624e5d37 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Apr 2007 21:34:25 +0200 Subject: [PATCH 70/83] remove inline NdbRecAttr functions for medium int as not to depend in my_global --- ndb/include/ndbapi/NdbRecAttr.hpp | 14 -------------- ndb/src/ndbapi/NdbRecAttr.cpp | 12 ++++++++++++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ndb/include/ndbapi/NdbRecAttr.hpp b/ndb/include/ndbapi/NdbRecAttr.hpp index 7f8add774dc..f5777cdddb3 100644 --- a/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/ndb/include/ndbapi/NdbRecAttr.hpp @@ -332,13 +332,6 @@ NdbRecAttr::int32_value() const return *(Int32*)theRef; } -inline -Int32 -NdbRecAttr::medium_value() const -{ - return sint3korr((unsigned char *)theRef); -} - inline short NdbRecAttr::short_value() const @@ -360,13 +353,6 @@ NdbRecAttr::u_32_value() const return *(Uint32*)theRef; } -inline -Uint32 -NdbRecAttr::u_medium_value() const -{ - return uint3korr((unsigned char*)theRef); -} - inline Uint16 NdbRecAttr::u_short_value() const diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 77578147d99..996c0256baa 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -519,3 +519,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); +} From f3efb3dcfac96afa487709f2603784f60f021f61 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Apr 2007 01:56:22 +0300 Subject: [PATCH 71/83] Added more descriptive error message of why statement was automaticly dropped Print information if net_clear() skipped bytes (As this otherwise hides critical timeing bugs) Added DBUG_ASSERT if we get packets out of order mysql_change_user() could on error send multiple packets, which caused mysql_client_test to randomly fail include/errmsg.h: Added more descriptive error message of why statement was automaticly dropped libmysql/client_settings.h: Added more descriptive error message of why statement was automaticly dropped libmysql/errmsg.c: Added more descriptive error message of why statement was automaticly dropped libmysql/libmysql.c: Added more descriptive error message of why statement was automaticly dropped sql-common/client.c: Added more descriptive error message of why statement was automaticly dropped sql/net_serv.cc: Print information if net_clear() skipped bytes (As this otherwise hides critical timeing bugs) Added DBUG_ASSERT if we get packets out of order sql/sql_class.cc: We need to set killed to NOT_KILLED after cleanup() if we want to continue using THD (If not, the connection will be closed after the current stmt) sql/sql_parse.cc: mysql_change_user() could on error send multiple packets, which caused mysql_client_test to randomly fail tests/mysql_client_test.c: More DBUG information Better usage of --silent Always print 'OK' the same way. Disable test_bug17667 if run outside of mysql-test-run --- include/errmsg.h | 3 +- libmysql/client_settings.h | 2 +- libmysql/errmsg.c | 3 + libmysql/libmysql.c | 4 +- sql-common/client.c | 12 ++- sql/net_serv.cc | 5 +- sql/sql_class.cc | 1 + sql/sql_parse.cc | 5 +- tests/mysql_client_test.c | 150 +++++++++++++++++++++---------------- 9 files changed, 112 insertions(+), 73 deletions(-) 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/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/sql-common/client.c b/sql-common/client.c index 89d69b4bd1f..d6fd98a1ed2 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) { #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) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index f4b940af898..778f82c92ef 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -298,7 +298,7 @@ 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 < 50100) +#if defined(EXTRA_DEBUG) fprintf(stderr,"Error: net_clear() skipped %d bytes from file: %s\n", count, vio_description(net->vio)); #endif @@ -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/sql_class.cc b/sql/sql_class.cc index 43f534d5404..f7b53141f46 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -420,6 +420,7 @@ void THD::init_for_queries() void THD::change_user(void) { cleanup(); + killed= NOT_KILLED; cleanup_done= 0; init(); stmt_map.reset(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 46f76db28ad..9c9a41a81fe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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; 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. */ - - /* Prepared statments always occurs twice in log */ - if (statement_cursor->qt == QT_PREPARED) - expected_hits++; - - /* Loop until we found expected number of log entries */ + /* Loop until we found expected number of log entries */ + do { + /* Loop until statement is found in log */ do { - /* Loop until statement is found in log */ - do { - memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); + 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"); + 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"); - } + 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); + } 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); - } + } + if (!opt_silent) 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)); - + 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); From 53fa178cb93f2cf67e0ba92bc20006dc58471f4f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Apr 2007 01:37:24 +0200 Subject: [PATCH 72/83] Bug#27775 mediumint auto_increment with ndb_restore - autoincrement column of size medium int not handled in ndb_restore - added testcase also for other types, tiny, small... etc --- mysql-test/r/ndb_restore.result | 29 ++++++++++++++++++---- mysql-test/t/ndb_restore.test | 33 ++++++++++++++++++++++---- ndb/tools/restore/Restore.hpp | 3 +++ ndb/tools/restore/consumer_restore.cpp | 4 ++-- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index be1f74a32e9..bc31798cee7 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', @@ -18,7 +18,7 @@ CREATE TABLE `t2_c` ( PRIMARY KEY (`capgotod`), 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; 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; @@ -255,6 +256,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 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; 520093696,1 diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 1169cc52b15..5b839a0d3aa 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -8,17 +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', @@ -29,7 +33,7 @@ CREATE TABLE `t2_c` ( PRIMARY KEY (`capgotod`), 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', @@ -38,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 '', @@ -49,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', @@ -67,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 '', @@ -141,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; 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; @@ -218,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'; --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9, t10; diff --git a/ndb/tools/restore/Restore.hpp b/ndb/tools/restore/Restore.hpp index 66e00d88dfe..c1545159ce4 100644 --- a/ndb/tools/restore/Restore.hpp +++ b/ndb/tools/restore/Restore.hpp @@ -219,6 +219,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/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp index d15cfea07df..811868f3e77 100644 --- a/ndb/tools/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -388,7 +388,7 @@ void BackupRestore::tuple_a(restore_callback_t *cb) Uint32 length = (size * arraySize) / 8; 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()) { @@ -602,7 +602,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()) From 719ef8a37aeb8d49fe040d2acd184acce2e21341 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Apr 2007 01:52:45 +0200 Subject: [PATCH 73/83] correct merge error --- mysql-test/r/ndb_restore.result | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index 396d724df49..b57fc2e14ba 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -245,20 +245,20 @@ a 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 +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 +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 +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 +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 +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; From 1d84f0c84464c99c60a69b9566bef367549a4e02 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Apr 2007 12:47:44 +0300 Subject: [PATCH 74/83] Merged from 5.0 --- mysql-test/r/grant.result | 20 +++--- sql/sql_parse.cc | 138 +++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 87 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 2dcfaf13198..f6bbc3d8c1a 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1106,16 +1106,6 @@ DROP DATABASE mysqltest2; DROP DATABASE mysqltest3; DROP DATABASE mysqltest4; DROP USER mysqltest_1@localhost; -End of 5.0 tests -set names utf8; -grant select on test.* to юзер_юзер@localhost; -user() -юзер_юзер@localhost -revoke all on test.* from юзер_юзер@localhost; -drop user юзер_юзер@localhost; -grant select on test.* to очень_длинный_юзер@localhost; -ERROR HY000: String 'очень_длинный_юзер' is too long for user name (should be no longer than 16) -set names default; DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; CREATE DATABASE mysqltest1; @@ -1191,3 +1181,13 @@ ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table ' 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; +user() +юзер_юзер@localhost +revoke all on test.* from юзер_юзер@localhost; +drop user юзер_юзер@localhost; +grant select on test.* to очень_длинный_юзер@localhost; +ERROR HY000: String 'очень_длинный_юзер' is too long for user name (should be no longer than 16) +set names default; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 53404792dea..df2ac4d72fa 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1358,8 +1358,8 @@ 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) { - DBUG_ENTER("prepare_schema_table"); SELECT_LEX *schema_select_lex= NULL; + DBUG_ENTER("prepare_schema_table"); switch (schema_table_idx) { case SCH_SCHEMATA: @@ -1393,6 +1393,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, 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); @@ -1403,32 +1404,23 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, #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: @@ -1454,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); } @@ -4691,74 +4683,57 @@ 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)) - { + switch (get_schema_table_idx(table->schema_table)) { case SCH_SCHEMATA: return (specialflag & SPECIAL_SKIP_SHOW_DB) && - check_global_access(thd, SHOW_DB_ACL); + 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)) { - 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; + 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= - (TABLE_LIST *) table->schema_select_lex->table_list.first; + { + TABLE_LIST *dst_table; + dst_table= (TABLE_LIST *) table->schema_select_lex->table_list.first; - DBUG_ASSERT(dst_table); + 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; - } + 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); - } - - case SCH_OPEN_TABLES: - case SCH_VARIABLES: - case SCH_STATUS: - case SCH_PROCEDURES: - case SCH_CHARSETS: - case SCH_COLLATIONS: - case SCH_COLLATION_CHARACTER_SET_APPLICABILITY: - case SCH_USER_PRIVILEGES: - case SCH_SCHEMA_PRIVILEGES: - case SCH_TABLE_PRIVILEGES: - case SCH_COLUMN_PRIVILEGES: - case SCH_TABLE_CONSTRAINTS: - case SCH_KEY_COLUMN_USAGE: + return (grant_option && + check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE)); + } + default: break; } @@ -4826,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; From 0a3abcf20d1497f2b4b9a0fdba2b280120a3b0f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Apr 2007 14:04:57 +0300 Subject: [PATCH 75/83] Avoid resetting a variable. Fixed grant.test. --- mysql-test/r/grant.result | 1 + mysql-test/t/grant.test | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index f6bbc3d8c1a..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; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 4867a6386c4..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; From 1cf3b96513db0ca2a0e217e2be512cdcaa04c82e Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Apr 2007 08:31:34 +0400 Subject: [PATCH 76/83] Bug#27321: Wrong subquery result in a grouping select. The Item_outer_ref class based on the Item_direct_ref class was always used to represent an outer field. But if the outer select is a grouping one and the outer field isn't under an aggregate function which is aggregated in that outer select an Item_ref object should be used to represent such a field. If the outer select in which the outer field is resolved isn't grouping then the Item_field class should be used to represent such a field. This logic also should be used for an outer field resolved through its alias name. Now the Item_field::fix_outer_field() uses Item_outer_field objects to represent aliased and non-aliased outer fields for grouping outer selects only. Now the fix_inner_refs() function chooses which class to use to access outer field - the Item_ref or the Item_direct_ref. An object of the chosen class substitutes the original field in the Item_outer_ref object. The direct_ref and the found_in_select_list fields were added to the Item_outer_ref class. mysql-test/t/subselect3.test: Some test cases were corrected after the fix for the bug#27321. mysql-test/r/subselect3.result: Some test cases were corrected after the fix for the bug#27321. mysql-test/t/subselect.test: Added a test case for the bug#27321: Wrong subquery result in a grouping select. mysql-test/r/subselect.result: Added a test case for the bug#27321: Wrong subquery result in a grouping select. Some test cases were corrected after this fix. sql/sql_union.cc: Bug#27321: Wrong subquery result in a grouping select. Cleanup of the inner_refs_list. sql/sql_select.cc: Bug#27321: Wrong subquery result in a grouping select. Now the fix_inner_refs() function chooses which class to use to access outer field - the Item_ref or the Item_direct_ref. An object of the chosen class substitutes the original field in the Item_outer_ref object. A comment is corrected. sql/item.cc: Bug#27321: Wrong subquery result in a grouping select. Now the Item_field::fix_outer_field() uses Item_outer_field objects to represent aliased and non-aliased outer fields for grouping outer selects only. sql/item.h: Bug#27321: Wrong subquery result in a grouping select. The direct_ref and the found_in_select_list fields were added to the Item_outer_ref class. --- mysql-test/r/subselect.result | 71 ++++++++++++++++++++++++-- mysql-test/r/subselect3.result | 10 +--- mysql-test/t/subselect.test | 37 ++++++++++++++ mysql-test/t/subselect3.test | 2 - sql/item.cc | 83 ++++++++++++++---------------- sql/item.h | 44 +++++++++++----- sql/sql_select.cc | 92 ++++++++++++++++++++++++++-------- sql/sql_union.cc | 1 + 8 files changed, 248 insertions(+), 92 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 81f087fe8fa..8357b209ae6 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 Extra 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED 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 Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1 Using where; Using index +2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 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 Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 Using where -2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 tt.id 1 Using where; Using index +2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 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,3 +3924,68 @@ 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; diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index 6a7a601ccf9..33e7fc54ed2 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 @@ -661,12 +661,6 @@ 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)); a b c -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; -a AVG(b) test -1 4.0000 NULL -2 2.0000 k -3 2.5000 NULL SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; a b c 1 3 c diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index efd54ca95d1..4d9bd789132 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2782,3 +2782,40 @@ SELECT COUNT(*) c, a, FROM t1 GROUP BY 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; diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index e3703c0da16..11468cd6759 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -507,8 +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)); -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/sql/item.cc b/sql/item.cc index 808e7925729..d1f64e30791 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1610,7 +1610,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); /* @@ -1624,7 +1624,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg, Field *f) :Item_ident(context_arg, f->table->s->db, *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 @@ -1663,7 +1663,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); @@ -1679,8 +1679,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); } @@ -3447,6 +3446,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; /* Currently derived tables cannot be correlated */ if (current_sel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE) @@ -3455,7 +3455,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; @@ -3498,45 +3498,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 == @@ -3642,11 +3625,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) @@ -5547,16 +5539,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 7b0d18e19c5..8364cf073c7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1221,7 +1221,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); @@ -1979,30 +1978,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 diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bb57764700d..1c0e1dfb8f8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -278,15 +278,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 @@ -299,33 +314,64 @@ fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, { Item_outer_ref *ref; bool res= FALSE; + bool direct_ref= FALSE; + List_iterator 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; @@ -478,10 +524,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; @@ -494,6 +536,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); @@ -5214,7 +5260,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, diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 1ec724a6338..7fb75732012 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -743,6 +743,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); } From 6ad00742b7e2f48b4da43707aed80e581af782e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Apr 2007 09:22:45 +0400 Subject: [PATCH 77/83] subselect.test, subselect.result: After merge fix. mysql-test/r/subselect.result: After merge fix. mysql-test/t/subselect.test: After merge fix. --- mysql-test/r/subselect.result | 1 + mysql-test/t/subselect.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 493a4c9a45f..94075df57b4 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -3988,6 +3988,7 @@ 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/t/subselect.test b/mysql-test/t/subselect.test index fd649ce2e03..482b3e883e6 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2818,6 +2818,7 @@ SELECT tt.a, MAX( 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 # From 3e8252ffc6ff28df8b0dbadcfea6ca506a731cbf Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Apr 2007 09:54:16 +0400 Subject: [PATCH 78/83] item.cc: Fix warning after fix for bug#27321. sql/item.cc: Fix warning after fix for bug#27321. --- sql/item.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 7ae5fef519c..ed5bd67d096 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3446,7 +3446,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; + SELECT_LEX *select= 0; /* Currently derived tables cannot be correlated */ if (current_sel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE) From cc76701e8f47ca52ca209150f49ba665a215c1d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Apr 2007 12:16:32 +0400 Subject: [PATCH 79/83] subselect.result: After merge fix. mysql-test/r/subselect.result: After merge fix. --- mysql-test/r/subselect.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 4023d613854..8263350fe58 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -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)))) From 48892844a9eab3c69143e1ae45690de3e947b650 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Apr 2007 17:08:29 +0300 Subject: [PATCH 80/83] Clear field_alloc when it's moved to result set (allows us to always call free_root on field_alloc) Change to use remove_file instead of 'system rm' in a lot of tests. (Should fix some windows test problems) Removed memory leak in mysql_test if sync_with_master fails. Do not terminate ndb_cluster_binary_log before the util thread has finnished. This should fix a shutdown bug where a thread is accessing injector_mutex after it's freed. Patch may fix Bug#27622 "mysqld shutdown, util thread continues, while binlog thread exits" client/mysqltest.c: Added missing 'mysql_free_result' (fixed confusing memory leak when sync_with_master fails)ug mysql-test/mysql-test-run.pl: Add the test case name to the instance manager log files mysql-test/r/rpl_log_pos.result: Made test more portable (for powermac) mysql-test/t/disabled.def: Disabled im_life_cycle (added bug#27851) mysql-test/t/myisam-system.test: Use remove_file instead of "system rm" mysql-test/t/ndb_autodiscover.test: Use remove_file instead of "system rm" mysql-test/t/ndb_loaddatalocal.test: Use remove_file instead of "system rm" mysql-test/t/rpl_loaddatalocal.test: Use remove_file instead of "system rm" mysql-test/t/rpl_log_pos.test: Made test more portable (for powermac) mysql-test/t/rpl_misc_functions.test: Use remove_file instead of "system rm" mysql-test/t/rpl_rbr_to_sbr.test: Use remove_file instead of "system rm" mysql-test/t/rpl_row_NOW.test: Use remove_file instead of "system rm" mysql-test/t/rpl_row_sp001.test: Use remove_file instead of "system rm" mysql-test/t/rpl_row_sp011.test: Use remove_file instead of "system rm" mysql-test/t/show_check.test: Use remove_file instead of "system rm" mysys/my_alloc.c: Don't return on zero argument, as this may hide other errors server-tools/instance-manager/log.cc: Log errors to both stdout and stderr (to know in which context we got the error) server-tools/instance-manager/thread_registry.cc: Log error before common assert (to know in which context we fail) sql/ha_ndbcluster.cc: Do not terminate ndb_cluster_binary_log before the util thread has finnished. sql/ha_ndbcluster.h: Do not terminate ndb_cluster_binary_log before the util thread has finnished. sql/ha_ndbcluster_binlog.cc: Do not terminate ndb_cluster_binary_log before the util thread has finnished. sql-common/client.c: Clear field_alloc when it's moved to result set (allows us to always call free_root on field_alloc) --- client/mysqltest.c | 5 ++- mysql-test/mysql-test-run.pl | 14 +++++--- mysql-test/r/rpl_log_pos.result | 2 +- mysql-test/t/disabled.def | 1 + mysql-test/t/myisam-system.test | 6 ++-- mysql-test/t/ndb_autodiscover.test | 32 +++++++++---------- mysql-test/t/ndb_loaddatalocal.test | 8 ++--- mysql-test/t/rpl_loaddatalocal.test | 4 +-- mysql-test/t/rpl_log_pos.test | 2 +- mysql-test/t/rpl_misc_functions.test | 4 +-- mysql-test/t/rpl_rbr_to_sbr.test | 4 +-- mysql-test/t/rpl_row_NOW.test | 4 +-- mysql-test/t/rpl_row_sp001.test | 4 +-- mysql-test/t/rpl_row_sp011.test | 4 +-- mysql-test/t/show_check.test | 3 +- mysys/my_alloc.c | 2 -- server-tools/instance-manager/log.cc | 8 ++++- .../instance-manager/thread_registry.cc | 7 ++-- sql-common/client.c | 4 ++- sql/ha_ndbcluster.cc | 2 +- sql/ha_ndbcluster.h | 4 ++- sql/ha_ndbcluster_binlog.cc | 22 ++++++++++++- 22 files changed, 92 insertions(+), 54 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index e4eb06953e2..8b5c657f75f 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); 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/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 diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 121d0dabf3c..dc949df6795 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/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/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_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/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 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_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/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/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/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 #include - #include - +#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 d6fd98a1ed2..2c09498d8f4 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2604,7 +2604,7 @@ static void mysql_close_free(MYSQL *mysql) */ void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)), - const char *func_name) + const char *func_name __attribute__((unused))) { #ifdef MYSQL_CLIENT /* Reset connection handle in all prepared statements. */ @@ -2828,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 */ @@ -2877,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/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9721b877e01..8a3675483ef 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -133,7 +133,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; diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index fe79135a47d..72e03fc2edd 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -1004,4 +1004,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 1c5db73ef6e..95b72cba64a 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); From 3cf4fb660f7838158b8ea7dc89551caa4868bbfe Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Apr 2007 16:55:37 +0200 Subject: [PATCH 81/83] Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() tests for the bug and associated is moved into another file because they appeared to be binlog-format sensitive. mysql-test/r/sp_trans.result: results changed mysql-test/t/sp_trans.test: binlog format sensitive piece of test moved to sp_trans_log. mysql-test/r/sp_trans_log.result: new results mysql-test/t/sp_trans_log.test: binlog-format sensitive part of sp_trans.test --- mysql-test/r/sp_trans.result | 25 ------------------- mysql-test/r/sp_trans_log.result | 28 +++++++++++++++++++++ mysql-test/t/sp_trans.test | 31 ----------------------- mysql-test/t/sp_trans_log.test | 42 ++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 56 deletions(-) create mode 100644 mysql-test/r/sp_trans_log.result create mode 100644 mysql-test/t/sp_trans_log.test diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index c976ea7a415..a0d687e565b 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -556,28 +556,3 @@ f1 bug13575(f1) 3 ccc drop function bug13575| drop table t3| -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 diff --git a/mysql-test/r/sp_trans_log.result b/mysql-test/r/sp_trans_log.result new file mode 100644 index 00000000000..a0bfcb26bf8 --- /dev/null +++ b/mysql-test/r/sp_trans_log.result @@ -0,0 +1,28 @@ +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| +Warnings: +Warning 1266 Using storage engine MyISAM for table 't2' +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 # # +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/t/sp_trans.test b/mysql-test/t/sp_trans.test index d57fb980956..a79f6c7e7e0 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -592,37 +592,6 @@ drop function bug13575| drop table t3| -# -# 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 */| - # # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/sp_trans_log.test b/mysql-test/t/sp_trans_log.test new file mode 100644 index 00000000000..aeb510b6360 --- /dev/null +++ b/mysql-test/t/sp_trans_log.test @@ -0,0 +1,42 @@ +# part of sp_trans test that appeared to be sensitive to binlog format +--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; From 10b96122cfbe746c5d23d1321f554092ee6be9b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Apr 2007 19:20:46 +0200 Subject: [PATCH 82/83] Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() refining the test with active innodb mysql-test/r/sp_trans_log.result: changed mysql-test/t/sp_trans_log.test: innodb activated --- mysql-test/r/sp_trans_log.result | 3 +-- mysql-test/t/sp_trans_log.test | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/sp_trans_log.result b/mysql-test/r/sp_trans_log.result index a0bfcb26bf8..a835b06858b 100644 --- a/mysql-test/r/sp_trans_log.result +++ b/mysql-test/r/sp_trans_log.result @@ -2,8 +2,6 @@ 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| -Warnings: -Warning 1266 Using storage engine MyISAM for table 't2' insert into t2 values (1,1)| create function bug23333() RETURNS int(11) @@ -21,6 +19,7 @@ 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 diff --git a/mysql-test/t/sp_trans_log.test b/mysql-test/t/sp_trans_log.test index aeb510b6360..cc3b2531bed 100644 --- a/mysql-test/t/sp_trans_log.test +++ b/mysql-test/t/sp_trans_log.test @@ -1,4 +1,5 @@ # 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 |; From 763f105dff3aada394cd7c6b94b3e5867f79c1b9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Apr 2007 14:41:16 +0300 Subject: [PATCH 83/83] Fixed federated and some replication tests to not stop slave until it's up and running. (Removes some warnings about UNIX_TIMESTAMP from the slave.err logs) Marked federated_server as a '--big-test' Change error in net_clear to 'Note', as it interfered with mysql-test-run. client/mysqltest.c: More DBUG messages Adding missing DBUG_RETURN mysql-test/extra/rpl_tests/rpl_max_relay_size.test: Added missing sync_slave_with_master mysql-test/extra/rpl_tests/rpl_relayrotate.test: Added missing sync_slave_with_master mysql-test/include/federated.inc: Don't do stop slave before the slave has started properly (Removes some warnings about UNIX_TIMESTAMP from the slave.err logs) mysql-test/include/federated_cleanup.inc: Trivial cleanup mysql-test/t/federated_server.test: Don't run this unless under --big-test Made test-loop smaller. (We will find out errors in code over time, as the test is run under a lot of difference machines which will compensate for the smaller loop) mysql-test/t/rpl_flushlog_loop.test: Added missing sync_slave_with_master sql/net_serv.cc: Change error to Note (low level warning), as it interfered with mysql-test-run. This is probably fine as we in some context on sever shutdown can get information about connection shutdown on the connection while we are doing a query at the same time. Still, in normal context one should get this, so it's good to have it in the log as it enables one to find errors easier. sql/slave.cc: Added reason to why things failed to error message --- client/mysqltest.c | 7 ++++--- mysql-test/extra/rpl_tests/rpl_max_relay_size.test | 3 +++ mysql-test/extra/rpl_tests/rpl_relayrotate.test | 4 ++++ mysql-test/include/federated.inc | 5 +++++ mysql-test/include/federated_cleanup.inc | 2 -- mysql-test/t/federated_server.test | 5 +++-- mysql-test/t/rpl_flushlog_loop.test | 3 +++ sql/net_serv.cc | 2 +- sql/slave.cc | 6 ++++-- 9 files changed, 27 insertions(+), 10 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 8b5c657f75f..360409e9611 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2552,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); @@ -2709,7 +2710,7 @@ int do_save_master_pos() if (rpl_parse) mysql_enable_rpl_parse(mysql); - return 0; + DBUG_RETURN(0); } @@ -3164,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))) @@ -3187,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/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/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/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/sql/net_serv.cc b/sql/net_serv.cc index 778f82c92ef..719e2ee0d3c 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -299,7 +299,7 @@ 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) - fprintf(stderr,"Error: net_clear() skipped %d bytes from file: %s\n", + fprintf(stderr,"Note: net_clear() skipped %d bytes from file: %s\n", count, vio_description(net->vio)); #endif } diff --git a/sql/slave.cc b/sql/slave.cc index 2e2fd93ea86..1064fb27c4e 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -794,8 +794,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);