diff options
380 files changed, 21908 insertions, 6179 deletions
diff --git a/.gitignore b/.gitignore index 4c7efe9a119..f2064537da4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ Docs/INFO_SRC Makefile TAGS Testing/ +tmp/ VERSION.dep configure client/async_example diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 13c642df932..f09ad3107cc 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -703,7 +703,7 @@ public: DBUG_ASSERT(ds->str); #ifdef EXTRA_DEBUG - DBUG_PRINT("QQ", ("str: %*s", (int) ds->length, ds->str)); + DBUG_PRINT("extra", ("str: %*s", (int) ds->length, ds->str)); #endif if (fwrite(ds->str, 1, ds->length, m_file) != ds->length) diff --git a/config.h.cmake b/config.h.cmake index 048ce816a43..f35e33ebe1a 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -189,6 +189,7 @@ #cmakedefine HAVE_PREAD 1 #cmakedefine HAVE_PAUSE_INSTRUCTION 1 #cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1 +#cmakedefine HAVE_HMT_PRIORITY_INSTRUCTION 1 #cmakedefine HAVE_RDTSCLL 1 #cmakedefine HAVE_READ_REAL_TIME 1 #cmakedefine HAVE_PTHREAD_ATTR_CREATE 1 diff --git a/configure.cmake b/configure.cmake index 294c5e24ca8..4470bee3223 100644 --- a/configure.cmake +++ b/configure.cmake @@ -784,6 +784,17 @@ IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC) } " HAVE_FAKE_PAUSE_INSTRUCTION) ENDIF() + IF (NOT HAVE_PAUSE_INSTRUCTION) + CHECK_C_SOURCE_COMPILES(" + #include <sys/platform/ppc.h> + int main() + { + __ppc_set_ppr_low(); + __ppc_set_ppr_med(); + return 0; + } + " HAVE_HMT_PRIORITY_INSTRUCTION) + ENDIF() ENDIF() CHECK_SYMBOL_EXISTS(tcgetattr "termios.h" HAVE_TCGETATTR 1) diff --git a/extra/comp_err.c b/extra/comp_err.c index 3fc4b05fa61..2bab6b60be7 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -32,9 +32,11 @@ #include <my_getopt.h> #include <my_dir.h> -#define MAX_ROWS 2000 +#define MAX_ROWS 3000 +#define ERRORS_PER_RANGE 1000 +#define MAX_SECTIONS 4 #define HEADER_LENGTH 32 /* Length of header in errmsg.sys */ -#define ERRMSG_VERSION 3 /* Version number of errmsg.sys */ +#define ERRMSG_VERSION 4 /* Version number of errmsg.sys */ #define DEFAULT_CHARSET_DIR "../sql/share/charsets" #define ER_PREFIX "ER_" #define ER_PREFIX2 "MARIA_ER_" @@ -53,6 +55,8 @@ static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace"; uchar file_head[]= { 254, 254, 2, ERRMSG_VERSION }; /* Store positions to each error message row to store in errmsg.sys header */ uint file_pos[MAX_ROWS+1]; +uint section_count,section_start; +uchar section_header[MAX_SECTIONS*2]; const char *empty_string= ""; /* For empty states */ /* @@ -131,7 +135,7 @@ static struct my_option my_long_options[]= }; -static struct errors *generate_empty_message(uint dcode); +static struct errors *generate_empty_message(uint dcode, my_bool skip); static struct languages *parse_charset_string(char *str); static struct errors *parse_error_string(char *ptr, int er_count); static struct message *parse_message_string(struct message *new_message, @@ -140,8 +144,9 @@ static struct message *find_message(struct errors *err, const char *lang, my_bool no_default); static int check_message_format(struct errors *err, const char* mess); -static int parse_input_file(const char *file_name, struct errors **top_error, - struct languages **top_language); +static uint parse_input_file(const char *file_name, struct errors **top_error, + struct languages **top_language, + uint *error_count); static int get_options(int *argc, char ***argv); static void print_version(void); static void usage(void); @@ -158,14 +163,15 @@ static char *find_end_of_word(char *str); static void clean_up(struct languages *lang_head, struct errors *error_head); static int create_header_files(struct errors *error_head); static int create_sys_files(struct languages *lang_head, - struct errors *error_head, uint row_count); + struct errors *error_head, uint max_error, + uint error_count); int main(int argc, char *argv[]) { MY_INIT(argv[0]); { - uint row_count; + uint max_error, error_count; struct errors *error_head; struct languages *lang_head; DBUG_ENTER("main"); @@ -173,32 +179,39 @@ int main(int argc, char *argv[]) charsets_dir= DEFAULT_CHARSET_DIR; my_umask_dir= 0777; if (get_options(&argc, &argv)) - DBUG_RETURN(1); - if (!(row_count= parse_input_file(TXTFILE, &error_head, &lang_head))) + goto err; + if (!(max_error= parse_input_file(TXTFILE, &error_head, &lang_head, + &error_count))) { fprintf(stderr, "Failed to parse input file %s\n", TXTFILE); - DBUG_RETURN(1); + goto err; } if (lang_head == NULL || error_head == NULL) { fprintf(stderr, "Failed to parse input file %s\n", TXTFILE); - DBUG_RETURN(1); + goto err; } if (create_header_files(error_head)) { fprintf(stderr, "Failed to create header files\n"); - DBUG_RETURN(1); + goto err; } - if (create_sys_files(lang_head, error_head, row_count)) + if (create_sys_files(lang_head, error_head, max_error, error_count)) { fprintf(stderr, "Failed to create sys files\n"); - DBUG_RETURN(1); + goto err; } clean_up(lang_head, error_head); DBUG_LEAVE; /* Can't use dbug after my_end() */ my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); return 0; + +err: + clean_up(lang_head, error_head); + DBUG_LEAVE; /* Can't use dbug after my_end() */ + my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); + exit(1); } } @@ -226,6 +239,7 @@ static void print_escaped_string(FILE *f, const char *str) static int create_header_files(struct errors *error_head) { uint er_last= 0; + uint section= 1; FILE *er_definef, *sql_statef, *er_namef; struct errors *tmp_error; struct message *er_msg; @@ -266,8 +280,19 @@ static int create_header_files(struct errors *error_head) if (!tmp_error->er_name) continue; /* Placeholder for gap */ - if (tmp_error->d_code > current_d_code + 1) + while (tmp_error->d_code > current_d_code + 1) + { + uint next_range= (((current_d_code + ERRORS_PER_RANGE) / + ERRORS_PER_RANGE) * ERRORS_PER_RANGE); + + fprintf(er_definef, "#define ER_ERROR_LAST_SECTION_%d %d\n", section, + current_d_code); fprintf(er_definef, "\n/* New section */\n\n"); + fprintf(er_definef, "#define ER_ERROR_FIRST_SECTION_%d %d\n", section+1, + MY_MIN(tmp_error->d_code, next_range)); + section++; + current_d_code= MY_MIN(tmp_error->d_code, next_range); + } current_d_code= tmp_error->d_code; fprintf(er_definef, "#define %s %u\n", tmp_error->er_name, @@ -297,17 +322,18 @@ static int create_header_files(struct errors *error_head) static int create_sys_files(struct languages *lang_head, - struct errors *error_head, uint row_count) + struct errors *error_head, + uint max_error, + uint error_count) { FILE *to; uint csnum= 0, length, i, row_nr; - uchar head[32]; + uchar head[HEADER_LENGTH]; char outfile[FN_REFLEN], *outfile_end; long start_pos; struct message *tmp; struct languages *tmp_lang; struct errors *tmp_error; - MY_STAT stat_info; DBUG_ENTER("create_sys_files"); @@ -331,7 +357,7 @@ static int create_sys_files(struct languages *lang_head, { if (my_mkdir(outfile, 0777,MYF(0)) < 0) { - fprintf(stderr, "Can't create output directory for %s\n", + fprintf(stderr, "Can't creqate output directory for %s\n", outfile); DBUG_RETURN(1); } @@ -343,8 +369,8 @@ static int create_sys_files(struct languages *lang_head, DBUG_RETURN(1); /* 2 is for 2 bytes to store row position / error message */ - start_pos= (long) (HEADER_LENGTH + row_count * 2); - fseek(to, start_pos, 0); + start_pos= (long) (HEADER_LENGTH + (error_count + section_count) * 2); + my_fseek(to, start_pos, 0, MYF(0)); row_nr= 0; for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error) { @@ -358,29 +384,38 @@ static int create_sys_files(struct languages *lang_head, "language\n", tmp_error->er_name, tmp_lang->lang_short_name); goto err; } - if (copy_rows(to, tmp->text, row_nr, start_pos)) + if (tmp->text) /* If not skipped row */ { - fprintf(stderr, "Failed to copy rows to %s\n", outfile); - goto err; + if (copy_rows(to, tmp->text, row_nr, start_pos)) + { + fprintf(stderr, "Failed to copy rows to %s\n", outfile); + goto err; + } + row_nr++; } - row_nr++; } + DBUG_ASSERT(error_count == row_nr); /* continue with header of the errmsg.sys file */ - length= ftell(to) - HEADER_LENGTH - row_count * 2; + length= (my_ftell(to, MYF(0)) - HEADER_LENGTH - + (error_count + section_count) * 2); bzero((uchar*) head, HEADER_LENGTH); - bmove((uchar *) head, (uchar *) file_head, 4); + bmove((uchar*) head, (uchar*) file_head, 4); head[4]= 1; int4store(head + 6, length); - int2store(head + 10, row_count); + int2store(head + 10, max_error); /* Max error */ + int2store(head + 12, row_nr); + int2store(head + 14, section_count); head[30]= csnum; my_fseek(to, 0l, MY_SEEK_SET, MYF(0)); - if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) + if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP)) || + my_fwrite(to, (uchar*) section_header, section_count*2, + MYF(MY_WME | MY_FNABP))) goto err; - file_pos[row_count]= (ftell(to) - start_pos); - for (i= 0; i < row_count; i++) + file_pos[row_nr]= (ftell(to) - start_pos); + for (i= 0; i < row_nr; i++) { /* Store length of each string */ int2store(head, file_pos[i+1] - file_pos[i]); @@ -437,24 +472,29 @@ static void clean_up(struct languages *lang_head, struct errors *error_head) } -static int parse_input_file(const char *file_name, struct errors **top_error, - struct languages **top_lang) +static uint parse_input_file(const char *file_name, struct errors **top_error, + struct languages **top_lang, uint *error_count) { FILE *file; char *str, buff[1000]; struct errors *current_error= 0, **tail_error= top_error; struct message current_message; - uint rcount= 0; + uint rcount= 0, skiped_errors= 0; my_bool er_offset_found= 0; DBUG_ENTER("parse_input_file"); *top_error= 0; *top_lang= 0; + *error_count= 0; + section_start= er_offset; + section_count= 0; + if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME)))) DBUG_RETURN(0); while ((str= fgets(buff, sizeof(buff), file))) { + my_bool skip; if (is_prefix(str, "language")) { if (!(*top_lang= parse_charset_string(str))) @@ -464,18 +504,34 @@ static int parse_input_file(const char *file_name, struct errors **top_error, } continue; } - if (is_prefix(str, "start-error-number")) + skip= 0; + if (is_prefix(str, "start-error-number") || + (skip= is_prefix(str, "skip-to-error-number"))) { uint tmp_er_offset; + if (!(tmp_er_offset= parse_error_offset(str))) { fprintf(stderr, "Failed to parse the error offset string!\n"); DBUG_RETURN(0); } + if (skip) + { + if (section_count >= MAX_SECTIONS-1) + { + fprintf(stderr, "Found too many skip-to-error-number entries. " + "We only support %d entries\n", MAX_SECTIONS); + DBUG_RETURN(0); + } + int2store(section_header + section_count*2, + er_offset +rcount - section_start); + section_count++; + section_start= tmp_er_offset; + } if (!er_offset_found) { er_offset_found= 1; - er_offset= tmp_er_offset; + er_offset= section_start= tmp_er_offset; } else { @@ -487,7 +543,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error, } for ( ; er_offset + rcount < tmp_er_offset ; rcount++) { - current_error= generate_empty_message(er_offset + rcount); + skiped_errors+= skip != 0; + current_error= generate_empty_message(er_offset + rcount, skip); *tail_error= current_error; tail_error= ¤t_error->next_error; } @@ -559,6 +616,11 @@ static int parse_input_file(const char *file_name, struct errors **top_error, fprintf(stderr, "Wrong input file format. Stop!\nLine: %s\n", str); DBUG_RETURN(0); } + int2store(section_header + section_count*2, + er_offset + rcount - section_start); + section_count++; + *error_count= rcount - skiped_errors; + *tail_error= 0; /* Mark end of list */ my_fclose(file, MYF(0)); @@ -887,7 +949,7 @@ static struct message *parse_message_string(struct message *new_message, } -static struct errors *generate_empty_message(uint d_code) +static struct errors *generate_empty_message(uint d_code, my_bool skip) { struct errors *new_error; struct message message; @@ -896,7 +958,8 @@ static struct errors *generate_empty_message(uint d_code) if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error), MYF(MY_WME)))) return(0); - if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1, MYF(0))) + if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1, + MYF(0))) return(0); /* OOM: Fatal error */ new_error->er_name= NULL; @@ -904,8 +967,10 @@ static struct errors *generate_empty_message(uint d_code) new_error->sql_code1= empty_string; new_error->sql_code2= empty_string; + message.text= 0; /* If skip set, don't generate a text */ + if (!(message.lang_short_name= my_strdup(default_language, MYF(MY_WME))) || - !(message.text= my_strdup("", MYF(MY_WME)))) + (!skip && !(message.text= my_strdup("", MYF(MY_WME))))) return(0); /* Can't fail as msg is preallocated */ @@ -1071,10 +1136,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__ ((unused)), switch (optid) { case 'V': print_version(); + my_end(0); exit(0); break; case '?': usage(); + my_end(0); exit(0); break; case '#': diff --git a/include/my_sys.h b/include/my_sys.h index 36530eb94e9..7b7158573b4 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -689,7 +689,7 @@ extern void my_osmaperr(unsigned long last_error); #endif extern void init_glob_errs(void); -extern const char** get_global_errmsgs(void); +extern const char** get_global_errmsgs(int nr); extern void wait_for_free_space(const char *filename, int errors); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); @@ -714,9 +714,9 @@ extern void my_printf_error(uint my_err, const char *format, ATTRIBUTE_FORMAT(printf, 2, 4); extern void my_printv_error(uint error, const char *format, myf MyFlags, va_list ap); -extern int my_error_register(const char** (*get_errmsgs) (void), +extern int my_error_register(const char** (*get_errmsgs) (int nr), uint first, uint last); -extern const char **my_error_unregister(uint first, uint last); +extern my_bool my_error_unregister(uint first, uint last); extern void my_message(uint my_err, const char *str,myf MyFlags); extern void my_message_stderr(uint my_err, const char *str, myf MyFlags); extern my_bool my_init(void); diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index cfa4b13a7ef..b3c71c65488 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -194,8 +194,10 @@ struct st_mysql_show_var { enum enum_mysql_show_type type; }; +struct system_status_var; + #define SHOW_VAR_FUNC_BUFF_SIZE (256 * sizeof(void*)) -typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, void *, enum enum_var_type); +typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); /* diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 8fc935262e2..aaf41c74a54 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -281,7 +281,8 @@ struct st_mysql_show_var { void *value; enum enum_mysql_show_type type; }; -typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type); +struct system_status_var; +typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); struct st_mysql_sys_var; struct st_mysql_value; typedef int (*mysql_var_check_func)(void* thd, diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 046f92b5ab8..10cd10bf9c8 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -281,7 +281,8 @@ struct st_mysql_show_var { void *value; enum enum_mysql_show_type type; }; -typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type); +struct system_status_var; +typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); struct st_mysql_sys_var; struct st_mysql_value; typedef int (*mysql_var_check_func)(void* thd, diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index 850dbf05a58..46d3c3d5a55 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -281,7 +281,8 @@ struct st_mysql_show_var { void *value; enum enum_mysql_show_type type; }; -typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type); +struct system_status_var; +typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); struct st_mysql_sys_var; struct st_mysql_value; typedef int (*mysql_var_check_func)(void* thd, diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index ee1056a36d7..17de800875e 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -281,7 +281,8 @@ struct st_mysql_show_var { void *value; enum enum_mysql_show_type type; }; -typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type); +struct system_status_var; +typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); struct st_mysql_sys_var; struct st_mysql_value; typedef int (*mysql_var_check_func)(void* thd, diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 0f14ac1eb53..1abdbd30f57 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -281,7 +281,8 @@ struct st_mysql_show_var { void *value; enum enum_mysql_show_type type; }; -typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, enum enum_var_type); +struct system_status_var; +typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); struct st_mysql_sys_var; struct st_mysql_value; typedef int (*mysql_var_check_func)(void* thd, diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index e30cdc9762b..fc5a6a07e11 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -90,7 +90,7 @@ const char *client_errors[]= "" }; -const char** get_client_errmsgs(void) +const char** get_client_errmsgs(int nr __attribute__((unused))) { return client_errors; } diff --git a/libmysql/get_password.c b/libmysql/get_password.c index e704aec8337..a113306ed57 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -46,7 +46,7 @@ #endif #endif #ifdef alpha_linux_port -#include <asm/ioctls.h> /* QQ; Fix this in configure */ +#include <asm/ioctls.h> #include <asm/termiobits.h> #endif #else diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 2081e7558d5..ad16584ec0e 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -109,6 +109,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/table_cache.cc ../sql/mf_iocache_encr.cc ../sql/item_inetfunc.cc ../sql/wsrep_dummy.cc ../sql/encryption.cc + ../sql/item_windowfunc.cc ../sql/sql_window.cc ../sql/sql_cte.cc ${GEN_SOURCES} ${MYSYS_LIBWRAP_SOURCE} diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 476981023fd..a067856b287 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -517,6 +517,9 @@ int init_embedded_server(int argc, char **argv, char **groups) if (my_thread_init()) return 1; + if (init_early_variables()) + return 1; + if (argc) { argcp= &argc; diff --git a/mysql-test/include/crash_mysqld.inc b/mysql-test/include/crash_mysqld.inc new file mode 100644 index 00000000000..4190d24d801 --- /dev/null +++ b/mysql-test/include/crash_mysqld.inc @@ -0,0 +1,18 @@ +# Crash mysqld hard and wait until it's restarted + +--source include/have_debug_sync.inc +--source include/not_embedded.inc + +# Write file to make mysql-test-run.pl expect crash and restart +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +# Setup the mysqld to crash at shutdown +SET debug_dbug="d,crash_shutdown"; +--error 2013 +shutdown; + +# Turn on reconnect +--enable_reconnect + +# Call script that will poll the server waiting for it to be back online again +--source include/wait_until_connected_again.inc diff --git a/mysql-test/include/galera_connect.inc b/mysql-test/include/galera_connect.inc index 9d458c5e063..a40b03bf421 100644 --- a/mysql-test/include/galera_connect.inc +++ b/mysql-test/include/galera_connect.inc @@ -37,12 +37,15 @@ if (!$_galera_port) if ($galera_debug) { +--disable_query_log --echo connect($galera_connection_name,127.0.0.1,root,,test,$_galera_port,) +--enable_query_log } # Temporal solution to avoid concurrent IST MDEV-7178 --sleep 1 # Open a connection +--disable_query_log --connect($galera_connection_name,127.0.0.1,root,,test,$_galera_port,) - +--enable_query_log diff --git a/mysql-test/r/analyze_format_json.result b/mysql-test/r/analyze_format_json.result index 4f8876a8414..fadbe705f99 100644 --- a/mysql-test/r/analyze_format_json.result +++ b/mysql-test/r/analyze_format_json.result @@ -492,8 +492,9 @@ ANALYZE "select_id": 1, "r_loops": 1, "volatile parameter": "REPLACED", - "having_condition": "(TOP > a)", + "having_condition": "(TOP > t2.a)", "filesort": { + "sort_key": "t2.a", "r_loops": 1, "volatile parameter": "REPLACED", "r_used_priority_queue": false, @@ -523,6 +524,7 @@ ANALYZE "r_loops": 1, "volatile parameter": "REPLACED", "filesort": { + "sort_key": "t2.a", "r_loops": 1, "volatile parameter": "REPLACED", "r_used_priority_queue": false, @@ -563,6 +565,7 @@ ANALYZE "r_loops": 1, "volatile parameter": "REPLACED", "filesort": { + "sort_key": "t2.a", "r_loops": 1, "volatile parameter": "REPLACED", "r_used_priority_queue": false, @@ -684,18 +687,20 @@ ANALYZE "r_loops": 1, "volatile parameter": "REPLACED", "filesort": { + "sort_key": "group_concat(t3.f3 separator ',')", "r_loops": 1, "volatile parameter": "REPLACED", "r_used_priority_queue": false, "r_output_rows": 0, "volatile parameter": "REPLACED", - "filesort": { - "r_loops": 1, - "volatile parameter": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 0, - "volatile parameter": "REPLACED", - "temporary_table": { + "temporary_table": { + "filesort": { + "sort_key": "(subquery#2)", + "r_loops": 1, + "volatile parameter": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 0, + "volatile parameter": "REPLACED", "temporary_table": { "table": { "table_name": "t2", diff --git a/mysql-test/r/analyze_stmt_orderby.result b/mysql-test/r/analyze_stmt_orderby.result index be1f01a2a52..37f0005148e 100644 --- a/mysql-test/r/analyze_stmt_orderby.result +++ b/mysql-test/r/analyze_stmt_orderby.result @@ -172,8 +172,8 @@ EXPLAIN "query_block": { "select_id": 1, "filesort": { + "sort_key": "t2.b", "temporary_table": { - "function": "buffer", "table": { "table_name": "t0", "access_type": "ALL", @@ -205,6 +205,7 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { + "sort_key": "t2.b", "r_loops": 1, "r_total_time_ms": "REPLACED", "r_limit": 4, @@ -257,6 +258,7 @@ EXPLAIN "select_id": 1, "read_sorted_file": { "filesort": { + "sort_key": "t0.a", "table": { "table_name": "t0", "access_type": "ALL", @@ -290,6 +292,7 @@ ANALYZE "read_sorted_file": { "r_rows": 10, "filesort": { + "sort_key": "t0.a", "r_loops": 1, "r_total_time_ms": "REPLACED", "r_used_priority_queue": false, @@ -346,6 +349,7 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { + "sort_key": "t2.c", "r_loops": 1, "r_total_time_ms": "REPLACED", "r_used_priority_queue": false, @@ -455,18 +459,20 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "filesort": { + "sort_key": "count(distinct t5.b)", "r_loops": 1, "r_total_time_ms": "REPLACED", "r_limit": 1, "r_used_priority_queue": true, "r_output_rows": 2, - "filesort": { - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 6, - "r_buffer_size": "REPLACED", - "temporary_table": { + "temporary_table": { + "filesort": { + "sort_key": "t5.a", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 6, + "r_buffer_size": "REPLACED", "temporary_table": { "table": { "table_name": "t6", @@ -511,26 +517,31 @@ EXPLAIN "query_block": { "select_id": 1, "filesort": { + "sort_key": "count(distinct t5.b)", "temporary_table": { - "function": "buffer", - "table": { - "table_name": "t6", - "access_type": "ALL", - "rows": 5, - "filtered": 100, - "attached_condition": "((t6.b > 0) and (t6.a <= 5))" - }, - "block-nl-join": { - "table": { - "table_name": "t5", - "access_type": "ALL", - "rows": 7, - "filtered": 100 - }, - "buffer_type": "flat", - "buffer_size": "256Kb", - "join_type": "BNL", - "attached_condition": "(t5.a = t6.a)" + "filesort": { + "sort_key": "t5.a", + "temporary_table": { + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "((t6.b > 0) and (t6.a <= 5))" + }, + "block-nl-join": { + "table": { + "table_name": "t5", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "256Kb", + "join_type": "BNL", + "attached_condition": "(t5.a = t6.a)" + } + } } } } diff --git a/mysql-test/r/connect2.result b/mysql-test/r/connect2.result index b68f7ae7c43..5430626a533 100644 --- a/mysql-test/r/connect2.result +++ b/mysql-test/r/connect2.result @@ -1,6 +1,7 @@ call mtr.add_suppression("Allocation failed"); SET @old_debug= @@session.debug; set @old_thread_cache_size=@@global.thread_cache_size; +set @@global.thread_cache_size=0; connect con1,localhost,root,,test,,; select 1; 1 diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result index df641156e61..a9c13f3f10b 100644 --- a/mysql-test/r/cte_nonrecursive.result +++ b/mysql-test/r/cte_nonrecursive.result @@ -746,3 +746,16 @@ with t(f1,f1) as (select * from t1 where b >= 'c') select t1.b from t2,t1 where t1.a = t2.c; ERROR 42S21: Duplicate column name 'f1' drop table t1,t2; +# +# Bug mdev-9937: View used in the specification of with table +# refers to the base table with the same name +# +create table t1 (a int); +insert into t1 values (20), (30), (10); +create view v1 as select * from t1 where a > 10; +with t1 as (select * from v1) select * from t1; +a +20 +30 +drop view v1; +drop table t1; diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result new file mode 100644 index 00000000000..7408bc56e63 --- /dev/null +++ b/mysql-test/r/cte_recursive.result @@ -0,0 +1,289 @@ +create table t1 (a int, b varchar(32)); +insert into t1 values +(4,'aaaa' ), (7,'bb'), (1,'ccc'), (4,'dd'); +insert into t1 values +(3,'eee'), (7,'bb'), (1,'fff'), (4,'ggg'); +with recursive +a1(a,b) as +(select * from t1 where t1.a>3 +union +select * from b1 where b1.a >3 +union +select * from c1 where c1.a>3), +b1(a,b) as +(select * from a1 where a1.b > 'ccc' +union +select * from c1 where c1.b > 'ddd'), +c1(a,b) as +(select * from a1 where a1.a<6 and a1.b< 'zz' +union +select * from b1 where b1.b > 'auu') +select * from c1; +ERROR HY000: No anchors for recursive WITH element 'b1' +drop table t1; +create table folks(id int, name char(32), dob date, father int, mother int); +insert into folks values +(100, 'Vasya', '2000-01-01', 20, 30), +(20, 'Dad', '1970-02-02', 10, 9), +(30, 'Mom', '1975-03-03', 8, 7), +(10, 'Grandpa Bill', '1940-04-05', null, null), +(9, 'Grandma Ann', '1941-10-15', null, null), +(25, 'Uncle Jim', '1968-11-18', 8, 7), +(98, 'Sister Amy', '2001-06-20', 20, 30), +(8, 'Grandma Sally', '1943-08-23', 5, 6), +(6, 'Grandgrandma Martha', '1923-05-17', null, null), +(67, 'Cousin Eddie', '1992-02-28', 25, 27), +(27, 'Auntie Melinda', '1971-03-29', null, null); +with recursive +ancestors +as +( +select * +from folks +where name = 'Vasya' and dob = '2000-01-01' + union +select p.id, p.name, p.dob, p.father, p.mother +from folks as p, ancestors AS a +where p.id = a.father or p.id = a.mother +) +select * from ancestors; +id name dob father mother +100 Vasya 2000-01-01 20 30 +20 Dad 1970-02-02 10 9 +30 Mom 1975-03-03 8 7 +10 Grandpa Bill 1940-04-05 NULL NULL +9 Grandma Ann 1941-10-15 NULL NULL +8 Grandma Sally 1943-08-23 5 6 +6 Grandgrandma Martha 1923-05-17 NULL NULL +with recursive +ancestors +as +( +select p.* +from folks as p, ancestors AS a +where p.id = a.father or p.id = a.mother +union +select * +from folks +where name = 'Vasya' and dob = '2000-01-01' +) +select * from ancestors; +id name dob father mother +100 Vasya 2000-01-01 20 30 +20 Dad 1970-02-02 10 9 +30 Mom 1975-03-03 8 7 +10 Grandpa Bill 1940-04-05 NULL NULL +9 Grandma Ann 1941-10-15 NULL NULL +8 Grandma Sally 1943-08-23 5 6 +6 Grandgrandma Martha 1923-05-17 NULL NULL +with recursive +ancestors +as +( +select * +from folks +where name = 'Cousin Eddie' + union +select p.* +from folks as p, ancestors as a +where p.id = a.father or p.id = a.mother +) +select * from ancestors; +id name dob father mother +67 Cousin Eddie 1992-02-28 25 27 +25 Uncle Jim 1968-11-18 8 7 +27 Auntie Melinda 1971-03-29 NULL NULL +8 Grandma Sally 1943-08-23 5 6 +6 Grandgrandma Martha 1923-05-17 NULL NULL +with recursive +ancestors +as +( +select * +from folks +where name = 'Vasya' or name='Sister Amy' + union +select p.* +from folks as p, ancestors as a +where p.id = a.father or p.id = a.mother +) +select * from ancestors; +id name dob father mother +100 Vasya 2000-01-01 20 30 +98 Sister Amy 2001-06-20 20 30 +20 Dad 1970-02-02 10 9 +30 Mom 1975-03-03 8 7 +10 Grandpa Bill 1940-04-05 NULL NULL +9 Grandma Ann 1941-10-15 NULL NULL +8 Grandma Sally 1943-08-23 5 6 +6 Grandgrandma Martha 1923-05-17 NULL NULL +with recursive +prev_gen +as +( +select folks.* +from folks, prev_gen +where folks.id=prev_gen.father or folks.id=prev_gen.mother +union +select * +from folks +where name='Vasya' +), +ancestors +as +( +select * +from folks +where name='Vasya' + union +select * +from ancestors +union +select * +from prev_gen +) +select ancestors.name, ancestors.dob from ancestors; +name dob +Vasya 2000-01-01 +Dad 1970-02-02 +Mom 1975-03-03 +Grandpa Bill 1940-04-05 +Grandma Ann 1941-10-15 +Grandma Sally 1943-08-23 +Grandgrandma Martha 1923-05-17 +with recursive +descendants +as +( +select * +from folks +where name = 'Grandpa Bill' + union +select folks.* +from folks, descendants as d +where d.id=folks.father or d.id=folks.mother +) +select * from descendants; +id name dob father mother +10 Grandpa Bill 1940-04-05 NULL NULL +20 Dad 1970-02-02 10 9 +100 Vasya 2000-01-01 20 30 +98 Sister Amy 2001-06-20 20 30 +with recursive +descendants +as +( +select * +from folks +where name = 'Grandma Sally' + union +select folks.* +from folks, descendants as d +where d.id=folks.father or d.id=folks.mother +) +select * from descendants; +id name dob father mother +8 Grandma Sally 1943-08-23 5 6 +30 Mom 1975-03-03 8 7 +25 Uncle Jim 1968-11-18 8 7 +100 Vasya 2000-01-01 20 30 +98 Sister Amy 2001-06-20 20 30 +67 Cousin Eddie 1992-02-28 25 27 +with recursive +ancestors +as +( +select * +from folks +where name = 'Vasya' and dob = '2000-01-01' + union +select p.* +from folks as p, ancestors AS a +where p.id = a.father OR p.id = a.mother +) +select * +from ancestors t1, ancestors t2 +where exists (select * from ancestors a +where a.father=t1.id AND a.mother=t2.id); +id name dob father mother id name dob father mother +20 Dad 1970-02-02 10 9 30 Mom 1975-03-03 8 7 +10 Grandpa Bill 1940-04-05 NULL NULL 9 Grandma Ann 1941-10-15 NULL NULL +with +ancestor_couples(husband, h_dob, wife, w_dob) +as +( +with recursive +ancestors +as +( +select * +from folks +where name = 'Vasya' + union +select p.* +from folks as p, ancestors AS a +where p.id = a.father OR p.id = a.mother +) +select t1.name, t1.dob, t2.name, t2.dob +from ancestors t1, ancestors t2 +where exists (select * from ancestors a +where a.father=t1.id AND a.mother=t2.id) +) +select * from ancestor_couples; +husband h_dob wife w_dob +Dad 1970-02-02 Mom 1975-03-03 +Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15 +with recursive +ancestors +as +( +select * +from folks +where name = 'Vasya' and dob = '2000-01-01' + union +select p.* +from folks as p, ancestors AS a +where p.id = a.father +union +select p.* +from folks as p, ancestors AS a +where p.id = a.mother +) +select * from ancestors; +id name dob father mother +100 Vasya 2000-01-01 20 30 +20 Dad 1970-02-02 10 9 +30 Mom 1975-03-03 8 7 +9 Grandma Ann 1941-10-15 NULL NULL +10 Grandpa Bill 1940-04-05 NULL NULL +8 Grandma Sally 1943-08-23 5 6 +6 Grandgrandma Martha 1923-05-17 NULL NULL +with recursive +ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, +w_id, w_name, w_dob, w_father, w_mother) +as +( +select h.*, w.* +from folks h, folks w, coupled_ancestors a +where a.father = h.id AND a.mother = w.id +union +select h.*, w.* +from folks v, folks h, folks w +where v.name = 'Vasya' and +(v.father = h.id AND v.mother= w.id) +), +coupled_ancestors (id, name, dob, father, mother) +as +( +select h_id, h_name, h_dob, h_father, h_mother +from ancestor_couples +union +select w_id, w_name, w_dob, w_father, w_mother +from ancestor_couples +) +select h_name, h_dob, w_name, w_dob +from ancestor_couples; +h_name h_dob w_name w_dob +Dad 1970-02-02 Mom 1975-03-03 +Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15 +drop table folks; diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result index f9cb4f1eecc..8d4d8f6d5f9 100644 --- a/mysql-test/r/ctype_eucjpms.result +++ b/mysql-test/r/ctype_eucjpms.result @@ -33913,3 +33913,24 @@ DROP TABLE t1; # # End of 10.1 tests # +# +# End of 10.2 tests +# +# +# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +# +CREATE TABLE t1 (a TEXT CHARACTER SET eucjpms); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.ujis.txt' INTO TABLE t1 CHARACTER SET eucjpms IGNORE 4 LINES; +SELECT HEX(a) FROM t1; +HEX(a) +3F +78787831 +3F3F +78787832 +8FA1A1 +78787833 +3F3F +DROP TABLE t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/r/ctype_gbk_export_import.result b/mysql-test/r/ctype_gbk_export_import.result new file mode 100644 index 00000000000..d7d5aa98f02 --- /dev/null +++ b/mysql-test/r/ctype_gbk_export_import.result @@ -0,0 +1,3903 @@ +DROP DATABASE IF EXISTS gbk; +CREATE DATABASE gbk DEFAULT CHARACTER SET gbk; +USE gbk; +CREATE TABLE t1 ( +id INT NOT NULL, +a1 TEXT NOT NULL, +a2 TEXT CHARACTER SET utf8 NOT NULL, +b1 BLOB NOT NULL, +eol TEXT NOT NULL); +CREATE PROCEDURE populate() +BEGIN +TRUNCATE TABLE t1; +INSERT INTO t1 SET id=1, a1=0xEE5C, a2=_gbk 0xEE5C, b1=0xEE5C, eol='$'; +INSERT INTO t1 SET id=2, a1=0xEE5C5C, a2=_gbk 0xEE5C5C, b1=0xEE5C5C, eol='$'; +END| +CREATE FUNCTION cmt(id INT, field_name TEXT, field_value BLOB) +RETURNS TEXT CHARACTER SET utf8 +BEGIN +DECLARE comment TEXT CHARACTER SET utf8; +DECLARE expected_value_01 BLOB; +DECLARE expected_value_02 BLOB; +SET comment= CASE field_name WHEN 'a1' THEN 'TEXT-GBK' WHEN 'a2' THEN 'TEXT-UTF8' WHEN 'b1' THEN 'BLOB' ELSE '' END; +SET expected_value_01= CASE field_name WHEN 'a1' THEN 0xEE5C WHEN 'a2' THEN 0xE9A0AB WHEN 'b1' THEN 0xEE5C ELSE '' END; +SET expected_value_02= CASE field_name WHEN 'a1' THEN 0xEE5C5C WHEN 'a2' THEN 0xE9A0AB5C WHEN 'b1' THEN 0xEE5C5C ELSE '' END; +RETURN IF(CASE id +WHEN 1 THEN expected_value_01 +WHEN 2 THEN expected_value_02 +ELSE '' + END <> field_value, +CONCAT('BAD-', comment), ''); +END| +CREATE FUNCTION display_file(file BLOB) RETURNS TEXT CHARACTER SET utf8 +BEGIN +SET file=REPLACE(file, 0x09, '----'); +SET file=REPLACE(file, 0x0A, '++++'); +RETURN REPLACE(REPLACE(HEX(file), '2D2D2D2D','-'), '2B2B2B2B','|'); +END| +CREATE VIEW v1 AS +SELECT +id, +CONCAT(RPAD(HEX(a1),50,' '), cmt(id, 'a1', a1)) AS a1, +CONCAT(RPAD(HEX(a2),50,' '), cmt(id, 'a2', a2)) AS a2, +CONCAT(RPAD(HEX(b1),50,' '), cmt(id, 'b1', b1)) AS b1, +CONCAT(RPAD(HEX(eol),50,' '), IF(eol<>'$','BAD-EOL','')) AS eol, +'---' AS `---` +FROM t1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `a1` text NOT NULL, + `a2` text CHARACTER SET utf8 NOT NULL, + `b1` blob NOT NULL, + `eol` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=gbk +# +# Dump using SELECT INTO OUTFILE +# +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto }{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=auto +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=auto +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=auto CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=auto CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk }{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=auto +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=auto +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=gbk CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-5CEE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-5CEE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 }{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=auto +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET gbk +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET gbk}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=auto +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET utf8 +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET utf8}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 } +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +OUTFILE: --default-character-set=utf8 CHARACTER SET binary +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8 CHARACTER SET binary}{--default-character-set=utf8 CHARACTER SET binary} + + +# +# Dump using mysqldump -Tdir +# +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto } +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=auto +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary } +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary } + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=binary CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=binary CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=binary CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=binary CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk } +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 } +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9978B3F BAD-TEXT-UTF8 +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C5C +a2 E9978BE78E9509E9A0AB5C0924 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 E9A0AB +b1 EE5C0924 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 EE5C5C0924 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=binary +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-E9A0AB-EE5C5C-24|32-EE5C5C5C-E9A0AB5C5C-EE5C5C5C5C-24| +id 1 +a1 3F09E9A03F BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09E9A0AB5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 24 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=binary}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto } +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=auto +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary } +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary } + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=binary CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=binary CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=binary CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=binary CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk } +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 } +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 EE5C +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F5C BAD-TEXT-GBK +a2 3F5C BAD-TEXT-UTF8 +b1 EE5C +eol 24 +--- --- +id 2 +a1 3F5C5C BAD-TEXT-GBK +a2 3F5C5C BAD-TEXT-UTF8 +b1 EE5C5C +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=gbk +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-EE5C-EE5C-EE5C-24|32-EE5C5C5C-EE5C5C5C-EE5C5C5C-24| +id 1 +a1 3F093F093F0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +id 2 +a1 EE5C09EE5C09EE5C0924 BAD-TEXT-GBK +a2 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=gbk}{--default-character-set=utf8 CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto } +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=auto +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto } + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=auto CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=auto CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=auto CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=auto CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary } +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary } + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=binary CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=binary CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=binary CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=binary CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk } +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk } + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=gbk CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=gbk CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=gbk CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=gbk CHARACTER SET binary} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 } +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 } + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 CHARACTER SET gbk} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=utf8 CHARACTER SET gbk +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9978B3F BAD-TEXT-UTF8 +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C09E9A0AB5C093F5C5C BAD-TEXT-GBK +a2 24 BAD-TEXT-UTF8 +b1 BAD-BLOB +eol BAD-EOL +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 CHARACTER SET gbk} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 CHARACTER SET utf8} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=utf8 CHARACTER SET utf8 +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 EE5C +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 EE5C5C +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 CHARACTER SET utf8} + + +Start of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 CHARACTER SET binary} +Locale: zh_CN.gbk +mysqldump: --default-character-set=utf8 +INFILE: --default-character-set=utf8 CHARACTER SET binary +file 31-E9A0AB-E9A0AB-3F5C5C-24|32-E9A0AB5C5C-E9A0AB5C5C-3F5C5C5C5C-24| +id 1 +a1 E9A03F BAD-TEXT-GBK +a2 E9A0AB +b1 3F5C BAD-BLOB +eol 24 +--- --- +id 2 +a1 E9A0AB5C BAD-TEXT-GBK +a2 E9A0AB5C +b1 3F5C5C BAD-BLOB +eol 24 +--- --- +End of {zh_CN.gbk}{--default-character-set=utf8}{--default-character-set=utf8 CHARACTER SET binary} + + +DROP DATABASE gbk; +USE test; diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index 61541ec7678..5eb9a3e1db5 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -26218,3 +26218,24 @@ DROP TABLE t1; # # End of 10.1 tests # +# +# End of 10.2 tests +# +# +# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +# +CREATE TABLE t1 (a TEXT CHARACTER SET ujis); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.ujis.txt' INTO TABLE t1 CHARACTER SET ujis IGNORE 4 LINES; +SELECT HEX(a) FROM t1; +HEX(a) +3F +78787831 +3F3F +78787832 +8FA1A1 +78787833 +3F3F +DROP TABLE t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index f52e08a676f..48a6eb02526 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -10426,5 +10426,38 @@ b c DROP TABLE t1; # +# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +# +CREATE TABLE t1 (a TEXT CHARACTER SET utf8); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.utf8mb4.txt' INTO TABLE t1 CHARACTER SET utf8 IGNORE 4 LINES; +Warnings: +Warning 1366 Incorrect string value: '\xD0' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xE1\x80' for column 'a' at row 3 +Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 5 +Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 7 +Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 8 +SELECT HEX(a) FROM t1; +HEX(a) +3F +78787831 +3F3F +78787832 +3F3F3F +78787833 +3F3F3F3F +3F3F3F +DROP TABLE t1; +# +# MDEV-9874 LOAD XML INFILE does not handle well broken multi-byte characters +# +CREATE TABLE t1 (a TEXT CHARACTER SET utf8); +LOAD XML INFILE '../../std_data/loaddata/mdev9874.xml' INTO TABLE t1 CHARACTER SET utf8 ROWS IDENTIFIED BY '<row>'; +Warnings: +Warning 1366 Incorrect string value: '\xD0' for column 'a' at row 1 +SELECT HEX(a) FROM t1; +HEX(a) +613F +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index 10d77ae1502..558aba9c466 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -3398,3 +3398,30 @@ DROP FUNCTION f1; # # End of 10.1 tests # +# +# End of 10.2 tests +# +# +# MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +# +CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.utf8mb4.txt' INTO TABLE t1 CHARACTER SET utf8mb4 IGNORE 4 LINES; +Warnings: +Warning 1366 Incorrect string value: '\xD0' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xE1\x80' for column 'a' at row 3 +Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 5 +Warning 1366 Incorrect string value: '\xF0\x9F\x98' for column 'a' at row 8 +SELECT HEX(a) FROM t1; +HEX(a) +3F +78787831 +3F3F +78787832 +3F3F3F +78787833 +F09F988E +3F3F3F +DROP TABLE t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index 80b99115055..d54fa40f2da 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -476,3 +476,37 @@ connection con1; disconnect con1; connection default; drop tables tm, t1, t2; +# +# MDEV-9621 INSERT DELAYED fails on insert for tables with many columns +# +CREATE TABLE t1 ( +a int,b int,c int,d int,e int,f int,g int,h int,i int,j int,k int,l int,m int,n int,o int,p int,q int,r int,s int,t int,u int,v int,x int,y int,z int +) ENGINE=MyISAM; +INSERT DELAYED INTO t1 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z) +values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +INSERT DELAYED INTO t1 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z) +values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +drop table t1; +# +# INSERT DELAYED hangs if table was crashed +# +create table t1 (a int, b int) engine=myisam; +insert into t1 values (1,1); +SET debug_dbug="d,crash_shutdown"; +shutdown; +ERROR HY000: Lost connection to MySQL server during query +call mtr.add_suppression(" marked as crashed and should be repaired"); +call mtr.add_suppression("Checking table"); +insert delayed into t1 values (2,2); +Warnings: +Error 145 Table './test/t1' is marked as crashed and should be repaired +Error 1194 Table 't1' is marked as crashed and should be repaired +Error 1034 1 client is using or hasn't closed the table properly +insert delayed into t1 values (3,3); +flush tables t1; +select * from t1; +a b +1 1 +2 2 +3 3 +drop table t1; diff --git a/mysql-test/r/derived_opt.result b/mysql-test/r/derived_opt.result index 04a76c2cbc8..6e4ea1b5d36 100644 --- a/mysql-test/r/derived_opt.result +++ b/mysql-test/r/derived_opt.result @@ -231,8 +231,8 @@ CREATE VIEW v1 AS SELECT a, MIN(b) AS b FROM t2 GROUP BY a; EXPLAIN SELECT * FROM v1, t1 WHERE v1.b=t1.a ORDER BY v1.a; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system NULL NULL NULL NULL 1 Using filesort -1 PRIMARY <derived2> ref key0 key0 5 const 1 Using where +1 PRIMARY t1 system NULL NULL NULL NULL 1 +1 PRIMARY <derived2> ref key0 key0 5 const 1 Using where; Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort SELECT * FROM v1, t1 WHERE v1.b=t1.a ORDER BY v1.a; a b a diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index d6e5a69e217..e2a7c462efd 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using temporary 1 SIMPLE t3 ref a a 5 test.t1.b 2 Using index -1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Distinct; Using join buffer (flat, BNL join) +1 SIMPLE t2 index a a 4 NULL 5 Using where; Using index; Using join buffer (flat, BNL join) SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; a 1 @@ -302,11 +302,11 @@ WHERE AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2)); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index id id 4 NULL 2 Using index; Using temporary -1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct; Using join buffer (flat, BNL join) -1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct; Using join buffer (flat, BNL join) -1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer (flat, BNL join) -1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index; Distinct -1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer (flat, BNL join) +1 SIMPLE t2 index id id 8 NULL 1 Using index; Using join buffer (flat, BNL join) +1 SIMPLE t3 index id id 8 NULL 1 Using index; Using join buffer (flat, BNL join) +1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index +1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) 1 SIMPLE t3_lj ref id id 4 test.j_lj_t3.id 1 Using where; Using index; Distinct SELECT DISTINCT t1.id @@ -518,7 +518,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1_1 ALL NULL NULL NULL NULL 3 Using temporary -1 SIMPLE t1_2 index NULL PRIMARY 4 NULL 3 Using index; Distinct; Using join buffer (flat, BNL join) +1 SIMPLE t1_2 index NULL PRIMARY 4 NULL 3 Using index; Using join buffer (flat, BNL join) EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2 WHERE t1_1.a = t1_2.a; id select_type table type possible_keys key key_len ref rows Extra @@ -916,8 +916,8 @@ SELECT STRAIGHT_JOIN DISTINCT t1.id FROM t1, v1, t2 WHERE v1.id = t2.i AND t1.i1 = v1.i1 AND t2.i != 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 96 100.00 Using where; Using temporary -1 PRIMARY <derived2> ref key0 key0 5 test.t1.i1 9 100.00 Using where; Distinct -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Distinct; Using join buffer (flat, BNL join) +1 PRIMARY <derived2> ref key0 key0 5 test.t1.i1 9 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) 2 DERIVED t1 ALL NULL NULL NULL NULL 96 100.00 Warnings: Note 1003 select straight_join distinct `test`.`t1`.`id` AS `id` from `test`.`t1` join `test`.`v1` join `test`.`t2` where ((`test`.`t2`.`i` = `v1`.`id`) and (`v1`.`i1` = `test`.`t1`.`i1`) and (`v1`.`id` <> 3)) diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result index 46d586ac29d..af5d1b800aa 100644 --- a/mysql-test/r/explain_json.result +++ b/mysql-test/r/explain_json.result @@ -486,8 +486,8 @@ EXPLAIN "query_block": { "select_id": 2, "filesort": { + "sort_key": "t1.a", "temporary_table": { - "function": "buffer", "table": { "table_name": "t1", "access_type": "ALL", @@ -530,8 +530,8 @@ EXPLAIN "query_block": { "select_id": 2, "filesort": { + "sort_key": "t1.a", "temporary_table": { - "function": "buffer", "table": { "table_name": "t1", "access_type": "ALL", @@ -576,7 +576,6 @@ EXPLAIN "query_block": { "select_id": 2, "temporary_table": { - "function": "buffer", "table": { "table_name": "t1", "access_type": "ALL", @@ -1132,8 +1131,8 @@ EXPLAIN "select_id": 1, "having_condition": "(TOP > t2.a)", "filesort": { + "sort_key": "t2.a", "temporary_table": { - "function": "buffer", "table": { "table_name": "t2", "access_type": "ALL", @@ -1151,8 +1150,8 @@ EXPLAIN "query_block": { "select_id": 1, "filesort": { + "sort_key": "t2.a", "temporary_table": { - "function": "buffer", "table": { "table_name": "t2", "access_type": "ALL", @@ -1181,8 +1180,8 @@ EXPLAIN "query_block": { "select_id": 1, "filesort": { + "sort_key": "t2.a", "temporary_table": { - "function": "buffer", "table": { "table_name": "t2", "access_type": "ALL", @@ -1380,7 +1379,6 @@ EXPLAIN "query_block": { "select_id": 1, "temporary_table": { - "function": "buffer", "table": { "table_name": "t1", "access_type": "ALL", diff --git a/mysql-test/r/func_analyse.result b/mysql-test/r/func_analyse.result index 2c300559a32..bc8ec445e73 100644 --- a/mysql-test/r/func_analyse.result +++ b/mysql-test/r/func_analyse.result @@ -19,7 +19,7 @@ test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL create table t2 select * from t1 procedure analyse(); -ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'procedure analyse()' at line 1 drop table t1; EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); ERROR HY000: Incorrect usage of PROCEDURE and subquery @@ -120,7 +120,7 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1),(2); # should not crash CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE(); -ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE()' at line 1 DROP TABLE t1; End of 5.0 tests # @@ -149,3 +149,25 @@ Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_ test.t2.f2 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL DROP TABLE t1, t2; End of 5.1 tests +# +# Start of 10.2 tests +# +(SELECT 1 FROM DUAL PROCEDURE ANALYSE()); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +1 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL +((SELECT 1 FROM DUAL PROCEDURE ANALYSE())); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +1 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL +SELECT * FROM t1 UNION SELECT * FROM t1 PROCEDURE analyse(); +ERROR HY000: Incorrect usage of PROCEDURE and subquery +# +# MDEV-10030 sql_yacc.yy: Split table_expression and remove PROCEDURE from create_select, select_paren_derived, select_derived2, query_specification +# +SELECT * FROM (SELECT * FROM t1 PROCEDURE ANALYSE()); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE())' at line 1 +SELECT * FROM t1 NATURAL JOIN (SELECT * FROM t2 PROCEDURE ANALYSE()); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE())' at line 1 +SELECT (SELECT 1 FROM t1 PROCEDURE ANALYSE()) FROM t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE()) FROM t2' at line 1 +SELECT ((SELECT 1 FROM t1 PROCEDURE ANALYSE())) FROM t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE())) FROM t2' at line 1 diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 422e7bd25c8..74247ae1b8e 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1519,7 +1519,7 @@ SELECT MAX(pk) as max, i FROM t1 ORDER BY max; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 # Only 11 is correct for collumn i in this result SELECT MAX(pk) as max, i diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 07773960e5a..f27ae67adff 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1346,12 +1346,43 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 144 +# +# For this explain, the query plan is weird: if we are using +# the primary key for reasons other than doing grouping, can't +# GROUP BY code take advantage of this? Well, currently it doesnt: EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort +# Here's a proof it is really doing sorting: +flush status; +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +show status like 'Sort_%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 144 +Sort_scan 1 +# Proof ends. +# +# For this explain, the query plan is weird: if we are using +# the primary key for reasons other than doing sorting, can't +# ORDER BY code take advantage of this? Well, currently it doesnt: EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort +# Here's a proof it is really doing sorting: +flush status; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +show status like 'Sort_%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 144 +Sort_scan 1 +# Proof ends. +# SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; a 1 @@ -2678,3 +2709,17 @@ NULL 100098 100099 drop table t0,t1,t2; +# +# MDEV-9602 crash in st_key::actual_rec_per_key when group by constant +# +create table t1 (a date not null,unique (a)) engine=innodb; +Warnings: +Warning 1286 Unknown storage engine 'innodb' +Warning 1266 Using storage engine MyISAM for table 't1' +select distinct a from t1 group by 'a'; +a +insert into t1 values("2001-02-02"),("2001-02-03"); +select distinct a from t1 group by 'a'; +a +2001-02-02 +drop table t1; diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index eda67460205..627edd60141 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -470,10 +470,9 @@ WHERE table2.f1 = 2 GROUP BY table1.f1, table2.f2 HAVING (table2.f2 = 8 AND table1.f1 >= 6); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE table2 const PRIMARY PRIMARY 4 const 1 100.00 Using filesort -1 SIMPLE table1 ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables Warnings: -Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having ((7 = 8) and (`test`.`table1`.`f1` >= 6)) +Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having 0 EXPLAIN EXTENDED SELECT table1.f1, table2.f2 FROM t1 AS table1 @@ -482,10 +481,9 @@ WHERE table2.f1 = 2 GROUP BY table1.f1, table2.f2 HAVING (table2.f2 = 8); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE table2 const PRIMARY PRIMARY 4 const 1 100.00 Using filesort -1 SIMPLE table1 ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables Warnings: -Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having (7 = 8) +Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table1`.`f3` = 9) group by `test`.`table1`.`f1`,7 having 0 DROP TABLE t1; # # Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355 diff --git a/mysql-test/r/join_cache.result b/mysql-test/r/join_cache.result index d816b1acf92..c15f96fc2e5 100644 --- a/mysql-test/r/join_cache.result +++ b/mysql-test/r/join_cache.result @@ -5412,9 +5412,9 @@ WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND t2.a BETWEEN 4 and 5 ORDER BY t2.b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system NULL NULL NULL NULL 1 Using filesort +1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t3 system NULL NULL NULL NULL 1 -1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where +1 PRIMARY t2 range a,c a 5 NULL 1 Using index condition; Using where; Using filesort 1 PRIMARY t4 ref c c 5 test.t2.c 2 Using where; Start temporary; End temporary SELECT * FROM t1,t2 WHERE t2.c IN (SELECT c FROM t3,t4 WHERE t4.a < 10) AND diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 820d66b9264..ca544f40aa8 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1289,8 +1289,8 @@ SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) FROM t1 JOIN t2 USING( a ) GROUP BY t1.a WITH ROLLUP; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system NULL NULL NULL NULL 1 Using filesort -1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where +1 SIMPLE t1 system NULL NULL NULL NULL 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where; Using filesort SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) FROM t1 JOIN t2 USING( a ) GROUP BY t1.a WITH ROLLUP; @@ -1429,8 +1429,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort -1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; @@ -1846,8 +1846,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort -1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 4412f8059dd..3616deaee9c 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1300,8 +1300,8 @@ SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) FROM t1 JOIN t2 USING( a ) GROUP BY t1.a WITH ROLLUP; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system NULL NULL NULL NULL 1 Using filesort -1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where +1 SIMPLE t1 system NULL NULL NULL NULL 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where; Using filesort SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) FROM t1 JOIN t2 USING( a ) GROUP BY t1.a WITH ROLLUP; @@ -1440,8 +1440,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort -1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; @@ -1857,8 +1857,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 Using filesort -1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref PRIMARY PRIMARY 4 const 1 Using where; Using index; Using filesort SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL GROUP BY t2.f1, t2.f2; diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result index 176a93c7a46..064fa5a18a7 100644 --- a/mysql-test/r/limit.result +++ b/mysql-test/r/limit.result @@ -80,13 +80,13 @@ create table t1 (a int); insert into t1 values (1),(2),(3),(4),(5),(6),(7); explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary +1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; c 7 explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary +1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; c 28 diff --git a/mysql-test/r/limit_rows_examined.result b/mysql-test/r/limit_rows_examined.result index 130d17ae270..318039db068 100644 --- a/mysql-test/r/limit_rows_examined.result +++ b/mysql-test/r/limit_rows_examined.result @@ -471,9 +471,11 @@ id select_type table type possible_keys key key_len ref rows Extra select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 0; c1 sum(c2) Warnings: -Warning 1931 Query execution was interrupted. The query examined at least 2 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete. +Warning 1931 Query execution was interrupted. The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete. select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 1; -ERROR HY000: Sort aborted: +c1 sum(c2) +Warnings: +Warning 1931 Query execution was interrupted. The query examined at least 3 rows, which exceeds LIMIT ROWS EXAMINED (1). The query result may be incomplete. select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 20; c1 sum(c2) aa 3 @@ -496,9 +498,11 @@ id select_type table type possible_keys key key_len ref rows Extra select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 0; c1 sum(c2) Warnings: -Warning 1931 Query execution was interrupted. The query examined at least 2 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete. +Warning 1931 Query execution was interrupted. The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete. select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 1; -ERROR HY000: Sort aborted: +c1 sum(c2) +Warnings: +Warning 1931 Query execution was interrupted. The query examined at least 3 rows, which exceeds LIMIT ROWS EXAMINED (1). The query result may be incomplete. select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 20; c1 sum(c2) aa 3 @@ -627,7 +631,7 @@ CREATE TABLE t4 (a int); INSERT INTO t4 values (1), (2); INSERT INTO t4 SELECT a + 2 FROM t4 LIMIT ROWS EXAMINED 0; Warnings: -Warning 1931 Query execution was interrupted. The query examined at least 2 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete. +Warning 1931 Query execution was interrupted. The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0). The query result may be incomplete. select * from t4; a 1 @@ -666,7 +670,7 @@ MDEV-115 SET @@optimizer_switch='in_to_exists=on,outer_join_with_cache=on'; CREATE TABLE t1 ( a VARCHAR(3) ) ENGINE=MyISAM; -INSERT INTO t1 VALUES ('USA'); +INSERT INTO t1 VALUES ('USA'),('CAN'); CREATE TABLE t2 ( b INT ); INSERT INTO t2 VALUES (3899),(3914),(3888); CREATE TABLE t3 ( c VARCHAR(33), d INT ); @@ -676,8 +680,8 @@ SELECT DISTINCT a AS field1 FROM t1, t2 WHERE EXISTS (SELECT c FROM t3 LEFT JOIN t2 ON b = d) HAVING field1 > 'aaa' LIMIT ROWS EXAMINED 20; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary -1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Distinct +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) 2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) SELECT DISTINCT a AS field1 FROM t1, t2 @@ -685,24 +689,27 @@ WHERE EXISTS (SELECT c FROM t3 LEFT JOIN t2 ON b = d) HAVING field1 > 'aaa' LIMIT ROWS EXAMINED 20; field1 Warnings: -Warning 1931 Query execution was interrupted. The query examined at least 23 rows, which exceeds LIMIT ROWS EXAMINED (20). The query result may be incomplete. +Warning 1931 Query execution was interrupted. The query examined at least 21 rows, which exceeds LIMIT ROWS EXAMINED (20). The query result may be incomplete. EXPLAIN SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 14; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Distinct +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 14; a +USA Warnings: Warning 1931 Query execution was interrupted. The query examined at least 15 rows, which exceeds LIMIT ROWS EXAMINED (14). The query result may be incomplete. SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 15; a USA +CAN Warnings: Warning 1931 Query execution was interrupted. The query examined at least 16 rows, which exceeds LIMIT ROWS EXAMINED (15). The query result may be incomplete. SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 16; a USA +CAN Warnings: Warning 1931 Query execution was interrupted. The query examined at least 17 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete. drop table t1,t2,t3; diff --git a/mysql-test/r/mrr_derived_crash_4610.result b/mysql-test/r/mrr_derived_crash_4610.result index 8dcdfda9276..3e38a0d4218 100644 --- a/mysql-test/r/mrr_derived_crash_4610.result +++ b/mysql-test/r/mrr_derived_crash_4610.result @@ -7,8 +7,8 @@ explain select 1 from (select f2, f3, val, count(id) from t4 join t2 left join t3 on 0) top join t1 on f1 = f3 where f3 = 'aaaa' order by val; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 const PRIMARY PRIMARY 12 const 1 Using index; Using filesort -1 PRIMARY <derived2> ref key0 key0 13 const 0 Using where +1 PRIMARY t1 const PRIMARY PRIMARY 12 const 1 Using index +1 PRIMARY <derived2> ref key0 key0 13 const 0 Using where; Using filesort 2 DERIVED t4 ALL NULL NULL NULL NULL 1 2 DERIVED t2 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) 2 DERIVED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 67a63d7a08a..1eef64be640 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -523,11 +523,11 @@ a explain select sql_big_result distinct t1.a from t1,t2 order by t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary -1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct +1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index explain select distinct t1.a from t1,t2 order by t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary -1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct +1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index drop table t1,t2; create table t1 ( c1 varchar(32), @@ -603,6 +603,10 @@ test.t2 3442722830 test.t3 NULL Warnings: Error 1146 Table 'test.t3' doesn't exist +alter table t1 add d int default 30, add e bigint default 300000, add f decimal(30) default 442; +checksum table t1; +Table Checksum +test.t1 2924214226 drop table t1,t2; create table t1 (a int, key (a)); show keys from t1; diff --git a/mysql-test/r/order_by_optimizer.result b/mysql-test/r/order_by_optimizer.result new file mode 100644 index 00000000000..8f128552a86 --- /dev/null +++ b/mysql-test/r/order_by_optimizer.result @@ -0,0 +1,30 @@ +drop table if exists t0,t1,t2,t3; +# +# MDEV-7885: EXPLAIN shows wrong info for ORDER BY query +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; +create table t2 (key1 int, col1 int, key(key1)); +insert into t2 select a,a from t0; +insert into t2 select 15,15 from t1; +alter table t2 add key2 int, add key(key2); +# This must show "Using filesort": +explain +select * from t2 ignore index for order by (key1) where col1<0 order by key1 limit 10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1010 Using where; Using filesort +drop table t0, t1, t2; +# +# MDEV-8857: [Upstream too] EXPLAIN incorrectly shows Distinct for tables using join buffer +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler char(200), key(a)); +insert into t1 select A.a + B.a* 10, 'AAAAAAAAAAAAAAAAAAAA' from t0 A, t0 B where B.a in (0,1); +explain select distinct A.a from t0 A, t1 B where A.a+B.a> 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE A ALL NULL NULL NULL NULL 10 Using temporary +1 SIMPLE B index NULL a 5 NULL 20 Using where; Using index; Using join buffer (flat, BNL join) +drop table t0, t1; diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 01cc9d79aaf..18a8e13815c 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -686,7 +686,7 @@ FOR UPDATE) a; SELECT 1 FROM (SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 PROCEDURE ANALYSE() FOR UPDATE) a; -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE() FOR UPDATE) a' at line 3 SELECT 1 FROM t1 WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 FOR UPDATE); @@ -694,7 +694,7 @@ FOR UPDATE); SELECT 1 FROM t1 WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 PROCEDURE ANALYSE() FOR UPDATE); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE() FOR UPDATE)' at line 3 SELECT 1 FROM t1 UNION SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 7b38515cf70..8462e19fda8 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -83,20 +83,20 @@ UNIQUE KEY e_n (email,name) ); EXPLAIN SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system PRIMARY,kid NULL NULL NULL 0 const row not found -1 SIMPLE t2 index NULL e_n 104 NULL 10 +1 SIMPLE t1 system PRIMARY,kid NULL NULL NULL 0 const row not found; Using temporary +1 SIMPLE t2 ALL NULL NULL NULL NULL 200 SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10; email email1 +email2 +email3 +email4 +email5 +email6 +email7 +email8 +email9 email10 -email100 -email101 -email102 -email103 -email104 -email105 -email106 -email107 SELECT FOUND_ROWS(); FOUND_ROWS() 200 diff --git a/mysql-test/r/show_explain.result b/mysql-test/r/show_explain.result index 5a885766f7b..0819ae5ba37 100644 --- a/mysql-test/r/show_explain.result +++ b/mysql-test/r/show_explain.result @@ -1162,7 +1162,7 @@ SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, fie connection default; show explain for $thr2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 system NULL NULL NULL NULL 1 Using filesort +1 SIMPLE t2 system NULL NULL NULL NULL 1 1 SIMPLE t1 range b b 6 NULL 107 Using where; Using index 1 SIMPLE t3 ref PRIMARY PRIMARY 5 test.t1.b 1 Using index Warnings: diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index b306965034b..1b1198958b8 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -79,7 +79,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); 1 1 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 87645d187f2..7202a6238b0 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -19,7 +19,7 @@ SELECT 1 FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3)) ORDER BY count(*); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index; Using temporary +1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found # should not crash the next statement @@ -2003,8 +2003,8 @@ FROM t2 JOIN t3 ON t3.f4 = t2.f4 WHERE t3.f1 = 8 GROUP BY 1, 2; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 system NULL NULL NULL NULL 1 Using filesort -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY t3 system NULL NULL NULL NULL 1 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using filesort 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 3 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table PREPARE st1 FROM " diff --git a/mysql-test/r/subselect_no_exists_to_in.result b/mysql-test/r/subselect_no_exists_to_in.result index 244f6057a2f..39d1f64410e 100644 --- a/mysql-test/r/subselect_no_exists_to_in.result +++ b/mysql-test/r/subselect_no_exists_to_in.result @@ -83,7 +83,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); 1 1 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index e095ed16ff9..211d3206a7f 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -86,7 +86,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); 1 1 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index f4714526613..6ae9f8aa066 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -82,7 +82,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); 1 1 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result index 5ead5de4cf9..9a3fcd1de3b 100644 --- a/mysql-test/r/subselect_no_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -85,7 +85,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); 1 1 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index c57c46b76ff..10cf05649e7 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -82,7 +82,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); 1 1 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result new file mode 100644 index 00000000000..a6b43788ffe --- /dev/null +++ b/mysql-test/r/win.result @@ -0,0 +1,1961 @@ +drop table if exists t1,t2; +drop view if exists v1; +# ######################################################################## +# # Parser tests +# ######################################################################## +# +# Check what happens when one attempts to use window function without OVER clause +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2); +select row_number() from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from t1' at line 1 +select rank() from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from t1' at line 1 +# Attempt to use window function in the WHERE clause +select * from t1 where 1=rank() over (order by a); +ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause +select * from t1 where 1>row_number() over (partition by b order by a); +ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause +drop table t1; +# ######################################################################## +# # Functionality tests +# ######################################################################## +# +# Check if ROW_NUMBER() works in basic cases +create table t1(a int, b int, x char(32)); +insert into t1 values (2, 10, 'xx'); +insert into t1 values (2, 10, 'zz'); +insert into t1 values (2, 20, 'yy'); +insert into t1 values (3, 10, 'xxx'); +insert into t1 values (3, 20, 'vvv'); +select a, row_number() over (partition by a order by b) from t1; +a row_number() over (partition by a order by b) +2 1 +2 2 +2 3 +3 1 +3 2 +select a, b, x, row_number() over (partition by a order by x) from t1; +a b x row_number() over (partition by a order by x) +2 10 xx 1 +2 10 zz 3 +2 20 yy 2 +3 10 xxx 2 +3 20 vvv 1 +drop table t1; +create table t1 (pk int primary key, a int, b int); +insert into t1 values +(1, 10, 22), +(2, 11, 21), +(3, 12, 20), +(4, 13, 19), +(5, 14, 18); +select +pk, a, b, +row_number() over (order by a), +row_number() over (order by b) +from t1; +pk a b row_number() over (order by a) row_number() over (order by b) +1 10 22 1 5 +2 11 21 2 4 +3 12 20 3 3 +4 13 19 4 2 +5 14 18 5 1 +drop table t1; +# +# Try RANK() function +# +create table t2 ( +pk int primary key, +a int +); +insert into t2 values +( 1 , 0), +( 2 , 0), +( 3 , 1), +( 4 , 1), +( 8 , 2), +( 5 , 2), +( 6 , 2), +( 7 , 2), +( 9 , 4), +(10 , 4); +select pk, a, rank() over (order by a) from t2; +pk a rank() over (order by a) +1 0 1 +2 0 1 +3 1 3 +4 1 3 +8 2 5 +5 2 5 +6 2 5 +7 2 5 +9 4 9 +10 4 9 +select pk, a, rank() over (order by a desc) from t2; +pk a rank() over (order by a desc) +1 0 9 +2 0 9 +3 1 7 +4 1 7 +8 2 3 +5 2 3 +6 2 3 +7 2 3 +9 4 1 +10 4 1 +drop table t2; +# +# Try Aggregates as window functions. With frames. +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; +pk c +1 1 +2 1 +3 1 +4 1 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +select +pk, c, +count(*) over (partition by c order by pk +rows between 2 preceding and 2 following) as CNT +from t1; +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +select +pk, c, +count(*) over (partition by c order by pk +rows between 1 preceding and 2 following) as CNT +from t1; +pk c CNT +1 1 3 +2 1 4 +3 1 3 +4 1 2 +5 2 3 +6 2 4 +7 2 4 +8 2 4 +9 2 3 +10 2 2 +select +pk, c, +count(*) over (partition by c order by pk +rows between 2 preceding and current row) as CNT +from t1; +pk c CNT +1 1 1 +2 1 2 +3 1 3 +4 1 3 +5 2 1 +6 2 2 +7 2 3 +8 2 3 +9 2 3 +10 2 3 +select +pk,c, +count(*) over (partition by c order by pk rows +between 1 following and 2 following) as CNT +from t1; +pk c CNT +1 1 2 +2 1 2 +3 1 1 +4 1 0 +5 2 2 +6 2 2 +7 2 2 +8 2 2 +9 2 1 +10 2 0 +select +pk,c, +count(*) over (partition by c order by pk rows +between 2 preceding and 1 preceding) as CNT +from t1; +pk c CNT +1 1 0 +2 1 1 +3 1 2 +4 1 2 +5 2 0 +6 2 1 +7 2 2 +8 2 2 +9 2 2 +10 2 2 +select +pk, c, +count(*) over (partition by c order by pk +rows between current row and 1 following) as CNT +from t1; +pk c CNT +1 1 2 +2 1 2 +3 1 2 +4 1 1 +5 2 2 +6 2 2 +7 2 2 +8 2 2 +9 2 2 +10 2 1 +# Check ORDER BY DESC +select +pk, c, +count(*) over (partition by c order by pk desc +rows between 2 preceding and 2 following) as CNT +from t1; +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +drop table t0,t1; +# +# Resolution of window names +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; +pk c +1 1 +2 1 +3 1 +4 1 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +select +pk, c, +count(*) over w1 as CNT +from t1 +window w1 as (partition by c order by pk +rows between 2 preceding and 2 following); +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +select +pk, c, +count(*) over (w1 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c order by pk); +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +select +pk, c, +count(*) over (w1 order by pk rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c); +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +select +pk, c, +count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w2 as (w1 order by pk); +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +select +pk, c, +count(*) over w3 as CNT +from t1 +window +w1 as (partition by c), +w2 as (w1 order by pk), +w3 as (w2 rows between 2 preceding and 2 following); +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +select +pk, c, +count(*) over w as CNT +from t1 +window w1 as (partition by c order by pk +rows between 2 preceding and 2 following); +ERROR HY000: Window specification with name 'w' is not defined +select +pk, c, +count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w1 as (order by pk); +ERROR HY000: Multiple window specifications with the same name 'w1' +select +pk, c, +count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w2 as (w partition by c order by pk); +ERROR HY000: Window specification with name 'w' is not defined +select +pk, c, +count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w2 as (w1 partition by c order by pk); +ERROR HY000: Window specification referencing another one 'w1' cannot contain partition list +select +pk, c, +count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c order by pk), w2 as (w1 order by pk); +ERROR HY000: Referenced window specification 'w1' already contains order list +select +pk, c, +count(*) over w3 as CNT +from t1 +window +w1 as (partition by c), +w2 as (w1 order by pk rows between 3 preceding and 2 following), +w3 as (w2 rows between 2 preceding and 2 following); +ERROR HY000: Referenced window specification 'w2' cannot contain window frame +select +pk, c, +count(*) over w1 as CNT +from t1 +window w1 as (partition by c order by pk +rows between unbounded following and 2 following); +ERROR HY000: Unacceptable combination of window frame bound specifications +select +pk, c, +count(*) over (w1 rows between 2 preceding and unbounded preceding) as CNT +from t1 +window w1 as (partition by c order by pk); +ERROR HY000: Unacceptable combination of window frame bound specifications +select +pk, c, +count(*) over (w1 order by pk rows between current row and 2 preceding) as CNT +from t1 +window w1 as (partition by c); +ERROR HY000: Unacceptable combination of window frame bound specifications +select +pk, c, +count(*) over (w2 rows between 2 following and current row) as CNT +from t1 +window w1 as (partition by c), w2 as (w1 order by pk); +ERROR HY000: Unacceptable combination of window frame bound specifications +select +pk, c +from t1 where rank() over w1 > 2 +window w1 as (partition by c order by pk); +ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause +select +c, max(pk) as m +from t1 +group by c + rank() over w1 +window w1 as (order by m); +ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause +select +c, max(pk) as m, rank() over w1 as r +from t1 +group by c+r +window w1 as (order by m); +ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause +select +c, max(pk) as m, rank() over w1 as r +from t1 +group by c having c+r > 3 +window w1 as (order by m); +ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause +select +c, max(pk) as m, rank() over w1 as r, +rank() over (partition by r+1 order by m) +from t1 +group by c +window w1 as (order by m); +ERROR HY000: Window function is not allowed in window specification +select +c, max(pk) as m, rank() over w1 as r, +rank() over (partition by m order by r) +from t1 +group by c +window w1 as (order by m); +ERROR HY000: Window function is not allowed in window specification +select +c, max(pk) as m, rank() over w1 as r, dense_rank() over w2 as dr +from t1 +group by c +window w1 as (order by m), w2 as (partition by r order by m); +ERROR HY000: Window function is not allowed in window specification +select +pk, c, +row_number() over (partition by c order by pk +range between unbounded preceding and current row) as r +from t1; +ERROR HY000: Window frame is not allowed with 'row_number' +select +pk, c, +rank() over w1 as r +from t1 +window w1 as (partition by c order by pk +rows between 2 preceding and 2 following); +ERROR HY000: Window frame is not allowed with 'rank' +select +pk, c, +dense_rank() over (partition by c order by pk +rows between 1 preceding and 1 following) as r +from t1; +ERROR HY000: Window frame is not allowed with 'dense_rank' +select +pk, c, +rank() over w1 as r +from t1 +window w1 as (partition by c); +ERROR HY000: No order list in window specification for 'rank' +select +pk, c, +dense_rank() over (partition by c) as r +from t1; +ERROR HY000: No order list in window specification for 'dense_rank' +drop table t0,t1; +# +# MDEV-9634: Window function produces incorrect value +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (part_id int, pk int, a int); +insert into t2 select +if(a<5, 0, 1), a, if(a<5, NULL, 1) from t0; +select * from t2; +part_id pk a +0 0 NULL +0 1 NULL +0 2 NULL +0 3 NULL +0 4 NULL +1 5 1 +1 6 1 +1 7 1 +1 8 1 +1 9 1 +select +part_id, pk, a, +count(a) over (partition by part_id order by pk +rows between 1 preceding and 1 following) as CNT +from t2; +part_id pk a CNT +0 0 NULL 0 +0 1 NULL 0 +0 2 NULL 0 +0 3 NULL 0 +0 4 NULL 0 +1 5 1 2 +1 6 1 3 +1 7 1 3 +1 8 1 3 +1 9 1 2 +drop table t0, t2; +# +# RANGE-type bounds +# +create table t3 ( +pk int, +val int +); +insert into t3 values +(0, 1), +(1, 1), +(2, 1), +(3, 2), +(4, 2), +(5, 2), +(6, 2); +select +pk, +val, +count(val) over (order by val +range between current row and +current row) +as CNT +from t3; +pk val CNT +0 1 3 +1 1 3 +2 1 3 +3 2 4 +4 2 4 +5 2 4 +6 2 4 +insert into t3 values +(7, 3), +(8, 3); +select +pk, +val, +count(val) over (order by val +range between current row and +current row) +as CNT +from t3; +pk val CNT +0 1 3 +1 1 3 +2 1 3 +3 2 4 +4 2 4 +5 2 4 +6 2 4 +7 3 2 +8 3 2 +drop table t3; +# Now, check with PARTITION BY +create table t4 ( +part_id int, +pk int, +val int +); +insert into t4 values +(1234, 100, 1), +(1234, 101, 1), +(1234, 102, 1), +(1234, 103, 2), +(1234, 104, 2), +(1234, 105, 2), +(1234, 106, 2), +(1234, 107, 3), +(1234, 108, 3), +(5678, 200, 1), +(5678, 201, 1), +(5678, 202, 1), +(5678, 203, 2), +(5678, 204, 2), +(5678, 205, 2), +(5678, 206, 2), +(5678, 207, 3), +(5678, 208, 3); +select +part_id, +pk, +val, +count(val) over (partition by part_id +order by val +range between current row and +current row) +as CNT +from t4; +part_id pk val CNT +1234 100 1 3 +1234 101 1 3 +1234 102 1 3 +1234 103 2 4 +1234 104 2 4 +1234 105 2 4 +1234 106 2 4 +1234 107 3 2 +1234 108 3 2 +5678 200 1 3 +5678 201 1 3 +5678 202 1 3 +5678 203 2 4 +5678 204 2 4 +5678 205 2 4 +5678 206 2 4 +5678 207 3 2 +5678 208 3 2 +# +# Try RANGE UNBOUNDED PRECEDING | FOLLOWING +# +select +part_id, +pk, +val, +count(val) over (partition by part_id +order by val +range between unbounded preceding and +current row) +as CNT +from t4; +part_id pk val CNT +1234 100 1 3 +1234 101 1 3 +1234 102 1 3 +1234 103 2 7 +1234 104 2 7 +1234 105 2 7 +1234 106 2 7 +1234 107 3 9 +1234 108 3 9 +5678 200 1 3 +5678 201 1 3 +5678 202 1 3 +5678 203 2 7 +5678 204 2 7 +5678 205 2 7 +5678 206 2 7 +5678 207 3 9 +5678 208 3 9 +select +part_id, +pk, +val, +count(val) over (partition by part_id +order by val +range between current row and +unbounded following) +as CNT +from t4; +part_id pk val CNT +1234 100 1 9 +1234 101 1 9 +1234 102 1 9 +1234 103 2 6 +1234 104 2 6 +1234 105 2 6 +1234 106 2 6 +1234 107 3 2 +1234 108 3 2 +5678 200 1 9 +5678 201 1 9 +5678 202 1 9 +5678 203 2 6 +5678 204 2 6 +5678 205 2 6 +5678 206 2 6 +5678 207 3 2 +5678 208 3 2 +select +part_id, +pk, +val, +count(val) over (partition by part_id +order by val +range between unbounded preceding and +unbounded following) +as CNT +from t4; +part_id pk val CNT +1234 100 1 9 +1234 101 1 9 +1234 102 1 9 +1234 103 2 9 +1234 104 2 9 +1234 105 2 9 +1234 106 2 9 +1234 107 3 9 +1234 108 3 9 +5678 200 1 9 +5678 201 1 9 +5678 202 1 9 +5678 203 2 9 +5678 204 2 9 +5678 205 2 9 +5678 206 2 9 +5678 207 3 9 +5678 208 3 9 +drop table t4; +# +# MDEV-9695: Wrong window frame when using RANGE BETWEEN N FOLLOWING AND PRECEDING +# +create table t1 (pk int, a int, b int); +insert into t1 values +( 1 , 0, 1), +( 2 , 0, 2), +( 3 , 1, 4), +( 4 , 1, 8), +( 5 , 2, 32), +( 6 , 2, 64), +( 7 , 2, 128), +( 8 , 2, 16); +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as bit_or +from t1; +pk a b bit_or +1 0 1 3 +2 0 2 3 +3 1 4 12 +4 1 8 12 +5 2 32 96 +6 2 64 224 +7 2 128 208 +8 2 16 144 +# Extra ROWS n PRECEDING tests +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) as bit_or +from t1; +pk a b bit_or +1 0 1 0 +2 0 2 1 +3 1 4 0 +4 1 8 4 +5 2 32 0 +6 2 64 32 +7 2 128 64 +8 2 16 128 +drop table t1; +create table t2 ( +pk int, +a int, +b int +); +insert into t2 values +( 1, 0, 1), +( 2, 0, 2), +( 3, 0, 4), +( 4, 0, 8), +( 5, 1, 16), +( 6, 1, 32), +( 7, 1, 64), +( 8, 1, 128), +( 9, 2, 256), +(10, 2, 512), +(11, 2, 1024), +(12, 2, 2048); +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) as bit_or +from t2; +pk a b bit_or +1 0 1 0 +2 0 2 1 +3 0 4 2 +4 0 8 4 +5 1 16 0 +6 1 32 16 +7 1 64 32 +8 1 128 64 +9 2 256 0 +10 2 512 256 +11 2 1024 512 +12 2 2048 1024 +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) as bit_or +from t2; +pk a b bit_or +1 0 1 0 +2 0 2 0 +3 0 4 1 +4 0 8 2 +5 1 16 0 +6 1 32 0 +7 1 64 16 +8 1 128 32 +9 2 256 0 +10 2 512 0 +11 2 1024 256 +12 2 2048 512 +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) as bit_or +from t2; +pk a b bit_or +1 0 1 0 +2 0 2 1 +3 0 4 3 +4 0 8 6 +5 1 16 0 +6 1 32 16 +7 1 64 48 +8 1 128 96 +9 2 256 0 +10 2 512 256 +11 2 1024 768 +12 2 2048 1536 +# Check CURRENT ROW +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN CURRENT ROW AND CURRENT ROW) as bit_or +from t2; +pk a b bit_or +1 0 1 1 +2 0 2 2 +3 0 4 4 +4 0 8 8 +5 1 16 16 +6 1 32 32 +7 1 64 64 +8 1 128 128 +9 2 256 256 +10 2 512 512 +11 2 1024 1024 +12 2 2048 2048 +drop table t2; +# +# Try RANGE PRECEDING|FOLLWING n +# +create table t1 ( +part_id int, +pk int, +a int +); +insert into t1 values +(10, 1, 1), +(10, 2, 2), +(10, 3, 4), +(10, 4, 8), +(10, 5,26), +(10, 6,27), +(10, 7,40), +(10, 8,71), +(10, 9,72); +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN UNBOUNDED PRECEDING +AND 10 FOLLOWING) as cnt +from t1; +pk a cnt +1 1 4 +2 2 4 +3 4 4 +4 8 4 +5 26 6 +6 27 6 +7 40 7 +8 71 9 +9 72 9 +select +pk, a, +count(a) over (ORDER BY a DESC +RANGE BETWEEN UNBOUNDED PRECEDING +AND 10 FOLLOWING) as cnt +from t1; +pk a cnt +1 1 9 +2 2 9 +3 4 9 +4 8 9 +5 26 5 +6 27 5 +7 40 3 +8 71 2 +9 72 2 +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN UNBOUNDED PRECEDING +AND 1 FOLLOWING) as cnt +from t1; +pk a cnt +1 1 2 +2 2 2 +3 4 3 +4 8 4 +5 26 6 +6 27 6 +7 40 7 +8 71 9 +9 72 9 +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN UNBOUNDED PRECEDING +AND 10 PRECEDING) as cnt +from t1; +pk a cnt +1 1 0 +2 2 0 +3 4 0 +4 8 0 +5 26 4 +6 27 4 +7 40 6 +8 71 7 +9 72 7 +select +pk, a, +count(a) over (ORDER BY a DESC +RANGE BETWEEN UNBOUNDED PRECEDING +AND 10 PRECEDING) as cnt +from t1; +pk a cnt +1 1 5 +2 2 5 +3 4 5 +4 8 5 +5 26 3 +6 27 3 +7 40 2 +8 71 0 +9 72 0 +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN UNBOUNDED PRECEDING +AND 1 PRECEDING) as cnt +from t1; +pk a cnt +1 1 0 +2 2 1 +3 4 2 +4 8 3 +5 26 4 +6 27 5 +7 40 6 +8 71 7 +9 72 8 +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN 1 PRECEDING +AND CURRENT ROW) as cnt +from t1; +pk a cnt +1 1 1 +2 2 2 +3 4 1 +4 8 1 +5 26 1 +6 27 2 +7 40 1 +8 71 1 +9 72 2 +select +pk, a, +count(a) over (ORDER BY a DESC +RANGE BETWEEN 1 PRECEDING +AND CURRENT ROW) as cnt +from t1; +pk a cnt +1 1 2 +2 2 1 +3 4 1 +4 8 1 +5 26 2 +6 27 1 +7 40 1 +8 71 2 +9 72 1 +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN 1 FOLLOWING +AND 3 FOLLOWING) as cnt +from t1; +pk a cnt +1 1 2 +2 2 1 +3 4 0 +4 8 0 +5 26 1 +6 27 0 +7 40 0 +8 71 1 +9 72 0 +# Try CURRENT ROW with[out] DESC +select +pk, a, +count(a) over (ORDER BY a +RANGE BETWEEN CURRENT ROW +AND 1 FOLLOWING) as cnt +from t1; +pk a cnt +1 1 2 +2 2 1 +3 4 1 +4 8 1 +5 26 2 +6 27 1 +7 40 1 +8 71 2 +9 72 1 +select +pk, a, +count(a) over (order by a desc +range between current row +and 1 following) as cnt +from t1; +pk a cnt +1 1 1 +2 2 2 +3 4 1 +4 8 1 +5 26 1 +6 27 2 +7 40 1 +8 71 1 +9 72 2 +insert into t1 select 22, pk, a from t1; +select +part_id, pk, a, +count(a) over (PARTITION BY part_id +ORDER BY a +RANGE BETWEEN UNBOUNDED PRECEDING +AND 10 FOLLOWING) as cnt +from t1; +part_id pk a cnt +10 1 1 4 +10 2 2 4 +10 3 4 4 +10 4 8 4 +10 5 26 6 +10 6 27 6 +10 7 40 7 +10 8 71 9 +10 9 72 9 +22 1 1 4 +22 2 2 4 +22 3 4 4 +22 4 8 4 +22 5 26 6 +22 6 27 6 +22 7 40 7 +22 8 71 9 +22 9 72 9 +select +pk, a, +count(a) over (PARTITION BY part_id +ORDER BY a +RANGE BETWEEN UNBOUNDED PRECEDING +AND 1 PRECEDING) as cnt +from t1; +pk a cnt +1 1 0 +2 2 1 +3 4 2 +4 8 3 +5 26 4 +6 27 5 +7 40 6 +8 71 7 +9 72 8 +1 1 0 +2 2 1 +3 4 2 +4 8 3 +5 26 4 +6 27 5 +7 40 6 +8 71 7 +9 72 8 +drop table t1; +# Try a RANGE frame over non-integer datatype: +create table t1 ( +col1 int, +a decimal(5,3) +); +insert into t1 values (1, 0.45); +insert into t1 values (1, 0.5); +insert into t1 values (1, 0.55); +insert into t1 values (1, 1.21); +insert into t1 values (1, 1.22); +insert into t1 values (1, 3.33); +select +a, +count(col1) over (order by a +range between 0.1 preceding +and 0.1 following) +from t1; +a count(col1) over (order by a +range between 0.1 preceding +and 0.1 following) +0.450 3 +0.500 3 +0.550 3 +1.210 2 +1.220 2 +3.330 1 +drop table t1; +# +# RANGE-type frames and NULL values +# +create table t1 ( +pk int, +a int, +b int +); +insert into t1 values (1, NULL,1); +insert into t1 values (2, NULL,1); +insert into t1 values (3, NULL,1); +insert into t1 values (4, 10 ,1); +insert into t1 values (5, 11 ,1); +insert into t1 values (6, 12 ,1); +insert into t1 values (7, 13 ,1); +insert into t1 values (8, 14 ,1); +select +pk, a, +count(b) over (order by a +range between 2 preceding +and 2 following) as CNT +from t1; +pk a CNT +1 NULL 3 +2 NULL 3 +3 NULL 3 +4 10 3 +5 11 4 +6 12 5 +7 13 4 +8 14 3 +drop table t1; +# +# Try ranges that have bound1 > bound2. The standard actually allows them +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; +pk c +1 1 +2 1 +3 1 +4 1 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +select +pk, c, +count(*) over (partition by c +order by pk +rows between 1 preceding +and 2 preceding) +as cnt +from t1; +pk c cnt +1 1 0 +2 1 0 +3 1 0 +4 1 0 +5 2 0 +6 2 0 +7 2 0 +8 2 0 +9 2 0 +10 2 0 +select +pk, c, +count(*) over (partition by c +order by pk +range between 1 preceding +and 2 preceding) +as cnt +from t1; +pk c cnt +1 1 0 +2 1 0 +3 1 0 +4 1 0 +5 2 0 +6 2 0 +7 2 0 +8 2 0 +9 2 0 +10 2 0 +drop table t0, t1; +# +# Error checking for frame bounds +# +create table t1 (a int, b int, c varchar(32)); +insert into t1 values (1,1,'foo'); +insert into t1 values (2,2,'bar'); +select +count(*) over (order by a,b +range between unbounded preceding and current row) +from t1; +ERROR HY000: RANGE-type frame requires ORDER BY clause with single sort key +select +count(*) over (order by c +range between unbounded preceding and current row) +from t1; +ERROR HY000: Numeric datatype is required for RANGE-type frame +select +count(*) over (order by a +range between 'abcd' preceding and current row) +from t1; +ERROR HY000: Numeric datatype is required for RANGE-type frame +select +count(*) over (order by a +range between current row and 'foo' following) +from t1; +ERROR HY000: Numeric datatype is required for RANGE-type frame +# Try range frame with invalid bounds +select +count(*) over (order by a +rows between 0.5 preceding and current row) +from t1; +ERROR HY000: Integer is required for ROWS-type frame +select +count(*) over (order by a +rows between current row and 3.14 following) +from t1; +ERROR HY000: Integer is required for ROWS-type frame +# +# EXCLUDE clause is parsed but not supported +# +select +count(*) over (order by a +rows between 1 preceding and 1 following +exclude current row) +from t1; +ERROR HY000: Frame exclusion is not supported yet +select +count(*) over (order by a +range between 1 preceding and 1 following +exclude ties) +from t1; +ERROR HY000: Frame exclusion is not supported yet +select +count(*) over (order by a +range between 1 preceding and 1 following +exclude group) +from t1; +ERROR HY000: Frame exclusion is not supported yet +select +count(*) over (order by a +rows between 1 preceding and 1 following +exclude no others) +from t1; +count(*) over (order by a +rows between 1 preceding and 1 following +exclude no others) +2 +2 +drop table t1; +# +# Window function in grouping query +# +create table t1 ( +username varchar(32), +amount int +); +insert into t1 values +('user1',1), +('user1',5), +('user1',3), +('user2',10), +('user2',20), +('user2',30); +select +username, +sum(amount) as s, +rank() over (order by s desc) +from t1 +group by username; +username s rank() over (order by s desc) +user1 9 2 +user2 60 1 +drop table t1; +# +# mdev-9719: Window function in prepared statement +# +create table t1(a int, b int, x char(32)); +insert into t1 values (2, 10, 'xx'); +insert into t1 values (2, 10, 'zz'); +insert into t1 values (2, 20, 'yy'); +insert into t1 values (3, 10, 'xxx'); +insert into t1 values (3, 20, 'vvv'); +prepare stmt from 'select a, row_number() over (partition by a order by b) from t1'; +execute stmt; +a row_number() over (partition by a order by b) +2 1 +2 2 +2 3 +3 1 +3 2 +drop table t1; +# +# mdev-9754: Window name resolution in prepared statement +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; +pk c +1 1 +2 1 +3 1 +4 1 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +prepare stmt from +'select + pk, c, + count(*) over w1 as CNT +from t1 +window w1 as (partition by c order by pk + rows between 2 preceding and 2 following)'; +execute stmt; +pk c CNT +1 1 3 +2 1 4 +3 1 4 +4 1 3 +5 2 3 +6 2 4 +7 2 5 +8 2 5 +9 2 4 +10 2 3 +drop table t0,t1; +# +# EXPLAIN FORMAT=JSON support for window functions +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +explain format=json select rank() over (order by a) from t0; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t0.a" + } + }, + "temporary_table": { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + } + } +} +create table t1 (a int, b int, c int); +insert into t1 select a,a,a from t0; +explain format=json +select +a, +rank() over (order by sum(b)) +from t1 +group by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "filesort": { + "sort_key": "t1.a", + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "sum(t1.b)" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + } + } + } +} +explain format=json +select +a, +rank() over (order by sum(b)) +from t1 +group by a +order by null; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "sum(t1.b)" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + } + } +} +# +# Check how window function works together with GROUP BY and HAVING +# +select b,max(a) as MX, rank() over (order by b) from t1 group by b having MX in (3,5,7); +b MX rank() over (order by b) +3 3 1 +5 5 2 +7 7 3 +explain format=json +select b,max(a) as MX, rank() over (order by b) from t1 group by b having MX in (3,5,7); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "having_condition": "(MX in (3,5,7))", + "filesort": { + "sort_key": "t1.b", + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.b" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + } + } + } +} +drop table t1; +drop table t0; +# +# Building ordering index for window functions +# +create table t1 ( +pk int primary key, +a int, +b int, +c int +); +insert into t1 values +(101 , 0, 10, 1), +(102 , 0, 10, 2), +(103 , 1, 10, 3), +(104 , 1, 10, 4), +(108 , 2, 10, 5), +(105 , 2, 20, 6), +(106 , 2, 20, 7), +(107 , 2, 20, 8), +(109 , 4, 20, 9), +(110 , 4, 20, 10), +(111 , 5, NULL, 11), +(112 , 5, 1, 12), +(113 , 5, NULL, 13), +(114 , 5, NULL, 14), +(115 , 5, NULL, 15), +(116 , 6, 1, NULL), +(117 , 6, 1, 10), +(118 , 6, 1, 1), +(119 , 6, 1, NULL), +(120 , 6, 1, NULL), +(121 , 6, 1, NULL), +(122 , 6, 1, 2), +(123 , 6, 1, 20), +(124 , 6, 1, -10), +(125 , 6, 1, NULL), +(126 , 6, 1, NULL), +(127 , 6, 1, NULL); +select sum(b) over (partition by a order by b,pk +rows between unbounded preceding and current row) as c1, +avg(b) over (w1 rows between 1 preceding and 1 following) as c2, +sum(c) over (w2 rows between 1 preceding and 1 following) as c5, +avg(b) over (w1 rows between 5 preceding and 5 following) as c3, +sum(b) over (w1 rows between 1 preceding and 1 following) as c4 +from t1 +window w1 as (partition by a order by b,pk), +w2 as (partition by b order by c,pk); +c1 c2 c5 c3 c4 +1 1.0000 42 1.0000 1 +1 1.0000 NULL 1.0000 2 +10 1.0000 NULL 1.0000 3 +10 10.0000 3 10.0000 20 +10 10.0000 9 10.0000 20 +10 15.0000 9 17.5000 30 +11 1.0000 NULL 1.0000 3 +12 1.0000 -10 1.0000 2 +2 1.0000 24 1.0000 3 +20 10.0000 12 10.0000 20 +20 10.0000 6 10.0000 20 +20 20.0000 27 20.0000 40 +3 1.0000 -7 1.0000 3 +30 16.6667 13 17.5000 50 +4 1.0000 NULL 1.0000 3 +40 20.0000 19 20.0000 40 +5 1.0000 NULL 1.0000 3 +50 20.0000 21 17.5000 60 +6 1.0000 NULL 1.0000 3 +7 1.0000 13 1.0000 3 +70 20.0000 24 17.5000 40 +8 1.0000 32 1.0000 3 +9 1.0000 -9 1.0000 3 +NULL 1.0000 29 1.0000 1 +NULL NULL 24 1.0000 NULL +NULL NULL 38 1.0000 NULL +NULL NULL 42 1.0000 NULL +drop table t1; +# +# MDEV-9848: Window functions: reuse sorting and/or scanning +# +create table t1 (a int, b int, c int); +insert into t1 values +(1,3,1), +(2,2,1), +(3,1,1); +# Check using counters +flush status; +select +rank() over (partition by c order by a), +rank() over (partition by c order by b) +from t1; +rank() over (partition by c order by a) rank() over (partition by c order by b) +1 3 +2 2 +3 1 +show status like '%sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 6 +Sort_scan 2 +flush status; +select +rank() over (partition by c order by a), +rank() over (partition by c order by a) +from t1; +rank() over (partition by c order by a) rank() over (partition by c order by a) +1 1 +2 2 +3 3 +show status like '%sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_priority_queue_sorts 0 +Sort_range 0 +Sort_rows 3 +Sort_scan 1 +explain format=json +select +rank() over (partition by c order by a), +rank() over (partition by c order by a) +from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.c, t1.a" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +explain format=json +select +rank() over (order by a), +row_number() over (order by a) +from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.a" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +explain format=json +select +rank() over (partition by c order by a), +count(*) over (partition by c) +from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.c, t1.a" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +explain format=json +select +count(*) over (partition by c), +rank() over (partition by c order by a) +from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.c, t1.a" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +drop table t1; +# +# MDEV-9847: Window functions: crash with big_tables=1 +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set @tmp=@@big_tables; +set big_tables=1; +select rank() over (order by a) from t1; +rank() over (order by a) +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +set big_tables=@tmp; +drop table t1; +# +# Check if "ORDER BY window_func" works +# +create table t1 (s1 int, s2 char(5)); +insert into t1 values (1,'a'); +insert into t1 values (null,null); +insert into t1 values (1,null); +insert into t1 values (null,'a'); +insert into t1 values (2,'b'); +insert into t1 values (-1,''); +explain format=json +select *, row_number() over (order by s1, s2) as X from t1 order by X desc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "filesort": { + "sort_key": "X", + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.s1, t1.s2" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + } + } + } +} +select *, row_number() over (order by s1, s2) as X from t1 order by X desc; +s1 s2 X +2 b 6 +1 a 5 +1 NULL 4 +-1 3 +NULL a 2 +NULL NULL 1 +drop table t1; +# +# Try window functions that are not directly present in the select list +# +create table t1 (a int, b int); +insert into t1 values +(1,3), +(2,2), +(3,1); +select +rank() over (order by a) - +rank() over (order by b) +from +t1; +rank() over (order by a) - +rank() over (order by b) +0 +0 +0 +drop table t1; +# +# MDEV-9894: Assertion `0' failed in Window_func_runner::setup +# return ER_NOT_SUPPORTED_YET for aggregates that are not yet supported +# as window functions. +# +create table t1 (i int); +insert into t1 values (1),(2); +SELECT MAX(i) OVER (PARTITION BY (i)) FROM t1; +ERROR 42000: This version of MariaDB doesn't yet support 'This aggregate as window function' +drop table t1; +# +# Check the 0 in ROWS 0 PRECEDING +# +create table t1 ( +part_id int, +pk int, +a int +); +insert into t1 values (1, 1, 1); +insert into t1 values (1, 2, 2); +insert into t1 values (1, 3, 4); +insert into t1 values (1, 4, 8); +select +pk, a, +sum(a) over (order by pk rows between 0 preceding and current row) +from t1; +pk a sum(a) over (order by pk rows between 0 preceding and current row) +1 1 1 +2 2 2 +3 4 4 +4 8 8 +select +pk, a, +sum(a) over (order by pk rows between 1 preceding and 0 preceding) +from t1; +pk a sum(a) over (order by pk rows between 1 preceding and 0 preceding) +1 1 1 +2 2 3 +3 4 6 +4 8 12 +insert into t1 values (200, 1, 1); +insert into t1 values (200, 2, 2); +insert into t1 values (200, 3, 4); +insert into t1 values (200, 4, 8); +select +part_id, pk, a, +sum(a) over (partition by part_id order by pk rows between 0 preceding and current row) +from t1; +part_id pk a sum(a) over (partition by part_id order by pk rows between 0 preceding and current row) +1 1 1 1 +1 2 2 2 +1 3 4 4 +1 4 8 8 +200 1 1 1 +200 2 2 2 +200 3 4 4 +200 4 8 8 +select +part_id, pk, a, +sum(a) over (partition by part_id order by pk rows between 1 preceding and 0 preceding) +from t1; +part_id pk a sum(a) over (partition by part_id order by pk rows between 1 preceding and 0 preceding) +1 1 1 1 +1 2 2 3 +1 3 4 6 +1 4 8 12 +200 1 1 1 +200 2 2 3 +200 3 4 6 +200 4 8 12 +drop table t1; +# +# MDEV-9780, The "DISTINCT must not bet converted into GROUP BY when +# window functions are present" part +# +create table t1 (part_id int, a int); +insert into t1 values +(100, 1), +(100, 2), +(100, 2), +(100, 3), +(2000, 1), +(2000, 2), +(2000, 3), +(2000, 3), +(2000, 3); +select rank() over (partition by part_id order by a) from t1; +rank() over (partition by part_id order by a) +1 +2 +2 +4 +1 +2 +3 +3 +3 +select distinct rank() over (partition by part_id order by a) from t1; +rank() over (partition by part_id order by a) +1 +2 +4 +3 +explain format=json +select distinct rank() over (partition by part_id order by a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "duplicate_removal": { + "window_functions_computation": { + "sorts": { + "filesort": { + "sort_key": "t1.part_id, t1.a" + } + }, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } + } + } + } + } +} +drop table t1; +# +# MDEV-9893: Window functions with different ORDER BY lists, +# one of these lists containing an expression +# +create table t1 (s1 int, s2 char(5)); +insert into t1 values (1,'a'); +insert into t1 values (null,null); +insert into t1 values (3,null); +insert into t1 values (4,'a'); +insert into t1 values (2,'b'); +insert into t1 values (-1,''); +select +*, +ROW_NUMBER() OVER (order by s1), +CUME_DIST() OVER (order by -s1) +from t1; +s1 s2 ROW_NUMBER() OVER (order by s1) CUME_DIST() OVER (order by -s1) +1 a 3 0.8333333333 +NULL NULL 1 0.1666666667 +3 NULL 5 0.5000000000 +4 a 6 0.3333333333 +2 b 4 0.6666666667 +-1 2 1.0000000000 +drop table t1; +# +# MDEV-9925: Wrong result with aggregate function as a window function +# +create table t1 (i int); +insert into t1 values (1),(2); +select i, sum(i) over (partition by i) from t1; +i sum(i) over (partition by i) +1 1 +2 2 +drop table t1; +# +# MDEV-9922: Assertion `!join->only_const_tables() && fsort' failed in int create_sort_index +# +create view v1 as select 1 as i; +select rank() over (order by i) from v1; +rank() over (order by i) +1 +drop view v1; diff --git a/mysql-test/r/win_avg.result b/mysql-test/r/win_avg.result new file mode 100644 index 00000000000..7e539d933d8 --- /dev/null +++ b/mysql-test/r/win_avg.result @@ -0,0 +1,95 @@ +create table t1 ( +pk int primary key, +a int, +b int, +c real +); +insert into t1 values +(101 , 0, 10, 1.1), +(102 , 0, 10, 2.1), +(103 , 1, 10, 3.1), +(104 , 1, 10, 4.1), +(108 , 2, 10, 5.1), +(105 , 2, 20, 6.1), +(106 , 2, 20, 7.1), +(107 , 2, 20, 8.15), +(109 , 4, 20, 9.15), +(110 , 4, 20, 10.15), +(111 , 5, NULL, 11.15), +(112 , 5, 1, 12.25), +(113 , 5, NULL, 13.35), +(114 , 5, NULL, 14.50), +(115 , 5, NULL, 15.65), +(116 , 6, 1, NULL), +(117 , 6, 1, 10), +(118 , 6, 1, 1.1), +(119 , 6, 1, NULL), +(120 , 6, 1, NULL), +(121 , 6, 1, NULL), +(122 , 6, 1, 2.2), +(123 , 6, 1, 20.1), +(124 , 6, 1, -10.4), +(125 , 6, 1, NULL), +(126 , 6, 1, NULL), +(127 , 6, 1, NULL); +select pk, a, b, avg(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; +pk a b avg(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +101 0 10 10.0000 +102 0 10 10.0000 +103 1 10 10.0000 +104 1 10 10.0000 +105 2 20 20.0000 +106 2 20 20.0000 +107 2 20 16.6667 +108 2 10 15.0000 +109 4 20 20.0000 +110 4 20 20.0000 +111 5 NULL 1.0000 +112 5 1 1.0000 +113 5 NULL 1.0000 +114 5 NULL NULL +115 5 NULL NULL +116 6 1 1.0000 +117 6 1 1.0000 +118 6 1 1.0000 +119 6 1 1.0000 +120 6 1 1.0000 +121 6 1 1.0000 +122 6 1 1.0000 +123 6 1 1.0000 +124 6 1 1.0000 +125 6 1 1.0000 +126 6 1 1.0000 +127 6 1 1.0000 +select pk, a, c, avg(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; +pk a c avg(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +101 0 1.1 1.6 +102 0 2.1 1.6 +103 1 3.1 3.5999999999999996 +104 1 4.1 3.5999999999999996 +105 2 6.1 6.6 +106 2 7.1 7.116666666666667 +107 2 8.15 6.783333333333334 +108 2 5.1 6.625000000000001 +109 4 9.15 9.65 +110 4 10.15 9.65 +111 5 11.15 11.7 +112 5 12.25 12.25 +113 5 13.35 13.366666666666667 +114 5 14.5 14.5 +115 5 15.65 15.075 +116 6 NULL 10 +117 6 10 5.55 +118 6 1.1 5.55 +119 6 NULL 1.0999999999999996 +120 6 NULL NULL +121 6 NULL 2.1999999999999997 +122 6 2.2 11.15 +123 6 20.1 3.966666666666667 +124 6 -10.4 4.85 +125 6 NULL -10.400000000000002 +126 6 NULL NULL +127 6 NULL NULL +drop table t1; diff --git a/mysql-test/r/win_bit.result b/mysql-test/r/win_bit.result new file mode 100644 index 00000000000..ac7625beb90 --- /dev/null +++ b/mysql-test/r/win_bit.result @@ -0,0 +1,117 @@ +create table t1 ( +pk int primary key, +a int, +b int +); +create table t2 ( +pk int primary key, +a int, +b int +); +insert into t1 values +( 1 , 0, 1), +( 2 , 0, 2), +( 3 , 1, 4), +( 4 , 1, 8), +( 5 , 2, 32), +( 6 , 2, 64), +( 7 , 2, 128), +( 8 , 2, 16); +insert into t2 values +( 1 , 0, 2), +( 2 , 0, 2), +( 3 , 1, 4), +( 4 , 1, 4), +( 5 , 2, 16), +( 6 , 2, 64), +( 7 , 2, 128), +( 8 , 2, 16); +# Test bit functions on only one partition. +select pk, a, b, +bit_or(b) over (order by pk) as bit_or, +bit_and(b) over (order by pk) as bit_and, +bit_xor(b) over (order by pk) as bit_xor +from t1; +pk a b bit_or bit_and bit_xor +1 0 1 1 1 1 +2 0 2 3 0 3 +3 1 4 7 0 7 +4 1 8 15 0 15 +5 2 32 47 0 47 +6 2 64 111 0 111 +7 2 128 239 0 239 +8 2 16 255 0 255 +select pk, a, b, +bit_or(b) over (order by pk) as bit_or, +bit_and(b) over (order by pk) as bit_and, +bit_xor(b) over (order by pk) as bit_xor +from t2; +pk a b bit_or bit_and bit_xor +1 0 2 2 2 2 +2 0 2 2 2 0 +3 1 4 6 0 4 +4 1 4 6 0 0 +5 2 16 22 0 16 +6 2 64 86 0 80 +7 2 128 214 0 208 +8 2 16 214 0 192 +# Test multiple partitions with bit functions. +select pk, a, b, +bit_or(b) over (partition by a order by pk) as bit_or, +bit_and(b) over (partition by a order by pk) as bit_and, +bit_xor(b) over (partition by a order by pk) as bit_xor +from t1; +pk a b bit_or bit_and bit_xor +1 0 1 1 1 1 +2 0 2 3 0 3 +3 1 4 4 4 4 +4 1 8 12 0 12 +5 2 32 32 32 32 +6 2 64 96 0 96 +7 2 128 224 0 224 +8 2 16 240 0 240 +select pk, a, b, +bit_or(b) over (partition by a order by pk) as bit_or, +bit_and(b) over (partition by a order by pk) as bit_and, +bit_xor(b) over (partition by a order by pk) as bit_xor +from t2; +pk a b bit_or bit_and bit_xor +1 0 2 2 2 2 +2 0 2 2 2 0 +3 1 4 4 4 4 +4 1 4 4 4 0 +5 2 16 16 16 16 +6 2 64 80 0 80 +7 2 128 208 0 208 +8 2 16 208 0 192 +# Test remove function for bit functions using a sliding window. +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as bit_or, +bit_and(b) over (partition by a order by pk) as bit_and, +bit_xor(b) over (partition by a order by pk) as bit_xor +from t1; +pk a b bit_or bit_and bit_xor +1 0 1 3 1 1 +2 0 2 3 0 3 +3 1 4 12 4 4 +4 1 8 12 0 12 +5 2 32 96 32 32 +6 2 64 224 0 96 +7 2 128 208 0 224 +8 2 16 144 0 240 +select pk, a, b, +bit_or(b) over (partition by a order by pk) as bit_or, +bit_and(b) over (partition by a order by pk) as bit_and, +bit_xor(b) over (partition by a order by pk) as bit_xor +from t2; +pk a b bit_or bit_and bit_xor +1 0 2 2 2 2 +2 0 2 2 2 0 +3 1 4 4 4 4 +4 1 4 4 4 0 +5 2 16 16 16 16 +6 2 64 80 0 80 +7 2 128 208 0 208 +8 2 16 208 0 192 +drop table t1; +drop table t2; diff --git a/mysql-test/r/win_ntile.result b/mysql-test/r/win_ntile.result new file mode 100644 index 00000000000..41cb1a594bf --- /dev/null +++ b/mysql-test/r/win_ntile.result @@ -0,0 +1,435 @@ +create table t1 ( +pk int primary key, +a int, +b int +); +insert into t1 values +(11 , 0, 10), +(12 , 0, 10), +(13 , 1, 10), +(14 , 1, 10), +(18 , 2, 10), +(15 , 2, 20), +(16 , 2, 20), +(17 , 2, 20), +(19 , 4, 20), +(20 , 4, 20); +select pk, a, b, ntile(-1) over (order by a) +from t1; +ERROR HY000: Argument of NTILE must be greater than 0 +select pk, a, b, +ntile(0) over (order by a) +from t1; +ERROR HY000: Argument of NTILE must be greater than 0 +select pk, a, b, +ntile(1) over (order by pk) +from t1; +pk a b ntile(1) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 1 +15 2 20 1 +16 2 20 1 +17 2 20 1 +18 2 10 1 +19 4 20 1 +20 4 20 1 +select pk, a, b, +ntile(2) over (order by pk) +from t1; +pk a b ntile(2) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 1 +15 2 20 1 +16 2 20 2 +17 2 20 2 +18 2 10 2 +19 4 20 2 +20 4 20 2 +select pk, a, b, +ntile(3) over (order by pk) +from t1; +pk a b ntile(3) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 1 +15 2 20 2 +16 2 20 2 +17 2 20 2 +18 2 10 3 +19 4 20 3 +20 4 20 3 +select pk, a, b, +ntile(4) over (order by pk) +from t1; +pk a b ntile(4) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 2 +15 2 20 2 +16 2 20 2 +17 2 20 3 +18 2 10 3 +19 4 20 4 +20 4 20 4 +select pk, a, b, +ntile(5) over (order by pk) +from t1; +pk a b ntile(5) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 2 +15 2 20 3 +16 2 20 3 +17 2 20 4 +18 2 10 4 +19 4 20 5 +20 4 20 5 +select pk, a, b, +ntile(6) over (order by pk) +from t1; +pk a b ntile(6) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 2 +15 2 20 3 +16 2 20 3 +17 2 20 4 +18 2 10 4 +19 4 20 5 +20 4 20 6 +select pk, a, b, +ntile(7) over (order by pk) +from t1; +pk a b ntile(7) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 2 +15 2 20 3 +16 2 20 3 +17 2 20 4 +18 2 10 5 +19 4 20 6 +20 4 20 7 +select pk, a, b, +ntile(8) over (order by pk) +from t1; +pk a b ntile(8) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 2 +15 2 20 3 +16 2 20 4 +17 2 20 5 +18 2 10 6 +19 4 20 7 +20 4 20 8 +select pk, a, b, +ntile(9) over (order by pk) +from t1; +pk a b ntile(9) over (order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 3 +15 2 20 4 +16 2 20 5 +17 2 20 6 +18 2 10 7 +19 4 20 8 +20 4 20 9 +select pk, a, b, +ntile(10) over (order by pk) +from t1; +pk a b ntile(10) over (order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +15 2 20 5 +16 2 20 6 +17 2 20 7 +18 2 10 8 +19 4 20 9 +20 4 20 10 +select pk, a, b, +ntile(11) over (order by pk) +from t1; +pk a b ntile(11) over (order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +15 2 20 5 +16 2 20 6 +17 2 20 7 +18 2 10 8 +19 4 20 9 +20 4 20 10 +select pk, a, b, +ntile(20) over (order by pk) +from t1; +pk a b ntile(20) over (order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +15 2 20 5 +16 2 20 6 +17 2 20 7 +18 2 10 8 +19 4 20 9 +20 4 20 10 +select pk, a, b, +ntile(1) over (partition by b order by pk) +from t1; +pk a b ntile(1) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 1 +18 2 10 1 +15 2 20 1 +16 2 20 1 +17 2 20 1 +19 4 20 1 +20 4 20 1 +select pk, a, b, +ntile(2) over (partition by b order by pk) +from t1; +pk a b ntile(2) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 2 +18 2 10 2 +15 2 20 1 +16 2 20 1 +17 2 20 1 +19 4 20 2 +20 4 20 2 +select pk, a, b, +ntile(3) over (partition by b order by pk) +from t1; +pk a b ntile(3) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 2 +18 2 10 3 +15 2 20 1 +16 2 20 1 +17 2 20 2 +19 4 20 2 +20 4 20 3 +select pk, a, b, +ntile(4) over (partition by b order by pk) +from t1; +pk a b ntile(4) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 3 +18 2 10 4 +15 2 20 1 +16 2 20 1 +17 2 20 2 +19 4 20 3 +20 4 20 4 +select pk, a, b, +ntile(5) over (partition by b order by pk) +from t1; +pk a b ntile(5) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(6) over (partition by b order by pk) +from t1; +pk a b ntile(6) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(7) over (partition by b order by pk) +from t1; +pk a b ntile(7) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(8) over (partition by b order by pk) +from t1; +pk a b ntile(8) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(9) over (partition by b order by pk) +from t1; +pk a b ntile(9) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(10) over (partition by b order by pk) +from t1; +pk a b ntile(10) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(11) over (partition by b order by pk) +from t1; +pk a b ntile(11) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(20) over (partition by b order by pk) +from t1; +pk a b ntile(20) over (partition by b order by pk) +11 0 10 1 +12 0 10 2 +13 1 10 3 +14 1 10 4 +18 2 10 5 +15 2 20 1 +16 2 20 2 +17 2 20 3 +19 4 20 4 +20 4 20 5 +select pk, a, b, +ntile(1 + 3) over (partition by b order by pk) +from t1; +pk a b ntile(1 + 3) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 3 +18 2 10 4 +15 2 20 1 +16 2 20 1 +17 2 20 2 +19 4 20 3 +20 4 20 4 +select pk, a, b, +ntile((select 4)) over (partition by b order by pk) +from t1; +pk a b ntile((select 4)) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 2 +14 1 10 3 +18 2 10 4 +15 2 20 1 +16 2 20 1 +17 2 20 2 +19 4 20 3 +20 4 20 4 +select t1.a from t1 where pk = 11; +a +0 +select pk, a, b, +ntile((select a from t1 where pk=11)) over (partition by b order by pk) +from t1; +ERROR HY000: Argument of NTILE must be greater than 0 +select t1.a from t1 where pk = 13; +a +1 +select pk, a, b, +ntile((select a from t1 where pk=13)) over (partition by b order by pk) +from t1; +pk a b ntile((select a from t1 where pk=13)) over (partition by b order by pk) +11 0 10 1 +12 0 10 1 +13 1 10 1 +14 1 10 1 +18 2 10 1 +15 2 20 1 +16 2 20 1 +17 2 20 1 +19 4 20 1 +20 4 20 1 +explain +select pk, a, b, +ntile((select a from t1 where pk=13)) over (partition by b order by pk) +from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using temporary +2 SUBQUERY t1 const PRIMARY PRIMARY 4 const 1 +select a from t1; +a +0 +0 +1 +1 +2 +2 +2 +2 +4 +4 +select pk, a, b, +ntile((select a from t1)) over (partition by b order by pk) +from t1; +ERROR 21000: Subquery returns more than 1 row +drop table t1; diff --git a/mysql-test/r/win_orderby.result b/mysql-test/r/win_orderby.result new file mode 100644 index 00000000000..bf4a40a4db3 --- /dev/null +++ b/mysql-test/r/win_orderby.result @@ -0,0 +1,26 @@ +drop table if exists t0,t1; +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1( +pk int, +a int, +key(pk) +); +insert into t1 +select +A.a + B.a* 10 + C.a * 100, +1 +from t0 A, t0 B, t0 C; +select +pk, +count(a) over (order by pk rows between 2 preceding and 2 following) +from t1 +where pk between 1 and 30 +order by pk desc +limit 4; +pk count(a) over (order by pk rows between 2 preceding and 2 following) +30 3 +29 4 +28 5 +27 5 +drop table t0,t1; diff --git a/mysql-test/r/win_percent_cume.result b/mysql-test/r/win_percent_cume.result new file mode 100644 index 00000000000..d38c95c9ea7 --- /dev/null +++ b/mysql-test/r/win_percent_cume.result @@ -0,0 +1,62 @@ +create table t1 ( +pk int primary key, +a int, +b int +); +insert into t1 values +( 1 , 0, 10), +( 2 , 0, 10), +( 3 , 1, 10), +( 4 , 1, 10), +( 8 , 2, 10), +( 5 , 2, 20), +( 6 , 2, 20), +( 7 , 2, 20), +( 9 , 4, 20), +(10 , 4, 20); +select pk, a, b, +percent_rank() over (order by a), +cume_dist() over (order by a) +from t1; +pk a b percent_rank() over (order by a) cume_dist() over (order by a) +1 0 10 0.0000000000 0.2000000000 +2 0 10 0.0000000000 0.2000000000 +3 1 10 0.2222222222 0.4000000000 +4 1 10 0.2222222222 0.4000000000 +8 2 10 0.4444444444 0.8000000000 +5 2 20 0.4444444444 0.8000000000 +6 2 20 0.4444444444 0.8000000000 +7 2 20 0.4444444444 0.8000000000 +9 4 20 0.8888888889 1.0000000000 +10 4 20 0.8888888889 1.0000000000 +select pk, a, b, +percent_rank() over (order by pk), +cume_dist() over (order by pk) +from t1 order by pk; +pk a b percent_rank() over (order by pk) cume_dist() over (order by pk) +1 0 10 0.0000000000 0.1000000000 +2 0 10 0.1111111111 0.2000000000 +3 1 10 0.2222222222 0.3000000000 +4 1 10 0.3333333333 0.4000000000 +5 2 20 0.4444444444 0.5000000000 +6 2 20 0.5555555556 0.6000000000 +7 2 20 0.6666666667 0.7000000000 +8 2 10 0.7777777778 0.8000000000 +9 4 20 0.8888888889 0.9000000000 +10 4 20 1.0000000000 1.0000000000 +select pk, a, b, +percent_rank() over (partition by a order by a), +cume_dist() over (partition by a order by a) +from t1; +pk a b percent_rank() over (partition by a order by a) cume_dist() over (partition by a order by a) +1 0 10 0.0000000000 1.0000000000 +2 0 10 0.0000000000 1.0000000000 +3 1 10 0.0000000000 1.0000000000 +4 1 10 0.0000000000 1.0000000000 +8 2 10 0.0000000000 1.0000000000 +5 2 20 0.0000000000 1.0000000000 +6 2 20 0.0000000000 1.0000000000 +7 2 20 0.0000000000 1.0000000000 +9 4 20 0.0000000000 1.0000000000 +10 4 20 0.0000000000 1.0000000000 +drop table t1; diff --git a/mysql-test/r/win_rank.result b/mysql-test/r/win_rank.result new file mode 100644 index 00000000000..725683d3869 --- /dev/null +++ b/mysql-test/r/win_rank.result @@ -0,0 +1,104 @@ +# +# Try DENSE_RANK() function +# +create table t1 ( +pk int primary key, +a int, +b int +); +insert into t1 values +( 1 , 0, 10), +( 2 , 0, 10), +( 3 , 1, 10), +( 4 , 1, 10), +( 8 , 2, 10), +( 5 , 2, 20), +( 6 , 2, 20), +( 7 , 2, 20), +( 9 , 4, 20), +(10 , 4, 20); +select pk, a, b, rank() over (order by a) as rank, +dense_rank() over (order by a) as dense_rank +from t1; +pk a b rank dense_rank +1 0 10 1 1 +2 0 10 1 1 +3 1 10 3 2 +4 1 10 3 2 +8 2 10 5 3 +5 2 20 5 3 +6 2 20 5 3 +7 2 20 5 3 +9 4 20 9 4 +10 4 20 9 4 +select pk, a, b, rank() over (partition by b order by a) as rank, +dense_rank() over (partition by b order by a) as dense_rank +from t1; +pk a b rank dense_rank +1 0 10 1 1 +2 0 10 1 1 +3 1 10 3 2 +4 1 10 3 2 +8 2 10 5 3 +5 2 20 1 1 +6 2 20 1 1 +7 2 20 1 1 +9 4 20 4 2 +10 4 20 4 2 +drop table t1; +# +# Test with null values in the table. +# +create table t2 (s1 int, s2 char(5)); +insert into t2 values (1,'a'); +insert into t2 values (null,null); +insert into t2 values (1,null); +insert into t2 values (null,'a'); +insert into t2 values (null,'c'); +insert into t2 values (2,'b'); +insert into t2 values (-1,''); +select *, rank() over (order by s1) as rank, +dense_rank() over (order by s1) as dense_rank +from t2; +s1 s2 rank dense_rank +1 a 5 3 +NULL NULL 1 1 +1 NULL 5 3 +NULL a 1 1 +NULL c 1 1 +2 b 7 4 +-1 4 2 +select *, rank() over (partition by s2 order by s1) as rank, +dense_rank() over (partition by s2 order by s1) as dense_rank +from t2; +s1 s2 rank dense_rank +1 a 2 2 +NULL NULL 1 1 +1 NULL 2 2 +NULL a 1 1 +NULL c 1 1 +2 b 1 1 +-1 1 1 +select *, rank() over (order by s2) as rank, +dense_rank() over (order by s2) as dense_rank +from t2; +s1 s2 rank dense_rank +1 a 4 3 +NULL NULL 1 1 +1 NULL 1 1 +NULL a 4 3 +NULL c 7 5 +2 b 6 4 +-1 3 2 +select *, rank() over (partition by s1 order by s2) as rank, +dense_rank() over (partition by s1 order by s2) as dense_rank +from t2; +s1 s2 rank dense_rank +1 a 2 2 +NULL NULL 1 1 +1 NULL 1 1 +NULL a 2 2 +NULL c 3 3 +2 b 1 1 +-1 1 1 +drop table t2; diff --git a/mysql-test/r/win_sum.result b/mysql-test/r/win_sum.result new file mode 100644 index 00000000000..66a48fe8293 --- /dev/null +++ b/mysql-test/r/win_sum.result @@ -0,0 +1,95 @@ +create table t1 ( +pk int primary key, +a int, +b int, +c real +); +insert into t1 values +(101 , 0, 10, 1.1), +(102 , 0, 10, 2.1), +(103 , 1, 10, 3.1), +(104 , 1, 10, 4.1), +(108 , 2, 10, 5.1), +(105 , 2, 20, 6.1), +(106 , 2, 20, 7.1), +(107 , 2, 20, 8.15), +(109 , 4, 20, 9.15), +(110 , 4, 20, 10.15), +(111 , 5, NULL, 11.15), +(112 , 5, 1, 12.25), +(113 , 5, NULL, 13.35), +(114 , 5, NULL, 14.50), +(115 , 5, NULL, 15.65), +(116 , 6, 1, NULL), +(117 , 6, 1, 10), +(118 , 6, 1, 1.1), +(119 , 6, 1, NULL), +(120 , 6, 1, NULL), +(121 , 6, 1, NULL), +(122 , 6, 1, 2.2), +(123 , 6, 1, 20.1), +(124 , 6, 1, -10.4), +(125 , 6, 1, NULL), +(126 , 6, 1, NULL), +(127 , 6, 1, NULL); +select pk, a, b, sum(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; +pk a b sum(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +101 0 10 20 +102 0 10 20 +103 1 10 20 +104 1 10 20 +105 2 20 40 +106 2 20 60 +107 2 20 50 +108 2 10 30 +109 4 20 40 +110 4 20 40 +111 5 NULL 1 +112 5 1 1 +113 5 NULL 1 +114 5 NULL NULL +115 5 NULL NULL +116 6 1 2 +117 6 1 3 +118 6 1 3 +119 6 1 3 +120 6 1 3 +121 6 1 3 +122 6 1 3 +123 6 1 3 +124 6 1 3 +125 6 1 3 +126 6 1 3 +127 6 1 2 +select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; +pk a c sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +101 0 1.1 3.2 +102 0 2.1 3.2 +103 1 3.1 7.199999999999999 +104 1 4.1 7.199999999999999 +105 2 6.1 13.2 +106 2 7.1 21.35 +107 2 8.15 20.35 +108 2 5.1 13.250000000000002 +109 4 9.15 19.3 +110 4 10.15 19.3 +111 5 11.15 23.4 +112 5 12.25 36.75 +113 5 13.35 40.1 +114 5 14.5 43.5 +115 5 15.65 30.15 +116 6 NULL 10 +117 6 10 11.1 +118 6 1.1 11.1 +119 6 NULL 1.0999999999999996 +120 6 NULL NULL +121 6 NULL 2.1999999999999997 +122 6 2.2 22.3 +123 6 20.1 11.9 +124 6 -10.4 9.7 +125 6 NULL -10.400000000000002 +126 6 NULL NULL +127 6 NULL NULL +drop table t1; diff --git a/mysql-test/std_data/bad2_master.info b/mysql-test/std_data/bad2_master.info new file mode 100644 index 00000000000..61722562748 --- /dev/null +++ b/mysql-test/std_data/bad2_master.info @@ -0,0 +1,35 @@ +33 +mysql-bin.000001 +4 +127.0.0.1 +root + +3310 +60 +0 + + + + + +0 +1800.000 + +0 + +0 + + + + + + + + + + + + + +using_gtid=1 +=0 diff --git a/mysql-test/std_data/bad3_master.info b/mysql-test/std_data/bad3_master.info new file mode 100644 index 00000000000..6e632cd9a49 --- /dev/null +++ b/mysql-test/std_data/bad3_master.info @@ -0,0 +1,37 @@ +33 +mysql-bin.000001 +4 +127.0.0.1 +root + +3310 +60 +0 + + + + + +0 +1800.000 + +0 + +0 + + + + + + + + + + + + + +using_gtid=1 + + +0 diff --git a/mysql-test/std_data/bad4_master.info b/mysql-test/std_data/bad4_master.info new file mode 100644 index 00000000000..87572efc8a4 --- /dev/null +++ b/mysql-test/std_data/bad4_master.info @@ -0,0 +1,35 @@ +33 +mysql-bin.000001 +4 +127.0.0.1 +root + +3310 +60 +0 + + + + + +0 +1800.000 + +0 + +0 + + + + + + + + + + + + + +using_gtid=1 +d=1 diff --git a/mysql-test/std_data/bad5_master.info b/mysql-test/std_data/bad5_master.info new file mode 100644 index 00000000000..4ea8113250b --- /dev/null +++ b/mysql-test/std_data/bad5_master.info @@ -0,0 +1,35 @@ +33 +mysql-bin.000001 +4 +127.0.0.1 +root + +3310 +60 +0 + + + + + +0 +1800.000 + +0 + +0 + + + + + + + + + + + + + +using_gtid=1 +using_gtid diff --git a/mysql-test/std_data/bad6_master.info b/mysql-test/std_data/bad6_master.info new file mode 100644 index 00000000000..0f48f4871f0 --- /dev/null +++ b/mysql-test/std_data/bad6_master.info @@ -0,0 +1,36 @@ +33 +mysql-bin.000001 +4 +127.0.0.1 +root + +3310 +60 +0 + + + + + +0 +1800.000 + +0 + +0 + + + + + + + + + + + + + +using_gtid=1 +END_MARKER +do_domain_ids=20 Hulubulu!!?! diff --git a/mysql-test/std_data/bad_master.info b/mysql-test/std_data/bad_master.info new file mode 100644 index 00000000000..1541fdf2c61 --- /dev/null +++ b/mysql-test/std_data/bad_master.info @@ -0,0 +1,35 @@ +33 +mysql-bin.000001 +4 +127.0.0.1 +root + +3310 +60 +0 + + + + + +0 +1800.000 + +0 + +0 + + + + + + + + + + + + + +using_gtid=1 + diff --git a/mysql-test/std_data/loaddata/mdev9823.ujis.txt b/mysql-test/std_data/loaddata/mdev9823.ujis.txt new file mode 100644 index 00000000000..5468c999585 --- /dev/null +++ b/mysql-test/std_data/loaddata/mdev9823.ujis.txt @@ -0,0 +1,11 @@ +# This file has incomplete UJIS sequences {8F}, {8FA1}, +# has a valid UJIS sequence {8FA1A1}, +# and has no NL at the end: +# {8F} \n xxx1 {8FA1} \n xxx2 {8FA1A1} \n xxx3 \n {8FA1} EOF + +xxx1 +¡ +xxx2 +¡¡ +xxx3 +¡
\ No newline at end of file diff --git a/mysql-test/std_data/loaddata/mdev9823.utf8mb4.txt b/mysql-test/std_data/loaddata/mdev9823.utf8mb4.txt new file mode 100644 index 00000000000..87739567de1 --- /dev/null +++ b/mysql-test/std_data/loaddata/mdev9823.utf8mb4.txt @@ -0,0 +1,12 @@ +# This file has incomplete utf8mb4 sequences {D0}, {E180}, {F09F98}, +# has a valid utf8mb4 sequence {F09F988E} +# and has no NL at the end: +# {D0} \n xxx1 {E180} xxx2 \n {F09F98} \n xxx3 {F09F988E} {F09F98} EOF +Ð +xxx1 +ဠ+xxx2 +😠+xxx3 +😎 +ðŸ˜
\ No newline at end of file diff --git a/mysql-test/std_data/loaddata/mdev9874.xml b/mysql-test/std_data/loaddata/mdev9874.xml new file mode 100644 index 00000000000..513a0dff2be --- /dev/null +++ b/mysql-test/std_data/loaddata/mdev9874.xml @@ -0,0 +1 @@ +<table><row><a>aÐ</a></row></table>
\ No newline at end of file diff --git a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc index 5f87d23dcc1..cbd2c1c817a 100644 --- a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc +++ b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc @@ -6,6 +6,7 @@ --connection node_1 # We need a user with a password to perform SST, otherwise we hit LP #1378253 +CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; --let $wsrep_sst_auth_orig = `SELECT @@wsrep_sst_auth` diff --git a/mysql-test/suite/galera/r/binlog_checksum.result b/mysql-test/suite/galera/r/binlog_checksum.result index 5c1981fc17f..e86f3892ac7 100644 --- a/mysql-test/suite/galera/r/binlog_checksum.result +++ b/mysql-test/suite/galera/r/binlog_checksum.result @@ -1,7 +1,9 @@ # On node_1 +connection node_1; SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM; SET @@GLOBAL.BINLOG_CHECKSUM=CRC32; # On node_2 +connection node_2; SET @binlog_checksum_saved= @@GLOBAL.BINLOG_CHECKSUM; SET @@GLOBAL.BINLOG_CHECKSUM=CRC32; USE test; @@ -23,6 +25,7 @@ c1 5 # On node_2 +connection node_2; SELECT * FROM test.t1; c1 1 @@ -31,6 +34,10 @@ c1 4 5 DROP TABLE t1; +connection node_1; SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved; +connection node_2; SET @@GLOBAL.BINLOG_CHECKSUM = @binlog_checksum_saved; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/create.result b/mysql-test/suite/galera/r/create.result index d8a2db99a68..20bc9a3958e 100644 --- a/mysql-test/suite/galera/r/create.result +++ b/mysql-test/suite/galera/r/create.result @@ -25,10 +25,12 @@ SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved; # # MDEV-7673: CREATE TABLE SELECT fails on Galera cluster # +connection node_1; CREATE TABLE t1 (i INT) ENGINE=INNODB DEFAULT CHARSET=utf8 SELECT 1 as i; SELECT * FROM t1; i 1 +connection node_2; SELECT * FROM t1; i 1 @@ -37,6 +39,7 @@ DROP TABLE t1; # MDEV-8166 : Adding index on new table from select crashes Galera # cluster # +connection node_1; CREATE TABLE t1(i int(11) NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO t1(i) VALUES (1), (2), (3); CREATE TABLE t2 (i INT) SELECT i FROM t1; @@ -46,6 +49,7 @@ i 1 2 3 +connection node_2; SELECT * FROM t2; i 1 diff --git a/mysql-test/suite/galera/r/enforce_storage_engine.result b/mysql-test/suite/galera/r/enforce_storage_engine.result index a3513fc2789..746aa22bf20 100644 --- a/mysql-test/suite/galera/r/enforce_storage_engine.result +++ b/mysql-test/suite/galera/r/enforce_storage_engine.result @@ -2,11 +2,13 @@ # MDEV-8831 : enforce_storage_engine doesn't block table creation on # other nodes (galera cluster) # +connection node_1; SET @@enforce_storage_engine=INNODB; CREATE TABLE t1(i INT) ENGINE=INNODB; CREATE TABLE t2(i INT) ENGINE=MYISAM; ERROR 42000: Unknown storage engine 'MyISAM' INSERT INTO t1 VALUES(1); +connection node_2; SHOW TABLES; Tables_in_test t1 @@ -14,6 +16,7 @@ SELECT COUNT(*)=1 FROM t1; COUNT(*)=1 1 CREATE TABLE t2(i INT) ENGINE=MYISAM; +connection node_1; SHOW TABLES; Tables_in_test t1 diff --git a/mysql-test/suite/galera/r/fk.result b/mysql-test/suite/galera/r/fk.result index d6a3a25b01a..ab8e1c8f680 100644 --- a/mysql-test/suite/galera/r/fk.result +++ b/mysql-test/suite/galera/r/fk.result @@ -1,6 +1,7 @@ USE test; # On node_1 +connection node_1; CREATE TABLE networks ( `tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `id` varchar(36) COLLATE utf8_unicode_ci NOT NULL, @@ -60,9 +61,11 @@ INSERT INTO ipallocations VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','10.25. select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516'; tenant_id id name network_id mac_address admin_state_up status device_id device_owner f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 fa:16:3e:e3:cc:bb 1 DOWN f37aa3fe-ab99-4d0f-a566-6cd3169d7516 network:router_gateway +connection node_2; select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516'; tenant_id id name network_id mac_address admin_state_up status device_id device_owner f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 fa:16:3e:e3:cc:bb 1 DOWN f37aa3fe-ab99-4d0f-a566-6cd3169d7516 network:router_gateway +connection node_1; DELETE FROM ports WHERE ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516'; select * from networks; tenant_id id name status admin_state_up shared @@ -78,6 +81,7 @@ select * from ports; tenant_id id name network_id mac_address admin_state_up status device_id device_owner # On node_2 +connection node_2; select * from networks; tenant_id id name status admin_state_up shared f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 MyNet ACTIVE 0 0 @@ -90,7 +94,10 @@ select * from ipallocations; port_id ip_address subnet_id network_id select * from ports; tenant_id id name network_id mac_address admin_state_up status device_id device_owner +connection node_1; drop table ipallocations; drop table subnets; drop table ports; drop table networks; +disconnect node_2; +disconnect node_1; diff --git a/mysql-test/suite/galera/r/galera_account_management.result b/mysql-test/suite/galera/r/galera_account_management.result index 9b3ae9ba46e..7fb472a5c2d 100644 --- a/mysql-test/suite/galera/r/galera_account_management.result +++ b/mysql-test/suite/galera/r/galera_account_management.result @@ -1,39 +1,55 @@ +connection node_1; CREATE USER user1, user2 IDENTIFIED BY 'password'; +connection node_2; SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2'); COUNT(*) = 2 1 +connection node_1; RENAME USER user2 TO user3; +connection node_2; SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2'; COUNT(*) = 0 1 SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user3'; COUNT(*) = 1 1 +connection node_1; SET PASSWORD FOR user3 = PASSWORD('foo'); +connection node_1; SELECT password != '' FROM mysql.user WHERE user = 'user3'; password != '' 1 +connection node_1; DROP USER user1, user3; +connection node_2; SELECT COUNT(*) = 0 FROM mysql.user WHERE user IN ('user1', 'user2'); COUNT(*) = 0 1 +connection node_1; GRANT ALL ON *.* TO user4 IDENTIFIED BY 'password'; +connection node_2; SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user4'; COUNT(*) = 1 1 SELECT Select_priv = 'Y' FROM mysql.user WHERE user = 'user4'; Select_priv = 'Y' 1 +connection node_1; CREATE USER user5; GRANT PROXY ON user4 TO user5; +connection node_2; SELECT COUNT(*) = 1 FROM mysql.proxies_priv WHERE user = 'user5'; COUNT(*) = 1 1 +connection node_1; REVOKE ALL PRIVILEGES ON *.* FROM user4; +connection node_2; SELECT Select_priv = 'N' FROM mysql.user WHERE user = 'user4'; Select_priv = 'N' 1 +connection node_1; REVOKE PROXY ON user4 FROM user5; +connection node_2; SELECT COUNT(*) = 0 FROM mysql.proxies_priv WHERE user = 'user5'; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_alter_engine_innodb.result b/mysql-test/suite/galera/r/galera_alter_engine_innodb.result index 2b30ac5814d..ff6ab792c0e 100644 --- a/mysql-test/suite/galera/r/galera_alter_engine_innodb.result +++ b/mysql-test/suite/galera/r/galera_alter_engine_innodb.result @@ -1,6 +1,7 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); ALTER TABLE t1 ENGINE=InnoDB; +connection node_2; SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ENGINE = 'InnoDB' 1 diff --git a/mysql-test/suite/galera/r/galera_alter_engine_myisam.result b/mysql-test/suite/galera/r/galera_alter_engine_myisam.result index 280cb58208c..389383858ac 100644 --- a/mysql-test/suite/galera/r/galera_alter_engine_myisam.result +++ b/mysql-test/suite/galera/r/galera_alter_engine_myisam.result @@ -2,10 +2,12 @@ SET GLOBAL wsrep_replicate_myisam = TRUE; CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1); ALTER TABLE t1 ENGINE=InnoDB; +connection node_2; SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ENGINE = 'InnoDB' 1 SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_alter_table_force.result b/mysql-test/suite/galera/r/galera_alter_table_force.result index 401ab46d868..d0a2f81b631 100644 --- a/mysql-test/suite/galera/r/galera_alter_table_force.result +++ b/mysql-test/suite/galera/r/galera_alter_table_force.result @@ -1,6 +1,7 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); ALTER TABLE t1 FORCE; +connection node_2; SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ENGINE = 'InnoDB' 1 diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result index cecbfc1f3cf..18dcc55d5d4 100644 --- a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result +++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result @@ -1,12 +1,17 @@ +connection node_1; SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; FLUSH TABLE t1 WITH READ LOCK; +connection node_2; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; SET SESSION wsrep_sync_wait = 0; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_1; UNLOCK TABLES; SET SESSION wsrep_sync_wait = 7; SELECT COUNT(*) = 2 FROM t1; diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result index ee967356c85..1cf88dbf5d3 100644 --- a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result +++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result @@ -1,10 +1,13 @@ +connection node_1; SET SESSION wsrep_sync_wait = 0; SET SESSION lock_wait_timeout = 60; SET SESSION innodb_lock_wait_timeout=60; SET SESSION wait_timeout=60; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; FLUSH TABLE t1 WITH READ LOCK; +connection node_2; ALTER TABLE t1 ADD COLUMN f2 INTEGER; +connection node_1; SELECT 1 FROM DUAL; 1 1 diff --git a/mysql-test/suite/galera/r/galera_as_master.result b/mysql-test/suite/galera/r/galera_as_master.result index d87a744000c..92a1a0e7cb3 100644 --- a/mysql-test/suite/galera/r/galera_as_master.result +++ b/mysql-test/suite/galera/r/galera_as_master.result @@ -1,4 +1,6 @@ +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; START SLAVE; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); # Disable binary logging for current session @@ -10,6 +12,7 @@ CREATE TABLE test.t3 AS SELECT * from t1; SET SQL_LOG_BIN=ON; INSERT INTO t1 VALUES(3); CREATE TABLE test.t4 AS SELECT * from t1; +connection node_2; SELECT * FROM t1; f1 1 @@ -27,6 +30,7 @@ f1 1 2 3 +connection node_3; SHOW TABLES; Tables_in_test t1 @@ -41,8 +45,10 @@ f1 2 3 # Cleanup +connection node_1; DROP TABLE t1, t4; SET SQL_LOG_BIN=OFF; DROP TABLE t2, t3; +connection node_3; STOP SLAVE; RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_as_master_large.result b/mysql-test/suite/galera/r/galera_as_master_large.result index 4d5533899cf..dad74211af9 100644 --- a/mysql-test/suite/galera/r/galera_as_master_large.result +++ b/mysql-test/suite/galera/r/galera_as_master_large.result @@ -2,7 +2,9 @@ # MDEV-9044 : Getting binlog corruption on my Galera cluster (10.1.8) # making it impossible to async slave. # +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; START SLAVE; +connection node_1; SELECT @@GLOBAL.BINLOG_CACHE_SIZE; @@GLOBAL.BINLOG_CACHE_SIZE 8192 @@ -12,12 +14,14 @@ START TRANSACTION; INSERT INTO t1 VALUES(1, REPEAT('-', 10000)); COMMIT; INSERT INTO t2 VALUES(1); +connection node_2; SELECT c1, LENGTH(c2) FROM t1; c1 LENGTH(c2) 1 10000 SELECT * FROM t2; c1 1 +connection node_3; SELECT c1, LENGTH(c2) FROM t1; c1 LENGTH(c2) 1 10000 @@ -25,6 +29,8 @@ SELECT * FROM t2; c1 1 # Cleanup +connection node_1; DROP TABLE t1, t2; +connection node_3; STOP SLAVE; RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_as_slave.result b/mysql-test/suite/galera/r/galera_as_slave.result index 2d7d689aa36..9ccb5106234 100644 --- a/mysql-test/suite/galera/r/galera_as_slave.result +++ b/mysql-test/suite/galera/r/galera_as_slave.result @@ -1,15 +1,24 @@ +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; START SLAVE; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); +connection node_2; INSERT INTO t1 VALUES (2); +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 INSERT INTO t1 VALUES (3); +connection node_2; SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 1 +connection node_1; DROP TABLE t1; +connection node_2; STOP SLAVE; RESET SLAVE ALL; +connection node_1; RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid.result b/mysql-test/suite/galera/r/galera_as_slave_gtid.result index fbac7b1b6b5..0ef9d208bf4 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_gtid.result +++ b/mysql-test/suite/galera/r/galera_as_slave_gtid.result @@ -1,16 +1,24 @@ +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; START SLAVE; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); SELECT LENGTH(@@global.gtid_binlog_state) > 1; LENGTH(@@global.gtid_binlog_state) > 1 1 +connection node_2; gtid_binlog_state_equal 1 +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 gtid_binlog_state_equal 1 +connection node_1; DROP TABLE t1; +connection node_3; +connection node_2; STOP SLAVE; RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result index 8c07d87eec3..210492937b0 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result @@ -1,7 +1,10 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET AUTOCOMMIT=OFF; FLUSH TABLES t1 FOR EXPORT; +connection node_1; INSERT INTO t1 VALUES (2); +connection node_2; SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; COMMIT; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_ftwrl.result b/mysql-test/suite/galera/r/galera_bf_abort_ftwrl.result index e3819172510..ae1ca6d2157 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_ftwrl.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_ftwrl.result @@ -1,7 +1,10 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET AUTOCOMMIT=OFF; FLUSH TABLES WITH READ LOCK;; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; UNLOCK TABLES; wsrep_local_aborts_increment 1 diff --git a/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result b/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result index 2e44a773b23..ce3ac6ab2cb 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result @@ -1,11 +1,15 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_2a; SELECT GET_LOCK("foo", 1000); GET_LOCK("foo", 1000) 1 +connection node_2; SET AUTOCOMMIT=OFF; INSERT INTO t1 VALUES (1); SELECT GET_LOCK("foo", 1000);; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction wsrep_local_aborts_increment 1 diff --git a/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result b/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result index 7510e48ee83..81b5816ddbe 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_lock_table.result @@ -1,7 +1,10 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET AUTOCOMMIT=OFF; LOCK TABLE t1 WRITE; +connection node_1; INSERT INTO t1 VALUES (2); +connection node_2; UNLOCK TABLES; COMMIT; SELECT COUNT(*) = 1 FROM t1; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_sleep.result b/mysql-test/suite/galera/r/galera_bf_abort_sleep.result index 8e85a5feda2..f069198dff6 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_sleep.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_sleep.result @@ -1,8 +1,11 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET AUTOCOMMIT=OFF; INSERT INTO t1 VALUES (1); SELECT SLEEP(1000);; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction wsrep_local_aborts_increment 1 diff --git a/mysql-test/suite/galera/r/galera_binlog_cache_size.result b/mysql-test/suite/galera/r/galera_binlog_cache_size.result index 9726cf2a440..6aac74ab5f0 100644 --- a/mysql-test/suite/galera/r/galera_binlog_cache_size.result +++ b/mysql-test/suite/galera/r/galera_binlog_cache_size.result @@ -3,6 +3,7 @@ CREATE TABLE ten (f1 INTEGER); INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); SET GLOBAL binlog_cache_size=4096; SET GLOBAL max_binlog_cache_size=4096; +connection node_1a; SET AUTOCOMMIT=ON; START TRANSACTION; INSERT INTO t1 SELECT REPEAT('a', 767) FROM ten; diff --git a/mysql-test/suite/galera/r/galera_binlog_checksum.result b/mysql-test/suite/galera/r/galera_binlog_checksum.result index a6ab62350b1..b0ea2293119 100644 --- a/mysql-test/suite/galera/r/galera_binlog_checksum.result +++ b/mysql-test/suite/galera/r/galera_binlog_checksum.result @@ -1,9 +1,12 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; UPDATE t1 SET f1 = 2 WHERE f1 = 1; +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_binlog_event_max_size_min.result b/mysql-test/suite/galera/r/galera_binlog_event_max_size_min.result index 984a943fcbe..7b88af5d5af 100644 --- a/mysql-test/suite/galera/r/galera_binlog_event_max_size_min.result +++ b/mysql-test/suite/galera/r/galera_binlog_event_max_size_min.result @@ -1,5 +1,6 @@ CREATE TABLE t1 (f1 VARCHAR(1000)); INSERT INTO t1 VALUES (REPEAT('x', 1000)); +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = REPEAT('x', 1000); COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_concurrent_ctas.result b/mysql-test/suite/galera/r/galera_concurrent_ctas.result index 8b0a4c07ac2..8a3ac1ae0d3 100644 --- a/mysql-test/suite/galera/r/galera_concurrent_ctas.result +++ b/mysql-test/suite/galera/r/galera_concurrent_ctas.result @@ -1 +1,3 @@ +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_create_function.result b/mysql-test/suite/galera/r/galera_create_function.result index 8e4a823d00f..576ea44cce5 100644 --- a/mysql-test/suite/galera/r/galera_create_function.result +++ b/mysql-test/suite/galera/r/galera_create_function.result @@ -1,3 +1,4 @@ +connection node_1; CREATE USER 'user1'; CREATE DEFINER = 'user1' @@ -18,12 +19,14 @@ DETERMINISTIC NO SQL SQL SECURITY INVOKER RETURN 123; +connection node_1; SHOW CREATE FUNCTION f1; Function sql_mode Create Function character_set_client collation_connection Database Collation f1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` FUNCTION `f1`(param INTEGER) RETURNS varchar(200) CHARSET latin1 MODIFIES SQL DATA COMMENT 'f1_comment' RETURN 'abc' latin1 latin1_swedish_ci latin1_swedish_ci +connection node_2; SELECT 1 FROM DUAL; 1 1 @@ -33,6 +36,7 @@ f1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` FUNCTIO MODIFIES SQL DATA COMMENT 'f1_comment' RETURN 'abc' latin1 latin1_swedish_ci latin1_swedish_ci +connection node_1; SHOW CREATE FUNCTION f2; Function sql_mode Create Function character_set_client collation_connection Database Collation f2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f2`(param VARCHAR(100)) RETURNS int(11) @@ -40,6 +44,7 @@ f2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` DETERMINISTIC SQL SECURITY INVOKER RETURN 123 latin1 latin1_swedish_ci latin1_swedish_ci +connection node_2; SHOW CREATE FUNCTION f2; Function sql_mode Create Function character_set_client collation_connection Database Collation f2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f2`(param VARCHAR(100)) RETURNS int(11) @@ -53,6 +58,7 @@ f1(1) = 'abc' SELECT f2('abc') = 123; f2('abc') = 123 1 +connection node_1; DROP FUNCTION f1; DROP FUNCTION f2; DROP USER 'user1'; diff --git a/mysql-test/suite/galera/r/galera_create_procedure.result b/mysql-test/suite/galera/r/galera_create_procedure.result index 6191ef48ee5..90f29ffa617 100644 --- a/mysql-test/suite/galera/r/galera_create_procedure.result +++ b/mysql-test/suite/galera/r/galera_create_procedure.result @@ -1,3 +1,4 @@ +connection node_1; CREATE USER 'user1'; CREATE TABLE t1 (f1 INTEGER); CREATE @@ -16,12 +17,14 @@ PROCEDURE p2 (param VARCHAR(100)) DETERMINISTIC NO SQL SQL SECURITY INVOKER BEGIN END ; +connection node_1; SHOW CREATE PROCEDURE p1; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation p1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` PROCEDURE `p1`(IN param1 INTEGER, OUT param2 INTEGER, INOUT param3 INTEGER) MODIFIES SQL DATA COMMENT 'p1_comment' INSERT INTO t1 VALUES (1) latin1 latin1_swedish_ci latin1_swedish_ci +connection node_2; SELECT 1 FROM DUAL; 1 1 @@ -31,6 +34,7 @@ p1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` PROCEDU MODIFIES SQL DATA COMMENT 'p1_comment' INSERT INTO t1 VALUES (1) latin1 latin1_swedish_ci latin1_swedish_ci +connection node_1; SHOW CREATE PROCEDURE p2; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(param VARCHAR(100)) @@ -38,6 +42,7 @@ p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` DETERMINISTIC SQL SECURITY INVOKER BEGIN END latin1 latin1_swedish_ci latin1_swedish_ci +connection node_2; SHOW CREATE PROCEDURE p2; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(param VARCHAR(100)) @@ -47,6 +52,7 @@ p2 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` BEGIN END latin1 latin1_swedish_ci latin1_swedish_ci CALL p1(@a, @b, @c); CALL p2('abc'); +connection node_1; DROP PROCEDURE p1; DROP PROCEDURE p2; DROP USER 'user1'; diff --git a/mysql-test/suite/galera/r/galera_create_table_like.result b/mysql-test/suite/galera/r/galera_create_table_like.result index b335101fa62..131ac311bca 100644 --- a/mysql-test/suite/galera/r/galera_create_table_like.result +++ b/mysql-test/suite/galera/r/galera_create_table_like.result @@ -11,6 +11,7 @@ CREATE TABLE real_table3 LIKE schema1.myisam_table; CREATE TEMPORARY TABLE temp_table1 LIKE schema1.real_table; CREATE TEMPORARY TABLE temp_table2 LIKE schema1.temp_table; CREATE TEMPORARY TABLE temp_table3 LIKE schema1.myisam_table; +connection node_2; SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table' AND TABLE_SCHEMA = 'schema1'; COUNT(*) = 1 1 @@ -38,6 +39,7 @@ COUNT(*) = 0 SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table3' AND TABLE_SCHEMA = 'schema2'; COUNT(*) = 0 1 +connection node_1; DROP TABLE schema1.real_table; DROP TABLE schema1.myisam_table; DROP TABLE schema2.real_table1; diff --git a/mysql-test/suite/galera/r/galera_create_trigger.result b/mysql-test/suite/galera/r/galera_create_trigger.result index 7e656081871..d07a007543e 100644 --- a/mysql-test/suite/galera/r/galera_create_trigger.result +++ b/mysql-test/suite/galera/r/galera_create_trigger.result @@ -7,6 +7,7 @@ CREATE DEFINER=root@localhost TRIGGER definer_root BEFORE INSERT ON definer_root CREATE DEFINER=user1 TRIGGER definer_user BEFORE INSERT ON definer_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); CREATE DEFINER=current_user TRIGGER definer_current_user BEFORE INSERT ON definer_current_user FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); CREATE TRIGGER definer_default BEFORE INSERT ON definer_default FOR EACH ROW SET NEW.trigger_user = CURRENT_USER(); +connection node_2; INSERT INTO definer_root (f1) VALUES (1); SELECT DEFINER = 'root@localhost' FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME = 'definer_root'; DEFINER = 'root@localhost' @@ -35,6 +36,7 @@ DEFINER = 'root@localhost' SELECT trigger_user = 'root@localhost' FROM definer_default; trigger_user = 'root@localhost' 1 +connection node_1; DROP TABLE definer_current_user; DROP TABLE definer_user; DROP TABLE definer_root; diff --git a/mysql-test/suite/galera/r/galera_delete_limit.result b/mysql-test/suite/galera/r/galera_delete_limit.result index 72bee18eab6..f6fb2e56346 100644 --- a/mysql-test/suite/galera/r/galera_delete_limit.result +++ b/mysql-test/suite/galera/r/galera_delete_limit.result @@ -1,8 +1,11 @@ +connection node_1; CREATE TABLE ten (f1 INTEGER) Engine=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND(); +connection node_2; DELETE FROM t1 ORDER BY RAND() LIMIT 5; +connection node_1; sum_matches 1 max_matches @@ -10,7 +13,9 @@ max_matches DROP TABLE t1; CREATE TABLE t2 (f1 INTEGER) Engine=InnoDB; INSERT INTO t2 SELECT f1 FROM ten ORDER BY RAND(); +connection node_2; DELETE FROM t2 ORDER BY RAND() LIMIT 5; +connection node_1; sum_matches 1 max_matches diff --git a/mysql-test/suite/galera/r/galera_drop_multi.result b/mysql-test/suite/galera/r/galera_drop_multi.result index d82ae3bec1a..7793ef93b90 100644 --- a/mysql-test/suite/galera/r/galera_drop_multi.result +++ b/mysql-test/suite/galera/r/galera_drop_multi.result @@ -8,6 +8,7 @@ START TRANSACTION; DROP TABLE t1, t2, t3, t4; INSERT INTO t5 VALUES (1); COMMIT; +connection node_2; SHOW CREATE TABLE t1; ERROR 42S02: Table 'test.t1' doesn't exist SHOW CREATE TABLE t2; @@ -17,4 +18,5 @@ ERROR 42S02: Table 'test.t3' doesn't exist SHOW CREATE TABLE t4; ERROR 42S02: Table 'test.t4' doesn't exist CALL mtr.add_suppression("Slave SQL: Error 'Unknown table 'test.t2,test.t4'' on query\. Default database: 'test'\. Query: 'DROP TABLE t1, t2, t3, t4', Error_code: 1051"); +connection node_1; DROP TABLE t5; diff --git a/mysql-test/suite/galera/r/galera_enum.result b/mysql-test/suite/galera/r/galera_enum.result index e853c5c9943..e8ccb12b990 100644 --- a/mysql-test/suite/galera/r/galera_enum.result +++ b/mysql-test/suite/galera/r/galera_enum.result @@ -1,9 +1,11 @@ +connection node_1; CREATE TABLE t1 (f1 ENUM('', 'one', 'two'), KEY (f1)) ENGINE=InnoDB; INSERT INTO t1 VALUES (''); INSERT INTO t1 VALUES ('one'), ('two'); INSERT INTO t1 VALUES (0), (1), (2); Warnings: Warning 1265 Data truncated for column 'f1' at row 1 +connection node_2; SELECT COUNT(*) = 6 FROM t1; COUNT(*) = 6 1 @@ -14,23 +16,30 @@ SELECT COUNT(*) = 2 FROM t1 where f1 = 'one'; COUNT(*) = 2 1 DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 ENUM('', 'one', 'two', 'three', 'four') PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (''), ('one'), ('two'); +connection node_2; SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 1 SELECT COUNT(*) = 1 FROM t1 WHERE f1 = ''; COUNT(*) = 1 1 +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f1 = 'three' where f1 = ''; +connection node_2; SET AUTOCOMMIt=OFF; START TRANSACTION; UPDATE t1 SET f1 = 'four' where f1 = ''; +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_1; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 'three'; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_events.result b/mysql-test/suite/galera/r/galera_events.result index 09d8406d5d0..f01627aba70 100644 --- a/mysql-test/suite/galera/r/galera_events.result +++ b/mysql-test/suite/galera/r/galera_events.result @@ -1,18 +1,27 @@ +connection node_1; CREATE EVENT event1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT 1; +connection node_2; SELECT DEFINER= 'root@localhost', ORIGINATOR = 1, STATUS = 'SLAVESIDE_DISABLED', EVENT_TYPE = 'ONE TIME', ON_COMPLETION = 'NOT PRESERVE' FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1'; DEFINER= 'root@localhost' ORIGINATOR = 1 STATUS = 'SLAVESIDE_DISABLED' EVENT_TYPE = 'ONE TIME' ON_COMPLETION = 'NOT PRESERVE' 1 1 1 1 1 +connection node_1; ALTER EVENT event1 DISABLE; +connection node_2; SELECT DEFINER= 'root@localhost', ORIGINATOR = 1, STATUS = 'SLAVESIDE_DISABLED', EVENT_TYPE = 'ONE TIME', ON_COMPLETION = 'NOT PRESERVE' FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1'; DEFINER= 'root@localhost' ORIGINATOR = 1 STATUS = 'SLAVESIDE_DISABLED' EVENT_TYPE = 'ONE TIME' ON_COMPLETION = 'NOT PRESERVE' 1 1 1 1 1 +connection node_2; SET GLOBAL event_scheduler = ON; CREATE EVENT event2 ON SCHEDULE AT CURRENT_TIMESTAMP ON COMPLETION NOT PRESERVE DO SELECT 1; +connection node_1; SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event2'; COUNT(*) = 0 1 +connection node_1; DROP EVENT event1; +connection node_2; SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1'; COUNT(*) = 0 1 +connection node_2; SET GLOBAL event_scheduler = OFF;; diff --git a/mysql-test/suite/galera/r/galera_fk_cascade_delete.result b/mysql-test/suite/galera/r/galera_fk_cascade_delete.result index 89f4301a0b4..73375ae55c5 100644 --- a/mysql-test/suite/galera/r/galera_fk_cascade_delete.result +++ b/mysql-test/suite/galera/r/galera_fk_cascade_delete.result @@ -18,7 +18,9 @@ ON DELETE CASCADE INSERT INTO grandparent VALUES (1),(2); INSERT INTO parent VALUES (1,1), (2,2); INSERT INTO child VALUES (1,1), (2,2); +connection node_2; DELETE FROM grandparent WHERE id = 1; +connection node_1; SELECT COUNT(*) = 0 FROM parent WHERE grandparent_id = 1; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_fk_cascade_update.result b/mysql-test/suite/galera/r/galera_fk_cascade_update.result index 2ab2ad31a13..5fe8b532473 100644 --- a/mysql-test/suite/galera/r/galera_fk_cascade_update.result +++ b/mysql-test/suite/galera/r/galera_fk_cascade_update.result @@ -18,7 +18,9 @@ ON UPDATE CASCADE INSERT INTO grandparent VALUES (1),(2); INSERT INTO parent VALUES (1,1), (2,2); INSERT INTO child VALUES (1,1), (2,2); +connection node_2; UPDATE grandparent SET id = 3 WHERE id = 1; +connection node_1; SELECT COUNT(*) = 1 FROM parent WHERE grandparent_id = 3; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_fk_conflict.result b/mysql-test/suite/galera/r/galera_fk_conflict.result index ae6c4823a54..d9919c0348b 100644 --- a/mysql-test/suite/galera/r/galera_fk_conflict.result +++ b/mysql-test/suite/galera/r/galera_fk_conflict.result @@ -10,13 +10,17 @@ REFERENCES parent(id) ) ENGINE=InnoDB; INSERT INTO parent VALUES (1), (2); INSERT INTO child VALUES (1,1); +connection node_1; SET AUTOCOMMIT = OFF; START TRANSACTION; DELETE FROM parent WHERE id = 2; +connection node_2; SET AUTOCOMMIT = OFF; START TRANSACTION; INSERT INTO child VALUES (2, 2); +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction DROP TABLE child; diff --git a/mysql-test/suite/galera/r/galera_fk_mismatch.result b/mysql-test/suite/galera/r/galera_fk_mismatch.result index 07cdb1b09a2..bdc60c9e099 100644 --- a/mysql-test/suite/galera/r/galera_fk_mismatch.result +++ b/mysql-test/suite/galera/r/galera_fk_mismatch.result @@ -13,11 +13,14 @@ ON DELETE CASCADE ) ENGINE=InnoDB; INSERT INTO parent VALUES (1, 2); INSERT INTO child VALUES (1, 1); +connection node_2; UPDATE parent SET id1 = 3 WHERE id1 = 1; +connection node_1; SELECT COUNT(*) = 1 FROM child WHERE parent_id1 = 3; COUNT(*) = 1 1 DELETE FROM parent WHERE id1 = 3; +connection node_2; SELECT COUNT(*) = 0 FROM child WHERE parent_id1 = 3; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_fk_multicolumn.result b/mysql-test/suite/galera/r/galera_fk_multicolumn.result index a86b87a83ef..f5b6aa23692 100644 --- a/mysql-test/suite/galera/r/galera_fk_multicolumn.result +++ b/mysql-test/suite/galera/r/galera_fk_multicolumn.result @@ -17,7 +17,9 @@ ON UPDATE CASCADE INSERT INTO t0 VALUES (0, 0); INSERT INTO t1 VALUES (0); INSERT INTO t2 VALUES (0); +connection node_2; UPDATE t0 SET f1 = 1, f2 = 2; +connection node_1; SELECT f1 = 1 FROM t1 WHERE f1 = 1; f1 = 1 1 diff --git a/mysql-test/suite/galera/r/galera_fk_multitable.result b/mysql-test/suite/galera/r/galera_fk_multitable.result index e77128d3b04..04ff7adc3e9 100644 --- a/mysql-test/suite/galera/r/galera_fk_multitable.result +++ b/mysql-test/suite/galera/r/galera_fk_multitable.result @@ -11,7 +11,9 @@ ON DELETE CASCADE INSERT INTO t0 VALUES (0), (1); INSERT INTO t1 VALUES (0, 0); INSERT INTO t1 VALUES (1, 0); +connection node_2; DELETE t0.*, t1.* FROM t0, t1 WHERE t0.f0 = 0 AND t1.f1 = 0; +connection node_1; SELECT COUNT(*) = 1 FROM t0; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_fk_no_pk.result b/mysql-test/suite/galera/r/galera_fk_no_pk.result index e4f92863d92..e7b5f0b2b64 100644 --- a/mysql-test/suite/galera/r/galera_fk_no_pk.result +++ b/mysql-test/suite/galera/r/galera_fk_no_pk.result @@ -12,11 +12,14 @@ ON DELETE CASCADE ) ENGINE=InnoDB; INSERT INTO parent VALUES (1), (1), (2), (2); INSERT INTO child VALUES (1,1), (2,2), (1,1), (2,2); +connection node_2; DELETE FROM parent WHERE id = 1; SELECT COUNT(*) = 0 FROM child WHERE id = 1; COUNT(*) = 0 1 +connection node_1; UPDATE parent SET id = 3 WHERE id = 2; +connection node_2; SELECT COUNT(*) = 0 FROM child WHERE parent_id = 1; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_fk_selfreferential.result b/mysql-test/suite/galera/r/galera_fk_selfreferential.result index 25c37046e88..3b4dbf2a8e9 100644 --- a/mysql-test/suite/galera/r/galera_fk_selfreferential.result +++ b/mysql-test/suite/galera/r/galera_fk_selfreferential.result @@ -6,7 +6,9 @@ REFERENCES t1(f1) ON DELETE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES (1, 1), (2, 1); +connection node_2; DELETE FROM t1 WHERE f1 = 1; +connection node_1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_fk_setnull.result b/mysql-test/suite/galera/r/galera_fk_setnull.result index f7fb9d04040..d4f20fe60a3 100644 --- a/mysql-test/suite/galera/r/galera_fk_setnull.result +++ b/mysql-test/suite/galera/r/galera_fk_setnull.result @@ -12,10 +12,12 @@ ON DELETE SET NULL ) ENGINE=InnoDB; INSERT INTO parent VALUES (1),(2); INSERT INTO child VALUES (1,1),(2,2); +connection node_2; DELETE FROM parent WHERE id = 1; SELECT parent_id IS NULL FROM child WHERE id = 1; parent_id IS NULL 1 +connection node_1; SELECT parent_id IS NULL FROM child WHERE id = 1; parent_id IS NULL 1 @@ -23,8 +25,10 @@ UPDATE parent SET id = 3 WHERE id = 2; SELECT parent_id IS NULL FROM child WHERE id = 2; parent_id IS NULL 1 +connection node_2; SELECT parent_id IS NULL FROM child WHERE id = 2; parent_id IS NULL 1 +connection node_1; DROP TABLE child; DROP TABLE parent; diff --git a/mysql-test/suite/galera/r/galera_forced_binlog_format.result b/mysql-test/suite/galera/r/galera_forced_binlog_format.result index 92e78685b58..01f738f6109 100644 --- a/mysql-test/suite/galera/r/galera_forced_binlog_format.result +++ b/mysql-test/suite/galera/r/galera_forced_binlog_format.result @@ -1,3 +1,4 @@ +connection node_1; RESET MASTER; SET SESSION binlog_format = 'STATEMENT'; Warnings: @@ -40,4 +41,6 @@ GRANT ALL PRIVILEGES ON `testdb_9401`.`t1` TO 'dummy'@'localhost' REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost; DROP USER dummy@localhost; DROP DATABASE testdb_9401; +disconnect node_2; +disconnect node_1; # End of tests diff --git a/mysql-test/suite/galera/r/galera_ftwrl.result b/mysql-test/suite/galera/r/galera_ftwrl.result index c216b52650b..0565781c051 100644 --- a/mysql-test/suite/galera/r/galera_ftwrl.result +++ b/mysql-test/suite/galera/r/galera_ftwrl.result @@ -1,7 +1,10 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; FLUSH TABLES WITH READ LOCK; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; SHOW TABLES; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SELECT * FROM t1; diff --git a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result index ad60ead4b8a..a1ba8672eae 100644 --- a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result +++ b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result @@ -1,16 +1,22 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; FLUSH TABLES WITH READ LOCK; +connection node_1; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (5); +connection node_1a; +connection node_2; UNLOCK TABLES; +connection node_1; INSERT INTO t1 VALUES (6); +connection node_2; SELECT COUNT(*) = 6 FROM t1; COUNT(*) = 6 1 diff --git a/mysql-test/suite/galera/r/galera_gtid.result b/mysql-test/suite/galera/r/galera_gtid.result index 546c29cb49a..acc5eae9876 100644 --- a/mysql-test/suite/galera/r/galera_gtid.result +++ b/mysql-test/suite/galera/r/galera_gtid.result @@ -1,9 +1,11 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY); INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 UPDATE t1 SET f1 = 2; +connection node_1; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_insert_ignore.result b/mysql-test/suite/galera/r/galera_insert_ignore.result index b53b5795416..d21fb2b02d0 100644 --- a/mysql-test/suite/galera/r/galera_insert_ignore.result +++ b/mysql-test/suite/galera/r/galera_insert_ignore.result @@ -1,5 +1,7 @@ SET GLOBAL wsrep_sync_wait = 7; +connection node_2; SET GLOBAL wsrep_sync_wait = 7; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1), (2); @@ -9,10 +11,12 @@ SELECT * FROM t1; f1 1 2 +connection node_2; SELECT * FROM t1; f1 1 2 +connection node_2; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t2 VALUES (0), (2), (3); INSERT IGNORE INTO t1 SELECT f1 FROM t2; @@ -24,14 +28,17 @@ f1 1 2 3 +connection node_1; SELECT * FROM t1; f1 0 1 2 3 +connection node_2; CREATE TABLE t3 (f1 INTEGER UNIQUE) Engine=InnoDB; INSERT INTO t3 VALUES (NULL); +connection node_1; INSERT IGNORE INTO t3 VALUES (1), (NULL), (2); SELECT * FROM t3; f1 @@ -39,6 +46,7 @@ NULL NULL 1 2 +connection node_2; SELECT * FROM t3; f1 NULL @@ -46,6 +54,7 @@ NULL 1 2 SET GLOBAL wsrep_sync_wait = (SELECT @@wsrep_sync_wait); +connection node_1; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; diff --git a/mysql-test/suite/galera/r/galera_insert_multi.result b/mysql-test/suite/galera/r/galera_insert_multi.result index 33717781f2c..38bb5c26d20 100644 --- a/mysql-test/suite/galera/r/galera_insert_multi.result +++ b/mysql-test/suite/galera/r/galera_insert_multi.result @@ -1,57 +1,76 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1),(2); +connection node_2; INSERT INTO t1 VALUES (3),(4); +connection node_1; SELECT COUNT(*) = 4 FROM t1; COUNT(*) = 4 1 +connection node_2; SELECT COUNT(*) = 4 FROM t1; COUNT(*) = 4 1 DROP TABLE t1; +connection node_2; CREATE TABLE t1 (f1 INTEGER, KEY (f1)) ENGINE=InnoDB; INSERT INTO t1 VALUES (1),(1); +connection node_1; INSERT INTO t1 VALUES (2),(2); +connection node_2; SELECT COUNT(*) = 4 FROM t1; COUNT(*) = 4 1 +connection node_1; SELECT COUNT(*) = 4 FROM t1; COUNT(*) = 4 1 DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (1); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; SET AUTOCOMMIT = OFF; START TRANSACTION; INSERT INTO t1 VALUES (1), (2); +connection node_2; SET AUTOCOMMIT = OFF; START TRANSACTION; INSERT INTO t1 VALUES (2), (1); +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ROLLBACK; INSERT INTO t1 VALUES (1), (2); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; START TRANSACTION; INSERT INTO t1 VALUES (1), (2); +connection node_2; START TRANSACTION; INSERT INTO t1 VALUES (2), (1); +connection node_1; ROLLBACK; +connection node_2; COMMIT; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 +connection node_1; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 diff --git a/mysql-test/suite/galera/r/galera_ist_mysqldump.result b/mysql-test/suite/galera/r/galera_ist_mysqldump.result index 9a5b4e8a76f..788d60051b5 100644 --- a/mysql-test/suite/galera/r/galera_ist_mysqldump.result +++ b/mysql-test/suite/galera/r/galera_ist_mysqldump.result @@ -1,4 +1,5 @@ Setting SST method to mysqldump ... +CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; SET GLOBAL wsrep_sst_method = 'mysqldump'; diff --git a/mysql-test/suite/galera/r/galera_kill_applier.result b/mysql-test/suite/galera/r/galera_kill_applier.result index fe4911639ed..6fa632c242f 100644 --- a/mysql-test/suite/galera/r/galera_kill_applier.result +++ b/mysql-test/suite/galera/r/galera_kill_applier.result @@ -1,3 +1,4 @@ +connection node_1; Got one of the listed errors Got one of the listed errors Got one of the listed errors diff --git a/mysql-test/suite/galera/r/galera_kill_ddl.result b/mysql-test/suite/galera/r/galera_kill_ddl.result index 8dd36497dfb..c5b3e31b80e 100644 --- a/mysql-test/suite/galera/r/galera_kill_ddl.result +++ b/mysql-test/suite/galera/r/galera_kill_ddl.result @@ -1,11 +1,17 @@ +connection node_1; SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +connection node_2; Killing server ... +connection node_1; ALTER TABLE t1 ADD COLUMN f2 INTEGER; +connection node_2; +connection node_2a; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1'; COUNT(*) = 2 1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_kill_smallchanges.result b/mysql-test/suite/galera/r/galera_kill_smallchanges.result index 8409740a035..bcd7d6fd15d 100644 --- a/mysql-test/suite/galera/r/galera_kill_smallchanges.result +++ b/mysql-test/suite/galera/r/galera_kill_smallchanges.result @@ -1,11 +1,17 @@ +connection node_1; SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +connection node_2; Killing server ... +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; +connection node_2a; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_lock_table.result b/mysql-test/suite/galera/r/galera_lock_table.result index 16e9037a4de..c15f61d298e 100644 --- a/mysql-test/suite/galera/r/galera_lock_table.result +++ b/mysql-test/suite/galera/r/galera_lock_table.result @@ -1,8 +1,11 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; LOCK TABLE t1 READ; +connection node_1; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); +connection node_2a; SET SESSION wsrep_sync_wait=0; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 @@ -10,6 +13,7 @@ COUNT(*) = 0 SELECT COUNT(*) = 0 FROM t2; COUNT(*) = 0 1 +connection node_2; UNLOCK TABLES; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 diff --git a/mysql-test/suite/galera/r/galera_log_bin.result b/mysql-test/suite/galera/r/galera_log_bin.result index 4772f347375..576a72eb55f 100644 --- a/mysql-test/suite/galera/r/galera_log_bin.result +++ b/mysql-test/suite/galera/r/galera_log_bin.result @@ -3,12 +3,14 @@ INSERT INTO t1 VALUES (1); CREATE TABLE t2 (id INT) ENGINE=InnoDB; INSERT INTO t2 VALUES (1); INSERT INTO t2 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SELECT COUNT(*) = 2 FROM t2; COUNT(*) = 2 1 +connection node_1; ALTER TABLE t1 ADD COLUMN f2 INTEGER; FLUSH LOGS; SHOW BINLOG EVENTS IN 'mysqld-bin.000002' LIMIT 4,18; @@ -31,6 +33,7 @@ mysqld-bin.000002 # Write_rows_v1 # # table_id: # flags: STMT_END_F mysqld-bin.000002 # Xid # # COMMIT /* xid=# */ mysqld-bin.000002 # Gtid # # GTID 0-1-6 mysqld-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER +connection node_2; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 2 1 @@ -56,4 +59,5 @@ mysqld-bin.000003 # Gtid # # GTID 0-1-6 mysqld-bin.000003 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER DROP TABLE t1; DROP TABLE t2; +connection node_1; RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_many_indexes.result b/mysql-test/suite/galera/r/galera_many_indexes.result index ab6eec550a1..59d0194687f 100644 --- a/mysql-test/suite/galera/r/galera_many_indexes.result +++ b/mysql-test/suite/galera/r/galera_many_indexes.result @@ -63,6 +63,7 @@ CREATE UNIQUE INDEX i3 ON t1(f1); CREATE UNIQUE INDEX i2 ON t1(f1); CREATE UNIQUE INDEX i1 ON t1(f1); INSERT INTO t1 VALUES (REPEAT('a', 767)); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 @@ -91,6 +92,7 @@ INSERT INTO t1 VALUES (REPEAT('b', 767)); ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK +connection node_1; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 @@ -98,6 +100,7 @@ ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK DELETE FROM t1 WHERE f1 = REPEAT('b', 767); +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; SELECT COUNT(*) = 1 FROM t1; @@ -108,16 +111,23 @@ ROLLBACK; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_2; START TRANSACTION; SET AUTOCOMMIT=OFF; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; START TRANSACTION; +connection node_2; START TRANSACTION; +connection node_1; UPDATE t1 SET f1 = REPEAT('e', 767); +connection node_2; UPDATE t1 SET f1 = REPEAT('f', 767); +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_mdl_race.result b/mysql-test/suite/galera/r/galera_mdl_race.result index 535f20de7f1..0c83ead931e 100644 --- a/mysql-test/suite/galera/r/galera_mdl_race.result +++ b/mysql-test/suite/galera/r/galera_mdl_race.result @@ -2,24 +2,32 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); INSERT INTO t1 VALUES (1, 'a'); INSERT INTO t1 VALUES (2, 'a'); +connection node_1; SET AUTOCOMMIT=ON; START TRANSACTION; UPDATE t1 SET f2 = 'b' WHERE f1 = 1; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; LOCK TABLE t2 WRITE; +connection node_1; SET GLOBAL DEBUG = "d,sync.wsrep_before_mdl_wait"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SELECT * FROM t2;; +connection node_1a; SET GLOBAL DEBUG = "d,sync.wsrep_after_BF_victim_lock"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +connection node_2; UPDATE t1 SET f2 = 'c' WHERE f1 = 1; +connection node_1a; SET GLOBAL DEBUG = ""; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; UNLOCK TABLES; +connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; COUNT(*) = 1 @@ -27,6 +35,7 @@ COUNT(*) = 1 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; COUNT(*) = 1 1 +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; COUNT(*) = 1 1 @@ -35,4 +44,5 @@ COUNT(*) = 1 1 DROP TABLE t1; DROP TABLE t2; +connection node_1a; SET DEBUG_SYNC = "RESET"; diff --git a/mysql-test/suite/galera/r/galera_multi_database.result b/mysql-test/suite/galera/r/galera_multi_database.result index a04eb484caf..f6242de663b 100644 --- a/mysql-test/suite/galera/r/galera_multi_database.result +++ b/mysql-test/suite/galera/r/galera_multi_database.result @@ -2,13 +2,17 @@ CREATE DATABASE d1; CREATE TABLE d1.t1(f1 INTEGER) ENGINE=InnoDB; CREATE DATABASE d2; CREATE TABLE d2.t1(f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO d1.t1 VALUES (1); +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO d2.t1 VALUES (1); +connection node_1; COMMIT; +connection node_2; COMMIT; SELECT COUNT(*) = 1 FROM d1.t1; COUNT(*) = 1 @@ -16,6 +20,7 @@ COUNT(*) = 1 SELECT COUNT(*) = 1 FROM d2.t1; COUNT(*) = 1 1 +connection node_1; SELECT COUNT(*) = 1 FROM d1.t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_myisam_autocommit.result b/mysql-test/suite/galera/r/galera_myisam_autocommit.result index 3f8d93bae76..e9578a261e6 100644 --- a/mysql-test/suite/galera/r/galera_myisam_autocommit.result +++ b/mysql-test/suite/galera/r/galera_myisam_autocommit.result @@ -14,6 +14,7 @@ DELETE FROM t1 WHERE f1 = 9; DELETE FROM t2 WHERE f1 = 9; TRUNCATE TABLE t1; TRUNCATE TABLE t1; +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_myisam_transactions.result b/mysql-test/suite/galera/r/galera_myisam_transactions.result index 284f92b414c..25796c309d1 100644 --- a/mysql-test/suite/galera/r/galera_myisam_transactions.result +++ b/mysql-test/suite/galera/r/galera_myisam_transactions.result @@ -7,6 +7,7 @@ START TRANSACTION; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); COMMIT; +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 @@ -16,12 +17,14 @@ COUNT(*) = 0 SELECT COUNT(*) = 0 FROM t2; COUNT(*) = 0 1 +connection node_1; START TRANSACTION; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); ROLLBACK; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_nopk_bit.result b/mysql-test/suite/galera/r/galera_nopk_bit.result index 5723dac42fd..7662c15c672 100644 --- a/mysql-test/suite/galera/r/galera_nopk_bit.result +++ b/mysql-test/suite/galera/r/galera_nopk_bit.result @@ -1,5 +1,6 @@ CREATE TABLE t1 (f1 BIT) ENGINE=InnoDB; INSERT INTO t1 VALUES (NULL),(0),(b'1'); +connection node_2; SELECT f1 IS NULL, f1 = b'1' FROM t1; f1 IS NULL f1 = b'1' 1 NULL @@ -8,19 +9,24 @@ f1 IS NULL f1 = b'1' DELETE FROM t1 WHERE f1 = b'1'; UPDATE t1 SET f1 = b'1' WHERE f1 IS NULL; UPDATE t1 SET f1 = 1 WHERE f1 = b'0'; +connection node_1; SELECT f1 IS NULL, f1 = b'1' FROM t1; f1 IS NULL f1 = b'1' 0 1 0 1 +connection node_1; CREATE TABLE t2 (f1 BIT) ENGINE=InnoDB; INSERT INTO t2 VALUES (NULL); SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t2 SET f1 = 0 WHERE f1 IS NULL; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t2 SET f1 = 1 WHERE f1 IS NULL; +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_nopk_blob.result b/mysql-test/suite/galera/r/galera_nopk_blob.result index 7491b715ed2..a7570c2cfee 100644 --- a/mysql-test/suite/galera/r/galera_nopk_blob.result +++ b/mysql-test/suite/galera/r/galera_nopk_blob.result @@ -1,26 +1,32 @@ CREATE TABLE t1 (f1 BLOB) ENGINE=InnoDB; INSERT INTO t1 VALUES (NULL),('abc'); +connection node_2; SELECT f1 FROM t1; f1 NULL abc DELETE FROM t1 WHERE f1 IS NULL; UPDATE t1 SET f1 = 'xyz' WHERE f1 = 'abc'; +connection node_1; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SELECT f1 = 'abc' FROM t1; f1 = 'abc' 0 +connection node_1; CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB; INSERT INTO t2 VALUES (NULL); SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t2 SET f1 = 'abc' WHERE f1 IS NULL; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t2 SET f1 = 'xyz' WHERE f1 IS NULL; +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_nopk_large_varchar.result b/mysql-test/suite/galera/r/galera_nopk_large_varchar.result index abca81e15b0..08cffaa2bd1 100644 --- a/mysql-test/suite/galera/r/galera_nopk_large_varchar.result +++ b/mysql-test/suite/galera/r/galera_nopk_large_varchar.result @@ -1,11 +1,13 @@ CREATE TABLE t1 (f1 VARCHAR(8000)) ENGINE=InnoDB; INSERT INTO t1 VALUES (NULL),(CONCAT(REPEAT('x', 7999), 'a')); +connection node_2; SELECT LENGTH(f1) FROM t1; LENGTH(f1) NULL 8000 DELETE FROM t1 WHERE f1 IS NULL; UPDATE t1 SET f1 = CONCAT(REPEAT('x', 7999), 'b') WHERE f1 = CONCAT(REPEAT('x', 7999), 'a'); +connection node_1; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 @@ -15,15 +17,19 @@ LENGTH(f1) = 8000 SELECT f1 = CONCAT(REPEAT('x', 7999), 'b') FROM t1; f1 = CONCAT(REPEAT('x', 7999), 'b') 1 +connection node_1; CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB; INSERT INTO t2 VALUES (CONCAT(REPEAT('x', 7999), 'a')); SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t2 SET f1 = 'abc' WHERE f1 = CONCAT(REPEAT('x', 7999), 'a'); +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t2 SET f1 = 'xyz' WHERE f1 = CONCAT(REPEAT('x', 7999), 'a'); +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_nopk_unicode.result b/mysql-test/suite/galera/r/galera_nopk_unicode.result index 68d049a2146..882a91a29b5 100644 --- a/mysql-test/suite/galera/r/galera_nopk_unicode.result +++ b/mysql-test/suite/galera/r/galera_nopk_unicode.result @@ -3,16 +3,21 @@ f1 VARCHAR(255), KEY (f1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO t1 VALUES ('текÑÑ‚'); +connection node_2; SELECT f1 = 'текÑÑ‚' FROM t1; f1 = 'текÑÑ‚' 1 +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f1 = 'текÑÑ‚2'; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f1 = 'текÑÑ‚3'; +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SELECT f1 = 'текÑÑ‚2' FROM t1; diff --git a/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result b/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result index db4528ac22d..bf4b056a6e4 100644 --- a/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result +++ b/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result @@ -1,9 +1,12 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET GLOBAL wsrep_slave_threads = 2; LOCK TABLE t1 READ; +connection node_1; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); +connection node_2a; SET SESSION wsrep_sync_wait=0; SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%applied write set%'; COUNT(*) = 1 @@ -17,7 +20,9 @@ COUNT(*) = 0 SELECT COUNT(*) = 0 FROM t2; COUNT(*) = 0 1 +connection node_2; UNLOCK TABLES; +connection node_2a; SET SESSION wsrep_sync_wait = 7;; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 diff --git a/mysql-test/suite/galera/r/galera_pc_ignore_sb.result b/mysql-test/suite/galera/r/galera_pc_ignore_sb.result index 5fcccfe2d59..e02ec0a3179 100644 --- a/mysql-test/suite/galera/r/galera_pc_ignore_sb.result +++ b/mysql-test/suite/galera/r/galera_pc_ignore_sb.result @@ -1,5 +1,10 @@ +connection node_1; +connection node_2; +connection node_1; SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; +connection node_2; Killing server ... +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); DROP TABLE t1; @@ -10,3 +15,4 @@ SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABL VARIABLE_VALUE = 'ON' 1 SET GLOBAL wsrep_cluster_address = ''; +connection node_2; diff --git a/mysql-test/suite/galera/r/galera_pk_bigint_signed.result b/mysql-test/suite/galera/r/galera_pk_bigint_signed.result index a3075994657..27bb3c50733 100644 --- a/mysql-test/suite/galera/r/galera_pk_bigint_signed.result +++ b/mysql-test/suite/galera/r/galera_pk_bigint_signed.result @@ -3,23 +3,29 @@ INSERT INTO t1 VALUES (-9223372036854775808, 'min'), (9223372036854775807, 'max') ; +connection node_2; SELECT * FROM t1; f1 f2 -9223372036854775808 min 9223372036854775807 max UPDATE t1 SET f2 = CONCAT(f2, '_'); +connection node_1; SELECT * FROM t1; f1 f2 -9223372036854775808 min_ 9223372036854775807 max_ +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f2 = 'foo' WHERE f1 = -9223372036854775808; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f2 = 'bar' WHERE f1 = -9223372036854775808; +connection node_1; COMMIT; SET AUTOCOMMIT=ON; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SET AUTOCOMMIT=ON; diff --git a/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result b/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result index 441926e949c..f586fe2f589 100644 --- a/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result +++ b/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result @@ -2,21 +2,27 @@ CREATE TABLE t1 (f1 BIGINT UNSIGNED PRIMARY KEY, f2 VARCHAR(5)) ENGINE=InnoDB; INSERT INTO t1 VALUES (18446744073709551615, 'max') ; +connection node_2; SELECT f1 = 18446744073709551615 FROM t1; f1 = 18446744073709551615 1 UPDATE t1 SET f2 = CONCAT(f2, '_'); +connection node_1; SELECT f1 = 18446744073709551615 FROM t1; f1 = 18446744073709551615 1 +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f2 = 'foo' WHERE f1 = 18446744073709551615; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f2 = 'bar' WHERE f1 = 18446744073709551615; +connection node_1; COMMIT; SET AUTOCOMMIT=ON; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SET AUTOCOMMIT=ON; diff --git a/mysql-test/suite/galera/r/galera_prepared_statement.result b/mysql-test/suite/galera/r/galera_prepared_statement.result index de5ac9c760a..d32d412ff46 100644 --- a/mysql-test/suite/galera/r/galera_prepared_statement.result +++ b/mysql-test/suite/galera/r/galera_prepared_statement.result @@ -11,6 +11,7 @@ EXECUTE st1; EXECUTE st2; EXECUTE st3; EXECUTE st4; +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 @@ -25,8 +26,10 @@ COUNT(*) = 1 1 ALTER TABLE t1 ADD COLUMN f2 INTEGER; ALTER TABLE t1 DROP COLUMN f1; +connection node_1; EXECUTE st1; ERROR 22007: Incorrect integer value: 'abc' for column 'f2' at row 1 +connection node_1; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; diff --git a/mysql-test/suite/galera/r/galera_query_cache.result b/mysql-test/suite/galera/r/galera_query_cache.result index 502d8a58e9c..e64c9438646 100644 --- a/mysql-test/suite/galera/r/galera_query_cache.result +++ b/mysql-test/suite/galera/r/galera_query_cache.result @@ -1,5 +1,6 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; RESET QUERY CACHE; FLUSH STATUS; SELECT COUNT(*) FROM t1; @@ -14,7 +15,9 @@ COUNT(*) SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; VARIABLE_VALUE = 1 1 +connection node_1; INSERT INTO t1 VALUES (2); +connection node_2; FLUSH STATUS; SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; VARIABLE_VALUE = 0 @@ -34,7 +37,9 @@ COUNT(*) SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; VARIABLE_VALUE = 1 1 +connection node_1; ALTER TABLE t1 ADD COLUMN f2 INTEGER; +connection node_2; FLUSH STATUS; SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; VARIABLE_VALUE = 0 diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result index 856abbb43be..2a37d62698a 100644 --- a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result @@ -1,5 +1,6 @@ CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: @@ -8,7 +9,9 @@ SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) 1 +connection node_1; INSERT INTO t1 VALUES (2); +connection node_2; SELECT MAX(id) FROM t1; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SET GLOBAL DEBUG = ""; @@ -21,14 +24,18 @@ SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "RESET"; +connection node_1; INSERT INTO t1 VALUES (3); +connection node_2; SELECT MAX(id) FROM t1; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SET GLOBAL DEBUG = ""; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +connection node_1; INSERT INTO t1 VALUES (4); +connection node_2; SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) @@ -44,13 +51,18 @@ VARIABLE_VALUE = 1 SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +connection node_1; INSERT INTO t1 VALUES (5); +connection node_2; SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1 ; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2a; SET GLOBAL DEBUG = ""; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +connection node_2; MAX(id) 5 SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; diff --git a/mysql-test/suite/galera/r/galera_read_only.result b/mysql-test/suite/galera/r/galera_read_only.result index 82736c5f4ba..4c2523f8691 100644 --- a/mysql-test/suite/galera/r/galera_read_only.result +++ b/mysql-test/suite/galera/r/galera_read_only.result @@ -1,15 +1,21 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; SET GLOBAL read_only=TRUE; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 CREATE USER foo@localhost; # Open connection to node 2 using 'foo' user. +connect foo_node_2,127.0.0.1,foo,,test,$port_2,; # Connect with foo_node_2 +connection foo_node_2; INSERT INTO t1 VALUES (2); ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_repl_key_format_flat16.result b/mysql-test/suite/galera/r/galera_repl_key_format_flat16.result index 4acf0143f8b..2470f59c497 100644 --- a/mysql-test/suite/galera/r/galera_repl_key_format_flat16.result +++ b/mysql-test/suite/galera/r/galera_repl_key_format_flat16.result @@ -1,13 +1,16 @@ +connection node_1; SET GLOBAL wsrep_provider_options = 'repl.key_format=FLAT16'; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (123); CREATE TABLE t2 (f1 VARCHAR(256)) ENGINE=InnoDB; INSERT INTO t2 VALUES (REPEAT('a', 256)); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 UPDATE t1 SET f1 = 234; UPDATE t2 SET f1 = REPEAT('b', 256); +connection node_1; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 234; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_repl_max_ws_size.result b/mysql-test/suite/galera/r/galera_repl_max_ws_size.result index 6e245b44462..00980181824 100644 --- a/mysql-test/suite/galera/r/galera_repl_max_ws_size.result +++ b/mysql-test/suite/galera/r/galera_repl_max_ws_size.result @@ -1,3 +1,4 @@ +connection node_1; CREATE TABLE t1 (f1 VARCHAR(512)) ENGINE=InnoDB; SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=512'; INSERT INTO t1 VALUES (REPEAT('a', 512)); diff --git a/mysql-test/suite/galera/r/galera_restart_nochanges.result b/mysql-test/suite/galera/r/galera_restart_nochanges.result index accace97826..380a4812da1 100644 --- a/mysql-test/suite/galera/r/galera_restart_nochanges.result +++ b/mysql-test/suite/galera/r/galera_restart_nochanges.result @@ -1,5 +1,10 @@ +connection node_1; +connection node_2; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; +connection node_2a; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_roles.result b/mysql-test/suite/galera/r/galera_roles.result index c0cdbc0e338..1617f0d7b51 100644 --- a/mysql-test/suite/galera/r/galera_roles.result +++ b/mysql-test/suite/galera/r/galera_roles.result @@ -3,6 +3,7 @@ # # On node_1 +connection node_1; CREATE DATABASE test1; CREATE TABLE test1.t1 (a int, b int); CREATE TABLE test1.t2 (a int, b int); @@ -18,8 +19,11 @@ GRANT EXECUTE ON PROCEDURE test1.pr1 TO role1; GRANT SELECT ON test1.t1 TO role1; GRANT SELECT (a) ON test1.t2 TO role1; # Open connections to the 2 nodes using 'foo' user. +connect foo_node_1,127.0.0.1,foo,,test,$port_1,; +connect foo_node_2,127.0.0.1,foo,,test,$port_2,; # Connect with foo_node_1 +connection foo_node_1; SHOW GRANTS; Grants for foo@localhost GRANT role1 TO 'foo'@'localhost' @@ -55,6 +59,7 @@ pr1 pr1 # Connect with foo_node_2 +connection foo_node_2; SHOW GRANTS; Grants for foo@localhost GRANT role1 TO 'foo'@'localhost' @@ -93,13 +98,16 @@ pr1 # # # Connect with node_1 +connection node_1; REVOKE EXECUTE ON PROCEDURE test1.pr1 FROM role1; # Connect with foo_node_1 +connection foo_node_1; CALL test1.pr1(); ERROR 42000: execute command denied to user 'foo'@'localhost' for routine 'test1.pr1' # Connect with foo_node_2 +connection foo_node_2; CALL test1.pr1(); ERROR 42000: execute command denied to user 'foo'@'localhost' for routine 'test1.pr1' # @@ -107,9 +115,11 @@ ERROR 42000: execute command denied to user 'foo'@'localhost' for routine 'test1 # # Connect with node_1 +connection node_1; DROP ROLE role1; # Connect with foo_node_1 +connection foo_node_1; FLUSH TABLES; SELECT * FROM mysql.roles_mapping; ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 'roles_mapping' @@ -131,6 +141,7 @@ CURRENT_ROLE() role1 # Connect with foo_node_2 +connection foo_node_2; FLUSH TABLES; SELECT * FROM mysql.roles_mapping; ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 'roles_mapping' @@ -150,7 +161,11 @@ NULL SELECT CURRENT_ROLE(); CURRENT_ROLE() role1 +disconnect foo_node_2; # Connect with node_1 +connection node_1; DROP USER foo@localhost; DROP DATABASE test1; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_rsu_error.result b/mysql-test/suite/galera/r/galera_rsu_error.result index bfe41390d1d..5c16e34b492 100644 --- a/mysql-test/suite/galera/r/galera_rsu_error.result +++ b/mysql-test/suite/galera/r/galera_rsu_error.result @@ -1,5 +1,6 @@ CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; INSERT INTO t1 VALUES (1), (1); +connection node_2; SET SESSION wsrep_OSU_method = "RSU"; ALTER TABLE t1 ADD PRIMARY KEY (f1); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' @@ -8,6 +9,7 @@ SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = COUNT(*) = 0 1 INSERT INTO t1 VALUES (1); +connection node_1; SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 't1'; COUNT(*) = 0 1 @@ -15,6 +17,7 @@ SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 1 INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(3) = 4 FROM t1; COUNT(3) = 4 1 diff --git a/mysql-test/suite/galera/r/galera_rsu_simple.result b/mysql-test/suite/galera/r/galera_rsu_simple.result index 4c2780a2933..d0ddcfb4d64 100644 --- a/mysql-test/suite/galera/r/galera_rsu_simple.result +++ b/mysql-test/suite/galera/r/galera_rsu_simple.result @@ -1,17 +1,21 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +connection node_2; SET SESSION wsrep_OSU_method = "RSU"; ALTER TABLE t1 ADD COLUMN f2 INTEGER; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 2 1 +connection node_1; SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 1 1 INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 INSERT INTO t1 (f1) VALUES (2); +connection node_1; SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result index 62e327ffdee..2b2b80ee91c 100644 --- a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result +++ b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result @@ -1,10 +1,14 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; SET GLOBAL wsrep_desync=1; SET wsrep_OSU_method=RSU; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; SET GLOBAL wsrep_desync=0; SET DEBUG_SYNC= 'now SIGNAL continue'; +connection node_1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -17,6 +21,7 @@ wsrep_desync OFF SET wsrep_OSU_method=TOI; DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; +connection node_1; CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; SET GLOBAL wsrep_desync=0; Warnings: @@ -24,10 +29,12 @@ Warning 1231 'wsrep_desync' is already OFF. SET wsrep_OSU_method=RSU; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +connection node_1a; SET GLOBAL wsrep_desync=1; ERROR HY000: Operation 'desync' failed for SET GLOBAL wsrep_desync=1 SET GLOBAL wsrep_desync=0; SET DEBUG_SYNC= 'now SIGNAL continue'; +connection node_1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -39,4 +46,5 @@ DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; CALL mtr.add_suppression("Protocol violation"); CALL mtr.add_suppression("desync failed"); +connection node_2; CALL mtr.add_suppression("Protocol violation"); diff --git a/mysql-test/suite/galera/r/galera_sbr.result b/mysql-test/suite/galera/r/galera_sbr.result index 0bf6cc7c9d3..61a58c9cb89 100644 --- a/mysql-test/suite/galera/r/galera_sbr.result +++ b/mysql-test/suite/galera/r/galera_sbr.result @@ -1,3 +1,4 @@ +connection node_1; SET SESSION binlog_format = 'STATEMENT'; Warnings: Warning 1105 MariaDB Galera does not support binlog format: STATEMENT @@ -7,8 +8,10 @@ SET SESSION binlog_format = 'MIXED'; Warnings: Warning 1105 MariaDB Galera does not support binlog format: MIXED INSERT INTO t1 VALUES (2); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 DROP TABLE t1; +connection node_1; SET GLOBAL binlog_format = 'ROW'; diff --git a/mysql-test/suite/galera/r/galera_sbr_binlog.result b/mysql-test/suite/galera/r/galera_sbr_binlog.result index 0bf6cc7c9d3..61a58c9cb89 100644 --- a/mysql-test/suite/galera/r/galera_sbr_binlog.result +++ b/mysql-test/suite/galera/r/galera_sbr_binlog.result @@ -1,3 +1,4 @@ +connection node_1; SET SESSION binlog_format = 'STATEMENT'; Warnings: Warning 1105 MariaDB Galera does not support binlog format: STATEMENT @@ -7,8 +8,10 @@ SET SESSION binlog_format = 'MIXED'; Warnings: Warning 1105 MariaDB Galera does not support binlog format: MIXED INSERT INTO t1 VALUES (2); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 DROP TABLE t1; +connection node_1; SET GLOBAL binlog_format = 'ROW'; diff --git a/mysql-test/suite/galera/r/galera_serializable.result b/mysql-test/suite/galera/r/galera_serializable.result index 90fe628e505..e81c3911b7d 100644 --- a/mysql-test/suite/galera/r/galera_serializable.result +++ b/mysql-test/suite/galera/r/galera_serializable.result @@ -1,27 +1,37 @@ +connection node_1; CREATE TABLE t1 (id INT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; SET AUTOCOMMIT=OFF; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; START TRANSACTION; SELECT * FROM t1; id f2 +connection node_2; INSERT INTO t1 VALUES (1,1); +connection node_1; SELECT * FROM t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ROLLBACK; DELETE FROM t1; +connection node_1; INSERT INTO t1 VALUES (1,1); START TRANSACTION; SELECT * FROM t1; id f2 1 1 +connection node_2; UPDATE t1 SET f2 = 2; +connection node_1; UPDATE t1 SET f2 = 3; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ROLLBACK; DELETE FROM t1; +connection node_1; START TRANSACTION; +connection node_1; INSERT INTO t1 VALUES (1,1); +connection node_2; INSERT INTO t1 VALUES (1,2); +connection node_1; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_server.result b/mysql-test/suite/galera/r/galera_server.result index ef81bf376b0..cc08b826e82 100644 --- a/mysql-test/suite/galera/r/galera_server.result +++ b/mysql-test/suite/galera/r/galera_server.result @@ -1,20 +1,26 @@ +connection node_1; # On node_1 CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (HOST 'foo'); +connection node_2; # On node_2 SELECT * FROM mysql.servers; Server_name Host Db Username Password Port Socket Wrapper Owner s1 foo 3306 mysql ALTER SERVER s1 OPTIONS (HOST 'bar'); +connection node_1; # On node_1 SELECT * FROM mysql.servers; Server_name Host Db Username Password Port Socket Wrapper Owner s1 bar 3306 mysql DROP SERVER s1; +connection node_2; # On node_2 SELECT COUNT(*)=0 FROM mysql.servers; COUNT(*)=0 1 +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_split_brain.result b/mysql-test/suite/galera/r/galera_split_brain.result index 615615040fe..9c5952cfa28 100644 --- a/mysql-test/suite/galera/r/galera_split_brain.result +++ b/mysql-test/suite/galera/r/galera_split_brain.result @@ -1,5 +1,11 @@ call mtr.add_suppression("WSREP: TO isolation failed for: "); +connection node_1; +connection node_1; +connection node_2; +connection node_2; Killing server ... +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SET GLOBAL wsrep_cluster_address = ''; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; diff --git a/mysql-test/suite/galera/r/galera_sql_log_bin_zero.result b/mysql-test/suite/galera/r/galera_sql_log_bin_zero.result index c15a24e481f..14407c917a1 100644 --- a/mysql-test/suite/galera/r/galera_sql_log_bin_zero.result +++ b/mysql-test/suite/galera/r/galera_sql_log_bin_zero.result @@ -3,10 +3,12 @@ SET SESSION sql_log_bin = 0; INSERT INTO t1 VALUES (1); SET SESSION sql_log_bin = 1; INSERT INTO t1 VALUES (2); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 1; COUNT(*) = 1 1 +connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ssl.result b/mysql-test/suite/galera/r/galera_ssl.result index 569c3c607d5..022d06319b8 100644 --- a/mysql-test/suite/galera/r/galera_ssl.result +++ b/mysql-test/suite/galera/r/galera_ssl.result @@ -6,6 +6,7 @@ VARIABLE_VALUE = 2 1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; VARIABLE_VALUE = 'Synced' 1 diff --git a/mysql-test/suite/galera/r/galera_ssl_compression.result b/mysql-test/suite/galera/r/galera_ssl_compression.result index f25b614d139..333d646376c 100644 --- a/mysql-test/suite/galera/r/galera_ssl_compression.result +++ b/mysql-test/suite/galera/r/galera_ssl_compression.result @@ -4,19 +4,23 @@ VARIABLE_VALUE = 'Synced' SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +connection node_2; SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; VARIABLE_VALUE = 'Synced' 1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +connection node_1; SET GLOBAL wsrep_provider_options = "socket.ssl_compression=No"; ERROR HY000: Incorrect arguments to SET CREATE TABLE t1 (f1 VARCHAR(333) PRIMARY KEY, f2 BLOB) Engine=InnoDB; INSERT INTO t1 VALUES (REPEAT('a', 333), REPEAT('b', 65535)); +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = REPEAT('a', 333) AND f2 = REPEAT('b', 65535); COUNT(*) = 1 1 +connection node_1; DROP TABLE t1; CALL mtr.add_suppression("Unknown parameter 'socket\.ssl_compression'"); CALL mtr.add_suppression("Set options returned 7"); diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump.result b/mysql-test/suite/galera/r/galera_sst_mysqldump.result index e35c4055f45..5c0d9a45d41 100644 --- a/mysql-test/suite/galera/r/galera_sst_mysqldump.result +++ b/mysql-test/suite/galera/r/galera_sst_mysqldump.result @@ -1,4 +1,5 @@ Setting SST method to mysqldump ... +CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; SET GLOBAL wsrep_sst_method = 'mysqldump'; diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result index 7d30b356aa9..227e1c15444 100644 --- a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result +++ b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result @@ -1,4 +1,5 @@ Setting SST method to mysqldump ... +CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; SET GLOBAL wsrep_sst_method = 'mysqldump'; diff --git a/mysql-test/suite/galera/r/galera_status_cluster.result b/mysql-test/suite/galera/r/galera_status_cluster.result index d7cf671cb10..ad92a51b775 100644 --- a/mysql-test/suite/galera/r/galera_status_cluster.result +++ b/mysql-test/suite/galera/r/galera_status_cluster.result @@ -1,9 +1,11 @@ +connection node_1; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 +connection node_2; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 diff --git a/mysql-test/suite/galera/r/galera_status_local_index.result b/mysql-test/suite/galera/r/galera_status_local_index.result index 4e886ac8921..8c36b60cc5f 100644 --- a/mysql-test/suite/galera/r/galera_status_local_index.result +++ b/mysql-test/suite/galera/r/galera_status_local_index.result @@ -1,6 +1,9 @@ +connection node_1; CREATE TABLE wsrep_local_indexes (wsrep_local_index INTEGER); INSERT INTO wsrep_local_indexes VALUES ((SELECT variable_value FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_local_index')); +connection node_2; INSERT INTO wsrep_local_indexes VALUES ((SELECT variable_value FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_local_index')); +connection node_1; SELECT COUNT(*) = 2 FROM wsrep_local_indexes; COUNT(*) = 2 1 diff --git a/mysql-test/suite/galera/r/galera_suspend_slave.result b/mysql-test/suite/galera/r/galera_suspend_slave.result index 02904812dd5..380ecb395c3 100644 --- a/mysql-test/suite/galera/r/galera_suspend_slave.result +++ b/mysql-test/suite/galera/r/galera_suspend_slave.result @@ -1,9 +1,16 @@ +connection node_1; +connection node_2; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +connection node_2; +disconnect node_2; +connection node_1; Suspending node_2 ... INSERT INTO t1 VALUES (1); Got one of the listed errors Resuming node_2 ... INSERT INTO t1 VALUES (1); +connection node_2a; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result index 2f030c26bb8..4a73a573041 100644 --- a/mysql-test/suite/galera/r/galera_sync_wait_show.result +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -1,38 +1,53 @@ +connection node_2; SET SESSION wsrep_sync_wait = 1; +connection node_1; CREATE DATABASE db1; +connection node_2; SHOW CREATE DATABASE db1; Database Create Database db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ DROP DATABASE db1; +connection node_1; CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; +connection node_2; SHOW CREATE PROCEDURE p1; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation p1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() SELECT 1 FROM DUAL latin1 latin1_swedish_ci latin1_swedish_ci DROP PROCEDURE p1; +connection node_1; CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; +connection node_2; SHOW PROCEDURE CODE p1; Pos Instruction 0 stmt 0 "SELECT 1 FROM DUAL" DROP PROCEDURE p1; +connection node_1; CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; +connection node_2; SHOW CREATE FUNCTION f1; Function sql_mode Create Function character_set_client collation_connection Database Collation f1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) RETURN 123 latin1 latin1_swedish_ci latin1_swedish_ci DROP FUNCTION f1; +connection node_1; CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; +connection node_2; SHOW FUNCTION CODE f1; Pos Instruction 0 freturn 3 123 DROP FUNCTION f1; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a'; +connection node_2; SHOW CREATE TRIGGER tr1; Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation tr1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a' latin1 latin1_swedish_ci latin1_swedish_ci DROP TABLE t1; +connection node_1; CREATE EVENT event1 ON SCHEDULE AT '2038-01-01 23:59:59' DO SELECT 1; +connection node_2; SHOW CREATE EVENT event1; Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation event1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `event1` ON SCHEDULE AT '2038-01-01 23:59:59' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci diff --git a/mysql-test/suite/galera/r/galera_toi_alter_auto_increment.result b/mysql-test/suite/galera/r/galera_toi_alter_auto_increment.result index f91415323ec..8a86dfd11e2 100644 --- a/mysql-test/suite/galera/r/galera_toi_alter_auto_increment.result +++ b/mysql-test/suite/galera/r/galera_toi_alter_auto_increment.result @@ -1,40 +1,54 @@ +connection node_1; CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; INSERT INTO t1 (f2) SELECT 1 FROM ten; +connection node_2; INSERT INTO t1 (f2) SELECT 1 FROM ten; ALTER TABLE t1 AUTO_INCREMENT = 1000; INSERT INTO t1 (f2) SELECT 1 FROM ten; +connection node_1; INSERT INTO t1 (f2) SELECT 1 FROM ten; SELECT MIN(f1) >= 1000, COUNT(*) = 20, COUNT(DISTINCT f1) = 20 FROM t1 WHERE f1 >= 1000; MIN(f1) >= 1000 COUNT(*) = 20 COUNT(DISTINCT f1) = 20 1 1 1 +connection node_2; SELECT MIN(f1) >= 1000, COUNT(*) = 20, COUNT(DISTINCT f1) = 20 FROM t1 WHERE f1 >= 1000; MIN(f1) >= 1000 COUNT(*) = 20 COUNT(DISTINCT f1) = 20 1 1 1 +connection node_1; ALTER TABLE t1 AUTO_INCREMENT = 5; INSERT INTO t1 (f2) SELECT 1 FROM ten; +connection node_2; INSERT INTO t1 (f2) SELECT 1 FROM ten; SELECT MIN(f1) >= 1000, COUNT(*) = 40, COUNT(DISTINCT f1) = 40 FROM t1 WHERE f1 >= 1000; MIN(f1) >= 1000 COUNT(*) = 40 COUNT(DISTINCT f1) = 40 1 1 1 +connection node_1; SELECT MIN(f1) >= 1000, COUNT(*) = 40, COUNT(DISTINCT f1) = 40 FROM t1 WHERE f1 >= 1000; MIN(f1) >= 1000 COUNT(*) = 40 COUNT(DISTINCT f1) = 40 1 1 1 DROP TABLE t1; +connection node_1; SET GLOBAL wsrep_auto_increment_control = OFF; SET GLOBAL auto_increment_increment = 1; SET GLOBAL auto_increment_offset = 1; +connection node_2; SET GLOBAL wsrep_auto_increment_control = OFF; SET GLOBAL auto_increment_increment = 1; SET GLOBAL auto_increment_offset = 1; +connection node_1a; CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; +connection node_2a; ALTER TABLE t1 AUTO_INCREMENT=100; +connection node_1a; INSERT INTO t1 (f2) SELECT 1 FROM ten; +connection node_2a; INSERT INTO t1 (f2) SELECT 1 FROM ten; SELECT MIN(f1) = 100, MAX(f1) = 119, COUNT(f1) = 20, COUNT(DISTINCT f1) = 20 FROM t1; MIN(f1) = 100 MAX(f1) = 119 COUNT(f1) = 20 COUNT(DISTINCT f1) = 20 1 1 1 1 +connection node_1a; SELECT MIN(f1) = 100, MAX(f1) = 119, COUNT(f1) = 20, COUNT(DISTINCT f1) = 20 FROM t1; MIN(f1) = 100 MAX(f1) = 119 COUNT(f1) = 20 COUNT(DISTINCT f1) = 20 1 1 1 1 diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_locking.result b/mysql-test/suite/galera/r/galera_toi_ddl_locking.result index f0a51db14d3..68743c024a0 100644 --- a/mysql-test/suite/galera/r/galera_toi_ddl_locking.result +++ b/mysql-test/suite/galera/r/galera_toi_ddl_locking.result @@ -1,7 +1,9 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +connection node_1; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +connection node_1a; SET SESSION wsrep_sync_wait = 0; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 @@ -15,6 +17,7 @@ SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t2 VALUES (1); COMMIT;; +connection node_1b; SET SESSION wsrep_sync_wait = 0; SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'Commit'; COUNT(*) = 1 @@ -23,19 +26,24 @@ SELECT COUNT(*) = 0 FROM t2; COUNT(*) = 0 1 SET DEBUG_SYNC= 'now SIGNAL continue'; +connection node_1a; +connection node_1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 SELECT COUNT(*) = 1 FROM t2; COUNT(*) = 1 1 +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 SELECT COUNT(*) = 1 FROM t2; COUNT(*) = 1 1 +connection node_1; SET DEBUG_SYNC= 'RESET'; +connection node_1b; SET DEBUG_SYNC= 'RESET'; DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result b/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result index 41e693c2b19..3844fa97d82 100644 --- a/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result +++ b/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result @@ -1,6 +1,9 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +connection node_2; ALTER TABLE t1 ADD COLUMN f3 INTEGER; INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 123);; +connection node_1; CREATE UNIQUE INDEX i1 ON t1(f2);; +connection node_2; INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 234); SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 3 @@ -11,6 +14,7 @@ COUNT(*) = 2 SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 +connection node_1; SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 3 1 diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_sequential.result b/mysql-test/suite/galera/r/galera_toi_ddl_sequential.result index 9dfa433d49f..722bb9d9e12 100644 --- a/mysql-test/suite/galera/r/galera_toi_ddl_sequential.result +++ b/mysql-test/suite/galera/r/galera_toi_ddl_sequential.result @@ -1,9 +1,12 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; ALTER TABLE t1 ADD COLUMN f2 INTEGER; INSERT INTO t1 VALUES (2, 3); +connection node_1; ALTER TABLE t1 DROP COLUMN f2; INSERT INTO t1 VALUES (4); +connection node_2; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -18,6 +21,7 @@ f1 1 2 4 +connection node_1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/galera_toi_ftwrl.result b/mysql-test/suite/galera/r/galera_toi_ftwrl.result index 594717c96ff..0f13e95b689 100644 --- a/mysql-test/suite/galera/r/galera_toi_ftwrl.result +++ b/mysql-test/suite/galera/r/galera_toi_ftwrl.result @@ -1,6 +1,9 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; FLUSH TABLES WITH READ LOCK; +connection node_1; ALTER TABLE t1 ADD COLUMN f2 INTEGER; +connection node_2; UNLOCK TABLES; SHOW CREATE TABLE t1; Table Create Table diff --git a/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result b/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result index eac50e8853c..c13b689f82b 100644 --- a/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result +++ b/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result @@ -1,15 +1,20 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (2); +connection node_2a; ALTER TABLE t1 ADD COLUMN f2 INTEGER, LOCK=EXCLUSIVE; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_1; INSERT INTO t1 VALUES (2, 2); SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 +connection node_2; INSERT INTO t1 VALUES (3, 3); SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 diff --git a/mysql-test/suite/galera/r/galera_toi_lock_shared.result b/mysql-test/suite/galera/r/galera_toi_lock_shared.result index 36c38860688..950c4d83c70 100644 --- a/mysql-test/suite/galera/r/galera_toi_lock_shared.result +++ b/mysql-test/suite/galera/r/galera_toi_lock_shared.result @@ -1,10 +1,13 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; ALTER TABLE t1 ADD COLUMN f2 INTEGER, LOCK=SHARED; +connection node_1; INSERT INTO t1 VALUES (2, 2); SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 +connection node_2; INSERT INTO t1 VALUES (3, 3); SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 diff --git a/mysql-test/suite/galera/r/galera_truncate.result b/mysql-test/suite/galera/r/galera_truncate.result index eeeb6721d12..4f3d72dbca7 100644 --- a/mysql-test/suite/galera/r/galera_truncate.result +++ b/mysql-test/suite/galera/r/galera_truncate.result @@ -1,24 +1,31 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; TRUNCATE TABLE t1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_2; CREATE TABLE t2 (f1 VARCHAR(255)) Engine=InnoDB; INSERT INTO t2 VALUES ('abc'); +connection node_1; TRUNCATE TABLE t2; +connection node_2; SELECT COUNT(*) = 0 FROM t2; COUNT(*) = 0 1 +connection node_1; CREATE TABLE t3 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; INSERT INTO t3 VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT); CREATE TABLE t4 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB AUTO_INCREMENT=1234; INSERT INTO t4 VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT); TRUNCATE TABLE t3; TRUNCATE TABLE t4; +connection node_2; SELECT AUTO_INCREMENT = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME IN ('t3', 't4'); AUTO_INCREMENT = 1 1 diff --git a/mysql-test/suite/galera/r/galera_truncate_temporary.result b/mysql-test/suite/galera/r/galera_truncate_temporary.result index 0bdc4e3632a..183ebd9d24a 100644 --- a/mysql-test/suite/galera/r/galera_truncate_temporary.result +++ b/mysql-test/suite/galera/r/galera_truncate_temporary.result @@ -4,8 +4,10 @@ TRUNCATE TABLE t1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_2; SELECT * FROM t1; ERROR 42S02: Table 'test.t1' doesn't exist +connection node_1; DROP TABLE t1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); @@ -21,12 +23,14 @@ TRUNCATE TABLE t1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SELECT f1 = 1 FROM t1; f1 = 1 1 +connection node_1; DROP TABLE t1; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 @@ -38,18 +42,23 @@ TRUNCATE TABLE t1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_1; DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (2); +connection node_2; TRUNCATE TABLE t1; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_1; SELECT f1 = 2 FROM t1; f1 = 2 1 diff --git a/mysql-test/suite/galera/r/galera_unicode_identifiers.result b/mysql-test/suite/galera/r/galera_unicode_identifiers.result index 8bea105c77e..146cc052152 100644 --- a/mysql-test/suite/galera/r/galera_unicode_identifiers.result +++ b/mysql-test/suite/galera/r/galera_unicode_identifiers.result @@ -1,5 +1,7 @@ SET GLOBAL wsrep_sync_wait = 7; +connection node_2; SET GLOBAL wsrep_sync_wait = 7; +connection node_1; CREATE DATABASE `database with space`; USE `database with space`; CREATE TABLE `table with space` ( @@ -24,6 +26,7 @@ CREATE TABLE `втора таблица` ( KEY `първи индекÑ` (`първа колона`) ); INSERT INTO `втора таблица` VALUES (1, 1); +connection node_2; USE `database with space`; SELECT `second column with space` FROM `table with space`; second column with space @@ -37,6 +40,7 @@ SELECT `втора колона` FROM `втора таблица`; втора колона 1 SET GLOBAL wsrep_sync_wait = (SELECT @@wsrep_sync_wait); +connection node_1; DROP TABLE `database with space`.`table with space`; DROP TABLE `база`.`таблица`; DROP TABLE `втора база`.`втора таблица`; diff --git a/mysql-test/suite/galera/r/galera_unicode_pk.result b/mysql-test/suite/galera/r/galera_unicode_pk.result index d59615b2542..2711e44b7cb 100644 --- a/mysql-test/suite/galera/r/galera_unicode_pk.result +++ b/mysql-test/suite/galera/r/galera_unicode_pk.result @@ -2,16 +2,21 @@ CREATE TABLE t1 ( f1 VARCHAR(255) PRIMARY KEY ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO t1 VALUES ('текÑÑ‚'); +connection node_2; SELECT f1 = 'текÑÑ‚' FROM t1; f1 = 'текÑÑ‚' 1 +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f1 = 'текÑÑ‚2'; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; UPDATE t1 SET f1 = 'текÑÑ‚3'; +connection node_1; COMMIT; +connection node_2; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SELECT f1 = 'текÑÑ‚2' FROM t1; @@ -20,11 +25,15 @@ f1 = 'текÑÑ‚2' SELECT f1 = 'текÑÑ‚2' FROM t1 WHERE f1 = 'текÑÑ‚2'; f1 = 'текÑÑ‚2' 1 +connection node_2; START TRANSACTION; INSERT INTO t1 VALUES ('текÑÑ‚4'); +connection node_1; START TRANSACTION; INSERT INTO t1 VALUES ('текÑÑ‚4'); +connection node_2; COMMIT; +connection node_1; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction COMMIT; diff --git a/mysql-test/suite/galera/r/galera_update_limit.result b/mysql-test/suite/galera/r/galera_update_limit.result index c26eb1c29f6..20a94e6f504 100644 --- a/mysql-test/suite/galera/r/galera_update_limit.result +++ b/mysql-test/suite/galera/r/galera_update_limit.result @@ -1,8 +1,11 @@ +connection node_1; CREATE TABLE ten (f1 INTEGER) Engine=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND(); +connection node_2; UPDATE IGNORE t1 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5; +connection node_1; sum_matches 1 max_matches @@ -10,7 +13,9 @@ max_matches DROP TABLE t1; CREATE TABLE t2 (f1 INTEGER) Engine=InnoDB; INSERT INTO t2 SELECT f1 FROM ten ORDER BY RAND(); +connection node_2; UPDATE IGNORE t2 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5; +connection node_1; sum_matches 1 DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_v1_row_events.result b/mysql-test/suite/galera/r/galera_v1_row_events.result index a6ab62350b1..b0ea2293119 100644 --- a/mysql-test/suite/galera/r/galera_v1_row_events.result +++ b/mysql-test/suite/galera/r/galera_v1_row_events.result @@ -1,9 +1,12 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; UPDATE t1 SET f1 = 2 WHERE f1 = 1; +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_var_OSU_method.result b/mysql-test/suite/galera/r/galera_var_OSU_method.result index 9a07873e1b9..18e8bd2271a 100644 --- a/mysql-test/suite/galera/r/galera_var_OSU_method.result +++ b/mysql-test/suite/galera/r/galera_var_OSU_method.result @@ -1,16 +1,24 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +connection node_1; SET SESSION wsrep_OSU_method = "RSU"; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; SET GLOBAL wsrep_OSU_method = "TOI"; SET DEBUG_SYNC= 'now SIGNAL continue'; +connection node_1; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 2 1 +connection node_2; SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 1 1 +connection node_1; SET SESSION wsrep_OSU_method = "TOI"; +connection node_1; SET DEBUG_SYNC= 'RESET'; +connection node_1a; SET DEBUG_SYNC= 'RESET'; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_OSU_method2.result b/mysql-test/suite/galera/r/galera_var_OSU_method2.result index 08f2e6aa0d8..0e3751645a8 100644 --- a/mysql-test/suite/galera/r/galera_var_OSU_method2.result +++ b/mysql-test/suite/galera/r/galera_var_OSU_method2.result @@ -1,19 +1,26 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +connection node_1; SET SESSION wsrep_OSU_method = "TOI"; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; SET SESSION wsrep_sync_wait = 0; SET GLOBAL wsrep_OSU_method = "RSU"; SET DEBUG_SYNC= 'now SIGNAL continue'; +connection node_1; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 2 1 INSERT INTO t1 VALUES (1,2); +connection node_2; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 2 1 INSERT INTO t1 VALUES (3,4); +connection node_1; SET GLOBAL wsrep_OSU_method = "TOI"; DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; +connection node_1a; SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result b/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result index 92b69fbbaa7..15bbe7c508a 100644 --- a/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result +++ b/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result @@ -1,9 +1,12 @@ +connection node_1; SET GLOBAL wsrep_auto_increment_control = OFF; SET GLOBAL auto_increment_increment = 1; SET GLOBAL auto_increment_offset = 1; +connection node_2; SET GLOBAL wsrep_auto_increment_control = OFF; SET GLOBAL auto_increment_increment = 1; SET GLOBAL auto_increment_offset = 1; +connection node_1a; SELECT @@auto_increment_increment = 1; @@auto_increment_increment = 1 1 @@ -18,6 +21,7 @@ t1 CREATE TABLE `t1` ( `node` varchar(10) DEFAULT NULL, PRIMARY KEY (`f1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_2a; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -25,6 +29,7 @@ t1 CREATE TABLE `t1` ( `node` varchar(10) DEFAULT NULL, PRIMARY KEY (`f1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_1a; SELECT @@auto_increment_increment = 1; @@auto_increment_increment = 1 1 @@ -37,6 +42,7 @@ INSERT INTO t1 (node) VALUES ('node1'); SELECT f1 FROM t1; f1 1 +connection node_2a; SELECT @@auto_increment_increment = 1; @@auto_increment_increment = 1 1 @@ -49,12 +55,16 @@ INSERT INTO t1 (node) VALUES ('node2'); SELECT f1 FROM t1; f1 1 +connection node_1a; COMMIT; +connection node_2a; COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_1a; SELECT * FROM t1; f1 node 1 node1 +connection node_2a; SELECT * FROM t1; f1 node 1 node1 diff --git a/mysql-test/suite/galera/r/galera_var_certify_nonPK_off.result b/mysql-test/suite/galera/r/galera_var_certify_nonPK_off.result index e6f37792569..b13302d3ecd 100644 --- a/mysql-test/suite/galera/r/galera_var_certify_nonPK_off.result +++ b/mysql-test/suite/galera/r/galera_var_certify_nonPK_off.result @@ -1,11 +1,14 @@ SET GLOBAL wsrep_certify_nonPK = OFF; +connection node_2; SET GLOBAL wsrep_certify_nonPK = OFF; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB /* Table has no primary key */; CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1), (2); Got one of the listed errors INSERT INTO t2 VALUES (1), (2); UPDATE t2 SET f1 = 3 WHERE f1 = 1; +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 @@ -15,7 +18,9 @@ COUNT(*) = 2 SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 3; COUNT(*) = 1 1 +connection node_1; SET GLOBAL wsrep_certify_nonPK = 1; +connection node_2; SET GLOBAL wsrep_certify_nonPK = 1; DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_var_cluster_address.result b/mysql-test/suite/galera/r/galera_var_cluster_address.result index f8bd869f8fe..09971c08580 100644 --- a/mysql-test/suite/galera/r/galera_var_cluster_address.result +++ b/mysql-test/suite/galera/r/galera_var_cluster_address.result @@ -1,3 +1,6 @@ +connection node_1; +connection node_2; +connection node_1; SET GLOBAL wsrep_cluster_address = 'foo://'; SET SESSION wsrep_sync_wait=0; SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS; @@ -14,19 +17,24 @@ wsrep_local_state 0 SHOW STATUS LIKE 'wsrep_local_state_comment'; Variable_name Value wsrep_local_state_comment Initialized +connection node_2; SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 1 1 SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 +connection node_1; +connection node_2; SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address; +connection node_1; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +connection node_1; SET GLOBAL wsrep_cluster_address = 'gcomm://192.0.2.1'; SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS; ERROR 08S01: WSREP has not yet prepared node for application use @@ -42,7 +50,10 @@ wsrep_local_state 0 SHOW STATUS LIKE 'wsrep_local_state_comment'; Variable_name Value wsrep_local_state_comment Initialized +connection node_1; +connection node_2; SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address; +connection node_1; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 diff --git a/mysql-test/suite/galera/r/galera_var_desync_on.result b/mysql-test/suite/galera/r/galera_var_desync_on.result index 0b5f34688b7..383e077f775 100644 --- a/mysql-test/suite/galera/r/galera_var_desync_on.result +++ b/mysql-test/suite/galera/r/galera_var_desync_on.result @@ -1,8 +1,10 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; SET GLOBAL wsrep_desync = TRUE; FLUSH TABLES WITH READ LOCK; +connection node_1; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (4); @@ -12,6 +14,7 @@ INSERT INTO t1 VALUES (7); INSERT INTO t1 VALUES (8); INSERT INTO t1 VALUES (9); INSERT INTO t1 VALUES (10); +connection node_2; SET SESSION wsrep_sync_wait = 0; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 @@ -22,7 +25,9 @@ SET SESSION wsrep_sync_wait = 1; SELECT COUNT(*) = 10 FROM t1; COUNT(*) = 10 1 +connection node_1; INSERT INTO t1 VALUES (11); +connection node_2; SELECT COUNT(*) = 11 FROM t1; COUNT(*) = 11 1 diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index 6d703c8cf95..6b3a3ec0eb5 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -1,3 +1,4 @@ +connection node_2; CREATE TABLE t1(i INT) ENGINE=INNODB; INSERT INTO t1 VALUES(1); SELECT * FROM t1; @@ -18,8 +19,11 @@ SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; i 1 +connection node_1; SELECT * FROM t1; i 1 DROP TABLE t1; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_var_fkchecks.result b/mysql-test/suite/galera/r/galera_var_fkchecks.result index 342212a5241..8b1b913a584 100644 --- a/mysql-test/suite/galera/r/galera_var_fkchecks.result +++ b/mysql-test/suite/galera/r/galera_var_fkchecks.result @@ -12,6 +12,7 @@ INSERT INTO parent VALUES (1); INSERT INTO child VALUES (1,1); SET SESSION foreign_key_checks = 0; INSERT INTO child VALUES (2,2); +connection node_2; SELECT COUNT(*) = 1 FROM child WHERE id = 2; COUNT(*) = 1 1 @@ -19,6 +20,7 @@ INSERT INTO child VALUES (3,3); ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) SET SESSION foreign_key_checks = 0; DELETE FROM parent; +connection node_1; SELECT COUNT(*) = 0 FROM parent; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result b/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result index 8e84236d5bf..1a8733e2e1a 100644 --- a/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result +++ b/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result @@ -1,4 +1,5 @@ # On node_1 +connection node_1; list of GTID variables : gtid_domain_id 1 gtid_binlog_pos @@ -8,6 +9,7 @@ gtid_slave_pos wsrep_gtid_domain_id 9999 wsrep_gtid_mode 1 # On node_2 +connection node_2; list of GTID variables : gtid_domain_id 2 gtid_binlog_pos @@ -17,6 +19,7 @@ gtid_slave_pos wsrep_gtid_domain_id 9999 wsrep_gtid_mode 1 # On node_1 +connection node_1; CREATE TABLE t1(i INT) ENGINE=INNODB; CREATE TABLE t2(i INT) ENGINE=MEMORY; INSERT INTO t1 VALUES(1); @@ -34,6 +37,7 @@ gtid_slave_pos wsrep_gtid_domain_id 9999 wsrep_gtid_mode 1 # On node_2 +connection node_2; SELECT * FROM t1; i 1 @@ -46,6 +50,7 @@ gtid_slave_pos wsrep_gtid_domain_id 9999 wsrep_gtid_mode 1 # On node_1 +connection node_1; INSERT INTO t2 VALUES(1); SELECT * FROM t2; i @@ -59,6 +64,7 @@ gtid_slave_pos wsrep_gtid_domain_id 9999 wsrep_gtid_mode 1 # On node_2 +connection node_2; SELECT * FROM t2; i list of GTID variables : @@ -70,5 +76,8 @@ gtid_slave_pos wsrep_gtid_domain_id 9999 wsrep_gtid_mode 1 # On node_1 +connection node_1; DROP TABLE t1, t2; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_var_innodb_disallow_writes.result b/mysql-test/suite/galera/r/galera_var_innodb_disallow_writes.result index 912e45a14b1..5377a0af1b6 100644 --- a/mysql-test/suite/galera/r/galera_var_innodb_disallow_writes.result +++ b/mysql-test/suite/galera/r/galera_var_innodb_disallow_writes.result @@ -1,11 +1,16 @@ +connection node_1a; SET SESSION wsrep_sync_wait = 0; +connection node_1; CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; SET GLOBAL innodb_disallow_writes=ON; INSERT INTO t1 VALUES (1);; +connection node_1a; SET GLOBAL innodb_disallow_writes=OFF; +connection node_1; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_var_log_bin.result b/mysql-test/suite/galera/r/galera_var_log_bin.result index a6ab62350b1..b0ea2293119 100644 --- a/mysql-test/suite/galera/r/galera_var_log_bin.result +++ b/mysql-test/suite/galera/r/galera_var_log_bin.result @@ -1,9 +1,12 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; UPDATE t1 SET f1 = 2 WHERE f1 = 1; +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_var_max_ws_size.result b/mysql-test/suite/galera/r/galera_var_max_ws_size.result index d0bf7deafa5..71859ef82e0 100644 --- a/mysql-test/suite/galera/r/galera_var_max_ws_size.result +++ b/mysql-test/suite/galera/r/galera_var_max_ws_size.result @@ -1,3 +1,4 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 VARCHAR(1024)) Engine=InnoDB; SET GLOBAL wsrep_max_ws_size = 1024; INSERT INTO t1 VALUES (DEFAULT, REPEAT('X', 1024)); diff --git a/mysql-test/suite/galera/r/galera_var_mysql_replication_bundle.result b/mysql-test/suite/galera/r/galera_var_mysql_replication_bundle.result index f2a951c26b0..202633a020e 100644 --- a/mysql-test/suite/galera/r/galera_var_mysql_replication_bundle.result +++ b/mysql-test/suite/galera/r/galera_var_mysql_replication_bundle.result @@ -1,12 +1,17 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; SET GLOBAL wsrep_mysql_replication_bundle = 2; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 0 +connection node_1; INSERT INTO t1 VALUES (2); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 +connection node_1; SET GLOBAL wsrep_mysql_replication_bundle = 0; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_node_address.result b/mysql-test/suite/galera/r/galera_var_node_address.result index fa88f4b3128..fe3b5613903 100644 --- a/mysql-test/suite/galera/r/galera_var_node_address.result +++ b/mysql-test/suite/galera/r/galera_var_node_address.result @@ -1,9 +1,14 @@ SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 +connection node_1; CREATE TABLE t1 (f1 INTEGER); +connection node_2; INSERT INTO t1 VALUES (1); +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_replicate_myisam_off.result b/mysql-test/suite/galera/r/galera_var_replicate_myisam_off.result index c8b79071d10..382466b1387 100644 --- a/mysql-test/suite/galera/r/galera_var_replicate_myisam_off.result +++ b/mysql-test/suite/galera/r/galera_var_replicate_myisam_off.result @@ -1,8 +1,10 @@ SET GLOBAL wsrep_replicate_myisam = FALSE; CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_1; SET GLOBAL wsrep_replicate_myisam = 0; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result b/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result index 73a0576048b..bf5a09f6a77 100644 --- a/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result +++ b/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result @@ -1,17 +1,24 @@ +connection node_1; +connection node_1; SET GLOBAL wsrep_replicate_myisam = TRUE; +connection node_2; SET GLOBAL wsrep_replicate_myisam = TRUE; +connection node_1; CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2), (3); INSERT INTO t1 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; +connection node_2; SELECT COUNT(*) = 5 FROM t1; COUNT(*) = 5 1 DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 VARCHAR(100)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1, 'abc'),(2,'abc'), (3, 'xxx'); REPLACE INTO t1 VALUES (1, 'klm'), (2,'xyz'); REPLACE INTO t1 SELECT 3, 'yyy' FROM DUAL; +connection node_2; SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 1 @@ -24,19 +31,26 @@ COUNT(*) = 1 SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 3 AND f2 = 'yyy'; COUNT(*) = 1 1 +connection node_1; UPDATE t1 SET f2 = 'zzz' WHERE f2 = 'yyy'; +connection node_2; SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'zzz'; COUNT(*) = 1 1 +connection node_1; DELETE FROM t1 WHERE f2 = 'zzz'; +connection node_2; SELECT COUNT(*) = 0 FROM t1 WHERE f2 = 'zzz'; COUNT(*) = 0 1 +connection node_1; TRUNCATE TABLE t1; +connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; SET AUTOCOMMIT=OFF; @@ -44,18 +58,21 @@ START TRANSACTION; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); COMMIT; +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SELECT COUNT(*) = 1 FROM t2; COUNT(*) = 1 1 +connection node_1; START TRANSACTION; INSERT INTO t1 VALUES (2); INSERT INTO t2 VALUES (2); ROLLBACK; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 @@ -64,15 +81,20 @@ COUNT(*) = 1 1 DROP TABLE t1; DROP TABLE t2; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; CREATE TABLE t2 (f2 INTEGER PRIMARY KEY) ENGINE=InnoDB; START TRANSACTION; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); +connection node_2; INSERT INTO t1 VALUES (1); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +connection node_1; COMMIT; DROP TABLE t1; DROP TABLE t2; +connection node_1; SET GLOBAL wsrep_replicate_myisam = 0; +connection node_2; SET GLOBAL wsrep_replicate_myisam = 0; diff --git a/mysql-test/suite/galera/r/galera_var_slave_threads.result b/mysql-test/suite/galera/r/galera_var_slave_threads.result index 603dfaeacc7..facc083544c 100644 --- a/mysql-test/suite/galera/r/galera_var_slave_threads.result +++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result @@ -1,5 +1,7 @@ +connection node_1; CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; +connection node_2; SET GLOBAL wsrep_slave_threads = 0; Warnings: Warning 1292 Truncated incorrect wsrep_slave_threads value: '0' @@ -17,7 +19,9 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use COUNT(*) = 1 1 SET GLOBAL wsrep_slave_threads = 64; +connection node_1; INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 @@ -28,6 +32,7 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use COUNT(*) = 1 1 SET GLOBAL wsrep_slave_threads = 1; +connection node_1; INSERT INTO t2 VALUES (DEFAULT); INSERT INTO t2 VALUES (DEFAULT); INSERT INTO t2 VALUES (DEFAULT); @@ -92,6 +97,7 @@ INSERT INTO t2 VALUES (DEFAULT); INSERT INTO t2 VALUES (DEFAULT); INSERT INTO t2 VALUES (DEFAULT); INSERT INTO t2 VALUES (DEFAULT); +connection node_2; SELECT COUNT(*) = 64 FROM t2; COUNT(*) = 64 1 @@ -107,7 +113,9 @@ DROP TABLE t2; # # lp:1372840 - Changing wsrep_slave_threads causes future connections to hang # +connection node_1; CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB; +connection node_2; SET GLOBAL wsrep_slave_threads = 4; SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_sync_wait.result b/mysql-test/suite/galera/r/galera_var_sync_wait.result index f6136a4ddc4..40a6290374f 100644 --- a/mysql-test/suite/galera/r/galera_var_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_var_sync_wait.result @@ -1,4 +1,6 @@ +connection node_1; CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; +connection node_2; SET GLOBAL wsrep_sync_wait = 1; SHOW TABLES LIKE '%t1'; Tables_in_test (%t1) @@ -6,15 +8,20 @@ t1 SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +connection node_1; CREATE TABLE t2 (f1 INT PRIMARY KEY) Engine=InnoDB; +connection node_2; SET GLOBAL wsrep_sync_wait = 4; INSERT INTO t2 VALUES (1); +connection node_1; CREATE TABLE t3 (f1 INT PRIMARY KEY) Engine=InnoDB; INSERT INTO t3 VALUES (1); +connection node_2; SET GLOBAL wsrep_sync_wait = 2; UPDATE t3 SET f1 = 2; affected rows: 1 info: Rows matched: 1 Changed: 1 Warnings: 0 +connection node_2; SET GLOBAL wsrep_sync_wait = 7; DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_var_wsrep_on_off.result b/mysql-test/suite/galera/r/galera_var_wsrep_on_off.result index 8b1c4ebf83b..36340f505ff 100644 --- a/mysql-test/suite/galera/r/galera_var_wsrep_on_off.result +++ b/mysql-test/suite/galera/r/galera_var_wsrep_on_off.result @@ -2,11 +2,14 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); SET SESSION wsrep_on = FALSE; INSERT INTO t1 VALUES (2); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +connection node_1; SET GLOBAL wsrep_on = TRUE; INSERT INTO t1 VALUES (3); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 diff --git a/mysql-test/suite/galera/r/galera_wan.result b/mysql-test/suite/galera/r/galera_wan.result index 6be32b291e5..73100636a0d 100644 --- a/mysql-test/suite/galera/r/galera_wan.result +++ b/mysql-test/suite/galera/r/galera_wan.result @@ -1,9 +1,14 @@ SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 +connection node_1; CREATE TABLE t1 (f1 INTEGER); +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; INSERT INTO t1 VALUES (1); CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); +connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4; +connection node_4; SELECT VARIABLE_VALUE LIKE '%gmcast.segment = 3%' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'wsrep_provider_options'; VARIABLE_VALUE LIKE '%gmcast.segment = 3%' 1 diff --git a/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result b/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result index e3f2fa4046f..ca388496794 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result +++ b/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result @@ -16,6 +16,7 @@ VARIABLE_VALUE = 4 SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; VARIABLE_VALUE = 'Synced' 1 +connection node_2; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 diff --git a/mysql-test/suite/galera/r/galera_zero_length_column.result b/mysql-test/suite/galera/r/galera_zero_length_column.result index 2e6119bd1ba..572d94d6756 100644 --- a/mysql-test/suite/galera/r/galera_zero_length_column.result +++ b/mysql-test/suite/galera/r/galera_zero_length_column.result @@ -1,9 +1,11 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY , f2 VARCHAR(0)) ENGINE=InnoDB; CREATE TABLE t2 (f1 VARCHAR(0)) ENGINE=InnoDB; INSERT INTO t1 VALUES (1, NULL); INSERT INTO t1 VALUES (2, ''); INSERT INTO t2 VALUES (NULL); INSERT INTO t2 VALUES (''); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 @@ -25,6 +27,7 @@ f1 = '' UPDATE t1 SET f2 = '' WHERE f1 = 1; UPDATE t1 SET f2 = NULL WHERE f1 = 2; UPDATE t2 SET f1 = '' WHERE f1 IS NULL; +connection node_1; SELECT f2 = '' FROM t1 WHERE f1 = 1; f2 = '' 1 diff --git a/mysql-test/suite/galera/r/grant.result b/mysql-test/suite/galera/r/grant.result index 8d257e7e8e2..a2ca72ee8ec 100644 --- a/mysql-test/suite/galera/r/grant.result +++ b/mysql-test/suite/galera/r/grant.result @@ -3,6 +3,7 @@ # # On node_1 +connection node_1; GRANT SELECT ON *.* TO 'user_6266'@'localhost' IDENTIFIED BY 'pass'; # Now, try changing password for 'user_6266'. This command should also @@ -10,8 +11,11 @@ GRANT SELECT ON *.* TO 'user_6266'@'localhost' IDENTIFIED BY 'pass'; SET PASSWORD FOR 'user_6266'@'localhost' = PASSWORD('newpass'); # On node_2 +connection node_2; SELECT user FROM mysql.user WHERE user='user_6266'; user user_6266 DROP USER 'user_6266'@'localhost'; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/lp1276424.result b/mysql-test/suite/galera/r/lp1276424.result index 5f09ec9ea8b..363758e0d66 100644 --- a/mysql-test/suite/galera/r/lp1276424.result +++ b/mysql-test/suite/galera/r/lp1276424.result @@ -1,6 +1,7 @@ CREATE TABLE t1 (f1 INT DEFAULT NULL, UNIQUE KEY i1 (f1)) ENGINE=InnoDB; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 diff --git a/mysql-test/suite/galera/r/lp1438990.result b/mysql-test/suite/galera/r/lp1438990.result index b53bc186953..d48d2435faa 100644 --- a/mysql-test/suite/galera/r/lp1438990.result +++ b/mysql-test/suite/galera/r/lp1438990.result @@ -1,3 +1,4 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); CREATE TABLE t2 (f1 INTEGER PRIMARY KEY); CREATE TABLE t3 (f1 INTEGER PRIMARY KEY); diff --git a/mysql-test/suite/galera/r/mdev_9290.result b/mysql-test/suite/galera/r/mdev_9290.result index cb2f0813333..276ab9e8ecb 100644 --- a/mysql-test/suite/galera/r/mdev_9290.result +++ b/mysql-test/suite/galera/r/mdev_9290.result @@ -2,13 +2,18 @@ # MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353 # InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno # +connection node_1; CREATE TABLE t1 (i INT) ENGINE=InnoDB; +connection node_2; START TRANSACTION; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); COMMIT; +connection node_1; SELECT * FROM t1; i 1 2 DROP TABLE t1; +disconnect node_2; +disconnect node_1; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#110.result b/mysql-test/suite/galera/r/mysql-wsrep#110.result index 551c3666fb4..6d4031d71cd 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#110.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#110.result @@ -1,3 +1,4 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); CREATE TABLE t2 (f1 INTEGER PRIMARY KEY); CREATE TABLE t3 (f1 INTEGER PRIMARY KEY); @@ -23,6 +24,7 @@ COUNT(*) = 1 SELECT COUNT(*) = 1 FROM t3; COUNT(*) = 1 1 +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 @@ -32,6 +34,7 @@ COUNT(*) = 1 SELECT COUNT(*) = 1 FROM t3; COUNT(*) = 1 1 +connection node_1; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#198.result b/mysql-test/suite/galera/r/mysql-wsrep#198.result index 25ba2cb615c..afc2a07fb30 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#198.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#198.result @@ -1,16 +1,26 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; LOCK TABLE t2 WRITE; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2a; OPTIMIZE TABLE t1,t2;; +connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2b; REPAIR TABLE t1,t2;; +connection node_2; SET SESSION wsrep_sync_wait = 0; +connection node_1; INSERT INTO t2 VALUES (1); +connection node_2; UNLOCK TABLES; +connection node_2a; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK test.t2 optimize note Table does not support optimize, doing recreate + analyze instead test.t2 optimize status OK +connection node_2b; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair test.t2 repair note The storage engine for the table doesn't support repair diff --git a/mysql-test/suite/galera/r/mysql-wsrep#201.result b/mysql-test/suite/galera/r/mysql-wsrep#201.result index 1c0998e35ac..0f2980eddd2 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#201.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#201.result @@ -1,4 +1,5 @@ CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; INSERT INTO t1 VALUES (DEFAULT); +connection node_2; SET GLOBAL query_cache_size=1355776; SET SESSION wsrep_sync_wait = 7; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#237.result b/mysql-test/suite/galera/r/mysql-wsrep#237.result index 3fd9aed1480..19503dd5781 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#237.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#237.result @@ -1,10 +1,18 @@ CREATE TABLE t (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +connection node_1; SET DEBUG_SYNC = 'wsrep_before_replication WAIT_FOR continue'; INSERT INTO t values (1);; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; SET SESSION wsrep_sync_wait = 0; +connection node_2; FLUSH TABLES; +connection node_1a; SELECT SLEEP(1); SLEEP(1) 0 SET DEBUG_SYNC= 'now SIGNAL continue'; +connection node_1; DROP TABLE t; +connection node_1a; +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#247.result b/mysql-test/suite/galera/r/mysql-wsrep#247.result index 1b00f511f03..e59c6d1a299 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#247.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#247.result @@ -1,3 +1,4 @@ +connection node_1; SET GLOBAL wsrep_desync=1; SET wsrep_OSU_method=RSU; CREATE TABLE t1 (i int primary key); diff --git a/mysql-test/suite/galera/r/mysql-wsrep#31.result b/mysql-test/suite/galera/r/mysql-wsrep#31.result index a21bb3eccfd..973f11543fa 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#31.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#31.result @@ -1,10 +1,13 @@ +connection node_1; CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; INSERT INTO t1 VALUES('test'); CREATE DATABASE db; +connection node_2; Shutting down server 2 ... Recovering server 2 ... Performing --wsrep-recover ... Restarting server ... Using --wsrep-start-position when starting mysqld ... +connection node_1; DROP TABLE t1; DROP DATABASE db; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#33.result b/mysql-test/suite/galera/r/mysql-wsrep#33.result index 62af519ad32..fc647a2000d 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#33.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#33.result @@ -1,4 +1,5 @@ Setting SST method to mysqldump ... +CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; SET GLOBAL wsrep_sst_method = 'mysqldump'; diff --git a/mysql-test/suite/galera/r/partition.result b/mysql-test/suite/galera/r/partition.result index 3907b4f08c9..15f0275a04c 100644 --- a/mysql-test/suite/galera/r/partition.result +++ b/mysql-test/suite/galera/r/partition.result @@ -13,10 +13,12 @@ SELECT * FROM t1; pk i # On node_1 +connection node_1; SELECT * FROM t1; pk i # On node_2 +connection node_2; SELECT * FROM t1; pk i DROP TABLE t1; @@ -26,6 +28,7 @@ DROP TABLE t1; # # On node_1 +connection node_1; CREATE TABLE test.t1 ( i INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (i) @@ -46,6 +49,7 @@ i 9 # On node_2 +connection node_2; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -70,15 +74,18 @@ i 9 # On node_1 +connection node_1; ALTER TABLE t1 TRUNCATE PARTITION p2; SELECT * FROM test.t1; i # On node_2 +connection node_2; SELECT * FROM test.t1; i # On node_1 +connection node_1; ALTER TABLE t1 DROP PARTITION p2; SHOW CREATE TABLE t1; Table Create Table @@ -91,6 +98,7 @@ t1 CREATE TABLE `t1` ( PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ # On node_2 +connection node_2; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -104,11 +112,13 @@ DROP TABLE t1, p1; # # MDEV-5146: Bulk loads into partitioned table not working # +connection node_1; # Case 1: wsrep_load_data_splitting = ON & LOAD DATA with 20002 # entries. SET GLOBAL wsrep_load_data_splitting = ON; CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +connection node_2; SELECT COUNT(*) = 20002 FROM t1; COUNT(*) = 20002 1 @@ -116,9 +126,11 @@ wsrep_last_committed_diff 1 DROP TABLE t1; # Case 2: wsrep_load_data_splitting = ON & LOAD DATA with 101 entries. +connection node_1; SET GLOBAL wsrep_load_data_splitting = ON; CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +connection node_2; SELECT COUNT(*) = 101 FROM t1; COUNT(*) = 101 1 @@ -127,14 +139,19 @@ wsrep_last_committed_diff DROP TABLE t1; # Case 3: wsrep_load_data_splitting = OFF & LOAD DATA with 20002 # entries. +connection node_1; SET GLOBAL wsrep_load_data_splitting = OFF; CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB PARTITION BY HASH(pk) PARTITIONS 2; +connection node_2; SELECT COUNT(*) = 20002 FROM t1; COUNT(*) = 20002 1 wsrep_last_committed_diff 1 DROP TABLE t1; +connection node_1; SET GLOBAL wsrep_load_data_splitting = 1;; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/rename.result b/mysql-test/suite/galera/r/rename.result index 3c81e8b6320..a7ec431657b 100644 --- a/mysql-test/suite/galera/r/rename.result +++ b/mysql-test/suite/galera/r/rename.result @@ -2,6 +2,7 @@ # MDEV-8598 : Failed MySQL DDL commands and Galera replication # # On node 1 +connection node_1; USE test; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1(i INT) ENGINE=INNODB; @@ -13,6 +14,8 @@ i CREATE USER foo@localhost; GRANT SELECT on test.* TO foo@localhost; # Open connection to the 1st node using 'test_user1' user. +connect foo_node_1,localhost,foo,,test,$port_1,; +connection foo_node_1; SELECT * FROM t1; i 1 @@ -20,20 +23,24 @@ i RENAME TABLE t1 TO t2; ERROR 42000: DROP, ALTER command denied to user 'foo'@'localhost' for table 't1' # On node 2 +connection node_2; USE test; SELECT * FROM t1; i 1 # On node_1 +connection node_1; RENAME TABLE t1 TO t2; SHOW TABLES; Tables_in_test t2 # On node 2 +connection node_2; USE test; SELECT * FROM t2; i 1 +connection node_1; DROP USER foo@localhost; DROP TABLE t2; # End of tests diff --git a/mysql-test/suite/galera/r/rpl_row_annotate.result b/mysql-test/suite/galera/r/rpl_row_annotate.result index ff8d49702ac..23de06f015b 100644 --- a/mysql-test/suite/galera/r/rpl_row_annotate.result +++ b/mysql-test/suite/galera/r/rpl_row_annotate.result @@ -1,14 +1,18 @@ # On node_2 +connection node_2; RESET MASTER; # On node_1 +connection node_1; RESET MASTER; CREATE TABLE t1(i INT)ENGINE=INNODB; INSERT INTO t1 VALUES(1); DELETE FROM t1 WHERE i = 1; # On node_2 +connection node_2; INSERT INTO t1 VALUES(2); DELETE FROM t1 WHERE i = 2; # On node_1 +connection node_1; SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM <start_pos>; Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000001 # Gtid_list 1 # [] @@ -36,6 +40,7 @@ mysqld-bin.000001 # Table_map 2 # table_id: # (test.t1) mysqld-bin.000001 # Delete_rows_v1 2 # table_id: # flags: STMT_END_F mysqld-bin.000001 # Xid 2 # COMMIT /* xid= */ # On node_2 +connection node_2; SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM <start_pos>; Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000001 # Gtid_list 2 # [] @@ -63,4 +68,6 @@ mysqld-bin.000001 # Table_map 2 # table_id: # (test.t1) mysqld-bin.000001 # Delete_rows_v1 2 # table_id: # flags: STMT_END_F mysqld-bin.000001 # Xid 2 # COMMIT /* xid= */ DROP TABLE t1; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/sql_log_bin.result b/mysql-test/suite/galera/r/sql_log_bin.result index 237725ec9a7..8b208ff82d5 100644 --- a/mysql-test/suite/galera/r/sql_log_bin.result +++ b/mysql-test/suite/galera/r/sql_log_bin.result @@ -1,5 +1,6 @@ # On node_1 +connection node_1; USE test; CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=INNODB; INSERT INTO t1 VALUES (1); @@ -31,6 +32,7 @@ c1 2 # On node_2 +connection node_2; USE test; SELECT * FROM t1; c1 @@ -49,4 +51,6 @@ c1 1 2 DROP TABLE t1, t2, t3, t4; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/unique_key.result b/mysql-test/suite/galera/r/unique_key.result index ffb4f01c1f8..9f1fc858389 100644 --- a/mysql-test/suite/galera/r/unique_key.result +++ b/mysql-test/suite/galera/r/unique_key.result @@ -5,6 +5,7 @@ USE test; # On node_1 +connection node_1; CREATE TABLE t1(c1 INT DEFAULT NULL, UNIQUE KEY c1(c1)) ENGINE=INNODB; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -14,12 +15,14 @@ NULL NULL # On node_2 +connection node_2; SELECT * FROM test.t1; c1 NULL NULL # On node_1 +connection node_1; INSERT INTO t1 VALUES (1); UPDATE t1 SET c1=NULL WHERE c1=1; SELECT * FROM test.t1; @@ -29,6 +32,7 @@ NULL NULL # On node_2 +connection node_2; SELECT * FROM test.t1; c1 NULL @@ -36,12 +40,16 @@ NULL NULL # On node_1 +connection node_1; DELETE FROM t1 WHERE c1<=>NULL; SELECT * FROM test.t1; c1 # On node_2 +connection node_2; SELECT * FROM test.t1; c1 DROP TABLE t1; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/view.result b/mysql-test/suite/galera/r/view.result index 06d7bf072e8..f8da811f9cc 100644 --- a/mysql-test/suite/galera/r/view.result +++ b/mysql-test/suite/galera/r/view.result @@ -8,6 +8,7 @@ DROP VIEW v1; # MDEV-8464 : ALTER VIEW not replicated in some cases # # On node_1 +connection node_1; USE test; CREATE TABLE t1(i INT) ENGINE=INNODB; CREATE DEFINER=CURRENT_USER VIEW v1 AS SELECT * FROM t1; @@ -15,6 +16,7 @@ CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t1; CREATE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t1; CREATE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1; # On node_2 +connection node_2; USE test; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection @@ -29,11 +31,13 @@ SHOW CREATE VIEW v4; View Create View character_set_client collation_connection v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci # On node_1 +connection node_1; ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; ALTER ALGORITHM=UNDEFINED VIEW v2 AS SELECT * FROM t1; ALTER DEFINER=CURRENT_USER VIEW v3 AS SELECT * FROM t1; ALTER ALGORITHM=TEMPTABLE DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1; # On node_2 +connection node_2; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci diff --git a/mysql-test/suite/galera/t/mysql-wsrep#237.test b/mysql-test/suite/galera/t/mysql-wsrep#237.test index 7a65cb52ae9..f2dd6bce711 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#237.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#237.test @@ -29,3 +29,5 @@ SET DEBUG_SYNC= 'now SIGNAL continue'; --reap DROP TABLE t; +--connection node_1a +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/maria/maria.result b/mysql-test/suite/maria/maria.result index 1b80f5ef695..ea4e7896066 100644 --- a/mysql-test/suite/maria/maria.result +++ b/mysql-test/suite/maria/maria.result @@ -554,11 +554,11 @@ a explain select sql_big_result distinct t1.a from t1,t2 order by t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary -1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct +1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index explain select distinct t1.a from t1,t2 order by t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary -1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct +1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index drop table t1,t2; create table t1 ( c1 varchar(32), diff --git a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result index 5e16befa87d..889db65d7ef 100644 --- a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result +++ b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result @@ -116,7 +116,6 @@ include/wait_for_slave_sql_to_start.inc # SAVEPOINT and ROLLBACK TO have the same problem in BUG#43263 # This was reported by BUG#50407 connection master; -SET SESSION AUTOCOMMIT=0 BEGIN; INSERT INTO db1.t1 VALUES(20); # @@ -164,7 +163,6 @@ master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t2 VALUES("after rollba master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t1 VALUES(50) master-bin.000001 # Xid # # COMMIT /* XID */ connection slave; -[on slave] # # Verify INSERT statements in savepoints are executed, for MyISAM table # is not effected by ROLLBACK TO diff --git a/mysql-test/suite/rpl/r/rpl_upgrade_master_info.result b/mysql-test/suite/rpl/r/rpl_upgrade_master_info.result new file mode 100644 index 00000000000..3e737267fbd --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_upgrade_master_info.result @@ -0,0 +1,102 @@ +include/master-slave.inc +[connection master] +*** MDEV-9383: Server fails to read master.info after upgrade 10.0 -> 10.1 *** +connection slave; +include/stop_slave.inc +CHANGE MASTER TO master_use_gtid=CURRENT_POS; +include/rpl_stop_server.inc [server_number=2] +include/rpl_start_server.inc [server_number=2] +connection master; +CREATE TABLE t1 (a INT PRIMARY KEY); +INSERT INTO t1 VALUES (1); +include/save_master_gtid.inc +connection slave; +CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1; +include/start_slave.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1; +a +1 +include/stop_slave.inc +include/rpl_stop_server.inc [server_number=2] +include/rpl_start_server.inc [server_number=2] +connection master; +INSERT INTO t1 VALUES (2); +include/save_master_gtid.inc +connection slave; +CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1; +include/start_slave.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +include/stop_slave.inc +include/rpl_stop_server.inc [server_number=2] +include/rpl_start_server.inc [server_number=2] +connection master; +INSERT INTO t1 VALUES (3); +include/save_master_gtid.inc +connection slave; +CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1; +include/start_slave.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +include/stop_slave.inc +include/rpl_stop_server.inc [server_number=2] +include/rpl_start_server.inc [server_number=2] +connection master; +INSERT INTO t1 VALUES (4); +include/save_master_gtid.inc +connection slave; +CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1; +include/start_slave.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +include/stop_slave.inc +include/rpl_stop_server.inc [server_number=2] +include/rpl_start_server.inc [server_number=2] +connection master; +INSERT INTO t1 VALUES (5); +include/save_master_gtid.inc +connection slave; +CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1; +include/start_slave.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +include/stop_slave.inc +include/rpl_stop_server.inc [server_number=2] +include/rpl_start_server.inc [server_number=2] +connection master; +INSERT INTO t1 VALUES (6); +include/save_master_gtid.inc +connection slave; +CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1; +include/start_slave.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +6 +connection master; +DROP TABLE t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test index 347e88412c1..f0ed5dc0123 100644 --- a/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test +++ b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test @@ -129,7 +129,6 @@ source include/wait_for_slave_sql_to_start.inc; --echo # SAVEPOINT and ROLLBACK TO have the same problem in BUG#43263 --echo # This was reported by BUG#50407 connection master; -echo SET SESSION AUTOCOMMIT=0; let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1); BEGIN; @@ -157,7 +156,6 @@ COMMIT; source include/show_binlog_events.inc; sync_slave_with_master; ---echo [on slave] --echo # --echo # Verify INSERT statements in savepoints are executed, for MyISAM table --echo # is not effected by ROLLBACK TO diff --git a/mysql-test/suite/rpl/t/rpl_upgrade_master_info.test b/mysql-test/suite/rpl/t/rpl_upgrade_master_info.test new file mode 100644 index 00000000000..e81e7c0d714 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_upgrade_master_info.test @@ -0,0 +1,163 @@ +--source include/master-slave.inc + +--echo *** MDEV-9383: Server fails to read master.info after upgrade 10.0 -> 10.1 *** + +--connection slave +--source include/stop_slave.inc +CHANGE MASTER TO master_use_gtid=CURRENT_POS; +--let $datadir= `SELECT @@datadir` + +--let $rpl_server_number= 2 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master.info +--copy_file $MYSQL_TEST_DIR/std_data/bad_master.info $datadir/master.info + +--let $rpl_server_number= 2 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +--connection master +CREATE TABLE t1 (a INT PRIMARY KEY); +INSERT INTO t1 VALUES (1); +--source include/save_master_gtid.inc + +--connection slave +# Fix the port after we replaced master.info. +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1; + +--source include/stop_slave.inc + +--let $rpl_server_number= 2 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master.info +--copy_file $MYSQL_TEST_DIR/std_data/bad2_master.info $datadir/master.info + +--let $rpl_server_number= 2 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +--connection master +INSERT INTO t1 VALUES (2); +--source include/save_master_gtid.inc + +--connection slave +# Fix the port after we replaced master.info. +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--source include/stop_slave.inc + +--let $rpl_server_number= 2 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master.info +--copy_file $MYSQL_TEST_DIR/std_data/bad3_master.info $datadir/master.info + +--let $rpl_server_number= 2 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +--connection master +INSERT INTO t1 VALUES (3); +--source include/save_master_gtid.inc + +--connection slave +# Fix the port after we replaced master.info. +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--source include/stop_slave.inc + +--let $rpl_server_number= 2 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master.info +--copy_file $MYSQL_TEST_DIR/std_data/bad4_master.info $datadir/master.info + +--let $rpl_server_number= 2 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +--connection master +INSERT INTO t1 VALUES (4); +--source include/save_master_gtid.inc + +--connection slave +# Fix the port after we replaced master.info. +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--source include/stop_slave.inc + +--let $rpl_server_number= 2 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master.info +--copy_file $MYSQL_TEST_DIR/std_data/bad5_master.info $datadir/master.info + +--let $rpl_server_number= 2 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +--connection master +INSERT INTO t1 VALUES (5); +--source include/save_master_gtid.inc + +--connection slave +# Fix the port after we replaced master.info. +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--source include/stop_slave.inc + +--let $rpl_server_number= 2 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master.info +--copy_file $MYSQL_TEST_DIR/std_data/bad6_master.info $datadir/master.info + +--let $rpl_server_number= 2 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +--connection master +INSERT INTO t1 VALUES (6); +--source include/save_master_gtid.inc + +--connection slave +# Fix the port after we replaced master.info. +--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 +eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + + +# Cleanup +--connection master +DROP TABLE t1; +--source include/rpl_end.inc diff --git a/mysql-test/t/connect2.test b/mysql-test/t/connect2.test index b4614a65a91..9d2a438aa0a 100644 --- a/mysql-test/t/connect2.test +++ b/mysql-test/t/connect2.test @@ -7,7 +7,7 @@ call mtr.add_suppression("Allocation failed"); SET @old_debug= @@session.debug; set @old_thread_cache_size=@@global.thread_cache_size; - +set @@global.thread_cache_size=0; # Test connections to the connect(con1,localhost,root,,test,,); @@ -32,7 +32,6 @@ select 1; disconnect con1; # Test connections to the extra port. - connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); select 1; disconnect con1; diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test index 5a6e07e0c0c..e3164f53887 100644 --- a/mysql-test/t/cte_nonrecursive.test +++ b/mysql-test/t/cte_nonrecursive.test @@ -434,3 +434,17 @@ with t(f1,f1) as (select * from t1 where b >= 'c') select t1.b from t2,t1 where t1.a = t2.c; drop table t1,t2; + +--echo # +--echo # Bug mdev-9937: View used in the specification of with table +--echo # refers to the base table with the same name +--echo # + +create table t1 (a int); +insert into t1 values (20), (30), (10); +create view v1 as select * from t1 where a > 10; + +with t1 as (select * from v1) select * from t1; + +drop view v1; +drop table t1; diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test new file mode 100644 index 00000000000..34eee6d3bf2 --- /dev/null +++ b/mysql-test/t/cte_recursive.test @@ -0,0 +1,241 @@ +create table t1 (a int, b varchar(32)); +insert into t1 values +(4,'aaaa' ), (7,'bb'), (1,'ccc'), (4,'dd'); +insert into t1 values +(3,'eee'), (7,'bb'), (1,'fff'), (4,'ggg'); + +--ERROR 1984 +with recursive +a1(a,b) as +(select * from t1 where t1.a>3 +union +select * from b1 where b1.a >3 +union +select * from c1 where c1.a>3), +b1(a,b) as +(select * from a1 where a1.b > 'ccc' +union +select * from c1 where c1.b > 'ddd'), +c1(a,b) as +(select * from a1 where a1.a<6 and a1.b< 'zz' +union +select * from b1 where b1.b > 'auu') +select * from c1; + +drop table t1; + +create table folks(id int, name char(32), dob date, father int, mother int); + +insert into folks values +(100, 'Vasya', '2000-01-01', 20, 30), +(20, 'Dad', '1970-02-02', 10, 9), +(30, 'Mom', '1975-03-03', 8, 7), +(10, 'Grandpa Bill', '1940-04-05', null, null), +(9, 'Grandma Ann', '1941-10-15', null, null), +(25, 'Uncle Jim', '1968-11-18', 8, 7), +(98, 'Sister Amy', '2001-06-20', 20, 30), +(8, 'Grandma Sally', '1943-08-23', 5, 6), +(6, 'Grandgrandma Martha', '1923-05-17', null, null), +(67, 'Cousin Eddie', '1992-02-28', 25, 27), +(27, 'Auntie Melinda', '1971-03-29', null, null); + + +with recursive +ancestors +as +( + select * + from folks + where name = 'Vasya' and dob = '2000-01-01' + union + select p.id, p.name, p.dob, p.father, p.mother + from folks as p, ancestors AS a + where p.id = a.father or p.id = a.mother +) +select * from ancestors; + +with recursive +ancestors +as +( + select p.* + from folks as p, ancestors AS a + where p.id = a.father or p.id = a.mother + union + select * + from folks + where name = 'Vasya' and dob = '2000-01-01' +) +select * from ancestors; + +with recursive +ancestors +as +( + select * + from folks + where name = 'Cousin Eddie' + union + select p.* + from folks as p, ancestors as a + where p.id = a.father or p.id = a.mother +) +select * from ancestors; + +with recursive +ancestors +as +( + select * + from folks + where name = 'Vasya' or name='Sister Amy' + union + select p.* + from folks as p, ancestors as a + where p.id = a.father or p.id = a.mother +) +select * from ancestors; + +with recursive +prev_gen +as +( + select folks.* + from folks, prev_gen + where folks.id=prev_gen.father or folks.id=prev_gen.mother + union + select * + from folks + where name='Vasya' +), +ancestors +as +( + select * + from folks + where name='Vasya' + union + select * + from ancestors + union + select * + from prev_gen +) +select ancestors.name, ancestors.dob from ancestors; + + +with recursive +descendants +as +( + select * + from folks + where name = 'Grandpa Bill' + union + select folks.* + from folks, descendants as d + where d.id=folks.father or d.id=folks.mother +) +select * from descendants; + +with recursive +descendants +as +( + select * + from folks + where name = 'Grandma Sally' + union + select folks.* + from folks, descendants as d + where d.id=folks.father or d.id=folks.mother +) +select * from descendants; + + +with recursive +ancestors +as +( + select * + from folks + where name = 'Vasya' and dob = '2000-01-01' + union + select p.* + from folks as p, ancestors AS a + where p.id = a.father OR p.id = a.mother +) +select * + from ancestors t1, ancestors t2 + where exists (select * from ancestors a + where a.father=t1.id AND a.mother=t2.id); + +with +ancestor_couples(husband, h_dob, wife, w_dob) +as +( +with recursive +ancestors +as +( + select * + from folks + where name = 'Vasya' + union + select p.* + from folks as p, ancestors AS a + where p.id = a.father OR p.id = a.mother +) +select t1.name, t1.dob, t2.name, t2.dob + from ancestors t1, ancestors t2 + where exists (select * from ancestors a + where a.father=t1.id AND a.mother=t2.id) +) +select * from ancestor_couples; + +with recursive +ancestors +as +( + select * + from folks + where name = 'Vasya' and dob = '2000-01-01' + union + select p.* + from folks as p, ancestors AS a + where p.id = a.father + union + select p.* + from folks as p, ancestors AS a + where p.id = a.mother +) +select * from ancestors; + +with recursive +ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, + w_id, w_name, w_dob, w_father, w_mother) +as +( + select h.*, w.* + from folks h, folks w, coupled_ancestors a + where a.father = h.id AND a.mother = w.id + union + select h.*, w.* + from folks v, folks h, folks w + where v.name = 'Vasya' and + (v.father = h.id AND v.mother= w.id) +), +coupled_ancestors (id, name, dob, father, mother) +as +( + select h_id, h_name, h_dob, h_father, h_mother + from ancestor_couples + union + select w_id, w_name, w_dob, w_father, w_mother + from ancestor_couples +) +select h_name, h_dob, w_name, w_dob + from ancestor_couples; + +drop table folks; + diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test index d533e38b2a2..b5bd92d1d07 100644 --- a/mysql-test/t/ctype_eucjpms.test +++ b/mysql-test/t/ctype_eucjpms.test @@ -566,3 +566,19 @@ DROP TABLE t1; --echo # --echo # End of 10.1 tests --echo # + +--echo # +--echo # End of 10.2 tests +--echo # + +--echo # +--echo # MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +--echo # +CREATE TABLE t1 (a TEXT CHARACTER SET eucjpms); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.ujis.txt' INTO TABLE t1 CHARACTER SET eucjpms IGNORE 4 LINES; +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/t/ctype_gbk_export_import.test b/mysql-test/t/ctype_gbk_export_import.test new file mode 100644 index 00000000000..02d18fe60d4 --- /dev/null +++ b/mysql-test/t/ctype_gbk_export_import.test @@ -0,0 +1,161 @@ +--source include/not_windows.inc +--source include/have_case_sensitive_file_system.inc +--source include/have_gbk.inc + +# +# Check if we're running on a POSIX-locale machine +# + +--disable_query_log +--exec locale -a > $MYSQLTEST_VARDIR/tmp/locale_a_gbk.output 2>/dev/null || true +SET @file=REPLACE(LOAD_FILE('../../tmp/locale_a_gbk.output'), '-', ''); +# Note, file content must be case sensitive. See mysql_locale_posix.test +--remove_file $MYSQLTEST_VARDIR/tmp/locale_a_gbk.output +if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nzh_CN.gbk\n%')`) +{ + Skip Need POSIX locale zh_CN.gbk; +} +--enable_query_log + + +--disable_warnings +DROP DATABASE IF EXISTS gbk; +--enable_warnings + +CREATE DATABASE gbk DEFAULT CHARACTER SET gbk; +USE gbk; + +CREATE TABLE t1 ( + id INT NOT NULL, + a1 TEXT NOT NULL, + a2 TEXT CHARACTER SET utf8 NOT NULL, + b1 BLOB NOT NULL, + eol TEXT NOT NULL); + +DELIMITER |; +CREATE PROCEDURE populate() +BEGIN + TRUNCATE TABLE t1; + INSERT INTO t1 SET id=1, a1=0xEE5C, a2=_gbk 0xEE5C, b1=0xEE5C, eol='$'; + INSERT INTO t1 SET id=2, a1=0xEE5C5C, a2=_gbk 0xEE5C5C, b1=0xEE5C5C, eol='$'; +END| + +CREATE FUNCTION cmt(id INT, field_name TEXT, field_value BLOB) + RETURNS TEXT CHARACTER SET utf8 +BEGIN + DECLARE comment TEXT CHARACTER SET utf8; + DECLARE expected_value_01 BLOB; + DECLARE expected_value_02 BLOB; + SET comment= CASE field_name WHEN 'a1' THEN 'TEXT-GBK' WHEN 'a2' THEN 'TEXT-UTF8' WHEN 'b1' THEN 'BLOB' ELSE '' END; + SET expected_value_01= CASE field_name WHEN 'a1' THEN 0xEE5C WHEN 'a2' THEN 0xE9A0AB WHEN 'b1' THEN 0xEE5C ELSE '' END; + SET expected_value_02= CASE field_name WHEN 'a1' THEN 0xEE5C5C WHEN 'a2' THEN 0xE9A0AB5C WHEN 'b1' THEN 0xEE5C5C ELSE '' END; + RETURN IF(CASE id + WHEN 1 THEN expected_value_01 + WHEN 2 THEN expected_value_02 + ELSE '' + END <> field_value, + CONCAT('BAD-', comment), ''); +END| + +CREATE FUNCTION display_file(file BLOB) RETURNS TEXT CHARACTER SET utf8 +BEGIN + SET file=REPLACE(file, 0x09, '----'); + SET file=REPLACE(file, 0x0A, '++++'); + RETURN REPLACE(REPLACE(HEX(file), '2D2D2D2D','-'), '2B2B2B2B','|'); +END| + +DELIMITER ;| + +CREATE VIEW v1 AS +SELECT + id, + CONCAT(RPAD(HEX(a1),50,' '), cmt(id, 'a1', a1)) AS a1, + CONCAT(RPAD(HEX(a2),50,' '), cmt(id, 'a2', a2)) AS a2, + CONCAT(RPAD(HEX(b1),50,' '), cmt(id, 'b1', b1)) AS b1, + CONCAT(RPAD(HEX(eol),50,' '), IF(eol<>'$','BAD-EOL','')) AS eol, + '---' AS `---` +FROM t1; +SHOW CREATE TABLE t1; + +--echo # +--echo # Dump using SELECT INTO OUTFILE +--echo # + +--perl +my $dir= $ENV{'MYSQL_TMP_DIR'}; +open (my $FILE, '>', "$dir/tmpgbk.inc") or die "open(): $!"; +for $LOCALE ("zh_CN.gbk") { +for $DUMP_OPTIONS ("--default-character-set=auto", "--default-character-set=gbk","--default-character-set=utf8") { +for $DUMP_CHARSET_CLAUSE ("", "CHARACTER SET gbk", "CHARACTER SET utf8", "CHARACTER SET binary") { +for $RESTORE_OPTIONS ("--default-character-set=auto", "--default-character-set=gbk","--default-character-set=utf8") { +for $RESTORE_CHARSET_CLAUSE ("", "CHARACTER SET gbk", "CHARACTER SET utf8", "CHARACTER SET binary") { +print $FILE <<END +--echo Start of {$LOCALE}{$DUMP_OPTIONS $DUMP_CHARSET_CLAUSE}{$RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE} +--echo Locale: $LOCALE +--echo OUTFILE: $DUMP_OPTIONS $DUMP_CHARSET_CLAUSE +--echo INFILE: $RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE +--disable_query_log +CALL populate(); +--exec LC_ALL=$LOCALE \$MYSQL $DUMP_OPTIONS gbk -e "SELECT * INTO OUTFILE '\$MYSQLTEST_VARDIR/tmp/t1' $DUMP_CHARSET_CLAUSE FROM t1" +--vertical_results +TRUNCATE TABLE t1; +--eval SELECT display_file(LOAD_FILE('\$MYSQLTEST_VARDIR/tmp/t1')) AS file; +--exec LC_ALL=$LOCALE \$MYSQL $RESTORE_OPTIONS gbk -e "LOAD DATA INFILE '\$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t1 $RESTORE_CHARSET_CLAUSE" +SELECT * FROM v1; +--echo End of {$LOCALE}{$DUMP_OPTIONS $DUMP_CHARSET_CLAUSE}{$RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE} +--echo +--echo +--horizontal_results +--enable_query_log +--remove_file \$MYSQLTEST_VARDIR/tmp/t1 +END +}}}}} +close $FILE +EOF +--source $MYSQL_TMP_DIR/tmpgbk.inc +--remove_file $MYSQL_TMP_DIR/tmpgbk.inc + + +--echo # +--echo # Dump using mysqldump -Tdir +--echo # + +--exec mkdir $MYSQLTEST_VARDIR/tmp/tmpgbk +--perl +my $dir= $ENV{'MYSQL_TMP_DIR'}; +open (my $FILE, '>', "$dir/tmpgbk.inc") or die "open(): $!"; +for $LOCALE ("zh_CN.gbk") { +for $DUMP_OPTIONS ("--default-character-set=binary","--default-character-set=gbk","--default-character-set=utf8") { +for $RESTORE_OPTIONS ("--default-character-set=auto","--default-character-set=binary","--default-character-set=gbk","--default-character-set=utf8") { +for $RESTORE_CHARSET_CLAUSE ("", "CHARACTER SET gbk", "CHARACTER SET utf8", "CHARACTER SET binary") { +print $FILE <<END +--echo Start of {$LOCALE}{$DUMP_OPTIONS}{$RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE} +--echo Locale: $LOCALE +--echo mysqldump: $DUMP_OPTIONS +--echo INFILE: $RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE +--disable_query_log +CALL populate(); +--exec LC_ALL=$LOCALE \$MYSQL_DUMP $DUMP_OPTIONS -T\$MYSQLTEST_VARDIR/tmp/tmpgbk gbk t1 +--vertical_results +TRUNCATE TABLE t1; +--eval SELECT display_file(LOAD_FILE('\$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.txt')) AS file; +--exec LC_ALL=$LOCALE \$MYSQL $RESTORE_OPTIONS gbk -e "LOAD DATA INFILE '\$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.txt' INTO TABLE t1 $RESTORE_CHARSET_CLAUSE" +SELECT * FROM v1; +--echo End of {$LOCALE}{$DUMP_OPTIONS}{$RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE} +--echo +--echo +--horizontal_results +--enable_query_log +--remove_file \$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.txt +--remove_file \$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.sql +END +}}}} +close $FILE +EOF +--source $MYSQL_TMP_DIR/tmpgbk.inc +--remove_file $MYSQL_TMP_DIR/tmpgbk.inc +--rmdir $MYSQLTEST_VARDIR/tmp/tmpgbk + + +DROP DATABASE gbk; +USE test; diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 3f444580b13..db85585efd9 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -1396,3 +1396,20 @@ SELECT HEX(a) FROM t1 ORDER BY a;DROP TABLE t1; --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # End of 10.2 tests +--echo # + +--echo # +--echo # MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +--echo # +CREATE TABLE t1 (a TEXT CHARACTER SET ujis); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.ujis.txt' INTO TABLE t1 CHARACTER SET ujis IGNORE 4 LINES; +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index f3a9e63b57d..61bc1c58ecb 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1967,5 +1967,21 @@ SELECT c1 FROM t1; DROP TABLE t1; --echo # +--echo # MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +--echo # +CREATE TABLE t1 (a TEXT CHARACTER SET utf8); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.utf8mb4.txt' INTO TABLE t1 CHARACTER SET utf8 IGNORE 4 LINES; +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-9874 LOAD XML INFILE does not handle well broken multi-byte characters +--echo # +CREATE TABLE t1 (a TEXT CHARACTER SET utf8); +LOAD XML INFILE '../../std_data/loaddata/mdev9874.xml' INTO TABLE t1 CHARACTER SET utf8 ROWS IDENTIFIED BY '<row>'; +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 2fe9b5e6544..74e39a80e5b 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1919,3 +1919,20 @@ DROP FUNCTION f1; --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # End of 10.2 tests +--echo # + +--echo # +--echo # MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis +--echo # +CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4); +LOAD DATA INFILE '../../std_data/loaddata/mdev9823.utf8mb4.txt' INTO TABLE t1 CHARACTER SET utf8mb4 IGNORE 4 LINES; +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 85f28de128b..dea16c84a51 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -1,5 +1,12 @@ # delayed works differently in embedded server --source include/not_embedded.inc +# Don't test this under valgrind, memory leaks will occur +--source include/not_valgrind.inc +# Avoid CrashReporter popup on Mac +--source include/not_crashrep.inc +# Binary must be compiled with debug for crash to occur +--source include/have_debug_sync.inc + # # test of DELAYED insert and timestamps # (Can't be tested with purify :( ) @@ -601,3 +608,37 @@ disconnect con1; --source include/wait_until_disconnected.inc connection default; drop tables tm, t1, t2; + +--echo # +--echo # MDEV-9621 INSERT DELAYED fails on insert for tables with many columns +--echo # + +CREATE TABLE t1 ( + a int,b int,c int,d int,e int,f int,g int,h int,i int,j int,k int,l int,m int,n int,o int,p int,q int,r int,s int,t int,u int,v int,x int,y int,z int +) ENGINE=MyISAM; + +INSERT DELAYED INTO t1 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z) +values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +INSERT DELAYED INTO t1 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z) +values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +drop table t1; + +--echo # +--echo # INSERT DELAYED hangs if table was crashed +--echo # + +create table t1 (a int, b int) engine=myisam; +insert into t1 values (1,1); + +# Will come back with t1 crashed. +--source include/crash_mysqld.inc + +call mtr.add_suppression(" marked as crashed and should be repaired"); +call mtr.add_suppression("Checking table"); + +--replace_result '\\' '/' +insert delayed into t1 values (2,2); +insert delayed into t1 values (3,3); +flush tables t1; +select * from t1; +drop table t1; diff --git a/mysql-test/t/func_analyse.test b/mysql-test/t/func_analyse.test index c77967a0cc9..6c30c0ca630 100644 --- a/mysql-test/t/func_analyse.test +++ b/mysql-test/t/func_analyse.test @@ -11,7 +11,7 @@ insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6 select count(*) from t1 procedure analyse(); select * from t1 procedure analyse(); select * from t1 procedure analyse(2); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR create table t2 select * from t1 procedure analyse(); drop table t1; @@ -127,7 +127,7 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1),(2); --echo # should not crash ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE(); DROP TABLE t1; @@ -157,3 +157,27 @@ SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE(); DROP TABLE t1, t2; --echo End of 5.1 tests + +--echo # +--echo # Start of 10.2 tests +--echo # +(SELECT 1 FROM DUAL PROCEDURE ANALYSE()); +((SELECT 1 FROM DUAL PROCEDURE ANALYSE())); + +# TODO: +--error ER_WRONG_USAGE +SELECT * FROM t1 UNION SELECT * FROM t1 PROCEDURE analyse(); + +--echo # +--echo # MDEV-10030 sql_yacc.yy: Split table_expression and remove PROCEDURE from create_select, select_paren_derived, select_derived2, query_specification +--echo # + +--error ER_PARSE_ERROR +SELECT * FROM (SELECT * FROM t1 PROCEDURE ANALYSE()); +--ERROR ER_PARSE_ERROR +SELECT * FROM t1 NATURAL JOIN (SELECT * FROM t2 PROCEDURE ANALYSE()); + +--error ER_PARSE_ERROR +SELECT (SELECT 1 FROM t1 PROCEDURE ANALYSE()) FROM t2; +--error ER_PARSE_ERROR +SELECT ((SELECT 1 FROM t1 PROCEDURE ANALYSE())) FROM t2; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index fe9308cd20a..f0007186ab2 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -996,8 +996,33 @@ EXPLAIN SELECT a FROM t1 WHERE a < 2 ORDER BY a; EXPLAIN SELECT a FROM t1 WHERE a < 2 GROUP BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); + +--echo # +--echo # For this explain, the query plan is weird: if we are using +--echo # the primary key for reasons other than doing grouping, can't +--echo # GROUP BY code take advantage of this? Well, currently it doesnt: EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +--echo # Here's a proof it is really doing sorting: +flush status; +--disable_result_log +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +--enable_result_log +show status like 'Sort_%'; +--echo # Proof ends. +--echo # + +--echo # For this explain, the query plan is weird: if we are using +--echo # the primary key for reasons other than doing sorting, can't +--echo # ORDER BY code take advantage of this? Well, currently it doesnt: EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +--echo # Here's a proof it is really doing sorting: +flush status; +--disable_result_log +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +--enable_result_log +show status like 'Sort_%'; +--echo # Proof ends. +--echo # SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; @@ -1793,3 +1818,13 @@ from t1 group by t1.b; drop table t0,t1,t2; + +--echo # +--echo # MDEV-9602 crash in st_key::actual_rec_per_key when group by constant +--echo # + +create table t1 (a date not null,unique (a)) engine=innodb; +select distinct a from t1 group by 'a'; +insert into t1 values("2001-02-02"),("2001-02-03"); +select distinct a from t1 group by 'a'; +drop table t1; diff --git a/mysql-test/t/limit_rows_examined.test b/mysql-test/t/limit_rows_examined.test index 45ee483c7aa..382530234be 100644 --- a/mysql-test/t/limit_rows_examined.test +++ b/mysql-test/t/limit_rows_examined.test @@ -305,7 +305,6 @@ select c1, sum(c2) from t3 group by c1; explain select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 0; select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 0; ---error 1028 select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 1; select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 20; select c1, sum(c2) from t3 group by c1 LIMIT ROWS EXAMINED 21; @@ -321,7 +320,6 @@ insert into t3i values explain select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 0; select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 0; ---error 1028 select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 1; select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 20; select c1, sum(c2) from t3i group by c1 LIMIT ROWS EXAMINED 21; @@ -432,7 +430,7 @@ drop table t1,t2,t1i,t2i; SET @@optimizer_switch='in_to_exists=on,outer_join_with_cache=on'; CREATE TABLE t1 ( a VARCHAR(3) ) ENGINE=MyISAM; -INSERT INTO t1 VALUES ('USA'); +INSERT INTO t1 VALUES ('USA'),('CAN'); CREATE TABLE t2 ( b INT ); INSERT INTO t2 VALUES (3899),(3914),(3888); diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 9ac49a9063d..a454fa25ac4 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -552,6 +552,8 @@ insert t2 select * from t1; checksum table t1, t2, t3 quick; checksum table t1, t2, t3; checksum table t1, t2, t3 extended; +alter table t1 add d int default 30, add e bigint default 300000, add f decimal(30) default 442; +checksum table t1; #show table status; drop table t1,t2; diff --git a/mysql-test/t/order_by_optimizer.test b/mysql-test/t/order_by_optimizer.test new file mode 100644 index 00000000000..a4c134afec9 --- /dev/null +++ b/mysql-test/t/order_by_optimizer.test @@ -0,0 +1,34 @@ +--disable_warnings +drop table if exists t0,t1,t2,t3; + +--enable_warnings +--echo # +--echo # MDEV-7885: EXPLAIN shows wrong info for ORDER BY query +--echo # +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; + +create table t2 (key1 int, col1 int, key(key1)); +insert into t2 select a,a from t0; +insert into t2 select 15,15 from t1; +alter table t2 add key2 int, add key(key2); +--echo # This must show "Using filesort": +explain +select * from t2 ignore index for order by (key1) where col1<0 order by key1 limit 10; + +drop table t0, t1, t2; + +--echo # +--echo # MDEV-8857: [Upstream too] EXPLAIN incorrectly shows Distinct for tables using join buffer +--echo # +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (a int, filler char(200), key(a)); +insert into t1 select A.a + B.a* 10, 'AAAAAAAAAAAAAAAAAAAA' from t0 A, t0 B where B.a in (0,1); +explain select distinct A.a from t0 A, t1 B where A.a+B.a> 0; + +drop table t0, t1; + diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 0a19b03a4eb..86cc3c47c37 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -806,7 +806,7 @@ SELECT 1 FROM (SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 FOR UPDATE) a; ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR SELECT 1 FROM (SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 PROCEDURE ANALYSE() FOR UPDATE) a; @@ -815,7 +815,7 @@ SELECT 1 FROM t1 WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 FOR UPDATE); ---error ER_WRONG_USAGE +--error ER_PARSE_ERROR SELECT 1 FROM t1 WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 PROCEDURE ANALYSE() FOR UPDATE); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 7a7c01e78bd..5313a4b8a39 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -51,7 +51,7 @@ SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c O SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1); SELECT 1 IN (SELECT 1); SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); --- error ER_WRONG_USAGE +-- error ER_PARSE_ERROR select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); -- error ER_PARSE_ERROR SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test new file mode 100644 index 00000000000..09ddf41b4f0 --- /dev/null +++ b/mysql-test/t/win.test @@ -0,0 +1,1203 @@ +# +# Window Functions Tests +# + +--disable_warnings +drop table if exists t1,t2; +drop view if exists v1; +--enable_warnings + +--echo # ######################################################################## +--echo # # Parser tests +--echo # ######################################################################## +--echo # +--echo # Check what happens when one attempts to use window function without OVER clause +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2); + +--error ER_PARSE_ERROR +select row_number() from t1; +--error ER_PARSE_ERROR +select rank() from t1; + +--echo # Attempt to use window function in the WHERE clause +--error ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION +select * from t1 where 1=rank() over (order by a); +--error ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION +select * from t1 where 1>row_number() over (partition by b order by a); +drop table t1; + +--echo # ######################################################################## +--echo # # Functionality tests +--echo # ######################################################################## +--echo # +--echo # Check if ROW_NUMBER() works in basic cases +create table t1(a int, b int, x char(32)); +insert into t1 values (2, 10, 'xx'); +insert into t1 values (2, 10, 'zz'); +insert into t1 values (2, 20, 'yy'); +insert into t1 values (3, 10, 'xxx'); +insert into t1 values (3, 20, 'vvv'); + +--sorted_result +select a, row_number() over (partition by a order by b) from t1; + +select a, b, x, row_number() over (partition by a order by x) from t1; + +drop table t1; + +create table t1 (pk int primary key, a int, b int); +insert into t1 values + (1, 10, 22), + (2, 11, 21), + (3, 12, 20), + (4, 13, 19), + (5, 14, 18); + +select + pk, a, b, + row_number() over (order by a), + row_number() over (order by b) +from t1; + +drop table t1; + +--echo # +--echo # Try RANK() function +--echo # +create table t2 ( + pk int primary key, + a int +); + +insert into t2 values +( 1 , 0), +( 2 , 0), +( 3 , 1), +( 4 , 1), +( 8 , 2), +( 5 , 2), +( 6 , 2), +( 7 , 2), +( 9 , 4), +(10 , 4); + +select pk, a, rank() over (order by a) from t2; +select pk, a, rank() over (order by a desc) from t2; + +drop table t2; + +--echo # +--echo # Try Aggregates as window functions. With frames. +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; + +select + pk, c, + count(*) over (partition by c order by pk + rows between 2 preceding and 2 following) as CNT +from t1; + +select + pk, c, + count(*) over (partition by c order by pk + rows between 1 preceding and 2 following) as CNT +from t1; + +select + pk, c, + count(*) over (partition by c order by pk + rows between 2 preceding and current row) as CNT +from t1; + +select + pk,c, + count(*) over (partition by c order by pk rows + between 1 following and 2 following) as CNT +from t1; + +select + pk,c, + count(*) over (partition by c order by pk rows + between 2 preceding and 1 preceding) as CNT +from t1; + +select + pk, c, + count(*) over (partition by c order by pk + rows between current row and 1 following) as CNT +from t1; + +--echo # Check ORDER BY DESC +select + pk, c, + count(*) over (partition by c order by pk desc + rows between 2 preceding and 2 following) as CNT +from t1; + +drop table t0,t1; + +--echo # +--echo # Resolution of window names +--echo # + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; + +select + pk, c, + count(*) over w1 as CNT +from t1 +window w1 as (partition by c order by pk + rows between 2 preceding and 2 following); + +select + pk, c, + count(*) over (w1 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c order by pk); + +select + pk, c, + count(*) over (w1 order by pk rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c); + +select + pk, c, + count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w2 as (w1 order by pk); + +select + pk, c, + count(*) over w3 as CNT +from t1 +window + w1 as (partition by c), + w2 as (w1 order by pk), + w3 as (w2 rows between 2 preceding and 2 following); + +--error ER_WRONG_WINDOW_SPEC_NAME +select + pk, c, + count(*) over w as CNT +from t1 +window w1 as (partition by c order by pk + rows between 2 preceding and 2 following); + +--error ER_DUP_WINDOW_NAME +select + pk, c, + count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w1 as (order by pk); + +--error ER_WRONG_WINDOW_SPEC_NAME +select + pk, c, + count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w2 as (w partition by c order by pk); + +--error ER_PARTITION_LIST_IN_REFERENCING_WINDOW_SPEC +select + pk, c, + count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c), w2 as (w1 partition by c order by pk); + +--error ER_ORDER_LIST_IN_REFERENCING_WINDOW_SPEC +select + pk, c, + count(*) over (w2 rows between 2 preceding and 2 following) as CNT +from t1 +window w1 as (partition by c order by pk), w2 as (w1 order by pk); + +--error ER_WINDOW_FRAME_IN_REFERENCED_WINDOW_SPEC +select + pk, c, + count(*) over w3 as CNT +from t1 +window + w1 as (partition by c), + w2 as (w1 order by pk rows between 3 preceding and 2 following), + w3 as (w2 rows between 2 preceding and 2 following); + +--error ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS +select + pk, c, + count(*) over w1 as CNT +from t1 +window w1 as (partition by c order by pk + rows between unbounded following and 2 following); + +--error ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS +select + pk, c, + count(*) over (w1 rows between 2 preceding and unbounded preceding) as CNT +from t1 +window w1 as (partition by c order by pk); + +--error ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS +select + pk, c, + count(*) over (w1 order by pk rows between current row and 2 preceding) as CNT +from t1 +window w1 as (partition by c); + +--error ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS +select + pk, c, + count(*) over (w2 rows between 2 following and current row) as CNT +from t1 +window w1 as (partition by c), w2 as (w1 order by pk); + +--error ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION +select + pk, c +from t1 where rank() over w1 > 2 +window w1 as (partition by c order by pk); + +--error ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION +select + c, max(pk) as m +from t1 + group by c + rank() over w1 +window w1 as (order by m); + +--error ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION +select + c, max(pk) as m, rank() over w1 as r +from t1 + group by c+r +window w1 as (order by m); + +--error ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION +select + c, max(pk) as m, rank() over w1 as r +from t1 + group by c having c+r > 3 +window w1 as (order by m); + +--error ER_WINDOW_FUNCTION_IN_WINDOW_SPEC +select + c, max(pk) as m, rank() over w1 as r, + rank() over (partition by r+1 order by m) +from t1 + group by c +window w1 as (order by m); + +--error ER_WINDOW_FUNCTION_IN_WINDOW_SPEC +select + c, max(pk) as m, rank() over w1 as r, + rank() over (partition by m order by r) +from t1 + group by c +window w1 as (order by m); + +--error ER_WINDOW_FUNCTION_IN_WINDOW_SPEC +select + c, max(pk) as m, rank() over w1 as r, dense_rank() over w2 as dr +from t1 + group by c +window w1 as (order by m), w2 as (partition by r order by m); + +--error ER_NOT_ALLOWED_WINDOW_FRAME +select + pk, c, + row_number() over (partition by c order by pk + range between unbounded preceding and current row) as r +from t1; + +--error ER_NOT_ALLOWED_WINDOW_FRAME +select + pk, c, + rank() over w1 as r +from t1 +window w1 as (partition by c order by pk + rows between 2 preceding and 2 following); + +--error ER_NOT_ALLOWED_WINDOW_FRAME +select + pk, c, + dense_rank() over (partition by c order by pk + rows between 1 preceding and 1 following) as r +from t1; + +--error ER_NO_ORDER_LIST_IN_WINDOW_SPEC +select + pk, c, + rank() over w1 as r +from t1 +window w1 as (partition by c); + +--error ER_NO_ORDER_LIST_IN_WINDOW_SPEC +select + pk, c, + dense_rank() over (partition by c) as r +from t1; + +drop table t0,t1; + +--echo # +--echo # MDEV-9634: Window function produces incorrect value +--echo # + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (part_id int, pk int, a int); +insert into t2 select + if(a<5, 0, 1), a, if(a<5, NULL, 1) from t0; +select * from t2; + +select + part_id, pk, a, + count(a) over (partition by part_id order by pk + rows between 1 preceding and 1 following) as CNT +from t2; + +drop table t0, t2; + +--echo # +--echo # RANGE-type bounds +--echo # + +create table t3 ( + pk int, + val int +); + +insert into t3 values +(0, 1), +(1, 1), +(2, 1), +(3, 2), +(4, 2), +(5, 2), +(6, 2); + +select + pk, + val, + count(val) over (order by val + range between current row and + current row) + as CNT +from t3; + +insert into t3 values +(7, 3), +(8, 3); + +select + pk, + val, + count(val) over (order by val + range between current row and + current row) + as CNT +from t3; + +drop table t3; + +--echo # Now, check with PARTITION BY +create table t4 ( + part_id int, + pk int, + val int +); + +insert into t4 values +(1234, 100, 1), +(1234, 101, 1), +(1234, 102, 1), +(1234, 103, 2), +(1234, 104, 2), +(1234, 105, 2), +(1234, 106, 2), +(1234, 107, 3), +(1234, 108, 3), + +(5678, 200, 1), +(5678, 201, 1), +(5678, 202, 1), +(5678, 203, 2), +(5678, 204, 2), +(5678, 205, 2), +(5678, 206, 2), +(5678, 207, 3), +(5678, 208, 3); + +select + part_id, + pk, + val, + count(val) over (partition by part_id + order by val + range between current row and + current row) + as CNT +from t4; + +--echo # +--echo # Try RANGE UNBOUNDED PRECEDING | FOLLOWING +--echo # +select + part_id, + pk, + val, + count(val) over (partition by part_id + order by val + range between unbounded preceding and + current row) + as CNT +from t4; + +select + part_id, + pk, + val, + count(val) over (partition by part_id + order by val + range between current row and + unbounded following) + as CNT +from t4; + +select + part_id, + pk, + val, + count(val) over (partition by part_id + order by val + range between unbounded preceding and + unbounded following) + as CNT +from t4; + +drop table t4; + +--echo # +--echo # MDEV-9695: Wrong window frame when using RANGE BETWEEN N FOLLOWING AND PRECEDING +--echo # +create table t1 (pk int, a int, b int); +insert into t1 values +( 1 , 0, 1), +( 2 , 0, 2), +( 3 , 1, 4), +( 4 , 1, 8), +( 5 , 2, 32), +( 6 , 2, 64), +( 7 , 2, 128), +( 8 , 2, 16); + +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as bit_or +from t1; + +--echo # Extra ROWS n PRECEDING tests +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) as bit_or +from t1; +drop table t1; + + +create table t2 ( + pk int, + a int, + b int +); + +insert into t2 values +( 1, 0, 1), +( 2, 0, 2), +( 3, 0, 4), +( 4, 0, 8), +( 5, 1, 16), +( 6, 1, 32), +( 7, 1, 64), +( 8, 1, 128), +( 9, 2, 256), +(10, 2, 512), +(11, 2, 1024), +(12, 2, 2048); + +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) as bit_or +from t2; + +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) as bit_or +from t2; + +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) as bit_or +from t2; + +--echo # Check CURRENT ROW + +select pk, a, b, +bit_or(b) over (partition by a order by pk ROWS BETWEEN CURRENT ROW AND CURRENT ROW) as bit_or +from t2; + +drop table t2; + +--echo # +--echo # Try RANGE PRECEDING|FOLLWING n +--echo # +create table t1 ( + part_id int, + pk int, + a int +); + +insert into t1 values +(10, 1, 1), +(10, 2, 2), +(10, 3, 4), +(10, 4, 8), +(10, 5,26), +(10, 6,27), +(10, 7,40), +(10, 8,71), +(10, 9,72); + +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN UNBOUNDED PRECEDING + AND 10 FOLLOWING) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a DESC + RANGE BETWEEN UNBOUNDED PRECEDING + AND 10 FOLLOWING) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN UNBOUNDED PRECEDING + AND 1 FOLLOWING) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN UNBOUNDED PRECEDING + AND 10 PRECEDING) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a DESC + RANGE BETWEEN UNBOUNDED PRECEDING + AND 10 PRECEDING) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN UNBOUNDED PRECEDING + AND 1 PRECEDING) as cnt +from t1; + +# Try bottom bound +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN 1 PRECEDING + AND CURRENT ROW) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a DESC + RANGE BETWEEN 1 PRECEDING + AND CURRENT ROW) as cnt +from t1; + +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN 1 FOLLOWING + AND 3 FOLLOWING) as cnt +from t1; + +--echo # Try CURRENT ROW with[out] DESC +select + pk, a, + count(a) over (ORDER BY a + RANGE BETWEEN CURRENT ROW + AND 1 FOLLOWING) as cnt +from t1; + +select + pk, a, + count(a) over (order by a desc + range between current row + and 1 following) as cnt +from t1; + + +# Try with partitions +insert into t1 select 22, pk, a from t1; +select + part_id, pk, a, + count(a) over (PARTITION BY part_id + ORDER BY a + RANGE BETWEEN UNBOUNDED PRECEDING + AND 10 FOLLOWING) as cnt +from t1; + +select + pk, a, + count(a) over (PARTITION BY part_id + ORDER BY a + RANGE BETWEEN UNBOUNDED PRECEDING + AND 1 PRECEDING) as cnt +from t1; + +drop table t1; + +--echo # Try a RANGE frame over non-integer datatype: + +create table t1 ( + col1 int, + a decimal(5,3) +); + +insert into t1 values (1, 0.45); +insert into t1 values (1, 0.5); +insert into t1 values (1, 0.55); +insert into t1 values (1, 1.21); +insert into t1 values (1, 1.22); +insert into t1 values (1, 3.33); + +select + a, + count(col1) over (order by a + range between 0.1 preceding + and 0.1 following) +from t1; + +drop table t1; + +--echo # +--echo # RANGE-type frames and NULL values +--echo # +create table t1 ( + pk int, + a int, + b int +); + +insert into t1 values (1, NULL,1); +insert into t1 values (2, NULL,1); +insert into t1 values (3, NULL,1); +insert into t1 values (4, 10 ,1); +insert into t1 values (5, 11 ,1); +insert into t1 values (6, 12 ,1); +insert into t1 values (7, 13 ,1); +insert into t1 values (8, 14 ,1); + + +select + pk, a, + count(b) over (order by a + range between 2 preceding + and 2 following) as CNT +from t1; +drop table t1; + +--echo # +--echo # Try ranges that have bound1 > bound2. The standard actually allows them +--echo # + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; + +select + pk, c, + count(*) over (partition by c + order by pk + rows between 1 preceding + and 2 preceding) + as cnt +from t1; + + +select + pk, c, + count(*) over (partition by c + order by pk + range between 1 preceding + and 2 preceding) + as cnt +from t1; +drop table t0, t1; + +--echo # +--echo # Error checking for frame bounds +--echo # + +create table t1 (a int, b int, c varchar(32)); +insert into t1 values (1,1,'foo'); +insert into t1 values (2,2,'bar'); +--error ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY +select + count(*) over (order by a,b + range between unbounded preceding and current row) +from t1; + +--error ER_WRONG_TYPE_FOR_RANGE_FRAME +select + count(*) over (order by c + range between unbounded preceding and current row) +from t1; + +--error ER_WRONG_TYPE_FOR_RANGE_FRAME +select + count(*) over (order by a + range between 'abcd' preceding and current row) +from t1; + +--error ER_WRONG_TYPE_FOR_RANGE_FRAME +select + count(*) over (order by a + range between current row and 'foo' following) +from t1; + +--echo # Try range frame with invalid bounds +--error ER_WRONG_TYPE_FOR_ROWS_FRAME +select + count(*) over (order by a + rows between 0.5 preceding and current row) +from t1; + +--error ER_WRONG_TYPE_FOR_ROWS_FRAME +select + count(*) over (order by a + rows between current row and 3.14 following) +from t1; + +--echo # +--echo # EXCLUDE clause is parsed but not supported +--echo # + +--error ER_FRAME_EXCLUSION_NOT_SUPPORTED +select + count(*) over (order by a + rows between 1 preceding and 1 following + exclude current row) +from t1; + +--error ER_FRAME_EXCLUSION_NOT_SUPPORTED +select + count(*) over (order by a + range between 1 preceding and 1 following + exclude ties) +from t1; + +--error ER_FRAME_EXCLUSION_NOT_SUPPORTED +select + count(*) over (order by a + range between 1 preceding and 1 following + exclude group) +from t1; + +# EXCLUDE NO OTHERS means 'don't exclude anything' +select + count(*) over (order by a + rows between 1 preceding and 1 following + exclude no others) +from t1; + +drop table t1; + +--echo # +--echo # Window function in grouping query +--echo # + +create table t1 ( + username varchar(32), + amount int +); + +insert into t1 values +('user1',1), +('user1',5), +('user1',3), +('user2',10), +('user2',20), +('user2',30); + +select + username, + sum(amount) as s, + rank() over (order by s desc) +from t1 +group by username; + +drop table t1; + +--echo # +--echo # mdev-9719: Window function in prepared statement +--echo # + +create table t1(a int, b int, x char(32)); +insert into t1 values (2, 10, 'xx'); +insert into t1 values (2, 10, 'zz'); +insert into t1 values (2, 20, 'yy'); +insert into t1 values (3, 10, 'xxx'); +insert into t1 values (3, 20, 'vvv'); + +prepare stmt from 'select a, row_number() over (partition by a order by b) from t1'; +--sorted_result +execute stmt; + +drop table t1; + +--echo # +--echo # mdev-9754: Window name resolution in prepared statement +--echo # + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (pk int, c int); +insert into t1 select a+1,1 from t0; +update t1 set c=2 where pk not in (1,2,3,4); +select * from t1; + +prepare stmt from +'select + pk, c, + count(*) over w1 as CNT +from t1 +window w1 as (partition by c order by pk + rows between 2 preceding and 2 following)'; +execute stmt; + +drop table t0,t1; + +--echo # +--echo # EXPLAIN FORMAT=JSON support for window functions +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +explain format=json select rank() over (order by a) from t0; + +create table t1 (a int, b int, c int); +insert into t1 select a,a,a from t0; + +explain format=json +select + a, + rank() over (order by sum(b)) +from t1 +group by a; + +explain format=json +select + a, + rank() over (order by sum(b)) +from t1 +group by a +order by null; + +--echo # +--echo # Check how window function works together with GROUP BY and HAVING +--echo # + +select b,max(a) as MX, rank() over (order by b) from t1 group by b having MX in (3,5,7); +explain format=json +select b,max(a) as MX, rank() over (order by b) from t1 group by b having MX in (3,5,7); + +drop table t1; +drop table t0; + +--echo # +--echo # Building ordering index for window functions +--echo # + +create table t1 ( + pk int primary key, + a int, + b int, + c int +); + +insert into t1 values +(101 , 0, 10, 1), +(102 , 0, 10, 2), +(103 , 1, 10, 3), +(104 , 1, 10, 4), +(108 , 2, 10, 5), +(105 , 2, 20, 6), +(106 , 2, 20, 7), +(107 , 2, 20, 8), +(109 , 4, 20, 9), +(110 , 4, 20, 10), +(111 , 5, NULL, 11), +(112 , 5, 1, 12), +(113 , 5, NULL, 13), +(114 , 5, NULL, 14), +(115 , 5, NULL, 15), +(116 , 6, 1, NULL), +(117 , 6, 1, 10), +(118 , 6, 1, 1), +(119 , 6, 1, NULL), +(120 , 6, 1, NULL), +(121 , 6, 1, NULL), +(122 , 6, 1, 2), +(123 , 6, 1, 20), +(124 , 6, 1, -10), +(125 , 6, 1, NULL), +(126 , 6, 1, NULL), +(127 , 6, 1, NULL); + +--sorted_result +select sum(b) over (partition by a order by b,pk + rows between unbounded preceding and current row) as c1, + avg(b) over (w1 rows between 1 preceding and 1 following) as c2, + sum(c) over (w2 rows between 1 preceding and 1 following) as c5, + avg(b) over (w1 rows between 5 preceding and 5 following) as c3, + sum(b) over (w1 rows between 1 preceding and 1 following) as c4 +from t1 +window w1 as (partition by a order by b,pk), + w2 as (partition by b order by c,pk); + +drop table t1; + + +--echo # +--echo # MDEV-9848: Window functions: reuse sorting and/or scanning +--echo # + +create table t1 (a int, b int, c int); +insert into t1 values +(1,3,1), +(2,2,1), +(3,1,1); + +--echo # Check using counters +flush status; +select + rank() over (partition by c order by a), + rank() over (partition by c order by b) +from t1; +show status like '%sort%'; + +flush status; +select + rank() over (partition by c order by a), + rank() over (partition by c order by a) +from t1; +show status like '%sort%'; + +# Check using EXPLAIN FORMAT=JSON +explain format=json +select + rank() over (partition by c order by a), + rank() over (partition by c order by a) +from t1; + +explain format=json +select + rank() over (order by a), + row_number() over (order by a) +from t1; + +explain format=json +select + rank() over (partition by c order by a), + count(*) over (partition by c) +from t1; + +explain format=json +select + count(*) over (partition by c), + rank() over (partition by c order by a) +from t1; + +drop table t1; + + +--echo # +--echo # MDEV-9847: Window functions: crash with big_tables=1 +--echo # +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set @tmp=@@big_tables; +set big_tables=1; +select rank() over (order by a) from t1; +set big_tables=@tmp; +drop table t1; + +--echo # +--echo # Check if "ORDER BY window_func" works +--echo # + +create table t1 (s1 int, s2 char(5)); +insert into t1 values (1,'a'); +insert into t1 values (null,null); +insert into t1 values (1,null); +insert into t1 values (null,'a'); +insert into t1 values (2,'b'); +insert into t1 values (-1,''); + +explain format=json +select *, row_number() over (order by s1, s2) as X from t1 order by X desc; +select *, row_number() over (order by s1, s2) as X from t1 order by X desc; +drop table t1; + +--echo # +--echo # Try window functions that are not directly present in the select list +--echo # +create table t1 (a int, b int); +insert into t1 values + (1,3), + (2,2), + (3,1); + +select + rank() over (order by a) - + rank() over (order by b) +from + t1; + +drop table t1; + +--echo # +--echo # MDEV-9894: Assertion `0' failed in Window_func_runner::setup +--echo # return ER_NOT_SUPPORTED_YET for aggregates that are not yet supported +--echo # as window functions. +--echo # +create table t1 (i int); +insert into t1 values (1),(2); +--error ER_NOT_SUPPORTED_YET +SELECT MAX(i) OVER (PARTITION BY (i)) FROM t1; +drop table t1; + +--echo # +--echo # Check the 0 in ROWS 0 PRECEDING +--echo # + +create table t1 ( + part_id int, + pk int, + a int +); + +insert into t1 values (1, 1, 1); +insert into t1 values (1, 2, 2); +insert into t1 values (1, 3, 4); +insert into t1 values (1, 4, 8); + +select + pk, a, + sum(a) over (order by pk rows between 0 preceding and current row) +from t1; + +select + pk, a, + sum(a) over (order by pk rows between 1 preceding and 0 preceding) +from t1; + +insert into t1 values (200, 1, 1); +insert into t1 values (200, 2, 2); +insert into t1 values (200, 3, 4); +insert into t1 values (200, 4, 8); +select + part_id, pk, a, + sum(a) over (partition by part_id order by pk rows between 0 preceding and current row) +from t1; + +select + part_id, pk, a, + sum(a) over (partition by part_id order by pk rows between 1 preceding and 0 preceding) +from t1; + +drop table t1; +--echo # +--echo # MDEV-9780, The "DISTINCT must not bet converted into GROUP BY when +--echo # window functions are present" part +--echo # + +create table t1 (part_id int, a int); +insert into t1 values +(100, 1), +(100, 2), +(100, 2), +(100, 3), +(2000, 1), +(2000, 2), +(2000, 3), +(2000, 3), +(2000, 3); + +select rank() over (partition by part_id order by a) from t1; +select distinct rank() over (partition by part_id order by a) from t1; +explain format=json +select distinct rank() over (partition by part_id order by a) from t1; + +drop table t1; + +--echo # +--echo # MDEV-9893: Window functions with different ORDER BY lists, +--echo # one of these lists containing an expression +--echo # + +create table t1 (s1 int, s2 char(5)); +insert into t1 values (1,'a'); +insert into t1 values (null,null); +insert into t1 values (3,null); +insert into t1 values (4,'a'); +insert into t1 values (2,'b'); +insert into t1 values (-1,''); + +select + *, + ROW_NUMBER() OVER (order by s1), + CUME_DIST() OVER (order by -s1) +from t1; + +drop table t1; + + +--echo # +--echo # MDEV-9925: Wrong result with aggregate function as a window function +--echo # +create table t1 (i int); +insert into t1 values (1),(2); +select i, sum(i) over (partition by i) from t1; +drop table t1; + +--echo # +--echo # MDEV-9922: Assertion `!join->only_const_tables() && fsort' failed in int create_sort_index +--echo # +create view v1 as select 1 as i; +select rank() over (order by i) from v1; +drop view v1; + diff --git a/mysql-test/t/win_avg.test b/mysql-test/t/win_avg.test new file mode 100644 index 00000000000..23a3652d943 --- /dev/null +++ b/mysql-test/t/win_avg.test @@ -0,0 +1,47 @@ +create table t1 ( + pk int primary key, + a int, + b int, + c real +); + + +insert into t1 values +(101 , 0, 10, 1.1), +(102 , 0, 10, 2.1), +(103 , 1, 10, 3.1), +(104 , 1, 10, 4.1), +(108 , 2, 10, 5.1), +(105 , 2, 20, 6.1), +(106 , 2, 20, 7.1), +(107 , 2, 20, 8.15), +(109 , 4, 20, 9.15), +(110 , 4, 20, 10.15), +(111 , 5, NULL, 11.15), +(112 , 5, 1, 12.25), +(113 , 5, NULL, 13.35), +(114 , 5, NULL, 14.50), +(115 , 5, NULL, 15.65), +(116 , 6, 1, NULL), +(117 , 6, 1, 10), +(118 , 6, 1, 1.1), +(119 , 6, 1, NULL), +(120 , 6, 1, NULL), +(121 , 6, 1, NULL), +(122 , 6, 1, 2.2), +(123 , 6, 1, 20.1), +(124 , 6, 1, -10.4), +(125 , 6, 1, NULL), +(126 , 6, 1, NULL), +(127 , 6, 1, NULL); + + +--sorted_result +select pk, a, b, avg(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; + +--sorted_result +select pk, a, c, avg(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; + +drop table t1; diff --git a/mysql-test/t/win_bit.test b/mysql-test/t/win_bit.test new file mode 100644 index 00000000000..f077d0d67a0 --- /dev/null +++ b/mysql-test/t/win_bit.test @@ -0,0 +1,89 @@ +create table t1 ( + pk int primary key, + a int, + b int +); + +create table t2 ( + pk int primary key, + a int, + b int +); + + + +insert into t1 values +( 1 , 0, 1), +( 2 , 0, 2), +( 3 , 1, 4), +( 4 , 1, 8), +( 5 , 2, 32), +( 6 , 2, 64), +( 7 , 2, 128), +( 8 , 2, 16); + +insert into t2 values +( 1 , 0, 2), +( 2 , 0, 2), +( 3 , 1, 4), +( 4 , 1, 4), +( 5 , 2, 16), +( 6 , 2, 64), +( 7 , 2, 128), +( 8 , 2, 16); + + + +--echo # Test bit functions on only one partition. +select pk, a, b, + bit_or(b) over (order by pk) as bit_or, + bit_and(b) over (order by pk) as bit_and, + bit_xor(b) over (order by pk) as bit_xor +from t1; + +select pk, a, b, + bit_or(b) over (order by pk) as bit_or, + bit_and(b) over (order by pk) as bit_and, + bit_xor(b) over (order by pk) as bit_xor +from t2; + +--echo # Test multiple partitions with bit functions. +select pk, a, b, + bit_or(b) over (partition by a order by pk) as bit_or, + bit_and(b) over (partition by a order by pk) as bit_and, + bit_xor(b) over (partition by a order by pk) as bit_xor +from t1; + +select pk, a, b, + bit_or(b) over (partition by a order by pk) as bit_or, + bit_and(b) over (partition by a order by pk) as bit_and, + bit_xor(b) over (partition by a order by pk) as bit_xor +from t2; + +--echo # Test remove function for bit functions using a sliding window. +select pk, a, b, + bit_or(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as bit_or, + bit_and(b) over (partition by a order by pk) as bit_and, + bit_xor(b) over (partition by a order by pk) as bit_xor +from t1; + +select pk, a, b, + bit_or(b) over (partition by a order by pk) as bit_or, + bit_and(b) over (partition by a order by pk) as bit_and, + bit_xor(b) over (partition by a order by pk) as bit_xor +from t2; + + + + + + + +#select pk, a, b, bit_or(b) over (order by a) as count from t1 order by a, pk; +#select pk, a, b, bit_and(b) over (order by a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as count from t1 order by a, pk; +#select pk, a, b, bit_xor(b) over (order by a, pk ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as count from t2 order by pk; +#select pk, a, b, bit_or(b) over (order by a, pk ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as count from t2 order by pk; +#select pk, a, b, bit_and(b) over (order by a, pk ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as count from t3 order by pk; + +drop table t1; +drop table t2; diff --git a/mysql-test/t/win_ntile.test b/mysql-test/t/win_ntile.test new file mode 100644 index 00000000000..6f12e1f4005 --- /dev/null +++ b/mysql-test/t/win_ntile.test @@ -0,0 +1,171 @@ +create table t1 ( + pk int primary key, + a int, + b int +); + + +insert into t1 values +(11 , 0, 10), +(12 , 0, 10), +(13 , 1, 10), +(14 , 1, 10), +(18 , 2, 10), +(15 , 2, 20), +(16 , 2, 20), +(17 , 2, 20), +(19 , 4, 20), +(20 , 4, 20); + +# TODO Try invalid queries too. + +--error ER_INVALID_NTILE_ARGUMENT +select pk, a, b, ntile(-1) over (order by a) +from t1; + +--error ER_INVALID_NTILE_ARGUMENT +select pk, a, b, + ntile(0) over (order by a) +from t1; + +--sorted_result +select pk, a, b, + ntile(1) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(2) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(3) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(4) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(5) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(6) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(7) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(8) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(9) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(10) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(11) over (order by pk) +from t1; + +--sorted_result +select pk, a, b, + ntile(20) over (order by pk) +from t1; + + +select pk, a, b, + ntile(1) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(2) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(3) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(4) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(5) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(6) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(7) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(8) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(9) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(10) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(11) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(20) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile(1 + 3) over (partition by b order by pk) +from t1; + +select pk, a, b, + ntile((select 4)) over (partition by b order by pk) +from t1; + +select t1.a from t1 where pk = 11; +--error ER_INVALID_NTILE_ARGUMENT +select pk, a, b, + ntile((select a from t1 where pk=11)) over (partition by b order by pk) +from t1; + +select t1.a from t1 where pk = 13; +select pk, a, b, + ntile((select a from t1 where pk=13)) over (partition by b order by pk) +from t1; + +explain +select pk, a, b, + ntile((select a from t1 where pk=13)) over (partition by b order by pk) +from t1; + +select a from t1; +--error ER_SUBQUERY_NO_1_ROW +select pk, a, b, + ntile((select a from t1)) over (partition by b order by pk) +from t1; + + +drop table t1; diff --git a/mysql-test/t/win_orderby.test b/mysql-test/t/win_orderby.test new file mode 100644 index 00000000000..0d42c606486 --- /dev/null +++ b/mysql-test/t/win_orderby.test @@ -0,0 +1,32 @@ +# +# Tests for window functions and ORDER BY +# + +--disable_warnings +drop table if exists t0,t1; +--enable_warnings + +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1( + pk int, + a int, + key(pk) +); + +insert into t1 +select + A.a + B.a* 10 + C.a * 100, + 1 +from t0 A, t0 B, t0 C; + +select + pk, + count(a) over (order by pk rows between 2 preceding and 2 following) +from t1 +where pk between 1 and 30 +order by pk desc +limit 4; + +drop table t0,t1; diff --git a/mysql-test/t/win_percent_cume.test b/mysql-test/t/win_percent_cume.test new file mode 100644 index 00000000000..b851185cb32 --- /dev/null +++ b/mysql-test/t/win_percent_cume.test @@ -0,0 +1,36 @@ +create table t1 ( + pk int primary key, + a int, + b int +); + + +insert into t1 values +( 1 , 0, 10), +( 2 , 0, 10), +( 3 , 1, 10), +( 4 , 1, 10), +( 8 , 2, 10), +( 5 , 2, 20), +( 6 , 2, 20), +( 7 , 2, 20), +( 9 , 4, 20), +(10 , 4, 20); + +select pk, a, b, + percent_rank() over (order by a), + cume_dist() over (order by a) +from t1; + +select pk, a, b, + percent_rank() over (order by pk), + cume_dist() over (order by pk) +from t1 order by pk; + +select pk, a, b, + percent_rank() over (partition by a order by a), + cume_dist() over (partition by a order by a) +from t1; + +drop table t1; + diff --git a/mysql-test/t/win_rank.test b/mysql-test/t/win_rank.test new file mode 100644 index 00000000000..eda1f458205 --- /dev/null +++ b/mysql-test/t/win_rank.test @@ -0,0 +1,58 @@ +--echo # +--echo # Try DENSE_RANK() function +--echo # + +create table t1 ( + pk int primary key, + a int, + b int +); + +insert into t1 values +( 1 , 0, 10), +( 2 , 0, 10), +( 3 , 1, 10), +( 4 , 1, 10), +( 8 , 2, 10), +( 5 , 2, 20), +( 6 , 2, 20), +( 7 , 2, 20), +( 9 , 4, 20), +(10 , 4, 20); + +select pk, a, b, rank() over (order by a) as rank, + dense_rank() over (order by a) as dense_rank +from t1; +select pk, a, b, rank() over (partition by b order by a) as rank, + dense_rank() over (partition by b order by a) as dense_rank +from t1; + +drop table t1; + +--echo # +--echo # Test with null values in the table. +--echo # + +create table t2 (s1 int, s2 char(5)); +insert into t2 values (1,'a'); +insert into t2 values (null,null); +insert into t2 values (1,null); +insert into t2 values (null,'a'); +insert into t2 values (null,'c'); +insert into t2 values (2,'b'); +insert into t2 values (-1,''); + +select *, rank() over (order by s1) as rank, + dense_rank() over (order by s1) as dense_rank +from t2; +select *, rank() over (partition by s2 order by s1) as rank, + dense_rank() over (partition by s2 order by s1) as dense_rank +from t2; +select *, rank() over (order by s2) as rank, + dense_rank() over (order by s2) as dense_rank +from t2; +select *, rank() over (partition by s1 order by s2) as rank, + dense_rank() over (partition by s1 order by s2) as dense_rank +from t2; + +drop table t2; diff --git a/mysql-test/t/win_sum.test b/mysql-test/t/win_sum.test new file mode 100644 index 00000000000..aa4965bfd5a --- /dev/null +++ b/mysql-test/t/win_sum.test @@ -0,0 +1,47 @@ +create table t1 ( + pk int primary key, + a int, + b int, + c real +); + + +insert into t1 values +(101 , 0, 10, 1.1), +(102 , 0, 10, 2.1), +(103 , 1, 10, 3.1), +(104 , 1, 10, 4.1), +(108 , 2, 10, 5.1), +(105 , 2, 20, 6.1), +(106 , 2, 20, 7.1), +(107 , 2, 20, 8.15), +(109 , 4, 20, 9.15), +(110 , 4, 20, 10.15), +(111 , 5, NULL, 11.15), +(112 , 5, 1, 12.25), +(113 , 5, NULL, 13.35), +(114 , 5, NULL, 14.50), +(115 , 5, NULL, 15.65), +(116 , 6, 1, NULL), +(117 , 6, 1, 10), +(118 , 6, 1, 1.1), +(119 , 6, 1, NULL), +(120 , 6, 1, NULL), +(121 , 6, 1, NULL), +(122 , 6, 1, 2.2), +(123 , 6, 1, 20.1), +(124 , 6, 1, -10.4), +(125 , 6, 1, NULL), +(126 , 6, 1, NULL), +(127 , 6, 1, NULL); + + +--sorted_result +select pk, a, b, sum(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; + +--sorted_result +select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +from t1; + +drop table t1; diff --git a/mysys/errors.c b/mysys/errors.c index 11e7d04e79e..e3fbfd4d8e6 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -119,7 +119,7 @@ void wait_for_free_space(const char *filename, int errors) (void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC); } -const char **get_global_errmsgs() +const char **get_global_errmsgs(int nr __attribute__((unused))) { return globerrs; } diff --git a/mysys/my_default.c b/mysys/my_default.c index 7f41551f779..0c4fce0d2c7 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -565,7 +565,7 @@ int my_load_defaults(const char *conf_file, const char **groups, for (; *groups ; groups++) group.count++; - if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32, MYF(0))) + if (my_init_dynamic_array(&args, sizeof(char*), 128, 64, MYF(0))) goto err; ctx.alloc= &alloc; diff --git a/mysys/my_error.c b/mysys/my_error.c index 5d16091e0be..c0698b19a20 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -49,7 +49,7 @@ static struct my_err_head { struct my_err_head *meh_next; /* chain link */ - const char** (*get_errmsgs)(); /* returns error message format */ + const char** (*get_errmsgs)(int nr); /* returns error message format */ uint meh_first; /* error number matching array slot 0 */ uint meh_last; /* error number matching last slot */ } my_errmsgs_globerrs= @@ -86,7 +86,7 @@ const char *my_get_err_msg(uint nr) we return NULL. */ if (!(format= (meh_p && (nr >= meh_p->meh_first)) ? - meh_p->get_errmsgs()[nr - meh_p->meh_first] : NULL) || + meh_p->get_errmsgs(nr)[nr - meh_p->meh_first] : NULL) || !*format) return NULL; @@ -217,7 +217,8 @@ void my_message(uint error, const char *str, register myf MyFlags) @retval != 0 Error */ -int my_error_register(const char** (*get_errmsgs) (), uint first, uint last) +int my_error_register(const char** (*get_errmsgs)(int error), uint first, + uint last) { struct my_err_head *meh_p; struct my_err_head **search_meh_pp; @@ -273,11 +274,10 @@ int my_error_register(const char** (*get_errmsgs) (), uint first, uint last) @retval non-NULL OK, returns address of error messages pointers array. */ -const char **my_error_unregister(uint first, uint last) +my_bool my_error_unregister(uint first, uint last) { struct my_err_head *meh_p; struct my_err_head **search_meh_pp; - const char **errmsgs; /* Search for the registration in the list. */ for (search_meh_pp= &my_errmsgs_list; @@ -289,17 +289,15 @@ const char **my_error_unregister(uint first, uint last) break; } if (! *search_meh_pp) - return NULL; - + return TRUE; + /* Remove header from the chain. */ meh_p= *search_meh_pp; *search_meh_pp= meh_p->meh_next; - /* Save the return value and free the header. */ - errmsgs= meh_p->get_errmsgs(); my_free(meh_p); - return errmsgs; + return FALSE; } diff --git a/plugin/file_key_management/file_key_management_plugin.cc b/plugin/file_key_management/file_key_management_plugin.cc index e0afbd68cc9..77344bc57ee 100644 --- a/plugin/file_key_management/file_key_management_plugin.cc +++ b/plugin/file_key_management/file_key_management_plugin.cc @@ -169,6 +169,12 @@ static int file_key_management_plugin_init(void *p) return parser.parse(&keys); } +static int file_key_management_plugin_deinit(void *p) +{ + keys.free_memory(); + return 0; +} + /* Plugin library descriptor */ @@ -181,7 +187,7 @@ maria_declare_plugin(file_key_management) "File-based key management plugin", PLUGIN_LICENSE_GPL, file_key_management_plugin_init, - NULL, + file_key_management_plugin_deinit, 0x0100 /* 1.0 */, NULL, /* status variables */ settings, diff --git a/plugin/wsrep_info/plugin.cc b/plugin/wsrep_info/plugin.cc index b8aaee5a132..f9843cb6f39 100644 --- a/plugin/wsrep_info/plugin.cc +++ b/plugin/wsrep_info/plugin.cc @@ -120,10 +120,10 @@ static int wsrep_memb_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) if (check_global_access(thd, SUPER_ACL, true)) return rc; - wsrep_config_state.lock(); + wsrep_config_state->lock(); Dynamic_array<wsrep_member_info_t> *memb_arr= - wsrep_config_state.get_member_info(); + wsrep_config_state->get_member_info(); TABLE *table= tables->table; @@ -151,7 +151,7 @@ static int wsrep_memb_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) } end: - wsrep_config_state.unlock(); + wsrep_config_state->unlock(); return rc; } @@ -175,10 +175,10 @@ static int wsrep_status_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) if (check_global_access(thd, SUPER_ACL, true)) return rc; - wsrep_config_state.lock(); + wsrep_config_state->lock(); - wsrep_view_info_t view= wsrep_config_state.get_view_info(); - wsrep_member_status_t status= wsrep_config_state.get_status(); + wsrep_view_info_t view= wsrep_config_state->get_view_info(); + wsrep_member_status_t status= wsrep_config_state->get_status(); TABLE *table= tables->table; @@ -210,7 +210,7 @@ static int wsrep_status_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) if (schema_table_store_record(thd, table)) rc= 1; - wsrep_config_state.unlock(); + wsrep_config_state->unlock(); return rc; } diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 9dcd23a8392..773b5ee99a9 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -29,6 +29,7 @@ args="" defaults="" mysqld_opt="" user="" +silent_startup="--silent-startup" force=0 in_rpm=0 @@ -124,7 +125,7 @@ parse_arguments() # where a chown of datadir won't help) user=`parse_arg "$arg"` ;; --skip-name-resolve) ip_only=1 ;; - --verbose) verbose=1 ;; # Obsolete + --verbose) verbose=1 ; silent_startup="" ;; --rpm) in_rpm=1 ;; --help) usage ;; --no-defaults|--defaults-file=*|--defaults-extra-file=*) @@ -418,7 +419,7 @@ fi mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}" mysqld_install_cmd_line() { - "$mysqld_bootstrap" $defaults "$mysqld_opt" --bootstrap \ + "$mysqld_bootstrap" $defaults "$mysqld_opt" --bootstrap $silent_startup\ "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \ $args --max_allowed_packet=8M \ --net_buffer_length=16K diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index b878a2e636e..d9d01707b30 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -237,3 +237,9 @@ EXECUTE stmt; DROP PREPARE stmt; set storage_engine=@orig_storage_engine; + +-- +-- Drop some tables not used anymore in MariaDB +--- + +drop table if exists mysql.ndb_binlog_index; diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 6136c39fc9c..062e59bee5b 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -123,7 +123,7 @@ SET (SQL_SOURCE sql_profile.cc event_parse_data.cc sql_alter.cc sql_signal.cc rpl_handler.cc mdl.cc sql_admin.cc transaction.cc sys_vars.cc sql_truncate.cc datadict.cc - sql_reload.cc sql_cmd.h item_inetfunc.cc + sql_reload.cc sql_cmd.h item_inetfunc.cc # added in MariaDB: sql_explain.h sql_explain.cc @@ -138,6 +138,7 @@ SET (SQL_SOURCE my_json_writer.cc my_json_writer.h rpl_gtid.cc rpl_parallel.cc sql_type.cc sql_type.h + item_windowfunc.cc sql_window.cc sql_cte.cc sql_cte.h ${WSREP_SOURCES} table_cache.cc encryption.cc diff --git a/sql/derror.cc b/sql/derror.cc index bc4b89493aa..5a1bee23f4a 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -30,16 +30,19 @@ #include "derror.h" // read_texts #include "sql_class.h" // THD +uint errors_per_range[MAX_ERROR_RANGES+1]; + static bool check_error_mesg(const char *file_name, const char **errmsg); static void init_myfunc_errs(void); C_MODE_START -static const char **get_server_errmsgs() +static const char **get_server_errmsgs(int nr) { + int section= (nr-ER_ERROR_FIRST) / ERRORS_PER_RANGE; if (!current_thd) - return DEFAULT_ERRMSGS; - return CURRENT_THD_ERRMSGS; + return DEFAULT_ERRMSGS[section]; + return CURRENT_THD_ERRMSGS[section]; } C_MODE_END @@ -60,61 +63,88 @@ C_MODE_END TRUE Error */ +static const char ***original_error_messages; + bool init_errmessage(void) { - const char **errmsgs, **ptr, **org_errmsgs; + const char **errmsgs; bool error= FALSE; DBUG_ENTER("init_errmessage"); - /* - Get a pointer to the old error messages pointer array. - read_texts() tries to free it. - */ - org_errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); + free_error_messages(); + my_free(original_error_messages); + original_error_messages= 0; + + error_message_charset_info= system_charset_info; /* Read messages from file. */ if (read_texts(ERRMSG_FILE, my_default_lc_messages->errmsgs->language, - &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) && - !errmsgs) + &original_error_messages)) { - my_free(errmsgs); - - if (org_errmsgs) - { - /* Use old error messages */ - errmsgs= org_errmsgs; - } - else + /* + No error messages. Create a temporary empty error message so + that we don't get a crash if some code wrongly tries to access + a non existing error message. + */ + if (!(original_error_messages= (const char***) + my_malloc(MAX_ERROR_RANGES * sizeof(char**) + + (ERRORS_PER_RANGE * sizeof(char*)), + MYF(0)))) + DBUG_RETURN(TRUE); + errmsgs= (const char**) (original_error_messages + MAX_ERROR_RANGES); + + for (uint i=0 ; i < MAX_ERROR_RANGES ; i++) { - /* - No error messages. Create a temporary empty error message so - that we don't get a crash if some code wrongly tries to access - a non existing error message. - */ - if (!(errmsgs= (const char**) my_malloc((ER_ERROR_LAST-ER_ERROR_FIRST+1)* - sizeof(char*), MYF(0)))) - DBUG_RETURN(TRUE); - for (ptr= errmsgs; ptr < errmsgs + ER_ERROR_LAST - ER_ERROR_FIRST; ptr++) - *ptr= ""; - error= TRUE; + original_error_messages[i]= errmsgs; + errors_per_range[i]= ERRORS_PER_RANGE; } + errors_per_range[2]= 0; // MYSYS error messages + + for (const char **ptr= errmsgs; + ptr < errmsgs + ERRORS_PER_RANGE ; + ptr++) + *ptr= ""; + + error= TRUE; } - else - my_free(org_errmsgs); // Free old language /* Register messages for use with my_error(). */ - if (my_error_register(get_server_errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST)) + for (uint i=0 ; i < MAX_ERROR_RANGES ; i++) { - my_free(errmsgs); - DBUG_RETURN(TRUE); + if (errors_per_range[i]) + { + if (my_error_register(get_server_errmsgs, (i+1)*ERRORS_PER_RANGE, + (i+1)*ERRORS_PER_RANGE + + errors_per_range[i]-1)) + { + my_free(original_error_messages); + original_error_messages= 0; + DBUG_RETURN(TRUE); + } + } } - - DEFAULT_ERRMSGS= errmsgs; /* Init global variable */ + DEFAULT_ERRMSGS= original_error_messages; init_myfunc_errs(); /* Init myfunc messages */ DBUG_RETURN(error); } +void free_error_messages() +{ + /* We don't need to free errmsg as it's done in cleanup_errmsg */ + for (uint i= 0 ; i < MAX_ERROR_RANGES ; i++) + { + if (errors_per_range[i]) + { + my_error_unregister((i+1)*ERRORS_PER_RANGE, + (i+1)*ERRORS_PER_RANGE + + errors_per_range[i]-1); + errors_per_range[i]= 0; + } + } +} + + /** Check the error messages array contains all relevant error messages */ @@ -125,11 +155,17 @@ static bool check_error_mesg(const char *file_name, const char **errmsg) The last MySQL error message can't be an empty string; If it is, it means that the error file doesn't contain all MySQL messages and is probably from an older version of MySQL / MariaDB. + We also check that each section has enough error messages. */ - if (errmsg[ER_LAST_MYSQL_ERROR_MESSAGE -1 - ER_ERROR_FIRST][0] == 0) + if (errmsg[ER_LAST_MYSQL_ERROR_MESSAGE -1 - ER_ERROR_FIRST][0] == 0 || + (errors_per_range[0] < ER_ERROR_LAST_SECTION_2 - ER_ERROR_FIRST + 1) || + errors_per_range[1] != 0 || + (errors_per_range[2] < ER_ERROR_LAST_SECTION_4 - + ER_ERROR_FIRST_SECTION_4 +1) || + (errors_per_range[3] < ER_ERROR_LAST - ER_ERROR_FIRST_SECTION_5 + 1)) { sql_print_error("Error message file '%s' is probably from and older " - "version of MariaDB / MYSQL as it doesn't contain all " + "version of MariaDB as it doesn't contain all " "error messages", file_name); return 1; } @@ -137,27 +173,28 @@ static bool check_error_mesg(const char *file_name, const char **errmsg) } -/** - Read text from packed textfile in language-directory. +struct st_msg_file +{ + uint sections; + uint max_error; + uint errors; + size_t text_length; +}; - If we can't read messagefile then it's panic- we can't continue. +/** + Open file for packed textfile in language-directory. */ -bool read_texts(const char *file_name, const char *language, - const char ***point, uint error_messages) +static File open_error_msg_file(const char *file_name, const char *language, + uint error_messages, struct st_msg_file *ret) { - register uint i; - uint count,funktpos; - size_t offset, length; + int error_pos= 0; File file; char name[FN_REFLEN]; char lang_path[FN_REFLEN]; - uchar *UNINIT_VAR(buff); - uchar head[32],*pos; - DBUG_ENTER("read_texts"); + uchar head[32]; + DBUG_ENTER("open_error_msg_file"); - *point= 0; - funktpos=0; convert_dirname(lang_path, language, NullS); (void) my_load_path(lang_path, lang_path, lc_messages_dir); if ((file= mysql_file_open(key_file_ERRMSG, @@ -168,69 +205,121 @@ bool read_texts(const char *file_name, const char *language, /* Trying pre-5.4 sematics of the --language parameter. It included the language-specific part, e.g.: - --language=/path/to/english/ */ if ((file= mysql_file_open(key_file_ERRMSG, - fn_format(name, file_name, lc_messages_dir, "", 4), + fn_format(name, file_name, lc_messages_dir, "", + 4), O_RDONLY | O_SHARE | O_BINARY, MYF(0))) < 0) goto err; sql_print_warning("An old style --language or -lc-message-dir value with language specific part detected: %s", lc_messages_dir); sql_print_warning("Use --lc-messages-dir without language specific part instead."); } - - funktpos=1; + error_pos=1; if (mysql_file_read(file, (uchar*) head, 32, MYF(MY_NABP))) goto err; - funktpos=2; + error_pos=2; if (head[0] != (uchar) 254 || head[1] != (uchar) 254 || - head[2] != 2 || head[3] != 3) + head[2] != 2 || head[3] != 4) goto err; /* purecov: inspected */ - error_message_charset_info= system_charset_info; - length=uint4korr(head+6); count=uint2korr(head+10); + ret->text_length= uint4korr(head+6); + ret->max_error= uint2korr(head+10); + ret->errors= uint2korr(head+12); + ret->sections= uint2korr(head+14); - if (count < error_messages) + if (ret->max_error < error_messages || ret->sections != MAX_ERROR_RANGES) { sql_print_error("\ Error message file '%s' had only %d error messages, but it should contain at least %d error messages.\nCheck that the above file is the right version for this program!", - name,count,error_messages); + name,ret->errors,error_messages); (void) mysql_file_close(file, MYF(MY_WME)); - DBUG_RETURN(1); + DBUG_RETURN(FERR); } + DBUG_RETURN(file); - if (!(*point= (const char**) - my_malloc((size_t) (MY_MAX(length,count*2)+count*sizeof(char*)),MYF(0)))) - { - funktpos=3; /* purecov: inspected */ +err: + sql_print_error((error_pos == 2) ? + "Incompatible header in messagefile '%s'. Probably from " + "another version of MariaDB" : + ((error_pos == 1) ? "Can't read from messagefile '%s'" : + "Can't find messagefile '%s'"), name); + if (file != FERR) + (void) mysql_file_close(file, MYF(MY_WME)); + DBUG_RETURN(FERR); +} + + +/* + Define the number of normal and extra error messages in the errmsg.sys + file +*/ + +static const uint error_messages= ER_ERROR_LAST - ER_ERROR_FIRST+1; + +/** + Read text from packed textfile in language-directory. +*/ + +bool read_texts(const char *file_name, const char *language, + const char ****data) +{ + uint i, range_size; + const char **point; + size_t offset; + File file; + uchar *buff, *pos; + struct st_msg_file msg_file; + DBUG_ENTER("read_texts"); + + if ((file= open_error_msg_file(file_name, language, error_messages, + &msg_file)) == FERR) + DBUG_RETURN(1); + + if (!(*data= (const char***) + my_malloc((size_t) ((MAX_ERROR_RANGES+1) * sizeof(char**) + + MY_MAX(msg_file.text_length, msg_file.errors * 2)+ + msg_file.errors * sizeof(char*)), + MYF(MY_WME)))) goto err; /* purecov: inspected */ - } - buff= (uchar*) (*point + count); - if (mysql_file_read(file, buff, (size_t) count*2, MYF(MY_NABP))) + point= (const char**) ((*data) + MAX_ERROR_RANGES); + buff= (uchar*) (point + msg_file.errors); + + if (mysql_file_read(file, buff, + (size_t) (msg_file.errors + msg_file.sections) * 2, + MYF(MY_NABP | MY_WME))) goto err; - for (i=0, offset=0, pos= buff ; i< count ; i++) + + pos= buff; + /* read in sections */ + for (i= 0, offset= 0; i < msg_file.sections ; i++) { - (*point)[i]= (char*) buff+offset; - offset+= uint2korr(pos); + (*data)[i]= point + offset; + errors_per_range[i]= range_size= uint2korr(pos); + offset+= range_size; + pos+= 2; + } + + /* Calculate pointers to text data */ + for (i=0, offset=0 ; i < msg_file.errors ; i++) + { + point[i]= (char*) buff+offset; + offset+=uint2korr(pos); pos+=2; } - if (mysql_file_read(file, buff, length, MYF(MY_NABP))) + + /* Read error message texts */ + if (mysql_file_read(file, buff, msg_file.text_length, MYF(MY_NABP | MY_WME))) goto err; - (void) mysql_file_close(file, MYF(0)); + (void) mysql_file_close(file, MYF(MY_WME)); - i= check_error_mesg(file_name, *point); - DBUG_RETURN(i); + DBUG_RETURN(check_error_mesg(file_name, point)); err: - sql_print_error((funktpos == 3) ? "Not enough memory for messagefile '%s'" : - (funktpos == 2) ? "Incompatible header in messagefile '%s'. Probably from another version of MariaDB" : - ((funktpos == 1) ? "Can't read from messagefile '%s'" : - "Can't find messagefile '%s'"), name); - if (file != FERR) - (void) mysql_file_close(file, MYF(MY_WME)); + (void) mysql_file_close(file, MYF(0)); DBUG_RETURN(1); } /* read_texts */ diff --git a/sql/derror.h b/sql/derror.h index b2f6331e048..9f2aee71c7e 100644 --- a/sql/derror.h +++ b/sql/derror.h @@ -19,7 +19,8 @@ #include "my_global.h" /* uint */ bool init_errmessage(void); +void free_error_messages(); bool read_texts(const char *file_name, const char *language, - const char ***point, uint error_messages); + const char ****data); #endif /* DERROR_INCLUDED */ diff --git a/sql/field.cc b/sql/field.cc index cf5be38398f..a5d2d759edc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1224,7 +1224,8 @@ bool Field::test_if_equality_guarantees_uniqueness(const Item *item) const for temporal columns, so the query: WHERE temporal_column='string' cannot return multiple distinct temporal values. - QQ: perhaps we could allow INT/DECIMAL/DOUBLE types for temporal items. + + TODO: perhaps we could allow INT/DECIMAL/DOUBLE types for temporal items. */ return result_type() == item->result_type(); } diff --git a/sql/filesort.cc b/sql/filesort.cc index 54a79421d2e..82a5c90d0bb 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -74,7 +74,6 @@ static bool check_if_pq_applicable(Sort_param *param, SORT_INFO *info, TABLE *table, ha_rows records, ulong memory_available); - void Sort_param::init_for_filesort(uint sortlen, TABLE *table, ulong max_length_for_sort_data, ha_rows maxrows, bool sort_positions) @@ -124,28 +123,21 @@ void Sort_param::init_for_filesort(uint sortlen, TABLE *table, @param thd Current thread @param table Table to sort - @param sortorder How to sort the table - @param s_length Number of elements in sortorder - @param select Condition to apply to the rows - @param max_rows Return only this many rows - @param sort_positions Set to TRUE if we want to force sorting by - position - (Needed by UPDATE/INSERT or ALTER TABLE or - when rowids are required by executor) + @param filesort How to sort the table + @param[out] found_rows Store the number of found rows here. + This is the number of found rows after + applying WHERE condition. @note - If we sort by position (like if sort_positions is 1) filesort() will - call table->prepare_for_position(). + If we sort by position (like if filesort->sort_positions==true) + filesort() will call table->prepare_for_position(). @retval 0 Error # SORT_INFO */ -SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, - uint s_length, - SQL_SELECT *select, ha_rows max_rows, - bool sort_positions, - Filesort_tracker* tracker) +SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort, + Filesort_tracker* tracker) { int error; size_t memory_available= thd->variables.sortbuff_size; @@ -156,9 +148,16 @@ SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, Sort_param param; bool multi_byte_charset; Bounded_queue<uchar, uchar> pq; + SQL_SELECT *const select= filesort->select; + ha_rows max_rows= filesort->limit; + uint s_length= 0; DBUG_ENTER("filesort"); - DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length);); + + if (!(s_length= filesort->make_sortorder(thd))) + DBUG_RETURN(NULL); /* purecov: inspected */ + + DBUG_EXECUTE("info",TEST_filesort(filesort->sortorder,s_length);); #ifdef SKIP_DBUG_IN_FILESORT DBUG_PUSH(""); /* No DBUG here */ #endif @@ -194,11 +193,11 @@ SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, error= 1; sort->found_rows= HA_POS_ERROR; - param.init_for_filesort(sortlength(thd, sortorder, s_length, + param.init_for_filesort(sortlength(thd, filesort->sortorder, s_length, &multi_byte_charset), table, thd->variables.max_length_for_sort_data, - max_rows, sort_positions); + max_rows, filesort->sort_positions); sort->addon_buf= param.addon_buf; sort->addon_field= param.addon_field; @@ -275,7 +274,7 @@ SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, goto err; param.sort_form= table; - param.end=(param.local_sortorder=sortorder)+s_length; + param.end=(param.local_sortorder=filesort->sortorder)+s_length; num_rows= find_all_keys(thd, ¶m, select, sort, &buffpek_pointers, @@ -429,6 +428,55 @@ SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, } /* filesort */ +void Filesort::cleanup() +{ + if (select && own_select) + { + select->cleanup(); + select= NULL; + } +} + + +uint Filesort::make_sortorder(THD *thd) +{ + uint count; + SORT_FIELD *sort,*pos; + ORDER *ord; + DBUG_ENTER("make_sortorder"); + + + count=0; + for (ord = order; ord; ord= ord->next) + count++; + if (!sortorder) + sortorder= (SORT_FIELD*) thd->alloc(sizeof(SORT_FIELD) * (count + 1)); + pos= sort= sortorder; + + if (!pos) + DBUG_RETURN(0); + + for (ord= order; ord; ord= ord->next, pos++) + { + Item *item= ord->item[0]->real_item(); + pos->field= 0; pos->item= 0; + if (item->type() == Item::FIELD_ITEM) + pos->field= ((Item_field*) item)->field; + else if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item()) + pos->field= ((Item_sum*) item)->get_tmp_table_field(); + else if (item->type() == Item::COPY_STR_ITEM) + { // Blob patch + pos->item= ((Item_copy*) item)->get_item(); + } + else + pos->item= *ord->item; + pos->reverse= (ord->direction == ORDER::ORDER_DESC); + DBUG_ASSERT(pos->field != NULL || pos->item != NULL); + } + DBUG_RETURN(count); + } + + /** Read 'count' number of buffer pointers into memory. */ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, diff --git a/sql/filesort.h b/sql/filesort.h index 454c745b5c0..18029a10c14 100644 --- a/sql/filesort.h +++ b/sql/filesort.h @@ -17,13 +17,67 @@ #define FILESORT_INCLUDED #include "my_base.h" /* ha_rows */ +#include "sql_list.h" /* Sql_alloc */ #include "filesort_utils.h" class SQL_SELECT; class THD; struct TABLE; -struct SORT_FIELD; class Filesort_tracker; +struct SORT_FIELD; +typedef struct st_order ORDER; + + +/** + Sorting related info. + To be extended by another WL to include complete filesort implementation. +*/ +class Filesort: public Sql_alloc +{ +public: + /** List of expressions to order the table by */ + ORDER *order; + /** Number of records to return */ + ha_rows limit; + /** ORDER BY list with some precalculated info for filesort */ + SORT_FIELD *sortorder; + /** select to use for getting records */ + SQL_SELECT *select; + /** TRUE <=> free select on destruction */ + bool own_select; + /** true means we are using Priority Queue for order by with limit. */ + bool using_pq; + + /* + TRUE means sort operation must produce table rowids. + FALSE means that it halso has an option of producing {sort_key, + addon_fields} pairs. + */ + bool sort_positions; + + Filesort_tracker *tracker; + + Filesort(ORDER *order_arg, ha_rows limit_arg, bool sort_positions_arg, + SQL_SELECT *select_arg): + order(order_arg), + limit(limit_arg), + sortorder(NULL), + select(select_arg), + own_select(false), + using_pq(false), + sort_positions(sort_positions_arg) + { + DBUG_ASSERT(order); + }; + + ~Filesort() { cleanup(); } + /* Prepare ORDER BY list for sorting. */ + uint make_sortorder(THD *thd); + +private: + void cleanup(); +}; + class SORT_INFO { @@ -97,19 +151,12 @@ public: size_t sort_buffer_size() const { return filesort_buffer.sort_buffer_size(); } - friend SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, - uint s_length, - SQL_SELECT *select, ha_rows max_rows, - bool sort_positions, - Filesort_tracker* tracker); + friend SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort, + Filesort_tracker* tracker); }; - -SORT_INFO *filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, - uint s_length, - SQL_SELECT *select, ha_rows max_rows, - bool sort_positions, - Filesort_tracker* tracker); +SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort, + Filesort_tracker* tracker); void change_double_for_sort(double nr,uchar *to); diff --git a/sql/handler.cc b/sql/handler.cc index 748a51f5c59..2186d389056 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -295,7 +295,7 @@ handler *get_ha_partition(partition_info *part_info) static const char **handler_errmsgs; C_MODE_START -static const char **get_handler_errmsgs() +static const char **get_handler_errmsgs(int nr) { return handler_errmsgs; } @@ -386,12 +386,10 @@ int ha_init_errors(void) */ static int ha_finish_errors(void) { - const char **errmsgs; - /* Allocate a pointer array for the error message strings. */ - if (! (errmsgs= my_error_unregister(HA_ERR_FIRST, HA_ERR_LAST))) - return 1; - my_free(errmsgs); + my_error_unregister(HA_ERR_FIRST, HA_ERR_LAST); + my_free(handler_errmsgs); + handler_errmsgs= 0; return 0; } @@ -3079,6 +3077,7 @@ int handler::update_auto_increment() if (unlikely(nr == ULONGLONG_MAX)) DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); + DBUG_ASSERT(nr != 0); DBUG_PRINT("info",("auto_increment: %llu nb_reserved_values: %llu", nr, append ? nb_reserved_values : 0)); diff --git a/sql/item.cc b/sql/item.cc index 7cdb2d2e7e4..65fb00d4757 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -455,7 +455,7 @@ Item::Item(THD *thd): { DBUG_ASSERT(thd); marker= 0; - maybe_null=null_value=with_sum_func=with_field=0; + maybe_null=null_value=with_sum_func=with_window_func=with_field=0; in_rollup= 0; with_subselect= 0; /* Initially this item is not attached to any JOIN_TAB. */ @@ -500,6 +500,7 @@ Item::Item(THD *thd, Item *item): in_rollup(item->in_rollup), null_value(item->null_value), with_sum_func(item->with_sum_func), + with_window_func(item->with_window_func), with_field(item->with_field), fixed(item->fixed), is_autogenerated_name(item->is_autogenerated_name), @@ -1749,7 +1750,7 @@ public: thd->fatal_error() may be called if we are out of memory */ -void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, +void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, Item **ref, uint split_flags) { @@ -1760,6 +1761,14 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, ((Item_sum *) this)->ref_by) return; } + else if (type() == WINDOW_FUNC_ITEM) + { + /* + Skip the else part, window functions are very special functions: + they need to have their own fields in the temp. table, but they + need to be proceessed differently than regular aggregate functions + */ + } else { /* Not a SUM() function */ @@ -1800,7 +1809,7 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, Exception is Item_direct_view_ref which we need to convert to Item_ref to allow fields from view being stored in tmp table. */ - Item_aggregate_ref *item_ref; + Item_ref *item_ref; uint el= fields.elements; /* If this is an item_ref, get the original item @@ -1810,13 +1819,24 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, Item *real_itm= real_item(); ref_pointer_array[el]= real_itm; - if (!(item_ref= (new (thd->mem_root) - Item_aggregate_ref(thd, - &thd->lex->current_select->context, - ref_pointer_array + el, 0, name)))) - return; // fatal_error is set + if (type() == WINDOW_FUNC_ITEM) + { + if (!(item_ref= (new (thd->mem_root) + Item_direct_ref(thd, + &thd->lex->current_select->context, + &ref_pointer_array[el], 0, name)))) + return; // fatal_error is set + } + else + { + if (!(item_ref= (new (thd->mem_root) + Item_aggregate_ref(thd, + &thd->lex->current_select->context, + &ref_pointer_array[el], 0, name)))) + return; // fatal_error is set + } if (type() == SUM_FUNC_ITEM) - item_ref->depended_from= ((Item_sum *) this)->depended_from(); + item_ref->depended_from= ((Item_sum *) this)->depended_from(); fields.push_front(real_itm); thd->change_item_tree(ref, item_ref); } @@ -3755,16 +3775,18 @@ Item_param::set_value(THD *thd, sp_rcontext *ctx, Item **it) str_value.charset()); collation.set(str_value.charset(), DERIVATION_COERCIBLE); decimals= 0; - + item_type= Item::STRING_ITEM; break; } case REAL_RESULT: set_double(arg->val_real()); + item_type= Item::REAL_ITEM; break; case INT_RESULT: set_int(arg->val_int(), arg->max_length); + item_type= Item::INT_ITEM; break; case DECIMAL_RESULT: @@ -3776,6 +3798,7 @@ Item_param::set_value(THD *thd, sp_rcontext *ctx, Item **it) return TRUE; set_decimal(dv); + item_type= Item::DECIMAL_ITEM; break; } @@ -3785,11 +3808,11 @@ Item_param::set_value(THD *thd, sp_rcontext *ctx, Item **it) DBUG_ASSERT(TRUE); // Abort in debug mode. set_null(); // Set to NULL in release mode. + item_type= Item::NULL_ITEM; return FALSE; } set_handler_by_result_type(arg->result_type()); - item_type= arg->type(); return FALSE; } @@ -4489,7 +4512,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select) return NULL; } DBUG_ASSERT((*select_ref)->fixed); - return (select->ref_pointer_array + counter); + return &select->ref_pointer_array[counter]; } if (group_by_ref) return group_by_ref; @@ -6516,15 +6539,14 @@ Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg) type() != Item::TRIGGER_FIELD_ITEM) { List<Item> *all_fields= &select->join->all_fields; - Item **ref_pointer_array= select->ref_pointer_array; - DBUG_ASSERT(all_fields->elements <= select->ref_pointer_array_size); + Ref_ptr_array &ref_pointer_array= select->ref_pointer_array; int el= all_fields->elements; Item_ref *ref; ref_pointer_array[el]= (Item*)this; all_fields->push_front((Item*)this, thd->mem_root); ref= new (thd->mem_root) - Item_ref(thd, &select->context, ref_pointer_array + el, + Item_ref(thd, &select->context, &ref_pointer_array[el], table_name, field_name); return ref; } @@ -6928,6 +6950,7 @@ void Item_ref::set_properties() split_sum_func() doesn't try to change the reference. */ with_sum_func= (*ref)->with_sum_func; + with_window_func= (*ref)->with_window_func; with_field= (*ref)->with_field; fixed= 1; if (alias_name_used) diff --git a/sql/item.h b/sql/item.h index e42442aa301..674ff6e99dc 100644 --- a/sql/item.h +++ b/sql/item.h @@ -65,6 +65,8 @@ class RANGE_OPT_PARAM; class SEL_TREE; +typedef Bounds_checked_array<Item*> Ref_ptr_array; + static inline uint32 char_to_byte_length_safe(uint32 char_length_arg, uint32 mbmaxlen_arg) { @@ -626,7 +628,8 @@ public: static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} - enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, + enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, + WINDOW_FUNC_ITEM, STRING_ITEM, INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM, PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM, @@ -692,6 +695,7 @@ public: of a query with ROLLUP */ bool null_value; /* if item is null */ bool with_sum_func; /* True if item contains a sum func */ + bool with_window_func; /* True if item contains a window func */ /** True if any item except Item_sum contains a field. Set during parsing. */ @@ -1180,7 +1184,7 @@ public: void print_item_w_name(String *, enum_query_type query_type); void print_value(String *); virtual void update_used_tables() {} - virtual COND *build_equal_items(THD *thd, COND_EQUAL *inherited, + virtual COND *build_equal_items(THD *thd, COND_EQUAL *inheited, bool link_item_fields, COND_EQUAL **cond_equal_ref) { @@ -1216,10 +1220,11 @@ public: { return false; } - virtual void split_sum_func(THD *thd, Item **ref_pointer_array, + virtual void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) {} /* Called for items that really have to be split */ - void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields, + void split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, Item **ref, uint flags); virtual bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); bool get_time(MYSQL_TIME *ltime) @@ -4768,17 +4773,10 @@ public: - cmp() method that compares the saved value with the current value of the source item, and if they were not equal saves item's value into the saved value. -*/ -/* - Cached_item_XXX objects are not exactly caches. They do the following: - - Each Cached_item_XXX object has - - its source item - - saved value of the source item - - cmp() method that compares the saved value with the current value of the - source item, and if they were not equal saves item's value into the saved - value. + TODO: add here: + - a way to save the new value w/o comparison + - a way to do less/equal/greater comparison */ class Cached_item :public Sql_alloc @@ -4786,48 +4784,75 @@ class Cached_item :public Sql_alloc public: bool null_value; Cached_item() :null_value(0) {} + /* + Compare the cached value with the source value. If not equal, copy + the source value to the cache. + @return + true - Not equal + false - Equal + */ virtual bool cmp(void)=0; + + /* Compare the cached value with the source value, without copying */ + virtual int cmp_read_only()=0; + virtual ~Cached_item(); /*line -e1509 */ }; -class Cached_item_str :public Cached_item +class Cached_item_item : public Cached_item { +protected: Item *item; + + Cached_item_item(Item *arg) : item(arg) {} +public: + void fetch_value_from(Item *new_item) + { + Item *save= item; + item= new_item; + cmp(); + item= save; + } +}; + +class Cached_item_str :public Cached_item_item +{ uint32 value_max_length; String value,tmp_value; public: Cached_item_str(THD *thd, Item *arg); bool cmp(void); + int cmp_read_only(); ~Cached_item_str(); // Deallocate String:s }; -class Cached_item_real :public Cached_item +class Cached_item_real :public Cached_item_item { - Item *item; double value; public: - Cached_item_real(Item *item_par) :item(item_par),value(0.0) {} + Cached_item_real(Item *item_par) :Cached_item_item(item_par),value(0.0) {} bool cmp(void); + int cmp_read_only(); }; -class Cached_item_int :public Cached_item +class Cached_item_int :public Cached_item_item { - Item *item; longlong value; public: - Cached_item_int(Item *item_par) :item(item_par),value(0) {} + Cached_item_int(Item *item_par) :Cached_item_item(item_par),value(0) {} bool cmp(void); + int cmp_read_only(); }; -class Cached_item_decimal :public Cached_item +class Cached_item_decimal :public Cached_item_item { - Item *item; my_decimal value; public: Cached_item_decimal(Item *item_par); bool cmp(void); + int cmp_read_only(); }; class Cached_item_field :public Cached_item @@ -4844,6 +4869,7 @@ public: buff= (uchar*) thd_calloc(thd, length= field->pack_length()); } bool cmp(void); + int cmp_read_only(); }; class Item_default_value : public Item_field @@ -5129,7 +5155,7 @@ public: return (this->*processor)(arg); } virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); - void split_sum_func2_example(THD *thd, Item **ref_pointer_array, + void split_sum_func2_example(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) { example->split_sum_func2(thd, ref_pointer_array, fields, &example, flags); diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 62c2f76dc2e..488eb52fb77 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -71,7 +71,7 @@ Cached_item::~Cached_item() {} */ Cached_item_str::Cached_item_str(THD *thd, Item *arg) - :item(arg), + :Cached_item_item(arg), value_max_length(MY_MIN(arg->max_length, thd->variables.max_sort_length)), value(value_max_length) {} @@ -98,6 +98,25 @@ bool Cached_item_str::cmp(void) return tmp; } + +int Cached_item_str::cmp_read_only() +{ + String *res= item->val_str(&tmp_value); + + if (null_value) + { + if (item->null_value) + return 0; + else + return -1; + } + if (item->null_value) + return 1; + + return sortcmp(&value, res, item->collation.collation); +} + + Cached_item_str::~Cached_item_str() { item=0; // Safety @@ -115,6 +134,23 @@ bool Cached_item_real::cmp(void) return FALSE; } + +int Cached_item_real::cmp_read_only() +{ + double nr= item->val_real(); + if (null_value) + { + if (item->null_value) + return 0; + else + return -1; + } + if (item->null_value) + return 1; + return (nr == value)? 0 : ((nr < value)? 1: -1); +} + + bool Cached_item_int::cmp(void) { longlong nr=item->val_int(); @@ -128,6 +164,22 @@ bool Cached_item_int::cmp(void) } +int Cached_item_int::cmp_read_only() +{ + longlong nr= item->val_int(); + if (null_value) + { + if (item->null_value) + return 0; + else + return -1; + } + if (item->null_value) + return 1; + return (nr == value)? 0 : ((nr < value)? 1: -1); +} + + bool Cached_item_field::cmp(void) { bool tmp= FALSE; // Value is identical @@ -148,8 +200,24 @@ bool Cached_item_field::cmp(void) } +int Cached_item_field::cmp_read_only() +{ + if (null_value) + { + if (field->is_null()) + return 0; + else + return -1; + } + if (field->is_null()) + return 1; + + return field->cmp(buff); +} + + Cached_item_decimal::Cached_item_decimal(Item *it) - :item(it) + :Cached_item_item(it) { my_decimal_set_zero(&value); } @@ -174,3 +242,20 @@ bool Cached_item_decimal::cmp() return FALSE; } + +int Cached_item_decimal::cmp_read_only() +{ + my_decimal tmp; + my_decimal *ptmp= item->val_decimal(&tmp); + if (null_value) + { + if (item->null_value) + return 0; + else + return -1; + } + if (item->null_value) + return 1; + return my_decimal_cmp(&value, ptmp); +} + diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 579cdc10057..335228c37fa 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2482,7 +2482,7 @@ bool Item_func_if::date_op(MYSQL_TIME *ltime, uint fuzzydate) } -void Item_func_nullif::split_sum_func(THD *thd, Item **ref_pointer_array, +void Item_func_nullif::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) { if (m_cache) @@ -4791,7 +4791,7 @@ void Item_cond::traverse_cond(Cond_traverser traverser, that have or refer (HAVING) to a SUM expression. */ -void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array, +void Item_cond::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) { List_iterator<Item> li(list); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 2d197a86d9b..5789186dbe8 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1030,8 +1030,8 @@ public: uint decimal_precision() const { return args[2]->decimal_precision(); } const char *func_name() const { return "nullif"; } void print(String *str, enum_query_type query_type); - void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields, - uint flags); + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags); void update_used_tables(); table_map not_null_tables() const { return 0; } bool is_null(); @@ -2055,8 +2055,8 @@ public: SARGABLE_PARAM **sargables); SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr); virtual void print(String *str, enum_query_type query_type); - void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields, - uint flags); + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags); friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds); void top_level_item() { abort_on_null=1; } @@ -2083,7 +2083,7 @@ template <template<class> class LI, class T> class Item_equal_iterator; All equality predicates of the form field1=field2 contained in a conjunction are substituted for a sequence of items of this class. An item of this class Item_equal(f1,f2,...fk) represents a - multiple equality f1=f2=...=fk. + multiple equality f1=f2=...=fk.l If a conjunction contains predicates f1=f2 and f2=f3, a new item of this class is created Item_equal(f1,f2,f3) representing the multiple diff --git a/sql/item_func.cc b/sql/item_func.cc index 50b6f4a6b68..57bd004cf88 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -132,6 +132,7 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list) while ((item= li++)) { with_sum_func|= item->with_sum_func; + with_window_func|= item->with_window_func; with_field|= item->with_field; } } @@ -226,6 +227,7 @@ Item_func::fix_fields(THD *thd, Item **ref) maybe_null=1; with_sum_func= with_sum_func || item->with_sum_func; + with_window_func= with_window_func || item->with_window_func; with_field= with_field || item->with_field; used_tables_and_const_cache_join(item); with_subselect|= item->has_subquery(); @@ -431,7 +433,7 @@ void Item_args::propagate_equal_fields(THD *thd, See comments in Item_cond::split_sum_func() */ -void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array, +void Item_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) { Item **arg, **arg_end; @@ -4904,9 +4906,16 @@ Item_func_set_user_var::update_hash(void *ptr, uint length, If we set a variable explicitely to NULL then keep the old result type of the variable */ - if ((null_value= args[0]->null_value) && null_item) + if (args[0]->type() == Item::FIELD_ITEM) + { + /* args[0]->null_value may be outdated */ + null_value= ((Item_field*)args[0])->field->is_null(); + } + else + null_value= args[0]->null_value; + if (null_value && null_item) res_type= m_var_entry->type; // Don't change type of item - if (::update_hash(m_var_entry, (null_value= args[0]->null_value), + if (::update_hash(m_var_entry, null_value, ptr, length, res_type, cs, unsigned_arg)) { null_value= 1; diff --git a/sql/item_func.h b/sql/item_func.h index 2ce199b3565..5c21535adbe 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -151,8 +151,8 @@ public: sync_with_sum_func_and_with_field(list); list.empty(); // Fields are used } - void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields, - uint flags); + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags); virtual void print(String *str, enum_query_type query_type); void print_op(String *str, enum_query_type query_type); void print_args(String *str, uint from, enum_query_type query_type); diff --git a/sql/item_row.cc b/sql/item_row.cc index b1575b81087..56d73f7b759 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -100,7 +100,7 @@ void Item_row::cleanup() } -void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array, +void Item_row::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) { Item **arg, **arg_end; diff --git a/sql/item_row.h b/sql/item_row.h index 153a6f085b3..ddb6f0835f2 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -85,8 +85,8 @@ public: bool fix_fields(THD *thd, Item **ref); void fix_after_pullout(st_select_lex *new_parent, Item **ref); void cleanup(); - void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields, - uint flags); + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags); table_map used_tables() const { return used_tables_cache; }; bool const_item() const { return const_item_cache; }; enum Item_result result_type() const { return ROW_RESULT; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 8745baa8c69..94e7bc98618 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -739,7 +739,7 @@ int Item_in_subselect::optimize(double *out_rows, double *cost) } /* Now with grouping */ - if (join->group_list) + if (join->group_list_for_estimates) { DBUG_PRINT("info",("Materialized join has grouping, trying to estimate it")); double output_rows= get_post_group_estimate(join, *out_rows); @@ -1896,7 +1896,8 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) (ALL && (> || =>)) || (ANY && (< || =<)) for ALL condition is inverted */ - item= new (thd->mem_root) Item_sum_max(thd, *select_lex->ref_pointer_array); + item= new (thd->mem_root) Item_sum_max(thd, + select_lex->ref_pointer_array[0]); } else { @@ -1904,11 +1905,12 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) (ALL && (< || =<)) || (ANY && (> || =>)) for ALL condition is inverted */ - item= new (thd->mem_root) Item_sum_min(thd, *select_lex->ref_pointer_array); + item= new (thd->mem_root) Item_sum_min(thd, + select_lex->ref_pointer_array[0]); } if (upper_item) upper_item->set_sum_test(item); - thd->change_item_tree(select_lex->ref_pointer_array, item); + thd->change_item_tree(&select_lex->ref_pointer_array[0], item); { List_iterator<Item> it(select_lex->item_list); it++; @@ -2054,8 +2056,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join, thd, &select_lex->context, this, - select_lex-> - ref_pointer_array, + &select_lex-> + ref_pointer_array[0], (char *)"<ref>", this->full_name())); if (!abort_on_null && left_expr->maybe_null) @@ -2130,7 +2132,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join, new (thd->mem_root) Item_ref_null_helper(thd, &select_lex->context, this, - select_lex->ref_pointer_array, + &select_lex->ref_pointer_array[0], (char *)"<no matter>", (char *)"<result>")); if (!abort_on_null && left_expr->maybe_null) @@ -2317,7 +2319,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, (char *)in_left_expr_name), new (thd->mem_root) Item_ref(thd, &select_lex->context, - select_lex->ref_pointer_array + i, + &select_lex->ref_pointer_array[i], (char *)"<no matter>", (char *)"<list ref>")); Item *item_isnull= @@ -2325,7 +2327,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, Item_func_isnull(thd, new (thd->mem_root) Item_ref(thd, &select_lex->context, - select_lex->ref_pointer_array+i, + &select_lex->ref_pointer_array[i], (char *)"<no matter>", (char *)"<list ref>")); Item *col_item= new (thd->mem_root) @@ -2343,8 +2345,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, Item_is_not_null_test(thd, this, new (thd->mem_root) Item_ref(thd, &select_lex->context, - select_lex-> - ref_pointer_array + i, + &select_lex-> + ref_pointer_array[i], (char *)"<no matter>", (char *)"<list ref>")); if (!abort_on_null && left_expr->element_index(i)->maybe_null) @@ -2382,8 +2384,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, (char *)in_left_expr_name), new (thd->mem_root) Item_direct_ref(thd, &select_lex->context, - select_lex-> - ref_pointer_array+i, + &select_lex-> + ref_pointer_array[i], (char *)"<no matter>", (char *)"<list ref>")); if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null) @@ -2393,7 +2395,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, Item_is_not_null_test(thd, this, new (thd->mem_root) Item_ref(thd, &select_lex->context, - select_lex->ref_pointer_array + i, + &select_lex->ref_pointer_array[i], (char *)"<no matter>", (char *)"<list ref>")); @@ -2402,8 +2404,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, Item_func_isnull(thd, new (thd->mem_root) Item_direct_ref(thd, &select_lex->context, - select_lex-> - ref_pointer_array+i, + &select_lex-> + ref_pointer_array[i], (char *)"<no matter>", (char *)"<list ref>")); item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull); @@ -3533,8 +3535,7 @@ int subselect_single_select_engine::prepare() prepared= 1; SELECT_LEX *save_select= thd->lex->current_select; thd->lex->current_select= select_lex; - if (join->prepare(&select_lex->ref_pointer_array, - select_lex->table_list.first, + if (join->prepare(select_lex->table_list.first, select_lex->with_wild, select_lex->where, select_lex->order_list.elements + @@ -3683,14 +3684,6 @@ int subselect_single_select_engine::exec() */ select_lex->uncacheable|= UNCACHEABLE_EXPLAIN; select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; - /* - Force join->join_tmp creation, because this subquery will be replaced - by a simple select from the materialization temp table by optimize() - called by EXPLAIN and we need to preserve the initial query structure - so we can display it. - */ - if (join->need_tmp && join->init_save_join_tab()) - DBUG_RETURN(1); /* purecov: inspected */ } } if (item->engine_changed(this)) @@ -5231,7 +5224,7 @@ double get_post_group_estimate(JOIN* join, double join_op_rows) table_map tables_in_group_list= table_map(0); /* Find out which tables are used in GROUP BY list */ - for (ORDER *order= join->group_list; order; order= order->next) + for (ORDER *order= join->group_list_for_estimates; order; order= order->next) { Item *item= order->item[0]; table_map item_used_tables= item->used_tables(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 0c85cf53e18..f774ee5a561 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1243,7 +1243,8 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table) Item_sum_sum::Item_sum_sum(THD *thd, Item_sum_sum *item) :Item_sum_num(thd, item), Type_handler_hybrid_field_type(item), - curr_dec_buff(item->curr_dec_buff) + curr_dec_buff(item->curr_dec_buff), + count(item->count) { /* TODO: check if the following assignments are really needed */ if (Item_sum_sum::result_type() == DECIMAL_RESULT) @@ -1265,6 +1266,7 @@ void Item_sum_sum::clear() { DBUG_ENTER("Item_sum_sum::clear"); null_value=1; + count= 0; if (Item_sum_sum::result_type() == DECIMAL_RESULT) { curr_dec_buff= 0; @@ -1318,25 +1320,57 @@ void Item_sum_sum::fix_length_and_dec() bool Item_sum_sum::add() { DBUG_ENTER("Item_sum_sum::add"); + add_helper(false); + DBUG_RETURN(0); +} + +void Item_sum_sum::add_helper(bool perform_removal) +{ + DBUG_ENTER("Item_sum_sum::add_helper"); + if (Item_sum_sum::result_type() == DECIMAL_RESULT) { my_decimal value; const my_decimal *val= aggr->arg_val_decimal(&value); if (!aggr->arg_is_null(true)) { - my_decimal_add(E_DEC_FATAL_ERROR, dec_buffs + (curr_dec_buff^1), - val, dec_buffs + curr_dec_buff); + if (perform_removal) + { + DBUG_ASSERT(count > 0); + my_decimal_sub(E_DEC_FATAL_ERROR, dec_buffs + (curr_dec_buff ^ 1), + dec_buffs + curr_dec_buff, val); + count--; + } + else + { + count++; + my_decimal_add(E_DEC_FATAL_ERROR, dec_buffs + (curr_dec_buff ^ 1), + val, dec_buffs + curr_dec_buff); + } curr_dec_buff^= 1; - null_value= 0; + null_value= (count > 0) ? 0 : 1; } } else { - sum+= aggr->arg_val_real(); + if (perform_removal) + sum-= aggr->arg_val_real(); + else + sum+= aggr->arg_val_real(); if (!aggr->arg_is_null(true)) - null_value= 0; + { + if (perform_removal) + { + DBUG_ASSERT(count > 0); + count--; + } + else + count++; + + null_value= (count > 0) ? 0 : 1; + } } - DBUG_RETURN(0); + DBUG_VOID_RETURN; } @@ -1386,6 +1420,13 @@ my_decimal *Item_sum_sum::val_decimal(my_decimal *val) return val_decimal_from_real(val); } +void Item_sum_sum::remove() +{ + DBUG_ENTER("Item_sum_sum::remove"); + add_helper(true); + DBUG_VOID_RETURN; +} + /** Aggregate a distinct row from the distinct hash table. @@ -1531,6 +1572,19 @@ bool Item_sum_count::add() return 0; } + +/* + Remove a row. This is used by window functions. +*/ + +void Item_sum_count::remove() +{ + DBUG_ASSERT(aggr->Aggrtype() == Aggregator::SIMPLE_AGGREGATOR); + if (aggr->arg_is_null(false)) + return; + count--; +} + longlong Item_sum_count::val_int() { DBUG_ASSERT(fixed == 1); @@ -1626,6 +1680,16 @@ bool Item_sum_avg::add() return FALSE; } +void Item_sum_avg::remove() +{ + Item_sum_sum::remove(); + if (!aggr->arg_is_null(true)) + { + DBUG_ASSERT(count > 0); + count--; + } +} + double Item_sum_avg::val_real() { DBUG_ASSERT(fixed == 1); @@ -2086,6 +2150,8 @@ longlong Item_sum_bit::val_int() void Item_sum_bit::clear() { bits= reset_bits; + if (as_window_function) + clear_as_window(); } Item *Item_sum_or::copy_or_same(THD* thd) @@ -2093,15 +2159,79 @@ Item *Item_sum_or::copy_or_same(THD* thd) return new (thd->mem_root) Item_sum_or(thd, this); } +bool Item_sum_bit::clear_as_window() +{ + memset(bit_counters, 0, sizeof(bit_counters)); + num_values_added= 0; + set_bits_from_counters(); + return 0; +} + +bool Item_sum_bit::remove_as_window(ulonglong value) +{ + DBUG_ASSERT(as_window_function); + for (int i= 0; i < NUM_BIT_COUNTERS; i++) + { + if (!bit_counters[i]) + { + // Don't attempt to remove values that were never added. + DBUG_ASSERT((value & (1 << i)) == 0); + continue; + } + bit_counters[i]-= (value & (1 << i)) ? 1 : 0; + } + DBUG_ASSERT(num_values_added > 0); + // Prevent overflow; + num_values_added = std::min(num_values_added, num_values_added - 1); + set_bits_from_counters(); + return 0; +} + +bool Item_sum_bit::add_as_window(ulonglong value) +{ + DBUG_ASSERT(as_window_function); + for (int i= 0; i < NUM_BIT_COUNTERS; i++) + { + bit_counters[i]+= (value & (1 << i)) ? 1 : 0; + } + // Prevent overflow; + num_values_added = std::max(num_values_added, num_values_added + 1); + set_bits_from_counters(); + return 0; +} + +void Item_sum_or::set_bits_from_counters() +{ + ulonglong value= 0; + for (int i= 0; i < NUM_BIT_COUNTERS; i++) + { + value|= bit_counters[i] > 0 ? (1 << i) : 0; + } + bits= value | reset_bits; +} bool Item_sum_or::add() { ulonglong value= (ulonglong) args[0]->val_int(); if (!args[0]->null_value) + { + if (as_window_function) + return add_as_window(value); bits|=value; + } return 0; } +void Item_sum_xor::set_bits_from_counters() +{ + ulonglong value= 0; + for (int i= 0; i < NUM_BIT_COUNTERS; i++) + { + value|= (bit_counters[i] % 2) ? (1 << i) : 0; + } + bits= value ^ reset_bits; +} + Item *Item_sum_xor::copy_or_same(THD* thd) { return new (thd->mem_root) Item_sum_xor(thd, this); @@ -2112,10 +2242,31 @@ bool Item_sum_xor::add() { ulonglong value= (ulonglong) args[0]->val_int(); if (!args[0]->null_value) + { + if (as_window_function) + return add_as_window(value); bits^=value; + } return 0; } +void Item_sum_and::set_bits_from_counters() +{ + ulonglong value= 0; + if (!num_values_added) + { + bits= reset_bits; + return; + } + + for (int i= 0; i < NUM_BIT_COUNTERS; i++) + { + // We've only added values of 1 for this bit. + if (bit_counters[i] == num_values_added) + value|= (1 << i); + } + bits= value & reset_bits; +} Item *Item_sum_and::copy_or_same(THD* thd) { return new (thd->mem_root) Item_sum_and(thd, this); @@ -2126,7 +2277,11 @@ bool Item_sum_and::add() { ulonglong value= (ulonglong) args[0]->val_int(); if (!args[0]->null_value) + { + if (as_window_function) + return add_as_window(value); bits&=value; + } return 0; } @@ -2314,6 +2469,10 @@ void Item_sum_bit::reset_field() void Item_sum_bit::update_field() { + // We never call update_field when computing the function as a window + // function. Setting bits to a random value invalidates the bits counters and + // the result of the bit function becomes erroneous. + DBUG_ASSERT(!as_window_function); uchar *res=result_field->ptr; bits= uint8korr(res); add(); @@ -2896,7 +3055,7 @@ int group_concat_key_cmp_with_order(void* arg, const void* key1, field->table->s->null_bytes); int res= field->cmp((uchar*)key1 + offset, (uchar*)key2 + offset); if (res) - return (*order_item)->asc ? res : -res; + return ((*order_item)->direction == ORDER::ORDER_ASC) ? res : -res; } /* We can't return 0 because in that case the tree class would remove this @@ -3372,8 +3531,8 @@ bool Item_func_group_concat::setup(THD *thd) if (!ref_pointer_array) DBUG_RETURN(TRUE); memcpy(ref_pointer_array, args, arg_count * sizeof(Item*)); - if (setup_order(thd, ref_pointer_array, context->table_list, list, - all_fields, *order)) + if (setup_order(thd, Ref_ptr_array(ref_pointer_array, n_elems), + context->table_list, list, all_fields, *order)) DBUG_RETURN(TRUE); } @@ -3507,9 +3666,9 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) if (i) str->append(','); orig_args[i + arg_count_field]->print(str, query_type); - if (order[i]->asc) + if (order[i]->direction == ORDER::ORDER_ASC) str->append(STRING_WITH_LEN(" ASC")); - else + else str->append(STRING_WITH_LEN(" DESC")); } } diff --git a/sql/item_sum.h b/sql/item_sum.h index 811e9d5c59c..e766e69a1c5 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -109,6 +109,7 @@ public: class st_select_lex; +class Window_spec; /** Class Item_sum is the base class used for special expressions that SQL calls @@ -347,7 +348,9 @@ public: enum Sumfunctype { COUNT_FUNC, COUNT_DISTINCT_FUNC, SUM_FUNC, SUM_DISTINCT_FUNC, AVG_FUNC, AVG_DISTINCT_FUNC, MIN_FUNC, MAX_FUNC, STD_FUNC, - VARIANCE_FUNC, SUM_BIT_FUNC, UDF_SUM_FUNC, GROUP_CONCAT_FUNC + VARIANCE_FUNC, SUM_BIT_FUNC, UDF_SUM_FUNC, GROUP_CONCAT_FUNC, + ROW_NUMBER_FUNC, RANK_FUNC, DENSE_RANK_FUNC, PERCENT_RANK_FUNC, + CUME_DIST_FUNC, NTILE_FUNC }; Item **ref_by; /* pointer to a ref to the object used to register it */ @@ -540,12 +543,16 @@ public: virtual void clear()= 0; virtual bool add()= 0; virtual bool setup(THD *thd) { return false; } + + virtual void remove() { DBUG_ASSERT(0); } virtual void cleanup(); bool check_vcol_func_processor(uchar *int_arg) { return trace_unsupported_by_check_vcol_func_processor(func_name()); } + + virtual void setup_window_func(THD *thd, Window_spec *window_spec) {} }; @@ -710,6 +717,7 @@ public: class Item_sum_int :public Item_sum_num { public: + Item_sum_int(THD *thd): Item_sum_num(thd) {} Item_sum_int(THD *thd, Item *item_par): Item_sum_num(thd, item_par) {} Item_sum_int(THD *thd, List<Item> &list): Item_sum_num(thd, list) {} Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {} @@ -724,7 +732,7 @@ public: class Item_sum_sum :public Item_sum_num, - public Type_handler_hybrid_field_type + public Type_handler_hybrid_field_type { protected: double sum; @@ -763,6 +771,11 @@ public: return has_with_distinct() ? "sum(distinct " : "sum("; } Item *copy_or_same(THD* thd); + void remove(); + +private: + void add_helper(bool perform_removal); + ulonglong count; }; @@ -775,6 +788,7 @@ class Item_sum_count :public Item_sum_int void clear(); bool add(); void cleanup(); + void remove(); public: Item_sum_count(THD *thd, Item *item_par): @@ -821,6 +835,8 @@ class Item_sum_count :public Item_sum_int class Item_sum_avg :public Item_sum_sum { public: + // TODO-cvicentiu given that Item_sum_sum now uses a counter of its own, in + // order to implement remove(), it is possible to remove this member. ulonglong count; uint prec_increment; uint f_precision, f_scale, dec_bin_size; @@ -839,6 +855,7 @@ public: } void clear(); bool add(); + void remove(); double val_real(); // In SPs we might force the "wrong" type with select into a declare variable longlong val_int() { return val_int_from_real(); } @@ -1019,14 +1036,18 @@ public: class Item_sum_bit :public Item_sum_int { -protected: - ulonglong reset_bits,bits; - public: Item_sum_bit(THD *thd, Item *item_par, ulonglong reset_arg): - Item_sum_int(thd, item_par), reset_bits(reset_arg), bits(reset_arg) {} + Item_sum_int(thd, item_par), reset_bits(reset_arg), bits(reset_arg), + as_window_function(FALSE), num_values_added(0) {} Item_sum_bit(THD *thd, Item_sum_bit *item): - Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits) {} + Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits), + as_window_function(item->as_window_function), + num_values_added(item->num_values_added) + { + if (as_window_function) + memcpy(bit_counters, item->bit_counters, sizeof(bit_counters)); + } enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;} void clear(); longlong val_int(); @@ -1037,8 +1058,42 @@ public: void cleanup() { bits= reset_bits; + if (as_window_function) + clear_as_window(); Item_sum_int::cleanup(); } + void setup_window_func(THD *thd __attribute__((unused)), + Window_spec *window_spec __attribute__((unused))) + { + as_window_function= TRUE; + clear_as_window(); + } + void remove() + { + if (as_window_function) + { + remove_as_window(args[0]->val_int()); + return; + } + // Unless we're counting bits, we can not remove anything. + DBUG_ASSERT(0); + } + +protected: + static const int NUM_BIT_COUNTERS= 64; + ulonglong reset_bits,bits; + /* + Marks whether the function is to be computed as a window function. + */ + bool as_window_function; + // When used as an aggregate window function, we need to store + // this additional information. + ulonglong num_values_added; + ulonglong bit_counters[NUM_BIT_COUNTERS]; + bool add_as_window(ulonglong value); + bool remove_as_window(ulonglong value); + bool clear_as_window(); + virtual void set_bits_from_counters()= 0; }; @@ -1050,28 +1105,37 @@ public: bool add(); const char *func_name() const { return "bit_or("; } Item *copy_or_same(THD* thd); + +private: + void set_bits_from_counters(); }; class Item_sum_and :public Item_sum_bit { - public: +public: Item_sum_and(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, ULONGLONG_MAX) {} Item_sum_and(THD *thd, Item_sum_and *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_and("; } Item *copy_or_same(THD* thd); + +private: + void set_bits_from_counters(); }; class Item_sum_xor :public Item_sum_bit { - public: +public: Item_sum_xor(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {} Item_sum_xor(THD *thd, Item_sum_xor *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_xor("; } Item *copy_or_same(THD* thd); + +private: + void set_bits_from_counters(); }; diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc new file mode 100644 index 00000000000..d157d545dad --- /dev/null +++ b/sql/item_windowfunc.cc @@ -0,0 +1,242 @@ +#include "item_windowfunc.h" +#include "my_dbug.h" +#include "my_global.h" +#include "sql_select.h" // test if group changed + + +bool +Item_window_func::resolve_window_name(THD *thd) +{ + if (window_spec) + { + /* The window name has been already resolved */ + return false; + } + DBUG_ASSERT(window_name != NULL && window_spec == NULL); + char *ref_name= window_name->str; + + /* !TODO: Add the code to resolve ref_name in outer queries */ + /* + First look for the deinition of the window with 'window_name' + in the current select + */ + List<Window_spec> curr_window_specs= + List<Window_spec> (thd->lex->current_select->window_specs); + List_iterator_fast<Window_spec> it(curr_window_specs); + Window_spec *win_spec; + while((win_spec= it++)) + { + char *win_spec_name= win_spec->name(); + if (win_spec_name && + my_strcasecmp(system_charset_info, ref_name, win_spec_name) == 0) + { + window_spec= win_spec; + break; + } + } + + if (!window_spec) + { + my_error(ER_WRONG_WINDOW_SPEC_NAME, MYF(0), ref_name); + return true; + } + + return false; +} + + +void +Item_window_func::update_used_tables() +{ + used_tables_cache= 0; + window_func()->update_used_tables(); + used_tables_cache|= window_func()->used_tables(); + for (ORDER *ord= window_spec->partition_list->first; ord; ord=ord->next) + { + Item *item= *ord->item; + item->update_used_tables(); + used_tables_cache|= item->used_tables(); + } + for (ORDER *ord= window_spec->order_list->first; ord; ord=ord->next) + { + Item *item= *ord->item; + item->update_used_tables(); + used_tables_cache|= item->used_tables(); + } +} + + +bool +Item_window_func::fix_fields(THD *thd, Item **ref) +{ + DBUG_ASSERT(fixed == 0); + + enum_parsing_place place= thd->lex->current_select->parsing_place; + + if (!(place == SELECT_LIST || place == IN_ORDER_BY)) + { + my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0)); + return true; + } + + if (window_name && resolve_window_name(thd)) + return true; + + if (window_spec->window_frame && is_frame_prohibited()) + { + my_error(ER_NOT_ALLOWED_WINDOW_FRAME, MYF(0), window_func()->func_name()); + return true; + } + + if (window_spec->order_list->elements == 0 && is_order_list_mandatory()) + { + my_error(ER_NO_ORDER_LIST_IN_WINDOW_SPEC, MYF(0), window_func()->func_name()); + return true; + } + /* + TODO: why the last parameter is 'ref' in this call? What if window_func + decides to substitute itself for something else and does *ref=.... ? + This will substitute *this (an Item_window_func object) with Item_sum + object. Is this the intent? + */ + if (window_func()->fix_fields(thd, ref)) + return true; + + const_item_cache= false; + with_window_func= true; + with_sum_func= false; + + fix_length_and_dec(); + + max_length= window_func()->max_length; + maybe_null= window_func()->maybe_null; + + fixed= 1; + set_phase_to_initial(); + return false; +} + + +/* + @detail + Window function evaluates its arguments when it is scanning the temporary + table in partition/order-by order. That is, arguments should be read from + the temporary table, not from the original base columns. + + In order for this to work, we need to call "split_sum_func" for each + argument. The effect of the call is: + 1. the argument is added into ref_pointer_array. This will cause the + argument to be saved in the temp.table + 2. argument item is replaced with an Item_ref object. this object refers + the argument through the ref_pointer_array. + + then, change_to_use_tmp_fields() will replace ref_pointer_array with an + array that points to the temp.table fields. + This way, when window_func attempts to evaluate its arguments, it will use + Item_ref objects which will read data from the temp.table. + + Note: Before window functions, aggregate functions never needed to do such + transformations on their arguments. This is because grouping operation + does not need to read from the temp.table. + (Q: what happens when we first sort and then do grouping in a + group-after-group mode? dont group by items read from temp.table, then?) +*/ + +void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags) +{ + for (uint i=0; i < window_func()->argument_count(); i++) + { + Item **p_item= &window_func()->arguments()[i]; + (*p_item)->split_sum_func2(thd, ref_pointer_array, fields, p_item, flags); + } +} + + +/* + This must be called before advance_window() can be called. + + @detail + If we attempt to do it in fix_fields(), partition_fields will refer + to the original window function arguments. + We need it to refer to temp.table columns. +*/ + +void Item_window_func::setup_partition_border_check(THD *thd) +{ + partition_tracker.init(thd, window_spec->partition_list); + window_func()->setup_window_func(thd, window_spec); +} + + +void Item_sum_rank::setup_window_func(THD *thd, Window_spec *window_spec) +{ + /* TODO: move this into Item_window_func? */ + peer_tracker.init(thd, window_spec->order_list); + clear(); +} + +void Item_sum_dense_rank::setup_window_func(THD *thd, Window_spec *window_spec) +{ + /* TODO: consider moving this && Item_sum_rank's implementation */ + peer_tracker.init(thd, window_spec->order_list); + clear(); +} + +bool Item_sum_dense_rank::add() +{ + if (peer_tracker.check_if_next_group() || first_add) + { + first_add= false; + dense_rank++; + } + + return false; +} + + +bool Item_sum_rank::add() +{ + row_number++; + if (peer_tracker.check_if_next_group()) + { + /* Row value changed */ + cur_rank= row_number; + } + return false; +} + +bool Item_window_func::check_if_partition_changed() +{ + return partition_tracker.check_if_next_group(); +} + +void Item_window_func::advance_window() +{ + if (check_if_partition_changed()) + { + /* Next partition */ + window_func()->clear(); + } + window_func()->add(); +} + +bool Item_sum_percent_rank::add() +{ + row_number++; + if (peer_tracker.check_if_next_group()) + { + /* Row value changed. */ + cur_rank= row_number; + } + return false; +} + +void Item_sum_percent_rank::setup_window_func(THD *thd, Window_spec *window_spec) +{ + /* TODO: move this into Item_window_func? */ + peer_tracker.init(thd, window_spec->order_list); + clear(); +} + + diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h new file mode 100644 index 00000000000..40f48cc7dc5 --- /dev/null +++ b/sql/item_windowfunc.h @@ -0,0 +1,757 @@ +#ifndef ITEM_WINDOWFUNC_INCLUDED +#define ITEM_WINDOWFUNC_INCLUDED + +#include "my_global.h" +#include "item.h" + +class Window_spec; + + +int test_if_group_changed(List<Cached_item> &list); + +/* A wrapper around test_if_group_changed */ +class Group_bound_tracker +{ + List<Cached_item> group_fields; + /* + During the first check_if_next_group, the list of cached_items is not + initialized. The compare function will return that the items match if + the field's value is the same as the Cached_item's default value (0). + This flag makes sure that we always return true during the first check. + + XXX This is better to be implemented within test_if_group_changed, but + since it is used in other parts of the codebase, we keep it here for now. + */ + bool first_check; +public: + void init(THD *thd, SQL_I_List<ORDER> *list) + { + for (ORDER *curr = list->first; curr; curr=curr->next) + { + Cached_item *tmp= new_Cached_item(thd, curr->item[0], TRUE); + group_fields.push_back(tmp); + } + first_check= true; + } + + void cleanup() + { + group_fields.empty(); + } + + /* + Check if the current row is in a different group than the previous row + this function was called for. + XXX: Side-effect: The new row's group becomes the current row's group. + + Returns true if there is a change between the current_group and the cached + value, or if it is the first check after a call to init. + */ + bool check_if_next_group() + { + if (test_if_group_changed(group_fields) > -1 || first_check) + { + first_check= false; + return true; + } + return false; + } + + /* + Check if the current row is in a different group than the previous row + check_if_next_group was called for. + + Compares the groups without the additional side effect of updating the + current cached values. + */ + int compare_with_cache() + { + List_iterator<Cached_item> li(group_fields); + Cached_item *ptr; + int res; + while ((ptr= li++)) + { + if ((res= ptr->cmp_read_only())) + return res; + } + return 0; + } +}; + +/* + ROW_NUMBER() OVER (...) + + @detail + - This is a Window function (not just an aggregate) + - It can be computed by doing one pass over select output, provided + the output is sorted according to the window definition. +*/ + +class Item_sum_row_number: public Item_sum_int +{ + longlong count; + +public: + void clear() + { + count= 0; + } + bool add() + { + count++; + return false; + } + void update_field() {} + + Item_sum_row_number(THD *thd) + : Item_sum_int(thd), count(0) {} + + enum Sumfunctype sum_func() const + { + return ROW_NUMBER_FUNC; + } + + longlong val_int() + { + return count; + } + const char*func_name() const + { + return "row_number"; + } + +}; + + +/* + RANK() OVER (...) Windowing function + + @detail + - This is a Window function (not just an aggregate) + - It can be computed by doing one pass over select output, provided + the output is sorted according to the window definition. + + The function is defined as: + + "The rank of row R is defined as 1 (one) plus the number of rows that + precede R and are not peers of R" + + "This implies that if two or more rows are not distinct with respect to + the window ordering, then there will be one or more" +*/ + +class Item_sum_rank: public Item_sum_int +{ +protected: + longlong row_number; // just ROW_NUMBER() + longlong cur_rank; // current value + + Group_bound_tracker peer_tracker; +public: + void clear() + { + /* This is called on partition start */ + cur_rank= 1; + row_number= 0; + } + + bool add(); + + longlong val_int() + { + return cur_rank; + } + + void update_field() {} + /* + void reset_field(); + TODO: ^^ what does this do ? It is not called ever? + */ + +public: + Item_sum_rank(THD *thd) + : Item_sum_int(thd) {} + + enum Sumfunctype sum_func () const + { + return RANK_FUNC; + } + + const char*func_name() const + { + return "rank"; + } + + void setup_window_func(THD *thd, Window_spec *window_spec); + void cleanup() + { + peer_tracker.cleanup(); + Item_sum_int::cleanup(); + } +}; + + +/* + DENSE_RANK() OVER (...) Windowing function + + @detail + - This is a Window function (not just an aggregate) + - It can be computed by doing one pass over select output, provided + the output is sorted according to the window definition. + + The function is defined as: + + "If DENSE_RANK is specified, then the rank of row R is defined as the + number of rows preceding and including R that are distinct with respect + to the window ordering" + + "This implies that there are no gaps in the sequential rank numbering of + rows in each window partition." +*/ + + +class Item_sum_dense_rank: public Item_sum_int +{ + longlong dense_rank; + bool first_add; + Group_bound_tracker peer_tracker; + public: + /* + XXX(cvicentiu) This class could potentially be implemented in the rank + class, with a switch for the DENSE case. + */ + void clear() + { + dense_rank= 0; + first_add= true; + } + bool add(); + void update_field() {} + longlong val_int() + { + return dense_rank; + } + + Item_sum_dense_rank(THD *thd) + : Item_sum_int(thd), dense_rank(0), first_add(true) {} + enum Sumfunctype sum_func () const + { + return DENSE_RANK_FUNC; + } + + const char*func_name() const + { + return "dense_rank"; + } + + void setup_window_func(THD *thd, Window_spec *window_spec); + + void cleanup() + { + peer_tracker.cleanup(); + Item_sum_int::cleanup(); + } +}; + +/* + A base window function (aggregate) that also holds a counter for the number + of rows. +*/ +class Item_sum_window_with_row_count : public Item_sum_num +{ + public: + Item_sum_window_with_row_count(THD *thd) : Item_sum_num(thd), + partition_row_count_(0) {} + + Item_sum_window_with_row_count(THD *thd, Item *arg) : + Item_sum_num(thd, arg), partition_row_count_(0) {}; + + void set_row_count(ulonglong count) { partition_row_count_ = count; } + + protected: + longlong get_row_count() { return partition_row_count_; } + private: + ulonglong partition_row_count_; +}; + +/* + @detail + "The relative rank of a row R is defined as (RK-1)/(NR-1), where RK is + defined to be the RANK of R and NR is defined to be the number of rows in + the window partition of R." + + Computation of this function requires two passes: + - First pass to find #rows in the partition + This is held within the row_count context. + - Second pass to compute rank of current row and the value of the function +*/ +class Item_sum_percent_rank: public Item_sum_window_with_row_count +{ + public: + Item_sum_percent_rank(THD *thd) + : Item_sum_window_with_row_count(thd), cur_rank(1) {} + + longlong val_int() + { + /* + Percent rank is a real value so calling the integer value should never + happen. It makes no sense as it gets truncated to either 0 or 1. + */ + DBUG_ASSERT(0); + return 0; + } + + double val_real() + { + /* + We can not get the real value without knowing the number of rows + in the partition. Don't divide by 0. + */ + ulonglong partition_rows = get_row_count(); + null_value= partition_rows > 0 ? false : true; + + return partition_rows > 1 ? + static_cast<double>(cur_rank - 1) / (partition_rows - 1) : 0; + } + + enum Sumfunctype sum_func () const + { + return PERCENT_RANK_FUNC; + } + + const char*func_name() const + { + return "percent_rank"; + } + + void update_field() {} + + void clear() + { + cur_rank= 1; + row_number= 0; + } + bool add(); + enum Item_result result_type () const { return REAL_RESULT; } + enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } + + void fix_length_and_dec() + { + decimals = 10; // TODO-cvicentiu find out how many decimals the standard + // requires. + } + + void setup_window_func(THD *thd, Window_spec *window_spec); + + private: + longlong cur_rank; // Current rank of the current row. + longlong row_number; // Value if this were ROW_NUMBER() function. + + Group_bound_tracker peer_tracker; + + void cleanup() + { + peer_tracker.cleanup(); + Item_sum_num::cleanup(); + } +}; + + + + +/* + @detail + "The relative rank of a row R is defined as NP/NR, where + - NP is defined to be the number of rows preceding or peer with R in the + window ordering of the window partition of R + - NR is defined to be the number of rows in the window partition of R. + + Just like with Item_sum_percent_rank, computation of this function requires + two passes. +*/ + +class Item_sum_cume_dist: public Item_sum_window_with_row_count +{ + public: + Item_sum_cume_dist(THD *thd) : Item_sum_window_with_row_count(thd), + current_row_count_(0) {} + + double val_real() + { + if (get_row_count() == 0) + { + null_value= true; + return 0; + } + ulonglong partition_row_count= get_row_count(); + null_value= false; + return static_cast<double>(current_row_count_) / partition_row_count; + } + + bool add() + { + current_row_count_++; + return false; + } + + enum Sumfunctype sum_func() const + { + return CUME_DIST_FUNC; + } + + void clear() + { + current_row_count_= 0; + set_row_count(0); + } + + const char*func_name() const + { + return "cume_dist"; + } + + void update_field() {} + enum Item_result result_type () const { return REAL_RESULT; } + enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } + + void fix_length_and_dec() + { + decimals = 10; // TODO-cvicentiu find out how many decimals the standard + // requires. + } + + private: + ulonglong current_row_count_; +}; + +class Item_sum_ntile : public Item_sum_window_with_row_count +{ + public: + Item_sum_ntile(THD* thd, Item* num_quantiles_expr) : + Item_sum_window_with_row_count(thd, num_quantiles_expr), + current_row_count_(0) {}; + + double val_real() + { + return val_int(); + } + + longlong val_int() + { + if (get_row_count() == 0) + { + null_value= true; + return 0; + } + + longlong num_quantiles= get_num_quantiles(); + + if (num_quantiles <= 0) { + my_error(ER_INVALID_NTILE_ARGUMENT, MYF(0)); + return true; + } + + null_value= false; + ulonglong quantile_size = get_row_count() / num_quantiles; + ulonglong extra_rows = get_row_count() - quantile_size * num_quantiles; + + if (current_row_count_ <= extra_rows * (quantile_size + 1)) + return (current_row_count_ - 1) / (quantile_size + 1) + 1; + + return (current_row_count_ - 1 - extra_rows) / quantile_size + 1; + } + + bool add() + { + current_row_count_++; + return false; + } + + enum Sumfunctype sum_func() const + { + return NTILE_FUNC; + } + + void clear() + { + current_row_count_= 0; + set_row_count(0); + } + + const char*func_name() const + { + return "ntile"; + } + + void update_field() {} + + enum Item_result result_type () const { return INT_RESULT; } + enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } + + private: + longlong get_num_quantiles() { return args[0]->val_int(); } + ulong current_row_count_; +}; + + +class Item_window_func : public Item_func_or_sum +{ + /* Window function parameters as we've got them from the parser */ +public: + LEX_STRING *window_name; +public: + Window_spec *window_spec; + + /* + This stores the data about the partition we're currently in. + advance_window() uses this to tell when we've left one partition and + entered another + */ + Group_bound_tracker partition_tracker; +public: + Item_window_func(THD *thd, Item_sum *win_func, LEX_STRING *win_name) + : Item_func_or_sum(thd, (Item *) win_func), + window_name(win_name), window_spec(NULL), + force_return_blank(true), + read_value_from_result_field(false) {} + + Item_window_func(THD *thd, Item_sum *win_func, Window_spec *win_spec) + : Item_func_or_sum(thd, (Item *) win_func), + window_name(NULL), window_spec(win_spec), + force_return_blank(true), + read_value_from_result_field(false) {} + + Item_sum *window_func() const { return (Item_sum *) args[0]; } + + void update_used_tables(); + + /* + This is used by filesort to mark the columns it needs to read (because they + participate in the sort criteria and/or row retrieval. Window functions can + only be used in sort criteria). + + Sorting by window function value is only done after the window functions + have been computed. In that case, window function will need to read its + temp.table field. In order to allow that, mark that field in the read_set. + */ + bool register_field_in_read_map(uchar *arg) + { + TABLE *table= (TABLE*) arg; + if (result_field && (result_field->table == table || !table)) + { + bitmap_set_bit(result_field->table->read_set, result_field->field_index); + } + return 0; + } + + bool is_frame_prohibited() const + { + switch (window_func()->sum_func()) { + case Item_sum::ROW_NUMBER_FUNC: + case Item_sum::RANK_FUNC: + case Item_sum::DENSE_RANK_FUNC: + case Item_sum::PERCENT_RANK_FUNC: + case Item_sum::CUME_DIST_FUNC: + case Item_sum::NTILE_FUNC: + return true; + default: + return false; + } + } + + bool requires_partition_size() const + { + switch (window_func()->sum_func()) { + case Item_sum::PERCENT_RANK_FUNC: + case Item_sum::CUME_DIST_FUNC: + case Item_sum::NTILE_FUNC: + return true; + default: + return false; + } + } + + bool requires_peer_size() const + { + switch (window_func()->sum_func()) { + case Item_sum::CUME_DIST_FUNC: + return true; + default: + return false; + } + } + + bool is_order_list_mandatory() const + { + switch (window_func()->sum_func()) { + case Item_sum::RANK_FUNC: + case Item_sum::DENSE_RANK_FUNC: + case Item_sum::PERCENT_RANK_FUNC: + case Item_sum::CUME_DIST_FUNC: + return true; + default: + return false; + } + } + + /* + Computation functions. + TODO: consoder merging these with class Group_bound_tracker. + */ + void setup_partition_border_check(THD *thd); + + void advance_window(); + bool check_if_partition_changed(); + + enum_field_types field_type() const + { + return ((Item_sum *) args[0])->field_type(); + } + enum Item::Type type() const { return Item::WINDOW_FUNC_ITEM; } + +private: + /* + Window functions are very special functions, so val_() methods have + special meaning for them: + + - Phase#1, "Initial" we run the join and put its result into temporary + table. For window functions, we write the default value (NULL?) as + a placeholder. + + - Phase#2: "Computation": executor does the scan in {PARTITION, ORDER BY} + order of this window function. It calls appropriate methods to inform + the window function about rows entering/leaving the window. + It calls window_func()->val_int() so that current window function value + can be saved and stored in the temp.table. + + - Phase#3: "Retrieval" the temporary table is read and passed to query + output. However, Item_window_func still remains in the select list, + so item_windowfunc->val_int() will be called. + During Phase#3, read_value_from_result_field= true. + */ + bool force_return_blank; + bool read_value_from_result_field; + +public: + void set_phase_to_initial() + { + force_return_blank= true; + read_value_from_result_field= false; + } + void set_phase_to_computation() + { + force_return_blank= false; + read_value_from_result_field= false; + } + void set_phase_to_retrieval() + { + force_return_blank= false; + read_value_from_result_field= true; + } + + double val_real() + { + double res; + if (force_return_blank) + { + res= 0.0; + null_value= false; + } + else if (read_value_from_result_field) + { + res= result_field->val_real(); + null_value= result_field->is_null(); + } + else + { + res= window_func()->val_real(); + null_value= window_func()->null_value; + } + return res; + } + + longlong val_int() + { + longlong res; + if (force_return_blank) + { + res= 0; + null_value= false; + } + else if (read_value_from_result_field) + { + res= result_field->val_int(); + null_value= result_field->is_null(); + } + else + { + res= window_func()->val_int(); + null_value= window_func()->null_value; + } + return res; + } + + String* val_str(String* str) + { + String *res; + if (force_return_blank) + { + null_value= false; + str->length(0); + res= str; + } + else if (read_value_from_result_field) + { + if ((null_value= result_field->is_null())) + res= NULL; + else + res= result_field->val_str(str); + } + else + { + res= window_func()->val_str(str); + null_value= window_func()->null_value; + } + return res; + } + + my_decimal* val_decimal(my_decimal* dec) + { + my_decimal *res; + if (force_return_blank) + { + my_decimal_set_zero(dec); + null_value= false; + res= dec; + } + else if (read_value_from_result_field) + { + if ((null_value= result_field->is_null())) + res= NULL; + else + res= result_field->val_decimal(dec); + } + else + { + res= window_func()->val_decimal(dec); + null_value= window_func()->null_value; + } + return res; + } + + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags); + void fix_length_and_dec() + { + decimals = window_func()->decimals; + } + + const char* func_name() const { return "WF"; } + + bool fix_fields(THD *thd, Item **ref); + + bool resolve_window_name(THD *thd); + +}; + +#endif /* ITEM_WINDOWFUNC_INCLUDED */ diff --git a/sql/lex.h b/sql/lex.h index da5fa2de137..f7a183e1862 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -221,6 +221,7 @@ static SYMBOL symbols[] = { { "EVERY", SYM(EVERY_SYM)}, { "EXAMINED", SYM(EXAMINED_SYM)}, { "EXCHANGE", SYM(EXCHANGE_SYM)}, + { "EXCLUDE", SYM(EXCLUDE_SYM)}, { "EXECUTE", SYM(EXECUTE_SYM)}, { "EXISTS", SYM(EXISTS)}, { "EXIT", SYM(EXIT_SYM)}, @@ -241,6 +242,7 @@ static SYMBOL symbols[] = { { "FLOAT4", SYM(FLOAT_SYM)}, { "FLOAT8", SYM(DOUBLE_SYM)}, { "FLUSH", SYM(FLUSH_SYM)}, + { "FOLLOWING", SYM(FOLLOWING_SYM)}, { "FOR", SYM(FOR_SYM)}, { "FORCE", SYM(FORCE_SYM)}, { "FOREIGN", SYM(FOREIGN)}, @@ -425,9 +427,11 @@ static SYMBOL symbols[] = { { "OPTIONALLY", SYM(OPTIONALLY)}, { "OR", SYM(OR_SYM)}, { "ORDER", SYM(ORDER_SYM)}, + { "OTHERS", SYM(OTHERS_SYM)}, { "OUT", SYM(OUT_SYM)}, { "OUTER", SYM(OUTER)}, { "OUTFILE", SYM(OUTFILE)}, + { "OVER", SYM(OVER_SYM)}, { "OWNER", SYM(OWNER_SYM)}, { "PACK_KEYS", SYM(PACK_KEYS_SYM)}, { "PAGE", SYM(PAGE_SYM)}, @@ -446,6 +450,7 @@ static SYMBOL symbols[] = { { "POINT", SYM(POINT_SYM)}, { "POLYGON", SYM(POLYGON)}, { "PORT", SYM(PORT_SYM)}, + { "PRECEDING", SYM(PRECEDING_SYM)}, { "PRECISION", SYM(PRECISION)}, { "PREPARE", SYM(PREPARE_SYM)}, { "PRESERVE", SYM(PRESERVE_SYM)}, @@ -602,6 +607,7 @@ static SYMBOL symbols[] = { { "TEXT", SYM(TEXT_SYM)}, { "THAN", SYM(THAN_SYM)}, { "THEN", SYM(THEN_SYM)}, + { "TIES", SYM(TIES_SYM)}, { "TIME", SYM(TIME_SYM)}, { "TIMESTAMP", SYM(TIMESTAMP)}, { "TIMESTAMPADD", SYM(TIMESTAMP_ADD)}, @@ -619,6 +625,7 @@ static SYMBOL symbols[] = { { "TRUNCATE", SYM(TRUNCATE_SYM)}, { "TYPE", SYM(TYPE_SYM)}, { "TYPES", SYM(TYPES_SYM)}, + { "UNBOUNDED", SYM(UNBOUNDED_SYM)}, { "UNCOMMITTED", SYM(UNCOMMITTED_SYM)}, { "UNDEFINED", SYM(UNDEFINED_SYM)}, { "UNDO_BUFFER_SIZE", SYM(UNDO_BUFFER_SIZE_SYM)}, @@ -660,6 +667,7 @@ static SYMBOL symbols[] = { { "WHEN", SYM(WHEN_SYM)}, { "WHERE", SYM(WHERE)}, { "WHILE", SYM(WHILE_SYM)}, + { "WINDOW", SYM(WINDOW_SYM)}, { "WITH", SYM(WITH)}, { "WORK", SYM(WORK_SYM)}, { "WRAPPER", SYM(WRAPPER_SYM)}, @@ -682,17 +690,23 @@ static SYMBOL sql_functions[] = { { "BIT_XOR", SYM(BIT_XOR)}, { "CAST", SYM(CAST_SYM)}, { "COUNT", SYM(COUNT_SYM)}, + { "CUME_DIST", SYM(CUME_DIST_SYM)}, { "CURDATE", SYM(CURDATE)}, { "CURTIME", SYM(CURTIME)}, { "DATE_ADD", SYM(DATE_ADD_INTERVAL)}, { "DATE_SUB", SYM(DATE_SUB_INTERVAL)}, + { "DENSE_RANK", SYM(DENSE_RANK_SYM)}, { "EXTRACT", SYM(EXTRACT_SYM)}, { "GROUP_CONCAT", SYM(GROUP_CONCAT_SYM)}, { "MAX", SYM(MAX_SYM)}, { "MID", SYM(SUBSTRING)}, /* unireg function */ { "MIN", SYM(MIN_SYM)}, { "NOW", SYM(NOW_SYM)}, + { "NTILE", SYM(NTILE_SYM)}, { "POSITION", SYM(POSITION_SYM)}, + { "PERCENT_RANK", SYM(PERCENT_RANK_SYM)}, + { "RANK", SYM(RANK_SYM)}, + { "ROW_NUMBER", SYM(ROW_NUMBER_SYM)}, { "SESSION_USER", SYM(USER)}, { "STD", SYM(STD_SYM)}, { "STDDEV", SYM(STD_SYM)}, diff --git a/sql/log.cc b/sql/log.cc index dc8c08bfd36..f04b1432229 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -139,6 +139,12 @@ static bool start_binlog_background_thread(); static rpl_binlog_state rpl_global_gtid_binlog_state; +void setup_log_handling() +{ + rpl_global_gtid_binlog_state.init(); +} + + /** purge logs, master and slave sides both, related error code convertor. diff --git a/sql/log.h b/sql/log.h index 9bf80d6e603..e556ef91399 100644 --- a/sql/log.h +++ b/sql/log.h @@ -26,6 +26,7 @@ class Relay_log_info; class Format_description_log_event; +void setup_log_handling(); bool trans_has_updated_trans_table(const THD* thd); bool stmt_has_updated_trans_table(const THD *thd); bool use_trans_cache(const THD* thd, bool is_transactional); diff --git a/sql/log_event.cc b/sql/log_event.cc index b56a9e2aee3..3715f0cc4d4 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -4523,7 +4523,7 @@ compare_errors: "Error on master: message (format)='%s' error code=%d ; " "Error on slave: actual message='%s', error code=%d. " "Default database: '%s'. Query: '%s'", - ER_SAFE_THD(thd, expected_error), + ER_THD(thd, expected_error), expected_error, actual_error ? thd->get_stmt_da()->message() : "no error", actual_error, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e7d7f90d44e..845d114bc7a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -367,7 +367,7 @@ static my_bool opt_short_log_format= 0, opt_silent_startup= 0; uint kill_cached_threads; static uint wake_thread; ulong max_used_connections; -static volatile ulong cached_thread_count= 0; +volatile ulong cached_thread_count= 0; static char *mysqld_user, *mysqld_chroot; static char *default_character_set_name; static char *character_set_filesystem_name; @@ -1987,8 +1987,6 @@ static void __cdecl kill_server(int sig_ptr) if (wsrep_inited == 1) wsrep_deinit(true); - wsrep_thr_deinit(); - if (sig != MYSQL_KILL_SIGNAL && sig != 0) unireg_abort(1); /* purecov: inspected */ @@ -2144,6 +2142,9 @@ static void mysqld_exit(int exit_code) set_malloc_size_cb(NULL); cleanup_tls(); DBUG_LEAVE; + if (opt_endinfo && global_status_var.global_memory_used) + fprintf(stderr, "Warning: Memory not freed: %ld\n", + (long) global_status_var.global_memory_used); sd_notify(0, "STATUS=MariaDB server is down"); exit(exit_code); /* purecov: inspected */ } @@ -2213,11 +2214,12 @@ void clean_up(bool print_message) free_global_client_stats(); free_global_table_stats(); free_global_index_stats(); - delete_dynamic(&all_options); + delete_dynamic(&all_options); // This should be empty free_all_rpl_filters(); #ifdef HAVE_REPLICATION end_slave_list(); #endif + wsrep_thr_deinit(); my_uuid_end(); delete binlog_filter; delete global_rpl_filter; @@ -2234,13 +2236,12 @@ void clean_up(bool print_message) if (print_message && my_default_lc_messages && server_start_time) sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname); - cleanup_errmsgs(); MYSQL_CALLBACK(thread_scheduler, end, ()); thread_scheduler= 0; mysql_library_end(); finish_client_errs(); - (void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs - DBUG_PRINT("quit", ("Error messages freed")); + cleanup_errmsgs(); + free_error_messages(); /* Tell main we are ready */ logger.cleanup_end(); sys_var_end(); @@ -4088,40 +4089,45 @@ extern "C" { static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) { THD *thd= current_thd; - /* If thread specific memory */ - if (likely(is_thread_specific)) + + if (likely(is_thread_specific)) /* If thread specific memory */ { - if (mysqld_server_initialized || thd) - { - /* - THD may not be set if we are called from my_net_init() before THD - thread has started. - However, this should never happen, so better to assert and - fix this. - */ - DBUG_ASSERT(thd); - if (thd) - { - DBUG_PRINT("info", ("memory_used: %lld size: %lld", - (longlong) thd->status_var.local_memory_used, - size)); - thd->status_var.local_memory_used+= size; - DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 || - !debug_assert_on_not_freed_memory); - } - } + /* + When thread specfic is set, both mysqld_server_initialized and thd + must be set + */ + DBUG_ASSERT(mysqld_server_initialized && thd); + + DBUG_PRINT("info", ("thd memory_used: %lld size: %lld", + (longlong) thd->status_var.local_memory_used, + size)); + thd->status_var.local_memory_used+= size; + DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 || + !debug_assert_on_not_freed_memory); } else if (likely(thd)) + { + DBUG_PRINT("info", ("global thd memory_used: %lld size: %lld", + (longlong) thd->status_var.global_memory_used, + size)); thd->status_var.global_memory_used+= size; + } else { - // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1) - int64 volatile * volatile ptr=&global_status_var.global_memory_used; - my_atomic_add64_explicit(ptr, size, MY_MEMORY_ORDER_RELAXED); + update_global_memory_status(size); +#ifndef EMBEDDED_LIBRARY + /* + Check if we have missed some mallocs. THis can't be done for embedded + server as the main code may have done calls to malloc before starting + the embedded library. + */ + DBUG_ASSERT(global_status_var.global_memory_used >= 0); +#endif } } } + /** Create a replication file name or base for file names. @@ -4158,6 +4164,22 @@ rpl_make_log_name(const char *opt, DBUG_RETURN(NULL); } +/* We have to setup my_malloc_size_cb_func early to catch all mallocs */ + +static int init_early_variables() +{ + if (pthread_key_create(&THR_THD, NULL)) + { + fprintf(stderr, "Fatal error: Can't create thread-keys\n"); + return 1; + } + set_current_thd(0); + set_malloc_size_cb(my_malloc_size_cb_func); + global_status_var.global_memory_used= 0; + return 0; +} + + static int init_common_variables() { umask(((~my_umask) & 0666)); @@ -4169,15 +4191,6 @@ static int init_common_variables() connection_errors_peer_addr= 0; my_decimal_set_zero(&decimal_zero); // set decimal_zero constant; - if (pthread_key_create(&THR_THD, NULL)) - { - sql_print_error("Can't create thread-keys"); - return 1; - } - - set_current_thd(0); - set_malloc_size_cb(my_malloc_size_cb_func); - init_libstrings(); tzset(); // Set tzname @@ -4714,6 +4727,7 @@ static int init_thread_environment() mysql_mutex_init(key_LOCK_global_system_variables, &LOCK_global_system_variables, MY_MUTEX_INIT_FAST); mysql_mutex_record_order(&LOCK_active_mi, &LOCK_global_system_variables); + mysql_mutex_record_order(&LOCK_status, &LOCK_thread_count); mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash, &LOCK_system_variables_hash); mysql_mutex_init(key_LOCK_prepared_stmt_count, @@ -5020,6 +5034,8 @@ static int init_server_components() /* Setup logs */ + setup_log_handling(); + /* Enable old-fashioned error log, except when the user has requested help information. Since the implementation of plugin server @@ -5187,7 +5203,12 @@ static int init_server_components() variables even when a wsrep provider is not loaded. */ + /* It's now safe to use thread specific memory */ + mysqld_server_initialized= 1; + +#ifndef EMBEDDED_LIBRARY wsrep_thr_init(); +#endif if (WSREP_ON && !wsrep_recovery && !opt_abort) /* WSREP BEFORE SE */ { @@ -5637,6 +5658,9 @@ int mysqld_main(int argc, char **argv) sf_leaking_memory= 1; // no safemalloc memory leak reports if we exit early mysqld_server_started= mysqld_server_initialized= 0; + if (init_early_variables()) + exit(1); + #ifdef HAVE_NPTL ld_assume_kernel_is_set= (getenv("LD_ASSUME_KERNEL") != 0); #endif @@ -5939,9 +5963,6 @@ int mysqld_main(int argc, char **argv) if (Events::init((THD*) 0, opt_noacl || opt_bootstrap)) unireg_abort(1); - /* It's now safe to use thread specific memory */ - mysqld_server_initialized= 1; - if (WSREP_ON) { if (opt_bootstrap) @@ -8310,15 +8331,16 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff, static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff, + struct system_status_var *status_var, enum enum_var_type scope) { var->type= SHOW_LONGLONG; var->value= buff; if (scope == OPT_GLOBAL) - *(longlong*) buff= (global_status_var.local_memory_used + - global_status_var.global_memory_used); + *(longlong*) buff= (status_var->global_memory_used + + status_var->local_memory_used); else - *(longlong*) buff= thd->status_var.local_memory_used; + *(longlong*) buff= status_var->local_memory_used; return 0; } @@ -8747,7 +8769,9 @@ static int mysql_init_variables(void) prepared_stmt_count= 0; mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS; bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); - bzero((char *) &global_status_var, sizeof(global_status_var)); + /* Clear all except global_memory_used */ + bzero((char*) &global_status_var, offsetof(STATUS_VAR, + last_cleared_system_status_var)); opt_large_pages= 0; opt_super_large_pages= 0; #if defined(ENABLED_DEBUG_SYNC) @@ -9428,7 +9452,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr) /* prepare all_options array */ my_init_dynamic_array(&all_options, sizeof(my_option), - array_elements(my_long_options), + array_elements(my_long_options) + + sys_var_elements(), array_elements(my_long_options)/4, MYF(0)); add_many_options(&all_options, my_long_options, array_elements(my_long_options)); sys_var_add_options(&all_options, 0); @@ -9992,6 +10017,7 @@ void refresh_status(THD *thd) /* Reset thread's status variables */ thd->set_status_var_init(); + thd->status_var.global_memory_used= 0; bzero((uchar*) &thd->org_status_var, sizeof(thd->org_status_var)); thd->start_bytes_received= 0; diff --git a/sql/mysqld.h b/sql/mysqld.h index ef4a0d6a47a..e538cbd724e 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -203,6 +203,7 @@ extern LEX_CSTRING reason_slave_blocked; extern ulong slave_trans_retries; extern uint slave_net_timeout; extern int max_user_connections; +extern volatile ulong cached_thread_count; extern ulong what_to_log,flush_time; extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong open_files_limit; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 7169a3eda81..a69709bbf03 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1533,7 +1533,7 @@ end: if (!head->no_keyread) { doing_key_read= 1; - head->enable_keyread(); + head->set_keyread(true); } head->prepare_for_position(); @@ -10643,7 +10643,7 @@ int read_keys_and_merge_scans(THD *thd, if (!head->key_read) { enabled_keyread= 1; - head->enable_keyread(); + head->set_keyread(true); } head->prepare_for_position(); @@ -10736,7 +10736,7 @@ int read_keys_and_merge_scans(THD *thd, index merge currently doesn't support "using index" at all */ if (enabled_keyread) - head->disable_keyread(); + head->set_keyread(false); if (init_read_record(read_record, thd, head, (SQL_SELECT*) 0, &unique->sort, 1 , 1, TRUE)) result= 1; @@ -10744,7 +10744,7 @@ int read_keys_and_merge_scans(THD *thd, err: if (enabled_keyread) - head->disable_keyread(); + head->set_keyread(false); DBUG_RETURN(1); } @@ -12071,9 +12071,6 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) DBUG_RETURN(NULL); /* Cannot execute with correlated conditions. */ /* Check (SA1,SA4) and store the only MIN/MAX argument - the C attribute.*/ - if (join->make_sum_func_list(join->all_fields, join->fields_list, 1)) - DBUG_RETURN(NULL); - List_iterator<Item> select_items_it(join->fields_list); is_agg_distinct = is_indexed_agg_distinct(join, &agg_distinct_flds); @@ -13108,7 +13105,17 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, num_blocks= (ha_rows)(table_records / keys_per_block) + 1; /* Compute the number of keys in a group. */ - keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - 1); + if (!group_key_parts) + { + /* Summary over the whole table */ + keys_per_group= table_records; + } + else + { + keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - + 1); + } + if (keys_per_group == 0) /* If there is no statistics try to guess */ /* each group contains 10% of all records */ keys_per_group= (table_records / 10) + 1; @@ -13456,7 +13463,7 @@ QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT() { DBUG_ASSERT(file == head->file); if (doing_key_read) - head->disable_keyread(); + head->set_keyread(false); /* There may be a code path when the same table was first accessed by index, then the index is closed, and the table is scanned (order by + loose scan). @@ -13649,7 +13656,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) if (!head->key_read) { doing_key_read= 1; - head->enable_keyread(); /* We need only the key attributes */ + head->set_keyread(true); /* We need only the key attributes */ } if ((result= file->ha_index_init(index,1))) { diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 79b28a5994e..55c6c075f48 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -445,7 +445,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred); static bool convert_subq_to_jtbm(JOIN *parent_join, Item_in_subselect *subq_pred, bool *remove); static TABLE_LIST *alloc_join_nest(THD *thd); -static uint get_tmp_table_rec_length(Item **p_list, uint elements); +static uint get_tmp_table_rec_length(Ref_ptr_array p_list, uint elements); static double get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size); static double get_tmp_table_write_cost(THD *thd, double row_count, @@ -1342,8 +1342,8 @@ static bool replace_where_subcondition(JOIN *join, Item **expr, static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2, void *arg) { - return (el1->sj_convert_priority > el2->sj_convert_priority) ? 1 : - ( (el1->sj_convert_priority == el2->sj_convert_priority)? 0 : -1); + return (el1->sj_convert_priority > el2->sj_convert_priority) ? -1 : + ( (el1->sj_convert_priority == el2->sj_convert_priority)? 0 : 1); } @@ -2236,13 +2236,9 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map) JOIN_TAB *tab= join->best_positions[i].table; join->map2table[tab->table->tablenr]= tab; } - //List_iterator<Item> it(right_expr_list); - Item **ref_array= subq_select->ref_pointer_array; - Item **ref_array_end= ref_array + subq_select->item_list.elements; table_map map= 0; - //while ((item= it++)) - for (;ref_array < ref_array_end; ref_array++) - map |= (*ref_array)->used_tables(); + for (uint i=0; i < subq_select->item_list.elements; i++) + map|= subq_select->ref_pointer_array[i]->used_tables(); map= map & ~PSEUDO_TABLE_BITS; Table_map_iterator tm_it(map); int tableno; @@ -2305,15 +2301,14 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map) Length of the temptable record, in bytes */ -static uint get_tmp_table_rec_length(Item **p_items, uint elements) +static uint get_tmp_table_rec_length(Ref_ptr_array p_items, uint elements) { uint len= 0; Item *item; //List_iterator<Item> it(items); - Item **p_item; - for (p_item= p_items; p_item < p_items + elements ; p_item++) + for (uint i= 0; i < elements ; i++) { - item = *p_item; + item = p_items[i]; switch (item->result_type()) { case REAL_RESULT: len += sizeof(double); @@ -3562,13 +3557,10 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) */ sjm->sjm_table_param.init(); sjm->sjm_table_param.bit_fields_as_long= TRUE; - //List_iterator<Item> it(item_list); SELECT_LEX *subq_select= emb_sj_nest->sj_subq_pred->unit->first_select(); - Item **p_item= subq_select->ref_pointer_array; - Item **p_end= p_item + subq_select->item_list.elements; - //while((right_expr= it++)) - for(;p_item != p_end; p_item++) - sjm->sjm_table_cols.push_back(*p_item, thd->mem_root); + Ref_ptr_array p_items= subq_select->ref_pointer_array; + for (uint i= 0; i < subq_select->item_list.elements; i++) + sjm->sjm_table_cols.push_back(p_items[i], thd->mem_root); sjm->sjm_table_param.field_count= subq_select->item_list.elements; sjm->sjm_table_param.force_not_null_cols= TRUE; @@ -3724,13 +3716,13 @@ bool setup_sj_materialization_part2(JOIN_TAB *sjm_tab) */ sjm->copy_field= new Copy_field[sjm->sjm_table_cols.elements]; //it.rewind(); - Item **p_item= emb_sj_nest->sj_subq_pred->unit->first_select()->ref_pointer_array; + Ref_ptr_array p_items= emb_sj_nest->sj_subq_pred->unit->first_select()->ref_pointer_array; for (uint i=0; i < sjm->sjm_table_cols.elements; i++) { bool dummy; Item_equal *item_eq; //Item *item= (it++)->real_item(); - Item *item= (*(p_item++))->real_item(); + Item *item= p_items[i]->real_item(); DBUG_ASSERT(item->type() == Item::FIELD_ITEM); Field *copy_to= ((Item_field*)item)->field; /* @@ -5602,7 +5594,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables) */ /* C.1 Compute the cost of the materialization strategy. */ //uint rowlen= get_tmp_table_rec_length(unit->first_select()->item_list); - uint rowlen= get_tmp_table_rec_length(ref_pointer_array, + uint rowlen= get_tmp_table_rec_length(ref_ptrs, select_lex->item_list.elements); /* The cost of writing one row into the temporary table. */ double write_cost= get_tmp_table_write_cost(thd, inner_record_count_1, diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index f36887eb137..ad3f5aed112 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -406,7 +406,7 @@ int opt_sum_query(THD *thd, if (!error && reckey_in_range(is_max, &ref, item_field->field, conds, range_fl, prefix_len)) error= HA_ERR_KEY_NOT_FOUND; - table->disable_keyread(); + table->set_keyread(false); table->file->ha_index_end(); if (error) { @@ -968,7 +968,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, converted (for example to upper case) */ if (field->part_of_key.is_set(idx)) - table->enable_keyread(); + table->set_keyread(true); DBUG_RETURN(TRUE); } } diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index 912ef4a7df7..6835594ca07 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -1105,7 +1105,7 @@ int compare_field_values(Dep_value_field *a, Dep_value_field *b, void *unused) uint b_ratio= b->field->table->tablenr*MAX_FIELDS + b->field->field_index; - return (a_ratio < b_ratio)? -1 : ((a_ratio == b_ratio)? 0 : 1); + return (a_ratio < b_ratio)? 1 : ((a_ratio == b_ratio)? 0 : -1); } diff --git a/sql/records.cc b/sql/records.cc index 3995bea6569..e7a4ab836c0 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -39,7 +39,7 @@ int rr_sequential(READ_RECORD *info); static int rr_from_tempfile(READ_RECORD *info); static int rr_unpack_from_tempfile(READ_RECORD *info); static int rr_unpack_from_buffer(READ_RECORD *info); -static int rr_from_pointers(READ_RECORD *info); +int rr_from_pointers(READ_RECORD *info); static int rr_from_cache(READ_RECORD *info); static int init_rr_cache(THD *thd, READ_RECORD *info); static int rr_cmp(uchar *a,uchar *b); @@ -316,7 +316,7 @@ void end_read_record(READ_RECORD *info) } if (info->table) { - if (info->table->created) + if (info->table->is_created()) (void) info->table->file->extra(HA_EXTRA_NO_CACHE); if (info->read_record != rr_quick) // otherwise quick_range does it (void) info->table->file->ha_index_or_rnd_end(); @@ -535,7 +535,7 @@ static int rr_unpack_from_tempfile(READ_RECORD *info) return 0; } -static int rr_from_pointers(READ_RECORD *info) +int rr_from_pointers(READ_RECORD *info) { int tmp; uchar *cache_pos; diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index f54ef2b0081..5a94e1c5b54 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -1127,7 +1127,7 @@ rpl_slave_state::is_empty() } -rpl_binlog_state::rpl_binlog_state() +void rpl_binlog_state::init() { my_hash_init(&hash, &my_charset_bin, 32, offsetof(element, domain_id), sizeof(uint32), NULL, my_free, HASH_UNIQUE); @@ -1137,7 +1137,6 @@ rpl_binlog_state::rpl_binlog_state() initialized= 1; } - void rpl_binlog_state::reset_nolock() { diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index ece6effbef6..f638a084e38 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -231,9 +231,10 @@ struct rpl_binlog_state /* Auxiliary buffer to sort gtid list. */ DYNAMIC_ARRAY gtid_sort_array; - rpl_binlog_state(); + rpl_binlog_state() :initialized(0) {} ~rpl_binlog_state(); + void init(); void reset_nolock(); void reset(); void free(); diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index df721342d1d..02dbac46eb5 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -205,43 +205,56 @@ void init_master_log_pos(Master_info* mi) /** Parses the IO_CACHE for "key=" and returns the "key". + If no '=' found, returns the whole line (for END_MARKER). @param key [OUT] Key buffer @param max_size [IN] Maximum buffer size @param f [IN] IO_CACHE file + @param found_equal [OUT] Set true if a '=' was found. @retval 0 Either "key=" or '\n' found @retval 1 EOF */ -static int read_mi_key_from_file(char *key, int max_size, IO_CACHE *f) +static int +read_mi_key_from_file(char *key, int max_size, IO_CACHE *f, bool *found_equal) { int i= 0, c; - char *last_p; DBUG_ENTER("read_key_from_file"); - while (((c= my_b_get(f)) != '\n') && (c != my_b_EOF)) + *found_equal= false; + if (max_size <= 0) + DBUG_RETURN(1); + for (;;) { - last_p= key + i; - - if (i < max_size) + if (i >= max_size-1) { - if (c == '=') - { - /* We found '=', replace it by 0 and return. */ - *last_p= 0; - DBUG_RETURN(0); - } - else - *last_p= c; + key[i] = '\0'; + DBUG_RETURN(0); + } + c= my_b_get(f); + if (c == my_b_EOF) + { + DBUG_RETURN(1); + } + else if (c == '\n') + { + key[i]= '\0'; + DBUG_RETURN(0); + } + else if (c == '=') + { + key[i]= '\0'; + *found_equal= true; + DBUG_RETURN(0); + } + else + { + key[i]= c; + ++i; } - ++i; } - - if (c == my_b_EOF) - DBUG_RETURN(1); - - DBUG_RETURN(0); + /* NotReached */ } enum { @@ -539,6 +552,10 @@ file '%s')", fname); if (lines >= LINE_FOR_LAST_MYSQL_FUTURE) { uint i; + bool got_eq; + bool seen_using_gtid= false; + bool seen_do_domain_ids=false, seen_ignore_domain_ids=false; + /* Skip lines used by / reserved for MySQL >= 5.6. */ for (i= LINE_FOR_FIRST_MYSQL_5_6; i <= LINE_FOR_LAST_MYSQL_FUTURE; ++i) { @@ -551,11 +568,12 @@ file '%s')", fname); for "key=" and returns the "key" if found. The "value" can then the parsed on case by case basis. The "unknown" lines would be ignored to facilitate downgrades. + 10.0 does not have the END_MARKER before any left-overs at the end + of the file. So ignore any but the first occurrence of a key. */ - while (!read_mi_key_from_file(buf, sizeof(buf), &mi->file)) + while (!read_mi_key_from_file(buf, sizeof(buf), &mi->file, &got_eq)) { - /* using_gtid */ - if (!strncmp(buf, STRING_WITH_LEN("using_gtid"))) + if (got_eq && !seen_using_gtid && !strcmp(buf, "using_gtid")) { int val; if (!init_intvar_from_file(&val, &mi->file, 0)) @@ -566,15 +584,13 @@ file '%s')", fname); mi->using_gtid= Master_info::USE_GTID_SLAVE_POS; else mi->using_gtid= Master_info::USE_GTID_NO; - continue; + seen_using_gtid= true; } else { sql_print_error("Failed to initialize master info using_gtid"); goto errwithmsg; } } - - /* DO_DOMAIN_IDS */ - if (!strncmp(buf, STRING_WITH_LEN("do_domain_ids"))) + else if (got_eq && !seen_do_domain_ids && !strcmp(buf, "do_domain_ids")) { if (mi->domain_id_filter.init_ids(&mi->file, Domain_id_filter::DO_DOMAIN_IDS)) @@ -582,11 +598,10 @@ file '%s')", fname); sql_print_error("Failed to initialize master info do_domain_ids"); goto errwithmsg; } - continue; + seen_do_domain_ids= true; } - - /* IGNORE_DOMAIN_IDS */ - if (!strncmp(buf, STRING_WITH_LEN("ignore_domain_ids"))) + else if (got_eq && !seen_ignore_domain_ids && + !strcmp(buf, "ignore_domain_ids")) { if (mi->domain_id_filter.init_ids(&mi->file, Domain_id_filter::IGNORE_DOMAIN_IDS)) @@ -595,9 +610,9 @@ file '%s')", fname); "ignore_domain_ids"); goto errwithmsg; } - continue; + seen_ignore_domain_ids= true; } - else if (!strncmp(buf, STRING_WITH_LEN("END_MARKER"))) + else if (!got_eq && !strcmp(buf, "END_MARKER")) { /* Guard agaist extra left-overs at the end of file, in case a later diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index acdedd6e0a0..df036d0e23f 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -987,7 +987,6 @@ handle_rpl_parallel_thread(void *arg) thd->client_capabilities = CLIENT_LOCAL_FILES; thd->net.reading_or_writing= 0; thd_proc_info(thd, "Waiting for work from main SQL threads"); - thd->set_time(); thd->variables.lock_wait_timeout= LONG_TIMEOUT; thd->system_thread_info.rpl_sql_info= &sql_info; /* diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 2dd6f7d7afc..f9d0910a2a7 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -70,6 +70,7 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery) DBUG_ENTER("Relay_log_info::Relay_log_info"); relay_log.is_relay_log= TRUE; + relay_log_state.init(); #ifdef HAVE_PSI_INTERFACE relay_log.set_psi_keys(key_RELAYLOG_LOCK_index, key_RELAYLOG_update_cond, diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index e896c189a8e..3eaee90d0f6 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -347,10 +347,11 @@ public: rpl_parallel parallel; /* - The relay_log_state keeps track of the current binlog state of the execution - of the relay log. This is used to know where to resume current GTID position - if the slave thread is stopped and restarted. - It is only accessed from the SQL thread, so it does not need any locking. + The relay_log_state keeps track of the current binlog state of the + execution of the relay log. This is used to know where to resume + current GTID position if the slave thread is stopped and + restarted. It is only accessed from the SQL thread, so it does + not need any locking. */ rpl_binlog_state relay_log_state; /* diff --git a/sql/set_var.cc b/sql/set_var.cc index b5430c56865..5392a0065ac 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -64,7 +64,7 @@ int sys_var_init() /* Must be already initialized. */ DBUG_ASSERT(system_charset_info != NULL); - if (my_hash_init(&system_variable_hash, system_charset_info, 100, 0, + if (my_hash_init(&system_variable_hash, system_charset_info, 700, 0, 0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE)) goto error; @@ -78,6 +78,11 @@ error: DBUG_RETURN(1); } +uint sys_var_elements() +{ + return system_variable_hash.records; +} + int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags) { uint saved_elements= long_options->elements; diff --git a/sql/set_var.h b/sql/set_var.h index cf86ecf18fa..060a4e1a57c 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -414,6 +414,7 @@ extern sys_var *Sys_autocommit_ptr; CHARSET_INFO *get_old_charset_by_name(const char *old_name); int sys_var_init(); +uint sys_var_elements(); int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags); void sys_var_end(void); diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 0d168e937a9..376c1eb9d0d 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7154,3 +7154,50 @@ ER_WRONG_ORDER_IN_WITH_CLAUSE eng "The definition of the table '%s' refers to the table '%s' defined later in a non-recursive WITH clause" ER_RECURSIVE_QUERY_IN_WITH_CLAUSE eng "Recursive queries in WITH clause are not supported yet" + +# +# Internal errors, not used +# +skip-to-error-number 2000 + +# MySQL 5.7 error numbers starts here +skip-to-error-number 3000 + +ER_MYSQL_57_TEST + eng "5.7 test" + +# MariaDB extra error numbers starts from 4000 +skip-to-error-number 4000 + +ER_WRONG_WINDOW_SPEC_NAME + eng "Window specification with name '%s' is not defined" +ER_DUP_WINDOW_NAME + eng "Multiple window specifications with the same name '%s'" +ER_PARTITION_LIST_IN_REFERENCING_WINDOW_SPEC + eng "Window specification referencing another one '%s' cannot contain partition list" +ER_ORDER_LIST_IN_REFERENCING_WINDOW_SPEC + eng "Referenced window specification '%s' already contains order list" +ER_WINDOW_FRAME_IN_REFERENCED_WINDOW_SPEC + eng "Referenced window specification '%s' cannot contain window frame" +ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS + eng "Unacceptable combination of window frame bound specifications" +ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION + eng "Window function is allowed only in SELECT list and ORDER BY clause" +ER_WINDOW_FUNCTION_IN_WINDOW_SPEC + eng "Window function is not allowed in window specification" +ER_NOT_ALLOWED_WINDOW_FRAME + eng "Window frame is not allowed with '%s'" +ER_NO_ORDER_LIST_IN_WINDOW_SPEC + eng "No order list in window specification for '%s'" +ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY + eng "RANGE-type frame requires ORDER BY clause with single sort key" +ER_WRONG_TYPE_FOR_ROWS_FRAME + eng "Integer is required for ROWS-type frame" +ER_WRONG_TYPE_FOR_RANGE_FRAME + eng "Numeric datatype is required for RANGE-type frame" +ER_FRAME_EXCLUSION_NOT_SUPPORTED + eng "Frame exclusion is not supported yet" +ER_WINDOW_FUNCTION_DONT_HAVE_FRAME + eng "This window function may not have a window frame" +ER_INVALID_NTILE_ARGUMENT + eng "Argument of NTILE must be greater than 0" diff --git a/sql/slave.cc b/sql/slave.cc index 93506bc2ccd..30a0018f490 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4955,7 +4955,6 @@ err_during_init: delete serial_rgi; mysql_mutex_unlock(&LOCK_thread_count); - THD_CHECK_SENTRY(thd); delete thd; thread_safe_decrement32(&service_thread_count); signal_thd_deleted(); diff --git a/sql/sql_analyze_stmt.cc b/sql/sql_analyze_stmt.cc index d11c93229b0..58f72d6b8de 100644 --- a/sql/sql_analyze_stmt.cc +++ b/sql/sql_analyze_stmt.cc @@ -69,75 +69,3 @@ void Filesort_tracker::print_json_members(Json_writer *writer) } } - -/* - Report that we are doing a filesort. - @return - Tracker object to be used with filesort -*/ - -Filesort_tracker *Sort_and_group_tracker::report_sorting(THD *thd) -{ - DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS); - - if (total_actions) - { - /* This is not the first execution. Check */ - if (qep_actions[cur_action] != EXPL_ACTION_FILESORT) - { - varied_executions= true; - cur_action++; - if (!dummy_fsort_tracker) - dummy_fsort_tracker= new (thd->mem_root) Filesort_tracker(is_analyze); - return dummy_fsort_tracker; - } - return qep_actions_data[cur_action++].filesort_tracker; - } - - Filesort_tracker *fs_tracker= new(thd->mem_root)Filesort_tracker(is_analyze); - qep_actions_data[cur_action].filesort_tracker= fs_tracker; - qep_actions[cur_action++]= EXPL_ACTION_FILESORT; - - return fs_tracker; -} - - -void Sort_and_group_tracker::report_tmp_table(TABLE *tbl) -{ - DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS); - if (total_actions) - { - /* This is not the first execution. Check if the steps match. */ - // todo: should also check that tmp.table kinds are the same. - if (qep_actions[cur_action] != EXPL_ACTION_TEMPTABLE) - varied_executions= true; - } - - if (!varied_executions) - { - qep_actions[cur_action]= EXPL_ACTION_TEMPTABLE; - // qep_actions_data[cur_action]= .... - } - - cur_action++; -} - - -void Sort_and_group_tracker::report_duplicate_removal() -{ - DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS); - if (total_actions) - { - /* This is not the first execution. Check if the steps match. */ - if (qep_actions[cur_action] != EXPL_ACTION_REMOVE_DUPS) - varied_executions= true; - } - - if (!varied_executions) - { - qep_actions[cur_action]= EXPL_ACTION_REMOVE_DUPS; - } - - cur_action++; -} - diff --git a/sql/sql_analyze_stmt.h b/sql/sql_analyze_stmt.h index d7634bdfb85..2a08a842dfc 100644 --- a/sql/sql_analyze_stmt.h +++ b/sql/sql_analyze_stmt.h @@ -284,174 +284,3 @@ private: ulonglong sort_buffer_size; }; - -typedef enum -{ - EXPL_NO_TMP_TABLE=0, - EXPL_TMP_TABLE_BUFFER, - EXPL_TMP_TABLE_GROUP, - EXPL_TMP_TABLE_DISTINCT -} enum_tmp_table_use; - - -typedef enum -{ - EXPL_ACTION_EOF, /* not-an-action */ - EXPL_ACTION_FILESORT, - EXPL_ACTION_TEMPTABLE, - EXPL_ACTION_REMOVE_DUPS, -} enum_qep_action; - - -/* - This is to track how a JOIN object has resolved ORDER/GROUP BY/DISTINCT - - We are not tied to the query plan at all, because query plan does not have - sufficient information. *A lot* of decisions about ordering/grouping are - made at very late stages (in JOIN::exec, JOIN::init_execution, in - create_sort_index and even in create_tmp_table). - - The idea is that operations that happen during select execution will report - themselves. We have these operations: - - Sorting with filesort() - - Duplicate row removal (the one done by remove_duplicates()). - - Use of temporary table to buffer the result. - - There is also "Selection" operation, done by do_select(). It reads rows, - there are several distinct cases: - 1. doing the join operation on the base tables - 2. reading the temporary table - 3. reading the filesort output - it would be nice to build execution graph, e.g. - - Select(JOIN op) -> temp.table -> filesort -> Select(filesort result) - - the problem is that there is no way to tell what a do_select() call will do. - - Our solution is not to have explicit selection operations. We make these - assumptions about the query plan: - - Select(JOIN op) is the first operation in the query plan - - Unless the first recorded operation is filesort(). filesort() is unable - read result of a select, so when we find it first, the query plan is: - - filesort(first join table) -> Select(JOIN op) -> ... - - the other popular query plan is: - - Select (JOIN op) -> temp.table -> filesort() -> ... - -///TODO: handle repeated execution with subselects! -*/ - -class Sort_and_group_tracker : public Sql_alloc -{ - enum { MAX_QEP_ACTIONS = 5 }; - - /* Query actions in the order they were made. */ - enum_qep_action qep_actions[MAX_QEP_ACTIONS]; - - /* Number for the next action */ - int cur_action; - - /* - Non-zero means there was already an execution which had - #total_actions actions - */ - int total_actions; - - int get_n_actions() - { - return total_actions? total_actions: cur_action; - } - - /* - TRUE<=>there were executions which took different sort/buffer/de-duplicate - routes. The counter values are not meaningful. - */ - bool varied_executions; - - /* Details about query actions */ - union - { - Filesort_tracker *filesort_tracker; - enum_tmp_table_use tmp_table; - } - qep_actions_data[MAX_QEP_ACTIONS]; - - Filesort_tracker *dummy_fsort_tracker; - bool is_analyze; -public: - Sort_and_group_tracker(bool is_analyze_arg) : - cur_action(0), total_actions(0), varied_executions(false), - dummy_fsort_tracker(NULL), - is_analyze(is_analyze_arg) - {} - - /*************** Reporting interface ***************/ - /* Report that join execution is started */ - void report_join_start() - { - if (!total_actions && cur_action != 0) - { - /* This is a second execution */ - total_actions= cur_action; - } - cur_action= 0; - } - - /* - Report that a temporary table is created. The next step is to write to the - this tmp. table - */ - void report_tmp_table(TABLE *tbl); - - /* - Report that we are doing a filesort. - @return - Tracker object to be used with filesort - */ - Filesort_tracker *report_sorting(THD *thd); - - /* - Report that remove_duplicates() is invoked [on a temp. table]. - We don't collect any statistics on this operation, yet. - */ - void report_duplicate_removal(); - - friend class Iterator; - /*************** Statistics retrieval interface ***************/ - bool had_varied_executions() { return varied_executions; } - - class Iterator - { - Sort_and_group_tracker *owner; - int idx; - public: - Iterator(Sort_and_group_tracker *owner_arg) : - owner(owner_arg), idx(owner_arg->get_n_actions() - 1) - {} - - enum_qep_action get_next(Filesort_tracker **tracker/*, - enum_tmp_table_use *tmp_table_use*/) - { - /* Walk back through the array... */ - if (idx < 0) - return EXPL_ACTION_EOF; - switch (owner->qep_actions[idx]) - { - case EXPL_ACTION_FILESORT: - *tracker= owner->qep_actions_data[idx].filesort_tracker; - break; - case EXPL_ACTION_TEMPTABLE: - //*tmp_table_use= tmp_table_kind[tmp_table_idx++]; - break; - default: - break; - } - return owner->qep_actions[idx--]; - } - - bool is_last_element() { return idx == -1; } - }; -}; - diff --git a/sql/sql_array.h b/sql/sql_array.h index 159951e26a6..bbaa653b177 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -85,6 +85,15 @@ public: Element_type *array() const { return m_array; } + bool operator==(const Bounds_checked_array<Element_type>&rhs) const + { + return m_array == rhs.m_array && m_size == rhs.m_size; + } + bool operator!=(const Bounds_checked_array<Element_type>&rhs) const + { + return m_array != rhs.m_array || m_size != rhs.m_size; + } + private: Element_type *m_array; size_t m_size; @@ -230,6 +239,11 @@ public: delete_dynamic(&array); } + void free_memory() + { + delete_dynamic(&array); + } + typedef int (*CMP_FUNC)(const Elem *el1, const Elem *el2); void sort(CMP_FUNC cmp_func) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 08509a0e2bf..18e7ee950e6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2551,8 +2551,13 @@ retry_share: (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER, table_list); else if (share->crashed) - (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR, - table_list); + { + if (!(flags & MYSQL_OPEN_IGNORE_REPAIR)) + (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR, + table_list); + else + table_list->crashed= 1; /* Mark that table was crashed */ + } goto err_lock; } if (open_table_entry_fini(thd, share, table)) @@ -6824,6 +6829,8 @@ find_field_in_tables(THD *thd, Item_ident *item, or as a field name without alias, or as a field hidden by alias, or ignoring alias) + limit How many items in the list to check + (if limit==0 then all items are to be checked) RETURN VALUES 0 Item is not found or item is not unique, @@ -6841,9 +6848,10 @@ Item **not_found_item= (Item**) 0x1; Item ** find_item_in_list(Item *find, List<Item> &items, uint *counter, find_item_error_report_type report_error, - enum_resolution_type *resolution) + enum_resolution_type *resolution, uint limit) { List_iterator<Item> li(items); + uint n_items= limit == 0 ? items.elements : limit; Item **found=0, **found_unaliased= 0, *item; const char *db_name=0; const char *field_name=0; @@ -6867,8 +6875,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, db_name= ((Item_ident*) find)->db_name; } - for (uint i= 0; (item=li++); i++) + for (uint i= 0; i < n_items; i++) { + item= li++; if (field_name && (item->real_item()->type() == Item::FIELD_ITEM || ((item->type() == Item::REF_ITEM) && @@ -7749,11 +7758,13 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, List<Item> *sum_func_list, uint wild_num) { + if (!wild_num) + return(0); + Item *item; List_iterator<Item> it(fields); Query_arena *arena, backup; DBUG_ENTER("setup_wild"); - DBUG_ASSERT(wild_num != 0); /* Don't use arena if we are not in prepared statements or stored procedures @@ -7832,7 +7843,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, ** Check that all given fields exists and fill struct with current data ****************************************************************************/ -bool setup_fields(THD *thd, Item **ref_pointer_array, +bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, enum_mark_columns mark_used_columns, List<Item> *sum_func_list, bool allow_sum_func) { @@ -7842,7 +7853,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, List_iterator<Item> it(fields); bool save_is_item_list_lookup; DBUG_ENTER("setup_fields"); - DBUG_PRINT("enter", ("ref_pointer_array: %p", ref_pointer_array)); + DBUG_PRINT("enter", ("ref_pointer_array: %p", ref_pointer_array.array())); thd->mark_used_columns= mark_used_columns; DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns)); @@ -7864,8 +7875,11 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, TODO: remove it when (if) we made one list for allfields and ref_pointer_array */ - if (ref_pointer_array) - bzero(ref_pointer_array, sizeof(Item *) * fields.elements); + if (!ref_pointer_array.is_null()) + { + DBUG_ASSERT(ref_pointer_array.size() >= fields.elements); + memset(ref_pointer_array.array(), 0, sizeof(Item *) * fields.elements); + } /* We call set_entry() there (before fix_fields() of the whole list of field @@ -7883,7 +7897,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, while ((var= li++)) var->set_entry(thd, FALSE); - Item **ref= ref_pointer_array; + Ref_ptr_array ref= ref_pointer_array; thd->lex->current_select->cur_pos_in_select_list= 0; while ((item= it++)) { @@ -7896,12 +7910,20 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns)); DBUG_RETURN(TRUE); /* purecov: inspected */ } - if (ref) - *(ref++)= item; - if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && - sum_func_list) + if (!ref.is_null()) + { + ref[0]= item; + ref.pop_front(); + } + /* + split_sum_func() must be called for Window Function items, see + Item_window_func::split_sum_func. + */ + if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && + sum_func_list) || item->with_window_func) item->split_sum_func(thd, ref_pointer_array, *sum_func_list, SPLIT_SUM_SELECT); + thd->lex->current_select->select_list_tables|= item->used_tables(); thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; } @@ -8320,7 +8342,10 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, views and natural joins this update is performed inside the loop below. */ if (table) + { thd->lex->used_tables|= table->map; + thd->lex->current_select->select_list_tables|= table->map; + } /* Initialize a generic field iterator for the current table reference. @@ -8412,6 +8437,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, if (field_table) { thd->lex->used_tables|= field_table->map; + thd->lex->current_select->select_list_tables|= + field_table->map; field_table->covering_keys.intersect(field->part_of_key); field_table->merge_keys.merge(field->part_of_key); field_table->used_fields++; diff --git a/sql/sql_base.h b/sql/sql_base.h index b6e135b6feb..d6bd0e2ace7 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -107,6 +107,10 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update, table flush, wait on thr_lock.c locks) while opening and locking table. */ #define MYSQL_OPEN_IGNORE_KILLED 0x8000 +/** + Don't try to auto-repair table +*/ +#define MYSQL_OPEN_IGNORE_REPAIR 0x10000 /** Please refer to the internals manual. */ #define MYSQL_OPEN_REOPEN (MYSQL_OPEN_IGNORE_FLUSH |\ @@ -168,7 +172,7 @@ void make_leaves_list(THD *thd, List<TABLE_LIST> &list, TABLE_LIST *tables, bool full_table_list, TABLE_LIST *boundary); int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, List<Item> *sum_func_list, uint wild_num); -bool setup_fields(THD *thd, Item** ref_pointer_array, +bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &item, enum_mark_columns mark_used_columns, List<Item> *sum_func_list, bool allow_sum_func); void unfix_fields(List<Item> &items); @@ -197,7 +201,7 @@ Field * find_field_in_table_sef(TABLE *table, const char *name); Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter, find_item_error_report_type report_error, - enum_resolution_type *resolution); + enum_resolution_type *resolution, uint limit= 0); bool setup_tables(THD *thd, Name_resolution_context *context, List<TABLE_LIST> *from_clause, TABLE_LIST *tables, List<TABLE_LIST> &leaves, bool select_insert, @@ -382,7 +386,7 @@ inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table, } -inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array, +inline bool setup_fields_with_no_wrap(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &item, enum_mark_columns mark_used_columns, List<Item> *sum_func_list, diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 91dd8ad7325..42b80d9b143 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -354,7 +354,7 @@ const uchar *query_state_map; #include "emb_qcache.h" #endif -#if !defined(EXTRA_DBUG) && !defined(DBUG_OFF) +#if defined(EXTRA_DEBUG) && !defined(DBUG_OFF) #define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock 0x%lx",(ulong)(M))); \ if (!mysql_rwlock_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \ else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e3b70566597..b1217cb1f9f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -908,7 +908,8 @@ THD::THD(bool is_wsrep_applier) */ THD *old_THR_THD= current_thd; set_current_thd(this); - status_var.local_memory_used= status_var.global_memory_used= 0; + status_var.local_memory_used= sizeof(THD); + status_var.global_memory_used= 0; main_da.init(); /* @@ -1641,6 +1642,8 @@ THD::~THD() that memory allocation counting is done correctly */ set_current_thd(this); + if (!status_in_global) + add_status_to_global(); /* Ensure that no one is using THD */ mysql_mutex_lock(&LOCK_thd_data); @@ -1703,6 +1706,7 @@ THD::~THD() if (xid_hash_pins) lf_hash_put_pins(xid_hash_pins); /* Ensure everything is freed */ + status_var.local_memory_used-= sizeof(THD); if (status_var.local_memory_used != 0) { DBUG_PRINT("error", ("memory_used: %lld", status_var.local_memory_used)); @@ -1710,7 +1714,7 @@ THD::~THD() DBUG_ASSERT(status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory); } - + update_global_memory_status(status_var.global_memory_used); set_current_thd(orig_thd == this ? 0 : orig_thd); DBUG_VOID_RETURN; } @@ -1748,12 +1752,17 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) to_var->binlog_bytes_written+= from_var->binlog_bytes_written; to_var->cpu_time+= from_var->cpu_time; to_var->busy_time+= from_var->busy_time; - to_var->local_memory_used+= from_var->local_memory_used; /* Update global_memory_used. We have to do this with atomic_add as the global value can change outside of LOCK_status. */ + if (to_var == &global_status_var) + { + DBUG_PRINT("info", ("global memory_used: %lld size: %lld", + (longlong) global_status_var.global_memory_used, + (longlong) from_var->global_memory_used)); + } // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1) int64 volatile * volatile ptr= &to_var->global_memory_used; my_atomic_add64_explicit(ptr, from_var->global_memory_used, diff --git a/sql/sql_class.h b/sql/sql_class.h index be652e6dd01..e0792a4059f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -658,7 +658,7 @@ typedef struct system_variables /* Error messages */ MY_LOCALE *lc_messages; - const char **errmsgs; /* lc_messages->errmsg->errmsgs */ + const char ***errmsgs; /* lc_messages->errmsg->errmsgs */ /* Locale Support */ MY_LOCALE *lc_time_names; @@ -824,6 +824,20 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var); void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, STATUS_VAR *dec_var); +/* + Update global_memory_used. We have to do this with atomic_add as the + global value can change outside of LOCK_status. +*/ +inline void update_global_memory_status(int64 size) +{ + DBUG_PRINT("info", ("global memory_used: %lld size: %lld", + (longlong) global_status_var.global_memory_used, + size)); + // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1) + int64 volatile * volatile ptr= &global_status_var.global_memory_used; + my_atomic_add64_explicit(ptr, size, MY_MEMORY_ORDER_RELAXED); +} + /** Get collation by name, send error to client on failure. @param name Collation name @@ -3846,9 +3860,11 @@ public: void add_status_to_global() { + DBUG_ASSERT(status_in_global == 0); mysql_mutex_lock(&LOCK_status); add_to_status(&global_status_var, &status_var); /* Mark that this THD status has already been added in global status */ + status_var.global_memory_used= 0; status_in_global= 1; mysql_mutex_unlock(&LOCK_status); } @@ -4527,16 +4543,9 @@ inline uint tmp_table_max_key_parts() { return MI_MAX_KEY_SEG; } class TMP_TABLE_PARAM :public Sql_alloc { -private: - /* Prevent use of these (not safe because of lists and copy_field) */ - TMP_TABLE_PARAM(const TMP_TABLE_PARAM &); - void operator=(TMP_TABLE_PARAM &); - public: List<Item> copy_funcs; - List<Item> save_copy_funcs; Copy_field *copy_field, *copy_field_end; - Copy_field *save_copy_field, *save_copy_field_end; uchar *group_buff; Item **items_to_copy; /* Fields in tmp table */ TMP_ENGINE_COLUMNDEF *recinfo, *start_recinfo; @@ -4571,7 +4580,13 @@ public: uint hidden_field_count; uint group_parts,group_length,group_null_parts; uint quick_group; - bool using_indirect_summary_function; + /** + Enabled when we have atleast one outer_sum_func. Needed when used + along with distinct. + + @see create_tmp_table + */ + bool using_outer_summary_function; CHARSET_INFO *table_charset; bool schema_table; /* TRUE if the temp table is created for subquery materialization. */ @@ -4601,9 +4616,10 @@ public: TMP_TABLE_PARAM() :copy_field(0), group_parts(0), group_length(0), group_null_parts(0), - schema_table(0), materialized_subquery(0), force_not_null_cols(0), - precomputed_group_by(0), - force_copy_fields(0), bit_fields_as_long(0), skip_create_table(0) + using_outer_summary_function(0), + schema_table(0), materialized_subquery(0), force_not_null_cols(0), + precomputed_group_by(0), + force_copy_fields(0), bit_fields_as_long(0), skip_create_table(0) {} ~TMP_TABLE_PARAM() { @@ -4615,8 +4631,8 @@ public: if (copy_field) /* Fix for Intel compiler */ { delete [] copy_field; - save_copy_field= copy_field= NULL; - save_copy_field_end= copy_field_end= NULL; + copy_field= NULL; + copy_field_end= NULL; } } }; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index ea114bf40a5..66564bd5e94 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1192,7 +1192,6 @@ void prepare_new_connection_state(THD* thd) */ thd->proc_info= 0; thd->set_command(COM_SLEEP); - thd->set_time(); thd->init_for_queries(); if (opt_init_connect.length && !(sctx->master_access & SUPER_ACL)) @@ -1234,7 +1233,6 @@ void prepare_new_connection_state(THD* thd) } thd->proc_info=0; - thd->set_time(); thd->init_for_queries(); } } diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 1203a4ce0c8..77f0bcf04ba 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -512,7 +512,10 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) { With_clause *with_clause=sl->get_with_clause(); if (with_clause && (found= with_clause->find_table_def(table))) - return found; + return found; + /* Do not look for the table's definition beyond the scope of the view */ + if (sl->master_unit()->is_view) + break; } return found; } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 42e7f6c3569..95aee805c7f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -263,7 +263,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE"); DBUG_RETURN(TRUE); } - if (!(table= table_list->table) || !table->created) + if (!(table= table_list->table) || !table->is_created()) { my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0), table_list->view_db.str, table_list->view_name.str); @@ -490,27 +490,31 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (query_plan.using_filesort) { - uint length= 0; - SORT_FIELD *sortorder; { + Filesort fsort(order, HA_POS_ERROR, true, select); DBUG_ASSERT(query_plan.index == MAX_KEY); + Filesort_tracker *fs_tracker= thd->lex->explain->get_upd_del_plan()->filesort_tracker; - if (!(sortorder= make_unireg_sortorder(thd, order, &length, NULL)) || - !(file_sort= filesort(thd, table, sortorder, length, - select, HA_POS_ERROR, - true, - fs_tracker))) + if (!(file_sort= filesort(thd, table, &fsort, fs_tracker))) goto got_error; + thd->inc_examined_row_count(file_sort->examined_rows); /* Filesort has already found and selected the rows we want to delete, so we don't need the where clause */ delete select; - free_underlaid_joins(thd, select_lex); + + /* + If we are not in DELETE ... RETURNING, we can free subqueries. (in + DELETE ... RETURNING we can't, because the RETURNING part may have + a subquery in it) + */ + if (!with_select) + free_underlaid_joins(thd, select_lex); select= 0; } } @@ -737,7 +741,7 @@ got_error: wild_num - number of wildcards used in optional SELECT clause field_list - list of items in optional SELECT clause conds - conditions - +l RETURN VALUE FALSE OK TRUE error @@ -758,7 +762,8 @@ got_error: DELETE_ACL, SELECT_ACL, TRUE)) DBUG_RETURN(TRUE); if ((wild_num && setup_wild(thd, table_list, field_list, NULL, wild_num)) || - setup_fields(thd, NULL, field_list, MARK_COLUMNS_READ, NULL, 0) || + setup_fields(thd, Ref_ptr_array(), + field_list, MARK_COLUMNS_READ, NULL, 0) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || setup_ftfuncs(select_lex)) DBUG_RETURN(TRUE); diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 1ef83b3bf1f..79e57cded81 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -477,7 +477,7 @@ exit_merge: unconditional_materialization: derived->change_refs_to_fields(); derived->set_materialized_derived(); - if (!derived->table || !derived->table->created) + if (!derived->table || !derived->table->is_created()) res= mysql_derived_create(thd, lex, derived); if (!res) res= mysql_derived_fill(thd, lex, derived); @@ -859,7 +859,7 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) TABLE *table= derived->table; SELECT_LEX_UNIT *unit= derived->get_unit(); - if (table->created) + if (table->is_created()) DBUG_RETURN(FALSE); select_union *result= (select_union*)unit->result; if (table->s->db_type() == TMP_ENGINE_HTON) @@ -912,7 +912,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) if (unit->executed && !unit->uncacheable && !unit->describe) DBUG_RETURN(FALSE); /*check that table creation passed without problems. */ - DBUG_ASSERT(derived->table && derived->table->created); + DBUG_ASSERT(derived->table && derived->table->is_created()); SELECT_LEX *first_select= unit->first_select(); select_union *derived_result= derived->derived_result; SELECT_LEX *save_current_select= lex->current_select; @@ -928,7 +928,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) first_select->options&= ~OPTION_FOUND_ROWS; lex->current_select= first_select; - res= mysql_select(thd, &first_select->ref_pointer_array, + res= mysql_select(thd, first_select->table_list.first, first_select->with_wild, first_select->item_list, first_select->where, diff --git a/sql/sql_do.cc b/sql/sql_do.cc index 9e58031f6a4..6d86ece6a9f 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -29,7 +29,7 @@ bool mysql_do(THD *thd, List<Item> &values) List_iterator<Item> li(values); Item *value; DBUG_ENTER("mysql_do"); - if (setup_fields(thd, 0, values, MARK_COLUMNS_NONE, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), values, MARK_COLUMNS_NONE, 0, 0)) DBUG_RETURN(TRUE); while ((value = li++)) (void) value->is_null(); diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index dae5127cbf8..1f8b4f2dcb1 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -30,6 +30,7 @@ const char * STR_IMPOSSIBLE_WHERE= "Impossible WHERE"; const char * STR_NO_ROWS_AFTER_PRUNING= "No matching rows after partition pruning"; static void write_item(Json_writer *writer, Item *item); +static void append_item_to_str(String *out, Item *item); Explain_query::Explain_query(THD *thd_arg, MEM_ROOT *root) : mem_root(root), upd_del_plan(NULL), insert_plan(NULL), @@ -697,13 +698,6 @@ bool Explain_node::print_explain_json_cache(Json_writer *writer, } -void Explain_select::replace_table(uint idx, Explain_table_access *new_tab) -{ - delete join_tabs[idx]; - join_tabs[idx]= new_tab; -} - - Explain_basic_join::~Explain_basic_join() { if (join_tabs) @@ -754,35 +748,23 @@ int Explain_select::print_explain(Explain_query *query, } else { - bool using_tmp; - bool using_fs; + bool using_tmp= false; + bool using_fs= false; - if (is_analyze) + for (Explain_aggr_node *node= aggr_tree; node; node= node->child) { - /* - Get the data about "Using temporary; Using filesort" from execution - tracking system. - */ - using_tmp= false; - using_fs= false; - Sort_and_group_tracker::Iterator iter(&ops_tracker); - enum_qep_action action; - Filesort_tracker *dummy; - - while ((action= iter.get_next(&dummy)) != EXPL_ACTION_EOF) + switch (node->get_type()) { - if (action == EXPL_ACTION_FILESORT) - using_fs= true; - else if (action == EXPL_ACTION_TEMPTABLE) + case AGGR_OP_TEMP_TABLE: using_tmp= true; + break; + case AGGR_OP_FILESORT: + using_fs= true; + break; + default: + break; } } - else - { - /* Use imprecise "estimates" we got with the query plan */ - using_tmp= using_temporary; - using_fs= using_filesort; - } for (uint i=0; i< n_join_tabs; i++) { @@ -882,88 +864,40 @@ void Explain_select::print_explain_json(Explain_query *query, } } - Filesort_tracker *first_table_sort= NULL; - bool first_table_sort_used= false; int started_objects= 0; + + Explain_aggr_node *node= aggr_tree; - if (is_analyze) + for (; node; node= node->child) { - /* ANALYZE has collected this part of query plan independently */ - if (ops_tracker.had_varied_executions()) + switch (node->get_type()) { - writer->add_member("varied-sort-and-tmp").start_object(); - started_objects++; - } - else - { - Sort_and_group_tracker::Iterator iter(&ops_tracker); - enum_qep_action action; - Filesort_tracker *fs_tracker; - - while ((action= iter.get_next(&fs_tracker)) != EXPL_ACTION_EOF) + case AGGR_OP_TEMP_TABLE: + writer->add_member("temporary_table").start_object(); + break; + case AGGR_OP_FILESORT: { - if (action == EXPL_ACTION_FILESORT) - { - if (iter.is_last_element()) - { - first_table_sort= fs_tracker; - break; - } - writer->add_member("filesort").start_object(); - started_objects++; - fs_tracker->print_json_members(writer); - } - else if (action == EXPL_ACTION_TEMPTABLE) - { - writer->add_member("temporary_table").start_object(); - started_objects++; - /* - if (tmp == EXPL_TMP_TABLE_BUFFER) - func= "buffer"; - else if (tmp == EXPL_TMP_TABLE_GROUP) - func= "group-by"; - else - func= "distinct"; - writer->add_member("function").add_str(func); - */ - } - else if (action == EXPL_ACTION_REMOVE_DUPS) - { - writer->add_member("duplicate_removal").start_object(); - started_objects++; - } - else - DBUG_ASSERT(0); + writer->add_member("filesort").start_object(); + ((Explain_aggr_filesort*)node)->print_json_members(writer, is_analyze); + break; } - } - - if (first_table_sort) - first_table_sort_used= true; - } - else - { - /* This is just EXPLAIN. Try to produce something meaningful */ - if (using_temporary) - { - started_objects= 1; - if (using_filesort) + case AGGR_OP_REMOVE_DUPLICATES: + writer->add_member("duplicate_removal").start_object(); + break; + case AGGR_OP_WINDOW_FUNCS: { - started_objects++; - writer->add_member("filesort").start_object(); + //TODO: make print_json_members virtual? + writer->add_member("window_functions_computation").start_object(); + ((Explain_aggr_window_funcs*)node)->print_json_members(writer, is_analyze); + break; } - writer->add_member("temporary_table").start_object(); - writer->add_member("function").add_str("buffer"); - } - else - { - if (using_filesort) - first_table_sort_used= true; + default: + DBUG_ASSERT(0); } + started_objects++; } - Explain_basic_join::print_explain_json_interns(query, writer, is_analyze, - first_table_sort, - first_table_sort_used); + Explain_basic_join::print_explain_json_interns(query, writer, is_analyze); for (;started_objects; started_objects--) writer->end_object(); @@ -976,6 +910,64 @@ void Explain_select::print_explain_json(Explain_query *query, } +Explain_aggr_filesort::Explain_aggr_filesort(MEM_ROOT *mem_root, + bool is_analyze, + Filesort *filesort) + : tracker(is_analyze) +{ + child= NULL; + for (ORDER *ord= filesort->order; ord; ord= ord->next) + { + sort_items.push_back(ord->item[0], mem_root); + } + filesort->tracker= &tracker; +} + + +void Explain_aggr_filesort::print_json_members(Json_writer *writer, + bool is_analyze) +{ + char item_buf[256]; + String str(item_buf, sizeof(item_buf), &my_charset_bin); + str.length(0); + + List_iterator_fast<Item> it(sort_items); + Item *item; + bool first= true; + while ((item= it++)) + { + if (first) + first= false; + else + { + str.append(", "); + } + append_item_to_str(&str, item); + } + + writer->add_member("sort_key").add_str(str.c_ptr_safe()); + + if (is_analyze) + tracker.print_json_members(writer); +} + + +void Explain_aggr_window_funcs::print_json_members(Json_writer *writer, + bool is_analyze) +{ + Explain_aggr_filesort *srt; + List_iterator<Explain_aggr_filesort> it(sorts); + writer->add_member("sorts").start_object(); + while ((srt= it++)) + { + writer->add_member("filesort").start_object(); + srt->print_json_members(writer, is_analyze); + writer->end_object(); // filesort + } + writer->end_object(); // sorts +} + + void Explain_basic_join::print_explain_json(Explain_query *query, Json_writer *writer, bool is_analyze) @@ -983,7 +975,7 @@ void Explain_basic_join::print_explain_json(Explain_query *query, writer->add_member("query_block").start_object(); writer->add_member("select_id").add_ll(select_id); - print_explain_json_interns(query, writer, is_analyze, NULL, false); + print_explain_json_interns(query, writer, is_analyze); writer->end_object(); } @@ -992,9 +984,7 @@ void Explain_basic_join::print_explain_json(Explain_query *query, void Explain_basic_join:: print_explain_json_interns(Explain_query *query, Json_writer *writer, - bool is_analyze, - Filesort_tracker *first_table_sort, - bool first_table_sort_used) + bool is_analyze) { Json_writer_nesting_guard guard(writer); for (uint i=0; i< n_join_tabs; i++) @@ -1002,12 +992,7 @@ print_explain_json_interns(Explain_query *query, if (join_tabs[i]->start_dups_weedout) writer->add_member("duplicates_removal").start_object(); - join_tabs[i]->print_explain_json(query, writer, is_analyze, - first_table_sort, - first_table_sort_used); - - first_table_sort= NULL; - first_table_sort_used= false; + join_tabs[i]->print_explain_json(query, writer, is_analyze); if (join_tabs[i]->end_dups_weedout) writer->end_object(); @@ -1299,7 +1284,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai extra_buf.append(STRING_WITH_LEN("Using temporary")); } - if (using_filesort) + if (using_filesort || this->pre_join_sort) { if (first) first= false; @@ -1359,6 +1344,15 @@ static void write_item(Json_writer *writer, Item *item) writer->add_str(str.c_ptr_safe()); } +static void append_item_to_str(String *out, Item *item) +{ + THD *thd= current_thd; + ulonglong save_option_bits= thd->variables.option_bits; + thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE; + + item->print(out, QT_EXPLAIN); + thd->variables.option_bits= save_option_bits; +} void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_tag tag) { @@ -1486,25 +1480,14 @@ void add_json_keyset(Json_writer *writer, const char *elem_name, print_json_array(writer, elem_name, *keyset); } -/* - @param fs_tracker Normally NULL. When not NULL, it means that the join tab - used filesort to pre-sort the data. Then, sorted data - was read and the rest of the join was executed. - - @note - EXPLAIN command will check whether fs_tracker is present, but it can't use - any value from fs_tracker (these are only valid for ANALYZE). -*/ void Explain_table_access::print_explain_json(Explain_query *query, Json_writer *writer, - bool is_analyze, - Filesort_tracker *fs_tracker, - bool first_table_sort_used) + bool is_analyze) { Json_writer_nesting_guard guard(writer); - if (first_table_sort_used) + if (pre_join_sort) { /* filesort was invoked on this join tab before doing the join with the rest */ writer->add_member("read_sorted_file").start_object(); @@ -1531,8 +1514,7 @@ void Explain_table_access::print_explain_json(Explain_query *query, } } writer->add_member("filesort").start_object(); - if (is_analyze) - fs_tracker->print_json_members(writer); + pre_join_sort->print_json_members(writer, is_analyze); } if (bka_type.is_using_jbuf()) @@ -1610,11 +1592,11 @@ void Explain_table_access::print_explain_json(Explain_query *query, if (is_analyze) { writer->add_member("r_rows"); - if (fs_tracker) + if (pre_join_sort) { /* Get r_rows value from filesort */ - if (fs_tracker->get_r_loops()) - writer->add_double(fs_tracker->get_avg_examined_rows()); + if (pre_join_sort->tracker.get_r_loops()) + writer->add_double(pre_join_sort->tracker.get_avg_examined_rows()); else writer->add_null(); } @@ -1641,11 +1623,11 @@ void Explain_table_access::print_explain_json(Explain_query *query, if (is_analyze) { writer->add_member("r_filtered"); - if (fs_tracker) + if (pre_join_sort) { /* Get r_filtered value from filesort */ - if (fs_tracker->get_r_loops()) - writer->add_double(fs_tracker->get_r_filtered()); + if (pre_join_sort->tracker.get_r_loops()) + writer->add_double(pre_join_sort->tracker.get_r_filtered()); else writer->add_null(); } @@ -1723,7 +1705,7 @@ void Explain_table_access::print_explain_json(Explain_query *query, writer->end_object(); } - if (first_table_sort_used) + if (pre_join_sort) { writer->end_object(); // filesort writer->end_object(); // read_sorted_file diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 844773c4a47..abdb1bb978b 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -176,9 +176,7 @@ public: bool is_analyze); void print_explain_json_interns(Explain_query *query, Json_writer *writer, - bool is_analyze, - Filesort_tracker *first_table_sort, - bool first_table_sort_used); + bool is_analyze); /* A flat array of Explain structs for tables. */ Explain_table_access** join_tabs; @@ -186,6 +184,7 @@ public: }; +class Explain_aggr_node; /* EXPLAIN structure for a SELECT. @@ -212,15 +211,9 @@ public: having(NULL), having_value(Item::COND_UNDEF), using_temporary(false), using_filesort(false), time_tracker(is_analyze), - ops_tracker(is_analyze) + aggr_tree(NULL) {} - /* - This is used to save the results of "late" test_if_skip_sort_order() calls - that are made from JOIN::exec - */ - void replace_table(uint idx, Explain_table_access *new_tab); - public: const char *select_type; @@ -244,9 +237,13 @@ public: /* ANALYZE members */ Time_and_counter_tracker time_tracker; - - Sort_and_group_tracker ops_tracker; + /* + Part of query plan describing sorting, temp.table usage, and duplicate + removal + */ + Explain_aggr_node* aggr_tree; + int print_explain(Explain_query *query, select_result_sink *output, uint8 explain_flags, bool is_analyze); void print_explain_json(Explain_query *query, Json_writer *writer, @@ -260,6 +257,64 @@ private: Table_access_tracker using_temporary_read_tracker; }; +///////////////////////////////////////////////////////////////////////////// +// EXPLAIN structures for ORDER/GROUP operations. +///////////////////////////////////////////////////////////////////////////// +typedef enum +{ + AGGR_OP_TEMP_TABLE, + AGGR_OP_FILESORT, + //AGGR_OP_READ_SORTED_FILE, // need this? + AGGR_OP_REMOVE_DUPLICATES, + AGGR_OP_WINDOW_FUNCS + //AGGR_OP_JOIN // Need this? +} enum_explain_aggr_node_type; + + +class Explain_aggr_node : public Sql_alloc +{ +public: + virtual enum_explain_aggr_node_type get_type()= 0; + virtual ~Explain_aggr_node() {} + Explain_aggr_node *child; +}; + +class Explain_aggr_filesort : public Explain_aggr_node +{ + List<Item> sort_items; +public: + enum_explain_aggr_node_type get_type() { return AGGR_OP_FILESORT; } + Filesort_tracker tracker; + + Explain_aggr_filesort(MEM_ROOT *mem_root, bool is_analyze, + Filesort *filesort); + + void print_json_members(Json_writer *writer, bool is_analyze); +}; + +class Explain_aggr_tmp_table : public Explain_aggr_node +{ +public: + enum_explain_aggr_node_type get_type() { return AGGR_OP_TEMP_TABLE; } +}; + +class Explain_aggr_remove_dups : public Explain_aggr_node +{ +public: + enum_explain_aggr_node_type get_type() { return AGGR_OP_REMOVE_DUPLICATES; } +}; + +class Explain_aggr_window_funcs : public Explain_aggr_node +{ + List<Explain_aggr_filesort> sorts; +public: + enum_explain_aggr_node_type get_type() { return AGGR_OP_WINDOW_FUNCS; } + + void print_json_members(Json_writer *writer, bool is_analyze); + friend class Window_funcs_computation; +}; + +///////////////////////////////////////////////////////////////////////////// /* Explain structure for a UNION. @@ -617,7 +672,8 @@ public: where_cond(NULL), cache_cond(NULL), pushed_index_cond(NULL), - sjm_nest(NULL) + sjm_nest(NULL), + pre_join_sort(NULL) {} ~Explain_table_access() { delete sjm_nest; } @@ -710,6 +766,12 @@ public: Item *pushed_index_cond; Explain_basic_join *sjm_nest; + + /* + This describes a possible filesort() call that is done before doing the + join operation. + */ + Explain_aggr_filesort *pre_join_sort; /* ANALYZE members */ @@ -723,9 +785,7 @@ public: uint select_id, const char *select_type, bool using_temporary, bool using_filesort); void print_explain_json(Explain_query *query, Json_writer *writer, - bool is_analyze, - Filesort_tracker *fs_tracker, - bool first_table_sort_used); + bool is_analyze); private: void append_tag_name(String *str, enum explain_extra_tag tag); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9817b882bdd..65af14b62f6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -258,7 +258,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, if (table_list->is_view()) unfix_fields(fields); - res= setup_fields(thd, 0, fields, MARK_COLUMNS_WRITE, 0, 0); + res= setup_fields(thd, Ref_ptr_array(), fields, MARK_COLUMNS_WRITE, 0, 0); /* Restore the current context. */ ctx_state.restore_state(context, table_list); @@ -346,7 +346,8 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list, } /* Check the fields we are going to modify */ - if (setup_fields(thd, 0, update_fields, MARK_COLUMNS_WRITE, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), + update_fields, MARK_COLUMNS_WRITE, 0, 0)) return -1; if (insert_table_list->is_view() && @@ -771,7 +772,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), counter); goto abort; } - if (setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), *values, MARK_COLUMNS_READ, 0, 0)) goto abort; switch_to_nullable_trigger_fields(*values, table); } @@ -1466,7 +1467,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, table_list->next_local= 0; context->resolve_in_table_list_only(table_list); - res= (setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0) || + res= (setup_fields(thd, Ref_ptr_array(), + *values, MARK_COLUMNS_READ, 0, 0) || check_insert_fields(thd, context->table_list, fields, *values, !insert_into_view, 0, &map)); @@ -1482,7 +1484,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, } if (!res) - res= setup_fields(thd, 0, update_values, MARK_COLUMNS_READ, 0, 0); + res= setup_fields(thd, Ref_ptr_array(), + update_values, MARK_COLUMNS_READ, 0, 0); if (!res && duplic == DUP_UPDATE) { @@ -2014,6 +2017,7 @@ public: mysql_cond_t cond, cond_client; volatile uint tables_in_use,stacked_inserts; volatile bool status; + bool retry; /** When the handler thread starts, it clones a metadata lock ticket which protects against GRL and ticket for the table to be inserted. @@ -2038,7 +2042,7 @@ public: Delayed_insert(SELECT_LEX *current_select) :locks_in_memory(0), table(0),tables_in_use(0),stacked_inserts(0), - status(0), handler_thread_initialized(FALSE), group_count(0) + status(0), retry(0), handler_thread_initialized(FALSE), group_count(0) { DBUG_ENTER("Delayed_insert constructor"); thd.security_ctx->user=(char*) delayed_user; @@ -2297,7 +2301,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, } if (di->thd.killed) { - if (di->thd.is_error()) + if (di->thd.is_error() && ! di->retry) { /* Copy the error message. Note that we don't treat fatal @@ -2523,7 +2527,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) copy->vcol_set= copy->def_vcol_set; } copy->tmp_set.bitmap= 0; // To catch errors - bzero((char*) bitmap, share->column_bitmap_size + (share->vfields ? 3 : 2)); + bzero((char*) bitmap, share->column_bitmap_size * (share->vfields ? 3 : 2)); copy->read_set= ©->def_read_set; copy->write_set= ©->def_write_set; @@ -2532,7 +2536,6 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) /* Got fatal error */ error: tables_in_use--; - status=1; mysql_cond_signal(&cond); // Inform thread about abort DBUG_RETURN(0); } @@ -2774,13 +2777,20 @@ bool Delayed_insert::open_and_lock_table() /* Use special prelocking strategy to get ER_DELAYED_NOT_SUPPORTED error for tables with engines which don't support delayed inserts. + + We can't do auto-repair in insert delayed thread, as it would hang + when trying to an exclusive MDL_LOCK on the table during repair + as the connection thread has a SHARED_WRITE lock. */ if (!(table= open_n_lock_single_table(&thd, &table_list, TL_WRITE_DELAYED, - MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK, + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | + MYSQL_OPEN_IGNORE_REPAIR, &prelocking_strategy))) { - thd.fatal_error(); // Abort waiting inserts + /* If table was crashed, then upper level should retry open+repair */ + retry= table_list.crashed; + thd.fatal_error(); // Abort waiting inserts return TRUE; } @@ -3440,7 +3450,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) */ lex->current_select= &lex->select_lex; - res= (setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0) || + res= (setup_fields(thd, Ref_ptr_array(), values, MARK_COLUMNS_READ, 0, 0) || check_insert_fields(thd, table_list, *fields, values, !insert_into_view, 1, &map)); @@ -3493,7 +3503,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) table_list->next_name_resolution_table= ctx_state.get_first_name_resolution_table(); - res= res || setup_fields(thd, 0, *info.update_values, + res= res || setup_fields(thd, Ref_ptr_array(), *info.update_values, MARK_COLUMNS_READ, 0, 0); if (!res) { @@ -3622,7 +3632,7 @@ void select_insert::cleanup() select_insert::~select_insert() { DBUG_ENTER("~select_insert"); - if (table && table->created) + if (table && table->is_created()) { table->next_number_field=0; table->auto_increment_field_not_null= FALSE; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 65257c9b2ce..de345b4dd1c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -748,6 +748,14 @@ void lex_start(THD *thd) lex->stmt_var_list.empty(); lex->proc_list.elements=0; + lex->save_group_list.empty(); + lex->save_order_list.empty(); + lex->win_ref= NULL; + lex->win_frame= NULL; + lex->frame_top_bound= NULL; + lex->frame_bottom_bound= NULL; + lex->win_spec= NULL; + lex->is_lex_started= TRUE; DBUG_VOID_RETURN; } @@ -2070,6 +2078,7 @@ void st_select_lex_unit::init_query() found_rows_for_union= 0; insert_table_with_stored_vcol= 0; derived= 0; + is_view= false; with_clause= 0; with_element= 0; columns_are_renamed= false; @@ -2103,8 +2112,7 @@ void st_select_lex::init_query() parent_lex->push_context(&context, parent_lex->thd->mem_root); cond_count= between_count= with_wild= 0; max_equal_elems= 0; - ref_pointer_array= 0; - ref_pointer_array_size= 0; + ref_pointer_array.reset(); select_n_where_fields= 0; select_n_reserved= 0; select_n_having_items= 0; @@ -2122,8 +2130,11 @@ void st_select_lex::init_query() prep_leaf_list_state= UNINIT; have_merged_subqueries= FALSE; bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used)); + select_list_tables= 0; m_non_agg_field_used= false; m_agg_func_used= false; + window_specs.empty(); + window_funcs.empty(); } void st_select_lex::init_select() @@ -2650,7 +2661,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) select_n_having_items + select_n_where_fields + order_group_num) * 5; - if (ref_pointer_array != NULL) + if (!ref_pointer_array.is_null()) { /* We need to take 'n_sum_items' into account when allocating the array, @@ -2659,17 +2670,24 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) In the usual case we can reuse the array from the prepare phase. If we need a bigger array, we must allocate a new one. */ - if (ref_pointer_array_size >= n_elems) - { - DBUG_PRINT("info", ("reusing old ref_array")); + if (ref_pointer_array.size() == n_elems) return false; - } - } - ref_pointer_array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems)); - if (ref_pointer_array != NULL) - ref_pointer_array_size= n_elems; - return ref_pointer_array == NULL; + /* + We need to take 'n_sum_items' into account when allocating the array, + and this may actually increase during the optimization phase due to + MIN/MAX rewrite in Item_in_subselect::single_value_transformer. + In the usual case we can reuse the array from the prepare phase. + If we need a bigger array, we must allocate a new one. + */ + if (ref_pointer_array.size() == n_elems) + return false; + } + Item **array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems)); + if (array != NULL) + ref_pointer_array= Ref_ptr_array(array, n_elems); + + return array == NULL; } @@ -2734,8 +2752,8 @@ void st_select_lex::print_order(String *str, else (*order->item)->print(str, query_type); } - if (!order->asc) - str->append(STRING_WITH_LEN(" desc")); + if (order->direction == ORDER::ORDER_DESC) + str->append(STRING_WITH_LEN(" desc")); if (order->next) str->append(','); } @@ -4177,9 +4195,11 @@ void SELECT_LEX::update_used_tables() Item *item; List_iterator_fast<Item> it(join->fields_list); + select_list_tables= 0; while ((item= it++)) { item->update_used_tables(); + select_list_tables|= item->used_tables(); } Item_outer_ref *ref; List_iterator_fast<Item_outer_ref> ref_it(inner_refs_list); @@ -4229,6 +4249,8 @@ void st_select_lex::update_correlated_cache() if (join->conds) is_correlated|= MY_TEST(join->conds->used_tables() & OUTER_REF_TABLE_BIT); + is_correlated|= join->having_is_correlated; + if (join->having) is_correlated|= MY_TEST(join->having->used_tables() & OUTER_REF_TABLE_BIT); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index c64ed6b8d5c..10247bd33a2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -28,6 +28,7 @@ #include "mem_root_array.h" #include "sql_cmd.h" #include "sql_alter.h" // Alter_info +#include "sql_window.h" /* YACC and LEX Definitions */ @@ -47,6 +48,7 @@ class sys_var; class Item_func_match; class File_parser; class Key_part_spec; +class Item_window_func; struct sql_digest_state; class With_clause; @@ -643,6 +645,7 @@ public: derived tables/views handling. */ TABLE_LIST *derived; + bool is_view; /* With clause attached to this unit (if any) */ With_clause *with_clause; /* With element where this unit is used as the specification (if any) */ @@ -721,6 +724,7 @@ public: }; typedef class st_select_lex_unit SELECT_LEX_UNIT; +typedef Bounds_checked_array<Item*> Ref_ptr_array; /* SELECT_LEX - store information of parsed SELECT statment @@ -799,9 +803,9 @@ public: SQL_I_List<ORDER> order_list; /* ORDER clause */ SQL_I_List<ORDER> gorder_list; Item *select_limit, *offset_limit; /* LIMIT clause parameters */ - // Arrays of pointers to top elements of all_fields list - Item **ref_pointer_array; - size_t ref_pointer_array_size; // Number of elements in array. + + /// Array of pointers to top elements of all_fields list + Ref_ptr_array ref_pointer_array; /* number of items in select_list and HAVING clause used to get number @@ -898,6 +902,12 @@ public: */ List<String> *prev_join_using; + /** + The set of those tables whose fields are referenced in the select list of + this select level. + */ + table_map select_list_tables; + /* namp of nesting SELECT visibility (for aggregate functions check) */ nesting_map name_visibility_map; @@ -1088,6 +1098,24 @@ public: } With_element *find_table_def_in_with_clauses(TABLE_LIST *table); + List<Window_spec> window_specs; + void prepare_add_window_spec(THD *thd); + bool add_window_def(THD *thd, LEX_STRING *win_name, LEX_STRING *win_ref, + SQL_I_List<ORDER> win_partition_list, + SQL_I_List<ORDER> win_order_list, + Window_frame *win_frame); + bool add_window_spec(THD *thd, LEX_STRING *win_ref, + SQL_I_List<ORDER> win_partition_list, + SQL_I_List<ORDER> win_order_list, + Window_frame *win_frame); + List<Item_window_func> window_funcs; + bool add_window_func(Item_window_func *win_func) + { + return window_funcs.push_back(win_func); + } + + bool have_window_funcs() const { return (window_funcs.elements !=0); } + private: bool m_non_agg_field_used; bool m_agg_func_used; @@ -2756,6 +2784,14 @@ public: } + SQL_I_List<ORDER> save_group_list; + SQL_I_List<ORDER> save_order_list; + LEX_STRING *win_ref; + Window_frame *win_frame; + Window_frame_bound *frame_top_bound; + Window_frame_bound *frame_bottom_bound; + Window_spec *win_spec; + inline void free_set_stmt_mem_root() { DBUG_ASSERT(!is_arena_for_set_stmt()); diff --git a/sql/sql_list.h b/sql/sql_list.h index 113af35bad7..94e97e55aa7 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -451,6 +451,11 @@ public: el= ¤t->next; return current->info; } + /* Get what calling next() would return, without moving the iterator */ + inline void *peek() + { + return (*el)->info; + } inline void *next_fast(void) { list_node *tmp; @@ -503,6 +508,10 @@ public: { return el == &list->last_ref()->next; } + inline bool at_end() + { + return current == &end_of_list; + } friend class error_list_iterator; }; @@ -550,6 +559,7 @@ public: List_iterator() : base_list_iterator() {} inline void init(List<T> &a) { base_list_iterator::init(a); } inline T* operator++(int) { return (T*) base_list_iterator::next(); } + inline T* peek() { return (T*) base_list_iterator::peek(); } inline T *replace(T *a) { return (T*) base_list_iterator::replace(a); } inline T *replace(List<T> &a) { return (T*) base_list_iterator::replace(a); } inline void rewind(void) { base_list_iterator::rewind(); } @@ -607,7 +617,7 @@ inline void bubble_sort(List<T> *list_to_sort, swap= FALSE; while ((item2= it++) && (ref2= it.ref()) != last_ref) { - if (sort_func(item1, item2, arg) < 0) + if (sort_func(item1, item2, arg) > 0) { *ref1= item2; *ref2= item1; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c70e545675d..a4044dd0d59 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -61,6 +61,39 @@ XML_TAG::XML_TAG(int l, String f, String v) } +/* + Field and line terminators must be interpreted as sequence of unsigned char. + Otherwise, non-ascii terminators will be negative on some platforms, + and positive on others (depending on the implementation of char). +*/ +class Term_string +{ + const uchar *m_ptr; + uint m_length; + int m_initial_byte; +public: + Term_string(const String &str) : + m_ptr(static_cast<const uchar*>(static_cast<const void*>(str.ptr()))), + m_length(str.length()), + m_initial_byte((uchar) (str.length() ? str.ptr()[0] : INT_MAX)) + { } + void set(const uchar *str, uint length, int initial_byte) + { + m_ptr= str; + m_length= length; + m_initial_byte= initial_byte; + } + void reset() { set(NULL, 0, INT_MAX); } + const uchar *ptr() const { return m_ptr; } + uint length() const { return m_length; } + int initial_byte() const { return m_initial_byte; } + bool eq(const Term_string &other) const + { + return length() == other.length() && !memcmp(ptr(), other.ptr(), length()); + } +}; + + #define GET (stack_pos != stack ? *--stack_pos : my_b_get(&cache)) #define PUSH(A) *(stack_pos++)=(A) @@ -69,10 +102,10 @@ class READ_INFO { String data; /* Read buffer */ uint fixed_length; /* Length of the fixed length record */ uint max_length; /* Max length of row */ - const uchar *field_term_ptr,*line_term_ptr; - const char *line_start_ptr,*line_start_end; - uint field_term_length,line_term_length,enclosed_length; - int field_term_char,line_term_char,enclosed_char,escape_char; + Term_string m_field_term; /* FIELDS TERMINATED BY 'string' */ + Term_string m_line_term; /* LINES TERMINATED BY 'string' */ + Term_string m_line_start; /* LINES STARTING BY 'string' */ + int enclosed_char,escape_char; int *stack,*stack_pos; bool found_end_of_line,start_of_line,eof; NET *io_net; @@ -86,6 +119,70 @@ class READ_INFO { *to= chr; return false; } + + /** + Read a tail of a multi-byte character. + The first byte of the character is assumed to be already + read from the file and appended to "str". + + @returns true - if EOF happened unexpectedly + @returns false - no EOF happened: found a good multi-byte character, + or a bad byte sequence + + Note: + The return value depends only on EOF: + - read_mbtail() returns "false" is a good character was read, but also + - read_mbtail() returns "false" if an incomplete byte sequence was found + and no EOF happened. + + For example, suppose we have an ujis file with bytes 0x8FA10A, where: + - 0x8FA1 is an incomplete prefix of a 3-byte character + (it should be [8F][A1-FE][A1-FE] to make a full 3-byte character) + - 0x0A is a line demiliter + This file has some broken data, the trailing [A1-FE] is missing. + + In this example it works as follows: + - 0x8F is read from the file and put into "data" before the call + for read_mbtail() + - 0xA1 is read from the file and put into "data" by read_mbtail() + - 0x0A is kept in the read queue, so the next read iteration after + the current read_mbtail() call will normally find it and recognize as + a line delimiter + - the current call for read_mbtail() returns "false", + because no EOF happened + */ + bool read_mbtail(String *str) + { + int chlen; + if ((chlen= my_charlen(read_charset, str->end() - 1, str->end())) == 1) + return false; // Single byte character found + for (uint32 length0= str->length() - 1 ; MY_CS_IS_TOOSMALL(chlen); ) + { + int chr= GET; + if (chr == my_b_EOF) + { + DBUG_PRINT("info", ("read_mbtail: chlen=%d; unexpected EOF", chlen)); + return true; // EOF + } + str->append(chr); + chlen= my_charlen(read_charset, str->ptr() + length0, str->end()); + if (chlen == MY_CS_ILSEQ) + { + /** + It has been an incomplete (but a valid) sequence so far, + but the last byte turned it into a bad byte sequence. + Unget the very last byte. + */ + str->length(str->length() - 1); + PUSH(chr); + DBUG_PRINT("info", ("read_mbtail: ILSEQ")); + return false; // Bad byte sequence + } + } + DBUG_PRINT("info", ("read_mbtail: chlen=%d", chlen)); + return false; // Good multi-byte character + } + public: bool error,line_cuted,found_null,enclosed; uchar *row_start, /* Found row starts here */ @@ -101,7 +198,11 @@ public: int read_fixed_length(void); int next_line(void); char unescape(char chr); - int terminator(const uchar *ptr, uint length); + bool terminator(const uchar *ptr, uint length); + bool terminator(const Term_string &str) + { return terminator(str.ptr(), str.length()); } + bool terminator(int chr, const Term_string &str) + { return str.initial_byte() == chr && terminator(str); } bool find_start_of_fields(); /* load xml */ List<XML_TAG> taglist; @@ -284,22 +385,25 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, Let us also prepare SET clause, altough it is probably empty in this case. */ - if (setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) || - setup_fields(thd, 0, set_values, MARK_COLUMNS_READ, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), + set_fields, MARK_COLUMNS_WRITE, 0, 0) || + setup_fields(thd, Ref_ptr_array(), set_values, MARK_COLUMNS_READ, 0, 0)) DBUG_RETURN(TRUE); } else { // Part field list /* TODO: use this conds for 'WITH CHECK OPTIONS' */ - if (setup_fields(thd, 0, fields_vars, MARK_COLUMNS_WRITE, 0, 0) || - setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) || + if (setup_fields(thd, Ref_ptr_array(), + fields_vars, MARK_COLUMNS_WRITE, 0, 0) || + setup_fields(thd, Ref_ptr_array(), + set_fields, MARK_COLUMNS_WRITE, 0, 0) || check_that_all_fields_are_given_values(thd, table, table_list)) DBUG_RETURN(TRUE); /* Add all fields with default functions to table->write_set. */ if (table->default_field) table->mark_default_fields_for_write(); /* Fix the expressions in SET clause */ - if (setup_fields(thd, 0, set_values, MARK_COLUMNS_READ, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), set_values, MARK_COLUMNS_READ, 0, 0)) DBUG_RETURN(TRUE); } switch_to_nullable_trigger_fields(fields_vars, table); @@ -1348,8 +1452,9 @@ READ_INFO::READ_INFO(THD *thd, File file_par, uint tot_length, CHARSET_INFO *cs, String &field_term, String &line_start, String &line_term, String &enclosed_par, int escape, bool get_it_from_net, bool is_fifo) - :file(file_par), fixed_length(tot_length), escape_char(escape), - found_end_of_line(false), eof(false), + :file(file_par), fixed_length(tot_length), + m_field_term(field_term), m_line_term(line_term), m_line_start(line_start), + escape_char(escape), found_end_of_line(false), eof(false), error(false), line_cuted(false), found_null(false), read_charset(cs) { data.set_thread_specific(); @@ -1358,39 +1463,17 @@ READ_INFO::READ_INFO(THD *thd, File file_par, uint tot_length, CHARSET_INFO *cs, Otherwise, non-ascii terminators will be negative on some platforms, and positive on others (depending on the implementation of char). */ - field_term_ptr= - static_cast<const uchar*>(static_cast<const void*>(field_term.ptr())); - field_term_length= field_term.length(); - line_term_ptr= - static_cast<const uchar*>(static_cast<const void*>(line_term.ptr())); - line_term_length= line_term.length(); level= 0; /* for load xml */ - if (line_start.length() == 0) - { - line_start_ptr=0; - start_of_line= 0; - } - else - { - line_start_ptr= line_start.ptr(); - line_start_end=line_start_ptr+line_start.length(); - start_of_line= 1; - } + start_of_line= line_start.length() != 0; /* If field_terminator == line_terminator, don't use line_terminator */ - if (field_term_length == line_term_length && - !memcmp(field_term_ptr,line_term_ptr,field_term_length)) - { - line_term_length=0; - line_term_ptr= NULL; - } - enclosed_char= (enclosed_length=enclosed_par.length()) ? - (uchar) enclosed_par[0] : INT_MAX; - field_term_char= field_term_length ? field_term_ptr[0] : INT_MAX; - line_term_char= line_term_length ? line_term_ptr[0] : INT_MAX; + if (m_field_term.eq(m_line_term)) + m_line_term.reset(); + enclosed_char= enclosed_par.length() ? (uchar) enclosed_par[0] : INT_MAX; /* Set of a stack for unget if long terminators */ - uint length= MY_MAX(cs->mbmaxlen, MY_MAX(field_term_length, line_term_length)) + 1; + uint length= MY_MAX(cs->mbmaxlen, MY_MAX(m_field_term.length(), + m_line_term.length())) + 1; set_if_bigger(length,line_start.length()); stack= stack_pos= (int*) thd->alloc(sizeof(int) * length); @@ -1432,7 +1515,7 @@ READ_INFO::~READ_INFO() } -inline int READ_INFO::terminator(const uchar *ptr,uint length) +inline bool READ_INFO::terminator(const uchar *ptr, uint length) { int chr=0; // Keep gcc happy uint i; @@ -1444,11 +1527,11 @@ inline int READ_INFO::terminator(const uchar *ptr,uint length) } } if (i == length) - return 1; + return true; PUSH(chr); while (i-- > 1) PUSH(*--ptr); - return 0; + return false; } @@ -1516,12 +1599,12 @@ int READ_INFO::read_field() chr= escape_char; } #ifdef ALLOW_LINESEPARATOR_IN_STRINGS - if (chr == line_term_char) + if (chr == m_line_term.initial_byte()) #else - if (chr == line_term_char && found_enclosed_char == INT_MAX) + if (chr == m_line_term.initial_byte() && found_enclosed_char == INT_MAX) #endif { - if (terminator(line_term_ptr,line_term_length)) + if (terminator(m_line_term)) { // Maybe unexpected linefeed enclosed=0; found_end_of_line=1; @@ -1538,9 +1621,7 @@ int READ_INFO::read_field() continue; } // End of enclosed field if followed by field_term or line_term - if (chr == my_b_EOF || - (chr == line_term_char && terminator(line_term_ptr, - line_term_length))) + if (chr == my_b_EOF || terminator(chr, m_line_term)) { /* Maybe unexpected linefeed */ enclosed=1; @@ -1549,8 +1630,7 @@ int READ_INFO::read_field() row_end= (uchar *) data.end(); return 0; } - if (chr == field_term_char && - terminator(field_term_ptr,field_term_length)) + if (terminator(chr, m_field_term)) { enclosed=1; row_start= (uchar *) data.ptr() + 1; @@ -1565,9 +1645,10 @@ int READ_INFO::read_field() /* copy the found term character to 'to' */ chr= found_enclosed_char; } - else if (chr == field_term_char && found_enclosed_char == INT_MAX) + else if (chr == m_field_term.initial_byte() && + found_enclosed_char == INT_MAX) { - if (terminator(field_term_ptr,field_term_length)) + if (terminator(m_field_term)) { enclosed=0; row_start= (uchar *) data.ptr(); @@ -1575,38 +1656,9 @@ int READ_INFO::read_field() return 0; } } -#ifdef USE_MB - if (my_mbcharlen(read_charset, chr) > 1) - { - uint32 length0= data.length(); - int ml= my_mbcharlen(read_charset, chr); - data.append(chr); - - for (int i= 1; i < ml; i++) - { - chr= GET; - if (chr == my_b_EOF) - { - /* - Need to back up the bytes already ready from illformed - multi-byte char - */ - data.length(length0); - goto found_eof; - } - data.append(chr); - } - if (my_ismbchar(read_charset, - (const char *) data.ptr() + length0, - (const char *) data.end())) - continue; - for (int i= 0; i < ml; i++) - PUSH(data.end()[-1 - i]); - data.length(length0); - chr= GET; - } -#endif data.append(chr); + if (use_mb(read_charset) && read_mbtail(&data)) + goto found_eof; } /* ** We come here if buffer is too small. Enlarge it and continue @@ -1665,13 +1717,10 @@ int READ_INFO::read_fixed_length() data.append((uchar) unescape((char) chr)); continue; } - if (chr == line_term_char) - { - if (terminator(line_term_ptr,line_term_length)) - { // Maybe unexpected linefeed - found_end_of_line=1; - break; - } + if (terminator(chr, m_line_term)) + { // Maybe unexpected linefeed + found_end_of_line= true; + break; } data.append(chr); } @@ -1690,14 +1739,14 @@ found_eof: int READ_INFO::next_line() { line_cuted=0; - start_of_line= line_start_ptr != 0; + start_of_line= m_line_start.length() != 0; if (found_end_of_line || eof) { found_end_of_line=0; return eof; } found_end_of_line=0; - if (!line_term_length) + if (!m_line_term.length()) return 0; // No lines for (;;) { @@ -1725,10 +1774,11 @@ int READ_INFO::next_line() or a broken byte sequence was found. Check if the sequence is a prefix of the "LINES TERMINATED BY" string. */ - if ((uchar) buf[0] == line_term_char && i <= line_term_length && - !memcmp(buf, line_term_ptr, i)) + if ((uchar) buf[0] == m_line_term.initial_byte() && + i <= m_line_term.length() && + !memcmp(buf, m_line_term.ptr(), i)) { - if (line_term_length == i) + if (m_line_term.length() == i) { /* We found a "LINES TERMINATED BY" string that consists @@ -1742,10 +1792,11 @@ int READ_INFO::next_line() that still needs to be checked is (line_term_length - i). Note, READ_INFO::terminator() assumes that the leftmost byte of the argument is already scanned from the file and is checked to - be a known prefix (e.g. against line_term_char). + be a known prefix (e.g. against line_term.initial_char()). So we need to pass one extra byte. */ - if (terminator(line_term_ptr + i - 1, line_term_length - i + 1)) + if (terminator(m_line_term.ptr() + i - 1, + m_line_term.length() - i + 1)) return 0; } /* @@ -1768,7 +1819,7 @@ int READ_INFO::next_line() return 1; continue; } - if (buf[0] == line_term_char && terminator(line_term_ptr,line_term_length)) + if (terminator(buf[0], m_line_term)) return 0; line_cuted= true; } @@ -1777,30 +1828,12 @@ int READ_INFO::next_line() bool READ_INFO::find_start_of_fields() { - int chr; - try_again: - do - { - if ((chr=GET) == my_b_EOF) - { - found_end_of_line=eof=1; - return 1; - } - } while ((char) chr != line_start_ptr[0]); - for (const char *ptr=line_start_ptr+1 ; ptr != line_start_end ; ptr++) + for (int chr= GET ; chr != my_b_EOF ; chr= GET) { - chr=GET; // Eof will be checked later - if ((char) chr != *ptr) - { // Can't be line_start - PUSH(chr); - while (--ptr != line_start_ptr) - { // Restart with next char - PUSH( *ptr); - } - goto try_again; - } + if (terminator(chr, m_line_start)) + return false; } - return 0; + return (found_end_of_line= eof= true); } @@ -1881,26 +1914,8 @@ int READ_INFO::read_value(int delim, String *val) int chr; String tmp; - for (chr= GET; my_tospace(chr) != delim && chr != my_b_EOF;) + for (chr= GET; my_tospace(chr) != delim && chr != my_b_EOF; chr= GET) { -#ifdef USE_MB - if (my_mbcharlen(read_charset, chr) > 1) - { - DBUG_PRINT("read_xml",("multi byte")); - int i, ml= my_mbcharlen(read_charset, chr); - for (i= 1; i < ml; i++) - { - val->append(chr); - /* - Don't use my_tospace() in the middle of a multi-byte character - TODO: check that the multi-byte sequence is valid. - */ - chr= GET; - if (chr == my_b_EOF) - return chr; - } - } -#endif if(chr == '&') { tmp.length(0); @@ -1920,8 +1935,11 @@ int READ_INFO::read_value(int delim, String *val) } } else + { val->append(chr); - chr= GET; + if (use_mb(read_charset) && read_mbtail(val)) + return my_b_EOF; + } } return my_tospace(chr); } @@ -1990,11 +2008,11 @@ int READ_INFO::read_xml(THD *thd) } // row tag should be in ROWS IDENTIFIED BY '<row>' - stored in line_term - if((tag.length() == line_term_length -2) && - (memcmp(tag.ptr(), line_term_ptr + 1, tag.length()) == 0)) + if((tag.length() == m_line_term.length() - 2) && + (memcmp(tag.ptr(), m_line_term.ptr() + 1, tag.length()) == 0)) { DBUG_PRINT("read_xml", ("start-of-row: %i %s %s", - level,tag.c_ptr_safe(), line_term_ptr)); + level,tag.c_ptr_safe(), m_line_term.ptr())); } if(chr == ' ' || chr == '>') @@ -2061,8 +2079,8 @@ int READ_INFO::read_xml(THD *thd) chr= my_tospace(GET); } - if((tag.length() == line_term_length -2) && - (memcmp(tag.ptr(), line_term_ptr + 1, tag.length()) == 0)) + if((tag.length() == m_line_term.length() - 2) && + (memcmp(tag.ptr(), m_line_term.ptr() + 1, tag.length()) == 0)) { DBUG_PRINT("read_xml", ("found end-of-row %i %s", level, tag.c_ptr_safe())); diff --git a/sql/sql_locale.h b/sql/sql_locale.h index 8357a9ecba4..e231393eec6 100644 --- a/sql/sql_locale.h +++ b/sql/sql_locale.h @@ -19,7 +19,7 @@ typedef struct my_locale_errmsgs { const char *language; - const char **errmsgs; + const char ***errmsgs; } MY_LOCALE_ERRMSGS; #include "my_global.h" /* uint */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7c50e4ed680..a6bb89f05df 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1122,7 +1122,6 @@ static enum enum_server_command fetch_command(THD *thd, char *packet) { enum enum_server_command command= (enum enum_server_command) (uchar) packet[0]; - NET *net= &thd->net; DBUG_ENTER("fetch_command"); if (command >= COM_END || @@ -1130,7 +1129,7 @@ static enum enum_server_command fetch_command(THD *thd, char *packet) command= COM_END; // Wrong command DBUG_PRINT("info",("Command on %s = %d (%s)", - vio_description(net->vio), command, + vio_description(thd->net.vio), command, command_name[command].str)); DBUG_RETURN(command); } @@ -4521,7 +4520,7 @@ end_with_restore_list: lex->table_count); if (result) { - res= mysql_select(thd, &select_lex->ref_pointer_array, + res= mysql_select(thd, select_lex->get_table_list(), select_lex->with_wild, select_lex->item_list, @@ -5309,6 +5308,7 @@ end_with_restore_list: } case SQLCOM_SHUTDOWN: #ifndef EMBEDDED_LIBRARY + DBUG_EXECUTE_IF("crash_shutdown", DBUG_SUICIDE();); if (check_global_access(thd,SHUTDOWN_ACL)) goto error; kill_mysql(thd); @@ -7789,7 +7789,6 @@ add_proc_to_list(THD* thd, Item *item) item_ptr = (Item**) (order+1); *item_ptr= item; order->item=item_ptr; - order->free_me=0; thd->lex->proc_list.link_in_list(order, &order->next); return 0; } @@ -7807,8 +7806,7 @@ bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *item,bool asc) DBUG_RETURN(1); order->item_ptr= item; order->item= &order->item_ptr; - order->asc = asc; - order->free_me=0; + order->direction= (asc ? ORDER::ORDER_ASC : ORDER::ORDER_DESC); order->used=0; order->counter_used= 0; order->fast_field_copier_setup= 0; @@ -8225,6 +8223,65 @@ TABLE_LIST *st_select_lex::convert_right_join() DBUG_RETURN(tab1); } + +void st_select_lex::prepare_add_window_spec(THD *thd) +{ + LEX *lex= thd->lex; + lex->save_group_list= group_list; + lex->save_order_list= order_list; + lex->win_ref= NULL; + lex->win_frame= NULL; + lex->frame_top_bound= NULL; + lex->frame_bottom_bound= NULL; + group_list.empty(); + order_list.empty(); +} + +bool st_select_lex::add_window_def(THD *thd, + LEX_STRING *win_name, + LEX_STRING *win_ref, + SQL_I_List<ORDER> win_partition_list, + SQL_I_List<ORDER> win_order_list, + Window_frame *win_frame) +{ + SQL_I_List<ORDER> *win_part_list_ptr= + new (thd->mem_root) SQL_I_List<ORDER> (win_partition_list); + SQL_I_List<ORDER> *win_order_list_ptr= + new (thd->mem_root) SQL_I_List<ORDER> (win_order_list); + if (!(win_part_list_ptr && win_order_list_ptr)) + return true; + Window_def *win_def= new (thd->mem_root) Window_def(win_name, + win_ref, + win_part_list_ptr, + win_order_list_ptr, + win_frame); + group_list= thd->lex->save_group_list; + order_list= thd->lex->save_order_list; + return (win_def == NULL || window_specs.push_back(win_def)); +} + +bool st_select_lex::add_window_spec(THD *thd, + LEX_STRING *win_ref, + SQL_I_List<ORDER> win_partition_list, + SQL_I_List<ORDER> win_order_list, + Window_frame *win_frame) +{ + SQL_I_List<ORDER> *win_part_list_ptr= + new (thd->mem_root) SQL_I_List<ORDER> (win_partition_list); + SQL_I_List<ORDER> *win_order_list_ptr= + new (thd->mem_root) SQL_I_List<ORDER> (win_order_list); + if (!(win_part_list_ptr && win_order_list_ptr)) + return true; + Window_spec *win_spec= new (thd->mem_root) Window_spec(win_ref, + win_part_list_ptr, + win_order_list_ptr, + win_frame); + group_list= thd->lex->save_group_list; + order_list= thd->lex->save_order_list; + thd->lex->win_spec= win_spec; + return (win_spec == NULL || window_specs.push_back(win_spec)); +} + /** Set lock for all tables in current select level. diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index dbe19674cf2..f540c268923 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1544,22 +1544,26 @@ int plugin_init(int *argc, char **argv, int flags) init_alloc_root(&plugin_vars_mem_root, 4096, 4096, MYF(0)); init_alloc_root(&tmp_root, 4096, 4096, MYF(0)); - if (my_hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0, + if (my_hash_init(&bookmark_hash, &my_charset_bin, 32, 0, 0, get_bookmark_hash_key, NULL, HASH_UNIQUE)) goto err; mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST); + /* + The 80 is from 2016-04-27 when we had 71 default plugins + Big enough to avoid many mallocs even in future + */ if (my_init_dynamic_array(&plugin_dl_array, sizeof(struct st_plugin_dl *), 16, 16, MYF(0)) || my_init_dynamic_array(&plugin_array, - sizeof(struct st_plugin_int *), 16, 16, MYF(0))) + sizeof(struct st_plugin_int *), 80, 32, MYF(0))) goto err; for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) { - if (my_hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0, + if (my_hash_init(&plugin_hash[i], system_charset_info, 32, 0, 0, get_plugin_hash_key, NULL, HASH_UNIQUE)) goto err; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 8e5ab71288d..2d6a7302afc 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1316,7 +1316,7 @@ static bool mysql_test_insert(Prepared_statement *stmt, my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), counter); goto error; } - if (setup_fields(thd, 0, *values, MARK_COLUMNS_NONE, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), *values, MARK_COLUMNS_NONE, 0, 0)) goto error; } } @@ -1406,7 +1406,8 @@ static int mysql_test_update(Prepared_statement *stmt, table_list->register_want_access(want_privilege); #endif thd->lex->select_lex.no_wrap_view_item= TRUE; - res= setup_fields(thd, 0, select->item_list, MARK_COLUMNS_READ, 0, 0); + res= setup_fields(thd, Ref_ptr_array(), + select->item_list, MARK_COLUMNS_READ, 0, 0); thd->lex->select_lex.no_wrap_view_item= FALSE; if (res) goto error; @@ -1417,7 +1418,8 @@ static int mysql_test_update(Prepared_statement *stmt, (SELECT_ACL & ~table_list->table->grant.privilege); table_list->register_want_access(SELECT_ACL); #endif - if (setup_fields(thd, 0, stmt->lex->value_list, MARK_COLUMNS_NONE, 0, 0) || + if (setup_fields(thd, Ref_ptr_array(), + stmt->lex->value_list, MARK_COLUMNS_NONE, 0, 0) || check_unique_table(thd, table_list)) goto error; /* TODO: here we should send types of placeholders to the client. */ @@ -1463,7 +1465,7 @@ static bool mysql_test_delete(Prepared_statement *stmt, my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE"); goto error; } - if (!table_list->table || !table_list->table->created) + if (!table_list->table || !table_list->table->is_created()) { my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0), table_list->view_db.str, table_list->view_name.str); @@ -1589,7 +1591,8 @@ static bool mysql_test_do_fields(Prepared_statement *stmt, if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL, DT_PREPARE | DT_CREATE)) DBUG_RETURN(TRUE); - DBUG_RETURN(setup_fields(thd, 0, *values, MARK_COLUMNS_NONE, 0, 0)); + DBUG_RETURN(setup_fields(thd, Ref_ptr_array(), + *values, MARK_COLUMNS_NONE, 0, 0)); } diff --git a/sql/sql_priv.h b/sql/sql_priv.h index cc56daacf3e..b15a80a889a 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -344,6 +344,7 @@ enum enum_parsing_place IN_WHERE, IN_ON, IN_GROUP_BY, + IN_ORDER_BY, PARSING_PLACE_SIZE /* always should be the last */ }; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index c9e2b3a586d..36f0cd84cbf 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -182,6 +182,7 @@ struct binlog_send_info { { error_text[0] = 0; bzero(&error_gtid, sizeof(error_gtid)); + until_binlog_state.init(); } }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3134f8eb007..6c4d2e1fc9c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -54,6 +54,7 @@ #include "sql_derived.h" #include "sql_statistics.h" #include "sql_cte.h" +#include "sql_window.h" #include "debug_sync.h" // DEBUG_SYNC #include <m_ctype.h> @@ -117,7 +118,6 @@ static int join_tab_cmp_straight(const void *dummy, const void* ptr1, const void static int join_tab_cmp_embedded_first(const void *emb, const void* ptr1, const void *ptr2); C_MODE_END static uint cache_record_length(JOIN *join,uint index); -bool get_best_combination(JOIN *join); static store_key *get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables, KEY_PART_INFO *key_part, uchar *key_buff, @@ -164,8 +164,11 @@ static COND *optimize_cond(JOIN *join, COND *conds, COND_EQUAL **cond_equal, int flags= 0); bool const_expression_in_where(COND *conds,Item *item, Item **comp_item); -static int do_select(JOIN *join,List<Item> *fields,TABLE *tmp_table, - Procedure *proc); +static int do_select(JOIN *join, Procedure *procedure); +static bool instantiate_tmp_table(TABLE *table, KEY *keyinfo, + MARIA_COLUMNDEF *start_recinfo, + MARIA_COLUMNDEF **recinfo, + ulonglong options); static enum_nested_loop_state evaluate_join_record(JOIN *, JOIN_TAB *, int); static enum_nested_loop_state @@ -179,7 +182,6 @@ end_update(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); static enum_nested_loop_state end_unique_update(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); -static int test_if_group_changed(List<Cached_item> &list); static int join_read_const_table(THD *thd, JOIN_TAB *tab, POSITION *pos); static int join_read_system(JOIN_TAB *tab); static int join_read_const(JOIN_TAB *tab); @@ -232,11 +234,7 @@ static bool list_contains_unique_index(TABLE *table, bool (*find_func) (Field *, void *), void *data); static bool find_field_in_item_list (Field *field, void *data); static bool find_field_in_order_list (Field *field, void *data); -static int create_sort_index(THD *thd, JOIN *join, ORDER *order, - ha_rows filesort_limit, ha_rows select_limit, - bool is_order_by); -static int remove_duplicates(JOIN *join,TABLE *entry,List<Item> &fields, - Item *having); +int create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort); static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field, Item *having); static int remove_dup_with_hash_index(THD *thd,TABLE *table, @@ -245,7 +243,7 @@ static int remove_dup_with_hash_index(THD *thd,TABLE *table, static bool cmp_buffer_with_ref(THD *thd, TABLE *table, TABLE_REF *tab_ref); static bool setup_new_fields(THD *thd, List<Item> &fields, List<Item> &all_fields, ORDER *new_order); -static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array, +static ORDER *create_distinct_group(THD *thd, Ref_ptr_array ref_pointer_array, ORDER *order, List<Item> &fields, List<Item> &all_fields, bool *all_order_by_fields_used); @@ -256,12 +254,12 @@ static void calc_group_buffer(JOIN *join,ORDER *group); static bool make_group_fields(JOIN *main_join, JOIN *curr_join); static bool alloc_group_fields(JOIN *join,ORDER *group); // Create list for using with tempory table -static bool change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, +static bool change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &new_list1, List<Item> &new_list2, uint elements, List<Item> &items); // Create list for using with tempory table -static bool change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array, +static bool change_refs_to_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &new_list1, List<Item> &new_list2, uint elements, List<Item> &items); @@ -288,7 +286,7 @@ static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab, uint n_top_tabs_count, JOIN_TAB *tab); static double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, table_map rem_tables); - +void set_postjoin_aggr_write_func(JOIN_TAB *tab); #ifndef DBUG_OFF /* @@ -364,7 +362,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, every PS/SP execution new, we will not need reset this flag if setup_tables_done_option changed for next rexecution */ - res= mysql_select(thd, &select_lex->ref_pointer_array, + res= mysql_select(thd, select_lex->table_list.first, select_lex->with_wild, select_lex->item_list, select_lex->where, @@ -455,7 +453,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, - Item **ref_pointer_array) + Ref_ptr_array ref_pointer_array) { Item_outer_ref *ref; @@ -484,10 +482,9 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, 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 && !ref->found_in_select_list) + if (!ref_pointer_array.is_null() && !ref->found_in_select_list) { int el= all_fields.elements; - DBUG_ASSERT(all_fields.elements <= select->ref_pointer_array_size); ref_pointer_array[el]= item; /* Add the field item to the select list of the current select. */ all_fields.push_front(item, thd->mem_root); @@ -495,7 +492,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, If it's needed reset each Item_ref item that refers this field with a new reference taken from ref_pointer_array. */ - item_ref= ref_pointer_array + el; + item_ref= &ref_pointer_array[el]; } if (ref->in_sum_func) @@ -533,6 +530,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, if (!ref->fixed && ref->fix_fields(thd, 0)) return TRUE; thd->lex->used_tables|= item->used_tables(); + thd->lex->current_select->select_list_tables|= item->used_tables(); } return false; } @@ -615,22 +613,26 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex) /** Function to setup clauses without sum functions. */ -inline int setup_without_group(THD *thd, Item **ref_pointer_array, - TABLE_LIST *tables, - List<TABLE_LIST> &leaves, - List<Item> &fields, - List<Item> &all_fields, - COND **conds, - ORDER *order, - ORDER *group, - bool *hidden_group_fields, - uint *reserved) +static inline int +setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array, + TABLE_LIST *tables, + List<TABLE_LIST> &leaves, + List<Item> &fields, + List<Item> &all_fields, + COND **conds, + ORDER *order, + ORDER *group, + List<Window_spec> &win_specs, + List<Item_window_func> &win_funcs, + bool *hidden_group_fields, + uint *reserved) { int res; + enum_parsing_place save_place; st_select_lex *const select= thd->lex->current_select; nesting_map save_allow_sum_func= thd->lex->allow_sum_func; /* - Need to save the value, so we can turn off only any new non_agg_field_used + Need to stave the value, so we can turn off only any new non_agg_field_used additions coming from the WHERE */ const bool saved_non_agg_field_used= select->non_agg_field_used(); @@ -650,11 +652,21 @@ inline int setup_without_group(THD *thd, Item **ref_pointer_array, select->set_non_agg_field_used(saved_non_agg_field_used); thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level; + + save_place= thd->lex->current_select->parsing_place; + thd->lex->current_select->parsing_place= IN_ORDER_BY; res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields, order); - thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level); + thd->lex->current_select->parsing_place= save_place; + thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level); + save_place= thd->lex->current_select->parsing_place; + thd->lex->current_select->parsing_place= IN_GROUP_BY; res= res || setup_group(thd, ref_pointer_array, tables, fields, all_fields, group, hidden_group_fields); + thd->lex->current_select->parsing_place= save_place; + thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level; + res= res || setup_windows(thd, ref_pointer_array, tables, fields, all_fields, + win_specs, win_funcs); thd->lex->allow_sum_func= save_allow_sum_func; DBUG_RETURN(res); } @@ -678,8 +690,7 @@ inline int setup_without_group(THD *thd, Item **ref_pointer_array, 0 on success */ int -JOIN::prepare(Item ***rref_pointer_array, - TABLE_LIST *tables_init, +JOIN::prepare(TABLE_LIST *tables_init, uint wild_num, COND *conds_init, uint og_num, ORDER *order_init, bool skip_order_by, ORDER *group_init, Item *having_init, @@ -783,24 +794,33 @@ JOIN::prepare(Item ***rref_pointer_array, tbl->table->maybe_null= 1; } - if ((wild_num && setup_wild(thd, tables_list, fields_list, &all_fields, - wild_num)) || - select_lex->setup_ref_array(thd, og_num) || - setup_fields(thd, (*rref_pointer_array), fields_list, MARK_COLUMNS_READ, - &all_fields, 1) || - setup_without_group(thd, (*rref_pointer_array), tables_list, - select_lex->leaf_tables, fields_list, - all_fields, &conds, order, group_list, - &hidden_group_fields, &select_lex->select_n_reserved)) - DBUG_RETURN(-1); /* purecov: inspected */ + if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num)) + DBUG_RETURN(-1); + if (select_lex->setup_ref_array(thd, og_num)) + DBUG_RETURN(-1); - ref_pointer_array= *rref_pointer_array; + ref_ptrs= ref_ptr_array_slice(0); + + enum_parsing_place save_place= thd->lex->current_select->parsing_place; + thd->lex->current_select->parsing_place= SELECT_LIST; + if (setup_fields(thd, ref_ptrs, fields_list, MARK_COLUMNS_READ, + &all_fields, 1)) + DBUG_RETURN(-1); + thd->lex->current_select->parsing_place= save_place; + if (setup_without_group(thd, ref_ptrs, tables_list, + select_lex->leaf_tables, fields_list, + all_fields, &conds, order, group_list, + select_lex->window_specs, + select_lex->window_funcs, + &hidden_group_fields, + &select_lex->select_n_reserved)) + DBUG_RETURN(-1); /* Resolve the ORDER BY that was skipped, then remove it. */ if (skip_order_by && select_lex != select_lex->master_unit()->global_parameters()) { - if (setup_order(thd, (*rref_pointer_array), tables_list, fields_list, + if (setup_order(thd, ref_ptrs, tables_list, fields_list, all_fields, select_lex->order_list.first)) DBUG_RETURN(-1); select_lex->order_list.empty(); @@ -828,6 +848,12 @@ JOIN::prepare(Item ***rref_pointer_array, if (having_fix_rc || thd->is_error()) DBUG_RETURN(-1); /* purecov: inspected */ thd->lex->allow_sum_func= save_allow_sum_func; + + if (having->with_window_func) + { + my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0)); + DBUG_RETURN(-1); + } } With_clause *with_clause=select_lex->get_with_clause(); @@ -867,14 +893,14 @@ JOIN::prepare(Item ***rref_pointer_array, real_order= TRUE; if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) - item->split_sum_func(thd, ref_pointer_array, all_fields, 0); + item->split_sum_func(thd, ref_ptrs, all_fields, 0); } if (!real_order) order= NULL; } if (having && having->with_sum_func) - having->split_sum_func2(thd, ref_pointer_array, all_fields, + having->split_sum_func2(thd, ref_ptrs, all_fields, &having, SPLIT_SUM_SKIP_REGISTERED); if (select_lex->inner_sum_func_list) { @@ -883,13 +909,13 @@ JOIN::prepare(Item ***rref_pointer_array, do { item_sum= item_sum->next; - item_sum->split_sum_func2(thd, ref_pointer_array, + item_sum->split_sum_func2(thd, ref_ptrs, all_fields, item_sum->ref_by, 0); } while (item_sum != end); } if (select_lex->inner_refs_list.elements && - fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array)) + fix_inner_refs(thd, all_fields, select_lex, ref_ptrs)) DBUG_RETURN(-1); if (group_list) @@ -907,10 +933,9 @@ JOIN::prepare(Item ***rref_pointer_array, { Item_field *field= new (thd->mem_root) Item_field(thd, *(Item_field**)ord->item); int el= all_fields.elements; - DBUG_ASSERT(all_fields.elements <= select_lex->ref_pointer_array_size); - ref_pointer_array[el]= field; + ref_ptrs[el]= field; all_fields.push_front(field, thd->mem_root); - ord->item= ref_pointer_array + el; + ord->item= &ref_ptrs[el]; } } } @@ -963,6 +988,12 @@ JOIN::prepare(Item ***rref_pointer_array, } if (thd->lex->derived_tables) { + /* + Queries with derived tables and PROCEDURE are not allowed. + Many of such queries are disallowed grammatically, but there + are still some complex cases: + SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE() + */ my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", thd->lex->derived_tables & DERIVED_VIEW ? "view" : "subquery"); @@ -970,6 +1001,7 @@ JOIN::prepare(Item ***rref_pointer_array, } if (thd->lex->sql_command != SQLCOM_SELECT) { + // EXPLAIN SELECT * FROM t1 PROCEDURE ANALYSE() my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "non-SELECT"); goto err; } @@ -1006,11 +1038,14 @@ bool JOIN::prepare_stage2() /* Init join struct */ count_field_types(select_lex, &tmp_table_param, all_fields, 0); - ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; if (tmp_table_param.sum_func_count && !group_list) + { implicit_grouping= TRUE; + // Result will contain zero or one row - ordering is meaningless + order= NULL; + } #ifdef RESTRICTED_GROUP if (implicit_grouping) @@ -1056,6 +1091,24 @@ int JOIN::optimize() need_tmp, !skip_sort_order && !no_order && (order || group_list), select_distinct); + uint select_nr= select_lex->select_number; + JOIN_TAB *curr_tab= join_tab + top_join_tab_count; + for (uint i= 0; i < aggr_tables; i++, curr_tab++) + { + if (select_nr == INT_MAX) + { + /* this is a fake_select_lex of a union */ + select_nr= select_lex->master_unit()->first_select()->select_number; + curr_tab->tracker= thd->lex->explain->get_union(select_nr)-> + get_tmptable_read_tracker(); + } + else + { + curr_tab->tracker= thd->lex->explain->get_select(select_nr)-> + get_using_temporary_read_tracker(); + } + } + } return res; } @@ -1344,6 +1397,8 @@ JOIN::optimize_inner() { DBUG_PRINT("info",("No tables")); error= 0; + if (make_aggr_tables_info()) + DBUG_RETURN(1); goto setup_subq_exit; } error= -1; // Error is sent to client @@ -1355,7 +1410,6 @@ JOIN::optimize_inner() calling make_join_statistics() as this may call get_best_group_min_max() which needs a simplfied group_list. */ - simple_group= 1; if (group_list && table_count == 1) { group_list= remove_const(this, group_list, conds, @@ -1612,7 +1666,8 @@ JOIN::optimize_inner() (!join_tab[const_tables].select || !join_tab[const_tables].select->quick || join_tab[const_tables].select->quick->get_type() != - QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) + QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) && + !select_lex->have_window_funcs()) { if (group && rollup.state == ROLLUP::STATE_NONE && list_contains_unique_index(join_tab[const_tables].table, @@ -1662,11 +1717,13 @@ JOIN::optimize_inner() } if (group || tmp_table_param.sum_func_count) { - if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE) + if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE + && !select_lex->have_window_funcs()) select_distinct=0; } else if (select_distinct && table_count - const_tables == 1 && - rollup.state == ROLLUP::STATE_NONE) + rollup.state == ROLLUP::STATE_NONE && + !select_lex->have_window_funcs()) { /* We are only using one table. In this case we change DISTINCT to a @@ -1688,16 +1745,20 @@ JOIN::optimize_inner() tab= &join_tab[const_tables]; if (order) { - skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1, - &tab->table->keys_in_use_for_order_by); + skip_sort_order= + test_if_skip_sort_order(tab, order, select_limit, + true, // no_changes + &tab->table->keys_in_use_for_order_by); } if ((group_list=create_distinct_group(thd, select_lex->ref_pointer_array, order, fields_list, all_fields, &all_order_fields_used))) { - bool skip_group= (skip_sort_order && - test_if_skip_sort_order(tab, group_list, select_limit, 1, - &tab->table->keys_in_use_for_group_by) != 0); + const bool skip_group= + skip_sort_order && + test_if_skip_sort_order(tab, group_list, select_limit, + true, // no_changes + &tab->table->keys_in_use_for_group_by); count_field_types(select_lex, &tmp_table_param, all_fields, 0); if ((skip_group && all_order_fields_used) || select_limit == HA_POS_ERROR || @@ -1726,6 +1787,7 @@ JOIN::optimize_inner() else if (thd->is_fatal_error) // End of memory DBUG_RETURN(1); } + simple_group= rollup.state == ROLLUP::STATE_NONE; if (group) { /* @@ -1749,6 +1811,7 @@ JOIN::optimize_inner() group_optimized_away= 1; } } + calc_group_buffer(this, group_list); send_group_parts= tmp_table_param.group_parts; /* Save org parts */ if (procedure && procedure->group) @@ -1790,6 +1853,11 @@ JOIN::optimize_inner() } need_tmp= test_if_need_tmp_table(); + //TODO this could probably go in test_if_need_tmp_table. + if (this->select_lex->window_specs.elements > 0) { + need_tmp= TRUE; + simple_order= FALSE; + } /* If the hint FORCE INDEX FOR ORDER BY/GROUP BY is used for the table @@ -1813,6 +1881,31 @@ JOIN::optimize_inner() if (!(select_options & SELECT_DESCRIBE)) init_ftfuncs(thd, select_lex, MY_TEST(order)); + /* + It's necessary to check const part of HAVING cond as + there is a chance that some cond parts may become + const items after make_join_statisctics(for example + when Item is a reference to cost table field from + outer join). + This check is performed only for those conditions + which do not use aggregate functions. In such case + temporary table may not be used and const condition + elements may be lost during further having + condition transformation in JOIN::exec. + */ + if (having && const_table_map && !having->with_sum_func) + { + having->update_used_tables(); + having= having->remove_eq_conds(thd, &select_lex->having_value, true); + if (select_lex->having_value == Item::COND_FALSE) + { + having= new (thd->mem_root) Item_int(thd, (longlong) 0,1); + zero_result_cause= "Impossible HAVING noticed after reading const tables"; + error= 0; + DBUG_RETURN(0); + } + } + if (optimize_unflattened_subqueries()) DBUG_RETURN(1); @@ -1839,8 +1932,28 @@ JOIN::optimize_inner() DBUG_EXECUTE("info",TEST_join(this);); - if (const_tables != table_count) + if (!only_const_tables()) { + JOIN_TAB *tab= &join_tab[const_tables]; + + if (order) + { + /* + Force using of tmp table if sorting by a SP or UDF function due to + their expensive and probably non-deterministic nature. + */ + for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next) + { + Item *item= *tmp_order->item; + if (item->is_expensive()) + { + /* Force tmp table without sort */ + need_tmp=1; simple_order=simple_group=0; + break; + } + } + } + /* Because filesort always does a full table scan or a quick range scan we must add the removed reference to the select for the table. @@ -1848,72 +1961,197 @@ JOIN::optimize_inner() as in other cases the join is done before the sort. */ if ((order || group_list) && - join_tab[const_tables].type != JT_ALL && - join_tab[const_tables].type != JT_FT && - join_tab[const_tables].type != JT_REF_OR_NULL && + tab->type != JT_ALL && + tab->type != JT_FT && + tab->type != JT_REF_OR_NULL && ((order && simple_order) || (group_list && simple_group))) { - if (add_ref_to_table_cond(thd,&join_tab[const_tables])) { + if (add_ref_to_table_cond(thd,tab)) { DBUG_RETURN(1); } } /* - Calculate a possible 'limit' of table rows for 'GROUP BY': 'need_tmp' - implies that there will be more postprocessing so the specified - 'limit' should not be enforced yet in the call to - 'test_if_skip_sort_order'. + Investigate whether we may use an ordered index as part of either + DISTINCT, GROUP BY or ORDER BY execution. An ordered index may be + used for only the first of any of these terms to be executed. This + is reflected in the order which we check for test_if_skip_sort_order() + below. However we do not check for DISTINCT here, as it would have + been transformed to a GROUP BY at this stage if it is a candidate for + ordered index optimization. + If a decision was made to use an ordered index, the availability + of such an access path is stored in 'ordered_index_usage' for later + use by 'execute' or 'explain' */ - const ha_rows limit = need_tmp ? HA_POS_ERROR : unit->select_limit_cnt; + DBUG_ASSERT(ordered_index_usage == ordered_index_void); - if (!(select_options & SELECT_BIG_RESULT) && - ((group_list && - (!simple_group || - !test_if_skip_sort_order(&join_tab[const_tables], group_list, - limit, 0, - &join_tab[const_tables].table-> - keys_in_use_for_group_by))) || - select_distinct) && - tmp_table_param.quick_group && !procedure) + if (group_list) // GROUP BY honoured first + // (DISTINCT was rewritten to GROUP BY if skippable) { - need_tmp=1; simple_order=simple_group=0; // Force tmp table without sort - } - if (order) - { - /* - Do we need a temporary table due to the ORDER BY not being equal to - the GROUP BY? The call to test_if_skip_sort_order above tests for the - GROUP BY clause only and hence is not valid in this case. So the - estimated number of rows to be read from the first table is not valid. - We clear it here so that it doesn't show up in EXPLAIN. - */ - if (need_tmp && (select_options & SELECT_DESCRIBE) != 0) - join_tab[const_tables].limit= 0; /* - Force using of tmp table if sorting by a SP or UDF function due to - their expensive and probably non-deterministic nature. + When there is SQL_BIG_RESULT do not sort using index for GROUP BY, + and thus force sorting on disk unless a group min-max optimization + is going to be used as it is applied now only for one table queries + with covering indexes. */ - for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next) - { - Item *item= *tmp_order->item; - if (item->is_expensive()) + if (!(select_options & SELECT_BIG_RESULT) || + (tab->select && + tab->select->quick && + tab->select->quick->get_type() == + QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) + { + if (simple_group && // GROUP BY is possibly skippable + !select_distinct) // .. if not preceded by a DISTINCT { - /* Force tmp table without sort */ - need_tmp=1; simple_order=simple_group=0; - break; + /* + Calculate a possible 'limit' of table rows for 'GROUP BY': + A specified 'LIMIT' is relative to the final resultset. + 'need_tmp' implies that there will be more postprocessing + so the specified 'limit' should not be enforced yet. + */ + const ha_rows limit = need_tmp ? HA_POS_ERROR : select_limit; + if (test_if_skip_sort_order(tab, group_list, limit, false, + &tab->table->keys_in_use_for_group_by)) + { + ordered_index_usage= ordered_index_group_by; + } + } + + /* + If we are going to use semi-join LooseScan, it will depend + on the selected index scan to be used. If index is not used + for the GROUP BY, we risk that sorting is put on the LooseScan + table. In order to avoid this, force use of temporary table. + TODO: Explain the quick_group part of the test below. + */ + if ((ordered_index_usage != ordered_index_group_by) && + ((tmp_table_param.quick_group && !procedure) || + (tab->emb_sj_nest && + best_positions[const_tables].sj_strategy == SJ_OPT_LOOSE_SCAN))) + { + need_tmp=1; + simple_order= simple_group= false; // Force tmp table without sort } } } - } + else if (order && // ORDER BY wo/ preceeding GROUP BY + (simple_order || skip_sort_order)) // which is possibly skippable + { + if (test_if_skip_sort_order(tab, order, select_limit, false, + &tab->table->keys_in_use_for_order_by)) + { + ordered_index_usage= ordered_index_order_by; + } + } + } + + if (having) + having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT); + tmp_having= having; if ((select_lex->options & OPTION_SCHEMA_TABLE)) optimize_schema_tables_reads(this); /* + The loose index scan access method guarantees that all grouping or + duplicate row elimination (for distinct) is already performed + during data retrieval, and that all MIN/MAX functions are already + computed for each group. Thus all MIN/MAX functions should be + treated as regular functions, and there is no need to perform + grouping in the main execution loop. + Notice that currently loose index scan is applicable only for + single table queries, thus it is sufficient to test only the first + join_tab element of the plan for its access method. + */ + if (join_tab->is_using_loose_index_scan()) + { + tmp_table_param.precomputed_group_by= TRUE; + if (join_tab->is_using_agg_loose_index_scan()) + { + need_distinct= FALSE; + tmp_table_param.precomputed_group_by= FALSE; + } + } + + if (make_aggr_tables_info()) + DBUG_RETURN(1); + + error= 0; + + if (select_options & SELECT_DESCRIBE) + goto derived_exit; + + DBUG_RETURN(0); + +setup_subq_exit: + /* Choose an execution strategy for this JOIN. */ + if (!tables_list || !table_count) + choose_tableless_subquery_plan(); + /* + Even with zero matching rows, subqueries in the HAVING clause may + need to be evaluated if there are aggregate functions in the query. + */ + if (optimize_unflattened_subqueries()) + DBUG_RETURN(1); + error= 0; + +derived_exit: + + select_lex->mark_const_derived(zero_result_cause); + DBUG_RETURN(0); +} + + +/** + Set info for aggregation tables + + @details + This function finalizes execution plan by taking following actions: + .) aggregation temporary tables are created, but not instantiated + (this is done during execution). + JOIN_TABs for aggregation tables are set appropriately + (see JOIN::create_postjoin_aggr_table). + .) prepare fields lists (fields, all_fields, ref_pointer_array slices) for + each required stage of execution. These fields lists are set for + working tables' tabs and for the tab of last table in the join. + .) info for sorting/grouping/dups removal is prepared and saved in + appropriate tabs. Here is an example: + + @returns + false - Ok + true - Error +*/ + +bool JOIN::make_aggr_tables_info() +{ + List<Item> *curr_all_fields= &all_fields; + List<Item> *curr_fields_list= &fields_list; + JOIN_TAB *curr_tab= join_tab + const_tables; + TABLE *exec_tmp_table= NULL; + bool distinct= false; + bool keep_row_order= false; + DBUG_ENTER("JOIN::make_aggr_tables_info"); + + const bool has_group_by= this->group; + + sort_and_group_aggr_tab= NULL; + + + /* + Setup last table to provide fields and all_fields lists to the next + node in the plan. + */ + if (join_tab) + { + join_tab[top_join_tab_count - 1].fields= &fields_list; + join_tab[top_join_tab_count - 1].all_fields= &all_fields; + } + + /* All optimization is done. Check if we can use the storage engines group by handler to evaluate the group by */ - - if ((tmp_table_param.sum_func_count || group_list) && !procedure) + if (tables_list && (tmp_table_param.sum_func_count || group_list) && + !procedure) { /* At the moment we only support push down for queries where @@ -1933,24 +2171,39 @@ JOIN::optimize_inner() Query query= {&all_fields, select_distinct, tables_list, conds, group_list, order ? order : group_list, having}; group_by_handler *gbh= ht->create_group_by(thd, &query); + if (gbh) { pushdown_query= new (thd->mem_root) Pushdown_query(select_lex, gbh); - /* We must store rows in the tmp table if we need to do an ORDER BY or DISTINCT and the storage handler can't handle it. */ need_tmp= query.order_by || query.group_by || query.distinct; - tmp_table_param.hidden_field_count= (all_fields.elements - - fields_list.elements); - if (!(exec_tmp_table1= - create_tmp_table(thd, &tmp_table_param, all_fields, 0, - query.distinct, 1, - select_options, HA_POS_ERROR, "", - !need_tmp, query.order_by || query.group_by))) + distinct= query.distinct; + keep_row_order= query.order_by || query.group_by; + + order= query.order_by; + + aggr_tables++; + curr_tab= join_tab + top_join_tab_count; + bzero(curr_tab, sizeof(JOIN_TAB)); + curr_tab->ref.key= -1; + curr_tab->join= this; + + curr_tab->tmp_table_param= new TMP_TABLE_PARAM(tmp_table_param); + TABLE* table= create_tmp_table(thd, curr_tab->tmp_table_param, + all_fields, + NULL, query.distinct, + TRUE, select_options, HA_POS_ERROR, + "", !need_tmp, + query.order_by || query.group_by); + if (!table) DBUG_RETURN(1); + curr_tab->aggr= new (thd->mem_root) AGGR_OP(curr_tab); + curr_tab->aggr->set_write_func(::end_send); + curr_tab->table= table; /* Setup reference fields, used by summary functions and group by fields, to point to the temporary table. @@ -1959,17 +2212,18 @@ JOIN::optimize_inner() set_items_ref_array(items1). */ init_items_ref_array(); - items1= items0 + all_fields.elements; + items1= ref_ptr_array_slice(2); + //items1= items0 + all_fields.elements; if (change_to_use_tmp_fields(thd, items1, tmp_fields_list1, tmp_all_fields1, fields_list.elements, all_fields)) DBUG_RETURN(1); /* Give storage engine access to temporary table */ - gbh->table= exec_tmp_table1; - + gbh->table= table; pushdown_query->store_data_in_temp_table= need_tmp; pushdown_query->having= having; + /* Group by and having is calculated by the group_by handler. Reset the group by and having @@ -1986,21 +2240,19 @@ JOIN::optimize_inner() tmp_table_param.field_count+= tmp_table_param.sum_func_count; tmp_table_param.sum_func_count= 0; - /* Remember information about the original join */ - original_join_tab= join_tab; - original_table_count= table_count; + fields= curr_fields_list; - /* Set up one join tab to get sorting to work */ - const_tables= 0; - table_count= 1; - join_tab= (JOIN_TAB*) thd->calloc(sizeof(JOIN_TAB)); - join_tab[0].table= exec_tmp_table1; + //todo: new: + curr_tab->ref_array= &items1; + curr_tab->all_fields= &tmp_all_fields1; + curr_tab->fields= &tmp_fields_list1; DBUG_RETURN(thd->is_fatal_error); } } } + /* The loose index scan access method guarantees that all grouping or duplicate row elimination (for distinct) is already performed @@ -2012,194 +2264,584 @@ JOIN::optimize_inner() single table queries, thus it is sufficient to test only the first join_tab element of the plan for its access method. */ - if (join_tab->is_using_loose_index_scan()) + if (join_tab && join_tab->is_using_loose_index_scan()) + tmp_table_param.precomputed_group_by= + !join_tab->is_using_agg_loose_index_scan(); + + group_list_for_estimates= group_list; + /* Create a tmp table if distinct or if the sort is too complicated */ + if (need_tmp) { - tmp_table_param.precomputed_group_by= TRUE; - if (join_tab->is_using_agg_loose_index_scan()) + aggr_tables++; + curr_tab= join_tab + top_join_tab_count; + bzero(curr_tab, sizeof(JOIN_TAB)); + curr_tab->ref.key= -1; + if (only_const_tables()) + first_select= sub_select_postjoin_aggr; + + /* + Create temporary table on first execution of this join. + (Will be reused if this is a subquery that is executed several times.) + */ + init_items_ref_array(); + + ORDER *tmp_group= (ORDER *) 0; + if (!simple_group && !procedure && !(test_flags & TEST_NO_KEY_GROUP)) + tmp_group= group_list; + + tmp_table_param.hidden_field_count= + all_fields.elements - fields_list.elements; + + distinct= select_distinct && !group_list && + !select_lex->have_window_funcs(); + keep_row_order= false; + if (create_postjoin_aggr_table(curr_tab, + &all_fields, tmp_group, + group_list && simple_group, + distinct, keep_row_order)) + DBUG_RETURN(true); + exec_tmp_table= curr_tab->table; + + if (exec_tmp_table->distinct) + optimize_distinct(); + + /* + We don't have to store rows in temp table that doesn't match HAVING if: + - we are sorting the table and writing complete group rows to the + temp table. + - We are using DISTINCT without resolving the distinct as a GROUP BY + on all columns. + + If having is not handled here, it will be checked before the row + is sent to the client. + */ + if (having && + (sort_and_group || (exec_tmp_table->distinct && !group_list))) { - need_distinct= FALSE; - tmp_table_param.precomputed_group_by= FALSE; + // Attach HAVING to tmp table's condition + curr_tab->having= having; + having= NULL; // Already done } - } - error= 0; + /* Change sum_fields reference to calculated fields in tmp_table */ + items1= ref_ptr_array_slice(2); + if (sort_and_group || curr_tab->table->group || + tmp_table_param.precomputed_group_by) + { + if (change_to_use_tmp_fields(thd, items1, + tmp_fields_list1, tmp_all_fields1, + fields_list.elements, all_fields)) + DBUG_RETURN(true); + } + else + { + if (change_refs_to_tmp_fields(thd, items1, + tmp_fields_list1, tmp_all_fields1, + fields_list.elements, all_fields)) + DBUG_RETURN(true); + } + curr_all_fields= &tmp_all_fields1; + curr_fields_list= &tmp_fields_list1; + // Need to set them now for correct group_fields setup, reset at the end. + set_items_ref_array(items1); + curr_tab->ref_array= &items1; + curr_tab->all_fields= &tmp_all_fields1; + curr_tab->fields= &tmp_fields_list1; + set_postjoin_aggr_write_func(curr_tab); - tmp_having= having; - if (select_options & SELECT_DESCRIBE) - goto derived_exit; - having= 0; + tmp_table_param.func_count= 0; + tmp_table_param.field_count+= tmp_table_param.func_count; + if (sort_and_group || curr_tab->table->group) + { + tmp_table_param.field_count+= tmp_table_param.sum_func_count; + tmp_table_param.sum_func_count= 0; + } - DBUG_RETURN(0); + if (exec_tmp_table->group) + { // Already grouped + if (!order && !no_order && !skip_sort_order) + order= group_list; /* order by group */ + group_list= NULL; + } -setup_subq_exit: - /* Choose an execution strategy for this JOIN. */ - if (!tables_list || !table_count) - choose_tableless_subquery_plan(); - /* - Even with zero matching rows, subqueries in the HAVING clause may - need to be evaluated if there are aggregate functions in the query. - */ - if (optimize_unflattened_subqueries()) - DBUG_RETURN(1); - error= 0; + /* + If we have different sort & group then we must sort the data by group + and copy it to another tmp table + This code is also used if we are using distinct something + we haven't been able to store in the temporary table yet + like SEC_TO_TIME(SUM(...)). + */ + if ((group_list && + (!test_if_subpart(group_list, order) || select_distinct)) || + (select_distinct && tmp_table_param.using_outer_summary_function)) + { /* Must copy to another table */ + DBUG_PRINT("info",("Creating group table")); + + calc_group_buffer(this, group_list); + count_field_types(select_lex, &tmp_table_param, tmp_all_fields1, + select_distinct && !group_list); + tmp_table_param.hidden_field_count= + tmp_all_fields1.elements - tmp_fields_list1.elements; + + curr_tab++; + aggr_tables++; + bzero(curr_tab, sizeof(JOIN_TAB)); + curr_tab->ref.key= -1; -derived_exit: + /* group data to new table */ + /* + If the access method is loose index scan then all MIN/MAX + functions are precomputed, and should be treated as regular + functions. See extended comment above. + */ + if (join_tab->is_using_loose_index_scan()) + tmp_table_param.precomputed_group_by= TRUE; - select_lex->mark_const_derived(zero_result_cause); - DBUG_RETURN(0); -} + tmp_table_param.hidden_field_count= + curr_all_fields->elements - curr_fields_list->elements; + ORDER *dummy= NULL; //TODO can use table->group here also + if (create_postjoin_aggr_table(curr_tab, + curr_all_fields, dummy, true, + distinct, keep_row_order)) + DBUG_RETURN(true); -/** - Create and initialize objects neeed for the execution of a query plan. - Evaluate constant expressions not evaluated during optimization. -*/ + if (group_list) + { + if (!only_const_tables()) // No need to sort a single row + { + if (add_sorting_to_table(curr_tab - 1, group_list)) + DBUG_RETURN(true); + } -int JOIN::init_execution() -{ - DBUG_ENTER("JOIN::init_execution"); + if (make_group_fields(this, this)) + DBUG_RETURN(true); + } - DBUG_ASSERT(optimized); - DBUG_ASSERT(!(select_options & SELECT_DESCRIBE)); - initialized= true; + // Setup sum funcs only when necessary, otherwise we might break info + // for the first table + if (group_list || tmp_table_param.sum_func_count) + { + if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true, true)) + DBUG_RETURN(true); + if (prepare_sum_aggregators(sum_funcs, + !join_tab->is_using_agg_loose_index_scan())) + DBUG_RETURN(true); + group_list= NULL; + if (setup_sum_funcs(thd, sum_funcs)) + DBUG_RETURN(true); + } + // No sum funcs anymore + DBUG_ASSERT(items2.is_null()); - /* - Enable LIMIT ROWS EXAMINED during query execution if: - (1) This JOIN is the outermost query (not a subquery or derived table) - This ensures that the limit is enabled when actual execution begins, - and not if a subquery is evaluated during optimization of the outer - query. - (2) This JOIN is not the result of a UNION. In this case do not apply the - limit in order to produce the partial query result stored in the - UNION temp table. - */ - if (!select_lex->outer_select() && // (1) - select_lex != select_lex->master_unit()->fake_select_lex) // (2) - thd->lex->set_limit_rows_examined(); + items2= ref_ptr_array_slice(3); + if (change_to_use_tmp_fields(thd, items2, + tmp_fields_list2, tmp_all_fields2, + fields_list.elements, tmp_all_fields1)) + DBUG_RETURN(true); - /* Create a tmp table if distinct or if the sort is too complicated */ - if (need_tmp && !exec_tmp_table1) - { - DBUG_PRINT("info",("Creating tmp table")); - THD_STAGE_INFO(thd, stage_creating_tmp_table); + curr_fields_list= &tmp_fields_list2; + curr_all_fields= &tmp_all_fields2; + set_items_ref_array(items2); + curr_tab->ref_array= &items2; + curr_tab->all_fields= &tmp_all_fields2; + curr_tab->fields= &tmp_fields_list2; + set_postjoin_aggr_write_func(curr_tab); - init_items_ref_array(); + tmp_table_param.field_count+= tmp_table_param.sum_func_count; + tmp_table_param.sum_func_count= 0; + } + if (curr_tab->table->distinct) + select_distinct= false; /* Each row is unique */ - tmp_table_param.hidden_field_count= (all_fields.elements - - fields_list.elements); - ORDER *tmp_group= ((!simple_group && !procedure && - !(test_flags & TEST_NO_KEY_GROUP)) ? group_list : - (ORDER*) 0); - /* - Pushing LIMIT to the temporary table creation is not applicable - when there is ORDER BY or GROUP BY or there is no GROUP BY, but - there are aggregate functions, because in all these cases we need - all result rows. - */ - ha_rows tmp_rows_limit= ((order == 0 || skip_sort_order) && - !tmp_group && - !thd->lex->current_select->with_sum_func) ? - select_limit : HA_POS_ERROR; - - if (!(exec_tmp_table1= - create_tmp_table(thd, &tmp_table_param, all_fields, - tmp_group, group_list ? 0 : select_distinct, - group_list && simple_group, - select_options, tmp_rows_limit, ""))) - DBUG_RETURN(1); - explain->ops_tracker.report_tmp_table(exec_tmp_table1); - /* - We don't have to store rows in temp table that doesn't match HAVING if: - - we are sorting the table and writing complete group rows to the - temp table. - - We are using DISTINCT without resolving the distinct as a GROUP BY - on all columns. - - If having is not handled here, it will be checked before the row - is sent to the client. - */ - if (tmp_having && - (sort_and_group || (exec_tmp_table1->distinct && !group_list))) - having= tmp_having; - - /* if group or order on first table, sort first */ - if (group_list && simple_group) - { - DBUG_PRINT("info",("Sorting for group")); - THD_STAGE_INFO(thd, stage_sorting_for_group); - if (create_sort_index(thd, this, group_list, - HA_POS_ERROR, HA_POS_ERROR, FALSE) || - alloc_group_fields(this, group_list) || - make_sum_func_list(all_fields, fields_list, 1) || - prepare_sum_aggregators(sum_funcs, need_distinct) || - setup_sum_funcs(thd, sum_funcs)) + if (select_distinct && !group_list) + { + if (having) { - DBUG_RETURN(1); + curr_tab->having= having; + having->update_used_tables(); } - group_list=0; + curr_tab->distinct= true; + having= NULL; + select_distinct= false; + } + /* Clean tmp_table_param for the next tmp table. */ + tmp_table_param.field_count= tmp_table_param.sum_func_count= + tmp_table_param.func_count= 0; + + tmp_table_param.copy_field= tmp_table_param.copy_field_end=0; + first_record= sort_and_group=0; + + if (!group_optimized_away) + { + group= false; } else { - if (make_sum_func_list(all_fields, fields_list, 0) || - prepare_sum_aggregators(sum_funcs, need_distinct) || - setup_sum_funcs(thd, sum_funcs)) + /* + If grouping has been optimized away, a temporary table is + normally not needed unless we're explicitly requested to create + one (e.g. due to a SQL_BUFFER_RESULT hint or INSERT ... SELECT). + + In this case (grouping was optimized away), temp_table was + created without a grouping expression and JOIN::exec() will not + perform the necessary grouping (by the use of end_send_group() + or end_write_group()) if JOIN::group is set to false. + */ + // the temporary table was explicitly requested + DBUG_ASSERT(MY_TEST(select_options & OPTION_BUFFER_RESULT)); + // the temporary table does not have a grouping expression + DBUG_ASSERT(!curr_tab->table->group); + } + calc_group_buffer(this, group_list); + count_field_types(select_lex, &tmp_table_param, *curr_all_fields, false); + } + + if (group || implicit_grouping || tmp_table_param.sum_func_count) + { + if (make_group_fields(this, this)) + DBUG_RETURN(true); + + DBUG_ASSERT(items3.is_null()); + + if (items0.is_null()) + init_items_ref_array(); + items3= ref_ptr_array_slice(4); + setup_copy_fields(thd, &tmp_table_param, + items3, tmp_fields_list3, tmp_all_fields3, + curr_fields_list->elements, *curr_all_fields); + + curr_fields_list= &tmp_fields_list3; + curr_all_fields= &tmp_all_fields3; + set_items_ref_array(items3); + if (join_tab) + { + JOIN_TAB *last_tab= join_tab + top_join_tab_count + aggr_tables - 1; + // Set grouped fields on the last table + last_tab->ref_array= &items3; + last_tab->all_fields= &tmp_all_fields3; + last_tab->fields= &tmp_fields_list3; + } + if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true, true)) + DBUG_RETURN(true); + if (prepare_sum_aggregators(sum_funcs, + !join_tab || + !join_tab-> is_using_agg_loose_index_scan())) + DBUG_RETURN(true); + if (setup_sum_funcs(thd, sum_funcs) || thd->is_fatal_error) + DBUG_RETURN(true); + } + if (group_list || order) + { + DBUG_PRINT("info",("Sorting for send_result_set_metadata")); + THD_STAGE_INFO(thd, stage_sorting_result); + /* If we have already done the group, add HAVING to sorted table */ + if (tmp_having && !group_list && !sort_and_group) + { + // Some tables may have been const + tmp_having->update_used_tables(); + table_map used_tables= (const_table_map | curr_tab->table->map); + + Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables, + (table_map) 0, false, + false, false); + if (sort_table_cond) { - DBUG_RETURN(1); + if (!curr_tab->select) + if (!(curr_tab->select= new SQL_SELECT)) + DBUG_RETURN(true); + if (!curr_tab->select->cond) + curr_tab->select->cond= sort_table_cond; + else + { + if (!(curr_tab->select->cond= + new (thd->mem_root) Item_cond_and(thd, curr_tab->select->cond, + sort_table_cond))) + DBUG_RETURN(true); + } + if (curr_tab->pre_idx_push_select_cond) + { + if (sort_table_cond->type() == Item::COND_ITEM) + sort_table_cond= sort_table_cond->copy_andor_structure(thd); + if (!(curr_tab->pre_idx_push_select_cond= + new (thd->mem_root) Item_cond_and(thd, + curr_tab->pre_idx_push_select_cond, + sort_table_cond))) + DBUG_RETURN(true); + } + if (curr_tab->select->cond && !curr_tab->select->cond->fixed) + curr_tab->select->cond->fix_fields(thd, 0); + if (curr_tab->pre_idx_push_select_cond && + !curr_tab->pre_idx_push_select_cond->fixed) + curr_tab->pre_idx_push_select_cond->fix_fields(thd, 0); + curr_tab->select->pre_idx_push_select_cond= + curr_tab->pre_idx_push_select_cond; + curr_tab->set_select_cond(curr_tab->select->cond, __LINE__); + curr_tab->select_cond->top_level_item(); + DBUG_EXECUTE("where",print_where(curr_tab->select->cond, + "select and having", + QT_ORDINARY);); + + having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0, + ~used_tables, false, false, false); + DBUG_EXECUTE("where", + print_where(having, "having after sort", QT_ORDINARY);); } + } - if (!group_list && ! exec_tmp_table1->distinct && order && simple_order) + if (group) + select_limit= HA_POS_ERROR; + else if (!need_tmp) + { + /* + We can abort sorting after thd->select_limit rows if there are no + filter conditions for any tables after the sorted one. + Filter conditions come in several forms: + 1. as a condition item attached to the join_tab, or + 2. as a keyuse attached to the join_tab (ref access). + */ + for (uint i= const_tables + 1; i < top_join_tab_count; i++) { - DBUG_PRINT("info",("Sorting for order")); - THD_STAGE_INFO(thd, stage_sorting_for_order); - if (create_sort_index(thd, this, order, - HA_POS_ERROR, HA_POS_ERROR, TRUE)) + JOIN_TAB *const tab= join_tab + i; + if (tab->select_cond || // 1 + (tab->keyuse && !tab->first_inner)) // 2 { - DBUG_RETURN(1); + /* We have to sort all rows */ + select_limit= HA_POS_ERROR; + break; } - order=0; } } - /* - Optimize distinct when used on some of the tables - SELECT DISTINCT t1.a FROM t1,t2 WHERE t1.b=t2.b - In this case we can stop scanning t2 when we have found one t1.a + Here we add sorting stage for ORDER BY/GROUP BY clause, if the + optimiser chose FILESORT to be faster than INDEX SCAN or there is + no suitable index present. + OPTION_FOUND_ROWS supersedes LIMIT and is taken into account. */ + DBUG_PRINT("info",("Sorting for order by/group by")); + ORDER *order_arg= group_list ? group_list : order; + if (join_tab && + ordered_index_usage != + (group_list ? ordered_index_group_by : ordered_index_order_by) && + curr_tab->type != JT_CONST && + curr_tab->type != JT_EQ_REF) // Don't sort 1 row + { + // Sort either first non-const table or the last tmp table + JOIN_TAB *sort_tab= curr_tab; + + if (add_sorting_to_table(sort_tab, order_arg)) + DBUG_RETURN(true); + /* + filesort_limit: Return only this many rows from filesort(). + We can use select_limit_cnt only if we have no group_by and 1 table. + This allows us to use Bounded_queue for queries like: + "select SQL_CALC_FOUND_ROWS * from t1 order by b desc limit 1;" + m_select_limit == HA_POS_ERROR (we need a full table scan) + unit->select_limit_cnt == 1 (we only need one row in the result set) + */ + sort_tab->filesort->limit= + (has_group_by || (join_tab + table_count > curr_tab + 1)) ? + select_limit : unit->select_limit_cnt; + } + if (!only_const_tables() && + !join_tab[const_tables].filesort && + !(select_options & SELECT_DESCRIBE)) + { + /* + If no IO cache exists for the first table then we are using an + INDEX SCAN and no filesort. Thus we should not remove the sorted + attribute on the INDEX SCAN. + */ + skip_sort_order= true; + } + } + + /* + Window functions computation step should be attached to the last join_tab + that's doing aggregation. + The last join_tab reads the data from the temp. table. It also may do + - sorting + - duplicate value removal + Both of these operations are done after window function computation step. + */ + curr_tab= join_tab + top_join_tab_count + aggr_tables - 1; + if (select_lex->window_funcs.elements) + { + curr_tab->window_funcs_step= new Window_funcs_computation; + if (curr_tab->window_funcs_step->setup(thd, &select_lex->window_funcs, + curr_tab)) + DBUG_RETURN(true); + } + + fields= curr_fields_list; + // Reset before execution + set_items_ref_array(items0); + if (join_tab) + join_tab[top_join_tab_count + aggr_tables - 1].next_select= + setup_end_select_func(this, NULL); + group= has_group_by; + + DBUG_RETURN(false); +} + - if (exec_tmp_table1->distinct) + +bool +JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields, + ORDER *table_group, + bool save_sum_fields, + bool distinct, + bool keep_row_order) +{ + DBUG_ENTER("JOIN::create_postjoin_aggr_table"); + THD_STAGE_INFO(thd, stage_creating_tmp_table); + + /* + Pushing LIMIT to the post-join temporary table creation is not applicable + when there is ORDER BY or GROUP BY or there is no GROUP BY, but + there are aggregate functions, because in all these cases we need + all result rows. + */ + ha_rows table_rows_limit= ((order == NULL || skip_sort_order) && + !table_group && + !select_lex->with_sum_func) ? + select_limit : HA_POS_ERROR; + + tab->tmp_table_param= new TMP_TABLE_PARAM(tmp_table_param); + tab->tmp_table_param->skip_create_table= true; + TABLE* table= create_tmp_table(thd, tab->tmp_table_param, *table_fields, + table_group, distinct, + save_sum_fields, select_options, table_rows_limit, + "", true, keep_row_order); + if (!table) + DBUG_RETURN(true); + tmp_table_param.using_outer_summary_function= + tab->tmp_table_param->using_outer_summary_function; + tab->join= this; + DBUG_ASSERT(tab > tab->join->join_tab); + (tab - 1)->next_select= sub_select_postjoin_aggr; + tab->aggr= new (thd->mem_root) AGGR_OP(tab); + if (!tab->aggr) + goto err; + tab->table= table; + table->reginfo.join_tab= tab; + + /* if group or order on first table, sort first */ + if (group_list && simple_group) + { + DBUG_PRINT("info",("Sorting for group")); + THD_STAGE_INFO(thd, stage_sorting_for_group); + + if (ordered_index_usage != ordered_index_group_by && + (join_tab + const_tables)->type != JT_CONST && // Don't sort 1 row + add_sorting_to_table(join_tab + const_tables, group_list)) + goto err; + + if (alloc_group_fields(this, group_list)) + goto err; + if (make_sum_func_list(all_fields, fields_list, true)) + goto err; + if (prepare_sum_aggregators(sum_funcs, + !join_tab->is_using_agg_loose_index_scan())) + goto err; + if (setup_sum_funcs(thd, sum_funcs)) + goto err; + group_list= NULL; + } + else + { + if (make_sum_func_list(all_fields, fields_list, false)) + goto err; + if (prepare_sum_aggregators(sum_funcs, + !join_tab->is_using_agg_loose_index_scan())) + goto err; + if (setup_sum_funcs(thd, sum_funcs)) + goto err; + + if (!group_list && !table->distinct && order && simple_order) { - table_map used_tables= select_list_used_tables; - JOIN_TAB *last_join_tab= join_tab + top_join_tab_count - 1; - do - { - if (used_tables & last_join_tab->table->map || - last_join_tab->use_join_cache) - break; - last_join_tab->shortcut_for_distinct= true; - } while (last_join_tab-- != join_tab); - /* Optimize "select distinct b from t1 order by key_part_1 limit #" */ - if (order && skip_sort_order) - { - /* Should always succeed */ - if (test_if_skip_sort_order(&join_tab[const_tables], - order, unit->select_limit_cnt, 0, - &join_tab[const_tables].table-> - keys_in_use_for_order_by)) - order=0; - join_tab[const_tables].update_explain_data(const_tables); - } + DBUG_PRINT("info",("Sorting for order")); + THD_STAGE_INFO(thd, stage_sorting_for_order); + + if (ordered_index_usage != ordered_index_order_by && + add_sorting_to_table(join_tab + const_tables, order)) + goto err; + order= NULL; } + } - /* If this join belongs to an uncacheable query save the original join */ - if (select_lex->uncacheable && init_save_join_tab()) - DBUG_RETURN(-1); /* purecov: inspected */ + DBUG_RETURN(false); + +err: + if (table != NULL) + free_tmp_table(thd, table); + DBUG_RETURN(true); +} + + +void +JOIN::optimize_distinct() +{ + for (JOIN_TAB *last_join_tab= join_tab + top_join_tab_count - 1; ;) + { + if (select_lex->select_list_tables & last_join_tab->table->map || + last_join_tab->use_join_cache) + break; + last_join_tab->shortcut_for_distinct= true; + if (last_join_tab == join_tab) + break; + --last_join_tab; } - DBUG_RETURN(0); + /* Optimize "select distinct b from t1 order by key_part_1 limit #" */ + if (order && skip_sort_order) + { + /* Should already have been optimized away */ + DBUG_ASSERT(ordered_index_usage == ordered_index_order_by); + if (ordered_index_usage == ordered_index_order_by) + { + order= NULL; + } + } } /** + @brief Add Filesort object to the given table to sort if with filesort + + @param tab the JOIN_TAB object to attach created Filesort object to + @param order List of expressions to sort the table by + + @note This function moves tab->select, if any, to filesort->select + + @return false on success, true on OOM +*/ + +bool +JOIN::add_sorting_to_table(JOIN_TAB *tab, ORDER *order) +{ + tab->filesort= + new (thd->mem_root) Filesort(order, HA_POS_ERROR, tab->keep_current_rowid, + tab->select); + if (!tab->filesort) + return true; + /* + Select was moved to filesort->select to force join_init_read_record to use + sorted result instead of reading table through select. + */ + if (tab->select) + { + tab->select= NULL; + tab->set_select_cond(NULL, __LINE__); + } + tab->read_first_record= join_init_read_record; + return false; +} + + + + +/** Setup expression caches for subqueries that need them @details @@ -2291,17 +2933,6 @@ bool JOIN::setup_subquery_caches() } -/** - Restore values in temporary join. -*/ -void JOIN::restore_tmp() -{ - DBUG_PRINT("info", ("restore_tmp this %p tmp_join %p", this, tmp_join)); - DBUG_ASSERT(tmp_join != this); - memcpy(tmp_join, this, (size_t) sizeof(JOIN)); -} - - /* Shrink join buffers used for preceding tables to reduce the occupied space @@ -2366,25 +2997,29 @@ JOIN::reinit() unit->offset_limit_cnt= (ha_rows)(select_lex->offset_limit ? select_lex->offset_limit->val_uint() : 0); - first_record= 0; + first_record= false; + group_sent= false; cleaned= false; - if (exec_tmp_table1) - { - exec_tmp_table1->file->extra(HA_EXTRA_RESET_STATE); - exec_tmp_table1->file->ha_delete_all_rows(); - } - if (exec_tmp_table2) + if (aggr_tables) { - exec_tmp_table2->file->extra(HA_EXTRA_RESET_STATE); - exec_tmp_table2->file->ha_delete_all_rows(); + JOIN_TAB *curr_tab= join_tab + top_join_tab_count; + JOIN_TAB *end_tab= curr_tab + aggr_tables; + for ( ; curr_tab < end_tab; curr_tab++) + { + TABLE *tmp_table= curr_tab->table; + if (!tmp_table->is_created()) + continue; + tmp_table->file->extra(HA_EXTRA_RESET_STATE); + tmp_table->file->ha_delete_all_rows(); + } } clear_sj_tmp_tables(this); - if (items0) + if (current_ref_ptrs != items0) + { set_items_ref_array(items0); - - if (join_tab_save) - memcpy(join_tab, join_tab_save, sizeof(JOIN_TAB) * table_count); + set_group_rpa= false; + } /* need to reset ref access state (see join_read_key) */ if (join_tab) @@ -2397,9 +3032,6 @@ JOIN::reinit() } } - if (tmp_join) - restore_tmp(); - /* Reset of sum functions */ if (sum_funcs) { @@ -2424,38 +3056,40 @@ JOIN::reinit() DBUG_RETURN(0); } + /** - @brief Save the original join layout - - @details Saves the original join layout so it can be reused in - re-execution and for EXPLAIN. - - @return Operation status - @retval 0 success. - @retval 1 error occurred. + Prepare join result. + + @details Prepare join result prior to join execution or describing. + Instantiate derived tables and get schema tables result if necessary. + + @return + TRUE An error during derived or schema tables instantiation. + FALSE Ok */ -bool -JOIN::init_save_join_tab() +bool JOIN::prepare_result(List<Item> **columns_list) { - if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN)))) - return 1; /* purecov: inspected */ - error= 0; // Ensure that tmp_join.error= 0 - restore_tmp(); - return 0; -} + DBUG_ENTER("JOIN::prepare_result"); + error= 0; + /* Create result tables for materialized views. */ + if (!zero_result_cause && + select_lex->handle_derived(thd->lex, DT_CREATE)) + goto err; -bool -JOIN::save_join_tab() -{ - if (!join_tab_save && select_lex->master_unit()->uncacheable) - { - if (!(join_tab_save= (JOIN_TAB*)thd->memdup((uchar*) join_tab, - sizeof(JOIN_TAB) * table_count))) - return 1; - } - return 0; + if (result->prepare2()) + goto err; + + if ((select_lex->options & OPTION_SCHEMA_TABLE) && + get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC)) + goto err; + + DBUG_RETURN(FALSE); + +err: + error= 1; + DBUG_RETURN(TRUE); } @@ -2496,6 +3130,14 @@ void JOIN::save_explain_data(Explain_query *output, bool can_overwrite, Explain_union *eu= output->get_union(nr); explain= &eu->fake_select_lex_explain; join_tab[0].tracker= eu->get_fake_select_lex_tracker(); + for (uint i=0 ; i < top_join_tab_count + aggr_tables; i++) + { + if (join_tab[i].filesort) + { + join_tab[i].filesort->tracker= + new Filesort_tracker(thd->lex->analyze_stmt); + } + } } } @@ -2509,7 +3151,6 @@ void JOIN::exec() dbug_serve_apcs(thd, 1); ); ANALYZE_START_TRACKING(&explain->time_tracker); - explain->ops_tracker.report_join_start(); exec_inner(); ANALYZE_STOP_TRACKING(&explain->time_tracker); @@ -2522,29 +3163,26 @@ void JOIN::exec() } -/** - Exec select. - - @todo - Note, that create_sort_index calls test_if_skip_sort_order and may - finally replace sorting with index scan if there is a LIMIT clause in - the query. It's never shown in EXPLAIN! - - @todo - When can we have here thd->net.report_error not zero? -*/ - void JOIN::exec_inner() { List<Item> *columns_list= &fields_list; - int tmp_error; + DBUG_ENTER("JOIN::exec_inner"); - DBUG_ENTER("JOIN::exec"); + THD_STAGE_INFO(thd, stage_executing); - const bool has_group_by= this->group; + /* + Enable LIMIT ROWS EXAMINED during query execution if: + (1) This JOIN is the outermost query (not a subquery or derived table) + This ensures that the limit is enabled when actual execution begins, and + not if a subquery is evaluated during optimization of the outer query. + (2) This JOIN is not the result of a UNION. In this case do not apply the + limit in order to produce the partial query result stored in the + UNION temp table. + */ + if (!select_lex->outer_select() && // (1) + select_lex != select_lex->master_unit()->fake_select_lex) // (2) + thd->lex->set_limit_rows_examined(); - THD_STAGE_INFO(thd, stage_executing); - error= 0; if (procedure) { procedure_fields_list= fields_list; @@ -2565,13 +3203,16 @@ void JOIN::exec_inner() if (select_options & SELECT_DESCRIBE) select_describe(this, FALSE, FALSE, FALSE, (zero_result_cause?zero_result_cause:"No tables used")); + else { if (result->send_result_set_metadata(*columns_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) { DBUG_VOID_RETURN; } + /* We have to test for 'conds' here as the WHERE may not be constant even if we don't have any tables for prepared statements or if @@ -2638,7 +3279,7 @@ void JOIN::exec_inner() having ? having : tmp_having, all_fields); DBUG_VOID_RETURN; } - + /* Evaluate all constant expressions with subqueries in the ORDER/GROUP clauses to make sure that all subqueries return a @@ -2667,42 +3308,6 @@ void JOIN::exec_inner() if (select_options & SELECT_DESCRIBE) { - /* - Check if we managed to optimize ORDER BY away and don't use temporary - table to resolve ORDER BY: in that case, we only may need to do - filesort for GROUP BY. - */ - if (!order && !no_order && (!skip_sort_order || !need_tmp)) - { - /* - Reset 'order' to 'group_list' and reinit variables describing - 'order' - */ - order= group_list; - simple_order= simple_group; - skip_sort_order= 0; - } - if (order && join_tab) - { - bool made_call= false; - SQL_SELECT *tmp_select= join_tab[const_tables].select; - if ((order != group_list || - !(select_options & SELECT_BIG_RESULT) || - (tmp_select && tmp_select->quick && - tmp_select->quick->get_type() == - QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) && - (const_tables == table_count || - ((simple_order || skip_sort_order) && - (made_call=true) && - test_if_skip_sort_order(&join_tab[const_tables], order, - select_limit, 0, - &join_tab[const_tables].table-> - keys_in_use_for_query)))) - order=0; - if (made_call) - join_tab[const_tables].update_explain_data(const_tables); - } - having= tmp_having; select_describe(this, need_tmp, order != 0 && !skip_sort_order, select_distinct, @@ -2715,537 +3320,31 @@ void JOIN::exec_inner() select_lex->mark_const_derived(zero_result_cause); } - if (!initialized && init_execution()) - DBUG_VOID_RETURN; - - JOIN *curr_join= this; - List<Item> *curr_all_fields= &all_fields; - List<Item> *curr_fields_list= &fields_list; - TABLE *curr_tmp_table= 0; - /* - curr_join->join_free() will call JOIN::cleanup(full=TRUE). It will not - be safe to call update_used_tables() after that. - */ - if (curr_join->tmp_having) - curr_join->tmp_having->update_used_tables(); - /* Initialize examined rows here because the values from all join parts must be accumulated in examined_row_count. Hence every join iteration must count from zero. */ - curr_join->join_examined_rows= 0; - - curr_join->do_select_call_count= 0; - - /* Create a tmp table if distinct or if the sort is too complicated */ - if (need_tmp) - { - if (tmp_join) - { - /* - We are in a non cacheable sub query. Get the saved join structure - after optimization. - (curr_join may have been modified during last exection and we need - to reset it) - */ - curr_join= tmp_join; - } - curr_tmp_table= exec_tmp_table1; + join_examined_rows= 0; - /* Copy data to the temporary table */ - THD_STAGE_INFO(thd, stage_copying_to_tmp_table); - DBUG_PRINT("info", ("%s", thd->proc_info)); - if (!curr_join->sort_and_group && - curr_join->const_tables != curr_join->table_count) - { - JOIN_TAB *first_tab= curr_join->join_tab + curr_join->const_tables; - first_tab->sorted= MY_TEST(first_tab->loosescan_match_tab); - } - - Procedure *save_proc= curr_join->procedure; - tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0); - curr_join->procedure= save_proc; - if (tmp_error) - { - error= tmp_error; - DBUG_VOID_RETURN; - } - curr_tmp_table->file->info(HA_STATUS_VARIABLE); - - if (curr_join->having) - curr_join->having= curr_join->tmp_having= 0; // Allready done - - /* Change sum_fields reference to calculated fields in tmp_table */ -#ifdef HAVE_valgrind - if (curr_join != this) -#endif - curr_join->all_fields= *curr_all_fields; - if (!items1) - { - items1= items0 + all_fields.elements; - if (sort_and_group || curr_tmp_table->group || - tmp_table_param.precomputed_group_by) - { - if (change_to_use_tmp_fields(thd, items1, - tmp_fields_list1, tmp_all_fields1, - fields_list.elements, all_fields)) - DBUG_VOID_RETURN; - } - else - { - if (change_refs_to_tmp_fields(thd, items1, - tmp_fields_list1, tmp_all_fields1, - fields_list.elements, all_fields)) - DBUG_VOID_RETURN; - } -#ifdef HAVE_valgrind - if (curr_join != this) -#endif - { - curr_join->tmp_all_fields1= tmp_all_fields1; - curr_join->tmp_fields_list1= tmp_fields_list1; - } - curr_join->items1= items1; - } - curr_all_fields= &tmp_all_fields1; - curr_fields_list= &tmp_fields_list1; - curr_join->set_items_ref_array(items1); - - if (sort_and_group || curr_tmp_table->group) - { - curr_join->tmp_table_param.field_count+= - curr_join->tmp_table_param.sum_func_count+ - curr_join->tmp_table_param.func_count; - curr_join->tmp_table_param.sum_func_count= - curr_join->tmp_table_param.func_count= 0; - } - else - { - curr_join->tmp_table_param.field_count+= - curr_join->tmp_table_param.func_count; - curr_join->tmp_table_param.func_count= 0; - } - - // procedure can't be used inside subselect => we do nothing special for it - if (procedure) - procedure->update_refs(); - - if (curr_tmp_table->group) - { // Already grouped - if (!curr_join->order && !curr_join->no_order && !skip_sort_order) - curr_join->order= curr_join->group_list; /* order by group */ - curr_join->group_list= 0; - } - - /* - If we have different sort & group then we must sort the data by group - and copy it to another tmp table - This code is also used if we are using distinct something - we haven't been able to store in the temporary table yet - like SEC_TO_TIME(SUM(...)). - */ - - if ((curr_join->group_list && (!test_if_subpart(curr_join->group_list, - curr_join->order) || - curr_join->select_distinct)) || - (curr_join->select_distinct && - curr_join->tmp_table_param.using_indirect_summary_function)) - { /* Must copy to another table */ - DBUG_PRINT("info",("Creating group table")); - - /* Free first data from old join */ - - /* - psergey-todo: this is the place of pre-mature JOIN::free call. - */ - curr_join->join_free(); - if (curr_join->make_simple_join(this, curr_tmp_table)) - DBUG_VOID_RETURN; - calc_group_buffer(curr_join, group_list); - count_field_types(select_lex, &curr_join->tmp_table_param, - curr_join->tmp_all_fields1, - curr_join->select_distinct && !curr_join->group_list); - curr_join->tmp_table_param.hidden_field_count= - (curr_join->tmp_all_fields1.elements- - curr_join->tmp_fields_list1.elements); - - if (exec_tmp_table2) - curr_tmp_table= exec_tmp_table2; - else - { - /* group data to new table */ - - /* - If the access method is loose index scan then all MIN/MAX - functions are precomputed, and should be treated as regular - functions. See extended comment in JOIN::exec. - */ - if (curr_join->join_tab->is_using_loose_index_scan()) - curr_join->tmp_table_param.precomputed_group_by= TRUE; - - if (!(curr_tmp_table= - exec_tmp_table2= create_tmp_table(thd, - &curr_join->tmp_table_param, - *curr_all_fields, - (ORDER*) 0, - curr_join->select_distinct && - !curr_join->group_list, - 1, curr_join->select_options, - HA_POS_ERROR, ""))) - DBUG_VOID_RETURN; - curr_join->exec_tmp_table2= exec_tmp_table2; - explain->ops_tracker.report_tmp_table(exec_tmp_table2); - } - if (curr_join->group_list) - { - if (curr_join->join_tab == join_tab && save_join_tab()) - { - DBUG_VOID_RETURN; - } - DBUG_PRINT("info",("Sorting for index")); - THD_STAGE_INFO(thd, stage_creating_sort_index); - if (create_sort_index(thd, curr_join, curr_join->group_list, - HA_POS_ERROR, HA_POS_ERROR, FALSE) || - make_group_fields(this, curr_join)) - { - DBUG_VOID_RETURN; - } - sortorder= curr_join->sortorder; - } - - THD_STAGE_INFO(thd, stage_copying_to_group_table); - DBUG_PRINT("info", ("%s", thd->proc_info)); - if (curr_join != this) - { - if (sum_funcs2) - { - curr_join->sum_funcs= sum_funcs2; - curr_join->sum_funcs_end= sum_funcs_end2; - } - else - { - curr_join->alloc_func_list(); - sum_funcs2= curr_join->sum_funcs; - sum_funcs_end2= curr_join->sum_funcs_end; - } - } - if (curr_join->make_sum_func_list(*curr_all_fields, *curr_fields_list, - 1, TRUE) || - prepare_sum_aggregators(curr_join->sum_funcs, - !curr_join->join_tab->is_using_agg_loose_index_scan())) - DBUG_VOID_RETURN; - curr_join->group_list= 0; - if (!curr_join->sort_and_group && - curr_join->const_tables != curr_join->table_count) - { - JOIN_TAB *first_tab= curr_join->join_tab + curr_join->const_tables; - first_tab->sorted= MY_TEST(first_tab->loosescan_match_tab); - } - tmp_error= -1; - if (setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) || - (tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, - 0))) - { - error= tmp_error; - DBUG_VOID_RETURN; - } - end_read_record(&curr_join->join_tab->read_record); - curr_join->const_tables= curr_join->table_count; // Mark free for cleanup() - curr_join->join_tab[0].table= 0; // Table is freed - - // No sum funcs anymore - if (!items2) - { - items2= items1 + all_fields.elements; - if (change_to_use_tmp_fields(thd, items2, - tmp_fields_list2, tmp_all_fields2, - fields_list.elements, tmp_all_fields1)) - DBUG_VOID_RETURN; -#ifdef HAVE_valgrind - /* - Some GCCs use memcpy() for struct assignment, even for x=x. - GCC bug 19410: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19410 - */ - if (curr_join != this) -#endif - { - curr_join->tmp_fields_list2= tmp_fields_list2; - curr_join->tmp_all_fields2= tmp_all_fields2; - } - } - curr_fields_list= &curr_join->tmp_fields_list2; - curr_all_fields= &curr_join->tmp_all_fields2; - curr_join->set_items_ref_array(items2); - curr_join->tmp_table_param.field_count+= - curr_join->tmp_table_param.sum_func_count; - curr_join->tmp_table_param.sum_func_count= 0; - } - if (curr_tmp_table->distinct) - curr_join->select_distinct=0; /* Each row is unique */ - - curr_join->join_free(); /* Free quick selects */ - - if (curr_join->select_distinct && ! curr_join->group_list) - { - THD_STAGE_INFO(thd, stage_removing_duplicates); - if (remove_duplicates(curr_join, curr_tmp_table, - *curr_fields_list, curr_join->tmp_having)) - DBUG_VOID_RETURN; - curr_join->tmp_having=0; - curr_join->select_distinct=0; - } - curr_tmp_table->reginfo.lock_type= TL_UNLOCK; - // psergey-todo: here is one place where we switch to - if (curr_join->make_simple_join(this, curr_tmp_table)) - DBUG_VOID_RETURN; - calc_group_buffer(curr_join, curr_join->group_list); - count_field_types(select_lex, &curr_join->tmp_table_param, - *curr_all_fields, 0); - - } - if (procedure) - count_field_types(select_lex, &curr_join->tmp_table_param, - *curr_all_fields, 0); - - if (curr_join->group || curr_join->implicit_grouping || - curr_join->tmp_table_param.sum_func_count || - (procedure && (procedure->flags & PROC_GROUP))) - { - if (make_group_fields(this, curr_join)) - { - DBUG_VOID_RETURN; - } - if (!items3) - { - if (!items0) - init_items_ref_array(); - items3= ref_pointer_array + (all_fields.elements*4); - setup_copy_fields(thd, &curr_join->tmp_table_param, - items3, tmp_fields_list3, tmp_all_fields3, - curr_fields_list->elements, *curr_all_fields); - tmp_table_param.save_copy_funcs= curr_join->tmp_table_param.copy_funcs; - tmp_table_param.save_copy_field= curr_join->tmp_table_param.copy_field; - tmp_table_param.save_copy_field_end= - curr_join->tmp_table_param.copy_field_end; -#ifdef HAVE_valgrind - if (curr_join != this) -#endif - { - curr_join->tmp_all_fields3= tmp_all_fields3; - curr_join->tmp_fields_list3= tmp_fields_list3; - } - } - else - { - curr_join->tmp_table_param.copy_funcs= tmp_table_param.save_copy_funcs; - curr_join->tmp_table_param.copy_field= tmp_table_param.save_copy_field; - curr_join->tmp_table_param.copy_field_end= - tmp_table_param.save_copy_field_end; - } - curr_fields_list= &tmp_fields_list3; - curr_all_fields= &tmp_all_fields3; - curr_join->set_items_ref_array(items3); - - if (curr_join->make_sum_func_list(*curr_all_fields, *curr_fields_list, - 1, TRUE) || - prepare_sum_aggregators(curr_join->sum_funcs, - !curr_join->join_tab || - !curr_join->join_tab-> - is_using_agg_loose_index_scan()) || - setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) || - thd->is_fatal_error) - DBUG_VOID_RETURN; - } - if (curr_join->group_list || curr_join->order) - { - DBUG_PRINT("info",("Sorting for send_result_set_metadata")); - THD_STAGE_INFO(thd, stage_sorting_result); - /* If we have already done the group, add HAVING to sorted table */ - if (curr_join->tmp_having && ! curr_join->group_list && - ! curr_join->sort_and_group) - { - JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables]; - table_map used_tables= (curr_join->const_table_map | - curr_table->table->map); - curr_join->tmp_having->update_used_tables(); - - Item* sort_table_cond= make_cond_for_table(thd, curr_join->tmp_having, - used_tables, - (table_map)0, -1, - FALSE, FALSE); - if (sort_table_cond) - { - if (!curr_table->select) - if (!(curr_table->select= new SQL_SELECT)) - DBUG_VOID_RETURN; - if (!curr_table->select->cond) - curr_table->select->cond= sort_table_cond; - else - { - if (!(curr_table->select->cond= - new (thd->mem_root) Item_cond_and(thd, curr_table->select->cond, - sort_table_cond))) - DBUG_VOID_RETURN; - } - if (curr_table->pre_idx_push_select_cond) - { - if (sort_table_cond->type() == Item::COND_ITEM) - sort_table_cond= sort_table_cond->copy_andor_structure(thd); - if (!(curr_table->pre_idx_push_select_cond= - new (thd->mem_root) Item_cond_and(thd, curr_table->pre_idx_push_select_cond, - sort_table_cond))) - DBUG_VOID_RETURN; - } - if (curr_table->select->cond && !curr_table->select->cond->fixed) - curr_table->select->cond->fix_fields(thd, 0); - if (curr_table->pre_idx_push_select_cond && - !curr_table->pre_idx_push_select_cond->fixed) - curr_table->pre_idx_push_select_cond->fix_fields(thd, 0); - - curr_table->select->pre_idx_push_select_cond= - curr_table->pre_idx_push_select_cond; - curr_table->set_select_cond(curr_table->select->cond, __LINE__); - curr_table->select_cond->top_level_item(); - DBUG_EXECUTE("where",print_where(curr_table->select->cond, - "select and having", - QT_ORDINARY);); - curr_join->tmp_having= make_cond_for_table(thd, curr_join->tmp_having, - ~ (table_map) 0, - ~used_tables, -1, - FALSE, FALSE); - DBUG_EXECUTE("where",print_where(curr_join->tmp_having, - "having after sort", - QT_ORDINARY);); - } - } - { - if (group) - curr_join->select_limit= HA_POS_ERROR; - else - { - /* - We can abort sorting after thd->select_limit rows if we there is no - WHERE clause for any tables after the sorted one. - */ - JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables+1]; - JOIN_TAB *end_table= &curr_join->join_tab[curr_join->top_join_tab_count]; - for (; curr_table < end_table ; curr_table++) - { - /* - table->keyuse is set in the case there was an original WHERE clause - on the table that was optimized away. - */ - if (curr_table->select_cond || - (curr_table->keyuse && !curr_table->first_inner)) - { - /* We have to sort all rows */ - curr_join->select_limit= HA_POS_ERROR; - break; - } - } - } - if (curr_join->join_tab == join_tab && save_join_tab()) - { - DBUG_VOID_RETURN; - } - /* - Here we sort rows for ORDER BY/GROUP BY clause, if the optimiser - chose FILESORT to be faster than INDEX SCAN or there is no - suitable index present. - Note, that create_sort_index calls test_if_skip_sort_order and may - finally replace sorting with index scan if there is a LIMIT clause in - the query. XXX: it's never shown in EXPLAIN! - OPTION_FOUND_ROWS supersedes LIMIT and is taken into account. - */ - DBUG_PRINT("info",("Sorting for order by/group by")); - ORDER *order_arg= - curr_join->group_list ? curr_join->group_list : curr_join->order; - /* - filesort_limit: Return only this many rows from filesort(). - We can use select_limit_cnt only if we have no group_by and 1 table. - This allows us to use Bounded_queue for queries like: - "select SQL_CALC_FOUND_ROWS * from t1 order by b desc limit 1;" - select_limit == HA_POS_ERROR (we need a full table scan) - unit->select_limit_cnt == 1 (we only need one row in the result set) - */ - const ha_rows filesort_limit_arg= - (has_group_by || curr_join->table_count > 1) - ? curr_join->select_limit : unit->select_limit_cnt; - const ha_rows select_limit_arg= - select_options & OPTION_FOUND_ROWS - ? HA_POS_ERROR : unit->select_limit_cnt; - curr_join->filesort_found_rows= filesort_limit_arg != HA_POS_ERROR; - - DBUG_PRINT("info", ("has_group_by %d " - "curr_join->table_count %d " - "curr_join->m_select_limit %d " - "unit->select_limit_cnt %d", - has_group_by, - curr_join->table_count, - (int) curr_join->select_limit, - (int) unit->select_limit_cnt)); - if (create_sort_index(thd, - curr_join, - order_arg, - filesort_limit_arg, - select_limit_arg, - curr_join->group_list ? FALSE : TRUE)) - DBUG_VOID_RETURN; - sortorder= curr_join->sortorder; - if (curr_join->const_tables != curr_join->table_count && - !curr_join->join_tab[curr_join->const_tables].filesort) - { - /* - If no filesort for the first table then we are using an - INDEX SCAN. Thus we should not remove the sorted attribute - on the INDEX SCAN. - */ - skip_sort_order= 1; - } - } - } /* XXX: When can we have here thd->is_error() not zero? */ if (thd->is_error()) { error= thd->is_error(); DBUG_VOID_RETURN; } - curr_join->having= curr_join->tmp_having; - curr_join->fields= curr_fields_list; - curr_join->procedure= procedure; THD_STAGE_INFO(thd, stage_sending_data); DBUG_PRINT("info", ("%s", thd->proc_info)); - result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list : - *curr_fields_list), - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); - error= do_select(curr_join, curr_fields_list, NULL, procedure); - if (curr_join->order && curr_join->sortorder && - curr_join->filesort_found_rows) - { - /* Use info provided by filesort. */ - DBUG_ASSERT(curr_join->table_count > curr_join->const_tables); - JOIN_TAB *tab= curr_join->join_tab + curr_join->const_tables; - thd->limit_found_rows= tab->records; - } - + result->send_result_set_metadata( + procedure ? procedure_fields_list : *fields, + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); + error= do_select(this, procedure); /* Accumulate the counts from all join iterations of all join parts. */ - thd->inc_examined_row_count(curr_join->join_examined_rows); + thd->inc_examined_row_count(join_examined_rows); DBUG_PRINT("counts", ("thd->examined_row_count: %lu", (ulong) thd->get_examined_row_count())); - /* - With EXPLAIN EXTENDED we have to restore original ref_array - for a derived table which is always materialized. - We also need to do this when we have temp table(s). - Otherwise we would not be able to print the query correctly. - */ - if (items0 && (thd->lex->describe & DESCRIBE_EXTENDED) && - (select_lex->linkage == DERIVED_TABLE_TYPE || - exec_tmp_table1 || exec_tmp_table2)) - set_items_ref_array(items0); - DBUG_VOID_RETURN; } @@ -3263,41 +3362,34 @@ JOIN::destroy() DBUG_ENTER("JOIN::destroy"); select_lex->join= 0; - if (tmp_join) + cond_equal= 0; + having_equal= 0; + + cleanup(1); + + if (join_tab) { - if (join_tab != tmp_join->join_tab) + DBUG_ASSERT(table_count+aggr_tables > 0); + for (JOIN_TAB *tab= first_linear_tab(this, WITH_BUSH_ROOTS, + WITH_CONST_TABLES); + tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS)) { - JOIN_TAB *tab; - for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITH_CONST_TABLES); - tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS)) + if (tab->aggr) { - tab->cleanup(); + free_tmp_table(thd, tab->table); + delete tab->tmp_table_param; + tab->tmp_table_param= NULL; + tab->aggr= NULL; } + tab->table= NULL; } - tmp_join->tmp_join= 0; - /* - We need to clean up tmp_table_param for reusable JOINs (having non-zero - and different from self tmp_join) because it's not being cleaned up - anywhere else (as we need to keep the join is reusable). - */ - tmp_table_param.cleanup(); - tmp_join->tmp_table_param.copy_field= 0; - DBUG_RETURN(tmp_join->destroy()); } - cond_equal= 0; - having_equal= 0; - cleanup(1); - /* Cleanup items referencing temporary table columns */ + /* Cleanup items referencing temporary table columns */ cleanup_item_list(tmp_all_fields1); cleanup_item_list(tmp_all_fields3); - if (exec_tmp_table1) - free_tmp_table(thd, exec_tmp_table1); - if (exec_tmp_table2) - free_tmp_table(thd, exec_tmp_table2); - delete select; destroy_sj_tmp_tables(this); - delete_dynamic(&keyuse); + delete_dynamic(&keyuse); delete procedure; DBUG_RETURN(error); } @@ -3362,7 +3454,7 @@ void JOIN::cleanup_item_list(List<Item> &items) const */ bool -mysql_select(THD *thd, Item ***rref_pointer_array, +mysql_select(THD *thd, TABLE_LIST *tables, uint wild_num, List<Item> &fields, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulonglong select_options, @@ -3397,7 +3489,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, } else { - if ((err= join->prepare(rref_pointer_array, tables, wild_num, + if ((err= join->prepare( tables, wild_num, conds, og_num, order, false, group, having, proc_param, select_lex, unit))) { @@ -3421,7 +3513,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, DBUG_RETURN(TRUE); THD_STAGE_INFO(thd, stage_init); thd->lex->used_tables=0; - if ((err= join->prepare(rref_pointer_array, tables, wild_num, + if ((err= join->prepare(tables, wild_num, conds, og_num, order, false, group, having, proc_param, select_lex, unit))) { @@ -4224,7 +4316,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, DEBUG_SYNC(join->thd, "inside_make_join_statistics"); /* Generate an execution plan from the found optimal join order. */ - DBUG_RETURN(join->thd->check_killed() || get_best_combination(join)); + DBUG_RETURN(join->thd->check_killed() || join->get_best_combination()); error: /* @@ -4516,9 +4608,9 @@ add_key_field(JOIN *join, ((join->is_allowed_hash_join_access() && field->hash_join_is_possible() && !(field->table->pos_in_table_list->is_materialized_derived() && - field->table->created)) || + field->table->is_created())) || (field->table->pos_in_table_list->is_materialized_derived() && - !field->table->created && !(field->flags & BLOB_FLAG)))) + !field->table->is_created() && !(field->flags & BLOB_FLAG)))) { optimize= KEY_OPTIMIZE_EQ; } @@ -5725,7 +5817,8 @@ add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab) item->walk(&Item::collect_item_field_processor, 0, (uchar*) &indexed_fields); } - else if (is_indexed_agg_distinct(join, &indexed_fields)) + else if (join->tmp_table_param.sum_func_count && + is_indexed_agg_distinct(join, &indexed_fields)) { join->sort_and_group= 1; } @@ -7312,13 +7405,13 @@ double JOIN::get_examined_rows() { double examined_rows; double prev_fanout= 1; - JOIN_TAB *tab= first_breadth_first_optimization_tab(); + JOIN_TAB *tab= first_breadth_first_tab(); JOIN_TAB *prev_tab= tab; examined_rows= tab->get_examined_rows(); - while ((tab= next_breadth_first_tab(first_breadth_first_optimization_tab(), - top_table_access_tabs_count, tab))) + while ((tab= next_breadth_first_tab(first_breadth_first_tab(), + top_join_tab_count, tab))) { prev_fanout *= prev_tab->records_read; examined_rows+= tab->get_examined_rows() * prev_fanout; @@ -8215,6 +8308,7 @@ prev_record_reads(POSITION *positions, uint idx, table_map found_ref) static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab, uint n_top_tabs_count, JOIN_TAB *tab) { + n_top_tabs_count += tab->join->aggr_tables; if (!tab->bush_root_tab) { /* We're at top level. Get the next top-level tab */ @@ -8266,7 +8360,7 @@ static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab, JOIN_TAB *first_explain_order_tab(JOIN* join) { JOIN_TAB* tab; - tab= join->table_access_tabs; + tab= join->join_tab; return (tab->bush_children) ? tab->bush_children->start : tab; } @@ -8280,7 +8374,7 @@ JOIN_TAB *next_explain_order_tab(JOIN* join, JOIN_TAB* tab) /* Move to next tab in the array we're traversing */ tab++; - if (tab == join->table_access_tabs + join->top_join_tab_count) + if (tab == join->join_tab + join->top_join_tab_count) return NULL; /* Outside SJM nest and reached EOF */ if (tab->bush_children) @@ -8306,7 +8400,7 @@ JOIN_TAB *first_top_level_tab(JOIN *join, enum enum_with_const_tables const_tbls JOIN_TAB *next_top_level_tab(JOIN *join, JOIN_TAB *tab) { - tab= next_breadth_first_tab(join->first_breadth_first_execution_tab(), + tab= next_breadth_first_tab(join->first_breadth_first_tab(), join->top_join_tab_count, tab); if (tab && tab->bush_root_tab) tab= NULL; @@ -8384,7 +8478,7 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, } /* If no more JOIN_TAB's on the top level */ - if (++tab == join->join_tab + join->top_join_tab_count) + if (++tab == join->join_tab + join->top_join_tab_count + join->aggr_tables) return NULL; if (include_bush_roots == WITHOUT_BUSH_ROOTS && tab->bush_children) @@ -8478,37 +8572,58 @@ static Item * const null_ptr= NULL; TRUE Out of memory */ -bool -get_best_combination(JOIN *join) +bool JOIN::get_best_combination() { uint tablenr; table_map used_tables; - JOIN_TAB *join_tab,*j; + JOIN_TAB *j; KEYUSE *keyuse; - uint table_count; - THD *thd=join->thd; DBUG_ENTER("get_best_combination"); - table_count=join->table_count; - if (!(join->join_tab=join_tab= - (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*table_count))) + /* + Additional plan nodes for postjoin tmp tables: + 1? + // For GROUP BY + 1? + // For DISTINCT + 1? + // For aggregation functions aggregated in outer query + // when used with distinct + 1? + // For ORDER BY + 1? // buffer result + Up to 2 tmp tables are actually used, but it's hard to tell exact number + at this stage. + */ + uint aggr_tables= (group_list ? 1 : 0) + + (select_distinct ? + (tmp_table_param. using_outer_summary_function ? 2 : 1) : 0) + + (order ? 1 : 0) + + (select_options & (SELECT_BIG_RESULT | OPTION_BUFFER_RESULT) ? 1 : 0) ; + + if (aggr_tables == 0) + aggr_tables= 1; /* For group by pushdown */ + + if (select_lex->window_specs.elements) + aggr_tables++; + + if (aggr_tables > 2) + aggr_tables= 2; + if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)* + (top_join_tab_count + aggr_tables)))) DBUG_RETURN(TRUE); - join->full_join=0; - join->hash_join= FALSE; + full_join=0; + hash_join= FALSE; used_tables= OUTER_REF_TABLE_BIT; // Outer row is already read - fix_semijoin_strategies_for_picked_join_order(join); - + fix_semijoin_strategies_for_picked_join_order(this); + JOIN_TAB_RANGE *root_range; if (!(root_range= new (thd->mem_root) JOIN_TAB_RANGE)) DBUG_RETURN(TRUE); - root_range->start= join->join_tab; + root_range->start= join_tab; /* root_range->end will be set later */ - join->join_tab_ranges.empty(); + join_tab_ranges.empty(); - if (join->join_tab_ranges.push_back(root_range, thd->mem_root)) + if (join_tab_ranges.push_back(root_range, thd->mem_root)) DBUG_RETURN(TRUE); JOIN_TAB *sjm_nest_end= NULL; @@ -8517,7 +8632,7 @@ get_best_combination(JOIN *join) for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++) { TABLE *form; - POSITION *cur_pos= &join->best_positions[tablenr]; + POSITION *cur_pos= &best_positions[tablenr]; if (cur_pos->sj_strategy == SJ_OPT_MATERIALIZE || cur_pos->sj_strategy == SJ_OPT_MATERIALIZE_SCAN) { @@ -8528,7 +8643,7 @@ get_best_combination(JOIN *join) in the temptable. */ bzero(j, sizeof(JOIN_TAB)); - j->join= join; + j->join= this; j->table= NULL; //temporary way to tell SJM tables from others. j->ref.key = -1; j->on_expr_ref= (Item**) &null_ptr; @@ -8544,12 +8659,12 @@ get_best_combination(JOIN *join) j->cond_selectivity= 1.0; JOIN_TAB *jt; JOIN_TAB_RANGE *jt_range; - if (!(jt= (JOIN_TAB*)join->thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) || + if (!(jt= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) || !(jt_range= new JOIN_TAB_RANGE)) DBUG_RETURN(TRUE); jt_range->start= jt; jt_range->end= jt + sjm->tables; - join->join_tab_ranges.push_back(jt_range, join->thd->mem_root); + join_tab_ranges.push_back(jt_range, thd->mem_root); j->bush_children= jt_range; sjm_nest_end= jt + sjm->tables; sjm_nest_root= j; @@ -8557,11 +8672,11 @@ get_best_combination(JOIN *join) j= jt; } - *j= *join->best_positions[tablenr].table; + *j= *best_positions[tablenr].table; j->bush_root_tab= sjm_nest_root; - form=join->table[tablenr]=j->table; + form= table[tablenr]= j->table; used_tables|= form->map; form->reginfo.join_tab=j; if (!*j->on_expr_ref) @@ -8577,36 +8692,36 @@ get_best_combination(JOIN *join) if (j->type == JT_SYSTEM) goto loop_end; - if ( !(keyuse= join->best_positions[tablenr].key)) + if ( !(keyuse= best_positions[tablenr].key)) { j->type=JT_ALL; - if (join->best_positions[tablenr].use_join_buffer && - tablenr != join->const_tables) - join->full_join= 1; + if (best_positions[tablenr].use_join_buffer && + tablenr != const_tables) + full_join= 1; } - /*if (join->best_positions[tablenr].sj_strategy == SJ_OPT_LOOSE_SCAN) + /*if (best_positions[tablenr].sj_strategy == SJ_OPT_LOOSE_SCAN) { DBUG_ASSERT(!keyuse || keyuse->key == - join->best_positions[tablenr].loosescan_picker.loosescan_key); - j->index= join->best_positions[tablenr].loosescan_picker.loosescan_key; + best_positions[tablenr].loosescan_picker.loosescan_key); + j->index= best_positions[tablenr].loosescan_picker.loosescan_key; }*/ - if (keyuse && create_ref_for_key(join, j, keyuse, TRUE, used_tables)) + if (keyuse && create_ref_for_key(this, j, keyuse, TRUE, used_tables)) DBUG_RETURN(TRUE); // Something went wrong if ((j->type == JT_REF || j->type == JT_EQ_REF) && is_hash_join_key_no(j->ref.key)) - join->hash_join= TRUE; + hash_join= TRUE; loop_end: /* Save records_read in JOIN_TAB so that select_describe()/etc don't have to access join->best_positions[]. */ - j->records_read= join->best_positions[tablenr].records_read; - j->cond_selectivity= join->best_positions[tablenr].cond_selectivity; - join->map2table[j->table->tablenr]= j; + j->records_read= best_positions[tablenr].records_read; + j->cond_selectivity= best_positions[tablenr].cond_selectivity; + map2table[j->table->tablenr]= j; /* If we've reached the end of sjm nest, switch back to main sequence */ if (j + 1 == sjm_nest_end) @@ -8619,16 +8734,10 @@ get_best_combination(JOIN *join) } root_range->end= j; - join->top_join_tab_count= join->join_tab_ranges.head()->end - - join->join_tab_ranges.head()->start; - /* - Save pointers to select join tabs for SHOW EXPLAIN - */ - join->table_access_tabs= join->join_tab; - join->top_table_access_tabs_count= join->top_join_tab_count; - + top_join_tab_count= join_tab_ranges.head()->end - + join_tab_ranges.head()->start; - update_depend_map(join); + update_depend_map(this); DBUG_RETURN(0); } @@ -9027,115 +9136,6 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables, keyuse->val, FALSE); } -/** - @details Initialize a JOIN as a query execution plan - that accesses a single table via a table scan. - - @param parent contains JOIN_TAB and TABLE object buffers for this join - @param tmp_table temporary table - - @retval FALSE success - @retval TRUE error occurred -*/ -bool -JOIN::make_simple_join(JOIN *parent, TABLE *temp_table) -{ - DBUG_ENTER("JOIN::make_simple_join"); - - /* - Reuse TABLE * and JOIN_TAB if already allocated by a previous call - to this function through JOIN::exec (may happen for sub-queries). - - psergey-todo: here, save the pointer for original join_tabs. - */ - if (!(join_tab= parent->join_tab_reexec)) - { - if (!(join_tab= parent->join_tab_reexec= - (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)))) - DBUG_RETURN(TRUE); /* purecov: inspected */ - } - else - { - /* Free memory used by previous allocations */ - delete join_tab->filesort; - } - - table= &parent->table_reexec[0]; parent->table_reexec[0]= temp_table; - table_count= top_join_tab_count= 1; - - const_tables= 0; - const_table_map= 0; - eliminated_tables= 0; - tmp_table_param.field_count= tmp_table_param.sum_func_count= - tmp_table_param.func_count= 0; - /* - We need to destruct the copy_field (allocated in create_tmp_table()) - before setting it to 0 if the join is not "reusable". - */ - if (!tmp_join || tmp_join != this) - tmp_table_param.cleanup(); - tmp_table_param.copy_field= tmp_table_param.copy_field_end=0; - first_record= sort_and_group=0; - send_records= (ha_rows) 0; - - if (group_optimized_away && !tmp_table_param.precomputed_group_by) - { - /* - If grouping has been optimized away, a temporary table is - normally not needed unless we're explicitly requested to create - one (e.g. due to a SQL_BUFFER_RESULT hint or INSERT ... SELECT). - - In this case (grouping was optimized away), temp_table was - created without a grouping expression and JOIN::exec() will not - perform the necessary grouping (by the use of end_send_group() - or end_write_group()) if JOIN::group is set to false. - - There is one exception: if the loose index scan access method is - used to read into the temporary table, grouping and aggregate - functions are handled. - */ - // the temporary table was explicitly requested - DBUG_ASSERT(MY_TEST(select_options & OPTION_BUFFER_RESULT)); - // the temporary table does not have a grouping expression - DBUG_ASSERT(!temp_table->group); - } - else - group= false; - - row_limit= unit->select_limit_cnt; - do_send_rows= row_limit ? 1 : 0; - - bzero(join_tab, sizeof(JOIN_TAB)); - join_tab->table=temp_table; - join_tab->set_select_cond(NULL, __LINE__); - join_tab->type= JT_ALL; /* Map through all records */ - join_tab->keys.init(); - join_tab->keys.set_all(); /* test everything in quick */ - join_tab->ref.key = -1; - join_tab->shortcut_for_distinct= false; - join_tab->read_first_record= join_init_read_record; - join_tab->join= this; - join_tab->ref.key_parts= 0; - - uint select_nr= select_lex->select_number; - if (select_nr == INT_MAX) - { - /* this is a fake_select_lex of a union */ - select_nr= select_lex->master_unit()->first_select()->select_number; - join_tab->tracker= thd->lex->explain->get_union(select_nr)-> - get_tmptable_read_tracker(); - } - else - { - join_tab->tracker= thd->lex->explain->get_select(select_nr)-> - get_using_temporary_read_tracker(); - } - bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record)); - temp_table->status=0; - temp_table->null_row=0; - DBUG_RETURN(FALSE); -} - inline void add_cond_and_fix(THD *thd, Item **e1, Item *e2) { @@ -9551,6 +9551,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tab= next_depth_first_tab(join, tab), i++) { bool is_hj; + /* first_inner is the X in queries like: SELECT * FROM t1 LEFT OUTER JOIN (t2 JOIN t3) ON X @@ -11181,7 +11182,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) join_read_system :join_read_const; if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - table->enable_keyread(); + table->set_keyread(true); else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; @@ -11190,7 +11191,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) /* fall through */ if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - table->enable_keyread(); + table->set_keyread(true); else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; @@ -11205,7 +11206,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) tab->quick=0; if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - table->enable_keyread(); + table->set_keyread(true); else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; @@ -11268,7 +11269,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) if (tab->select && tab->select->quick && tab->select->quick->index != MAX_KEY && //not index_merge table->covering_keys.is_set(tab->select->quick->index)) - table->enable_keyread(); + table->set_keyread(true); else if (!table->covering_keys.is_clear_all() && !(tab->select && tab->select->quick)) { // Only read index tree @@ -11430,17 +11431,27 @@ void JOIN_TAB::cleanup() select= 0; delete quick; quick= 0; - delete filesort; - filesort= 0; if (cache) { cache->free(); cache= 0; } limit= 0; + // Free select that was created for filesort outside of create_sort_index + if (filesort && filesort->select && !filesort->own_select) + delete filesort->select; + delete filesort; + filesort= NULL; + /* Skip non-existing derived tables/views result tables */ + if (table && + (table->s->tmp_table != INTERNAL_TMP_TABLE || table->is_created())) + { + table->set_keyread(FALSE); + table->file->ha_index_or_rnd_end(); + } if (table) { - table->disable_keyread(); + table->set_keyread(false); table->file->ha_index_or_rnd_end(); preread_init_done= FALSE; if (table->pos_in_table_list && @@ -11490,7 +11501,7 @@ void JOIN_TAB::cleanup() double JOIN_TAB::scan_time() { double res; - if (table->created) + if (table->is_created()) { if (table->is_filled_at_execution()) { @@ -11529,9 +11540,10 @@ double JOIN_TAB::scan_time() ha_rows JOIN_TAB::get_examined_rows() { double examined_rows; + SQL_SELECT *sel= filesort? filesort->select : this->select; - if (select && select->quick && use_quick != 2) - examined_rows= select->quick->records; + if (sel && sel->quick && use_quick != 2) + examined_rows= sel->quick->records; else if (type == JT_NEXT || type == JT_ALL || type == JT_HASH || type ==JT_HASH_NEXT) { @@ -11818,35 +11830,12 @@ void JOIN::cleanup(bool full) table_count= original_table_count; } - if (table) + if (join_tab) { JOIN_TAB *tab; - /* - Only a sorted table may be cached. This sorted table is always the - first non const table in join->table - */ - if (table_count > const_tables) // Test for not-const tables - { - JOIN_TAB *first_tab= first_top_level_tab(this, WITHOUT_CONST_TABLES); - if (first_tab->table) - { - delete first_tab->filesort; - first_tab->filesort= 0; - } - } + if (full) { - JOIN_TAB *sort_tab= first_linear_tab(this, WITH_BUSH_ROOTS, - WITHOUT_CONST_TABLES); - if (pre_sort_join_tab) - { - if (sort_tab && sort_tab->select == pre_sort_join_tab->select) - { - pre_sort_join_tab->select= NULL; - } - else - clean_pre_sort_join_tab(); - } /* Call cleanup() on join tabs used by the join optimization (join->join_tab may now be pointing to result of make_simple_join @@ -11858,49 +11847,64 @@ void JOIN::cleanup(bool full) */ if (table_count) { - for (tab= first_breadth_first_optimization_tab(); tab; - tab= next_breadth_first_tab(first_breadth_first_optimization_tab(), - top_table_access_tabs_count, tab)) - tab->cleanup(); - - /* We've walked optimization tabs, do execution ones too. */ - if (first_breadth_first_execution_tab() != - first_breadth_first_optimization_tab()) + for (tab= first_breadth_first_tab(); tab; + tab= next_breadth_first_tab(first_breadth_first_tab(), + top_join_tab_count, tab)) { - for (tab= first_breadth_first_execution_tab(); tab; - tab= next_breadth_first_tab(first_breadth_first_execution_tab(), - top_join_tab_count, tab)) - tab->cleanup(); + tab->cleanup(); + delete tab->filesort_result; + tab->filesort_result= NULL; } } cleaned= true; + //psergey2: added (Q: why not in the above loop?) + { + JOIN_TAB *curr_tab= join_tab + top_join_tab_count; + for (uint i= 0; i < aggr_tables; i++, curr_tab++) + { + if (curr_tab->aggr) + { + free_tmp_table(thd, curr_tab->table); + delete curr_tab->tmp_table_param; + curr_tab->tmp_table_param= NULL; + curr_tab->aggr= NULL; + + delete curr_tab->filesort_result; + curr_tab->filesort_result= NULL; + } + } + aggr_tables= 0; // psergey3 + } } else { for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITH_CONST_TABLES); tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS)) { - if (tab->table) + if (!tab->table) + continue; + DBUG_PRINT("info", ("close index: %s.%s alias: %s", + tab->table->s->db.str, + tab->table->s->table_name.str, + tab->table->alias.c_ptr())); + if (tab->table->is_created()) { - DBUG_PRINT("info", ("close index: %s.%s alias: %s", - tab->table->s->db.str, - tab->table->s->table_name.str, - tab->table->alias.c_ptr())); tab->table->file->ha_index_or_rnd_end(); + if (tab->aggr) + { + int tmp= 0; + if ((tmp= tab->table->file->extra(HA_EXTRA_NO_CACHE))) + tab->table->file->print_error(tmp, MYF(0)); + } } + delete tab->filesort_result; + tab->filesort_result= NULL; } } } if (full) { cleanup_empty_jtbm_semi_joins(this, join_list); - /* - Ensure that the following delete_elements() would not be called - twice for the same list. - */ - if (tmp_join && tmp_join != this && - tmp_join->group_fields == this->group_fields) - tmp_join->group_fields.empty(); // Run Cached_item DTORs! group_fields.delete_elements(); @@ -11916,14 +11920,6 @@ void JOIN::cleanup(bool full) pointer to tmp_table_param.copy_field from tmp_join, because it qill be removed in tmp_table_param.cleanup(). */ - if (tmp_join && - tmp_join != this && - tmp_join->tmp_table_param.copy_field == - tmp_table_param.copy_field) - { - tmp_join->tmp_table_param.copy_field= - tmp_join->tmp_table_param.save_copy_field= 0; - } tmp_table_param.cleanup(); delete pushdown_query; @@ -11945,6 +11941,12 @@ void JOIN::cleanup(bool full) } } } + /* Restore ref array to original state */ + if (current_ref_ptrs != items0) + { + set_items_ref_array(items0); + set_group_rpa= false; + } DBUG_VOID_RETURN; } @@ -12120,8 +12122,8 @@ static ORDER * remove_const(JOIN *join,ORDER *first_order, COND *cond, bool change_list, bool *simple_order) { - *simple_order= 1; - if (join->table_count == join->const_tables) + *simple_order= join->rollup.state == ROLLUP::STATE_NONE; + if (join->only_const_tables()) return change_list ? 0 : first_order; // No need to sort ORDER *order,**prev_ptr, *tmp_order; @@ -13282,16 +13284,16 @@ static int compare_fields_by_table_order(Item *field1, Item_field *f1= (Item_field *) (field1->real_item()); Item_field *f2= (Item_field *) (field2->real_item()); if (field1->const_item() || f1->const_item()) - return 1; - if (field2->const_item() || f2->const_item()) return -1; - if (f2->used_tables() & OUTER_REF_TABLE_BIT) - { + if (field2->const_item() || f2->const_item()) + return 1; + if (f1->used_tables() & OUTER_REF_TABLE_BIT) + { outer_ref= 1; cmp= -1; } - if (f1->used_tables() & OUTER_REF_TABLE_BIT) - { + if (f2->used_tables() & OUTER_REF_TABLE_BIT) + { outer_ref= 1; cmp++; } @@ -13315,10 +13317,12 @@ static int compare_fields_by_table_order(Item *field1, tab2= tab2->bush_root_tab; } - cmp= tab2 - tab1; + cmp= tab1 - tab2; if (!cmp) { + /* Fields f1, f2 belong to the same table */ + JOIN_TAB *tab= idx[f1->field->table->tablenr]; uint keyno= MAX_KEY; if (tab->ref.key_parts) @@ -13327,31 +13331,38 @@ static int compare_fields_by_table_order(Item *field1, keyno = tab->select->quick->index; if (keyno != MAX_KEY) { - if (f2->field->part_of_key.is_set(keyno)) - cmp= -1; if (f1->field->part_of_key.is_set(keyno)) + cmp= -1; + if (f2->field->part_of_key.is_set(keyno)) cmp++; + /* + Here: + if both f1, f2 are components of the key tab->ref.key then cmp==0, + if only f1 is a component of the key then cmp==-1 (f1 is better), + if only f2 is a component of the key then cmp==1, (f2 is better), + if none of f1,f1 is component of the key cmp==0. + */ if (!cmp) { KEY *key_info= tab->table->key_info + keyno; for (uint i= 0; i < key_info->user_defined_key_parts; i++) { Field *fld= key_info->key_part[i].field; - if (fld->eq(f2->field)) + if (fld->eq(f1->field)) { - cmp= -1; + cmp= -1; // f1 is better break; } - if (fld->eq(f1->field)) + if (fld->eq(f2->field)) { - cmp= 1; + cmp= 1; // f2 is better break; } } } } - else - cmp= f2->field->field_index-f1->field->field_index; + if (!cmp) + cmp= f1->field->field_index-f2->field->field_index; } return cmp < 0 ? -1 : (cmp ? 1 : 0); } @@ -15973,6 +15984,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::NULL_ITEM: case Item::VARBIN_ITEM: case Item::CACHE_ITEM: + case Item::WINDOW_FUNC_ITEM: // psergey-winfunc: case Item::EXPR_CACHE_ITEM: if (make_copy_field) { @@ -16249,7 +16261,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, reclength= string_total_length= 0; blob_count= string_count= null_count= hidden_null_count= group_null_items= 0; - param->using_indirect_summary_function=0; + param->using_outer_summary_function= 0; List_iterator_fast<Item> li(fields); Item *item; @@ -16271,7 +16283,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, function. We need to know this if someone is going to use DISTINCT on the result. */ - param->using_indirect_summary_function=1; + param->using_outer_summary_function=1; continue; } } @@ -16885,13 +16897,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, if (!do_not_open) { - if (share->db_type() == TMP_ENGINE_HTON) - { - if (create_internal_tmp_table(table, param->keyinfo, param->start_recinfo, - ¶m->recinfo, select_options)) - goto err; - } - if (open_tmp_table(table)) + if (instantiate_tmp_table(table, param->keyinfo, param->start_recinfo, + ¶m->recinfo, select_options)) goto err; } @@ -17032,9 +17039,9 @@ bool open_tmp_table(TABLE *table) } table->db_stat= HA_OPEN_KEYFILE+HA_OPEN_RNDFILE; (void) table->file->extra(HA_EXTRA_QUICK); /* Faster */ - if (!table->created) + if (!table->is_created()) { - table->created= TRUE; + table->set_created(); table->in_use->inc_status_created_tmp_tables(); } @@ -17240,7 +17247,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, table->in_use->inc_status_created_tmp_tables(); table->in_use->query_plan_flags|= QPLAN_TMP_DISK; share->db_record_offset= 1; - table->created= TRUE; + table->set_created(); DBUG_RETURN(0); err: DBUG_RETURN(1); @@ -17558,7 +17565,7 @@ free_tmp_table(THD *thd, TABLE *entry) save_proc_info=thd->proc_info; THD_STAGE_INFO(thd, stage_removing_tmp_table); - if (entry->file && entry->created) + if (entry->file && entry->is_created()) { entry->file->ha_index_or_rnd_end(); if (entry->db_stat) @@ -17586,81 +17593,101 @@ free_tmp_table(THD *thd, TABLE *entry) /** - @details - Rows produced by a join sweep may end up in a temporary table or be sent - to a client. Setup the function of the nested loop join algorithm which - handles final fully constructed and matched records. + @brief + Set write_func of AGGR_OP object - @param join join to setup the function for. + @param join_tab JOIN_TAB of the corresponding tmp table - @return - end_select function to use. This function can't fail. + @details + Function sets up write_func according to how AGGR_OP object that + is attached to the given join_tab will be used in the query. */ -Next_select_func setup_end_select_func(JOIN *join) +void set_postjoin_aggr_write_func(JOIN_TAB *tab) { - TABLE *table= join->tmp_table; - TMP_TABLE_PARAM *tmp_tbl= &join->tmp_table_param; - Next_select_func end_select; + JOIN *join= tab->join; + TABLE *table= tab->table; + AGGR_OP *aggr= tab->aggr; + TMP_TABLE_PARAM *tmp_tbl= tab->tmp_table_param; - /* Set up select_end */ - if (table) + DBUG_ASSERT(table && aggr); + + if (table->group && tmp_tbl->sum_func_count && + !tmp_tbl->precomputed_group_by) { - if (table->group && tmp_tbl->sum_func_count && - !tmp_tbl->precomputed_group_by) - { - if (table->s->keys) - { - DBUG_PRINT("info",("Using end_update")); - end_select=end_update; - } - else - { - DBUG_PRINT("info",("Using end_unique_update")); - end_select=end_unique_update; - } - } - else if (join->sort_and_group && !tmp_tbl->precomputed_group_by) + /* + Note for MyISAM tmp tables: if uniques is true keys won't be + created. + */ + if (table->s->keys && !table->s->uniques) { - DBUG_PRINT("info",("Using end_write_group")); - end_select=end_write_group; + DBUG_PRINT("info",("Using end_update")); + aggr->set_write_func(end_update); } else { - DBUG_PRINT("info",("Using end_write")); - end_select=end_write; - if (tmp_tbl->precomputed_group_by) - { - /* - A preceding call to create_tmp_table in the case when loose - index scan is used guarantees that - TMP_TABLE_PARAM::items_to_copy has enough space for the group - by functions. It is OK here to use memcpy since we copy - Item_sum pointers into an array of Item pointers. - */ - memcpy(tmp_tbl->items_to_copy + tmp_tbl->func_count, - join->sum_funcs, - sizeof(Item*)*tmp_tbl->sum_func_count); - tmp_tbl->items_to_copy[tmp_tbl->func_count+tmp_tbl->sum_func_count]= 0; - } + DBUG_PRINT("info",("Using end_unique_update")); + aggr->set_write_func(end_unique_update); } } + else if (join->sort_and_group && !tmp_tbl->precomputed_group_by && + !join->sort_and_group_aggr_tab) + { + DBUG_PRINT("info",("Using end_write_group")); + aggr->set_write_func(end_write_group); + join->sort_and_group_aggr_tab= tab; + } else { - /* - Choose method for presenting result to user. Use end_send_group - if the query requires grouping (has a GROUP BY clause and/or one or - more aggregate functions). Use end_send if the query should not - be grouped. - */ - if ((join->sort_and_group || - (join->procedure && join->procedure->flags & PROC_GROUP)) && - !tmp_tbl->precomputed_group_by) - end_select= end_send_group; - else - end_select= end_send; + DBUG_PRINT("info",("Using end_write")); + aggr->set_write_func(end_write); + if (tmp_tbl->precomputed_group_by) + { + /* + A preceding call to create_tmp_table in the case when loose + index scan is used guarantees that + TMP_TABLE_PARAM::items_to_copy has enough space for the group + by functions. It is OK here to use memcpy since we copy + Item_sum pointers into an array of Item pointers. + */ + memcpy(tmp_tbl->items_to_copy + tmp_tbl->func_count, + join->sum_funcs, + sizeof(Item*)*tmp_tbl->sum_func_count); + tmp_tbl->items_to_copy[tmp_tbl->func_count+tmp_tbl->sum_func_count]= 0; + } + } +} + + +/** + @details + Rows produced by a join sweep may end up in a temporary table or be sent + to a client. Set the function of the nested loop join algorithm which + handles final fully constructed and matched records. + + @param join join to setup the function for. + + @return + end_select function to use. This function can't fail. +*/ + +Next_select_func setup_end_select_func(JOIN *join, JOIN_TAB *tab) +{ + TMP_TABLE_PARAM *tmp_tbl= tab ? tab->tmp_table_param : &join->tmp_table_param; + + /* + Choose method for presenting result to user. Use end_send_group + if the query requires grouping (has a GROUP BY clause and/or one or + more aggregate functions). Use end_send if the query should not + be grouped. + */ + if (join->sort_and_group && !tmp_tbl->precomputed_group_by) + { + DBUG_PRINT("info",("Using end_send_group")); + return end_send_group; } - return end_select; + DBUG_PRINT("info",("Using end_send")); + return end_send; } @@ -17676,19 +17703,13 @@ Next_select_func setup_end_select_func(JOIN *join) */ static int -do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) +do_select(JOIN *join, Procedure *procedure) { int rc= 0; enum_nested_loop_state error= NESTED_LOOP_OK; - JOIN_TAB *UNINIT_VAR(join_tab); DBUG_ENTER("do_select"); - - join->procedure=procedure; - join->tmp_table= table; /* Save for easy recursion */ - join->fields= fields; - join->do_select_call_count++; - if (join->pushdown_query && join->do_select_call_count == 1) + if (join->pushdown_query) { /* Select fields are in the temporary table */ join->fields= &join->tmp_fields_list1; @@ -17696,34 +17717,33 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) join->set_items_ref_array(join->items1); /* The storage engine will take care of the group by query result */ int res= join->pushdown_query->execute(join); - DBUG_RETURN(res); - } - if (table) - { - (void) table->file->extra(HA_EXTRA_WRITE_CACHE); - empty_record(table); - if (table->group && join->tmp_table_param.sum_func_count && - table->s->keys && !table->file->inited) + if (res) + DBUG_RETURN(res); + + if (join->pushdown_query->store_data_in_temp_table) { - rc= table->file->ha_index_init(0, 0); - if (rc) - { - table->file->print_error(rc, MYF(0)); - DBUG_RETURN(-1); - } + JOIN_TAB *last_tab= join->join_tab + join->table_count; + last_tab->next_select= end_send; + + enum_nested_loop_state state= last_tab->aggr->end_send(); + if (state >= NESTED_LOOP_OK) + state= sub_select(join, last_tab, true); + + if (state < NESTED_LOOP_OK) + res= 1; + + if (join->result->send_eof()) + res= 1; } + DBUG_RETURN(res); } - /* Set up select_end */ - Next_select_func end_select= setup_end_select_func(join); - if (join->table_count) - { - join->join_tab[join->top_join_tab_count - 1].next_select= end_select; - join_tab=join->join_tab+join->const_tables; - } + + join->procedure= procedure; join->send_records=0; - if (join->table_count == join->const_tables) + if (join->only_const_tables() && !join->need_tmp) { + Next_select_func end_select= setup_end_select_func(join, NULL); /* HAVING will be checked after processing aggregate functions, But WHERE should checked here (we alredy have read tables). @@ -17735,8 +17755,9 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) DBUG_ASSERT(join->outer_ref_cond == NULL); if (!join->pseudo_bits_cond || join->pseudo_bits_cond->val_int()) { + // HAVING will be checked by end_select error= (*end_select)(join, 0, 0); - if (error == NESTED_LOOP_OK || error == NESTED_LOOP_QUERY_LIMIT) + if (error >= NESTED_LOOP_OK) error= (*end_select)(join, 0, 1); /* @@ -17752,7 +17773,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) if (!join->having || join->having->val_int()) { List<Item> *columns_list= (procedure ? &join->procedure_fields_list : - fields); + join->fields); rc= join->result->send_data(*columns_list) > 0; } } @@ -17766,8 +17787,6 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) } else { - DBUG_ASSERT(join->table_count); - DBUG_EXECUTE_IF("show_explain_probe_do_select", if (dbug_user_var_equals_int(join->thd, "show_explain_probe_select_id", @@ -17775,15 +17794,13 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) dbug_serve_apcs(join->thd, 1); ); + JOIN_TAB *join_tab= join->join_tab + join->const_tables; if (join->outer_ref_cond && !join->outer_ref_cond->val_int()) error= NESTED_LOOP_NO_MORE_ROWS; else - error= sub_select(join,join_tab,0); - if ((error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS) && - join->thd->killed != ABORT_QUERY) - error= sub_select(join,join_tab,1); - if (error == NESTED_LOOP_QUERY_LIMIT) - error= NESTED_LOOP_OK; /* select_limit used */ + error= join->first_select(join,join_tab,0); + if (error >= NESTED_LOOP_OK && join->thd->killed != ABORT_QUERY) + error= join->first_select(join,join_tab,1); } join->thd->limit_found_rows= join->send_records; @@ -17791,23 +17808,37 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) if (error == NESTED_LOOP_NO_MORE_ROWS || join->thd->killed == ABORT_QUERY) error= NESTED_LOOP_OK; - if (table) + /* + For "order by with limit", we cannot rely on send_records, but need + to use the rowcount read originally into the join_tab applying the + filesort. There cannot be any post-filtering conditions, nor any + following join_tabs in this case, so this rowcount properly represents + the correct number of qualifying rows. + */ + if (join->order) { - int tmp, new_errno= 0; - if ((tmp=table->file->extra(HA_EXTRA_NO_CACHE))) + // Save # of found records prior to cleanup + JOIN_TAB *sort_tab; + JOIN_TAB *join_tab= join->join_tab; + uint const_tables= join->const_tables; + + // Take record count from first non constant table or from last tmp table + if (join->aggr_tables > 0) + sort_tab= join_tab + join->top_join_tab_count + join->aggr_tables - 1; + else { - DBUG_PRINT("error",("extra(HA_EXTRA_NO_CACHE) failed")); - new_errno= tmp; + DBUG_ASSERT(!join->only_const_tables()); + sort_tab= join_tab + const_tables; } - if ((tmp=table->file->ha_index_or_rnd_end())) + if (sort_tab->filesort && + join->select_options & OPTION_FOUND_ROWS && + sort_tab->filesort->sortorder && + sort_tab->filesort->limit != HA_POS_ERROR) { - DBUG_PRINT("error",("ha_index_or_rnd_end() failed")); - new_errno= tmp; + join->thd->limit_found_rows= sort_tab->records; } - if (new_errno) - table->file->print_error(new_errno,MYF(0)); } - else + { /* The following will unlock all cursors if the command wasn't an @@ -17821,11 +17852,8 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) Sic: this branch works even if rc != 0, e.g. when send_data above returns an error. */ - if (!table) // If sending data to client - { - if (join->result->send_eof()) - rc= 1; // Don't send error - } + if (join->result->send_eof()) + rc= 1; // Don't send error DBUG_PRINT("info",("%ld records output", (long) join->send_records)); } else @@ -17836,7 +17864,8 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) DBUG_PRINT("error",("Error: do_select() failed")); } #endif - DBUG_RETURN(join->thd->is_error() ? -1 : rc); + rc= join->thd->is_error() ? -1 : rc; + DBUG_RETURN(rc); } @@ -17853,6 +17882,106 @@ int rr_sequential_and_unpack(READ_RECORD *info) } +/** + @brief + Instantiates temporary table + + @param table Table object that describes the table to be + instantiated + @param keyinfo Description of the index (there is always one index) + @param start_recinfo Column descriptions + @param recinfo INOUT End of column descriptions + @param options Option bits + + @details + Creates tmp table and opens it. + + @return + FALSE - OK + TRUE - Error +*/ + +static +bool instantiate_tmp_table(TABLE *table, KEY *keyinfo, + MARIA_COLUMNDEF *start_recinfo, + MARIA_COLUMNDEF **recinfo, + ulonglong options) +{ + if (table->s->db_type() == TMP_ENGINE_HTON) + { + if (create_internal_tmp_table(table, keyinfo, start_recinfo, recinfo, + options)) + return TRUE; + // Make empty record so random data is not written to disk + empty_record(table); + } + if (open_tmp_table(table)) + return TRUE; + + return FALSE; +} + + +/** + @brief + Accumulate rows of the result of an aggregation operation in a tmp table + + @param join pointer to the structure providing all context info for the query + @param join_tab the JOIN_TAB object to which the operation is attached + @param end_records TRUE <=> all records were accumulated, send them further + + @details + This function accumulates records of the aggreagation operation for + the node join_tab from the execution plan in a tmp table. To add a new + record the function calls join_tab->aggr->put_records. + When there is no more records to save, in this + case the end_of_records argument == true, function tells the operation to + send records further by calling aggr->send_records(). + When all records are sent this function passes 'end_of_records' signal + further by calling sub_select() with end_of_records argument set to + true. After that aggr->end_send() is called to tell the operation that + it could end internal buffer scan. + + @note + This function is not expected to be called when dynamic range scan is + used to scan join_tab because range scans aren't used for tmp tables. + + @return + return one of enum_nested_loop_state. +*/ + +enum_nested_loop_state +sub_select_postjoin_aggr(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) +{ + enum_nested_loop_state rc; + AGGR_OP *aggr= join_tab->aggr; + + /* This function cannot be called if join_tab has no associated aggregation */ + DBUG_ASSERT(aggr != NULL); + + DBUG_ENTER("sub_select_aggr_tab"); + + if (join->thd->killed) + { + /* The user has aborted the execution of the query */ + join->thd->send_kill_message(); + DBUG_RETURN(NESTED_LOOP_KILLED); + } + + if (end_of_records) + { + rc= aggr->end_send(); + if (rc >= NESTED_LOOP_OK) + rc= sub_select(join, join_tab, end_of_records); + DBUG_RETURN(rc); + } + + rc= aggr->put_record(); + + DBUG_RETURN(rc); +} + + /* Fill the join buffer with partial records, retrieve all full matches for them @@ -17906,7 +18035,8 @@ sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) if (end_of_records) { rc= cache->join_records(FALSE); - if (rc == NESTED_LOOP_OK || rc == NESTED_LOOP_NO_MORE_ROWS) + if (rc == NESTED_LOOP_OK || rc == NESTED_LOOP_NO_MORE_ROWS || + rc == NESTED_LOOP_QUERY_LIMIT) rc= sub_select(join, join_tab, end_of_records); DBUG_RETURN(rc); } @@ -17933,7 +18063,8 @@ sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) without it. If it's not the case remove it. */ rc= cache->join_records(TRUE); - if (rc == NESTED_LOOP_OK || rc == NESTED_LOOP_NO_MORE_ROWS) + if (rc == NESTED_LOOP_OK || rc == NESTED_LOOP_NO_MORE_ROWS || + rc == NESTED_LOOP_QUERY_LIMIT) rc= sub_select(join, join_tab, end_of_records); DBUG_RETURN(rc); } @@ -18020,7 +18151,7 @@ sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) is the same as the value of the predicate, otherwise it's just returns true. To carry out a return to a nested loop level of join table t the pointer - to t is remembered in the field 'return_tab' of the join structure. + to t is remembered in the field 'return_rtab' of the join structure. Consider the following query: @code SELECT * FROM t1, @@ -18083,7 +18214,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) int error; enum_nested_loop_state rc= NESTED_LOOP_OK; READ_RECORD *info= &join_tab->read_record; - + + for (SJ_TMP_TABLE *flush_dups_table= join_tab->flush_weedout_table; flush_dups_table; flush_dups_table= flush_dups_table->next_flush_table) @@ -18174,7 +18306,6 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) DBUG_RETURN(rc); } - /** @brief Process one row of the nested loop join. @@ -18236,6 +18367,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, condition is true => a match is found. */ join_tab->tracker->r_rows_after_where++; + bool found= 1; while (join_tab->first_unmatched && found) { @@ -18577,11 +18709,11 @@ join_read_const_table(THD *thd, JOIN_TAB *tab, POSITION *pos) !table->no_keyread && (int) table->reginfo.lock_type <= (int) TL_READ_HIGH_PRIORITY) { - table->enable_keyread(); + table->set_keyread(true); tab->index= tab->ref.key; } error=join_read_const(tab); - table->disable_keyread(); + table->set_keyread(false); if (error) { tab->info= ET_UNIQUE_ROW_NOT_FOUND; @@ -19028,12 +19160,26 @@ bool test_if_use_dynamic_range_scan(JOIN_TAB *join_tab) int join_init_read_record(JOIN_TAB *tab) { - if (tab->select && tab->select->quick && tab->select->quick->reset()) + int error; + /* + Note: the query plan tree for the below operations is constructed in + save_agg_explain_data. + */ + if (tab->distinct && tab->remove_duplicates()) // Remove duplicates. + return 1; + if (tab->filesort && tab->sort_table()) // Sort table. return 1; + + if (tab->select && tab->select->quick && (error= tab->select->quick->reset())) + { + /* Ensures error status is propageted back to client */ + report_error(tab->table, error); + return 1; + } if (!tab->preread_init_done && tab->preread_init()) return 1; if (init_read_record(&tab->read_record, tab->join->thd, tab->table, - tab->select, tab->filesort, 1,1, FALSE)) + tab->select, tab->filesort_result, 1,1, FALSE)) return 1; return (*tab->read_record.read_record)(&tab->read_record); } @@ -19051,7 +19197,7 @@ join_read_record_no_init(JOIN_TAB *tab) save_copy_end= tab->read_record.copy_field_end; init_read_record(&tab->read_record, tab->join->thd, tab->table, - tab->select, tab->filesort, 1, 1, FALSE); + tab->select, tab->filesort_result, 1, 1, FALSE); tab->read_record.copy_field= save_copy; tab->read_record.copy_field_end= save_copy_end; @@ -19060,6 +19206,25 @@ join_read_record_no_init(JOIN_TAB *tab) return (*tab->read_record.read_record)(&tab->read_record); } + +/* + Helper function for sorting table with filesort. +*/ + +bool +JOIN_TAB::sort_table() +{ + int rc; + DBUG_PRINT("info",("Sorting for index")); + THD_STAGE_INFO(join->thd, stage_creating_sort_index); + DBUG_ASSERT(join->ordered_index_usage != (filesort->order == join->order ? + JOIN::ordered_index_order_by : + JOIN::ordered_index_group_by)); + rc= create_sort_index(join->thd, join, this, NULL); + return (rc != 0); +} + + static int join_read_first(JOIN_TAB *tab) { @@ -19069,7 +19234,7 @@ join_read_first(JOIN_TAB *tab) if (table->covering_keys.is_set(tab->index) && !table->no_keyread && !table->key_read) - table->enable_keyread(); + table->set_keyread(true); tab->table->status=0; tab->read_record.read_record=join_read_next; tab->read_record.table=table; @@ -19109,7 +19274,7 @@ join_read_last(JOIN_TAB *tab) if (table->covering_keys.is_set(tab->index) && !table->no_keyread && !table->key_read) - table->enable_keyread(); + table->set_keyread(true); tab->table->status=0; tab->read_record.read_record=join_read_prev; tab->read_record.table=table; @@ -19233,16 +19398,21 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records) { DBUG_ENTER("end_send"); + /* + When all tables are const this function is called with jointab == NULL. + This function shouldn't be called for the first join_tab as it needs + to get fields from previous tab. + */ + DBUG_ASSERT(join_tab == NULL || join_tab != join->join_tab); + //TODO pass fields via argument + List<Item> *fields= join_tab ? (join_tab-1)->fields : join->fields; + if (!end_of_records) { +#if 0 +#endif if (join->table_count && - (join->join_tab->is_using_loose_index_scan() || - /* - When order by used a loose scan as its input, the quick select may - be attached to pre_sort_join_tab. - */ - (join->pre_sort_join_tab && - join->pre_sort_join_tab->is_using_loose_index_scan()))) + join->join_tab->is_using_loose_index_scan()) { /* Copy non-aggregated fields when loose index scan is used. */ copy_fields(&join->tmp_table_param); @@ -19259,7 +19429,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { int error; /* result < 0 if row was not accepted and should not be counted */ - if ((error= join->result->send_data(*join->fields))) + if ((error= join->result->send_data(*fields))) DBUG_RETURN(error < 0 ? NESTED_LOOP_OK : NESTED_LOOP_ERROR); } @@ -19268,13 +19438,15 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), !join->do_send_rows) { /* - If filesort is used for sorting, stop after select_limit_cnt+1 - records are read. Because of optimization in some cases it can - provide only select_limit_cnt+1 records. + If we have used Priority Queue for optimizing order by with limit, + then stop here, there are no more records to consume. + When this optimization is used, end_send is called on the next + join_tab. */ - if (join->order && join->sortorder && - join->filesort_found_rows && - join->select_options & OPTION_FOUND_ROWS) + if (join->order && + join->select_options & OPTION_FOUND_ROWS && + join_tab > join->join_tab && + (join_tab - 1)->filesort && (join_tab - 1)->filesort->using_pq) { DBUG_PRINT("info", ("filesort NESTED_LOOP_QUERY_LIMIT")); DBUG_RETURN(NESTED_LOOP_QUERY_LIMIT); @@ -19286,7 +19458,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), if (join->select_options & OPTION_FOUND_ROWS) { JOIN_TAB *jt=join->join_tab; - if ((join->table_count == 1) && !join->tmp_table && !join->sort_and_group + if ((join->table_count == 1) && !join->sort_and_group && !join->send_group_parts && !join->having && !jt->select_cond && !(jt->select && jt->select->quick) && (jt->table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) && @@ -19295,10 +19467,9 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), /* Join over all rows in table; Return number of found rows */ TABLE *table=jt->table; - join->select_options ^= OPTION_FOUND_ROWS; - if (jt->filesort) // If filesort was used + if (jt->filesort_result) // If filesort was used { - join->send_records= jt->filesort->found_rows; + join->send_records= jt->filesort_result->found_rows; } else { @@ -19349,13 +19520,21 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { int idx= -1; enum_nested_loop_state ok_code= NESTED_LOOP_OK; + List<Item> *fields= join_tab ? (join_tab-1)->fields : join->fields; DBUG_ENTER("end_send_group"); + if (!join->items3.is_null() && !join->set_group_rpa) + { + join->set_group_rpa= true; + join->set_items_ref_array(join->items3); + } + if (!join->first_record || end_of_records || (idx=test_if_group_changed(join->group_fields)) >= 0) { - if (join->first_record || - (end_of_records && !join->group && !join->group_optimized_away)) + if (!join->group_sent && + (join->first_record || + (end_of_records && !join->group && !join->group_optimized_away))) { if (join->procedure) join->procedure->end_group(); @@ -19369,7 +19548,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), else { if (join->do_send_rows) - error=join->procedure->send_row(*join->fields) ? 1 : 0; + error=join->procedure->send_row(*fields) ? 1 : 0; join->send_records++; } if (end_of_records && join->procedure->end_of_records()) @@ -19381,11 +19560,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { List_iterator_fast<Item> it(*join->fields); Item *item; - DBUG_PRINT("info", ("no matching rows")); - - /* No matching rows for group function */ - join->clear(); - join->no_rows_in_result_called= 1; + /* No matching rows for group function */ + join->clear(); while ((item= it++)) item->no_rows_in_result(); @@ -19396,7 +19572,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { if (join->do_send_rows) { - error= join->result->send_data(*join->fields); + error=join->result->send_data(*fields); if (error < 0) { /* Duplicate row, don't count */ @@ -19405,6 +19581,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), } } join->send_records++; + join->group_sent= true; } if (join->rollup.state != ROLLUP::STATE_NONE && error <= 0) { @@ -19456,6 +19633,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), DBUG_RETURN(NESTED_LOOP_ERROR); if (join->procedure) join->procedure->add(); + join->group_sent= false; DBUG_RETURN(ok_code); } } @@ -19472,16 +19650,16 @@ static enum_nested_loop_state end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records) { - TABLE *table=join->tmp_table; + TABLE *const table= join_tab->table; DBUG_ENTER("end_write"); if (!end_of_records) { - copy_fields(&join->tmp_table_param); - if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd)) + copy_fields(join_tab->tmp_table_param); + if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd)) DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ - if (!join->having || join->having->val_int()) + if (!join_tab->having || join_tab->having->val_int()) { int error; join->found_records++; @@ -19491,15 +19669,16 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), goto end; bool is_duplicate; if (create_internal_tmp_table_from_heap(join->thd, table, - join->tmp_table_param.start_recinfo, - &join->tmp_table_param.recinfo, + join_tab->tmp_table_param->start_recinfo, + &join_tab->tmp_table_param->recinfo, error, 1, &is_duplicate)) DBUG_RETURN(NESTED_LOOP_ERROR); // Not a table_is_full error if (is_duplicate) goto end; table->s->uniques=0; // To ensure rows are the same } - if (++join->send_records >= join->tmp_table_param.end_write_records && + if (++join_tab->send_records >= + join_tab->tmp_table_param->end_write_records && join->do_send_rows) { if (!(join->select_options & OPTION_FOUND_ROWS)) @@ -19534,7 +19713,7 @@ static enum_nested_loop_state end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records) { - TABLE *table=join->tmp_table; + TABLE *const table= join_tab->table; ORDER *group; int error; DBUG_ENTER("end_update"); @@ -19543,7 +19722,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), DBUG_RETURN(NESTED_LOOP_OK); join->found_records++; - copy_fields(&join->tmp_table_param); // Groups are copied twice. + copy_fields(join_tab->tmp_table_param); // Groups are copied twice. /* Make a key of group index */ for (group=table->group ; group ; group=group->next) { @@ -19563,7 +19742,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), group->buff[-1]= (char) group->field->is_null(); } if (!table->file->ha_index_read_map(table->record[1], - join->tmp_table_param.group_buff, + join_tab->tmp_table_param->group_buff, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { /* Update old record */ @@ -19579,13 +19758,13 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), } init_tmptable_sum_functions(join->sum_funcs); - if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd)) + if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd)) DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ if ((error= table->file->ha_write_tmp_row(table->record[0]))) { if (create_internal_tmp_table_from_heap(join->thd, table, - join->tmp_table_param.start_recinfo, - &join->tmp_table_param.recinfo, + join_tab->tmp_table_param->start_recinfo, + &join_tab->tmp_table_param->recinfo, error, 0, NULL)) DBUG_RETURN(NESTED_LOOP_ERROR); // Not a table_is_full error /* Change method to update rows */ @@ -19595,9 +19774,9 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), DBUG_RETURN(NESTED_LOOP_ERROR); } - join->join_tab[join->top_join_tab_count-1].next_select=end_unique_update; + join_tab->aggr->set_write_func(end_unique_update); } - join->send_records++; + join_tab->send_records++; end: if (join->thd->check_killed()) { @@ -19614,7 +19793,7 @@ static enum_nested_loop_state end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records) { - TABLE *table=join->tmp_table; + TABLE *table= join_tab->table; int error; DBUG_ENTER("end_unique_update"); @@ -19622,12 +19801,12 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), DBUG_RETURN(NESTED_LOOP_OK); init_tmptable_sum_functions(join->sum_funcs); - copy_fields(&join->tmp_table_param); // Groups are copied twice. - if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd)) + copy_fields(join_tab->tmp_table_param); // Groups are copied twice. + if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd)) DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ if (!(error= table->file->ha_write_tmp_row(table->record[0]))) - join->send_records++; // New group + join_tab->send_records++; // New group else { if ((int) table->file->get_dup_key(error) < 0) @@ -19673,7 +19852,7 @@ enum_nested_loop_state end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records) { - TABLE *table=join->tmp_table; + TABLE *table= join_tab->table; int idx= -1; DBUG_ENTER("end_write_group"); @@ -19687,21 +19866,21 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), int send_group_parts= join->send_group_parts; if (idx < send_group_parts) { - if (!join->first_record) - { - /* No matching rows for group function */ - join->clear(); - } + if (!join->first_record) + { + /* No matching rows for group function */ + join->clear(); + } copy_sum_funcs(join->sum_funcs, join->sum_funcs_end[send_group_parts]); - if (!join->having || join->having->val_int()) + if (!join_tab->having || join_tab->having->val_int()) { int error= table->file->ha_write_tmp_row(table->record[0]); if (error && create_internal_tmp_table_from_heap(join->thd, table, - join->tmp_table_param.start_recinfo, - &join->tmp_table_param.recinfo, - error, 0, NULL)) + join_tab->tmp_table_param->start_recinfo, + &join_tab->tmp_table_param->recinfo, + error, 0, NULL)) DBUG_RETURN(NESTED_LOOP_ERROR); } if (join->rollup.state != ROLLUP::STATE_NONE) @@ -19722,8 +19901,8 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), } if (idx < (int) join->send_group_parts) { - copy_fields(&join->tmp_table_param); - if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd)) + copy_fields(join_tab->tmp_table_param); + if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd)) DBUG_RETURN(NESTED_LOOP_ERROR); if (init_sum_functions(join->sum_funcs, join->sum_funcs_end[idx+1])) DBUG_RETURN(NESTED_LOOP_ERROR); @@ -20281,9 +20460,11 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, if (key_part->field != field || !field->part_of_sortkey.is_set(idx)) DBUG_RETURN(0); + const ORDER::enum_order keypart_order= + (key_part->key_part_flag & HA_REVERSE_SORT) ? + ORDER::ORDER_DESC : ORDER::ORDER_ASC; /* set flag to 1 if we can use read-next on key, else to -1 */ - flag= ((order->asc == !(key_part->key_part_flag & HA_REVERSE_SORT)) ? - 1 : -1); + flag= (order->direction == keypart_order) ? 1 : -1; if (reverse && flag != reverse) DBUG_RETURN(0); reverse=flag; // Remember if reverse @@ -20856,11 +21037,11 @@ check_reverse_order: and best_key doesn't, then revert the decision. */ if (!table->covering_keys.is_set(best_key)) - table->disable_keyread(); + table->set_keyread(false); else { if (!table->key_read) - table->enable_keyread(); + table->set_keyread(true); } if (!quick_created) @@ -20891,7 +21072,7 @@ check_reverse_order: tab->ref.key_parts= 0; if (select_limit < table->stat_records()) tab->limit= select_limit; - table->disable_keyread(); + table->set_keyread(false); } } else if (tab->type != JT_ALL || tab->select->quick) @@ -21015,14 +21196,9 @@ use_filesort: create_sort_index() thd Thread handler join Join with table to sort - order How table should be sorted - filesort_limit Max number of rows that needs to be sorted - select_limit Max number of rows in final output - Used to decide if we should use index or not - is_order_by true if we are sorting on ORDER BY, false if GROUP BY - Used to decide if we should use index or not - - + join_tab What table to sort + fsort Filesort object. NULL means "use tab->filesort". + IMPLEMENTATION - If there is an index that can be used, the first non-const join_tab in 'join' is modified to use this index. @@ -21036,150 +21212,72 @@ use_filesort: 1 No records */ -static int -create_sort_index(THD *thd, JOIN *join, ORDER *order, - ha_rows filesort_limit, ha_rows select_limit, - bool is_order_by) +int +create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort) { - uint length; TABLE *table; SQL_SELECT *select; - JOIN_TAB *tab; bool quick_created= FALSE; SORT_INFO *file_sort= 0; DBUG_ENTER("create_sort_index"); - if (join->table_count == join->const_tables) - DBUG_RETURN(0); // One row, no need to sort - tab= join->join_tab + join->const_tables; - table= tab->table; - select= tab->select; - - JOIN_TAB *save_pre_sort_join_tab= NULL; - if (join->pre_sort_join_tab) - { - /* - we've already been in this function, and stashed away the - original access method in join->pre_sort_join_tab, restore it - now. - */ - - /* First, restore state of the handler */ - if (join->pre_sort_index != MAX_KEY) - { - if (table->file->ha_index_or_rnd_end()) - goto err; - if (join->pre_sort_idx_pushed_cond) - { - table->file->idx_cond_push(join->pre_sort_index, - join->pre_sort_idx_pushed_cond); - } - } - else - { - if (table->file->ha_index_or_rnd_end() || - table->file->ha_rnd_init(TRUE)) - goto err; - } - - /* Second, restore access method parameters */ - tab->records= join->pre_sort_join_tab->records; - tab->select= join->pre_sort_join_tab->select; - tab->select_cond= join->pre_sort_join_tab->select_cond; - tab->type= join->pre_sort_join_tab->type; - tab->read_first_record= join->pre_sort_join_tab->read_first_record; - - save_pre_sort_join_tab= join->pre_sort_join_tab; - join->pre_sort_join_tab= NULL; - } - else - { - /* - Save index #, save index condition. Do it right now, because MRR may - */ - if (table->file->inited == handler::INDEX) - { - join->pre_sort_index= table->file->active_index; - join->pre_sort_idx_pushed_cond= table->file->pushed_idx_cond; - // no need to save key_read - } - else - join->pre_sort_index= MAX_KEY; - } + if (fsort == NULL) + fsort= tab->filesort; + table= tab->table; + select= fsort->select; + /* Currently ORDER BY ... LIMIT is not supported in subqueries. */ DBUG_ASSERT(join->group_list || !join->is_in_subquery()); - /* - When there is SQL_BIG_RESULT do not sort using index for GROUP BY, - and thus force sorting on disk unless a group min-max optimization - is going to be used as it is applied now only for one table queries - with covering indexes. - The expections is if we are already using the index for GROUP BY - (in which case sort would be free) or ORDER and GROUP BY are different. - */ - if ((order != join->group_list || - !(join->select_options & SELECT_BIG_RESULT) || - (select && select->quick && - select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) && - test_if_skip_sort_order(tab,order,select_limit,0, - is_order_by ? &table->keys_in_use_for_order_by : - &table->keys_in_use_for_group_by)) - { - tab->update_explain_data(join->const_tables); - DBUG_RETURN(0); - } - tab->update_explain_data(join->const_tables); - - /* - Calculate length of join->order as this may be longer than 'order', - which may come from 'group by'. This is needed as join->sortorder is - used both for grouping and ordering. - */ - length= 0; - for (ORDER *ord= join->order; ord; ord= ord->next) - length++; - - if (!(join->sortorder= - make_unireg_sortorder(thd, order, &length, join->sortorder))) - goto err; /* purecov: inspected */ - table->status=0; // May be wrong if quick_select if (!tab->preread_init_done && tab->preread_init()) goto err; // If table has a range, move it to select - if (select && !select->quick && tab->ref.key >= 0) + if (select && tab->ref.key >= 0) { - if (tab->quick) + if (!select->quick) { - select->quick=tab->quick; - tab->quick=0; + if (tab->quick) + { + select->quick= tab->quick; + tab->quick= NULL; /* We can only use 'Only index' if quick key is same as ref_key and in index_merge 'Only index' cannot be used */ if (((uint) tab->ref.key != select->quick->index)) - table->disable_keyread(); + table->set_keyread(FALSE); + } + else + { + /* + We have a ref on a const; Change this to a range that filesort + can use. + For impossible ranges (like when doing a lookup on NULL on a NOT NULL + field, quick will contain an empty record set. + */ + if (!(select->quick= (tab->type == JT_FT ? + get_ft_select(thd, table, tab->ref.key) : + get_quick_select_for_ref(thd, table, &tab->ref, + tab->found_records)))) + goto err; + quick_created= TRUE; + } + fsort->own_select= true; } else { - /* - We have a ref on a const; Change this to a range that filesort - can use. - For impossible ranges (like when doing a lookup on NULL on a NOT NULL - field, quick will contain an empty record set. - */ - if (!(select->quick= (tab->type == JT_FT ? - get_ft_select(thd, table, tab->ref.key) : - get_quick_select_for_ref(thd, table, &tab->ref, - tab->found_records)))) - goto err; - quick_created= TRUE; + DBUG_ASSERT(tab->type == JT_REF || tab->type == JT_EQ_REF); + // Update ref value + if ((cp_buffer_from_ref(thd, table, &tab->ref) && thd->is_fatal_error)) + goto err; // out of memory } } + /* Fill schema tables with data before filesort if it's necessary */ if ((join->select_lex->options & OPTION_SCHEMA_TABLE) && get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX)) @@ -21187,11 +21285,9 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, if (table->s->tmp_table) table->file->info(HA_STATUS_VARIABLE); // Get record count - file_sort= filesort(thd, table, join->sortorder, length, - select, filesort_limit, 0, - join->explain->ops_tracker.report_sorting(thd)); - DBUG_ASSERT(tab->filesort == 0); - tab->filesort= file_sort; + file_sort= filesort(thd, table, fsort, fsort->tracker); + DBUG_ASSERT(tab->filesort_result == 0); + tab->filesort_result= file_sort; tab->records= 0; if (file_sort) { @@ -21205,42 +21301,18 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, /* This will delete the quick select. */ select->cleanup(); } - - if (!join->pre_sort_join_tab) - { - if (save_pre_sort_join_tab) - join->pre_sort_join_tab= save_pre_sort_join_tab; - else if (!(join->pre_sort_join_tab= (JOIN_TAB*)thd->alloc(sizeof(JOIN_TAB)))) - goto err; - } - - *(join->pre_sort_join_tab)= *tab; - - tab->select=NULL; - tab->set_select_cond(NULL, __LINE__); - tab->type=JT_ALL; // Read with normal read_record - tab->read_first_record= join_init_read_record; - tab->table->file->ha_index_or_rnd_end(); + + table->set_keyread(FALSE); // Restore if we used indexes + if (tab->type == JT_FT) + table->file->ft_end(); + else + table->file->ha_index_or_rnd_end(); DBUG_RETURN(file_sort == 0); err: DBUG_RETURN(-1); } -void JOIN::clean_pre_sort_join_tab() -{ - //TABLE *table= pre_sort_join_tab->table; - /* - Note: we can come here for fake_select_lex object. That object will have - the table already deleted by st_select_lex_unit::cleanup(). - We rely on that fake_select_lex didn't have quick select. - */ - if (pre_sort_join_tab->select && pre_sort_join_tab->select->quick) - { - pre_sort_join_tab->select->cleanup(); - } -} - /** Compare fields from table->record[0] and table->record[1], @@ -21304,22 +21376,28 @@ static void free_blobs(Field **ptr) Rows that do not satisfy 'having' condition are also removed. */ -static int -remove_duplicates(JOIN *join, TABLE *table, List<Item> &fields, Item *having) +bool +JOIN_TAB::remove_duplicates() + { - int error; + bool error; ulong keylength= 0; uint field_count; + List<Item> *fields= (this-1)->fields; THD *thd= join->thd; DBUG_ENTER("remove_duplicates"); - join->explain->ops_tracker.report_duplicate_removal(); + + DBUG_ASSERT(join->aggr_tables > 0 && table->s->tmp_table != NO_TMP_TABLE); + THD_STAGE_INFO(join->thd, stage_removing_duplicates); + + //join->explain->ops_tracker.report_duplicate_removal(); table->reginfo.lock_type=TL_WRITE; /* Calculate how many saved fields there is in list */ field_count=0; - List_iterator<Item> it(fields); + List_iterator<Item> it(*fields); Item *item; while ((item=it++)) { @@ -21330,7 +21408,7 @@ remove_duplicates(JOIN *join, TABLE *table, List<Item> &fields, Item *having) if (!field_count && !(join->select_options & OPTION_FOUND_ROWS) && !having) { // only const items with no OPTION_FOUND_ROWS join->unit->select_limit_cnt= 1; // Only send first row - DBUG_RETURN(0); + DBUG_RETURN(false); } Field **first_field=table->field+table->s->fields - field_count; @@ -21558,67 +21636,9 @@ err: } -SORT_FIELD *make_unireg_sortorder(THD *thd, ORDER *order, uint *length, - SORT_FIELD *sortorder) -{ - uint count; - SORT_FIELD *sort,*pos; - DBUG_ENTER("make_unireg_sortorder"); - - count=0; - for (ORDER *tmp = order; tmp; tmp=tmp->next) - count++; - if (!sortorder) - sortorder= (SORT_FIELD*) thd->alloc(sizeof(SORT_FIELD) * - (MY_MAX(count, *length) + 1)); - pos= sort= sortorder; - - if (!pos) - DBUG_RETURN(0); - - for (;order;order=order->next,pos++) - { - Item *const item= order->item[0], *const real_item= item->real_item(); - pos->field= 0; pos->item= 0; - if (real_item->type() == Item::FIELD_ITEM) - { - // Could be a field, or Item_direct_view_ref wrapping a field - DBUG_ASSERT(item->type() == Item::FIELD_ITEM || - (item->type() == Item::REF_ITEM && - static_cast<Item_ref*>(item)->ref_type() == - Item_ref::VIEW_REF)); - pos->field= static_cast<Item_field*>(real_item)->field; - } - else if (real_item->type() == Item::SUM_FUNC_ITEM && - !real_item->const_item()) - { - // Aggregate, or Item_aggregate_ref - DBUG_ASSERT(item->type() == Item::SUM_FUNC_ITEM || - (item->type() == Item::REF_ITEM && - static_cast<Item_ref*>(item)->ref_type() == - Item_ref::AGGREGATE_REF)); - pos->field= item->get_tmp_table_field(); - } - else if (real_item->type() == Item::COPY_STR_ITEM) - { // Blob patch - pos->item= static_cast<Item_copy*>(real_item)->get_item(); - } - else - pos->item= item; - pos->reverse=! order->asc; - DBUG_ASSERT(pos->field != NULL || pos->item != NULL); - } - *length=count; - DBUG_RETURN(sort); -} - - /* eq_ref: Create the lookup key and check if it is the same as saved key - - - SYNOPSIS cmp_buffer_with_ref() tab Join tab of the accessed table @@ -21715,6 +21735,7 @@ cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref) @param[in,out] all_fields All select, group and order by fields @param[in] is_group_field True if order is a GROUP field, false if ORDER by field + @param[in] search_in_all_fields If true then search in all_fields @retval FALSE if OK @@ -21723,9 +21744,9 @@ cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref) */ static bool -find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, +find_order_in_list(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, ORDER *order, List<Item> &fields, List<Item> &all_fields, - bool is_group_field) + bool is_group_field, bool search_in_all_fields) { Item *order_item= *order->item; /* The item from the GROUP/ORDER caluse. */ Item::Type order_item_type; @@ -21751,7 +21772,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, order_item->full_name(), thd->where); return TRUE; } - thd->change_item_tree((Item**)&order->item, (Item*)(ref_pointer_array + count - 1)); + thd->change_item_tree((Item **)&order->item, (Item *)&ref_pointer_array[count - 1]); order->in_field_list= 1; order->counter= count; order->counter_used= 1; @@ -21811,7 +21832,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, 'shadowed' a table field with the same name, the table field will be chosen over the derived field. */ - order->item= ref_pointer_array + counter; + order->item= &ref_pointer_array[counter]; order->in_field_list=1; return FALSE; } @@ -21830,6 +21851,18 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, thd->where); } } + else if (search_in_all_fields) + { + Item **found_item= find_item_in_list(order_item, all_fields, &counter, + REPORT_EXCEPT_NOT_FOUND, &resolution, + all_fields.elements - fields.elements); + if (found_item != not_found_item) + { + order->item= &ref_pointer_array[all_fields.elements-1-counter]; + order->in_field_list= 0; + return FALSE; + } + } order->in_field_list=0; /* @@ -21850,8 +21883,6 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, return TRUE; /* Wrong field. */ uint el= all_fields.elements; - DBUG_ASSERT(all_fields.elements <= - thd->lex->current_select->ref_pointer_array_size); /* Add new field to field list. */ all_fields.push_front(order_item, thd->mem_root); ref_pointer_array[el]= order_item; @@ -21866,7 +21897,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, if (order_item->type() == Item::SUM_FUNC_ITEM) ((Item_sum *)order_item)->ref_by= all_fields.head_ref(); - order->item= ref_pointer_array + el; + order->item= &ref_pointer_array[el]; return FALSE; } @@ -21878,15 +21909,22 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, the field list. */ -int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, - List<Item> &fields, List<Item> &all_fields, ORDER *order) -{ +int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, + List<Item> &fields, List<Item> &all_fields, ORDER *order, + bool search_in_all_fields) +{ + enum_parsing_place parsing_place= thd->lex->current_select->parsing_place; thd->where="order clause"; for (; order; order=order->next) { if (find_order_in_list(thd, ref_pointer_array, tables, order, fields, - all_fields, FALSE)) + all_fields, FALSE, search_in_all_fields)) + return 1; + if ((*order->item)->with_window_func && parsing_place != IN_ORDER_BY) + { + my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; + } } return 0; } @@ -21895,18 +21933,19 @@ int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, /** Intitialize the GROUP BY list. - @param thd Thread handler - @param ref_pointer_array We store references to all fields that was + @param thd Thread handler + @param ref_pointer_array We store references to all fields that was not in 'fields' here. - @param fields All fields in the select part. Any item in + @param fields All fields in the select part. Any item in 'order' that is part of these list is replaced by a pointer to this fields. - @param all_fields Total list of all unique fields used by the + @param all_fields Total list of all unique fields used by the select. All items in 'order' that was not part of fields will be added first to this list. - @param order The fields we should do GROUP BY on. - @param hidden_group_fields Pointer to flag that is set to 1 if we added + @param order The fields we should do GROUP/PARTITION BY on + @param hidden_group_fields Pointer to flag that is set to 1 if we added any fields to all_fields. + @param search_in_all_fields If true then search in all_fields @todo change ER_WRONG_FIELD_WITH_GROUP to more detailed @@ -21919,10 +21958,11 @@ int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, */ int -setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, +setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, List<Item> &fields, List<Item> &all_fields, ORDER *order, - bool *hidden_group_fields) + bool *hidden_group_fields, bool search_in_all_fields) { + enum_parsing_place parsing_place= thd->lex->current_select->parsing_place; *hidden_group_fields=0; ORDER *ord; @@ -21932,22 +21972,26 @@ setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, uint org_fields=all_fields.elements; thd->where="group statement"; - enum_parsing_place save_place= thd->lex->current_select->parsing_place; - thd->lex->current_select->parsing_place= IN_GROUP_BY; for (ord= order; ord; ord= ord->next) { if (find_order_in_list(thd, ref_pointer_array, tables, ord, fields, - all_fields, TRUE)) + all_fields, TRUE, search_in_all_fields)) return 1; (*ord->item)->marker= UNDEF_POS; /* Mark found */ - if ((*ord->item)->with_sum_func) + if ((*ord->item)->with_sum_func && parsing_place == IN_GROUP_BY) { my_error(ER_WRONG_GROUP_FIELD, MYF(0), (*ord->item)->full_name()); return 1; } + if ((*ord->item)->with_window_func) + { + if (parsing_place == IN_GROUP_BY) + my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0)); + else + my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); + return 1; + } } - thd->lex->current_select->parsing_place= save_place; - if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) { /* @@ -22054,14 +22098,16 @@ setup_new_fields(THD *thd, List<Item> &fields, */ ORDER * -create_distinct_group(THD *thd, Item **ref_pointer_array, +create_distinct_group(THD *thd, Ref_ptr_array ref_pointer_array, ORDER *order_list, List<Item> &fields, List<Item> &all_fields, bool *all_order_by_fields_used) { List_iterator<Item> li(fields); - Item *item, **orig_ref_pointer_array= ref_pointer_array; + Item *item; + Ref_ptr_array orig_ref_pointer_array= ref_pointer_array; ORDER *order,*group,**prev; + uint idx= 0; *all_order_by_fields_used= 1; while ((item=li++)) @@ -22108,16 +22154,14 @@ create_distinct_group(THD *thd, Item **ref_pointer_array, Because HEAP tables can't index BIT fields we need to use an additional hidden field for grouping because later it will be converted to a LONG field. Original field will remain of the - BIT type and will be returned to a client. + BIT type and will be returned [el]client. */ Item_field *new_item= new (thd->mem_root) Item_field(thd, (Item_field*)item); int el= all_fields.elements; - DBUG_ASSERT(all_fields.elements <= - thd->lex->current_select->ref_pointer_array_size); orig_ref_pointer_array[el]= new_item; all_fields.push_front(new_item, thd->mem_root); - ord->item= orig_ref_pointer_array + el; - } + ord->item=&orig_ref_pointer_array[el]; + } else { /* @@ -22125,14 +22169,14 @@ create_distinct_group(THD *thd, Item **ref_pointer_array, simple indexing of ref_pointer_array (order in the array and in the list are same) */ - ord->item= ref_pointer_array; + ord->item= &ref_pointer_array[idx]; } - ord->asc=1; + ord->direction= ORDER::ORDER_ASC; *prev=ord; prev= &ord->next; } next_item: - ref_pointer_array++; + idx++; } *prev=0; return group; @@ -22204,7 +22248,7 @@ test_if_subpart(ORDER *a,ORDER *b) for (; a && b; a=a->next,b=b->next) { if ((*a->item)->eq(*b->item,1)) - a->asc=b->asc; + a->direction=b->direction; else return 0; } @@ -22382,9 +22426,9 @@ make_group_fields(JOIN *main_join, JOIN *curr_join) /** - Get a list of buffers for saveing last group. + Get a list of buffers for saving last group. - Groups are saved in reverse order for easyer check loop. + Groups are saved in reverse order for easier check loop. */ static bool @@ -22435,8 +22479,13 @@ int test_if_item_cache_changed(List<Cached_item> &list) } +/* + @return + -1 - Group not changed + value>=0 - Number of the component where the group changed +*/ -static int +int test_if_group_changed(List<Cached_item> &list) { DBUG_ENTER("test_if_group_changed"); @@ -22485,7 +22534,7 @@ test_if_group_changed(List<Cached_item> &list) bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, - Item **ref_pointer_array, + Ref_ptr_array ref_pointer_array, List<Item> &res_selected_fields, List<Item> &res_all_fields, uint elements, List<Item> &all_fields) { @@ -22714,7 +22763,8 @@ bool JOIN::alloc_func_list() 1 error */ -bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_result_set_metadata, +bool JOIN::make_sum_func_list(List<Item> &field_list, + List<Item> &send_result_set_metadata, bool before_group_by, bool recompute) { List_iterator_fast<Item> it(field_list); @@ -22769,7 +22819,7 @@ bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_result_se */ static bool -change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, +change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &res_selected_fields, List<Item> &res_all_fields, uint elements, List<Item> &all_fields) @@ -22806,14 +22856,6 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, Item_field *new_field= new (thd->mem_root) Item_temptable_field(thd, field); if (!suv || !new_field) DBUG_RETURN(true); // Fatal error - /* - We are replacing the argument of Item_func_set_user_var after - its value has been read. The argument's null_value should be - set by now, so we must set it explicitly for the replacement - argument since the null_value may be read without any - preceeding call to val_*(). - */ - new_field->update_null_value(); List<Item> list; list.push_back(new_field, thd->mem_root); suv->set_arguments(thd, list); @@ -22887,7 +22929,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, */ static bool -change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array, +change_refs_to_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &res_selected_fields, List<Item> &res_all_fields, uint elements, List<Item> &all_fields) @@ -23240,17 +23282,23 @@ bool JOIN::rollup_init() */ tmp_table_param.group_parts= send_group_parts; - if (!(rollup.null_items= (Item_null_result**) thd->alloc((sizeof(Item*) + - sizeof(Item**) + - sizeof(List<Item>) + - ref_pointer_array_size) - * send_group_parts ))) - return 1; - - rollup.fields= (List<Item>*) (rollup.null_items + send_group_parts); - rollup.ref_pointer_arrays= (Item***) (rollup.fields + send_group_parts); + Item_null_result **null_items= + static_cast<Item_null_result**>(thd->alloc(sizeof(Item*)*send_group_parts)); + + rollup.null_items= Item_null_array(null_items, send_group_parts); + rollup.ref_pointer_arrays= + static_cast<Ref_ptr_array*> + (thd->alloc((sizeof(Ref_ptr_array) + + all_fields.elements * sizeof(Item*)) * send_group_parts)); + rollup.fields= + static_cast<List<Item>*>(thd->alloc(sizeof(List<Item>) * send_group_parts)); + + if (!null_items || !rollup.ref_pointer_arrays || !rollup.fields) + return true; + ref_array= (Item**) (rollup.ref_pointer_arrays+send_group_parts); + /* Prepare space for field list for the different levels These will be filled up in rollup_make_fields() @@ -23260,7 +23308,7 @@ bool JOIN::rollup_init() rollup.null_items[i]= new (thd->mem_root) Item_null_result(thd); List<Item> *rollup_fields= &rollup.fields[i]; rollup_fields->empty(); - rollup.ref_pointer_arrays[i]= ref_array; + rollup.ref_pointer_arrays[i]= Ref_ptr_array(ref_array, all_fields.elements); ref_array+= all_fields.elements; } for (i= 0 ; i < send_group_parts; i++) @@ -23407,11 +23455,12 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, bool real_fields= 0; Item *item; List_iterator<Item> new_it(rollup.fields[pos]); - Item **ref_array_start= rollup.ref_pointer_arrays[pos]; + Ref_ptr_array ref_array_start= rollup.ref_pointer_arrays[pos]; ORDER *start_group; /* Point to first hidden field */ - Item **ref_array= ref_array_start + fields_arg.elements-1; + uint ref_array_ix= fields_arg.elements-1; + /* Remember where the sum functions ends for the previous level */ sum_funcs_end[pos+1]= *func; @@ -23428,7 +23477,7 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, if (item == first_field) { real_fields= 1; // End of hidden fields - ref_array= ref_array_start; + ref_array_ix= 0; } if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item() && @@ -23472,15 +23521,15 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, } } } - *ref_array= item; + ref_array_start[ref_array_ix]= item; if (real_fields) { (void) new_it++; // Point to next item new_it.replace(item); // Replace previous - ref_array++; + ref_array_ix++; } else - ref_array--; + ref_array_ix--; } } sum_funcs_end[0]= *func; // Point to last function @@ -23513,9 +23562,7 @@ int JOIN::rollup_send_data(uint idx) { int res= 0; /* Get reference pointers to sum functions in place */ - memcpy((char*) ref_pointer_array, - (char*) rollup.ref_pointer_arrays[i], - ref_pointer_array_size); + copy_ref_ptr_array(ref_ptrs, rollup.ref_pointer_arrays[i]); if ((!having || having->val_int())) { if (send_records < unit->select_limit_cnt && do_send_rows && @@ -23526,7 +23573,7 @@ int JOIN::rollup_send_data(uint idx) } } /* Restore ref_pointer_array */ - set_items_ref_array(current_ref_pointer_array); + set_items_ref_array(current_ref_ptrs); return 0; } @@ -23556,9 +23603,7 @@ int JOIN::rollup_write_data(uint idx, TABLE *table_arg) for (i= send_group_parts ; i-- > idx ; ) { /* Get reference pointers to sum functions in place */ - memcpy((char*) ref_pointer_array, - (char*) rollup.ref_pointer_arrays[i], - ref_pointer_array_size); + copy_ref_ptr_array(ref_ptrs, rollup.ref_pointer_arrays[i]); if ((!having || having->val_int())) { int write_error; @@ -23581,7 +23626,7 @@ int JOIN::rollup_write_data(uint idx, TABLE *table_arg) } } /* Restore ref_pointer_array */ - set_items_ref_array(current_ref_pointer_array); + set_items_ref_array(current_ref_ptrs); return 0; } @@ -23704,33 +23749,9 @@ int append_possible_keys(MEM_ROOT *alloc, String_list &list, TABLE *table, } -/* - TODO: this function is only applicable for the first non-const optimization - join tab. -*/ - -void JOIN_TAB::update_explain_data(uint idx) -{ - if (this == join->first_breadth_first_optimization_tab() + join->const_tables && - join->select_lex->select_number != INT_MAX && - join->select_lex->select_number != UINT_MAX) - { - Explain_table_access *eta= new (join->thd->mem_root) - Explain_table_access(join->thd->mem_root); - save_explain_data(eta, join->const_table_map, join->select_distinct, - join->first_breadth_first_optimization_tab()); - - Explain_select *sel= join->thd->lex->explain-> - get_select(join->select_lex->select_number); - idx -= my_count_bits(join->eliminated_tables); - sel->replace_table(idx, eta); - } -} - - void JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tables, - bool distinct, JOIN_TAB *first_top_tab) + bool distinct_arg, JOIN_TAB *first_top_tab) { int quick_type; CHARSET_INFO *cs= system_charset_info; @@ -23746,6 +23767,21 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, explain_plan= eta; eta->key.clear(); eta->quick_info= NULL; + + SQL_SELECT *tab_select; + /* + We assume that if this table does pre-sorting, then it doesn't do filtering + with SQL_SELECT. + */ + DBUG_ASSERT(!(select && filesort)); + tab_select= (filesort)? filesort->select : select; + + if (filesort) + { + eta->pre_join_sort= new Explain_aggr_filesort(thd->mem_root, + thd->lex->analyze_stmt, + filesort); + } tracker= &eta->tracker; jbuf_tracker= &eta->jbuf_tracker; @@ -23823,9 +23859,9 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, /* "type" column */ enum join_type tab_type= type; if ((type == JT_ALL || type == JT_HASH) && - select && select->quick && use_quick != 2) + tab_select && tab_select->quick && use_quick != 2) { - cur_quick= select->quick; + cur_quick= tab_select->quick; quick_type= cur_quick->get_type(); if ((quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE) || (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT) || @@ -23860,9 +23896,9 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, In STRAIGHT_JOIN queries, there can be join tabs with JT_CONST type that still have quick selects. */ - if (select && select->quick && tab_type != JT_CONST) + if (tab_select && tab_select->quick && tab_type != JT_CONST) { - eta->quick_info= select->quick->get_explain(thd->mem_root); + eta->quick_info= tab_select->quick->get_explain(thd->mem_root); } if (key_info) /* 'index' or 'ref' access */ @@ -23986,7 +24022,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, uint keyno= MAX_KEY; if (ref.key_parts) keyno= ref.key; - else if (select && cur_quick) + else if (tab_select && cur_quick) keyno = cur_quick->index; if (keyno != MAX_KEY && keyno == table->file->pushed_idx_cond_keyno && @@ -24008,7 +24044,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, { eta->push_extra(ET_USING); } - if (select) + if (tab_select) { if (use_quick == 2) { @@ -24018,7 +24054,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, eta->range_checked_fer-> append_possible_keys_stat(thd->mem_root, table, keys); } - else if (select->cond || + else if (tab_select->cond || (cache_select && cache_select->cond)) { const COND *pushed_cond= table->file->pushed_cond; @@ -24031,7 +24067,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, } else { - eta->where_cond= select->cond; + eta->where_cond= tab_select->cond; eta->cache_cond= cache_select? cache_select->cond : NULL; eta->push_extra(ET_USING_WHERE); } @@ -24063,7 +24099,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) { QUICK_GROUP_MIN_MAX_SELECT *qgs= - (QUICK_GROUP_MIN_MAX_SELECT *) select->quick; + (QUICK_GROUP_MIN_MAX_SELECT *) tab_select->quick; eta->push_extra(ET_USING_INDEX_FOR_GROUP_BY); eta->loose_scan_is_scanning= qgs->loose_scan_is_scanning(); } @@ -24075,14 +24111,15 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, if (quick_type == QUICK_SELECT_I::QS_TYPE_RANGE) { - explain_append_mrr_info((QUICK_RANGE_SELECT*)(select->quick), + explain_append_mrr_info((QUICK_RANGE_SELECT*)(tab_select->quick), &eta->mrr_type); if (eta->mrr_type.length() > 0) eta->push_extra(ET_USING_MRR); } - if (distinct & test_all_bits(prefix_tables, join->select_list_used_tables)) + if (shortcut_for_distinct) eta->push_extra(ET_DISTINCT); + if (loosescan_match_tab) { eta->push_extra(ET_LOOSESCAN); @@ -24150,14 +24187,69 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, /* + Walk through join->aggr_tables and save aggregation/grouping query plan into + an Explain_select object +*/ + +void save_agg_explain_data(JOIN *join, Explain_select *xpl_sel) +{ + JOIN_TAB *join_tab=join->join_tab + join->top_join_tab_count; + Explain_aggr_node *prev_node; + Explain_aggr_node *node= xpl_sel->aggr_tree; + bool is_analyze= join->thd->lex->analyze_stmt; + THD *thd= join->thd; + + for (uint i= 0; i < join->aggr_tables; i++, join_tab++) + { + // Each aggregate means a temp.table + prev_node= node; + node= new Explain_aggr_tmp_table; + node->child= prev_node; + + if (join_tab->window_funcs_step) + { + Explain_aggr_node *new_node= + join_tab->window_funcs_step->save_explain_plan(thd->mem_root, + is_analyze); + if (new_node) + { + prev_node=node; + node= new_node; + node->child= prev_node; + } + } + + /* The below matches execution in join_init_read_record() */ + if (join_tab->distinct) + { + prev_node= node; + node= new Explain_aggr_remove_dups; + node->child= prev_node; + } + + if (join_tab->filesort) + { + Explain_aggr_filesort *eaf = + new Explain_aggr_filesort(thd->mem_root, is_analyze, join_tab->filesort); + prev_node= node; + node= eaf; + node->child= prev_node; + } + } + xpl_sel->aggr_tree= node; +} + + +/* Save Query Plan Footprint @note Currently, this function may be called multiple times */ -int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, - bool need_order, bool distinct, +int JOIN::save_explain_data_intern(Explain_query *output, + bool need_tmp_table_arg, + bool need_order_arg, bool distinct_arg, const char *message) { JOIN *join= this; /* Legacy: this code used to be a non-member function */ @@ -24186,7 +24278,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, explain->select_id= join->select_lex->select_number; explain->select_type= join->select_lex->type; explain->using_temporary= need_tmp; - explain->using_filesort= need_order; + explain->using_filesort= need_order_arg; /* Setting explain->message means that all other members are invalid */ explain->message= message; @@ -24203,7 +24295,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, explain->select_id= select_lex->select_number; explain->select_type= select_lex->type; explain->using_temporary= need_tmp; - explain->using_filesort= need_order; + explain->using_filesort= need_order_arg; explain->message= "Storage engine handles GROUP BY"; if (select_lex->master_unit()->derived) @@ -24223,12 +24315,8 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, xpl_sel->select_type= join->select_lex->type; if (select_lex->master_unit()->derived) xpl_sel->connection_type= Explain_node::EXPLAIN_NODE_DERIVED; - - if (need_tmp_table) - xpl_sel->using_temporary= true; - - if (need_order) - xpl_sel->using_filesort= true; + + save_agg_explain_data(this, xpl_sel); xpl_sel->exec_const_cond= exec_const_cond; xpl_sel->outer_ref_cond= outer_ref_cond; @@ -24238,7 +24326,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, xpl_sel->having= having; xpl_sel->having_value= having_value; - JOIN_TAB* const first_top_tab= join->first_breadth_first_optimization_tab(); + JOIN_TAB* const first_top_tab= join->first_breadth_first_tab(); JOIN_TAB* prev_bush_root_tab= NULL; Explain_basic_join *cur_parent= xpl_sel; @@ -24257,13 +24345,6 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, } - if (join->table_access_tabs == join->join_tab && - tab == (first_top_tab + join->const_tables) && pre_sort_join_tab) - { - saved_join_tab= tab; - tab= pre_sort_join_tab; - } - Explain_table_access *eta= (new (output->mem_root) Explain_table_access(output->mem_root)); @@ -24294,7 +24375,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, prev_bush_root_tab= tab->bush_root_tab; cur_parent->add_table(eta, output); - tab->save_explain_data(eta, used_tables, distinct, first_top_tab); + tab->save_explain_data(eta, used_tables, distinct_arg, first_top_tab); if (saved_join_tab) tab= saved_join_tab; @@ -24354,14 +24435,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, DBUG_ENTER("select_describe"); /* Update the QPF with latest values of using_temporary, using_filesort */ - Explain_select *explain_sel; - uint select_nr= join->select_lex->select_number; - if ((explain_sel= thd->lex->explain->get_select(select_nr))) - { - explain_sel->using_temporary= need_tmp_table; - explain_sel->using_filesort= need_order; - } - for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit(); unit; unit= unit->next_unit()) @@ -24425,18 +24498,17 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) { thd->lex->current_select= first; unit->set_limit(unit->global_parameters()); - res= mysql_select(thd, &first->ref_pointer_array, - first->table_list.first, - first->with_wild, first->item_list, - first->where, - first->order_list.elements + - first->group_list.elements, - first->order_list.first, - first->group_list.first, - first->having, - thd->lex->proc_list.first, - first->options | thd->variables.option_bits | SELECT_DESCRIBE, - result, unit, first); + res= mysql_select(thd, + first->table_list.first, + first->with_wild, first->item_list, + first->where, + first->order_list.elements + first->group_list.elements, + first->order_list.first, + first->group_list.first, + first->having, + thd->lex->proc_list.first, + first->options | thd->variables.option_bits | SELECT_DESCRIBE, + result, unit, first); } DBUG_RETURN(res || thd->is_error()); } @@ -24480,6 +24552,7 @@ static void print_table_array(THD *thd, str->append(STRING_WITH_LEN(" semi join ")); else str->append(STRING_WITH_LEN(" join ")); + curr->print(thd, eliminated_tables, str, query_type); if (curr->on_expr) { @@ -25808,6 +25881,153 @@ err: DBUG_RETURN(0); } +/**************************************************************************** + AGGR_OP implementation +****************************************************************************/ + +/** + @brief Instantiate tmp table for aggregation and start index scan if needed + @todo Tmp table always would be created, even for empty result. Extend + executor to avoid tmp table creation when no rows were written + into tmp table. + @return + true error + false ok +*/ + +bool +AGGR_OP::prepare_tmp_table() +{ + TABLE *table= join_tab->table; + JOIN *join= join_tab->join; + int rc= 0; + + if (!join_tab->table->is_created()) + { + if (instantiate_tmp_table(table, join_tab->tmp_table_param->keyinfo, + join_tab->tmp_table_param->start_recinfo, + &join_tab->tmp_table_param->recinfo, + join->select_options)) + return true; + (void) table->file->extra(HA_EXTRA_WRITE_CACHE); + empty_record(table); + } + /* If it wasn't already, start index scan for grouping using table index. */ + if (!table->file->inited && table->group && + join_tab->tmp_table_param->sum_func_count && table->s->keys) + rc= table->file->ha_index_init(0, 0); + else + { + /* Start index scan in scanning mode */ + rc= table->file->ha_rnd_init(true); + } + if (rc) + { + table->file->print_error(rc, MYF(0)); + return true; + } + return false; +} + + +/** + @brief Prepare table if necessary and call write_func to save record + + @param end_of_records the end_of_record signal to pass to the writer + + @return return one of enum_nested_loop_state. +*/ + +enum_nested_loop_state +AGGR_OP::put_record(bool end_of_records) +{ + // Lasy tmp table creation/initialization + if (!join_tab->table->file->inited) + prepare_tmp_table(); + enum_nested_loop_state rc= (*write_func)(join_tab->join, join_tab, + end_of_records); + return rc; +} + + +/** + @brief Finish rnd/index scan after accumulating records, switch ref_array, + and send accumulated records further. + @return return one of enum_nested_loop_state. +*/ + +enum_nested_loop_state +AGGR_OP::end_send() +{ + enum_nested_loop_state rc= NESTED_LOOP_OK; + TABLE *table= join_tab->table; + JOIN *join= join_tab->join; + + // All records were stored, send them further + int tmp, new_errno= 0; + + if ((rc= put_record(true)) < NESTED_LOOP_OK) + return rc; + + if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE))) + { + DBUG_PRINT("error",("extra(HA_EXTRA_NO_CACHE) failed")); + new_errno= tmp; + } + if ((tmp= table->file->ha_index_or_rnd_end())) + { + DBUG_PRINT("error",("ha_index_or_rnd_end() failed")); + new_errno= tmp; + } + if (new_errno) + { + table->file->print_error(new_errno,MYF(0)); + return NESTED_LOOP_ERROR; + } + + // Update ref array + join_tab->join->set_items_ref_array(*join_tab->ref_array); + if (join_tab->window_funcs_step) + { + if (join_tab->window_funcs_step->exec(join)) + return NESTED_LOOP_ERROR; + } + + table->reginfo.lock_type= TL_UNLOCK; + + bool in_first_read= true; + while (rc == NESTED_LOOP_OK) + { + int error; + if (in_first_read) + { + in_first_read= false; + error= join_init_read_record(join_tab); + } + else + error= join_tab->read_record.read_record(&join_tab->read_record); + + if (error > 0 || (join->thd->is_error())) // Fatal error + rc= NESTED_LOOP_ERROR; + else if (error < 0) + break; + else if (join->thd->killed) // Aborted by user + { + join->thd->send_kill_message(); + rc= NESTED_LOOP_KILLED; + } + else + rc= evaluate_join_record(join, join_tab, 0); + } + + // Finish rnd scn after sending records + if (join_tab->table->file->inited) + join_tab->table->file->ha_rnd_end(); + + return rc; +} + + /** @} (end of group Query_Optimizer) */ diff --git a/sql/sql_select.h b/sql/sql_select.h index 86c5ef87d89..c143d58c2e8 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -34,6 +34,7 @@ #include "opt_range.h" /* SQL_SELECT, QUICK_SELECT_I */ #include "filesort.h" +typedef struct st_join_table JOIN_TAB; /* Values in optimize */ #define KEY_OPTIMIZE_EXISTS 1 #define KEY_OPTIMIZE_REF_OR_NULL 2 @@ -184,7 +185,7 @@ enum sj_strategy_enum typedef enum_nested_loop_state (*Next_select_func)(JOIN *, struct st_join_table *, bool); -Next_select_func setup_end_select_func(JOIN *join); +Next_select_func setup_end_select_func(JOIN *join, JOIN_TAB *tab); int rr_sequential(READ_RECORD *info); int rr_sequential_and_unpack(READ_RECORD *info); @@ -198,9 +199,11 @@ int rr_sequential_and_unpack(READ_RECORD *info); class JOIN_CACHE; class SJ_TMP_TABLE; class JOIN_TAB_RANGE; +class AGGR_OP; +class Filesort; typedef struct st_join_table { - st_join_table() {} /* Remove gcc warning */ + st_join_table() {} TABLE *table; TABLE_LIST *tab_list; KEYUSE *keyuse; /**< pointer to first used key */ @@ -238,7 +241,6 @@ typedef struct st_join_table { For join tabs that are inside an SJM bush: root of the bush */ st_join_table *bush_root_tab; - SORT_INFO *filesort; /* TRUE <=> This join_tab is inside an SJM bush and is the last leaf tab here */ bool last_leaf_in_bush; @@ -262,6 +264,7 @@ typedef struct st_join_table { */ uint packed_info; + // READ_RECORD::Setup_func materialize_table; READ_RECORD::Setup_func read_first_record; Next_select_func next_select; READ_RECORD read_record; @@ -348,6 +351,7 @@ typedef struct st_join_table { */ Item *cache_idx_cond; SQL_SELECT *cache_select; + AGGR_OP *aggr; JOIN *join; /* Embedding SJ-nest (may be not the direct parent), or NULL if none. @@ -414,6 +418,46 @@ typedef struct st_join_table { /* NestedOuterJoins: Bitmap of nested joins this table is part of */ nested_join_map embedding_map; + /* Tmp table info */ + TMP_TABLE_PARAM *tmp_table_param; + + /* Sorting related info */ + Filesort *filesort; + SORT_INFO *filesort_result; + + /* + Non-NULL value means this join_tab must do window function computation + before reading. + */ + Window_funcs_computation* window_funcs_step; + + /** + List of topmost expressions in the select list. The *next* JOIN TAB + in the plan should use it to obtain correct values. Same applicable to + all_fields. These lists are needed because after tmp tables functions + will be turned to fields. These variables are pointing to + tmp_fields_list[123]. Valid only for tmp tables and the last non-tmp + table in the query plan. + @see JOIN::make_tmp_tables_info() + */ + List<Item> *fields; + /** List of all expressions in the select list */ + List<Item> *all_fields; + /* + Pointer to the ref array slice which to switch to before sending + records. Valid only for tmp tables. + */ + Ref_ptr_array *ref_array; + + /** Number of records saved in tmp table */ + ha_rows send_records; + + /** HAVING condition for checking prior saving a record into tmp table*/ + Item *having; + + /** TRUE <=> remove duplicates on this table. */ + bool distinct; + /* Semi-join strategy to be used for this join table. This is a copy of POSITION::sj_strategy field. This field is set up by the @@ -428,9 +472,9 @@ typedef struct st_join_table { void cleanup(); inline bool is_using_loose_index_scan() { - return (select && select->quick && - (select->quick->get_type() == - QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)); + const SQL_SELECT *sel= filesort ? filesort->select : select; + return (sel && sel->quick && + (sel->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)); } bool is_using_agg_loose_index_scan () { @@ -565,16 +609,22 @@ typedef struct st_join_table { void save_explain_data(Explain_table_access *eta, table_map prefix_tables, bool distinct, struct st_join_table *first_top_tab); - void update_explain_data(uint idx); + bool use_order() const; ///< Use ordering provided by chosen index? + bool sort_table(); + bool remove_duplicates(); + } JOIN_TAB; #include "sql_join_cache.h" -enum_nested_loop_state sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool - end_of_records); -enum_nested_loop_state sub_select(JOIN *join,JOIN_TAB *join_tab, bool - end_of_records); +enum_nested_loop_state +sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); +enum_nested_loop_state +sub_select(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); +enum_nested_loop_state +sub_select_postjoin_aggr(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); + enum_nested_loop_state end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records); @@ -869,12 +919,14 @@ typedef struct st_position Sj_materialization_picker sjmat_picker; } POSITION; +typedef Bounds_checked_array<Item_null_result*> Item_null_array; + typedef struct st_rollup { enum State { STATE_NONE, STATE_INITED, STATE_READY }; State state; - Item_null_result **null_items; - Item ***ref_pointer_arrays; + Item_null_array null_items; + Ref_ptr_array *ref_pointer_arrays; List<Item> *fields; } ROLLUP; @@ -888,6 +940,56 @@ public: class Pushdown_query; +/** + @brief + Class to perform postjoin aggregation operations + + @details + The result records are obtained on the put_record() call. + The aggrgation process is determined by the write_func, it could be: + end_write Simply store all records in tmp table. + end_write_group Perform grouping using join->group_fields, + records are expected to be sorted. + end_update Perform grouping using the key generated on tmp + table. Input records aren't expected to be sorted. + Tmp table uses the heap engine + end_update_unique Same as above, but the engine is myisam. + + Lazy table initialization is used - the table will be instantiated and + rnd/index scan started on the first put_record() call. + +*/ + +class AGGR_OP :public Sql_alloc +{ +public: + JOIN_TAB *join_tab; + + AGGR_OP(JOIN_TAB *tab) : join_tab(tab), write_func(NULL) + {}; + + enum_nested_loop_state put_record() { return put_record(false); }; + /* + Send the result of operation further (to a next operation/client) + This function is called after all records were put into tmp table. + + @return return one of enum_nested_loop_state values. + */ + enum_nested_loop_state end_send(); + /** write_func setter */ + void set_write_func(Next_select_func new_write_func) + { + write_func= new_write_func; + } + +private: + /** Write function that would be used for saving records in tmp table. */ + Next_select_func write_func; + enum_nested_loop_state put_record(bool end_of_records); + bool prepare_tmp_table(); +}; + + class JOIN :public Sql_alloc { private: @@ -956,33 +1058,11 @@ protected: public: JOIN_TAB *join_tab, **best_ref; - - /* - Saved join_tab for pre_sorting. create_sort_index() will save here.. - */ - JOIN_TAB *pre_sort_join_tab; - uint pre_sort_index; - Item *pre_sort_idx_pushed_cond; - void clean_pre_sort_join_tab(); /* List of fields that aren't under an aggregate function */ List<Item_field> non_agg_fields; - /* - For "Using temporary+Using filesort" queries, JOIN::join_tab can point to - either: - 1. array of join tabs describing how to run the select, or - 2. array of single join tab describing read from the temporary table. - - SHOW EXPLAIN code needs to read/show #1. This is why two next members are - there for saving it. - */ - JOIN_TAB *table_access_tabs; - uint top_table_access_tabs_count; - JOIN_TAB **map2table; ///< mapping between table indexes and JOIN_TABs - JOIN_TAB *join_tab_save; ///< saved join_tab for subquery reexecution - List<JOIN_TAB_RANGE> join_tab_ranges; /* @@ -1013,14 +1093,9 @@ public: We keep it here so that it is saved/restored with JOIN::restore_tmp. */ uint top_join_tab_count; + uint aggr_tables; ///< Number of post-join tmp tables uint send_group_parts; /* - This counts how many times do_select() was invoked for this JOIN. - It's used to restrict Pushdown_query::execute() only to the first - do_select() invocation. - */ - uint do_select_call_count; - /* True if the query has GROUP BY. (that is, if group_by != NULL. when DISTINCT is converted into GROUP BY, it will set this, too. It is not clear why we need a separate var from @@ -1125,6 +1200,7 @@ public: */ table_map complex_firstmatch_tables; + Next_select_func first_select; /* The cost of best complete join plan found so far during optimization, after optimization phase - cost of picked join order (not taking into @@ -1140,9 +1216,6 @@ public: double join_record_count; List<Item> *fields; List<Cached_item> group_fields, group_fields_cache; - TABLE *tmp_table; - /// used to store 2 possible tmp table of SELECT - TABLE *exec_tmp_table1, *exec_tmp_table2; THD *thd; Item_sum **sum_funcs, ***sum_funcs_end; /** second copy of sumfuncs (for queries with 2 temporary tables */ @@ -1151,6 +1224,8 @@ public: Item *having; Item *tmp_having; ///< To store having when processed temporary table Item *having_history; ///< Store having for explain + ORDER *group_list_for_estimates; + bool having_is_correlated; ulonglong select_options; /* Bitmap of allowed types of the join caches that @@ -1189,26 +1264,6 @@ public: */ bool filesort_found_rows; - /** - Copy of this JOIN to be used with temporary tables. - - tmp_join is used when the JOIN needs to be "reusable" (e.g. in a - subquery that gets re-executed several times) and we know will use - temporary tables for materialization. The materialization to a - temporary table overwrites the JOIN structure to point to the - temporary table after the materialization is done. This is where - tmp_join is used : it's a copy of the JOIN before the - materialization and is used in restoring before re-execution by - overwriting the current JOIN structure with the saved copy. - Because of this we should pay extra care of not freeing up helper - structures that are referenced by the original contents of the - JOIN. We can check for this by making sure the "current" join is - not the temporary copy, e.g. !tmp_join || tmp_join != join - - We should free these sub-structures at JOIN::destroy() if the - "current" join has a copy is not that copy. - */ - JOIN *tmp_join; ROLLUP rollup; ///< Used with rollup bool mixed_implicit_grouping; @@ -1230,6 +1285,19 @@ public: GROUP/ORDER BY. */ bool simple_order, simple_group; + + /* + ordered_index_usage is set if an ordered index access + should be used instead of a filesort when computing + ORDER/GROUP BY. + */ + enum + { + ordered_index_void, // No ordered index avail. + ordered_index_group_by, // Use index for GROUP BY + ordered_index_order_by // Use index for ORDER BY + } ordered_index_usage; + /** Is set only in case if we have a GROUP BY clause and no ORDER BY after constant elimination of 'order'. @@ -1282,10 +1350,19 @@ public: List<Item> exec_const_order_group_cond; SQL_SELECT *select; ///<created in optimisation phase JOIN_TAB *return_tab; ///<used only for outer joins - Item **ref_pointer_array; ///<used pointer reference for this select - // Copy of above to be used with different lists - Item **items0, **items1, **items2, **items3, **current_ref_pointer_array; - uint ref_pointer_array_size; ///< size of above in bytes + + /* + Used pointer reference for this select. + select_lex->ref_pointer_array contains five "slices" of the same length: + |========|========|========|========|========| + ref_ptrs items0 items1 items2 items3 + */ + Ref_ptr_array ref_ptrs; + // Copy of the initial slice above, to be used with different lists + Ref_ptr_array items0, items1, items2, items3; + // Used by rollup, to restore ref_ptrs after overwriting it. + Ref_ptr_array current_ref_ptrs; + const char *zero_result_cause; ///< not 0 if exec must return zero result bool union_part; ///< this subselect is part of union @@ -1312,20 +1389,12 @@ public: /* SJM nests that are executed with SJ-Materialization strategy */ List<SJ_MATERIALIZATION_INFO> sjm_info_list; - /* - storage for caching buffers allocated during query execution. - These buffers allocations need to be cached as the thread memory pool is - cleared only at the end of the execution of the whole query and not caching - allocations that occur in repetition at execution time will result in - excessive memory usage. - Note: make_simple_join always creates an execution plan that accesses - a single table, thus it is sufficient to have a one-element array for - table_reexec. - */ - SORT_FIELD *sortorder; // make_unireg_sortorder() - TABLE *table_reexec[1]; // make_simple_join() - JOIN_TAB *join_tab_reexec; // make_simple_join() - /* end of allocation caching storage */ + /** TRUE <=> ref_pointer_array is set to items3. */ + bool set_group_rpa; + /** Exec time only: TRUE <=> current group has been sent */ + bool group_sent; + + JOIN_TAB *sort_and_group_aggr_tab; JOIN(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg, select_result *result_arg) @@ -1337,12 +1406,13 @@ public: void init(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg, select_result *result_arg) { - join_tab= join_tab_save= 0; + join_tab= 0; table= 0; table_count= 0; top_join_tab_count= 0; const_tables= 0; const_table_map= 0; + aggr_tables= 0; eliminated_tables= 0; join_list= 0; implicit_grouping= FALSE; @@ -1352,25 +1422,21 @@ public: send_records= 0; found_records= 0; fetch_limit= HA_POS_ERROR; - join_examined_rows= 0; - exec_tmp_table1= 0; - exec_tmp_table2= 0; - sortorder= 0; - table_reexec[0]= 0; - join_tab_reexec= 0; thd= thd_arg; sum_funcs= sum_funcs2= 0; procedure= 0; having= tmp_having= having_history= 0; + having_is_correlated= false; + group_list_for_estimates= 0; select_options= select_options_arg; result= result_arg; lock= thd_arg->lock; select_lex= 0; //for safety - tmp_join= 0; select_distinct= MY_TEST(select_options & SELECT_DISTINCT); no_order= 0; simple_order= 0; simple_group= 0; + ordered_index_usage= ordered_index_void; need_distinct= 0; skip_sort_order= 0; need_tmp= 0; @@ -1378,8 +1444,11 @@ public: error= 0; select= 0; return_tab= 0; - ref_pointer_array= items0= items1= items2= items3= 0; - ref_pointer_array_size= 0; + ref_ptrs.reset(); + items0.reset(); + items1.reset(); + items2.reset(); + items3.reset(); zero_result_cause= 0; optimized= 0; have_query_plan= QEP_NOT_PRESENT_YET; @@ -1393,8 +1462,6 @@ public: positions= best_positions= 0; pushdown_query= 0; original_join_tab= 0; - do_select_call_count= 0; - explain= NULL; all_fields= fields_arg; @@ -1407,22 +1474,21 @@ public: rollup.state= ROLLUP::STATE_NONE; no_const_tables= FALSE; + first_select= sub_select; + set_group_rpa= false; + group_sent= 0; + outer_ref_cond= pseudo_bits_cond= NULL; in_to_exists_where= NULL; in_to_exists_having= NULL; - pre_sort_join_tab= NULL; emb_sjm_nest= NULL; sjm_lookup_tables= 0; - - /* - The following is needed because JOIN::cleanup(true) may be called for - joins for which JOIN::optimize was aborted with an error before a proper - query plan was produced - */ - table_access_tabs= NULL; } - int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num, + /* True if the plan guarantees that it will be returned zero or one row */ + bool only_const_tables() { return const_tables == table_count; } + + int prepare(TABLE_LIST *tables, uint wind_num, COND *conds, uint og_num, ORDER *order, bool skip_order_by, ORDER *group, Item *having, ORDER *proc_param, SELECT_LEX *select, SELECT_LEX_UNIT *unit); @@ -1432,7 +1498,9 @@ public: int reinit(); int init_execution(); void exec(); + void exec_inner(); + bool prepare_result(List<Item> **columns_list); int destroy(); void restore_tmp(); bool alloc_func_list(); @@ -1442,16 +1510,42 @@ public: bool make_sum_func_list(List<Item> &all_fields, List<Item> &send_fields, bool before_group_by, bool recompute= FALSE); - inline void set_items_ref_array(Item **ptr) + /// Initialzes a slice, see comments for ref_ptrs above. + Ref_ptr_array ref_ptr_array_slice(size_t slice_num) { - memcpy((char*) ref_pointer_array, (char*) ptr, ref_pointer_array_size); - current_ref_pointer_array= ptr; + size_t slice_sz= select_lex->ref_pointer_array.size() / 5U; + DBUG_ASSERT(select_lex->ref_pointer_array.size() % 5 == 0); + DBUG_ASSERT(slice_num < 5U); + return Ref_ptr_array(&select_lex->ref_pointer_array[slice_num * slice_sz], + slice_sz); } - inline void init_items_ref_array() + + /** + Overwrites one slice with the contents of another slice. + In the normal case, dst and src have the same size(). + However: the rollup slices may have smaller size than slice_sz. + */ + void copy_ref_ptr_array(Ref_ptr_array dst_arr, Ref_ptr_array src_arr) + { + DBUG_ASSERT(dst_arr.size() >= src_arr.size()); + void *dest= dst_arr.array(); + const void *src= src_arr.array(); + memcpy(dest, src, src_arr.size() * src_arr.element_size()); + } + + /// Overwrites 'ref_ptrs' and remembers the the source as 'current'. + void set_items_ref_array(Ref_ptr_array src_arr) { - items0= ref_pointer_array + all_fields.elements; - memcpy(items0, ref_pointer_array, ref_pointer_array_size); - current_ref_pointer_array= items0; + copy_ref_ptr_array(ref_ptrs, src_arr); + current_ref_ptrs= src_arr; + } + + /// Initializes 'items0' and remembers that it is 'current'. + void init_items_ref_array() + { + items0= ref_ptr_array_slice(1); + copy_ref_ptr_array(items0, ref_ptrs); + current_ref_ptrs= items0; } bool rollup_init(); @@ -1460,18 +1554,10 @@ public: Item_sum ***func); int rollup_send_data(uint idx); int rollup_write_data(uint idx, TABLE *table); - /** - Release memory and, if possible, the open tables held by this execution - plan (and nested plans). It's used to release some tables before - the end of execution in order to increase concurrency and reduce - memory consumption. - */ void join_free(); /** Cleanup this JOIN, possibly for reuse */ void cleanup(bool full); void clear(); - bool save_join_tab(); - bool init_save_join_tab(); bool send_row_on_empty_set() { return (do_send_rows && implicit_grouping && !group_optimized_away && @@ -1490,6 +1576,8 @@ public: return (table_map(1) << table_count) - 1; } void drop_unused_derived_keys(); + bool get_best_combination(); + bool add_sorting_to_table(JOIN_TAB *tab, ORDER *order); inline void eval_select_list_used_tables(); /* Return the table for which an index scan can be used to satisfy @@ -1551,16 +1639,44 @@ public: int save_explain_data_intern(Explain_query *output, bool need_tmp_table, bool need_order, bool distinct, const char *message); - JOIN_TAB *first_breadth_first_optimization_tab() { return table_access_tabs; } - JOIN_TAB *first_breadth_first_execution_tab() { return join_tab; } + JOIN_TAB *first_breadth_first_tab() { return join_tab; } private: /** + Create a temporary table to be used for processing DISTINCT/ORDER + BY/GROUP BY. + + @note Will modify JOIN object wrt sort/group attributes + + @param tab the JOIN_TAB object to attach created table to + @param tmp_table_fields List of items that will be used to define + column types of the table. + @param tmp_table_group Group key to use for temporary table, NULL if none. + @param save_sum_fields If true, do not replace Item_sum items in + @c tmp_fields list with Item_field items referring + to fields in temporary table. + + @returns false on success, true on failure + */ + bool create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *tmp_table_fields, + ORDER *tmp_table_group, + bool save_sum_fields, + bool distinct, + bool keep_row_ordermake); + /** + Optimize distinct when used on a subset of the tables. + + E.g.,: SELECT DISTINCT t1.a FROM t1,t2 WHERE t1.b=t2.b + In this case we can stop scanning t2 when we have found one t1.a + */ + void optimize_distinct(); + + /** TRUE if the query contains an aggregate function but has no GROUP BY clause. */ bool implicit_grouping; - bool make_simple_join(JOIN *join, TABLE *tmp_table); void cleanup_item_list(List<Item> &items) const; + bool make_aggr_tables_info(); }; enum enum_with_bush_roots { WITH_BUSH_ROOTS, WITHOUT_BUSH_ROOTS}; @@ -1585,7 +1701,7 @@ extern const char *join_type_str[]; void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param, List<Item> &fields, bool reset_with_sum_func); bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, - Item **ref_pointer_array, + Ref_ptr_array ref_pointer_array, List<Item> &new_list1, List<Item> &new_list2, uint elements, List<Item> &fields); void copy_fields(TMP_TABLE_PARAM *param); @@ -1826,19 +1942,20 @@ int safe_index_read(JOIN_TAB *tab); int get_quick_record(SQL_SELECT *select); SORT_FIELD * make_unireg_sortorder(THD *thd, ORDER *order, uint *length, SORT_FIELD *sortorder); -int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, - List<Item> &fields, List <Item> &all_fields, ORDER *order); -int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, +int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, + List<Item> &fields, List <Item> &all_fields, ORDER *order, + bool search_in_all_fields= true); +int setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, List<Item> &fields, List<Item> &all_fields, ORDER *order, - bool *hidden_group_fields); + bool *hidden_group_fields, bool search_in_all_fields= true); bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, - Item **ref_pointer_array); + Ref_ptr_array ref_pointer_array); int join_read_key2(THD *thd, struct st_join_table *tab, TABLE *table, struct st_table_ref *table_ref); bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option); -bool mysql_select(THD *thd, Item ***rref_pointer_array, +bool mysql_select(THD *thd, TABLE_LIST *tables, uint wild_num, List<Item> &list, COND *conds, uint og_num, ORDER *order, ORDER *group, Item *having, ORDER *proc_param, ulonglong select_type, @@ -2154,4 +2271,7 @@ public: int execute(JOIN *join); }; +bool test_if_order_compatible(SQL_I_List<ORDER> &a, SQL_I_List<ORDER> &b); +int test_if_group_changed(List<Cached_item> &list); +int create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort); #endif /* SQL_SELECT_INCLUDED */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index aa2b47fa4b7..f41fb394b47 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2960,8 +2960,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) thread in this thread. However it's better that we notice it eventually than hide it. */ - table->field[12]->store((longlong) (tmp->status_var.local_memory_used + - sizeof(THD)), + table->field[12]->store((longlong) tmp->status_var.local_memory_used, FALSE); table->field[12]->set_notnull(); table->field[13]->store((longlong) tmp->get_examined_row_count(), TRUE); @@ -3044,7 +3043,7 @@ int add_status_vars(SHOW_VAR *list) if (status_vars_inited) mysql_mutex_lock(&LOCK_show_status); if (!all_status_vars.buffer && // array is not allocated yet - do it now - my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20, MYF(0))) + my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 250, 50, MYF(0))) { res= 1; goto err; @@ -3257,7 +3256,8 @@ static bool show_status_array(THD *thd, const char *wild, */ for (var=variables; var->type == SHOW_FUNC || var->type == SHOW_SIMPLE_FUNC; var= &tmp) - ((mysql_show_var_func)(var->value))(thd, &tmp, buff, scope); + ((mysql_show_var_func)(var->value))(thd, &tmp, buff, + status_var, scope); SHOW_TYPE show_type=var->type; if (show_type == SHOW_ARRAY) @@ -3389,10 +3389,14 @@ end: DBUG_RETURN(res); } -/* collect status for all running threads */ +/* + collect status for all running threads + Return number of threads used +*/ -void calc_sum_of_all_status(STATUS_VAR *to) +uint calc_sum_of_all_status(STATUS_VAR *to) { + uint count= 0; DBUG_ENTER("calc_sum_of_all_status"); /* Ensure that thread id not killed during loop */ @@ -3403,16 +3407,21 @@ void calc_sum_of_all_status(STATUS_VAR *to) /* Get global values as base */ *to= global_status_var; + to->local_memory_used= 0; /* Add to this status from existing threads */ while ((tmp= it++)) { + count++; if (!tmp->status_in_global) + { add_to_status(to, &tmp->status_var); + to->local_memory_used+= tmp->status_var.local_memory_used; + } } mysql_mutex_unlock(&LOCK_thread_count); - DBUG_VOID_RETURN; + DBUG_RETURN(count); } diff --git a/sql/sql_show.h b/sql/sql_show.h index 9dae78e7f0e..dbae2a42b39 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -102,7 +102,7 @@ bool mysqld_show_authors(THD *thd); bool mysqld_show_contributors(THD *thd); bool mysqld_show_privileges(THD *thd); char *make_backup_log_name(char *buff, const char *name, const char* log_ext); -void calc_sum_of_all_status(STATUS_VAR *to); +uint calc_sum_of_all_status(STATUS_VAR *to); void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user, const LEX_STRING *definer_host); int add_status_vars(SHOW_VAR *list); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dad51139af3..758757ea7dd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9351,7 +9351,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, int error= 1; Copy_field *copy= NULL, *copy_end; ha_rows found_count= 0, delete_count= 0; - SORT_FIELD *sortorder; SORT_INFO *file_sort= 0; READ_RECORD info; TABLE_LIST tables; @@ -9441,7 +9440,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, } else { - uint length= 0; bzero((char *) &tables, sizeof(tables)); tables.table= from; tables.alias= tables.table_name= from->s->table_name.str; @@ -9449,14 +9447,14 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, THD_STAGE_INFO(thd, stage_sorting); Filesort_tracker dummy_tracker(false); + Filesort fsort(order, HA_POS_ERROR, true, NULL); + if (thd->lex->select_lex.setup_ref_array(thd, order_num) || setup_order(thd, thd->lex->select_lex.ref_pointer_array, - &tables, fields, all_fields, order) || - !(sortorder= make_unireg_sortorder(thd, order, &length, NULL)) || - !(file_sort= filesort(thd, from, sortorder, length, - NULL, HA_POS_ERROR, - true, - &dummy_tracker))) + &tables, fields, all_fields, order)) + goto err; + + if (!(file_sort= filesort(thd, from, &fsort, &dummy_tracker))) goto err; } thd_progress_next_stage(thd); @@ -9670,6 +9668,18 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) } +static void flush_checksum(ha_checksum *row_crc, uchar **checksum_start, + size_t *checksum_length) +{ + if (*checksum_start) + { + *row_crc= my_checksum(*row_crc, *checksum_start, *checksum_length); + *checksum_start= NULL; + *checksum_length= 0; + } +} + + bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) { @@ -9746,23 +9756,23 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, if (!(check_opt->flags & T_EXTEND) && (((t->file->ha_table_flags() & HA_HAS_OLD_CHECKSUM) && thd->variables.old_mode) || ((t->file->ha_table_flags() & HA_HAS_NEW_CHECKSUM) && !thd->variables.old_mode))) - protocol->store((ulonglong)t->file->checksum()); + protocol->store((ulonglong)t->file->checksum()); else if (check_opt->flags & T_QUICK) - protocol->store_null(); + protocol->store_null(); else { - /* calculating table's checksum */ - ha_checksum crc= 0; + /* calculating table's checksum */ + ha_checksum crc= 0; uchar null_mask=256 - (1 << t->s->last_null_bit_pos); t->use_all_columns(); - if (t->file->ha_rnd_init(1)) - protocol->store_null(); - else - { - for (;;) - { + if (t->file->ha_rnd_init(1)) + protocol->store_null(); + else + { + for (;;) + { if (thd->killed) { /* @@ -9773,7 +9783,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, thd->protocol->remove_last_row(); goto err; } - ha_checksum row_crc= 0; + ha_checksum row_crc= 0; int error= t->file->ha_rnd_next(t->record[0]); if (unlikely(error)) { @@ -9781,22 +9791,27 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, continue; break; } - if (t->s->null_bytes) + if (t->s->null_bytes) { /* fix undefined null bits */ t->record[0][t->s->null_bytes-1] |= null_mask; if (!(t->s->db_create_options & HA_OPTION_PACK_RECORD)) t->record[0][0] |= 1; - row_crc= my_checksum(row_crc, t->record[0], t->s->null_bytes); + row_crc= my_checksum(row_crc, t->record[0], t->s->null_bytes); } - for (uint i= 0; i < t->s->fields; i++ ) - { - Field *f= t->field[i]; + uchar *checksum_start= NULL; + size_t checksum_length= 0; + for (uint i= 0; i < t->s->fields; i++ ) + { + Field *f= t->field[i]; if (! thd->variables.old_mode && f->is_real_null(0)) + { + flush_checksum(&row_crc, &checksum_start, &checksum_length); continue; + } /* BLOB and VARCHAR have pointers in their field, we must convert to string; GEOMETRY is implemented on top of BLOB. @@ -9808,6 +9823,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, case MYSQL_TYPE_GEOMETRY: case MYSQL_TYPE_BIT: { + flush_checksum(&row_crc, &checksum_start, &checksum_length); String tmp; f->val_str(&tmp); row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), @@ -9815,16 +9831,20 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, break; } default: - row_crc= my_checksum(row_crc, f->ptr, f->pack_length()); + if (!checksum_start) + checksum_start= f->ptr; + DBUG_ASSERT(checksum_start + checksum_length == f->ptr); + checksum_length+= f->pack_length(); break; - } - } + } + } + flush_checksum(&row_crc, &checksum_start, &checksum_length); - crc+= row_crc; - } - protocol->store((ulonglong)crc); + crc+= row_crc; + } + protocol->store((ulonglong)crc); t->file->ha_rnd_end(); - } + } } trans_rollback_stmt(thd); close_thread_tables(thd); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 642cf208908..50d51dcc8cc 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -559,16 +559,19 @@ C_MODE_END void mysql_print_status() { char current_dir[FN_REFLEN]; + char llbuff[10][22]; STATUS_VAR tmp; + uint count; - calc_sum_of_all_status(&tmp); + count= calc_sum_of_all_status(&tmp); printf("\nStatus information:\n\n"); (void) my_getwd(current_dir, sizeof(current_dir),MYF(0)); printf("Current dir: %s\n", current_dir); - printf("Running threads: %d Stack size: %ld\n", thread_count, + printf("Running threads: %d Cached threads: %lu Stack size: %ld\n", + count, cached_thread_count, (long) my_thread_stack_size); +#ifdef EXTRA_DEBUG thr_print_locks(); // Write some debug info -#ifndef DBUG_OFF print_cached_tables(); #endif /* Print key cache status */ @@ -614,28 +617,33 @@ Next alarm time: %lu\n", #ifdef HAVE_MALLINFO struct mallinfo info= mallinfo(); printf("\nMemory status:\n\ -Non-mmapped space allocated from system: %d\n\ -Number of free chunks: %d\n\ -Number of fastbin blocks: %d\n\ -Number of mmapped regions: %d\n\ -Space in mmapped regions: %d\n\ -Maximum total allocated space: %d\n\ -Space available in freed fastbin blocks: %d\n\ -Total allocated space: %d\n\ -Total free space: %d\n\ -Top-most, releasable space: %d\n\ -Estimated memory (with thread stack): %ld\n", - (int) info.arena , - (int) info.ordblks, - (int) info.smblks, - (int) info.hblks, - (int) info.hblkhd, - (int) info.usmblks, - (int) info.fsmblks, - (int) info.uordblks, - (int) info.fordblks, - (int) info.keepcost, - (long) (thread_count * my_thread_stack_size + info.hblkhd + info.arena)); +Non-mmapped space allocated from system: %s\n\ +Number of free chunks: %lu\n\ +Number of fastbin blocks: %lu\n\ +Number of mmapped regions: %lu\n\ +Space in mmapped regions: %s\n\ +Maximum total allocated space: %s\n\ +Space available in freed fastbin blocks: %s\n\ +Total allocated space: %s\n\ +Total free space: %s\n\ +Top-most, releasable space: %s\n\ +Estimated memory (with thread stack): %s\n\ +Global memory allocated by server: %s\n\ +Memory allocated by threads: %s\n", + llstr(info.arena, llbuff[0]), + (ulong) info.ordblks, + (ulong) info.smblks, + (ulong) info.hblks, + llstr(info.hblkhd, llbuff[1]), + llstr(info.usmblks, llbuff[2]), + llstr(info.fsmblks, llbuff[3]), + llstr(info.uordblks, llbuff[4]), + llstr(info.fordblks, llbuff[5]), + llstr(info.keepcost, llbuff[6]), + llstr((count + cached_thread_count)* my_thread_stack_size + info.hblkhd + info.arena, llbuff[7]), + llstr(tmp.global_memory_used, llbuff[8]), + llstr(tmp.local_memory_used, llbuff[9])); + #endif #ifdef HAVE_EVENT_SCHEDULER diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 7a61279fc9c..63093620805 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1581,7 +1581,6 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, DBUG_RETURN(0); err_with_lex_cleanup: - // QQ: anything else ? lex_end(&lex); thd->lex= old_lex; thd->spcont= save_spcont; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 5685c90850a..87b836f40d9 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -436,8 +436,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit); - saved_error= join->prepare(&sl->ref_pointer_array, - sl->table_list.first, + saved_error= join->prepare(sl->table_list.first, sl->with_wild, sl->where, (can_skip_order_by ? 0 : @@ -646,8 +645,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, fake_select_lex->n_child_sum_items+= global_parameters()->n_sum_items; saved_error= fake_select_lex->join-> - prepare(&fake_select_lex->ref_pointer_array, - fake_select_lex->table_list.first, + prepare(fake_select_lex->table_list.first, 0, 0, global_parameters()->order_list.elements, // og_num global_parameters()->order_list.first, // order @@ -702,7 +700,7 @@ bool st_select_lex_unit::optimize() { item->assigned(0); // We will reinit & rexecute unit item->reset(); - if (table->created) + if (table->is_created()) { table->file->ha_delete_all_rows(); table->file->info(HA_STATUS_VARIABLE); @@ -946,13 +944,13 @@ bool st_select_lex_unit::exec() Don't add more sum_items if we have already done JOIN::prepare for this (with a different join object) */ - if (!fake_select_lex->ref_pointer_array) + if (fake_select_lex->ref_pointer_array.is_null()) fake_select_lex->n_child_sum_items+= global_parameters()->n_sum_items; if (!was_executed) save_union_explain_part2(thd->lex->explain); - saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array, + saved_error= mysql_select(thd, &result_table_list, 0, item_list, NULL, global_parameters()->order_list.elements, @@ -975,7 +973,7 @@ bool st_select_lex_unit::exec() to reset them back, we re-do all of the actions (yes it is ugly): */ // psergey-todo: is the above really necessary anymore?? join->init(thd, item_list, fake_select_lex->options, result); - saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array, + saved_error= mysql_select(thd, &result_table_list, 0, item_list, NULL, global_parameters()->order_list.elements, @@ -1022,27 +1020,11 @@ bool st_select_lex_unit::cleanup() } cleaned= 1; - if (union_result) - { - delete union_result; - union_result=0; // Safety - if (table) - free_tmp_table(thd, table); - table= 0; // Safety - } - for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) error|= sl->cleanup(); if (fake_select_lex) { - JOIN *join; - if ((join= fake_select_lex->join)) - { - join->tables_list= 0; - join->table_count= 0; - join->top_join_tab_count= 0; - } error|= fake_select_lex->cleanup(); /* There are two cases when we should clean order items: @@ -1064,6 +1046,15 @@ bool st_select_lex_unit::cleanup() } } + if (union_result) + { + delete union_result; + union_result=0; // Safety + if (table) + free_tmp_table(thd, table); + table= 0; // Safety + } + DBUG_RETURN(error); } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 61c16a905fe..6c60350844e 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -341,7 +341,8 @@ int mysql_update(THD *thd, if (table_list->is_view()) unfix_fields(fields); - if (setup_fields_with_no_wrap(thd, 0, fields, MARK_COLUMNS_WRITE, 0, 0)) + if (setup_fields_with_no_wrap(thd, Ref_ptr_array(), + fields, MARK_COLUMNS_WRITE, 0, 0)) DBUG_RETURN(1); /* purecov: inspected */ if (table_list->view && check_fields(thd, fields)) { @@ -360,7 +361,7 @@ int mysql_update(THD *thd, table_list->grant.want_privilege= table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege); #endif - if (setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0)) + if (setup_fields(thd, Ref_ptr_array(), values, MARK_COLUMNS_READ, 0, 0)) { free_underlaid_joins(thd, select_lex); DBUG_RETURN(1); /* purecov: inspected */ @@ -557,17 +558,12 @@ int mysql_update(THD *thd, to update NOTE: filesort will call table->prepare_for_position() */ - uint length= 0; - SORT_FIELD *sortorder; + Filesort fsort(order, limit, true, select); Filesort_tracker *fs_tracker= thd->lex->explain->get_upd_del_plan()->filesort_tracker; - if (!(sortorder=make_unireg_sortorder(thd, order, &length, NULL)) || - !(file_sort= filesort(thd, table, sortorder, length, - select, limit, - true, - fs_tracker))) + if (!(file_sort= filesort(thd, table, &fsort, fs_tracker))) goto err; thd->inc_examined_row_count(file_sort->examined_rows); @@ -696,7 +692,7 @@ int mysql_update(THD *thd, if (error >= 0) goto err; } - table->disable_keyread(); + table->set_keyread(false); table->column_bitmaps_set(save_read_set, save_write_set); } @@ -1050,7 +1046,7 @@ err: delete select; delete file_sort; free_underlaid_joins(thd, select_lex); - table->disable_keyread(); + table->set_keyread(false); thd->abort_on_warning= 0; DBUG_RETURN(1); @@ -1424,7 +1420,8 @@ int mysql_multi_update_prepare(THD *thd) if (lex->select_lex.handle_derived(thd->lex, DT_MERGE)) DBUG_RETURN(TRUE); - if (setup_fields_with_no_wrap(thd, 0, *fields, MARK_COLUMNS_WRITE, 0, 0)) + if (setup_fields_with_no_wrap(thd, Ref_ptr_array(), + *fields, MARK_COLUMNS_WRITE, 0, 0)) DBUG_RETURN(TRUE); for (tl= table_list; tl ; tl= tl->next_local) @@ -1611,7 +1608,7 @@ bool mysql_multi_update(THD *thd, thd->abort_on_warning= thd->is_strict_mode(); List<Item> total_list; - res= mysql_select(thd, &select_lex->ref_pointer_array, + res= mysql_select(thd, table_list, select_lex->with_wild, total_list, conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, @@ -1707,7 +1704,8 @@ int multi_update::prepare(List<Item> ¬_used_values, reference tables */ - int error= setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0); + int error= setup_fields(thd, Ref_ptr_array(), + *values, MARK_COLUMNS_READ, 0, 0); ti.rewind(); while ((table_ref= ti++)) @@ -2034,7 +2032,7 @@ loop_end: /* Make an unique key over the first field to avoid duplicated updates */ bzero((char*) &group, sizeof(group)); - group.asc= 1; + group.direction= ORDER::ORDER_ASC; group.item= (Item**) temp_fields.head_ref(); tmp_param->quick_group=1; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 41fd5b78f04..b66f678adfc 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1612,6 +1612,8 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, sl->context.error_processor_data= (void *)table; } + table->select_lex->master_unit()->is_view= true; + /* check MERGE algorithm ability - algorithm is not explicit TEMPORARY TABLE diff --git a/sql/sql_window.cc b/sql/sql_window.cc new file mode 100644 index 00000000000..e3e42fc4f75 --- /dev/null +++ b/sql/sql_window.cc @@ -0,0 +1,2129 @@ +#include "sql_select.h" +#include "sql_list.h" +#include "item_windowfunc.h" +#include "filesort.h" +#include "sql_base.h" +#include "sql_window.h" + + +bool +Window_spec::check_window_names(List_iterator_fast<Window_spec> &it) +{ + if (window_names_are_checked) + return false; + char *name= this->name(); + char *ref_name= window_reference(); + it.rewind(); + Window_spec *win_spec; + while((win_spec= it++) && win_spec != this) + { + char *win_spec_name= win_spec->name(); + if (!win_spec_name) + break; + if (name && my_strcasecmp(system_charset_info, name, win_spec_name) == 0) + { + my_error(ER_DUP_WINDOW_NAME, MYF(0), name); + return true; + } + if (ref_name && + my_strcasecmp(system_charset_info, ref_name, win_spec_name) == 0) + { + if (partition_list->elements) + { + my_error(ER_PARTITION_LIST_IN_REFERENCING_WINDOW_SPEC, MYF(0), + ref_name); + return true; + } + if (win_spec->order_list->elements && order_list->elements) + { + my_error(ER_ORDER_LIST_IN_REFERENCING_WINDOW_SPEC, MYF(0), ref_name); + return true; + } + if (win_spec->window_frame) + { + my_error(ER_WINDOW_FRAME_IN_REFERENCED_WINDOW_SPEC, MYF(0), ref_name); + return true; + } + referenced_win_spec= win_spec; + if (partition_list->elements == 0) + partition_list= win_spec->partition_list; + if (order_list->elements == 0) + order_list= win_spec->order_list; + } + } + if (ref_name && !referenced_win_spec) + { + my_error(ER_WRONG_WINDOW_SPEC_NAME, MYF(0), ref_name); + return true; + } + window_names_are_checked= true; + return false; +} + +bool +Window_frame::check_frame_bounds() +{ + if ((top_bound->is_unbounded() && + top_bound->precedence_type == Window_frame_bound::FOLLOWING) || + (bottom_bound->is_unbounded() && + bottom_bound->precedence_type == Window_frame_bound::PRECEDING) || + (top_bound->precedence_type == Window_frame_bound::CURRENT && + bottom_bound->precedence_type == Window_frame_bound::PRECEDING) || + (bottom_bound->precedence_type == Window_frame_bound::CURRENT && + top_bound->precedence_type == Window_frame_bound::FOLLOWING)) + { + my_error(ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS, MYF(0)); + return true; + } + + return false; +} + + +/* + Setup window functions in a select +*/ + +int +setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, + List<Item> &fields, List<Item> &all_fields, + List<Window_spec> &win_specs, List<Item_window_func> &win_funcs) +{ + Window_spec *win_spec; + DBUG_ENTER("setup_windows"); + List_iterator<Window_spec> it(win_specs); + + /* + Move all unnamed specifications after the named ones. + We could have avoided it if we had built two separate lists for + named and unnamed specifications. + */ + Query_arena *arena, backup; + arena= thd->activate_stmt_arena_if_needed(&backup); + uint i = 0; + uint elems= win_specs.elements; + while ((win_spec= it++) && i++ < elems) + { + if (win_spec->name() == NULL) + { + it.remove(); + win_specs.push_back(win_spec); + } + } + if (arena) + thd->restore_active_arena(arena, &backup); + + it.rewind(); + + List_iterator_fast<Window_spec> itp(win_specs); + + while ((win_spec= it++)) + { + bool hidden_group_fields; + if (win_spec->check_window_names(itp) || + setup_group(thd, ref_pointer_array, tables, fields, all_fields, + win_spec->partition_list->first, &hidden_group_fields, + true) || + setup_order(thd, ref_pointer_array, tables, fields, all_fields, + win_spec->order_list->first, true) || + (win_spec->window_frame && + win_spec->window_frame->check_frame_bounds())) + { + DBUG_RETURN(1); + } + + if (win_spec->window_frame && + win_spec->window_frame->exclusion != Window_frame::EXCL_NONE) + { + my_error(ER_FRAME_EXCLUSION_NOT_SUPPORTED, MYF(0)); + DBUG_RETURN(1); + } + /* + For "win_func() OVER (ORDER BY order_list RANGE BETWEEN ...)", + - ORDER BY order_list must not be ommitted + - the list must have a single element. + */ + if (win_spec->window_frame && + win_spec->window_frame->units == Window_frame::UNITS_RANGE) + { + if (win_spec->order_list->elements != 1) + { + my_error(ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY, MYF(0)); + DBUG_RETURN(1); + } + + /* + "The declared type of SK shall be numeric, datetime, or interval" + we don't support datetime or interval, yet. + */ + Item_result rtype= win_spec->order_list->first->item[0]->result_type(); + if (rtype != REAL_RESULT && rtype != INT_RESULT && + rtype != DECIMAL_RESULT) + { + my_error(ER_WRONG_TYPE_FOR_RANGE_FRAME, MYF(0)); + DBUG_RETURN(1); + } + + /* + "The declared type of UVS shall be numeric if the declared type of SK + is numeric; otherwise, it shall be an interval type that may be added + to or subtracted from the declared type of SK" + */ + Window_frame_bound *bounds[]= {win_spec->window_frame->top_bound, + win_spec->window_frame->bottom_bound, + NULL}; + for (Window_frame_bound **pbound= &bounds[0]; *pbound; pbound++) + { + if (!(*pbound)->is_unbounded() && + ((*pbound)->precedence_type == Window_frame_bound::FOLLOWING || + (*pbound)->precedence_type == Window_frame_bound::PRECEDING)) + { + Item_result rtype= (*pbound)->offset->result_type(); + if (rtype != REAL_RESULT && rtype != INT_RESULT && + rtype != DECIMAL_RESULT) + { + my_error(ER_WRONG_TYPE_FOR_RANGE_FRAME, MYF(0)); + DBUG_RETURN(1); + } + } + } + } + + /* "ROWS PRECEDING|FOLLOWING $n" must have a numeric $n */ + if (win_spec->window_frame && + win_spec->window_frame->units == Window_frame::UNITS_ROWS) + { + Window_frame_bound *bounds[]= {win_spec->window_frame->top_bound, + win_spec->window_frame->bottom_bound, + NULL}; + for (Window_frame_bound **pbound= &bounds[0]; *pbound; pbound++) + { + if (!(*pbound)->is_unbounded() && + ((*pbound)->precedence_type == Window_frame_bound::FOLLOWING || + (*pbound)->precedence_type == Window_frame_bound::PRECEDING)) + { + Item *offset= (*pbound)->offset; + if (offset->result_type() != INT_RESULT) + { + my_error(ER_WRONG_TYPE_FOR_ROWS_FRAME, MYF(0)); + DBUG_RETURN(1); + } + } + } + } + } + + List_iterator_fast<Item_window_func> li(win_funcs); + Item_window_func *win_func_item; + while ((win_func_item= li++)) + { + win_func_item->update_used_tables(); + } + + DBUG_RETURN(0); +} + +///////////////////////////////////////////////////////////////////////////// +// Sorting window functions to minimize the number of table scans +// performed during the computation of these functions +///////////////////////////////////////////////////////////////////////////// + +#define CMP_LT -2 // Less than +#define CMP_LT_C -1 // Less than and compatible +#define CMP_EQ 0 // Equal to +#define CMP_GT_C 1 // Greater than and compatible +#define CMP_GT 2 // Greater then + +static +int compare_order_elements(ORDER *ord1, ORDER *ord2) +{ + if (*ord1->item == *ord2->item) + return CMP_EQ; + Item *item1= (*ord1->item)->real_item(); + Item *item2= (*ord2->item)->real_item(); + DBUG_ASSERT(item1->type() == Item::FIELD_ITEM && + item2->type() == Item::FIELD_ITEM); + int cmp= ((Item_field *) item1)->field - ((Item_field *) item2)->field; + if (cmp == 0) + { + if (ord1->direction == ord2->direction) + return CMP_EQ; + return ord1->direction > ord2->direction ? CMP_GT : CMP_LT; + } + else + return cmp > 0 ? CMP_GT : CMP_LT; +} + +static +int compare_order_lists(SQL_I_List<ORDER> *part_list1, + SQL_I_List<ORDER> *part_list2) +{ + if (part_list1 == part_list2) + return CMP_EQ; + ORDER *elem1= part_list1->first; + ORDER *elem2= part_list2->first; + for ( ; elem1 && elem2; elem1= elem1->next, elem2= elem2->next) + { + int cmp; + if ((cmp= compare_order_elements(elem1, elem2))) + return cmp; + } + if (elem1) + return CMP_GT_C; + if (elem2) + return CMP_LT_C; + return CMP_EQ; +} + + +static +int compare_window_frame_bounds(Window_frame_bound *win_frame_bound1, + Window_frame_bound *win_frame_bound2, + bool is_bottom_bound) +{ + int res; + if (win_frame_bound1->precedence_type != win_frame_bound2->precedence_type) + { + res= win_frame_bound1->precedence_type > win_frame_bound2->precedence_type ? + CMP_GT : CMP_LT; + if (is_bottom_bound) + res= -res; + return res; + } + + if (win_frame_bound1->is_unbounded() && win_frame_bound2->is_unbounded()) + return CMP_EQ; + + if (!win_frame_bound1->is_unbounded() && !win_frame_bound2->is_unbounded()) + { + if (win_frame_bound1->offset->eq(win_frame_bound2->offset, true)) + return CMP_EQ; + else + { + res= strcmp(win_frame_bound1->offset->name, + win_frame_bound2->offset->name); + res= res > 0 ? CMP_GT : CMP_LT; + if (is_bottom_bound) + res= -res; + return res; + } + } + + /* + Here we have: + win_frame_bound1->is_unbounded() != win_frame_bound1->is_unbounded() + */ + return is_bottom_bound != win_frame_bound1->is_unbounded() ? CMP_LT : CMP_GT; +} + + +static +int compare_window_frames(Window_frame *win_frame1, + Window_frame *win_frame2) +{ + int cmp; + + if (win_frame1 == win_frame2) + return CMP_EQ; + + if (!win_frame1) + return CMP_LT; + + if (!win_frame2) + return CMP_GT; + + if (win_frame1->units != win_frame2->units) + return win_frame1->units > win_frame2->units ? CMP_GT : CMP_LT; + + cmp= compare_window_frame_bounds(win_frame1->top_bound, + win_frame2->top_bound, + false); + if (cmp) + return cmp; + + cmp= compare_window_frame_bounds(win_frame1->bottom_bound, + win_frame2->bottom_bound, + true); + if (cmp) + return cmp; + + if (win_frame1->exclusion != win_frame2->exclusion) + return win_frame1->exclusion > win_frame2->exclusion ? CMP_GT_C : CMP_LT_C; + + return CMP_EQ; +} + +static +int compare_window_spec_joined_lists(Window_spec *win_spec1, + Window_spec *win_spec2) +{ + win_spec1->join_partition_and_order_lists(); + win_spec2->join_partition_and_order_lists(); + int cmp= compare_order_lists(win_spec1->partition_list, + win_spec2->partition_list); + win_spec1->disjoin_partition_and_order_lists(); + win_spec2->disjoin_partition_and_order_lists(); + return cmp; +} + + +static +int compare_window_funcs_by_window_specs(Item_window_func *win_func1, + Item_window_func *win_func2, + void *arg) +{ + int cmp; + Window_spec *win_spec1= win_func1->window_spec; + Window_spec *win_spec2= win_func2->window_spec; + if (win_spec1 == win_spec2) + return CMP_EQ; + cmp= compare_order_lists(win_spec1->partition_list, + win_spec2->partition_list); + if (cmp == CMP_EQ) + { + /* + Partition lists contain the same elements. + Let's use only one of the lists. + */ + if (!win_spec1->name() && win_spec2->name()) + win_spec1->partition_list= win_spec2->partition_list; + else + win_spec2->partition_list= win_spec1->partition_list; + + cmp= compare_order_lists(win_spec1->order_list, + win_spec2->order_list); + + if (cmp != CMP_EQ) + return cmp; + + /* + Order lists contain the same elements. + Let's use only one of the lists. + */ + if (!win_spec1->name() && win_spec2->name()) + win_spec1->order_list= win_spec2->order_list; + else + win_spec2->order_list= win_spec1->order_list; + + cmp= compare_window_frames(win_spec1->window_frame, + win_spec2->window_frame); + + if (cmp != CMP_EQ) + return cmp; + + /* Window frames are equal. Let's use only one of them. */ + if (!win_spec1->name() && win_spec2->name()) + win_spec1->window_frame= win_spec2->window_frame; + else + win_spec2->window_frame= win_spec1->window_frame; + + return CMP_EQ; + } + + if (cmp == CMP_GT || cmp == CMP_LT) + return cmp; + + /* one of the partitions lists is the proper beginning of the another */ + cmp= compare_window_spec_joined_lists(win_spec1, win_spec2); + + if (CMP_LT_C <= cmp && cmp <= CMP_GT_C) + cmp= win_spec1->partition_list->elements < + win_spec2->partition_list->elements ? CMP_GT_C : CMP_LT_C; + + return cmp; +} + + +#define SORTORDER_CHANGE_FLAG 1 +#define PARTITION_CHANGE_FLAG 2 +#define FRAME_CHANGE_FLAG 4 + +typedef int (*Item_window_func_cmp)(Item_window_func *f1, + Item_window_func *f2, + void *arg); +/* + @brief + Sort window functions so that those that can be computed together are + adjacent. + + @detail + Sort window functions by their + - required sorting order, + - partition list, + - window frame compatibility. + + The changes between the groups are marked by setting item_window_func->marker. +*/ + +static +void order_window_funcs_by_window_specs(List<Item_window_func> *win_func_list) +{ + if (win_func_list->elements == 0) + return; + + bubble_sort<Item_window_func>(win_func_list, + compare_window_funcs_by_window_specs, + NULL); + + List_iterator_fast<Item_window_func> it(*win_func_list); + Item_window_func *prev= it++; + prev->marker= SORTORDER_CHANGE_FLAG | + PARTITION_CHANGE_FLAG | + FRAME_CHANGE_FLAG; + Item_window_func *curr; + while ((curr= it++)) + { + Window_spec *win_spec_prev= prev->window_spec; + Window_spec *win_spec_curr= curr->window_spec; + curr->marker= 0; + if (!(win_spec_prev->partition_list == win_spec_curr->partition_list && + win_spec_prev->order_list == win_spec_curr->order_list)) + { + int cmp; + if (win_spec_prev->partition_list == win_spec_curr->partition_list) + cmp= compare_order_lists(win_spec_prev->order_list, + win_spec_curr->order_list); + else + cmp= compare_window_spec_joined_lists(win_spec_prev, win_spec_curr); + if (!(CMP_LT_C <= cmp && cmp <= CMP_GT_C)) + { + curr->marker= SORTORDER_CHANGE_FLAG | + PARTITION_CHANGE_FLAG | + FRAME_CHANGE_FLAG; + } + else if (win_spec_prev->partition_list != win_spec_curr->partition_list) + { + curr->marker|= PARTITION_CHANGE_FLAG | FRAME_CHANGE_FLAG; + } + } + else if (win_spec_prev->window_frame != win_spec_curr->window_frame) + curr->marker|= FRAME_CHANGE_FLAG; + + prev= curr; + } +} + + +///////////////////////////////////////////////////////////////////////////// + + +/* + Do a pass over sorted table and compute window function values. + + This function is for handling window functions that can be computed on the + fly. Examples are RANK() and ROW_NUMBER(). +*/ +bool compute_window_func_values(Item_window_func *item_win, + TABLE *tbl, READ_RECORD *info) +{ + int err; + while (!(err=info->read_record(info))) + { + store_record(tbl,record[1]); + + /* + This will cause window function to compute its value for the + current row : + */ + item_win->advance_window(); + + /* + Put the new value into temptable's field + TODO: Should this use item_win->update_field() call? + Regular aggegate function implementations seem to implement it. + */ + item_win->save_in_field(item_win->result_field, true); + err= tbl->file->ha_update_row(tbl->record[1], tbl->record[0]); + if (err && err != HA_ERR_RECORD_IS_THE_SAME) + return true; + } + return false; +} + +///////////////////////////////////////////////////////////////////////////// +// Window Frames support +///////////////////////////////////////////////////////////////////////////// + +// note: make rr_from_pointers static again when not need it here anymore +int rr_from_pointers(READ_RECORD *info); + +/* + A temporary way to clone READ_RECORD structures until Monty provides the real + one. +*/ +bool clone_read_record(const READ_RECORD *src, READ_RECORD *dst) +{ + //DBUG_ASSERT(src->table->sort.record_pointers); + DBUG_ASSERT(src->read_record == rr_from_pointers); + memcpy(dst, src, sizeof(READ_RECORD)); + return false; +} + +///////////////////////////////////////////////////////////////////////////// + + +/* + A cursor over a sequence of rowids. One can + - Move to next rowid + - jump to given number in the sequence + - Know the number of the current rowid (i.e. how many rowids have been read) +*/ + +class Rowid_seq_cursor +{ + uchar *cache_start; + uchar *cache_pos; + uchar *cache_end; + uint ref_length; + +public: + virtual ~Rowid_seq_cursor() {} + + void init(READ_RECORD *info) + { + cache_start= info->cache_pos; + cache_pos= info->cache_pos; + cache_end= info->cache_end; + ref_length= info->ref_length; + } + + virtual int get_next() + { + /* Allow multiple get_next() calls in EOF state*/ + if (cache_pos == cache_end) + return -1; + cache_pos+= ref_length; + return 0; + } + + ha_rows get_rownum() + { + return (cache_pos - cache_start) / ref_length; + } + + // will be called by ROWS n FOLLOWING to catch up. + void move_to(ha_rows row_number) + { + cache_pos= cache_start + row_number * ref_length; + } +protected: + bool at_eof() { return (cache_pos == cache_end); } + + uchar *get_last_rowid() + { + if (cache_pos == cache_start) + return NULL; + else + return cache_pos - ref_length; + } + + uchar *get_curr_rowid() { return cache_pos; } +}; + + +/* + Cursor which reads from rowid sequence and also retrieves table rows. +*/ + +class Table_read_cursor : public Rowid_seq_cursor +{ + /* + Note: we don't own *read_record, somebody else is using it. + We only look at the constant part of it, e.g. table, record buffer, etc. + */ + READ_RECORD *read_record; +public: + virtual ~Table_read_cursor() {} + + void init(READ_RECORD *info) + { + Rowid_seq_cursor::init(info); + read_record= info; + } + + virtual int get_next() + { + if (at_eof()) + return -1; + + uchar* curr_rowid= get_curr_rowid(); + int res= Rowid_seq_cursor::get_next(); + if (!res) + { + res= read_record->table->file->ha_rnd_pos(read_record->record, + curr_rowid); + } + return res; + } + + bool restore_last_row() + { + uchar *p; + if ((p= get_last_rowid())) + { + int rc= read_record->table->file->ha_rnd_pos(read_record->record, p); + if (!rc) + return true; // restored ok + } + return false; // didn't restore + } + + // todo: should move_to() also read row here? +}; + + +/* + A cursor which only moves within a partition. The scan stops at the partition + end, and it needs an explicit command to move to the next partition. +*/ + +class Partition_read_cursor +{ + Table_read_cursor tbl_cursor; + Group_bound_tracker bound_tracker; + bool end_of_partition; +public: + void init(THD *thd, READ_RECORD *info, SQL_I_List<ORDER> *partition_list) + { + tbl_cursor.init(info); + bound_tracker.init(thd, partition_list); + end_of_partition= false; + } + + /* + Informs the cursor that we need to move into the next partition. + The next partition is provided in two ways: + - in table->record[0].. + - rownum parameter has the row number. + */ + void on_next_partition(int rownum) + { + /* Remember the sort key value from the new partition */ + bound_tracker.check_if_next_group(); + end_of_partition= false; + } + + /* + Moves to a new row. The row is assumed to be within the current partition + */ + void move_to(int rownum) { tbl_cursor.move_to(rownum); } + + /* + This returns -1 when end of partition was reached. + */ + int get_next() + { + int res; + if (end_of_partition) + return -1; + if ((res= tbl_cursor.get_next())) + return res; + + if (bound_tracker.compare_with_cache()) + { + end_of_partition= true; + return -1; + } + return 0; + } + + bool restore_last_row() + { + return tbl_cursor.restore_last_row(); + } +}; + +///////////////////////////////////////////////////////////////////////////// + + +/* + Window frame bound cursor. Abstract interface. + + @detail + The cursor moves within the partition that the current row is in. + It may be ahead or behind the current row. + + The cursor also assumes that the current row moves forward through the + partition and will move to the next adjacent partition after this one. + + List of all cursor classes: + Frame_cursor + Frame_range_n_top + Frame_range_n_bottom + + Frame_range_current_row_top + Frame_range_current_row_bottom + + Frame_n_rows_preceding + Frame_n_rows_following + + Frame_rows_current_row_top = Frame_n_rows_preceding(0) + Frame_rows_current_row_bottom + + // These handle both RANGE and ROWS-type bounds + Frame_unbounded_preceding + Frame_unbounded_following + + // This is not used as a frame bound, it counts rows in the partition: + Frame_unbounded_following_set_count : public Frame_unbounded_following + + @todo + - if we want to allocate this on the MEM_ROOT we should make sure + it is not re-allocated for every subquery execution. +*/ + +class Frame_cursor : public Sql_alloc +{ +public: + virtual void init(THD *thd, READ_RECORD *info, + SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + {} + + /* + Current row has moved to the next partition and is positioned on the first + row there. Position the frame bound accordingly. + + @param first - TRUE means this is the first partition + @param item - Put or remove rows from there. + + @detail + - if first==false, the caller guarantees that tbl->record[0] points at the + first row in the new partition. + - if first==true, we are just starting in the first partition and no such + guarantee is provided. + + - The callee may move tbl->file and tbl->record[0] to point to some other + row. + */ + virtual void pre_next_partition(longlong rownum, Item_sum* item){}; + virtual void next_partition(longlong rownum, Item_sum* item)=0; + + /* + The current row has moved one row forward. + Move this frame bound accordingly, and update the value of aggregate + function as necessary. + */ + virtual void pre_next_row(Item_sum* item){}; + virtual void next_row(Item_sum* item)=0; + + virtual ~Frame_cursor(){} +}; + +////////////////////////////////////////////////////////////////////////////// +// RANGE-type frames +////////////////////////////////////////////////////////////////////////////// + +/* + Frame_range_n_top handles the top end of RANGE-type frame. + + That is, it handles: + RANGE BETWEEN n PRECEDING AND ... + RANGE BETWEEN n FOLLOWING AND ... + + Top of the frame doesn't need to check for partition end, since bottom will + reach it before. +*/ + +class Frame_range_n_top : public Frame_cursor +{ + Table_read_cursor cursor; + + Cached_item_item *range_expr; + + Item *n_val; + Item *item_add; + + const bool is_preceding; + /* + 1 when order_list uses ASC ordering + -1 when order_list uses DESC ordering + */ + int order_direction; +public: + Frame_range_n_top(bool is_preceding_arg, Item *n_val_arg) : + n_val(n_val_arg), item_add(NULL), is_preceding(is_preceding_arg) + {} + + void init(THD *thd, READ_RECORD *info, + SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + cursor.init(info); + + DBUG_ASSERT(order_list->elements == 1); + Item *src_expr= order_list->first->item[0]; + if (order_list->first->direction == ORDER::ORDER_ASC) + order_direction= 1; + else + order_direction= -1; + + range_expr= (Cached_item_item*) new_Cached_item(thd, src_expr, FALSE); + + bool use_minus= is_preceding; + if (order_direction == -1) + use_minus= !use_minus; + + if (use_minus) + item_add= new (thd->mem_root) Item_func_minus(thd, src_expr, n_val); + else + item_add= new (thd->mem_root) Item_func_plus(thd, src_expr, n_val); + + item_add->fix_fields(thd, &item_add); + } + + void pre_next_partition(longlong rownum, Item_sum* item) + { + // Save the value of FUNC(current_row) + range_expr->fetch_value_from(item_add); + } + + void next_partition(longlong rownum, Item_sum* item) + { + cursor.move_to(rownum); + walk_till_non_peer(item); + } + + void pre_next_row(Item_sum* item) + { + range_expr->fetch_value_from(item_add); + } + + void next_row(Item_sum* item) + { + /* + Ok, our cursor is at the first row R where + (prev_row + n) >= R + We need to check about the current row. + */ + if (cursor.restore_last_row()) + { + if (order_direction * range_expr->cmp_read_only() <= 0) + return; + item->remove(); + } + walk_till_non_peer(item); + } + +private: + void walk_till_non_peer(Item_sum* item) + { + while (!cursor.get_next()) + { + if (order_direction * range_expr->cmp_read_only() <= 0) + break; + item->remove(); + } + } +}; + + +/* + Frame_range_n_bottom handles bottom end of RANGE-type frame. + + That is, it handles frame bounds in form: + RANGE BETWEEN ... AND n PRECEDING + RANGE BETWEEN ... AND n FOLLOWING + + Bottom end moves first so it needs to check for partition end + (todo: unless it's PRECEDING and in that case it doesnt) + (todo: factor out common parts with Frame_range_n_top into + a common ancestor) +*/ + +class Frame_range_n_bottom: public Frame_cursor +{ + Partition_read_cursor cursor; + + Cached_item_item *range_expr; + + Item *n_val; + Item *item_add; + + const bool is_preceding; + + bool end_of_partition; + + /* + 1 when order_list uses ASC ordering + -1 when order_list uses DESC ordering + */ + int order_direction; +public: + Frame_range_n_bottom(bool is_preceding_arg, Item *n_val_arg) : + n_val(n_val_arg), item_add(NULL), is_preceding(is_preceding_arg) + {} + + void init(THD *thd, READ_RECORD *info, + SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + cursor.init(thd, info, partition_list); + + DBUG_ASSERT(order_list->elements == 1); + Item *src_expr= order_list->first->item[0]; + + if (order_list->first->direction == ORDER::ORDER_ASC) + order_direction= 1; + else + order_direction= -1; + + range_expr= (Cached_item_item*) new_Cached_item(thd, src_expr, FALSE); + + bool use_minus= is_preceding; + if (order_direction == -1) + use_minus= !use_minus; + + if (use_minus) + item_add= new (thd->mem_root) Item_func_minus(thd, src_expr, n_val); + else + item_add= new (thd->mem_root) Item_func_plus(thd, src_expr, n_val); + + item_add->fix_fields(thd, &item_add); + } + + void pre_next_partition(longlong rownum, Item_sum* item) + { + // Save the value of FUNC(current_row) + range_expr->fetch_value_from(item_add); + + cursor.on_next_partition(rownum); + end_of_partition= false; + } + + void next_partition(longlong rownum, Item_sum* item) + { + cursor.move_to(rownum); + walk_till_non_peer(item); + } + + void pre_next_row(Item_sum* item) + { + if (end_of_partition) + return; + range_expr->fetch_value_from(item_add); + } + + void next_row(Item_sum* item) + { + if (end_of_partition) + return; + /* + Ok, our cursor is at the first row R where + (prev_row + n) >= R + We need to check about the current row. + */ + if (cursor.restore_last_row()) + { + if (order_direction * range_expr->cmp_read_only() < 0) + return; + item->add(); + } + walk_till_non_peer(item); + } + +private: + void walk_till_non_peer(Item_sum* item) + { + int res; + while (!(res= cursor.get_next())) + { + if (order_direction * range_expr->cmp_read_only() < 0) + break; + item->add(); + } + if (res) + end_of_partition= true; + } +}; + + +/* + RANGE BETWEEN ... AND CURRENT ROW, bottom frame bound for CURRENT ROW + ... + | peer1 + | peer2 <----- current_row + | peer3 + +-peer4 <----- the cursor points here. peer4 itself is included. + nonpeer1 + nonpeer2 + + This bound moves in front of the current_row. It should be a the first row + that is still a peer of the current row. +*/ + +class Frame_range_current_row_bottom: public Frame_cursor +{ + Partition_read_cursor cursor; + + Group_bound_tracker peer_tracker; + + bool dont_move; +public: + void init(THD *thd, READ_RECORD *info, + SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + cursor.init(thd, info, partition_list); + peer_tracker.init(thd, order_list); + } + + void pre_next_partition(longlong rownum, Item_sum* item) + { + // Save the value of the current_row + peer_tracker.check_if_next_group(); + cursor.on_next_partition(rownum); + if (rownum != 0) + { + // Add the current row now because our cursor has already seen it + item->add(); + } + } + + void next_partition(longlong rownum, Item_sum* item) + { + walk_till_non_peer(item); + } + + void pre_next_row(Item_sum* item) + { + dont_move= !peer_tracker.check_if_next_group(); + if (!dont_move) + item->add(); + } + + void next_row(Item_sum* item) + { + // Check if our cursor is pointing at a peer of the current row. + // If not, move forward until that becomes true + if (dont_move) + { + /* + Our current is not a peer of the current row. + No need to move the bound. + */ + return; + } + walk_till_non_peer(item); + } + +private: + void walk_till_non_peer(Item_sum* item) + { + /* + Walk forward until we've met first row that's not a peer of the current + row + */ + while (!cursor.get_next()) + { + if (peer_tracker.compare_with_cache()) + break; + item->add(); + } + } +}; + + +/* + RANGE BETWEEN CURRENT ROW AND .... Top CURRENT ROW, RANGE-type frame bound + + nonpeer1 + nonpeer2 + +-peer1 <----- the cursor points here. peer1 itself is included. + | peer2 + | peer3 <----- current_row + | peer4 + ... + + It moves behind the current_row. It is located right after the first peer of + the current_row. +*/ + +class Frame_range_current_row_top : public Frame_cursor +{ + Group_bound_tracker bound_tracker; + + Table_read_cursor cursor; + Group_bound_tracker peer_tracker; + + bool move; +public: + void init(THD *thd, READ_RECORD *info, + SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + bound_tracker.init(thd, partition_list); + + cursor.init(info); + peer_tracker.init(thd, order_list); + } + + void pre_next_partition(longlong rownum, Item_sum* item) + { + // Fetch the value from the first row + peer_tracker.check_if_next_group(); + cursor.move_to(rownum+1); + } + + void next_partition(longlong rownum, Item_sum* item) {} + + void pre_next_row(Item_sum* item) + { + // Check if the new current_row is a peer of the row that our cursor is + // pointing to. + move= peer_tracker.check_if_next_group(); + } + + void next_row(Item_sum* item) + { + if (move) + { + /* + Our cursor is pointing at the first row that was a peer of the previous + current row. Or, it was the first row in the partition. + */ + if (cursor.restore_last_row()) + { + // todo: need the following check ? + if (!peer_tracker.compare_with_cache()) + return; + item->remove(); + } + + do + { + if (cursor.get_next()) + return; + if (!peer_tracker.compare_with_cache()) + return; + item->remove(); + } + while (1); + } + } +}; + + +///////////////////////////////////////////////////////////////////////////// +// UNBOUNDED frame bounds (shared between RANGE and ROWS) +///////////////////////////////////////////////////////////////////////////// + +/* + UNBOUNDED PRECEDING frame bound +*/ +class Frame_unbounded_preceding : public Frame_cursor +{ +public: + void next_partition(longlong rownum, Item_sum* item) + { + /* + UNBOUNDED PRECEDING frame end just stays on the first row. + We are top of the frame, so we don't need to update the sum function. + */ + } + + void next_row(Item_sum* item) + { + /* Do nothing, UNBOUNDED PRECEDING frame end doesn't move. */ + } +}; + + +/* + UNBOUNDED FOLLOWING frame bound +*/ + +class Frame_unbounded_following : public Frame_cursor +{ +protected: + Partition_read_cursor cursor; + +public: + void init(THD *thd, READ_RECORD *info, SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + cursor.init(thd, info, partition_list); + } + + void pre_next_partition(longlong rownum, Item_sum* item) + { + cursor.on_next_partition(rownum); + } + + void next_partition(longlong rownum, Item_sum* item) + { + if (!rownum) + { + /* Read the first row */ + if (cursor.get_next()) + return; + } + item->add(); + + /* Walk to the end of the partition, updating the SUM function */ + while (!cursor.get_next()) + { + item->add(); + } + } + + void next_row(Item_sum* item) + { + /* Do nothing, UNBOUNDED FOLLOWING frame end doesn't move */ + } +}; + + +class Frame_unbounded_following_set_count : public Frame_unbounded_following +{ +public: + // pre_next_partition is inherited + + void next_partition(longlong rownum, Item_sum* item) + { + ulonglong num_rows_in_partition= 0; + if (!rownum) + { + /* Read the first row */ + if (cursor.get_next()) + return; + } + num_rows_in_partition++; + + /* Walk to the end of the partition, find how many rows there are. */ + while (!cursor.get_next()) + { + num_rows_in_partition++; + } + + Item_sum_window_with_row_count* item_with_row_count = + static_cast<Item_sum_window_with_row_count *>(item); + item_with_row_count->set_row_count(num_rows_in_partition); + } +}; + +///////////////////////////////////////////////////////////////////////////// +// ROWS-type frame bounds +///////////////////////////////////////////////////////////////////////////// +/* + ROWS $n PRECEDING frame bound + +*/ +class Frame_n_rows_preceding : public Frame_cursor +{ + /* Whether this is top of the frame or bottom */ + const bool is_top_bound; + const ha_rows n_rows; + + /* Number of rows that we need to skip before our cursor starts moving */ + ha_rows n_rows_to_skip; + + Table_read_cursor cursor; +public: + Frame_n_rows_preceding(bool is_top_bound_arg, ha_rows n_rows_arg) : + is_top_bound(is_top_bound_arg), n_rows(n_rows_arg) + {} + + void init(THD *thd, READ_RECORD *info, SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + cursor.init(info); + } + + void next_partition(longlong rownum, Item_sum* item) + { + /* + Position our cursor to point at the first row in the new partition + (for rownum=0, it is already there, otherwise, it lags behind) + */ + if (rownum != 0) + cursor.move_to(rownum); + + /* + Suppose the bound is ROWS 2 PRECEDING, and current row is row#n: + ... + n-3 + n-2 --- bound row + n-1 + n --- current_row + ... + The bound should point at row #(n-2). Bounds are inclusive, so + - bottom bound should add row #(n-2) into the window function + - top bound should remove row (#n-3) from the window function. + */ + n_rows_to_skip= n_rows + (is_top_bound? 1:0) - 1; + + /* Bottom bound "ROWS 0 PRECEDING" is a special case: */ + if (n_rows_to_skip == ha_rows(-1)) + { + cursor.get_next(); + item->add(); + n_rows_to_skip= 0; + } + } + + void next_row(Item_sum* item) + { + if (n_rows_to_skip) + { + n_rows_to_skip--; + return; + } + + if (cursor.get_next()) + return; // this is not expected to happen. + + if (is_top_bound) // this is frame start endpoint + item->remove(); + else + item->add(); + } +}; + + +/* + ROWS ... CURRENT ROW, Bottom bound. + + This case is moved to separate class because here we don't need to maintain + our own cursor, or check for partition bound. +*/ + +class Frame_rows_current_row_bottom : public Frame_cursor +{ +public: + void pre_next_partition(longlong rownum, Item_sum* item) + { + item->add(); + } + void next_partition(longlong rownum, Item_sum* item) {} + void pre_next_row(Item_sum* item) + { + /* Temp table's current row is current_row. Add it to the window func */ + item->add(); + } + void next_row(Item_sum* item) {}; +}; + + +/* + ROWS-type CURRENT ROW, top bound. + + This serves for processing "ROWS BETWEEN CURRENT ROW AND ..." frames. + + n-1 + n --+ --- current_row, and top frame bound + n+1 | + ... | + + when the current_row moves to row #n, this frame bound should remove the + row #(n-1) from the window function. + + In other words, we need what "ROWS PRECEDING 0" provides. +*/ +class Frame_rows_current_row_top: public Frame_n_rows_preceding + +{ +public: + Frame_rows_current_row_top() : + Frame_n_rows_preceding(true /*top*/, 0 /* n_rows */) + {} +}; + + +/* + ROWS $n FOLLOWING frame bound. +*/ + +class Frame_n_rows_following : public Frame_cursor +{ + /* Whether this is top of the frame or bottom */ + const bool is_top_bound; + const ha_rows n_rows; + + Partition_read_cursor cursor; + bool at_partition_end; +public: + Frame_n_rows_following(bool is_top_bound_arg, ha_rows n_rows_arg) : + is_top_bound(is_top_bound_arg), n_rows(n_rows_arg) + { + DBUG_ASSERT(n_rows > 0); + } + + void init(THD *thd, READ_RECORD *info, SQL_I_List<ORDER> *partition_list, + SQL_I_List<ORDER> *order_list) + { + cursor.init(thd, info, partition_list); + at_partition_end= false; + } + + void pre_next_partition(longlong rownum, Item_sum* item) + { + at_partition_end= false; + + cursor.on_next_partition(rownum); + + if (rownum != 0) + { + // This is only needed for "FOLLOWING 1". It is one row behind + cursor.move_to(rownum+1); + + // Current row points at the first row in the partition + if (is_top_bound) // this is frame top endpoint + item->remove(); + else + item->add(); + } + } + + /* Move our cursor to be n_rows ahead. */ + void next_partition(longlong rownum, Item_sum* item) + { + longlong i_end= n_rows + ((rownum==0)?1:0)- is_top_bound; + for (longlong i= 0; i < i_end; i++) + { + if (next_row_intern(item)) + break; + } + } + + void next_row(Item_sum* item) + { + if (at_partition_end) + return; + next_row_intern(item); + } + +private: + bool next_row_intern(Item_sum *item) + { + if (!cursor.get_next()) + { + if (is_top_bound) // this is frame start endpoint + item->remove(); + else + item->add(); + } + else + at_partition_end= true; + return at_partition_end; + } +}; + + +/* + Get a Frame_cursor for a frame bound. This is a "factory function". +*/ +Frame_cursor *get_frame_cursor(Window_frame *frame, bool is_top_bound) +{ + if (!frame) + { + /* + The docs say this about the lack of frame clause: + + Let WD be a window structure descriptor. + ... + If WD has no window framing clause, then + Case: + i) If the window ordering clause of WD is not present, then WF is the + window partition of R. + ii) Otherwise, WF consists of all rows of the partition of R that + precede R or are peers of R in the window ordering of the window + partition defined by the window ordering clause. + + For case #ii, the frame bounds essentially are "RANGE BETWEEN UNBOUNDED + PRECEDING AND CURRENT ROW". + For the case #i, without ordering clause all rows are considered peers, + so again the same frame bounds can be used. + */ + if (is_top_bound) + return new Frame_unbounded_preceding; + else + return new Frame_range_current_row_bottom; + } + + Window_frame_bound *bound= is_top_bound? frame->top_bound : + frame->bottom_bound; + + if (bound->precedence_type == Window_frame_bound::PRECEDING || + bound->precedence_type == Window_frame_bound::FOLLOWING) + { + bool is_preceding= (bound->precedence_type == + Window_frame_bound::PRECEDING); + + if (bound->offset == NULL) /* this is UNBOUNDED */ + { + /* The following serve both RANGE and ROWS: */ + if (is_preceding) + return new Frame_unbounded_preceding; + else + return new Frame_unbounded_following; + } + + if (frame->units == Window_frame::UNITS_ROWS) + { + longlong n_rows= bound->offset->val_int(); + /* These should be handled in the parser */ + DBUG_ASSERT(!bound->offset->null_value); + DBUG_ASSERT(n_rows >= 0); + if (is_preceding) + return new Frame_n_rows_preceding(is_top_bound, n_rows); + else + return new Frame_n_rows_following(is_top_bound, n_rows); + } + else + { + if (is_top_bound) + return new Frame_range_n_top(is_preceding, bound->offset); + else + return new Frame_range_n_bottom(is_preceding, bound->offset); + } + } + + if (bound->precedence_type == Window_frame_bound::CURRENT) + { + if (frame->units == Window_frame::UNITS_ROWS) + { + if (is_top_bound) + return new Frame_rows_current_row_top; + else + return new Frame_rows_current_row_bottom; + } + else + { + if (is_top_bound) + return new Frame_range_current_row_top; + else + return new Frame_range_current_row_bottom; + } + } + return NULL; +} + +void add_extra_frame_cursors(List<Frame_cursor> *cursors, + const Item_sum *window_func) +{ + switch (window_func->sum_func()) + { + case Item_sum::CUME_DIST_FUNC: + cursors->push_back(new Frame_unbounded_preceding); + cursors->push_back(new Frame_range_current_row_bottom); + break; + default: + cursors->push_back(new Frame_unbounded_preceding); + cursors->push_back(new Frame_rows_current_row_bottom); + } +} + +void get_window_func_required_cursors( + List<Frame_cursor> *result, const Item_window_func* item_win) +{ + if (item_win->requires_partition_size()) + result->push_back(new Frame_unbounded_following_set_count); + + /* + If it is not a regular window function that follows frame specifications, + specific cursors are required. + */ + if (item_win->is_frame_prohibited()) + { + add_extra_frame_cursors(result, item_win->window_func()); + return; + } + + /* A regular window function follows the frame specification. */ + result->push_back(get_frame_cursor(item_win->window_spec->window_frame, + false)); + result->push_back(get_frame_cursor(item_win->window_spec->window_frame, + true)); +} + +/* + Streamed window function computation with window frames. + + We make a single pass over the ordered temp.table, but we're using three + cursors: + - current row - the row that we're computing window func value for) + - start_bound - the start of the frame + - bottom_bound - the end of the frame + + All three cursors move together. + + @todo + Provided bounds have their 'cursors'... is it better to re-clone their + cursors or re-position them onto the current row? + + @detail + ROWS BETWEEN 3 PRECEDING -- frame start + AND 3 FOLLOWING -- frame end + + /------ frame end (aka BOTTOM) + Dataset start | + --------====*=======[*]========*========-------->> dataset end + | \ + | +-------- current row + | + \-------- frame start ("TOP") + + - frame_end moves forward and adds rows into the aggregate function. + - frame_start follows behind and removes rows from the aggregate function. + - current_row is the row where the value of aggregate function is stored. + + @TODO: Only the first cursor needs to check for run-out-of-partition + condition (Others can catch up by counting rows?) + +*/ + +bool compute_window_func_with_frames(Item_window_func *item_win, + TABLE *tbl, READ_RECORD *info) +{ + THD *thd= current_thd; + int err= 0; + + Item_sum *sum_func= item_win->window_func(); + /* This algorithm doesn't support DISTINCT aggregator */ + sum_func->set_aggregator(Aggregator::SIMPLE_AGGREGATOR); + + List<Frame_cursor> cursors; + get_window_func_required_cursors(&cursors, item_win); + + List_iterator_fast<Frame_cursor> it(cursors); + Frame_cursor *c; + while((c= it++)) + { + c->init(thd, info, item_win->window_spec->partition_list, + item_win->window_spec->order_list); + } + + bool is_error= false; + longlong rownum= 0; + uchar *rowid_buf= (uchar*) my_malloc(tbl->file->ref_length, MYF(0)); + + while (true) + { + /* Move the current_row */ + if ((err=info->read_record(info))) + { + break; /* End of file */ + } + bool partition_changed= item_win->check_if_partition_changed(); + + tbl->file->position(tbl->record[0]); + memcpy(rowid_buf, tbl->file->ref, tbl->file->ref_length); + + if (partition_changed || (rownum == 0)) + { + sum_func->clear(); + /* + pre_XXX functions assume that tbl->record[0] contains current_row, and + they may not change it. + */ + it.rewind(); + while ((c= it++)) + c->pre_next_partition(rownum, sum_func); + /* + We move bottom_bound first, because we want rows to be added into the + aggregate before top_bound attempts to remove them. + */ + it.rewind(); + while ((c= it++)) + c->next_partition(rownum, sum_func); + } + else + { + /* Again, both pre_XXX function can find current_row in tbl->record[0] */ + it.rewind(); + while ((c= it++)) + c->pre_next_row(sum_func); + + /* These make no assumptions about tbl->record[0] and may change it */ + it.rewind(); + while ((c= it++)) + c->next_row(sum_func); + } + rownum++; + + /* + Frame cursors may have made tbl->record[0] to point to some record other + than current_row. This applies to tbl->file's internal state, too. + Fix this by reading the current row again. + */ + tbl->file->ha_rnd_pos(tbl->record[0], rowid_buf); + store_record(tbl,record[1]); + item_win->save_in_field(item_win->result_field, true); + err= tbl->file->ha_update_row(tbl->record[1], tbl->record[0]); + if (err && err != HA_ERR_RECORD_IS_THE_SAME) + { + is_error= true; + break; + } + } + + my_free(rowid_buf); + cursors.delete_elements(); + return is_error? true: false; +} + + +/* Make a list that is a concation of two lists of ORDER elements */ + +static ORDER* concat_order_lists(MEM_ROOT *mem_root, ORDER *list1, ORDER *list2) +{ + if (!list1) + { + list1= list2; + list2= NULL; + } + + ORDER *res= NULL; // first element in the new list + ORDER *prev= NULL; // last element in the new list + ORDER *cur_list= list1; // this goes through list1, list2 + while (cur_list) + { + for (ORDER *cur= cur_list; cur; cur= cur->next) + { + ORDER *copy= (ORDER*)alloc_root(mem_root, sizeof(ORDER)); + memcpy(copy, cur, sizeof(ORDER)); + if (prev) + prev->next= copy; + prev= copy; + if (!res) + res= copy; + } + + cur_list= (cur_list == list1)? list2: NULL; + } + + if (prev) + prev->next= NULL; + + return res; +} + + +bool Window_func_runner::setup(THD *thd) +{ + win_func->setup_partition_border_check(thd); + + Item_sum::Sumfunctype type= win_func->window_func()->sum_func(); + switch (type) + { + case Item_sum::ROW_NUMBER_FUNC: + case Item_sum::RANK_FUNC: + case Item_sum::DENSE_RANK_FUNC: + { + /* + One-pass window function computation, walk through the rows and + assign values. + */ + compute_func= compute_window_func_values; + break; + } + case Item_sum::COUNT_FUNC: + case Item_sum::SUM_BIT_FUNC: + case Item_sum::SUM_FUNC: + case Item_sum::AVG_FUNC: + case Item_sum::PERCENT_RANK_FUNC: + case Item_sum::CUME_DIST_FUNC: + case Item_sum::NTILE_FUNC: + { + /* + Frame-aware window function computation. It does one pass, but + uses three cursors -frame_start, current_row, and frame_end. + */ + compute_func= compute_window_func_with_frames; + break; + } + default: + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "This aggregate as window function"); + return true; + } + + return false; +} + + +/* + Compute the value of window function for all rows. +*/ +bool Window_func_runner::exec(TABLE *tbl, SORT_INFO *filesort_result) +{ + THD *thd= current_thd; + win_func->set_phase_to_computation(); + + /* Go through the sorted array and compute the window function */ + READ_RECORD info; + + if (init_read_record(&info, thd, tbl, NULL/*select*/, filesort_result, + 0, 1, FALSE)) + return true; + + bool is_error= compute_func(win_func, tbl, &info); + + win_func->set_phase_to_retrieval(); + + end_read_record(&info); + + return is_error; +} + + +bool Window_funcs_sort::exec(JOIN *join) +{ + THD *thd= join->thd; + JOIN_TAB *join_tab= &join->join_tab[join->top_join_tab_count]; + + if (create_sort_index(thd, join, join_tab, filesort)) + return true; + + TABLE *tbl= join_tab->table; + SORT_INFO *filesort_result= join_tab->filesort_result; + + bool is_error= false; + List_iterator<Window_func_runner> it(runners); + Window_func_runner *runner; + + while ((runner= it++)) + { + if ((is_error= runner->exec(tbl, filesort_result))) + break; + } + + delete join_tab->filesort_result; + join_tab->filesort_result= NULL; + return is_error; +} + + +bool Window_funcs_sort::setup(THD *thd, SQL_SELECT *sel, + List_iterator<Item_window_func> &it) +{ + Item_window_func *win_func= it.peek(); + Item_window_func *prev_win_func; + + do + { + Window_func_runner *runner; + if (!(runner= new Window_func_runner(win_func)) || + runner->setup(thd)) + { + return true; + } + runners.push_back(runner); + it++; + prev_win_func= win_func; + } while ((win_func= it.peek()) && !(win_func->marker & SORTORDER_CHANGE_FLAG)); + + /* + The sort criteria must be taken from the last win_func in the group of + adjacent win_funcs that do not have SORTORDER_CHANGE_FLAG. + */ + Window_spec *spec = prev_win_func->window_spec; + + ORDER* sort_order= concat_order_lists(thd->mem_root, + spec->partition_list->first, + spec->order_list->first); + filesort= new (thd->mem_root) Filesort(sort_order, HA_POS_ERROR, true, NULL); + + /* Apply the same condition that the subsequent sort has. */ + filesort->select= sel; + + return false; +} + + +bool Window_funcs_computation::setup(THD *thd, + List<Item_window_func> *window_funcs, + JOIN_TAB *tab) +{ + order_window_funcs_by_window_specs(window_funcs); + + SQL_SELECT *sel= NULL; + if (tab->filesort && tab->filesort->select) + { + sel= tab->filesort->select; + DBUG_ASSERT(!sel->quick); + } + + Window_funcs_sort *srt; + List_iterator<Item_window_func> iter(*window_funcs); + while (iter.peek()) + { + if (!(srt= new Window_funcs_sort()) || + srt->setup(thd, sel, iter)) + { + return true; + } + win_func_sorts.push_back(srt, thd->mem_root); + } + return false; +} + + +bool Window_funcs_computation::exec(JOIN *join) +{ + List_iterator<Window_funcs_sort> it(win_func_sorts); + Window_funcs_sort *srt; + /* Execute each sort */ + while ((srt = it++)) + { + if (srt->exec(join)) + return true; + } + return false; +} + + +void Window_funcs_computation::cleanup() +{ + List_iterator<Window_funcs_sort> it(win_func_sorts); + Window_funcs_sort *srt; + while ((srt = it++)) + { + srt->cleanup(); + delete srt; + } +} + + +Explain_aggr_window_funcs* +Window_funcs_computation::save_explain_plan(MEM_ROOT *mem_root, + bool is_analyze) +{ + Explain_aggr_window_funcs *xpl= new Explain_aggr_window_funcs; + List_iterator<Window_funcs_sort> it(win_func_sorts); + Window_funcs_sort *srt; + while ((srt = it++)) + { + Explain_aggr_filesort *eaf= + new Explain_aggr_filesort(mem_root, is_analyze, srt->filesort); + xpl->sorts.push_back(eaf, mem_root); + } + return xpl; +} + +///////////////////////////////////////////////////////////////////////////// +// Unneeded comments (will be removed when we develop a replacement for +// the feature that was attempted here +///////////////////////////////////////////////////////////////////////////// + /* + TODO Get this code to set can_compute_window_function during preparation, + not during execution. + + The reason for this is the following: + Our single scan optimization for window functions without tmp table, + is valid, if and only if, we only need to perform one sorting operation, + via filesort. The cases where we need to perform one sorting operation only: + + * A select with only one window function. + * A select with multiple window functions, but they must have their + partition and order by clauses compatible. This means that one ordering + is acceptable for both window functions. + + For example: + partition by a, b, c; order by d, e results in sorting by a b c d e. + partition by a; order by d results in sorting by a d. + + This kind of sorting is compatible. The less specific partition does + not care for the order of b and c columns so it is valid if we sort + by those in case of equality over a. + + partition by a, b; order by d, e results in sorting by a b d e + partition by a; order by e results in sorting by a e + + This sorting is incompatible due to the order by clause. The partition by + clause is compatible, (partition by a) is a prefix for (partition by a, b) + However, order by e is not a prefix for order by d, e, thus it is not + compatible. + + The rule for having compatible sorting is thus: + Each partition order must contain the other window functions partitions + prefixes, or be a prefix itself. This must hold true for all partitions. + Analog for the order by clause. + */ +#if 0 + List<Item_window_func> window_functions; + SQL_I_List<ORDER> largest_partition; + SQL_I_List<ORDER> largest_order_by; + bool can_compute_window_live = !need_tmp; + // Construct the window_functions item list and check if they can be + // computed using only one sorting. + // + // TODO: Perhaps group functions into compatible sorting bins + // to minimize the number of sorting passes required to compute all of them. + while ((item= it++)) + { + if (item->type() == Item::WINDOW_FUNC_ITEM) + { + Item_window_func *item_win = (Item_window_func *) item; + window_functions.push_back(item_win); + if (!can_compute_window_live) + continue; // No point checking since we have to perform multiple sorts. + Window_spec *spec = item_win->window_spec; + // Having an empty partition list on one window function and a + // not empty list on a separate window function causes the sorting + // to be incompatible. + // + // Example: + // over (partition by a, order by x) && over (order by x). + // + // The first function requires an ordering by a first and then by x, + // while the seond function requires an ordering by x first. + // The same restriction is not required for the order by clause. + if (largest_partition.elements && !spec->partition_list.elements) + { + can_compute_window_live= FALSE; + continue; + } + can_compute_window_live= test_if_order_compatible(largest_partition, + spec->partition_list); + if (!can_compute_window_live) + continue; + + can_compute_window_live= test_if_order_compatible(largest_order_by, + spec->order_list); + if (!can_compute_window_live) + continue; + + if (largest_partition.elements < spec->partition_list.elements) + largest_partition = spec->partition_list; + if (largest_order_by.elements < spec->order_list.elements) + largest_order_by = spec->order_list; + } + } + if (can_compute_window_live && window_functions.elements && table_count == 1) + { + ha_rows examined_rows = 0; + ha_rows found_rows = 0; + ha_rows filesort_retval; + SORT_FIELD *s_order= (SORT_FIELD *) my_malloc(sizeof(SORT_FIELD) * + (largest_partition.elements + largest_order_by.elements) + 1, + MYF(MY_WME | MY_ZEROFILL | MY_THREAD_SPECIFIC)); + + size_t pos= 0; + for (ORDER* curr = largest_partition.first; curr; curr=curr->next, pos++) + s_order[pos].item = *curr->item; + + for (ORDER* curr = largest_order_by.first; curr; curr=curr->next, pos++) + s_order[pos].item = *curr->item; + + table[0]->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE), + MYF(MY_WME | MY_ZEROFILL| + MY_THREAD_SPECIFIC)); + + + filesort_retval= filesort(thd, table[0], s_order, + (largest_partition.elements + largest_order_by.elements), + this->select, HA_POS_ERROR, FALSE, + &examined_rows, &found_rows, + this->explain->ops_tracker.report_sorting(thd)); + table[0]->sort.found_records= filesort_retval; + + join_tab->read_first_record = join_init_read_record; + join_tab->records= found_rows; + + my_free(s_order); + } + else +#endif + + diff --git a/sql/sql_window.h b/sql/sql_window.h new file mode 100644 index 00000000000..54e39d827fe --- /dev/null +++ b/sql/sql_window.h @@ -0,0 +1,230 @@ + +#ifndef SQL_WINDOW_INCLUDED +#define SQL_WINDOW_INCLUDED + +#include "my_global.h" +#include "item.h" +#include "filesort.h" +#include "records.h" + +class Item_window_func; + +/* + Window functions module. + + Each instance of window function has its own element in SELECT_LEX::window_specs. +*/ + + +class Window_frame_bound : public Sql_alloc +{ + +public: + + enum Bound_precedence_type + { + PRECEDING, + CURRENT, // Used for CURRENT ROW window frame bounds + FOLLOWING + }; + + Bound_precedence_type precedence_type; + + + /* + For UNBOUNDED PRECEDING / UNBOUNDED FOLLOWING window frame bounds + precedence type is seto to PRECEDING / FOLLOWING and + offset is set to NULL. + The offset is not meaningful with precedence type CURRENT + */ + Item *offset; + + Window_frame_bound(Bound_precedence_type prec_type, + Item *offset_val) + : precedence_type(prec_type), offset(offset_val) {} + + bool is_unbounded() { return offset == NULL; } + +}; + + +class Window_frame : public Sql_alloc +{ + +public: + + enum Frame_units + { + UNITS_ROWS, + UNITS_RANGE + }; + + enum Frame_exclusion + { + EXCL_NONE, + EXCL_CURRENT_ROW, + EXCL_GROUP, + EXCL_TIES + }; + + Frame_units units; + + Window_frame_bound *top_bound; + + Window_frame_bound *bottom_bound; + + Frame_exclusion exclusion; + + Window_frame(Frame_units win_frame_units, + Window_frame_bound *win_frame_top_bound, + Window_frame_bound *win_frame_bottom_bound, + Frame_exclusion win_frame_exclusion) + : units(win_frame_units), top_bound(win_frame_top_bound), + bottom_bound(win_frame_bottom_bound), exclusion(win_frame_exclusion) {} + + bool check_frame_bounds(); + +}; + +class Window_spec : public Sql_alloc +{ + bool window_names_are_checked; + public: + virtual ~Window_spec() {} + + LEX_STRING *window_ref; + + SQL_I_List<ORDER> *partition_list; + + SQL_I_List<ORDER> *order_list; + + Window_frame *window_frame; + + Window_spec *referenced_win_spec; + + Window_spec(LEX_STRING *win_ref, + SQL_I_List<ORDER> *part_list, + SQL_I_List<ORDER> *ord_list, + Window_frame *win_frame) + : window_names_are_checked(false), window_ref(win_ref), + partition_list(part_list), order_list(ord_list), + window_frame(win_frame), referenced_win_spec(NULL) {} + + virtual char *name() { return NULL; } + + bool check_window_names(List_iterator_fast<Window_spec> &it); + + char *window_reference() { return window_ref ? window_ref->str : NULL; } + + void join_partition_and_order_lists() + { + *(partition_list->next)= order_list->first; + } + + void disjoin_partition_and_order_lists() + { + *(partition_list->next)= NULL; + } +}; + +class Window_def : public Window_spec +{ + public: + + LEX_STRING *window_name; + + Window_def(LEX_STRING *win_name, + LEX_STRING *win_ref, + SQL_I_List<ORDER> *part_list, + SQL_I_List<ORDER> *ord_list, + Window_frame *win_frame) + : Window_spec(win_ref, part_list, ord_list, win_frame), + window_name(win_name) {} + + char *name() { return window_name->str; } + +}; + +int setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, + List<Item> &fields, List<Item> &all_fields, + List<Window_spec> &win_specs, List<Item_window_func> &win_funcs); + + +////////////////////////////////////////////////////////////////////////////// +// Classes that make window functions computation a part of SELECT's query plan +////////////////////////////////////////////////////////////////////////////// + +typedef bool (*window_compute_func_t)(Item_window_func *item_win, + TABLE *tbl, READ_RECORD *info); + +/* + This handles computation of one window function. + + Currently, we make a spearate filesort() call for each window function. +*/ + +class Window_func_runner : public Sql_alloc +{ + Item_window_func *win_func; + + /* The function to use for computation*/ + window_compute_func_t compute_func; + +public: + Window_func_runner(Item_window_func *win_func_arg) : + win_func(win_func_arg) + {} + + // Set things up. Create filesort structures, etc + bool setup(THD *thd); + + // This sorts and runs the window function. + bool exec(TABLE *tbl, SORT_INFO *filesort_result); +}; + + +/* + Represents a group of window functions that require the same sorting of + rows and so share the filesort() call. + +*/ + +class Window_funcs_sort : public Sql_alloc +{ + List<Window_func_runner> runners; + + /* Window functions can be computed over this sorting */ + Filesort *filesort; +public: + bool setup(THD *thd, SQL_SELECT *sel, List_iterator<Item_window_func> &it); + bool exec(JOIN *join); + void cleanup() { delete filesort; } + + friend class Window_funcs_computation; +}; + + +struct st_join_table; +class Explain_aggr_window_funcs; +/* + This is a "window function computation phase": a single object of this class + takes care of computing all window functions in a SELECT. + + - JOIN optimizer is exected to call setup() during query optimization. + - JOIN::exec() should call exec() once it has collected join output in a + temporary table. +*/ + +class Window_funcs_computation : public Sql_alloc +{ + List<Window_funcs_sort> win_func_sorts; +public: + bool setup(THD *thd, List<Item_window_func> *window_funcs, st_join_table *tab); + bool exec(JOIN *join); + + Explain_aggr_window_funcs *save_explain_plan(MEM_ROOT *mem_root, bool is_analyze); + void cleanup(); +}; + + +#endif /* SQL_WINDOW_INCLUDED */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1870b3f719f..04c1ba7e99a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -55,6 +55,8 @@ #include "sql_signal.h" #include "sql_get_diagnostics.h" // Sql_cmd_get_diagnostics #include "sql_cte.h" +#include "sql_window.h" +#include "item_windowfunc.h" #include "event_parse_data.h" #include "create_options.h" #include <myisam.h> @@ -994,6 +996,8 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin) handlerton *db_type; st_select_lex *select_lex; struct p_elem_val *p_elem_value; + class Window_frame *window_frame; + class Window_frame_bound *window_frame_bound; udf_func *udf; /* enums */ @@ -1019,6 +1023,9 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin) enum sp_variable::enum_mode spvar_mode; enum thr_lock_type lock_type; enum enum_mysql_timestamp_type date_time_type; + enum Window_frame_bound::Bound_precedence_type bound_precedence_type; + enum Window_frame::Frame_units frame_units; + enum Window_frame::Frame_exclusion frame_exclusion; DDL_options_st object_ddl_options; } @@ -1030,10 +1037,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 121 shift/reduce conflicts. + Currently there are 123 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 121 +%expect 123 /* Comments for TOKENS. @@ -1156,6 +1163,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token CREATE /* SQL-2003-R */ %token CROSS /* SQL-2003-R */ %token CUBE_SYM /* SQL-2003-R */ +%token CUME_DIST_SYM %token CURDATE /* MYSQL-FUNC */ %token CURRENT_SYM /* SQL-2003-R */ %token CURRENT_USER /* SQL-2003-R */ @@ -1186,6 +1194,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token DELAYED_SYM %token DELAY_KEY_WRITE_SYM %token DELETE_SYM /* SQL-2003-R */ +%token DENSE_RANK_SYM %token DESC /* SQL-2003-N */ %token DESCRIBE /* SQL-2003-R */ %token DES_KEY_FILE @@ -1227,6 +1236,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token EVERY_SYM /* SQL-2003-N */ %token EXCHANGE_SYM %token EXAMINED_SYM +%token EXCLUDE_SYM %token EXECUTE_SYM /* SQL-2003-R */ %token EXISTS /* SQL-2003-R */ %token EXIT_SYM @@ -1245,6 +1255,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token FLOAT_NUM %token FLOAT_SYM /* SQL-2003-R */ %token FLUSH_SYM +%token FOLLOWING_SYM %token FORCE_SYM %token FOREIGN /* SQL-2003-R */ %token FOR_SYM /* SQL-2003-R */ @@ -1421,6 +1432,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token NO_SYM /* SQL-2003-R */ %token NO_WAIT_SYM %token NO_WRITE_TO_BINLOG +%token NTILE_SYM %token NULL_SYM /* SQL-2003-R */ %token NUM %token NUMBER_SYM /* SQL-2003-N */ @@ -1441,9 +1453,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ORDER_SYM /* SQL-2003-R */ %token OR_OR_SYM /* OPERATOR */ %token OR_SYM /* SQL-2003-R */ +%token OTHERS_SYM %token OUTER %token OUTFILE %token OUT_SYM /* SQL-2003-R */ +%token OVER_SYM %token OWNER_SYM %token PACK_KEYS_SYM %token PAGE_SYM @@ -1456,6 +1470,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token PARTITIONS_SYM %token PARTITIONING_SYM %token PASSWORD_SYM +%token PERCENT_RANK_SYM %token PERSISTENT_SYM %token PHASE_SYM %token PLUGINS_SYM @@ -1464,6 +1479,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token POLYGON %token PORT_SYM %token POSITION_SYM /* SQL-2003-N */ +%token PRECEDING_SYM %token PRECISION /* SQL-2003-R */ %token PREPARE_SYM /* SQL-2003-R */ %token PRESERVE_SYM @@ -1481,6 +1497,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token QUERY_SYM %token QUICK %token RANGE_SYM /* SQL-2003-R */ +%token RANK_SYM %token READS_SYM /* SQL-2003-R */ %token READ_ONLY_SYM %token READ_SYM /* SQL-2003-N */ @@ -1531,6 +1548,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ROW_FORMAT_SYM %token ROW_SYM /* SQL-2003-R */ %token ROW_COUNT_SYM /* SQL-2003-N */ +%token ROW_NUMBER_SYM %token RTREE_SYM %token SAVEPOINT_SYM /* SQL-2003-R */ %token SCHEDULE_SYM @@ -1621,6 +1639,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token TEXT_SYM %token THAN_SYM %token THEN_SYM /* SQL-2003-R */ +%token TIES_SYM %token TIMESTAMP /* SQL-2003-R */ %token TIMESTAMP_ADD %token TIMESTAMP_DIFF @@ -1641,6 +1660,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token TYPE_SYM /* SQL-2003-N */ %token UDF_RETURNS_SYM %token ULONGLONG_NUM +%token UNBOUNDED_SYM %token UNCOMMITTED_SYM /* SQL-2003-N */ %token UNDEFINED_SYM %token UNDERSCORE_CHARSET @@ -1682,6 +1702,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token WEIGHT_STRING_SYM %token WHEN_SYM /* SQL-2003-R */ %token WHERE /* SQL-2003-R */ +%token WINDOW_SYM %token WHILE_SYM %token WITH /* SQL-2003-R */ %token WITH_CUBE_SYM /* INTERNAL */ @@ -1821,6 +1842,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); simple_ident_nospvar simple_ident_q field_or_var limit_option part_func_expr + window_func_expr + window_func + simple_window_func function_call_keyword function_call_nonkeyword function_call_generic @@ -2010,6 +2034,15 @@ END_OF_INPUT %type <cond_info_item_name> condition_information_item_name; %type <cond_info_list> condition_information; +%type <NONE> opt_window_clause window_def_list window_def window_spec +%type <lex_str_ptr> window_name +%type <NONE> opt_window_ref opt_window_frame_clause +%type <frame_units> window_frame_units; +%type <NONE> window_frame_extent; +%type <frame_exclusion> opt_window_frame_exclusion; +%type <window_frame_bound> window_frame_start window_frame_bound; + + %type <NONE> '-' '+' '*' '/' '%' '(' ')' ',' '!' '{' '}' '&' '|' AND_SYM OR_SYM OR_OR_SYM BETWEEN_SYM CASE_SYM @@ -4952,7 +4985,7 @@ opt_create_partitioning: /* This part of the parser is about handling of the partition information. - It's first version was written by Mikael Ronström with lots of answers to + It's first version was written by Mikael Ronstrm with lots of answers to questions provided by Antony Curtis. The partition grammar can be called from three places. @@ -5662,7 +5695,19 @@ create_select: { Select->parsing_place= NO_MATTER; } - table_expression + /* + TODO: + The following sequence repeats a few times: + opt_table_expression + opt_order_clause + opt_limit_clause + opt_select_lock_type + Perhaps they can be grouped into a dedicated rule. + */ + opt_table_expression + opt_order_clause + opt_limit_clause + opt_select_lock_type { /* The following work only with the local list, the global list @@ -7415,7 +7460,7 @@ alter_commands: | remove_partitioning | partitioning /* - This part was added for release 5.1 by Mikael Ronström. + This part was added for release 5.1 by Mikael Ronstrm. From here we insert a number of commands to manage the partitions of a partitioned table such as adding partitions, dropping partitions, reorganising partitions in various manners. In future releases the list @@ -8502,7 +8547,10 @@ select_paren_derived: Lex->current_select->set_braces(true); } SELECT_SYM select_part2_derived - table_expression + opt_table_expression + opt_order_clause + opt_limit_clause + opt_select_lock_type { if (setup_select_in_parentheses(Lex)) MYSQL_YYABORT; @@ -8533,23 +8581,20 @@ select_part2: | select_options_and_item_list into opt_select_lock_type | select_options_and_item_list opt_into - from_clause - opt_where_clause - opt_group_clause - opt_having_clause + table_expression opt_order_clause opt_limit_clause opt_procedure_clause opt_into opt_select_lock_type { - if ($2 && $10) + if ($2 && $7) { /* double "INTO" clause */ my_error(ER_WRONG_USAGE, MYF(0), "INTO", "INTO"); MYSQL_YYABORT; } - if ($9 && ($2 || $10)) + if ($6 && ($2 || $7)) { /* "INTO" with "PROCEDURE ANALYSE" */ my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "INTO"); @@ -8572,24 +8617,25 @@ select_options_and_item_list: } ; + +/** + <table expression>, as in the SQL standard. +*/ table_expression: - opt_from_clause + from_clause opt_where_clause opt_group_clause opt_having_clause - opt_order_clause - opt_limit_clause - opt_procedure_clause - opt_select_lock_type + opt_window_clause ; -from_clause: - FROM table_reference_list +opt_table_expression: + /* Empty */ + | table_expression ; -opt_from_clause: - /* empty */ - | from_clause +from_clause: + FROM table_reference_list ; table_reference_list: @@ -9301,6 +9347,7 @@ simple_expr: | param_marker { $$= $1; } | variable | sum_expr + | window_func_expr | simple_expr OR_OR_SYM simple_expr { $$= new (thd->mem_root) Item_func_concat(thd, $1, $3); @@ -10436,6 +10483,92 @@ sum_expr: } ; +window_func_expr: + window_func OVER_SYM window_name + { + $$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, $3); + if ($$ == NULL) + MYSQL_YYABORT; + if (Select->add_window_func((Item_window_func *) $$)) + MYSQL_YYABORT; + } + | + window_func OVER_SYM window_spec + { + LEX *lex= Lex; + if (Select->add_window_spec(thd, lex->win_ref, + Select->group_list, + Select->order_list, + lex->win_frame)) + MYSQL_YYABORT; + $$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, + thd->lex->win_spec); + if ($$ == NULL) + MYSQL_YYABORT; + if (Select->add_window_func((Item_window_func *) $$)) + MYSQL_YYABORT; + } + ; + +window_func: + simple_window_func + | + sum_expr + ; + +simple_window_func: + ROW_NUMBER_SYM '(' ')' + { + $$= new (thd->mem_root) Item_sum_row_number(thd); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + RANK_SYM '(' ')' + { + $$= new (thd->mem_root) Item_sum_rank(thd); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + DENSE_RANK_SYM '(' ')' + { + $$= new (thd->mem_root) Item_sum_dense_rank(thd); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + PERCENT_RANK_SYM '(' ')' + { + $$= new (thd->mem_root) Item_sum_percent_rank(thd); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + CUME_DIST_SYM '(' ')' + { + $$= new (thd->mem_root) Item_sum_cume_dist(thd); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + NTILE_SYM '(' expr ')' + { + $$= new (thd->mem_root) Item_sum_ntile(thd, $3); + if ($$ == NULL) + MYSQL_YYABORT; + } + ; + +window_name: + ident + { + $$= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING)); + if ($$ == NULL) + MYSQL_YYABORT; + } + ; + variable: '@' { @@ -11086,7 +11219,10 @@ select_derived2: { Select->parsing_place= NO_MATTER; } - table_expression + opt_table_expression + opt_order_clause + opt_limit_clause + opt_select_lock_type ; get_select_lex: @@ -11371,6 +11507,155 @@ olap_opt: ; /* + optional window clause in select +*/ + +opt_window_clause: + /* empty */ + {} + | WINDOW_SYM + window_def_list + {} + ; + +window_def_list: + window_def_list ',' window_def + | window_def + ; + +window_def: + window_name AS window_spec + { + LEX *lex= Lex; + if (Select->add_window_def(thd, $1, lex->win_ref, + Select->group_list, + Select->order_list, + lex->win_frame )) + MYSQL_YYABORT; + } + ; + +window_spec: + '(' + { Select->prepare_add_window_spec(thd); } + opt_window_ref opt_window_partition_clause + opt_window_order_clause opt_window_frame_clause + ')' + ; + +opt_window_ref: + /* empty */ {} + | ident + { + thd->lex->win_ref= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING)); + if (thd->lex->win_ref == NULL) + MYSQL_YYABORT; + } + +opt_window_partition_clause: + /* empty */ { } + | PARTITION_SYM BY group_list + ; + +opt_window_order_clause: + /* empty */ { } + | ORDER_SYM BY order_list + ; + +opt_window_frame_clause: + /* empty */ {} + | window_frame_units window_frame_extent opt_window_frame_exclusion + { + LEX *lex= Lex; + lex->win_frame= + new (thd->mem_root) Window_frame($1, + lex->frame_top_bound, + lex->frame_bottom_bound, + $3); + if (lex->win_frame == NULL) + MYSQL_YYABORT; + } + ; + +window_frame_units: + ROWS_SYM { $$= Window_frame::UNITS_ROWS; } + | RANGE_SYM { $$= Window_frame::UNITS_RANGE; } + ; + +window_frame_extent: + window_frame_start + { + LEX *lex= Lex; + lex->frame_top_bound= $1; + lex->frame_bottom_bound= + new (thd->mem_root) + Window_frame_bound(Window_frame_bound::CURRENT, NULL); + if (lex->frame_bottom_bound == NULL) + MYSQL_YYABORT; + } + | BETWEEN_SYM window_frame_bound AND_SYM window_frame_bound + { + LEX *lex= Lex; + lex->frame_top_bound= $2; + lex->frame_bottom_bound= $4; + } + ; + +window_frame_start: + UNBOUNDED_SYM PRECEDING_SYM + { + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::PRECEDING, NULL); + if ($$ == NULL) + MYSQL_YYABORT; + } + | CURRENT_SYM ROW_SYM + { + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::CURRENT, NULL); + if ($$ == NULL) + MYSQL_YYABORT; + } + | literal PRECEDING_SYM + { + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::PRECEDING, $1); + if ($$ == NULL) + MYSQL_YYABORT; + } + ; + +window_frame_bound: + window_frame_start { $$= $1; } + | UNBOUNDED_SYM FOLLOWING_SYM + { + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::FOLLOWING, NULL); + if ($$ == NULL) + MYSQL_YYABORT; + } + | literal FOLLOWING_SYM + { + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::FOLLOWING, $1); + if ($$ == NULL) + MYSQL_YYABORT; + } + ; + +opt_window_frame_exclusion: + /* empty */ { $$= Window_frame::EXCL_NONE; } + | EXCLUDE_SYM CURRENT_SYM ROW_SYM + { $$= Window_frame::EXCL_CURRENT_ROW; } + | EXCLUDE_SYM GROUP_SYM + { $$= Window_frame::EXCL_GROUP; } + | EXCLUDE_SYM TIES_SYM + { $$= Window_frame::EXCL_TIES; } + | EXCLUDE_SYM NO_SYM OTHERS_SYM + { $$= Window_frame::EXCL_NONE; } + ; + +/* Order by statement in ALTER TABLE */ @@ -11675,9 +11960,11 @@ opt_procedure_clause: if (&lex->select_lex != lex->current_select) { + // SELECT * FROM t1 UNION SELECT * FROM t2 PROCEDURE ANALYSE(); my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "subquery"); MYSQL_YYABORT; } + lex->proc_list.elements=0; lex->proc_list.first=0; lex->proc_list.next= &lex->proc_list.first; @@ -16088,7 +16375,10 @@ union_option: query_specification: SELECT_SYM select_init2_derived - table_expression + opt_table_expression + opt_order_clause + opt_limit_clause + opt_select_lock_type { $$= Lex->current_select->master_unit()->first_select(); } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9d871703bfe..4bf202813f3 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4629,8 +4629,7 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var) mysql_mutex_lock(&LOCK_error_messages); res= (!locale->errmsgs->errmsgs && read_texts(ERRMSG_FILE, locale->errmsgs->language, - &locale->errmsgs->errmsgs, - ER_ERROR_LAST - ER_ERROR_FIRST + 1)); + &locale->errmsgs->errmsgs)); mysql_mutex_unlock(&LOCK_error_messages); if (res) { diff --git a/sql/table.cc b/sql/table.cc index 07e2876f5ba..dc1730b5b6f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5748,7 +5748,7 @@ void TABLE::mark_columns_used_by_index(uint index) MY_BITMAP *bitmap= &tmp_set; DBUG_ENTER("TABLE::mark_columns_used_by_index"); - enable_keyread(); + set_keyread(true); bitmap_clear_all(bitmap); mark_columns_used_by_index_no_reset(index, bitmap); column_bitmaps_set(bitmap, bitmap); @@ -5769,7 +5769,7 @@ void TABLE::add_read_columns_used_by_index(uint index) MY_BITMAP *bitmap= &tmp_set; DBUG_ENTER("TABLE::add_read_columns_used_by_index"); - enable_keyread(); + set_keyread(true); bitmap_copy(bitmap, read_set); mark_columns_used_by_index_no_reset(index, bitmap); column_bitmaps_set(bitmap, write_set); @@ -5792,7 +5792,7 @@ void TABLE::restore_column_maps_after_mark_index() { DBUG_ENTER("TABLE::restore_column_maps_after_mark_index"); - disable_keyread(); + set_keyread(false); default_column_bitmaps(); file->column_bitmaps_signal(); DBUG_VOID_RETURN; diff --git a/sql/table.h b/sql/table.h index 1c461d96097..a105df31e93 100644 --- a/sql/table.h +++ b/sql/table.h @@ -213,8 +213,13 @@ typedef struct st_order { Field *fast_field_copier_setup; int counter; /* position in SELECT list, correct only if counter_used is true*/ - bool asc; /* true if ascending */ - bool free_me; /* true if item isn't shared */ + enum enum_order { + ORDER_NOT_RELEVANT, + ORDER_ASC, + ORDER_DESC + }; + + enum_order direction; /* Requested direction of ordering */ bool in_field_list; /* true if in select field list */ bool counter_used; /* parameter was counter of columns */ Field *field; /* If tmp-table group */ @@ -1239,7 +1244,9 @@ public: bool alias_name_used; /* true if table_name is alias */ bool get_fields_in_item_tree; /* Signal to fix_field */ bool m_needs_reopen; +private: bool created; /* For tmp tables. TRUE <=> tmp table was actually created.*/ +public: #ifdef HAVE_REPLICATION /* used in RBR Triggers */ bool master_had_triggers; @@ -1351,30 +1358,46 @@ public: map= map_arg; tablenr= tablenr_arg; } - inline void enable_keyread() + + void set_keyread(bool flag) { - DBUG_ENTER("enable_keyread"); - DBUG_ASSERT(key_read == 0); - key_read= 1; - file->extra(HA_EXTRA_KEYREAD); - DBUG_VOID_RETURN; + DBUG_ASSERT(file); + if (flag && !key_read) + { + key_read= 1; + if (is_created()) + file->extra(HA_EXTRA_KEYREAD); + } + else if (!flag && key_read) + { + key_read= 0; + if (is_created()) + file->extra(HA_EXTRA_NO_KEYREAD); + } } + + /// Return true if table is instantiated, and false otherwise. + bool is_created() const { return created; } + + /** + Set the table as "created", and enable flags in storage engine + that could not be enabled without an instantiated table. + */ + void set_created() + { + if (created) + return; + if (key_read) + file->extra(HA_EXTRA_KEYREAD); + created= true; + } + /* Returns TRUE if the table is filled at execution phase (and so, the optimizer must not do anything that depends on the contents of the table, like range analysis or constant table detection) */ bool is_filled_at_execution(); - inline void disable_keyread() - { - DBUG_ENTER("disable_keyread"); - if (key_read) - { - key_read= 0; - file->extra(HA_EXTRA_NO_KEYREAD); - } - DBUG_VOID_RETURN; - } bool update_const_key_parts(COND *conds); @@ -1941,6 +1964,7 @@ struct TABLE_LIST bool updating; /* for replicate-do/ignore table */ bool force_index; /* prefer index over table scan */ bool ignore_leaves; /* preload only non-leaf nodes */ + bool crashed; /* Table was found crashed */ table_map dep_tables; /* tables the table depends on */ table_map on_expr_dep_tables; /* tables on expression depends on */ struct st_nested_join *nested_join; /* if the element is a nested join */ @@ -2049,6 +2073,11 @@ struct TABLE_LIST /* TRUE <=> this table is a const one and was optimized away. */ bool optimized_away; + /** + TRUE <=> already materialized. Valid only for materialized derived + tables/views. + */ + bool materialized; /* I_S: Flags to open_table (e.g. OPEN_TABLE_ONLY or OPEN_VIEW_ONLY) */ uint i_s_requested_object; diff --git a/sql/unireg.h b/sql/unireg.h index 10751b6ec93..251597c1884 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -43,15 +43,16 @@ #define PLUGINDIR "lib/plugin" #endif -#define CURRENT_THD_ERRMSGS current_thd->variables.errmsgs -#define DEFAULT_ERRMSGS my_default_lc_messages->errmsgs->errmsgs - -#define ER(X) CURRENT_THD_ERRMSGS[(X) - ER_ERROR_FIRST] -#define ER_DEFAULT(X) DEFAULT_ERRMSGS[(X) - ER_ERROR_FIRST] -#define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : "Invalid error code") -#define ER_SAFE_THD(T,X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER_THD(T,X) : "Invalid error code") -#define ER_THD(thd,X) ((thd)->variables.errmsgs[(X) - ER_ERROR_FIRST]) -#define ER_THD_OR_DEFAULT(thd,X) ((thd) ? ER_THD(thd, X) : ER_DEFAULT(X)) +#define MAX_ERROR_RANGES 4 /* 1000-2000, 2000-3000, 3000-4000, 4000-5000 */ +#define ERRORS_PER_RANGE 1000 + +#define DEFAULT_ERRMSGS my_default_lc_messages->errmsgs->errmsgs +#define CURRENT_THD_ERRMSGS (current_thd)->variables.errmsgs + +#define ER_DEFAULT(X) DEFAULT_ERRMSGS[((X)-ER_ERROR_FIRST) / ERRORS_PER_RANGE][(X)% ERRORS_PER_RANGE] +#define ER_THD(thd,X) ((thd)->variables.errmsgs[((X)-ER_ERROR_FIRST) / ERRORS_PER_RANGE][(X) % ERRORS_PER_RANGE]) +#define ER(X) ER_THD(current_thd, (X)) +#define ER_THD_OR_DEFAULT(thd,X) ((thd) ? ER_THD(thd, (X)) : ER_DEFAULT(X)) #define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH) #define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index f84ebe4dbb9..3cdf95e2bf2 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -202,7 +202,7 @@ wsrep_uuid_t local_uuid = WSREP_UUID_UNDEFINED; wsrep_seqno_t local_seqno = WSREP_SEQNO_UNDEFINED; long wsrep_protocol_version = 3; -wsp::Config_state wsrep_config_state; +wsp::Config_state *wsrep_config_state; // Boolean denoting if server is in initial startup phase. This is needed // to make sure that main thread waiting in wsrep_sst_wait() is signaled @@ -281,7 +281,7 @@ wsrep_view_handler_cb (void* app_ctx, *sst_req = NULL; *sst_req_len = 0; - wsrep_member_status_t memb_status= wsrep_config_state.get_status(); + wsrep_member_status_t memb_status= wsrep_config_state->get_status(); if (memcmp(&cluster_uuid, &view->state_id.uuid, sizeof(wsrep_uuid_t))) { @@ -442,7 +442,7 @@ wsrep_view_handler_cb (void* app_ctx, out: if (view->status == WSREP_VIEW_PRIMARY) wsrep_startup= FALSE; - wsrep_config_state.set(memb_status, view); + wsrep_config_state->set(memb_status, view); return WSREP_CB_SUCCESS; } @@ -484,7 +484,7 @@ static void wsrep_synced_cb(void* app_ctx) signal_main= true; } - wsrep_config_state.set(WSREP_MEMBER_SYNCED); + wsrep_config_state->set(WSREP_MEMBER_SYNCED); mysql_mutex_unlock (&LOCK_wsrep_ready); if (signal_main) @@ -753,6 +753,8 @@ done: /* Initialize wsrep thread LOCKs and CONDs */ void wsrep_thr_init() { + DBUG_ENTER("wsrep_thr_init"); + wsrep_config_state = new wsp::Config_state; #ifdef HAVE_PSI_INTERFACE mysql_mutex_register("sql", wsrep_mutexes, array_elements(wsrep_mutexes)); mysql_cond_register("sql", wsrep_conds, array_elements(wsrep_conds)); @@ -772,6 +774,7 @@ void wsrep_thr_init() mysql_mutex_init(key_LOCK_wsrep_slave_threads, &LOCK_wsrep_slave_threads, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_wsrep_desync, &LOCK_wsrep_desync, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_wsrep_config_state, &LOCK_wsrep_config_state, MY_MUTEX_INIT_FAST); + DBUG_VOID_RETURN; } @@ -819,6 +822,8 @@ void wsrep_deinit(bool free_options) /* Destroy wsrep thread LOCKs and CONDs */ void wsrep_thr_deinit() { + if (!wsrep_config_state) + return; // Never initialized mysql_mutex_destroy(&LOCK_wsrep_ready); mysql_cond_destroy(&COND_wsrep_ready); mysql_mutex_destroy(&LOCK_wsrep_sst); @@ -832,6 +837,8 @@ void wsrep_thr_deinit() mysql_mutex_destroy(&LOCK_wsrep_slave_threads); mysql_mutex_destroy(&LOCK_wsrep_desync); mysql_mutex_destroy(&LOCK_wsrep_config_state); + delete wsrep_config_state; + wsrep_config_state= 0; // Safety } void wsrep_recover() diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 6d04527cbcb..562bc7effb4 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -1256,7 +1256,7 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx, /* This will be reset when sync callback is called. * Should we set wsrep_ready to FALSE here too? */ - wsrep_config_state.set(WSREP_MEMBER_DONOR); + wsrep_config_state->set(WSREP_MEMBER_DONOR); const char* method = (char*)msg; size_t method_len = strlen (method); diff --git a/sql/wsrep_utils.h b/sql/wsrep_utils.h index ed699eabec9..54235cf5273 100644 --- a/sql/wsrep_utils.h +++ b/sql/wsrep_utils.h @@ -233,7 +233,7 @@ private: } /* namespace wsp */ -extern wsp::Config_state wsrep_config_state; +extern wsp::Config_state *wsrep_config_state; namespace wsp { /* a class to manage env vars array */ diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index 573357b54ee..0dff05567d7 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -458,12 +458,22 @@ dict_boot(void) if (err == DB_SUCCESS) { if (srv_read_only_mode && !ibuf_is_empty()) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Change buffer must be empty when --innodb-read-only " - "is set!"); + if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Change buffer must be empty when --innodb-read-only " + "is set! " + "You can try to recover the database with innodb_force_recovery=5"); + + err = DB_ERROR; + } else { + ib_logf(IB_LOG_LEVEL_WARN, + "Change buffer not empty when --innodb-read-only " + "is set! but srv_force_recovery = %d, ignoring.", + srv_force_recovery); + } + } - err = DB_ERROR; - } else { + if (err == DB_SUCCESS) { /* Load definitions of other indexes on system tables */ dict_load_sys_table(dict_sys->sys_tables); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index d918b21d779..22abf592adc 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -737,11 +737,9 @@ fil_node_open_file( } } - if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) { + if (size_bytes >= (1024*1024)) { /* Truncate the size to whole extent size. */ - size_bytes = ut_2pow_round(size_bytes, - FSP_EXTENT_SIZE * - UNIV_PAGE_SIZE); + size_bytes = ut_2pow_round(size_bytes, (1024*1024)); } if (!fsp_flags_is_compressed(flags)) { diff --git a/storage/innobase/include/log0crypt.h b/storage/innobase/include/log0crypt.h index 7e737853465..6b164e90d6e 100644 --- a/storage/innobase/include/log0crypt.h +++ b/storage/innobase/include/log0crypt.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. -Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -117,4 +117,12 @@ log_crypt_print_error( /*==================*/ log_crypt_err_t err_info); /*!< out: error info */ +/*********************************************************************//** +Print checkpoint no from log block and all encryption keys from +checkpoints if they are present. Used for problem analysis. */ +void +log_crypt_print_checkpoint_keys( +/*============================*/ + const byte* log_block); + #endif // log0crypt.h diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index e2635248b03..176f132704a 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -88,15 +88,32 @@ private: the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() -# elif defined(HAVE_ATOMIC_BUILTINS) +# elif defined(__powerpc__) +#include <sys/platform/ppc.h> # define UT_RELAX_CPU() do { \ - volatile lint volatile_var; \ - os_compare_and_swap_lint(&volatile_var, 0, 1); \ + volatile lint volatile_var = __ppc_get_timebase(); \ } while (0) # else # define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */ # endif +#if defined (__GNUC__) +# define UT_COMPILER_BARRIER() __asm__ __volatile__ ("":::"memory") +#elif defined (_MSC_VER) +# define UT_COMPILER_BARRIER() _ReadWriteBarrier() +#else +# define UT_COMPILER_BARRIER() +#endif + +# if defined(HAVE_HMT_PRIORITY_INSTRUCTION) +#include <sys/platform/ppc.h> +# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low() +# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med() +# else +# define UT_LOW_PRIORITY_CPU() ((void)0) +# define UT_RESUME_PRIORITY_CPU() ((void)0) +# endif + /*********************************************************************//** Delays execution for at most max_wait_us microseconds or returns earlier if cond becomes true. @@ -342,7 +359,7 @@ Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ UNIV_INTERN -ulint +void ut_delay( /*=====*/ ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 165db2d33ed..bc7ec1d221b 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -6817,7 +6817,7 @@ lock_clust_rec_modify_check_and_lock( lock_rec_convert_impl_to_expl(block, rec, index, offsets); lock_mutex_enter(); - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); ut_ad(lock_table_has(trx, index->table, LOCK_IX)); @@ -6877,7 +6877,7 @@ lock_sec_rec_modify_check_and_lock( index record, and this would not have been possible if another active transaction had modified this secondary index record. */ - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); lock_mutex_enter(); ut_ad(lock_table_has(trx, index->table, LOCK_IX)); @@ -6977,7 +6977,7 @@ lock_sec_rec_read_check_and_lock( lock_rec_convert_impl_to_expl(block, rec, index, offsets); } - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); lock_mutex_enter(); ut_ad(mode != LOCK_X @@ -7051,7 +7051,7 @@ lock_clust_rec_read_check_and_lock( } lock_mutex_enter(); - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); ut_ad(mode != LOCK_X || lock_table_has(trx, index->table, LOCK_IX)); diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc index 852148899e9..db2e84d7e45 100644 --- a/storage/innobase/log/log0crypt.cc +++ b/storage/innobase/log/log0crypt.cc @@ -127,12 +127,35 @@ static const crypt_info_t* get_crypt_info( /*===========*/ - const byte* log_block) { + const byte* log_block) +{ ib_uint64_t checkpoint_no = log_block_get_checkpoint_no(log_block); return get_crypt_info(checkpoint_no); } /*********************************************************************//** +Print checkpoint no from log block and all encryption keys from +checkpoints if they are present. Used for problem analysis. */ +void +log_crypt_print_checkpoint_keys( +/*============================*/ + const byte* log_block) +{ + ib_uint64_t checkpoint_no = log_block_get_checkpoint_no(log_block); + + if (crypt_info.size()) { + fprintf(stderr, "InnoDB: redo log checkpoint: %lu [ chk key ]: ", checkpoint_no); + for (size_t i = 0; i < crypt_info.size(); i++) { + struct crypt_info_t* it = &crypt_info[i]; + fprintf(stderr, "[ %lu %u ] ", + it->checkpoint_no, + it->key_version); + } + fprintf(stderr, "\n"); + } +} + +/*********************************************************************//** Call AES CTR to encrypt/decrypt log blocks. */ static Crypt_result @@ -278,12 +301,22 @@ Add crypt info to set if it is not already present @return true if successfull, false if not- */ static bool -add_crypt_info(crypt_info_t* info) +add_crypt_info( +/*===========*/ + crypt_info_t* info, /*!< in: crypt info */ + bool checkpoint_read)/*!< in: do we read checkpoint */ { + const crypt_info_t* found=NULL; /* so that no one is searching array while we modify it */ ut_ad(mutex_own(&(log_sys->mutex))); - if (get_crypt_info(info->checkpoint_no) != NULL) { + found = get_crypt_info(info->checkpoint_no); + + /* If one crypt info is found then we add a new one only if we + are reading checkpoint from the log. New checkpoints will always + use the first created crypt info. */ + if (found != NULL && + ( found->checkpoint_no == info->checkpoint_no || !checkpoint_read)) { // already present... return true; } @@ -356,7 +389,7 @@ log_crypt_set_ver_and_key( } - add_crypt_info(&info); + add_crypt_info(&info, false); } /******************************************************** @@ -514,7 +547,7 @@ log_crypt_read_checkpoint_buf( memcpy(info.crypt_msg, buf + 8, MY_AES_BLOCK_SIZE); memcpy(info.crypt_nonce, buf + 24, MY_AES_BLOCK_SIZE); - if (!add_crypt_info(&info)) { + if (!add_crypt_info(&info, true)) { return false; } buf += LOG_CRYPT_ENTRY_SIZE; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 2304f4885c2..d574cd55397 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -2714,6 +2714,8 @@ recv_scan_log_recs( /* Garbage or an incompletely written log block */ + /* Print checkpoint encryption keys if present */ + log_crypt_print_checkpoint_keys(log_block); finished = TRUE; if (maybe_encrypted) { diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index a5970c1dc3f..bde40220db3 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -45,9 +45,6 @@ Created 5/11/1994 Heikki Tuuri # include <string> #endif /* UNIV_HOTBACKUP */ -/** A constant to prevent the compiler from optimizing ut_delay() away. */ -UNIV_INTERN ibool ut_always_false = FALSE; - #ifdef __WIN__ /*****************************************************************//** NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix @@ -397,25 +394,21 @@ Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ UNIV_INTERN -ulint +void ut_delay( /*=====*/ ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */ { - ulint i, j; + ulint i; - j = 0; + UT_LOW_PRIORITY_CPU(); for (i = 0; i < delay * 50; i++) { - j += i; UT_RELAX_CPU(); + UT_COMPILER_BARRIER(); } - if (ut_always_false) { - ut_always_false = (ibool) j; - } - - return(j); + UT_RESUME_PRIORITY_CPU(); } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 947a019827c..75e029a7c9f 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -143,7 +143,7 @@ static mysql_mutex_t *mrn_LOCK_open; # define MRN_NEED_M_LOCK_TYPE_CHECK_FOR_WRAPPER_EXTERNAL_LOCK #endif -#if MYSQL_VERSION_ID >= 50603 && !defined(MRN_MARIADB_P) +#if MYSQL_VERSION_ID >= 50603 || defined(MRN_MARIADB_P) # define MRN_ORDER_IS_ASC(order) ((order)->direction == ORDER::ORDER_ASC) #else # define MRN_ORDER_IS_ASC(order) ((order)->asc) diff --git a/storage/mroonga/mrn_table.cpp b/storage/mroonga/mrn_table.cpp index 144dbe0c530..96f24ff2e00 100644 --- a/storage/mroonga/mrn_table.cpp +++ b/storage/mroonga/mrn_table.cpp @@ -998,7 +998,7 @@ int mrn_free_share(MRN_SHARE *share) TABLE_SHARE *mrn_get_table_share(TABLE_LIST *table_list, int *error) { - uint key_length; + uint key_length __attribute__((unused)); TABLE_SHARE *share; THD *thd = current_thd; MRN_DBUG_ENTER_FUNCTION(); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 6215a5584d0..a41a943cd04 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -8134,7 +8134,7 @@ int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( DBUG_PRINT("info",("spider error=%d", error_num)); DBUG_RETURN(error_num); } - if (order->asc) + if (order->direction == ORDER::ORDER_ASC) { if (str->reserve(SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index e263cabb0d1..5b387924b1e 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -602,6 +602,12 @@ public: // ICP introduced in MariaDB 5.5 Item* idx_cond_push(uint keyno, class Item* idx_cond); +#ifdef MARIADB_BASE_VERSION + void cancel_pushed_idx_cond() + { + invalidate_icp(); + } +#endif #if TOKU_INCLUDE_ALTER_56 public: diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_all.py b/storage/tokudb/mysql-test/tokudb/t/change_column_all.py index 04e7d143696..75cffb88dff 100644 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_all.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_all.py @@ -168,6 +168,7 @@ def header(): print "# generated from change_column_all.py" print "# test random column change on wide tables" print "source include/have_tokudb.inc;" + print "--source include/big_test.inc" print "--disable_warnings" print "DROP TABLE IF EXISTS t, ti;" print "--enable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/simple_icp.result b/storage/tokudb/mysql-test/tokudb_bugs/r/simple_icp.result index 2975d7d3116..12fec571d87 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/simple_icp.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/simple_icp.result @@ -110,7 +110,7 @@ a b c d e 5 1 10 NULL NULL show status like '%Handler_read_prev%'; Variable_name Value -Handler_read_prev 41 +Handler_read_prev 800 flush status; show status like '%Handler_read_prev%'; Variable_name Value @@ -142,7 +142,7 @@ a b c d e 20 1 10 NULL NULL show status like '%Handler_read_prev%'; Variable_name Value -Handler_read_prev 21 +Handler_read_prev 400 flush status; show status like '%Handler_read_next%'; Variable_name Value diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/part_supported_sql_func_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/part_supported_sql_func_tokudb.result index 82cbcbc311e..5b860845490 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/part_supported_sql_func_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/part_supported_sql_func_tokudb.result @@ -47,6 +47,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with abs(col1) ------------------------------------------------------------------------- +begin; insert into t1 values (5 ); insert into t1 values (13 ); insert into t2 values (5 ); @@ -55,6 +56,7 @@ insert into t2 values (17 ); insert into t3 values (5 ); insert into t3 values (13 ); insert into t3 values (17 ); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6; @@ -217,12 +219,14 @@ colint col1 50 56 51 34 55 123 +begin; update t1 set col1=15 where col1=5 ; update t2 set col1=15 where col1=5 ; update t3 set col1=15 where col1=5 ; update t4 set col1=15 where col1=5 ; update t5 set col1=15 where col1=5 ; update t6 set col1=15 where col1=5 ; +commit; select * from t1 order by col1; col1 13 @@ -877,12 +881,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with abs(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1=13 ; delete from t2 where col1=13 ; delete from t3 where col1=13 ; delete from t4 where col1=13 ; delete from t5 where col1=13 ; delete from t6 where col1=13 ; +commit; select * from t1 order by col1; col1 15 @@ -986,12 +992,14 @@ colint col1 50 56 51 34 55 123 +begin; insert into t1 values (13 ); insert into t2 values (13 ); insert into t3 values (13 ); insert into t4 values (60,13 ); insert into t5 values (60,13 ); insert into t6 values (60,13 ); +commit; select * from t1 order by col1; col1 13 @@ -1274,12 +1282,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with abs(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1=13 ; delete from t22 where col1=13 ; delete from t33 where col1=13 ; delete from t44 where col1=13 ; delete from t55 where col1=13 ; delete from t66 where col1=13 ; +commit; select * from t11 order by col1; col1 15 @@ -1383,12 +1393,14 @@ colint col1 50 56 51 34 55 123 +begin; insert into t11 values (13 ); insert into t22 values (13 ); insert into t33 values (13 ); insert into t44 values (60,13 ); insert into t55 values (60,13 ); insert into t66 values (60,13 ); +commit; select * from t11 order by col1; col1 13 @@ -1732,6 +1744,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with mod(col1,10) ------------------------------------------------------------------------- +begin; insert into t1 values (5); insert into t1 values (19); insert into t2 values (5); @@ -1740,6 +1753,7 @@ insert into t2 values (17); insert into t3 values (5); insert into t3 values (19); insert into t3 values (17); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6; @@ -1902,12 +1916,14 @@ colint col1 50 56 51 34 55 123 +begin; update t1 set col1=15 where col1=5; update t2 set col1=15 where col1=5; update t3 set col1=15 where col1=5; update t4 set col1=15 where col1=5; update t5 set col1=15 where col1=5; update t6 set col1=15 where col1=5; +commit; select * from t1 order by col1; col1 15 @@ -2562,12 +2578,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with mod(col1,10) ------------------------------------------------------------------------- +begin; delete from t1 where col1=19; delete from t2 where col1=19; delete from t3 where col1=19; delete from t4 where col1=19; delete from t5 where col1=19; delete from t6 where col1=19; +commit; select * from t1 order by col1; col1 15 @@ -2673,12 +2691,14 @@ colint col1 50 56 51 34 55 123 +begin; insert into t1 values (19); insert into t2 values (19); insert into t3 values (19); insert into t4 values (60,19); insert into t5 values (60,19); insert into t6 values (60,19); +commit; select * from t1 order by col1; col1 15 @@ -2970,12 +2990,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with mod(col1,10) ------------------------------------------------------------------------- +begin; delete from t11 where col1=19; delete from t22 where col1=19; delete from t33 where col1=19; delete from t44 where col1=19; delete from t55 where col1=19; delete from t66 where col1=19; +commit; select * from t11 order by col1; col1 15 @@ -3081,12 +3103,14 @@ colint col1 50 56 51 34 55 123 +begin; insert into t11 values (19); insert into t22 values (19); insert into t33 values (19); insert into t44 values (60,19); insert into t55 values (60,19); insert into t66 values (60,19); +commit; select * from t11 order by col1; col1 15 @@ -3439,6 +3463,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with day(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-02-03'); insert into t1 values ('2006-01-17'); insert into t2 values ('2006-02-03'); @@ -3447,6 +3472,7 @@ insert into t2 values ('2006-01-25'); insert into t3 values ('2006-02-03'); insert into t3 values ('2006-01-17'); insert into t3 values ('2006-01-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -3486,12 +3512,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-02-05' where col1='2006-02-03'; update t2 set col1='2006-02-05' where col1='2006-02-03'; update t3 set col1='2006-02-05' where col1='2006-02-03'; update t4 set col1='2006-02-05' where col1='2006-02-03'; update t5 set col1='2006-02-05' where col1='2006-02-03'; update t6 set col1='2006-02-05' where col1='2006-02-03'; +commit; select * from t1 order by col1; col1 2006-01-17 @@ -3695,12 +3723,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with day(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-01-17'; delete from t2 where col1='2006-01-17'; delete from t3 where col1='2006-01-17'; delete from t4 where col1='2006-01-17'; delete from t5 where col1='2006-01-17'; delete from t6 where col1='2006-01-17'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -3722,12 +3752,14 @@ colint col1 1 2006-02-05 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-01-17'); insert into t2 values ('2006-01-17'); insert into t3 values ('2006-01-17'); insert into t4 values (60,'2006-01-17'); insert into t5 values (60,'2006-01-17'); insert into t6 values (60,'2006-01-17'); +commit; select * from t1 order by col1; col1 2006-01-17 @@ -3789,12 +3821,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with day(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-01-17'; delete from t22 where col1='2006-01-17'; delete from t33 where col1='2006-01-17'; delete from t44 where col1='2006-01-17'; delete from t55 where col1='2006-01-17'; delete from t66 where col1='2006-01-17'; +commit; select * from t11 order by col1; col1 2006-02-05 @@ -3816,12 +3850,14 @@ colint col1 1 2006-02-05 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-01-17'); insert into t22 values ('2006-01-17'); insert into t33 values ('2006-01-17'); insert into t44 values (60,'2006-01-17'); insert into t55 values (60,'2006-01-17'); insert into t66 values (60,'2006-01-17'); +commit; select * from t11 order by col1; col1 2006-01-17 @@ -3944,6 +3980,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with dayofmonth(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-02-03'); insert into t1 values ('2006-01-17'); insert into t2 values ('2006-02-03'); @@ -3952,6 +3989,7 @@ insert into t2 values ('2006-01-25'); insert into t3 values ('2006-02-03'); insert into t3 values ('2006-01-17'); insert into t3 values ('2006-01-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -3991,12 +4029,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-02-05' where col1='2006-02-03'; update t2 set col1='2006-02-05' where col1='2006-02-03'; update t3 set col1='2006-02-05' where col1='2006-02-03'; update t4 set col1='2006-02-05' where col1='2006-02-03'; update t5 set col1='2006-02-05' where col1='2006-02-03'; update t6 set col1='2006-02-05' where col1='2006-02-03'; +commit; select * from t1 order by col1; col1 2006-01-17 @@ -4200,12 +4240,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with dayofmonth(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-01-17'; delete from t2 where col1='2006-01-17'; delete from t3 where col1='2006-01-17'; delete from t4 where col1='2006-01-17'; delete from t5 where col1='2006-01-17'; delete from t6 where col1='2006-01-17'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -4227,12 +4269,14 @@ colint col1 1 2006-02-05 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-01-17'); insert into t2 values ('2006-01-17'); insert into t3 values ('2006-01-17'); insert into t4 values (60,'2006-01-17'); insert into t5 values (60,'2006-01-17'); insert into t6 values (60,'2006-01-17'); +commit; select * from t1 order by col1; col1 2006-01-17 @@ -4294,12 +4338,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with dayofmonth(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-01-17'; delete from t22 where col1='2006-01-17'; delete from t33 where col1='2006-01-17'; delete from t44 where col1='2006-01-17'; delete from t55 where col1='2006-01-17'; delete from t66 where col1='2006-01-17'; +commit; select * from t11 order by col1; col1 2006-02-05 @@ -4321,12 +4367,14 @@ colint col1 1 2006-02-05 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-01-17'); insert into t22 values ('2006-01-17'); insert into t33 values ('2006-01-17'); insert into t44 values (60,'2006-01-17'); insert into t55 values (60,'2006-01-17'); insert into t66 values (60,'2006-01-17'); +commit; select * from t11 order by col1; col1 2006-01-17 @@ -4449,6 +4497,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with dayofweek(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-01-03'); insert into t1 values ('2006-02-17'); insert into t2 values ('2006-01-03'); @@ -4457,6 +4506,7 @@ insert into t2 values ('2006-01-25'); insert into t3 values ('2006-01-03'); insert into t3 values ('2006-02-17'); insert into t3 values ('2006-01-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -4496,12 +4546,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-02-05' where col1='2006-01-03'; update t2 set col1='2006-02-05' where col1='2006-01-03'; update t3 set col1='2006-02-05' where col1='2006-01-03'; update t4 set col1='2006-02-05' where col1='2006-01-03'; update t5 set col1='2006-02-05' where col1='2006-01-03'; update t6 set col1='2006-02-05' where col1='2006-01-03'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -4705,12 +4757,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with dayofweek(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-02-17'; delete from t2 where col1='2006-02-17'; delete from t3 where col1='2006-02-17'; delete from t4 where col1='2006-02-17'; delete from t5 where col1='2006-02-17'; delete from t6 where col1='2006-02-17'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -4734,12 +4788,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-02-17'); insert into t2 values ('2006-02-17'); insert into t3 values ('2006-02-17'); insert into t4 values (60,'2006-02-17'); insert into t5 values (60,'2006-02-17'); insert into t6 values (60,'2006-02-17'); +commit; select * from t1 order by col1; col1 2006-02-05 @@ -4805,12 +4861,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with dayofweek(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-02-17'; delete from t22 where col1='2006-02-17'; delete from t33 where col1='2006-02-17'; delete from t44 where col1='2006-02-17'; delete from t55 where col1='2006-02-17'; delete from t66 where col1='2006-02-17'; +commit; select * from t11 order by col1; col1 2006-02-05 @@ -4834,12 +4892,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-02-17'); insert into t22 values ('2006-02-17'); insert into t33 values ('2006-02-17'); insert into t44 values (60,'2006-02-17'); insert into t55 values (60,'2006-02-17'); insert into t66 values (60,'2006-02-17'); +commit; select * from t11 order by col1; col1 2006-02-05 @@ -4966,6 +5026,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with dayofyear(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-01-03'); insert into t1 values ('2006-01-17'); insert into t2 values ('2006-01-03'); @@ -4974,6 +5035,7 @@ insert into t2 values ('2006-02-25'); insert into t3 values ('2006-01-03'); insert into t3 values ('2006-01-17'); insert into t3 values ('2006-02-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -5013,12 +5075,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-02-05' where col1='2006-01-03'; update t2 set col1='2006-02-05' where col1='2006-01-03'; update t3 set col1='2006-02-05' where col1='2006-01-03'; update t4 set col1='2006-02-05' where col1='2006-01-03'; update t5 set col1='2006-02-05' where col1='2006-01-03'; update t6 set col1='2006-02-05' where col1='2006-01-03'; +commit; select * from t1 order by col1; col1 2006-01-17 @@ -5222,12 +5286,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with dayofyear(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-01-17'; delete from t2 where col1='2006-01-17'; delete from t3 where col1='2006-01-17'; delete from t4 where col1='2006-01-17'; delete from t5 where col1='2006-01-17'; delete from t6 where col1='2006-01-17'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -5249,12 +5315,14 @@ colint col1 1 2006-02-03 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-01-17'); insert into t2 values ('2006-01-17'); insert into t3 values ('2006-01-17'); insert into t4 values (60,'2006-01-17'); insert into t5 values (60,'2006-01-17'); insert into t6 values (60,'2006-01-17'); +commit; select * from t1 order by col1; col1 2006-01-17 @@ -5317,12 +5385,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with dayofyear(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-01-17'; delete from t22 where col1='2006-01-17'; delete from t33 where col1='2006-01-17'; delete from t44 where col1='2006-01-17'; delete from t55 where col1='2006-01-17'; delete from t66 where col1='2006-01-17'; +commit; select * from t11 order by col1; col1 2006-02-05 @@ -5344,12 +5414,14 @@ colint col1 1 2006-02-03 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-01-17'); insert into t22 values ('2006-01-17'); insert into t33 values ('2006-01-17'); insert into t44 values (60,'2006-01-17'); insert into t55 values (60,'2006-01-17'); insert into t66 values (60,'2006-01-17'); +commit; select * from t11 order by col1; col1 2006-01-17 @@ -5473,6 +5545,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with extract(month from col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-01-03'); insert into t1 values ('2006-02-17'); insert into t2 values ('2006-01-03'); @@ -5481,6 +5554,7 @@ insert into t2 values ('2006-01-25'); insert into t3 values ('2006-01-03'); insert into t3 values ('2006-02-17'); insert into t3 values ('2006-01-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -5520,12 +5594,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-02-05' where col1='2006-01-03'; update t2 set col1='2006-02-05' where col1='2006-01-03'; update t3 set col1='2006-02-05' where col1='2006-01-03'; update t4 set col1='2006-02-05' where col1='2006-01-03'; update t5 set col1='2006-02-05' where col1='2006-01-03'; update t6 set col1='2006-02-05' where col1='2006-01-03'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -5729,12 +5805,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with extract(month from col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-02-17'; delete from t2 where col1='2006-02-17'; delete from t3 where col1='2006-02-17'; delete from t4 where col1='2006-02-17'; delete from t5 where col1='2006-02-17'; delete from t6 where col1='2006-02-17'; +commit; select * from t1 order by col1; col1 2006-02-05 @@ -5758,12 +5836,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-02-17'); insert into t2 values ('2006-02-17'); insert into t3 values ('2006-02-17'); insert into t4 values (60,'2006-02-17'); insert into t5 values (60,'2006-02-17'); insert into t6 values (60,'2006-02-17'); +commit; select * from t1 order by col1; col1 2006-02-05 @@ -5824,12 +5904,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with extract(month from col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-02-17'; delete from t22 where col1='2006-02-17'; delete from t33 where col1='2006-02-17'; delete from t44 where col1='2006-02-17'; delete from t55 where col1='2006-02-17'; delete from t66 where col1='2006-02-17'; +commit; select * from t11 order by col1; col1 2006-02-05 @@ -5853,12 +5935,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-02-17'); insert into t22 values ('2006-02-17'); insert into t33 values ('2006-02-17'); insert into t44 values (60,'2006-02-17'); insert into t55 values (60,'2006-02-17'); insert into t66 values (60,'2006-02-17'); +commit; select * from t11 order by col1; col1 2006-02-05 @@ -5980,6 +6064,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with hour(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('09:09'); insert into t1 values ('14:30'); insert into t2 values ('09:09'); @@ -5988,6 +6073,7 @@ insert into t2 values ('21:59'); insert into t3 values ('09:09'); insert into t3 values ('14:30'); insert into t3 values ('21:59'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; @@ -6027,12 +6113,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; update t1 set col1='10:30' where col1='09:09'; update t2 set col1='10:30' where col1='09:09'; update t3 set col1='10:30' where col1='09:09'; update t4 set col1='10:30' where col1='09:09'; update t5 set col1='10:30' where col1='09:09'; update t6 set col1='10:30' where col1='09:09'; +commit; select * from t1 order by col1; col1 10:30:00 @@ -6236,12 +6324,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with hour(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='14:30'; delete from t2 where col1='14:30'; delete from t3 where col1='14:30'; delete from t4 where col1='14:30'; delete from t5 where col1='14:30'; delete from t6 where col1='14:30'; +commit; select * from t1 order by col1; col1 10:30:00 @@ -6265,12 +6355,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; insert into t1 values ('14:30'); insert into t2 values ('14:30'); insert into t3 values ('14:30'); insert into t4 values (60,'14:30'); insert into t5 values (60,'14:30'); insert into t6 values (60,'14:30'); +commit; select * from t1 order by col1; col1 10:30:00 @@ -6334,12 +6426,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with hour(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='14:30'; delete from t22 where col1='14:30'; delete from t33 where col1='14:30'; delete from t44 where col1='14:30'; delete from t55 where col1='14:30'; delete from t66 where col1='14:30'; +commit; select * from t11 order by col1; col1 10:30:00 @@ -6363,12 +6457,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; insert into t11 values ('14:30'); insert into t22 values ('14:30'); insert into t33 values ('14:30'); insert into t44 values (60,'14:30'); insert into t55 values (60,'14:30'); insert into t66 values (60,'14:30'); +commit; select * from t11 order by col1; col1 10:30:00 @@ -6445,7 +6541,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- microsecond(col1) in partition with coltype time +--- microsecond(col1) in partition with coltype time(6) ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -6456,11 +6552,11 @@ drop table if exists t6 ; ------------------------------------------------------------------------- --- Create tables with microsecond(col1) ------------------------------------------------------------------------- -create table t1 (col1 time) engine='TOKUDB' +create table t1 (col1 time(6)) engine='TOKUDB' partition by range(microsecond(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 time) engine='TOKUDB' +create table t2 (col1 time(6)) engine='TOKUDB' partition by list(microsecond(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), @@ -6469,14 +6565,14 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 time) engine='TOKUDB' +create table t3 (col1 time(6)) engine='TOKUDB' partition by hash(microsecond(col1)); -create table t4 (colint int, col1 time) engine='TOKUDB' +create table t4 (colint int, col1 time(6)) engine='TOKUDB' 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='TOKUDB' +create table t5 (colint int, col1 time(6)) engine='TOKUDB' partition by list(colint) subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), @@ -6486,13 +6582,14 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 time) engine='TOKUDB' +create table t6 (colint int, col1 time(6)) engine='TOKUDB' partition by range(colint) (partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with microsecond(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('09:09:15.000002'); insert into t1 values ('04:30:01.000018'); insert into t2 values ('09:09:15.000002'); @@ -6501,83 +6598,86 @@ insert into t2 values ('00:59:22.000024'); insert into t3 values ('09:09:15.000002'); insert into t3 values ('04:30:01.000018'); insert into t3 values ('00:59:22.000024'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; select microsecond(col1) from t1 order by col1; microsecond(col1) -0 -0 +18 +2 select * from t1 order by col1; col1 -04:30:01 -09:09:15 +04:30:01.000018 +09:09:15.000002 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -09:09:15 +00:59:22.000024 +04:30:01.000018 +09:09:15.000002 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -09:09:15 +00:59:22.000024 +04:30:01.000018 +09:09:15.000002 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 09:09:15.000002 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 09:09:15.000002 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 09:09:15.000002 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 +begin; update t1 set col1='05:30:34.000037' where col1='09:09:15.000002'; update t2 set col1='05:30:34.000037' where col1='09:09:15.000002'; update t3 set col1='05:30:34.000037' where col1='09:09:15.000002'; update t4 set col1='05:30:34.000037' where col1='09:09:15.000002'; update t5 set col1='05:30:34.000037' where col1='09:09:15.000002'; update t6 set col1='05:30:34.000037' where col1='09:09:15.000002'; +commit; select * from t1 order by col1; col1 -04:30:01 -05:30:34 +04:30:01.000018 +05:30:34.000037 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t4 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 select * from t5 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 select * from t6 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 ------------------------------------------------------------------------- --- Alter tables with microsecond(col1) ------------------------------------------------------------------------- @@ -6629,36 +6729,36 @@ partition by range(colint) partition p1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +04:30:01.000018 +05:30:34.000037 select * from t22 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t44 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 select * from t55 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 select * from t66 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 --------------------------- ---- some alter table begin --------------------------- @@ -6667,16 +6767,16 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +04:30:01.000018 +05:30:34.000037 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +04:30:01.000018 +05:30:34.000037 alter table t55 partition by list(colint) subpartition by hash(microsecond(col1)) subpartitions 5 @@ -6691,7 +6791,7 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` time DEFAULT NULL + `col1` time(6) DEFAULT NULL ) ENGINE=TokuDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) SUBPARTITION BY HASH (microsecond(col1)) @@ -6704,116 +6804,120 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = TokuDB) */ select * from t55 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 alter table t66 reorganize partition s1 into (partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 alter table t66 reorganize partition s1 into (partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +2 04:30:01.000018 +3 00:59:22.000024 +4 05:30:34.000037 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with microsecond(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='04:30:01.000018'; delete from t2 where col1='04:30:01.000018'; delete from t3 where col1='04:30:01.000018'; delete from t4 where col1='04:30:01.000018'; delete from t5 where col1='04:30:01.000018'; delete from t6 where col1='04:30:01.000018'; +commit; select * from t1 order by col1; col1 -05:30:34 +05:30:34.000037 select * from t2 order by col1; col1 -00:59:22 -05:30:34 +00:59:22.000024 +05:30:34.000037 select * from t3 order by col1; col1 -00:59:22 -05:30:34 +00:59:22.000024 +05:30:34.000037 select * from t4 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 select * from t5 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +begin; insert into t1 values ('04:30:01.000018'); insert into t2 values ('04:30:01.000018'); insert into t3 values ('04:30:01.000018'); insert into t4 values (60,'04:30:01.000018'); insert into t5 values (60,'04:30:01.000018'); insert into t6 values (60,'04:30:01.000018'); +commit; select * from t1 order by col1; col1 -04:30:01 -05:30:34 +04:30:01.000018 +05:30:34.000037 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t4 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 -60 04:30:01 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +60 04:30:01.000018 select * from t5 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 -60 04:30:01 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +60 04:30:01.000018 select * from t6 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 -60 04:30:01 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +60 04:30:01.000018 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -6821,90 +6925,99 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 +04:30:01.000018 +05:30:34.000037 select * from t2 order by col1; col1 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t4 order by colint; colint col1 -60 04:30:01 +60 04:30:01.000018 select * from t5 order by colint; colint col1 -60 04:30:01 +60 04:30:01.000018 select * from t6 order by colint; colint col1 -60 04:30:01 +60 04:30:01.000018 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with microsecond(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='04:30:01.000018'; delete from t22 where col1='04:30:01.000018'; delete from t33 where col1='04:30:01.000018'; delete from t44 where col1='04:30:01.000018'; delete from t55 where col1='04:30:01.000018'; delete from t66 where col1='04:30:01.000018'; +commit; select * from t11 order by col1; col1 -05:30:34 +05:30:34.000037 select * from t22 order by col1; col1 -00:59:22 -05:30:34 +00:59:22.000024 +05:30:34.000037 select * from t33 order by col1; col1 -00:59:22 -05:30:34 +00:59:22.000024 +05:30:34.000037 select * from t44 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 select * from t55 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +begin; insert into t11 values ('04:30:01.000018'); insert into t22 values ('04:30:01.000018'); insert into t33 values ('04:30:01.000018'); insert into t44 values (60,'04:30:01.000018'); insert into t55 values (60,'04:30:01.000018'); insert into t66 values (60,'04:30:01.000018'); +commit; select * from t11 order by col1; col1 -04:30:01 -05:30:34 +04:30:01.000018 +05:30:34.000037 select * from t22 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t44 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 -60 04:30:01 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +60 04:30:01.000018 select * from t55 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 -60 04:30:01 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +60 04:30:01.000018 select * from t66 order by colint; colint col1 -1 05:30:34 -3 00:59:22 -4 05:30:34 -60 04:30:01 +1 05:30:34.000037 +3 00:59:22.000024 +4 05:30:34.000037 +60 04:30:01.000018 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -6912,22 +7025,27 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 +04:30:01.000018 +05:30:34.000037 select * from t22 order by col1; col1 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +00:59:22.000024 +04:30:01.000018 +05:30:34.000037 select * from t44 order by colint; colint col1 -60 04:30:01 +60 04:30:01.000018 select * from t55 order by colint; colint col1 -60 04:30:01 +60 04:30:01.000018 select * from t66 order by colint; colint col1 -60 04:30:01 +60 04:30:01.000018 ------------------------- ---- some alter table end ------------------------- @@ -6992,6 +7110,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with minute(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('09:09:15'); insert into t1 values ('14:30:45'); insert into t2 values ('09:09:15'); @@ -7000,6 +7119,7 @@ insert into t2 values ('21:59:22'); insert into t3 values ('09:09:15'); insert into t3 values ('14:30:45'); insert into t3 values ('21:59:22'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; @@ -7039,12 +7159,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; update t1 set col1='10:24:23' where col1='09:09:15'; update t2 set col1='10:24:23' where col1='09:09:15'; update t3 set col1='10:24:23' where col1='09:09:15'; update t4 set col1='10:24:23' where col1='09:09:15'; update t5 set col1='10:24:23' where col1='09:09:15'; update t6 set col1='10:24:23' where col1='09:09:15'; +commit; select * from t1 order by col1; col1 10:24:23 @@ -7248,12 +7370,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with minute(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='14:30:45'; delete from t2 where col1='14:30:45'; delete from t3 where col1='14:30:45'; delete from t4 where col1='14:30:45'; delete from t5 where col1='14:30:45'; delete from t6 where col1='14:30:45'; +commit; select * from t1 order by col1; col1 10:24:23 @@ -7277,12 +7401,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; insert into t1 values ('14:30:45'); insert into t2 values ('14:30:45'); insert into t3 values ('14:30:45'); insert into t4 values (60,'14:30:45'); insert into t5 values (60,'14:30:45'); insert into t6 values (60,'14:30:45'); +commit; select * from t1 order by col1; col1 10:24:23 @@ -7349,12 +7475,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with minute(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='14:30:45'; delete from t22 where col1='14:30:45'; delete from t33 where col1='14:30:45'; delete from t44 where col1='14:30:45'; delete from t55 where col1='14:30:45'; delete from t66 where col1='14:30:45'; +commit; select * from t11 order by col1; col1 10:24:23 @@ -7378,12 +7506,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; insert into t11 values ('14:30:45'); insert into t22 values ('14:30:45'); insert into t33 values ('14:30:45'); insert into t44 values (60,'14:30:45'); insert into t55 values (60,'14:30:45'); insert into t66 values (60,'14:30:45'); +commit; select * from t11 order by col1; col1 10:24:23 @@ -7511,6 +7641,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with second(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('09:09:09'); insert into t1 values ('14:30:20'); insert into t2 values ('09:09:09'); @@ -7519,6 +7650,7 @@ insert into t2 values ('21:59:22'); insert into t3 values ('09:09:09'); insert into t3 values ('14:30:20'); insert into t3 values ('21:59:22'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; @@ -7558,12 +7690,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; update t1 set col1='10:22:33' where col1='09:09:09'; update t2 set col1='10:22:33' where col1='09:09:09'; update t3 set col1='10:22:33' where col1='09:09:09'; update t4 set col1='10:22:33' where col1='09:09:09'; update t5 set col1='10:22:33' where col1='09:09:09'; update t6 set col1='10:22:33' where col1='09:09:09'; +commit; select * from t1 order by col1; col1 10:22:33 @@ -7767,12 +7901,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with second(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='14:30:20'; delete from t2 where col1='14:30:20'; delete from t3 where col1='14:30:20'; delete from t4 where col1='14:30:20'; delete from t5 where col1='14:30:20'; delete from t6 where col1='14:30:20'; +commit; select * from t1 order by col1; col1 10:22:33 @@ -7796,12 +7932,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; insert into t1 values ('14:30:20'); insert into t2 values ('14:30:20'); insert into t3 values ('14:30:20'); insert into t4 values (60,'14:30:20'); insert into t5 values (60,'14:30:20'); insert into t6 values (60,'14:30:20'); +commit; select * from t1 order by col1; col1 10:22:33 @@ -7868,12 +8006,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with second(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='14:30:20'; delete from t22 where col1='14:30:20'; delete from t33 where col1='14:30:20'; delete from t44 where col1='14:30:20'; delete from t55 where col1='14:30:20'; delete from t66 where col1='14:30:20'; +commit; select * from t11 order by col1; col1 10:22:33 @@ -7897,12 +8037,14 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 +begin; insert into t11 values ('14:30:20'); insert into t22 values ('14:30:20'); insert into t33 values ('14:30:20'); insert into t44 values (60,'14:30:20'); insert into t55 values (60,'14:30:20'); insert into t66 values (60,'14:30:20'); +commit; select * from t11 order by col1; col1 10:22:33 @@ -8030,6 +8172,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with month(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-01-03'); insert into t1 values ('2006-12-17'); insert into t2 values ('2006-01-03'); @@ -8038,6 +8181,7 @@ insert into t2 values ('2006-05-25'); insert into t3 values ('2006-01-03'); insert into t3 values ('2006-12-17'); insert into t3 values ('2006-05-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -8077,12 +8221,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-11-06' where col1='2006-01-03'; update t2 set col1='2006-11-06' where col1='2006-01-03'; update t3 set col1='2006-11-06' where col1='2006-01-03'; update t4 set col1='2006-11-06' where col1='2006-01-03'; update t5 set col1='2006-11-06' where col1='2006-01-03'; update t6 set col1='2006-11-06' where col1='2006-01-03'; +commit; select * from t1 order by col1; col1 2006-11-06 @@ -8286,12 +8432,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with month(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-12-17'; delete from t2 where col1='2006-12-17'; delete from t3 where col1='2006-12-17'; delete from t4 where col1='2006-12-17'; delete from t5 where col1='2006-12-17'; delete from t6 where col1='2006-12-17'; +commit; select * from t1 order by col1; col1 2006-11-06 @@ -8315,12 +8463,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-12-17'); insert into t2 values ('2006-12-17'); insert into t3 values ('2006-12-17'); insert into t4 values (60,'2006-12-17'); insert into t5 values (60,'2006-12-17'); insert into t6 values (60,'2006-12-17'); +commit; select * from t1 order by col1; col1 2006-11-06 @@ -8384,12 +8534,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with month(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-12-17'; delete from t22 where col1='2006-12-17'; delete from t33 where col1='2006-12-17'; delete from t44 where col1='2006-12-17'; delete from t55 where col1='2006-12-17'; delete from t66 where col1='2006-12-17'; +commit; select * from t11 order by col1; col1 2006-11-06 @@ -8413,12 +8565,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-12-17'); insert into t22 values ('2006-12-17'); insert into t33 values ('2006-12-17'); insert into t44 values (60,'2006-12-17'); insert into t55 values (60,'2006-12-17'); insert into t66 values (60,'2006-12-17'); +commit; select * from t11 order by col1; col1 2006-11-06 @@ -8543,6 +8697,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with quarter(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-01-03'); insert into t1 values ('2006-12-17'); insert into t2 values ('2006-01-03'); @@ -8551,6 +8706,7 @@ insert into t2 values ('2006-09-25'); insert into t3 values ('2006-01-03'); insert into t3 values ('2006-12-17'); insert into t3 values ('2006-09-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -8590,12 +8746,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-07-30' where col1='2006-01-03'; update t2 set col1='2006-07-30' where col1='2006-01-03'; update t3 set col1='2006-07-30' where col1='2006-01-03'; update t4 set col1='2006-07-30' where col1='2006-01-03'; update t5 set col1='2006-07-30' where col1='2006-01-03'; update t6 set col1='2006-07-30' where col1='2006-01-03'; +commit; select * from t1 order by col1; col1 2006-07-30 @@ -8799,12 +8957,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with quarter(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-12-17'; delete from t2 where col1='2006-12-17'; delete from t3 where col1='2006-12-17'; delete from t4 where col1='2006-12-17'; delete from t5 where col1='2006-12-17'; delete from t6 where col1='2006-12-17'; +commit; select * from t1 order by col1; col1 2006-07-30 @@ -8828,12 +8988,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-12-17'); insert into t2 values ('2006-12-17'); insert into t3 values ('2006-12-17'); insert into t4 values (60,'2006-12-17'); insert into t5 values (60,'2006-12-17'); insert into t6 values (60,'2006-12-17'); +commit; select * from t1 order by col1; col1 2006-07-30 @@ -8896,12 +9058,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with quarter(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-12-17'; delete from t22 where col1='2006-12-17'; delete from t33 where col1='2006-12-17'; delete from t44 where col1='2006-12-17'; delete from t55 where col1='2006-12-17'; delete from t66 where col1='2006-12-17'; +commit; select * from t11 order by col1; col1 2006-07-30 @@ -8925,12 +9089,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-12-17'); insert into t22 values ('2006-12-17'); insert into t33 values ('2006-12-17'); insert into t44 values (60,'2006-12-17'); insert into t55 values (60,'2006-12-17'); insert into t66 values (60,'2006-12-17'); +commit; select * from t11 order by col1; col1 2006-07-30 @@ -9006,523 +9172,6 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -create table t1 (col1 time) engine='TOKUDB' -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='TOKUDB' -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='TOKUDB' -partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); -create table t4 (colint int, col1 time) engine='TOKUDB' -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='TOKUDB' -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='TOKUDB' -partition by range(colint) -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -insert into t1 values ('09:09:15'); -insert into t1 values ('14:30:45'); -insert into t2 values ('09:09:15'); -insert into t2 values ('14:30:45'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:15'); -insert into t3 values ('14:30:45'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1; -time_to_sec(col1)-(time_to_sec(col1)-20) -20 -20 -select * from t1 order by col1; -col1 -09:09:15 -14:30:45 -select * from t2 order by col1; -col1 -09:09:15 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -09:09:15 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t6 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -update t1 set col1='10:33:11' where col1='09:09:15'; -update t2 set col1='10:33:11' where col1='09:09:15'; -update t3 set col1='10:33:11' where col1='09:09:15'; -update t4 set col1='10:33:11' where col1='09:09:15'; -update t5 set col1='10:33:11' where col1='09:09:15'; -update t6 set col1='10:33:11' where col1='09:09:15'; -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t6 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -------------------------------------------------------------------------- ---- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='TOKUDB' as select * from t1; -create table t22 engine='TOKUDB' as select * from t2; -create table t33 engine='TOKUDB' as select * from t3; -create table t44 engine='TOKUDB' as select * from t4; -create table t55 engine='TOKUDB' as select * from t5; -create table t66 engine='TOKUDB' 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=TokuDB 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 = TokuDB, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = TokuDB, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = TokuDB, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = TokuDB, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = TokuDB, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = TokuDB) */ -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -delete from t1 where col1='14:30:45'; -delete from t2 where col1='14:30:45'; -delete from t3 where col1='14:30:45'; -delete from t4 where col1='14:30:45'; -delete from t5 where col1='14:30:45'; -delete from t6 where col1='14:30:45'; -select * from t1 order by col1; -col1 -10:33:11 -select * from t2 order by col1; -col1 -10:33:11 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t1 values ('14:30:45'); -insert into t2 values ('14:30:45'); -insert into t3 values ('14:30:45'); -insert into t4 values (60,'14:30:45'); -insert into t5 values (60,'14:30:45'); -insert into t6 values (60,'14:30:45'); -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t6 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -60 14:30:45 -select * from t5 order by colint; -colint col1 -60 14:30:45 -select * from t6 order by colint; -colint col1 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -delete from t11 where col1='14:30:45'; -delete from t22 where col1='14:30:45'; -delete from t33 where col1='14:30:45'; -delete from t44 where col1='14:30:45'; -delete from t55 where col1='14:30:45'; -delete from t66 where col1='14:30:45'; -select * from t11 order by col1; -col1 -10:33:11 -select * from t22 order by col1; -col1 -10:33:11 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t11 values ('14:30:45'); -insert into t22 values ('14:30:45'); -insert into t33 values ('14:30:45'); -insert into t44 values (60,'14:30:45'); -insert into t55 values (60,'14:30:45'); -insert into t66 values (60,'14:30:45'); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -60 14:30:45 -select * from t55 order by colint; -colint col1 -60 14:30:45 -select * from t66 order by colint; -colint col1 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- --- weekday(col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; @@ -9571,6 +9220,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with weekday(col1) ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-12-03'); insert into t1 values ('2006-11-17'); insert into t2 values ('2006-12-03'); @@ -9579,6 +9229,7 @@ insert into t2 values ('2006-05-25'); insert into t3 values ('2006-12-03'); insert into t3 values ('2006-11-17'); insert into t3 values ('2006-05-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -9618,12 +9269,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-02-06' where col1='2006-12-03'; update t2 set col1='2006-02-06' where col1='2006-12-03'; update t3 set col1='2006-02-06' where col1='2006-12-03'; update t4 set col1='2006-02-06' where col1='2006-12-03'; update t5 set col1='2006-02-06' where col1='2006-12-03'; update t6 set col1='2006-02-06' where col1='2006-12-03'; +commit; select * from t1 order by col1; col1 2006-02-06 @@ -9827,12 +9480,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with weekday(col1) ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-11-17'; delete from t2 where col1='2006-11-17'; delete from t3 where col1='2006-11-17'; delete from t4 where col1='2006-11-17'; delete from t5 where col1='2006-11-17'; delete from t6 where col1='2006-11-17'; +commit; select * from t1 order by col1; col1 2006-02-06 @@ -9856,12 +9511,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-11-17'); insert into t2 values ('2006-11-17'); insert into t3 values ('2006-11-17'); insert into t4 values (60,'2006-11-17'); insert into t5 values (60,'2006-11-17'); insert into t6 values (60,'2006-11-17'); +commit; select * from t1 order by col1; col1 2006-02-06 @@ -9923,12 +9580,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with weekday(col1) ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-11-17'; delete from t22 where col1='2006-11-17'; delete from t33 where col1='2006-11-17'; delete from t44 where col1='2006-11-17'; delete from t55 where col1='2006-11-17'; delete from t66 where col1='2006-11-17'; +commit; select * from t11 order by col1; col1 2006-02-06 @@ -9952,12 +9611,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-11-17'); insert into t22 values ('2006-11-17'); insert into t33 values ('2006-11-17'); insert into t44 values (60,'2006-11-17'); insert into t55 values (60,'2006-11-17'); insert into t66 values (60,'2006-11-17'); +commit; select * from t11 order by col1; col1 2006-02-06 @@ -10080,6 +9741,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with year(col1)-1990 ------------------------------------------------------------------------- +begin; insert into t1 values ('1996-01-03'); insert into t1 values ('2000-02-17'); insert into t2 values ('1996-01-03'); @@ -10088,6 +9750,7 @@ insert into t2 values ('2004-05-25'); insert into t3 values ('1996-01-03'); insert into t3 values ('2000-02-17'); insert into t3 values ('2004-05-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -10127,12 +9790,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2002-02-15' where col1='1996-01-03'; update t2 set col1='2002-02-15' where col1='1996-01-03'; update t3 set col1='2002-02-15' where col1='1996-01-03'; update t4 set col1='2002-02-15' where col1='1996-01-03'; update t5 set col1='2002-02-15' where col1='1996-01-03'; update t6 set col1='2002-02-15' where col1='1996-01-03'; +commit; select * from t1 order by col1; col1 2000-02-17 @@ -10336,12 +10001,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with year(col1)-1990 ------------------------------------------------------------------------- +begin; delete from t1 where col1='2000-02-17'; delete from t2 where col1='2000-02-17'; delete from t3 where col1='2000-02-17'; delete from t4 where col1='2000-02-17'; delete from t5 where col1='2000-02-17'; delete from t6 where col1='2000-02-17'; +commit; select * from t1 order by col1; col1 2002-02-15 @@ -10365,12 +10032,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2000-02-17'); insert into t2 values ('2000-02-17'); insert into t3 values ('2000-02-17'); insert into t4 values (60,'2000-02-17'); insert into t5 values (60,'2000-02-17'); insert into t6 values (60,'2000-02-17'); +commit; select * from t1 order by col1; col1 2000-02-17 @@ -10434,12 +10103,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with year(col1)-1990 ------------------------------------------------------------------------- +begin; delete from t11 where col1='2000-02-17'; delete from t22 where col1='2000-02-17'; delete from t33 where col1='2000-02-17'; delete from t44 where col1='2000-02-17'; delete from t55 where col1='2000-02-17'; delete from t66 where col1='2000-02-17'; +commit; select * from t11 order by col1; col1 2002-02-15 @@ -10463,12 +10134,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2000-02-17'); insert into t22 values ('2000-02-17'); insert into t33 values ('2000-02-17'); insert into t44 values (60,'2000-02-17'); insert into t55 values (60,'2000-02-17'); insert into t66 values (60,'2000-02-17'); +commit; select * from t11 order by col1; col1 2000-02-17 @@ -10593,6 +10266,7 @@ partition p1 values less than maxvalue); ------------------------------------------------------------------------- --- Access tables with yearweek(col1)-200600 ------------------------------------------------------------------------- +begin; insert into t1 values ('2006-01-03'); insert into t1 values ('2006-08-17'); insert into t2 values ('2006-01-03'); @@ -10601,6 +10275,7 @@ insert into t2 values ('2006-03-25'); insert into t3 values ('2006-01-03'); insert into t3 values ('2006-08-17'); insert into t3 values ('2006-03-25'); +commit; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; @@ -10640,12 +10315,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; update t1 set col1='2006-11-15' where col1='2006-01-03'; update t2 set col1='2006-11-15' where col1='2006-01-03'; update t3 set col1='2006-11-15' where col1='2006-01-03'; update t4 set col1='2006-11-15' where col1='2006-01-03'; update t5 set col1='2006-11-15' where col1='2006-01-03'; update t6 set col1='2006-11-15' where col1='2006-01-03'; +commit; select * from t1 order by col1; col1 2006-08-17 @@ -10849,12 +10526,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with yearweek(col1)-200600 ------------------------------------------------------------------------- +begin; delete from t1 where col1='2006-08-17'; delete from t2 where col1='2006-08-17'; delete from t3 where col1='2006-08-17'; delete from t4 where col1='2006-08-17'; delete from t5 where col1='2006-08-17'; delete from t6 where col1='2006-08-17'; +commit; select * from t1 order by col1; col1 2006-11-15 @@ -10878,12 +10557,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t1 values ('2006-08-17'); insert into t2 values ('2006-08-17'); insert into t3 values ('2006-08-17'); insert into t4 values (60,'2006-08-17'); insert into t5 values (60,'2006-08-17'); insert into t6 values (60,'2006-08-17'); +commit; select * from t1 order by col1; col1 2006-08-17 @@ -10950,12 +10631,14 @@ colint col1 ------------------------------------------------------------------------- --- Delete rows and partitions of tables with yearweek(col1)-200600 ------------------------------------------------------------------------- +begin; delete from t11 where col1='2006-08-17'; delete from t22 where col1='2006-08-17'; delete from t33 where col1='2006-08-17'; delete from t44 where col1='2006-08-17'; delete from t55 where col1='2006-08-17'; delete from t66 where col1='2006-08-17'; +commit; select * from t11 order by col1; col1 2006-11-15 @@ -10979,12 +10662,14 @@ colint col1 2 2006-01-17 3 2006-01-25 4 2006-02-05 +begin; insert into t11 values ('2006-08-17'); insert into t22 values ('2006-08-17'); insert into t33 values ('2006-08-17'); insert into t44 values (60,'2006-08-17'); insert into t55 values (60,'2006-08-17'); insert into t66 values (60,'2006-08-17'); +commit; select * from t11 order by col1; col1 2006-08-17 diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_2_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_2_tokudb.result index bd4239fd26d..3fb51c67d00 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_2_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_2_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -48,8 +48,8 @@ SET @@session.sql_mode= ''; # 1.2.1 PRIMARY KEY consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -540,8 +540,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1032,8 +1032,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1539,8 +1539,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2040,8 +2040,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2539,8 +2539,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3049,8 +3049,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3561,8 +3561,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4062,8 +4062,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4554,8 +4554,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5046,8 +5046,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5553,8 +5553,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6054,8 +6054,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6553,8 +6553,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7063,8 +7063,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7575,8 +7575,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8077,8 +8077,8 @@ DROP TABLE t1; # 1.2.2 UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8097,8 +8097,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8585,8 +8585,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8605,8 +8605,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9093,8 +9093,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9121,8 +9121,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9616,8 +9616,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9642,8 +9642,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10133,8 +10133,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10157,8 +10157,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10648,8 +10648,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10676,8 +10676,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11174,8 +11174,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11202,8 +11202,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11702,8 +11702,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11726,8 +11726,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -12219,8 +12219,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12239,8 +12239,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -12727,8 +12727,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12747,8 +12747,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -13235,8 +13235,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13263,8 +13263,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -13758,8 +13758,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13784,8 +13784,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -14275,8 +14275,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14299,8 +14299,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -14790,8 +14790,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14818,8 +14818,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -15316,8 +15316,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15344,8 +15344,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -15844,8 +15844,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15868,8 +15868,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -16362,8 +16362,8 @@ DROP TABLE t1; # 1.2.3 PRIMARY KEY and UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16855,8 +16855,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17348,8 +17348,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17856,8 +17856,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18358,8 +18358,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18858,8 +18858,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19369,8 +19369,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19882,8 +19882,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20384,8 +20384,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20877,8 +20877,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21370,8 +21370,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21878,8 +21878,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22380,8 +22380,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22880,8 +22880,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23391,8 +23391,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23904,8 +23904,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24406,8 +24406,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24899,8 +24899,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25392,8 +25392,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25900,8 +25900,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26402,8 +26402,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26902,8 +26902,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27413,8 +27413,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27926,8 +27926,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_tokudb.result index a59d3daeec7..2cc7b4298fc 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_1_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -47,8 +47,8 @@ SET @@session.sql_mode= ''; #------------------------------------------------------------------------ DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -62,8 +62,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -77,8 +77,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -100,8 +100,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -121,8 +121,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -140,8 +140,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -163,8 +163,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -186,8 +186,8 @@ ALTER TABLE t1 ADD PRIMARY KEY(f_int2); ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -206,8 +206,8 @@ ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -221,8 +221,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -236,8 +236,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -259,8 +259,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -280,8 +280,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -299,8 +299,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -322,8 +322,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -345,8 +345,8 @@ ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2); ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -366,8 +366,8 @@ DROP TABLE t1; # 1.1.3 PRIMARY KEY consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -858,8 +858,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1350,8 +1350,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1857,8 +1857,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2358,8 +2358,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2859,8 +2859,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3369,8 +3369,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3881,8 +3881,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4382,8 +4382,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4874,8 +4874,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5366,8 +5366,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5873,8 +5873,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6374,8 +6374,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6875,8 +6875,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7385,8 +7385,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7897,8 +7897,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8399,8 +8399,8 @@ DROP TABLE t1; # 1.1.4 UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8419,8 +8419,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8907,8 +8907,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8927,8 +8927,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9415,8 +9415,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9443,8 +9443,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9938,8 +9938,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9964,8 +9964,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10455,8 +10455,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10479,8 +10479,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10972,8 +10972,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11000,8 +11000,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11498,8 +11498,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11526,8 +11526,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -12026,8 +12026,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12050,8 +12050,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -12543,8 +12543,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12563,8 +12563,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -13051,8 +13051,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13071,8 +13071,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -13559,8 +13559,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13587,8 +13587,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -14082,8 +14082,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14108,8 +14108,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -14599,8 +14599,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14623,8 +14623,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -15116,8 +15116,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15144,8 +15144,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -15642,8 +15642,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15670,8 +15670,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -16170,8 +16170,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16194,8 +16194,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_2_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_2_tokudb.result index 9202e5f3a97..4aded14f336 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_2_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter1_2_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -47,8 +47,8 @@ SET @@session.sql_mode= ''; # 2.1.5 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -487,8 +487,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -927,8 +927,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1382,8 +1382,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1831,8 +1831,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2280,8 +2280,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2738,8 +2738,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3198,8 +3198,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3647,8 +3647,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4087,8 +4087,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4527,8 +4527,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4982,8 +4982,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5431,8 +5431,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5880,8 +5880,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6338,8 +6338,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6798,8 +6798,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7247,8 +7247,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7267,8 +7267,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -7703,8 +7703,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7723,8 +7723,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -8159,8 +8159,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8187,8 +8187,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -8630,8 +8630,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8656,8 +8656,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -9095,8 +9095,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9119,8 +9119,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -9560,8 +9560,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9588,8 +9588,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -10034,8 +10034,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10062,8 +10062,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -10510,8 +10510,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10534,8 +10534,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -10979,8 +10979,8 @@ DROP TABLE t1; # 2.2.1 DROP PRIMARY KEY consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11419,8 +11419,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11859,8 +11859,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12314,8 +12314,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12763,8 +12763,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13210,8 +13210,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13668,8 +13668,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14128,8 +14128,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14577,8 +14577,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15017,8 +15017,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15457,8 +15457,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15912,8 +15912,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16361,8 +16361,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16808,8 +16808,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17266,8 +17266,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17726,8 +17726,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18176,8 +18176,8 @@ DROP TABLE t1; # 2.2.2 DROP UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18196,8 +18196,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -18632,8 +18632,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18652,8 +18652,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -19088,8 +19088,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19116,8 +19116,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -19559,8 +19559,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19585,8 +19585,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -20024,8 +20024,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20048,8 +20048,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -20487,8 +20487,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20515,8 +20515,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -20961,8 +20961,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20989,8 +20989,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -21437,8 +21437,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21461,8 +21461,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -21902,8 +21902,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21922,8 +21922,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -22358,8 +22358,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22378,8 +22378,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -22814,8 +22814,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22842,8 +22842,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -23285,8 +23285,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23311,8 +23311,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -23750,8 +23750,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23774,8 +23774,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -24213,8 +24213,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24241,8 +24241,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -24687,8 +24687,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24715,8 +24715,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -25163,8 +25163,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25187,8 +25187,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -25629,8 +25629,8 @@ DROP TABLE t1; # 2.2.3 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26069,8 +26069,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26509,8 +26509,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26964,8 +26964,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27413,8 +27413,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27860,8 +27860,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -28318,8 +28318,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -28778,8 +28778,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -29227,8 +29227,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -29667,8 +29667,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -30107,8 +30107,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -30562,8 +30562,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31011,8 +31011,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31458,8 +31458,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31916,8 +31916,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -32376,8 +32376,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -32825,8 +32825,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -32845,8 +32845,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -33281,8 +33281,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -33301,8 +33301,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -33737,8 +33737,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -33765,8 +33765,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -34208,8 +34208,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -34234,8 +34234,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -34673,8 +34673,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -34697,8 +34697,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -35136,8 +35136,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -35164,8 +35164,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -35610,8 +35610,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -35638,8 +35638,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -36086,8 +36086,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -36110,8 +36110,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_1_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_1_tokudb.result index 8c7bc5ef296..6838b33d89d 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_1_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_1_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -48,8 +48,8 @@ SET @@session.sql_mode= ''; # 1.1.1 no PRIMARY KEY or UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -68,7 +68,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -504,8 +504,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -524,7 +524,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -960,8 +960,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -988,7 +988,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -1431,8 +1431,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1457,7 +1457,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -1896,8 +1896,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1920,7 +1920,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -2361,8 +2361,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2389,7 +2389,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -2835,8 +2835,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2863,7 +2863,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -3311,8 +3311,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3335,7 +3335,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -3777,8 +3777,8 @@ DROP TABLE t1; # 1.1.2 PRIMARY KEY exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3798,7 +3798,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4237,6 +4237,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4269,8 +4271,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4290,7 +4292,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4729,6 +4731,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4761,8 +4765,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4790,7 +4794,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5236,6 +5240,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5268,8 +5274,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5295,7 +5301,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5737,6 +5743,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5769,8 +5777,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5794,7 +5802,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6238,6 +6246,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6270,8 +6280,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6299,7 +6309,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6748,6 +6758,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6780,8 +6792,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6809,7 +6821,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7260,6 +7272,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7292,8 +7306,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7317,7 +7331,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7760,6 +7774,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7793,8 +7809,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7814,7 +7830,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8253,6 +8269,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8285,8 +8303,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8306,7 +8324,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8745,6 +8763,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8777,8 +8797,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8806,7 +8826,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9252,6 +9272,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9284,8 +9306,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9311,7 +9333,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9753,6 +9775,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9785,8 +9809,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9810,7 +9834,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10254,6 +10278,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10286,8 +10312,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10315,7 +10341,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10764,6 +10790,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10796,8 +10824,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10825,7 +10853,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11276,6 +11304,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11308,8 +11338,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11333,7 +11363,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11776,6 +11806,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11810,8 +11842,8 @@ DROP TABLE t1; # 1.1.3 UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11830,7 +11862,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -12318,8 +12350,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12338,7 +12370,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -12826,8 +12858,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12854,7 +12886,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -13349,8 +13381,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13375,7 +13407,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -13866,8 +13898,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13890,7 +13922,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -14383,8 +14415,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14411,7 +14443,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -14909,8 +14941,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14937,7 +14969,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -15437,8 +15469,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15461,7 +15493,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -15954,8 +15986,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15974,7 +16006,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -16462,8 +16494,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16482,7 +16514,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -16970,8 +17002,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16998,7 +17030,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -17493,8 +17525,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17519,7 +17551,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -18010,8 +18042,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18034,7 +18066,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -18527,8 +18559,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18555,7 +18587,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -19053,8 +19085,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19081,7 +19113,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -19581,8 +19613,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19605,7 +19637,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` bigint(20) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_2_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_2_tokudb.result index 92cfa5d59b9..f6e98be3c98 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_2_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_1_2_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -44,8 +44,8 @@ SET @@session.sql_mode= ''; # 1.3.1 no PRIMARY KEY or UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -500,8 +500,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -956,8 +956,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1427,8 +1427,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1892,8 +1892,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2355,8 +2355,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2829,8 +2829,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3305,8 +3305,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3771,8 +3771,8 @@ DROP TABLE t1; # 1.3.2 PRIMARY KEY exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3791,8 +3791,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4231,6 +4231,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4263,8 +4266,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4283,8 +4286,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4723,6 +4726,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4755,8 +4761,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4783,8 +4789,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5230,6 +5236,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5262,8 +5271,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5288,8 +5297,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5731,6 +5740,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5763,8 +5775,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5787,8 +5799,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6230,6 +6242,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6262,8 +6277,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6290,8 +6305,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6740,6 +6755,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6772,8 +6790,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6800,8 +6818,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7252,6 +7270,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7284,8 +7305,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7308,8 +7329,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7752,6 +7773,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7785,8 +7809,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7805,8 +7829,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8245,6 +8269,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8277,8 +8304,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8297,8 +8324,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8737,6 +8764,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8769,8 +8799,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8797,8 +8827,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9244,6 +9274,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9276,8 +9309,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9302,8 +9335,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9745,6 +9778,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9777,8 +9813,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9801,8 +9837,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10244,6 +10280,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10276,8 +10315,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10304,8 +10343,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10754,6 +10793,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10786,8 +10828,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10814,8 +10856,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11266,6 +11308,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11298,8 +11343,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11322,8 +11367,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` bigint(20) NOT NULL DEFAULT '0', - `f_int2` bigint(20) NOT NULL DEFAULT '0', + `f_int1` bigint(20) NOT NULL, + `f_int2` bigint(20) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11766,6 +11811,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11800,8 +11848,8 @@ DROP TABLE t1; # 1.3.3 UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12308,8 +12356,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12816,8 +12864,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13339,8 +13387,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13856,8 +13904,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14371,8 +14419,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14897,8 +14945,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15425,8 +15473,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15942,8 +15990,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16450,8 +16498,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16958,8 +17006,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17481,8 +17529,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17998,8 +18046,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18513,8 +18561,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19039,8 +19087,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19567,8 +19615,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_1_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_1_tokudb.result index 1ae379ccc07..883c9ec3453 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_1_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_1_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -48,8 +48,8 @@ SET @@session.sql_mode= ''; # 2.1.1 no PRIMARY KEY or UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -68,7 +68,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -506,8 +506,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -526,7 +526,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -964,8 +964,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -992,7 +992,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -1437,8 +1437,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1463,7 +1463,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -1902,8 +1902,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1926,7 +1926,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -2369,8 +2369,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2397,7 +2397,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -2843,8 +2843,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2871,7 +2871,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -3321,8 +3321,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3345,7 +3345,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -3788,8 +3788,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3809,7 +3809,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4250,6 +4250,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4282,8 +4284,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4303,7 +4305,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4744,6 +4746,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4776,8 +4780,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4805,7 +4809,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5253,6 +5257,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5285,8 +5291,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5312,7 +5318,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5754,6 +5760,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5786,8 +5794,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5811,7 +5819,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6257,6 +6265,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6289,8 +6299,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6318,7 +6328,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6767,6 +6777,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6799,8 +6811,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6828,7 +6840,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7281,6 +7293,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7313,8 +7327,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7338,7 +7352,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7783,6 +7797,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7816,8 +7832,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7837,7 +7853,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8278,6 +8294,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8310,8 +8328,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8331,7 +8349,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8772,6 +8790,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8804,8 +8824,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8833,7 +8853,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9281,6 +9301,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9313,8 +9335,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9340,7 +9362,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9782,6 +9804,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9814,8 +9838,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9839,7 +9863,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10285,6 +10309,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10317,8 +10343,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10346,7 +10372,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10795,6 +10821,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10827,8 +10855,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10856,7 +10884,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11309,6 +11337,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11341,8 +11371,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11366,7 +11396,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11811,6 +11841,8 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11845,8 +11877,8 @@ DROP TABLE t1; # 2.1.3 UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11865,7 +11897,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -12355,8 +12387,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12375,7 +12407,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -12865,8 +12897,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12893,7 +12925,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -13390,8 +13422,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13416,7 +13448,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -13907,8 +13939,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13931,7 +13963,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -14426,8 +14458,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14454,7 +14486,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -14952,8 +14984,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14980,7 +15012,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -15482,8 +15514,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15506,7 +15538,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -16001,8 +16033,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16021,7 +16053,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -16511,8 +16543,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16531,7 +16563,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -17021,8 +17053,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17049,7 +17081,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -17546,8 +17578,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17572,7 +17604,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -18063,8 +18095,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18087,7 +18119,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -18582,8 +18614,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18610,7 +18642,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -19108,8 +19140,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19136,7 +19168,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, @@ -19638,8 +19670,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19662,7 +19694,7 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', `f_int2` mediumint(9) DEFAULT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_2_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_2_tokudb.result index 9ed9866a42f..993025c9fb2 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_2_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter2_2_2_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -43,8 +43,8 @@ SET @@session.sql_mode= ''; # 2.3.1 no PRIMARY KEY or UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -502,8 +502,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -961,8 +961,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1435,8 +1435,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1905,8 +1905,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2373,8 +2373,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2852,8 +2852,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3331,8 +3331,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3800,8 +3800,8 @@ DROP TABLE t1; # 2.3.2 PRIMARY KEY exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3820,8 +3820,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4263,6 +4263,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4295,8 +4298,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4315,8 +4318,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -4758,6 +4761,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -4790,8 +4796,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4818,8 +4824,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5268,6 +5274,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5300,8 +5309,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5326,8 +5335,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -5774,6 +5783,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -5806,8 +5818,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5830,8 +5842,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6278,6 +6290,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6310,8 +6325,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6338,8 +6353,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -6793,6 +6808,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -6825,8 +6843,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6853,8 +6871,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7308,6 +7326,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7340,8 +7361,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7364,8 +7385,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -7811,6 +7832,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -7844,8 +7868,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7864,8 +7888,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8307,6 +8331,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8339,8 +8366,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8359,8 +8386,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -8802,6 +8829,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -8834,8 +8864,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8862,8 +8892,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9312,6 +9342,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9344,8 +9377,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9370,8 +9403,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -9818,6 +9851,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -9850,8 +9886,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9874,8 +9910,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10322,6 +10358,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10354,8 +10393,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10382,8 +10421,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -10837,6 +10876,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -10869,8 +10911,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10897,8 +10939,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11352,6 +11394,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11384,8 +11429,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11408,8 +11453,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` mediumint(9) NOT NULL DEFAULT '0', - `f_int2` mediumint(9) NOT NULL DEFAULT '0', + `f_int1` mediumint(9) NOT NULL, + `f_int2` mediumint(9) NOT NULL, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -11855,6 +11900,9 @@ SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; +Warnings: +Warning 1364 Field 'f_int1' doesn't have a default value +Warning 1364 Field 'f_int2' doesn't have a default value DROP TRIGGER trg_3; # check trigger-12 success: 1 @@ -11889,8 +11937,8 @@ DROP TABLE t1; # 2.3.3 UNIQUE INDEX exists DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12400,8 +12448,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12911,8 +12959,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13437,8 +13485,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13959,8 +14007,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14479,8 +14527,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15010,8 +15058,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15541,8 +15589,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16061,8 +16109,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16572,8 +16620,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17083,8 +17131,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17609,8 +17657,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18131,8 +18179,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18651,8 +18699,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19182,8 +19230,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19713,8 +19761,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter4_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter4_tokudb.result index 644c4815a36..40d167b57ea 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter4_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_alter4_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -47,8 +47,8 @@ SET @@session.sql_mode= ''; # 1.1 ALTER ... ANALYZE PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -69,8 +69,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -506,8 +506,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -528,8 +528,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -968,8 +968,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -998,8 +998,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -1441,8 +1441,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1469,8 +1469,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -1908,8 +1908,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1934,8 +1934,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -2375,8 +2375,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2405,8 +2405,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -2851,8 +2851,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2881,8 +2881,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -3329,8 +3329,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3355,8 +3355,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -3797,8 +3797,8 @@ DROP TABLE t1; # 1.2 ALTER ... ANALYZE PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3819,8 +3819,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -4256,8 +4256,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4278,8 +4278,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -4718,8 +4718,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4748,8 +4748,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -5191,8 +5191,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5219,8 +5219,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -5658,8 +5658,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5684,8 +5684,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -6125,8 +6125,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6155,8 +6155,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -6601,8 +6601,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6631,8 +6631,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -7079,8 +7079,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7105,8 +7105,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -7547,8 +7547,8 @@ DROP TABLE t1; # 1.3 ALTER ... ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7569,8 +7569,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -8006,8 +8006,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8028,8 +8028,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -8468,8 +8468,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8498,8 +8498,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -8941,8 +8941,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8969,8 +8969,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -9408,8 +9408,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9434,8 +9434,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -9875,8 +9875,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9905,8 +9905,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -10351,8 +10351,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10381,8 +10381,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -10829,8 +10829,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10855,8 +10855,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -11297,8 +11297,8 @@ DROP TABLE t1; # 1.4 ALTER ... ANALYZE PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11319,8 +11319,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -11756,8 +11756,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11778,8 +11778,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -12218,8 +12218,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12248,8 +12248,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -12691,8 +12691,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12719,8 +12719,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -13158,8 +13158,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13184,8 +13184,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -13625,8 +13625,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13655,8 +13655,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -14101,8 +14101,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14131,8 +14131,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -14579,8 +14579,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14605,8 +14605,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -15047,8 +15047,8 @@ DROP TABLE t1; # 1.5 ALTER ... ANALYZE PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15069,8 +15069,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -15506,8 +15506,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15528,8 +15528,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -15968,8 +15968,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15998,8 +15998,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -16441,8 +16441,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16469,8 +16469,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -16908,8 +16908,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16934,8 +16934,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -17375,8 +17375,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17405,8 +17405,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -17851,8 +17851,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17881,8 +17881,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -18329,8 +18329,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18355,8 +18355,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -18800,8 +18800,8 @@ DROP TABLE t1; # 2.1 ALTER ... CHECK PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18822,8 +18822,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -19259,8 +19259,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19281,8 +19281,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -19721,8 +19721,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19751,8 +19751,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -20194,8 +20194,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20222,8 +20222,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -20661,8 +20661,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20687,8 +20687,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -21128,8 +21128,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21158,8 +21158,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -21604,8 +21604,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21634,8 +21634,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -22082,8 +22082,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22108,8 +22108,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -22550,8 +22550,8 @@ DROP TABLE t1; # 2.2 ALTER ... CHECK PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22572,8 +22572,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -23009,8 +23009,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23031,8 +23031,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -23471,8 +23471,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23501,8 +23501,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -23944,8 +23944,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23972,8 +23972,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -24411,8 +24411,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24437,8 +24437,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -24878,8 +24878,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24908,8 +24908,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -25354,8 +25354,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25384,8 +25384,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -25832,8 +25832,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25858,8 +25858,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -26300,8 +26300,8 @@ DROP TABLE t1; # 2.3 ALTER ... CHECK PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26322,8 +26322,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -26759,8 +26759,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26781,8 +26781,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -27221,8 +27221,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27251,8 +27251,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -27694,8 +27694,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27722,8 +27722,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -28161,8 +28161,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -28187,8 +28187,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -28628,8 +28628,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -28658,8 +28658,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -29104,8 +29104,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -29134,8 +29134,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -29582,8 +29582,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -29608,8 +29608,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -30050,8 +30050,8 @@ DROP TABLE t1; # 2.4 ALTER ... CHECK PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -30072,8 +30072,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -30509,8 +30509,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -30531,8 +30531,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -30971,8 +30971,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31001,8 +31001,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -31444,8 +31444,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31472,8 +31472,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -31911,8 +31911,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31937,8 +31937,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -32378,8 +32378,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -32408,8 +32408,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -32854,8 +32854,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -32884,8 +32884,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -33332,8 +33332,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -33358,8 +33358,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -33800,8 +33800,8 @@ DROP TABLE t1; # 2.5 ALTER ... CHECK PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -33822,8 +33822,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -34259,8 +34259,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -34281,8 +34281,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -34721,8 +34721,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -34751,8 +34751,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -35194,8 +35194,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -35222,8 +35222,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -35661,8 +35661,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -35687,8 +35687,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -36128,8 +36128,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -36158,8 +36158,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -36604,8 +36604,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -36634,8 +36634,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -37082,8 +37082,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -37108,8 +37108,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -37553,8 +37553,8 @@ DROP TABLE t1; # 3.1 ALTER ... OPTIMIZE PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -37576,8 +37576,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -38013,8 +38013,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -38036,8 +38036,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -38476,8 +38476,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -38507,8 +38507,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -38950,8 +38950,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -38979,8 +38979,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -39418,8 +39418,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -39445,8 +39445,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -39886,8 +39886,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -39917,8 +39917,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -40363,8 +40363,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -40394,8 +40394,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -40842,8 +40842,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -40869,8 +40869,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -41311,8 +41311,8 @@ DROP TABLE t1; # 3.2 ALTER ... OPTIMIZE PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -41334,8 +41334,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -41771,8 +41771,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -41794,8 +41794,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -42234,8 +42234,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -42265,8 +42265,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -42708,8 +42708,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -42737,8 +42737,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -43176,8 +43176,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -43203,8 +43203,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -43644,8 +43644,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -43675,8 +43675,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -44121,8 +44121,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -44152,8 +44152,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -44600,8 +44600,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -44627,8 +44627,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -45069,8 +45069,8 @@ DROP TABLE t1; # 3.3 ALTER ... OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -45091,8 +45091,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -45528,8 +45528,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -45550,8 +45550,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -45990,8 +45990,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -46020,8 +46020,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -46463,8 +46463,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -46491,8 +46491,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -46930,8 +46930,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -46956,8 +46956,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -47397,8 +47397,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -47427,8 +47427,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -47873,8 +47873,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -47903,8 +47903,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -48351,8 +48351,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -48377,8 +48377,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -48819,8 +48819,8 @@ DROP TABLE t1; # 3.4 ALTER ... OPTIMIZE PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -48841,8 +48841,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -49278,8 +49278,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -49300,8 +49300,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -49740,8 +49740,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -49770,8 +49770,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -50213,8 +50213,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -50241,8 +50241,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -50680,8 +50680,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -50706,8 +50706,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -51147,8 +51147,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -51177,8 +51177,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -51623,8 +51623,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -51653,8 +51653,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -52101,8 +52101,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -52127,8 +52127,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -52569,8 +52569,8 @@ DROP TABLE t1; # 3.5 ALTER ... OPTIMIZE PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -52592,8 +52592,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -53029,8 +53029,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -53052,8 +53052,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -53492,8 +53492,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -53523,8 +53523,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -53966,8 +53966,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -53995,8 +53995,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -54434,8 +54434,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -54461,8 +54461,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -54902,8 +54902,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -54933,8 +54933,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -55379,8 +55379,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -55410,8 +55410,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -55858,8 +55858,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -55885,8 +55885,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -56330,8 +56330,8 @@ DROP TABLE t1; # 4.1 ALTER ... REBUILD PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -56350,8 +56350,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -56787,8 +56787,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -56807,8 +56807,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -57247,8 +57247,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -57275,8 +57275,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -57718,8 +57718,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -57744,8 +57744,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -58183,8 +58183,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -58207,8 +58207,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -58648,8 +58648,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -58676,8 +58676,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -59122,8 +59122,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -59150,8 +59150,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -59598,8 +59598,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -59622,8 +59622,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -60064,8 +60064,8 @@ DROP TABLE t1; # 4.2 ALTER ... REBUILD PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -60084,8 +60084,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -60521,8 +60521,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -60541,8 +60541,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -60981,8 +60981,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -61009,8 +61009,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -61452,8 +61452,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -61478,8 +61478,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -61917,8 +61917,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -61941,8 +61941,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -62382,8 +62382,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -62410,8 +62410,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -62856,8 +62856,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -62884,8 +62884,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -63332,8 +63332,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63356,8 +63356,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -63798,8 +63798,8 @@ DROP TABLE t1; # 4.3 ALTER ... REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63813,8 +63813,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63828,8 +63828,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63851,8 +63851,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63872,8 +63872,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63891,8 +63891,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63914,8 +63914,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63937,8 +63937,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63958,8 +63958,8 @@ DROP TABLE t1; # 4.4 ALTER ... REBUILD PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63973,8 +63973,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -63988,8 +63988,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64011,8 +64011,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64032,8 +64032,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64051,8 +64051,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64074,8 +64074,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64097,8 +64097,8 @@ ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Error in list of partitions to REBUILD DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64118,8 +64118,8 @@ DROP TABLE t1; # 4.5 ALTER ... REBUILD PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64138,8 +64138,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -64575,8 +64575,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -64595,8 +64595,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -65035,8 +65035,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -65063,8 +65063,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -65506,8 +65506,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -65532,8 +65532,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -65971,8 +65971,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -65995,8 +65995,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -66436,8 +66436,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -66464,8 +66464,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -66910,8 +66910,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -66938,8 +66938,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -67386,8 +67386,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -67410,8 +67410,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -67855,8 +67855,8 @@ DROP TABLE t1; # 5.1 ALTER ... REPAIR PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -67877,8 +67877,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -68314,8 +68314,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -68336,8 +68336,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -68776,8 +68776,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -68806,8 +68806,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -69249,8 +69249,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -69277,8 +69277,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -69716,8 +69716,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -69742,8 +69742,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -70183,8 +70183,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -70213,8 +70213,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -70659,8 +70659,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -70689,8 +70689,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -71137,8 +71137,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -71163,8 +71163,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -71605,8 +71605,8 @@ DROP TABLE t1; # 5.2 ALTER ... REPAIR PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -71627,8 +71627,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -72064,8 +72064,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -72086,8 +72086,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -72526,8 +72526,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -72556,8 +72556,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -72999,8 +72999,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -73027,8 +73027,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -73466,8 +73466,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -73492,8 +73492,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -73933,8 +73933,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -73963,8 +73963,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -74409,8 +74409,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -74439,8 +74439,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -74887,8 +74887,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -74913,8 +74913,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -75355,8 +75355,8 @@ DROP TABLE t1; # 5.3 ALTER ... REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -75377,8 +75377,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -75814,8 +75814,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -75836,8 +75836,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -76276,8 +76276,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -76306,8 +76306,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -76749,8 +76749,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -76777,8 +76777,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -77216,8 +77216,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -77242,8 +77242,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -77683,8 +77683,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -77713,8 +77713,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -78159,8 +78159,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -78189,8 +78189,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -78637,8 +78637,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -78663,8 +78663,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -79105,8 +79105,8 @@ DROP TABLE t1; # 5.4 ALTER ... REPAIR PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -79127,8 +79127,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -79564,8 +79564,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -79586,8 +79586,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -80026,8 +80026,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -80056,8 +80056,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -80499,8 +80499,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -80527,8 +80527,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -80966,8 +80966,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -80992,8 +80992,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -81433,8 +81433,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -81463,8 +81463,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -81909,8 +81909,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -81939,8 +81939,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -82387,8 +82387,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -82413,8 +82413,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -82855,8 +82855,8 @@ DROP TABLE t1; # 5.5 ALTER ... REPAIR PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -82877,8 +82877,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -83314,8 +83314,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -83336,8 +83336,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -83776,8 +83776,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -83806,8 +83806,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -84249,8 +84249,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -84277,8 +84277,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -84716,8 +84716,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -84742,8 +84742,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -85183,8 +85183,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -85213,8 +85213,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -85659,8 +85659,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -85689,8 +85689,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -86137,8 +86137,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -86163,8 +86163,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -86608,8 +86608,8 @@ DROP TABLE t1; # 6.1 ALTER ... REMOVE PARTITIONING; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -86628,8 +86628,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -87062,8 +87062,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -87082,8 +87082,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -87516,8 +87516,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -87544,8 +87544,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -87978,8 +87978,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -88004,8 +88004,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -88438,8 +88438,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -88462,8 +88462,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -88896,8 +88896,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -88924,8 +88924,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -89358,8 +89358,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -89386,8 +89386,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -89820,8 +89820,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -89844,8 +89844,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_basic_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_basic_tokudb.result index a13a53bd5f9..8182dce5625 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_basic_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_basic_tokudb.result @@ -11,8 +11,8 @@ SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , @@ -27,8 +27,8 @@ file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; -CREATE TABLE t0_aux ( f_int1 INTEGER, -f_int2 INTEGER, +CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) @@ -52,8 +52,8 @@ SET @@session.sql_mode= ''; # 1.1 The partitioning function contains one column. DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -67,8 +67,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -507,8 +507,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -522,8 +522,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -962,8 +962,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -985,8 +985,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -1432,8 +1432,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1453,8 +1453,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -1896,8 +1896,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -1915,8 +1915,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -2360,8 +2360,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2383,8 +2383,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -2833,8 +2833,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -2860,8 +2860,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -3312,8 +3312,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3331,8 +3331,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -3777,8 +3777,8 @@ DROP TABLE t1; # 1.2 The partitioning function contains two columns. DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -3792,8 +3792,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -4232,8 +4232,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4247,8 +4247,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -4687,8 +4687,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -4710,8 +4710,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -5157,8 +5157,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5178,8 +5178,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -5621,8 +5621,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -5640,8 +5640,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -6083,8 +6083,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6106,8 +6106,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -6556,8 +6556,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -6579,8 +6579,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -7031,8 +7031,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7050,8 +7050,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL @@ -7500,8 +7500,8 @@ DROP TABLE t1; # 2.5 PRIMARY KEY + UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -7992,8 +7992,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8484,8 +8484,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -8991,8 +8991,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9492,8 +9492,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -9993,8 +9993,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -10503,8 +10503,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11019,8 +11019,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -11520,8 +11520,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12012,8 +12012,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -12504,8 +12504,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13011,8 +13011,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -13512,8 +13512,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14013,8 +14013,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -14523,8 +14523,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15039,8 +15039,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15540,8 +15540,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -15555,8 +15555,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -16048,8 +16048,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16063,8 +16063,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -16556,8 +16556,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -16579,8 +16579,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -17079,8 +17079,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17100,8 +17100,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -17596,8 +17596,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -17615,8 +17615,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -18113,8 +18113,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18136,8 +18136,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -18639,8 +18639,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -18666,8 +18666,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -19171,8 +19171,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -19190,8 +19190,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -19693,8 +19693,8 @@ DROP TABLE t1; # 3.3 PRIMARY KEY and UNIQUE INDEX consisting of two columns DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20185,8 +20185,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -20677,8 +20677,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21184,8 +21184,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -21685,8 +21685,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22184,8 +22184,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -22694,8 +22694,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23206,8 +23206,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -23707,8 +23707,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24199,8 +24199,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -24691,8 +24691,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25198,8 +25198,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -25699,8 +25699,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26198,8 +26198,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -26708,8 +26708,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27220,8 +27220,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27721,8 +27721,8 @@ TRUNCATE t1; DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -27736,8 +27736,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -28229,8 +28229,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -28244,8 +28244,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -28737,8 +28737,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -28760,8 +28760,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -29260,8 +29260,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -29281,8 +29281,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -29777,8 +29777,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -29796,8 +29796,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -30292,8 +30292,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -30315,8 +30315,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -30818,8 +30818,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -30841,8 +30841,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, @@ -31346,8 +31346,8 @@ TRUNCATE t1; # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( -f_int1 INTEGER, -f_int2 INTEGER, +f_int1 INTEGER DEFAULT 0, +f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) @@ -31365,8 +31365,8 @@ create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f_int1` int(11) DEFAULT NULL, - `f_int2` int(11) DEFAULT NULL, + `f_int1` int(11) DEFAULT '0', + `f_int2` int(11) DEFAULT '0', `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL, diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result index 1a89df3eb1e..9155661d6d9 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result @@ -10,8 +10,9 @@ call mtr.add_suppression("TokuDB: Warning: MySQL is trying to drop table "); # after timed out COALESCE PARTITION # Extended crash recovery testing of fast_alter_partition_table. call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); +flush tables; # Crash testing ADD PARTITION -SET SESSION debug="+d,crash_add_partition_1"; +SET SESSION debug_dbug="+d,crash_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -69,8 +70,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_1"; -SET SESSION debug="+d,crash_add_partition_2"; +SET SESSION debug_dbug="-d,crash_add_partition_1"; +SET SESSION debug_dbug="+d,crash_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -130,8 +131,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_2"; -SET SESSION debug="+d,crash_add_partition_3"; +SET SESSION debug_dbug="-d,crash_add_partition_2"; +SET SESSION debug_dbug="+d,crash_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -191,8 +192,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_3"; -SET SESSION debug="+d,crash_add_partition_4"; +SET SESSION debug_dbug="-d,crash_add_partition_3"; +SET SESSION debug_dbug="+d,crash_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -252,8 +253,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_4"; -SET SESSION debug="+d,crash_add_partition_5"; +SET SESSION debug_dbug="-d,crash_add_partition_4"; +SET SESSION debug_dbug="+d,crash_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -313,8 +314,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_5"; -SET SESSION debug="+d,crash_add_partition_6"; +SET SESSION debug_dbug="-d,crash_add_partition_5"; +SET SESSION debug_dbug="+d,crash_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -374,8 +375,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_6"; -SET SESSION debug="+d,crash_add_partition_7"; +SET SESSION debug_dbug="-d,crash_add_partition_6"; +SET SESSION debug_dbug="+d,crash_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -435,8 +436,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_7"; -SET SESSION debug="+d,crash_add_partition_8"; +SET SESSION debug_dbug="-d,crash_add_partition_7"; +SET SESSION debug_dbug="+d,crash_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -497,8 +498,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_8"; -SET SESSION debug="+d,crash_add_partition_9"; +SET SESSION debug_dbug="-d,crash_add_partition_8"; +SET SESSION debug_dbug="+d,crash_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -557,8 +558,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_9"; -SET SESSION debug="+d,crash_add_partition_10"; +SET SESSION debug_dbug="-d,crash_add_partition_9"; +SET SESSION debug_dbug="+d,crash_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -617,9 +618,9 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_add_partition_10"; +SET SESSION debug_dbug="-d,crash_add_partition_10"; # Error recovery testing ADD PARTITION -SET SESSION debug="+d,fail_add_partition_1"; +SET SESSION debug_dbug="+d,fail_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -731,8 +732,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_1"; -SET SESSION debug="+d,fail_add_partition_2"; +SET SESSION debug_dbug="-d,fail_add_partition_1"; +SET SESSION debug_dbug="+d,fail_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -844,8 +845,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_2"; -SET SESSION debug="+d,fail_add_partition_3"; +SET SESSION debug_dbug="-d,fail_add_partition_2"; +SET SESSION debug_dbug="+d,fail_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -957,8 +958,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_3"; -SET SESSION debug="+d,fail_add_partition_4"; +SET SESSION debug_dbug="-d,fail_add_partition_3"; +SET SESSION debug_dbug="+d,fail_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1070,8 +1071,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_4"; -SET SESSION debug="+d,fail_add_partition_5"; +SET SESSION debug_dbug="-d,fail_add_partition_4"; +SET SESSION debug_dbug="+d,fail_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1183,8 +1184,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_5"; -SET SESSION debug="+d,fail_add_partition_6"; +SET SESSION debug_dbug="-d,fail_add_partition_5"; +SET SESSION debug_dbug="+d,fail_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1296,8 +1297,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_6"; -SET SESSION debug="+d,fail_add_partition_7"; +SET SESSION debug_dbug="-d,fail_add_partition_6"; +SET SESSION debug_dbug="+d,fail_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1409,8 +1410,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_7"; -SET SESSION debug="+d,fail_add_partition_8"; +SET SESSION debug_dbug="-d,fail_add_partition_7"; +SET SESSION debug_dbug="+d,fail_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1524,8 +1525,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_8"; -SET SESSION debug="+d,fail_add_partition_9"; +SET SESSION debug_dbug="-d,fail_add_partition_8"; +SET SESSION debug_dbug="+d,fail_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1639,8 +1640,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_9"; -SET SESSION debug="+d,fail_add_partition_10"; +SET SESSION debug_dbug="-d,fail_add_partition_9"; +SET SESSION debug_dbug="+d,fail_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1754,9 +1755,9 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_add_partition_10"; +SET SESSION debug_dbug="-d,fail_add_partition_10"; # Test DROP PARTITION -SET SESSION debug="+d,crash_drop_partition_1"; +SET SESSION debug_dbug="+d,crash_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1813,8 +1814,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_1"; -SET SESSION debug="+d,crash_drop_partition_2"; +SET SESSION debug_dbug="-d,crash_drop_partition_1"; +SET SESSION debug_dbug="+d,crash_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1873,8 +1874,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_2"; -SET SESSION debug="+d,crash_drop_partition_3"; +SET SESSION debug_dbug="-d,crash_drop_partition_2"; +SET SESSION debug_dbug="+d,crash_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1933,8 +1934,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_3"; -SET SESSION debug="+d,crash_drop_partition_4"; +SET SESSION debug_dbug="-d,crash_drop_partition_3"; +SET SESSION debug_dbug="+d,crash_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -1988,8 +1989,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_4"; -SET SESSION debug="+d,crash_drop_partition_5"; +SET SESSION debug_dbug="-d,crash_drop_partition_4"; +SET SESSION debug_dbug="+d,crash_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2043,8 +2044,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_5"; -SET SESSION debug="+d,crash_drop_partition_6"; +SET SESSION debug_dbug="-d,crash_drop_partition_5"; +SET SESSION debug_dbug="+d,crash_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2098,8 +2099,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_6"; -SET SESSION debug="+d,crash_drop_partition_7"; +SET SESSION debug_dbug="-d,crash_drop_partition_6"; +SET SESSION debug_dbug="+d,crash_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2151,8 +2152,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_7"; -SET SESSION debug="+d,crash_drop_partition_8"; +SET SESSION debug_dbug="-d,crash_drop_partition_7"; +SET SESSION debug_dbug="+d,crash_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2204,8 +2205,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_8"; -SET SESSION debug="+d,crash_drop_partition_9"; +SET SESSION debug_dbug="-d,crash_drop_partition_8"; +SET SESSION debug_dbug="+d,crash_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2257,9 +2258,9 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_drop_partition_9"; +SET SESSION debug_dbug="-d,crash_drop_partition_9"; # Error recovery DROP PARTITION -SET SESSION debug="+d,fail_drop_partition_1"; +SET SESSION debug_dbug="+d,fail_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2369,8 +2370,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_1"; -SET SESSION debug="+d,fail_drop_partition_2"; +SET SESSION debug_dbug="-d,fail_drop_partition_1"; +SET SESSION debug_dbug="+d,fail_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2480,8 +2481,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_2"; -SET SESSION debug="+d,fail_drop_partition_3"; +SET SESSION debug_dbug="-d,fail_drop_partition_2"; +SET SESSION debug_dbug="+d,fail_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2591,8 +2592,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_3"; -SET SESSION debug="+d,fail_drop_partition_4"; +SET SESSION debug_dbug="-d,fail_drop_partition_3"; +SET SESSION debug_dbug="+d,fail_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2692,8 +2693,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_4"; -SET SESSION debug="+d,fail_drop_partition_5"; +SET SESSION debug_dbug="-d,fail_drop_partition_4"; +SET SESSION debug_dbug="+d,fail_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2793,8 +2794,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_5"; -SET SESSION debug="+d,fail_drop_partition_6"; +SET SESSION debug_dbug="-d,fail_drop_partition_5"; +SET SESSION debug_dbug="+d,fail_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2894,8 +2895,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_6"; -SET SESSION debug="+d,fail_drop_partition_7"; +SET SESSION debug_dbug="-d,fail_drop_partition_6"; +SET SESSION debug_dbug="+d,fail_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -2995,8 +2996,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_7"; -SET SESSION debug="+d,fail_drop_partition_8"; +SET SESSION debug_dbug="-d,fail_drop_partition_7"; +SET SESSION debug_dbug="+d,fail_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3096,8 +3097,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_8"; -SET SESSION debug="+d,fail_drop_partition_9"; +SET SESSION debug_dbug="-d,fail_drop_partition_8"; +SET SESSION debug_dbug="+d,fail_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3197,10 +3198,10 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_drop_partition_9"; +SET SESSION debug_dbug="-d,fail_drop_partition_9"; # Test change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). -SET SESSION debug="+d,crash_change_partition_1"; +SET SESSION debug_dbug="+d,crash_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3259,8 +3260,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_1"; -SET SESSION debug="+d,crash_change_partition_2"; +SET SESSION debug_dbug="-d,crash_change_partition_1"; +SET SESSION debug_dbug="+d,crash_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3321,8 +3322,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_2"; -SET SESSION debug="+d,crash_change_partition_3"; +SET SESSION debug_dbug="-d,crash_change_partition_2"; +SET SESSION debug_dbug="+d,crash_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3383,8 +3384,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_3"; -SET SESSION debug="+d,crash_change_partition_4"; +SET SESSION debug_dbug="-d,crash_change_partition_3"; +SET SESSION debug_dbug="+d,crash_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3445,8 +3446,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_4"; -SET SESSION debug="+d,crash_change_partition_5"; +SET SESSION debug_dbug="-d,crash_change_partition_4"; +SET SESSION debug_dbug="+d,crash_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3507,8 +3508,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_5"; -SET SESSION debug="+d,crash_change_partition_6"; +SET SESSION debug_dbug="-d,crash_change_partition_5"; +SET SESSION debug_dbug="+d,crash_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3569,8 +3570,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_6"; -SET SESSION debug="+d,crash_change_partition_7"; +SET SESSION debug_dbug="-d,crash_change_partition_6"; +SET SESSION debug_dbug="+d,crash_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3632,8 +3633,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_7"; -SET SESSION debug="+d,crash_change_partition_8"; +SET SESSION debug_dbug="-d,crash_change_partition_7"; +SET SESSION debug_dbug="+d,crash_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3695,8 +3696,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_8"; -SET SESSION debug="+d,crash_change_partition_9"; +SET SESSION debug_dbug="-d,crash_change_partition_8"; +SET SESSION debug_dbug="+d,crash_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3756,8 +3757,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_9"; -SET SESSION debug="+d,crash_change_partition_10"; +SET SESSION debug_dbug="-d,crash_change_partition_9"; +SET SESSION debug_dbug="+d,crash_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3817,8 +3818,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_10"; -SET SESSION debug="+d,crash_change_partition_11"; +SET SESSION debug_dbug="-d,crash_change_partition_10"; +SET SESSION debug_dbug="+d,crash_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3878,8 +3879,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_11"; -SET SESSION debug="+d,crash_change_partition_12"; +SET SESSION debug_dbug="-d,crash_change_partition_11"; +SET SESSION debug_dbug="+d,crash_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -3939,10 +3940,10 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug="-d,crash_change_partition_12"; +SET SESSION debug_dbug="-d,crash_change_partition_12"; # Error recovery change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). -SET SESSION debug="+d,fail_change_partition_1"; +SET SESSION debug_dbug="+d,fail_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4056,8 +4057,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_1"; -SET SESSION debug="+d,fail_change_partition_2"; +SET SESSION debug_dbug="-d,fail_change_partition_1"; +SET SESSION debug_dbug="+d,fail_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4171,8 +4172,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_2"; -SET SESSION debug="+d,fail_change_partition_3"; +SET SESSION debug_dbug="-d,fail_change_partition_2"; +SET SESSION debug_dbug="+d,fail_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4286,8 +4287,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_3"; -SET SESSION debug="+d,fail_change_partition_4"; +SET SESSION debug_dbug="-d,fail_change_partition_3"; +SET SESSION debug_dbug="+d,fail_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4401,8 +4402,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_4"; -SET SESSION debug="+d,fail_change_partition_5"; +SET SESSION debug_dbug="-d,fail_change_partition_4"; +SET SESSION debug_dbug="+d,fail_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4516,8 +4517,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_5"; -SET SESSION debug="+d,fail_change_partition_6"; +SET SESSION debug_dbug="-d,fail_change_partition_5"; +SET SESSION debug_dbug="+d,fail_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4631,8 +4632,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_6"; -SET SESSION debug="+d,fail_change_partition_7"; +SET SESSION debug_dbug="-d,fail_change_partition_6"; +SET SESSION debug_dbug="+d,fail_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4748,8 +4749,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_7"; -SET SESSION debug="+d,fail_change_partition_8"; +SET SESSION debug_dbug="-d,fail_change_partition_7"; +SET SESSION debug_dbug="+d,fail_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4865,8 +4866,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_8"; -SET SESSION debug="+d,fail_change_partition_9"; +SET SESSION debug_dbug="-d,fail_change_partition_8"; +SET SESSION debug_dbug="+d,fail_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -4982,8 +4983,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_9"; -SET SESSION debug="+d,fail_change_partition_10"; +SET SESSION debug_dbug="-d,fail_change_partition_9"; +SET SESSION debug_dbug="+d,fail_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -5099,8 +5100,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_10"; -SET SESSION debug="+d,fail_change_partition_11"; +SET SESSION debug_dbug="-d,fail_change_partition_10"; +SET SESSION debug_dbug="+d,fail_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -5216,8 +5217,8 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_11"; -SET SESSION debug="+d,fail_change_partition_12"; +SET SESSION debug_dbug="-d,fail_change_partition_11"; +SET SESSION debug_dbug="+d,fail_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' PARTITION BY LIST (a) @@ -5333,14 +5334,14 @@ a b 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug="-d,fail_change_partition_12"; +SET SESSION debug_dbug="-d,fail_change_partition_12"; # # WL#4445: EXCHANGE PARTITION WITH TABLE # Verify ddl_log and TokuDB in case of crashing. call mtr.add_suppression("TokuDB: Warning: allocated tablespace .*, old maximum was "); call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); call mtr.add_suppression("table .* does not exist in the TokuDB internal"); -SET SESSION debug="+d,exchange_partition_abort_1"; +SET SESSION debug_dbug="+d,exchange_partition_abort_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -5435,8 +5436,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_1"; -SET SESSION debug="+d,exchange_partition_abort_2"; +SET SESSION debug_dbug="-d,exchange_partition_abort_1"; +SET SESSION debug_dbug="+d,exchange_partition_abort_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -5531,8 +5532,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_2"; -SET SESSION debug="+d,exchange_partition_abort_3"; +SET SESSION debug_dbug="-d,exchange_partition_abort_2"; +SET SESSION debug_dbug="+d,exchange_partition_abort_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -5627,8 +5628,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_3"; -SET SESSION debug="+d,exchange_partition_abort_4"; +SET SESSION debug_dbug="-d,exchange_partition_abort_3"; +SET SESSION debug_dbug="+d,exchange_partition_abort_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -5723,8 +5724,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_4"; -SET SESSION debug="+d,exchange_partition_abort_5"; +SET SESSION debug_dbug="-d,exchange_partition_abort_4"; +SET SESSION debug_dbug="+d,exchange_partition_abort_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -5819,8 +5820,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_5"; -SET SESSION debug="+d,exchange_partition_abort_6"; +SET SESSION debug_dbug="-d,exchange_partition_abort_5"; +SET SESSION debug_dbug="+d,exchange_partition_abort_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -5915,8 +5916,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_6"; -SET SESSION debug="+d,exchange_partition_abort_7"; +SET SESSION debug_dbug="-d,exchange_partition_abort_6"; +SET SESSION debug_dbug="+d,exchange_partition_abort_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6011,8 +6012,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_7"; -SET SESSION debug="+d,exchange_partition_abort_8"; +SET SESSION debug_dbug="-d,exchange_partition_abort_7"; +SET SESSION debug_dbug="+d,exchange_partition_abort_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6107,8 +6108,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_8"; -SET SESSION debug="+d,exchange_partition_abort_9"; +SET SESSION debug_dbug="-d,exchange_partition_abort_8"; +SET SESSION debug_dbug="+d,exchange_partition_abort_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6203,8 +6204,8 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_abort_9"; -SET SESSION debug="+d,exchange_partition_fail_1"; +SET SESSION debug_dbug="-d,exchange_partition_abort_9"; +SET SESSION debug_dbug="+d,exchange_partition_fail_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6295,8 +6296,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_1"; -SET SESSION debug="+d,exchange_partition_fail_2"; +SET SESSION debug_dbug="-d,exchange_partition_fail_1"; +SET SESSION debug_dbug="+d,exchange_partition_fail_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6387,8 +6388,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_2"; -SET SESSION debug="+d,exchange_partition_fail_3"; +SET SESSION debug_dbug="-d,exchange_partition_fail_2"; +SET SESSION debug_dbug="+d,exchange_partition_fail_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6437,7 +6438,7 @@ a b 3 Original from partition p0 4 Original from partition p0 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; -ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: 0 - n/a) +ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: 0 "Internal error/check (Not system error)") # State after failure t1.frm t1.par @@ -6479,8 +6480,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_3"; -SET SESSION debug="+d,exchange_partition_fail_4"; +SET SESSION debug_dbug="-d,exchange_partition_fail_3"; +SET SESSION debug_dbug="+d,exchange_partition_fail_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6571,8 +6572,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_4"; -SET SESSION debug="+d,exchange_partition_fail_5"; +SET SESSION debug_dbug="-d,exchange_partition_fail_4"; +SET SESSION debug_dbug="+d,exchange_partition_fail_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6621,7 +6622,7 @@ a b 3 Original from partition p0 4 Original from partition p0 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; -ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: 0 - n/a) +ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: 0 "Internal error/check (Not system error)") # State after failure t1.frm t1.par @@ -6663,8 +6664,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_5"; -SET SESSION debug="+d,exchange_partition_fail_6"; +SET SESSION debug_dbug="-d,exchange_partition_fail_5"; +SET SESSION debug_dbug="+d,exchange_partition_fail_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6755,8 +6756,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_6"; -SET SESSION debug="+d,exchange_partition_fail_7"; +SET SESSION debug_dbug="-d,exchange_partition_fail_6"; +SET SESSION debug_dbug="+d,exchange_partition_fail_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6805,7 +6806,7 @@ a b 3 Original from partition p0 4 Original from partition p0 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; -ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: 0 - n/a) +ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: 0 "Internal error/check (Not system error)") # State after failure t1.frm t1.par @@ -6847,8 +6848,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_7"; -SET SESSION debug="+d,exchange_partition_fail_8"; +SET SESSION debug_dbug="-d,exchange_partition_fail_7"; +SET SESSION debug_dbug="+d,exchange_partition_fail_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -6939,8 +6940,8 @@ a b 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_8"; -SET SESSION debug="+d,exchange_partition_fail_9"; +SET SESSION debug_dbug="-d,exchange_partition_fail_8"; +SET SESSION debug_dbug="+d,exchange_partition_fail_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); SHOW CREATE TABLE t2; @@ -7031,4 +7032,4 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug="-d,exchange_partition_fail_9"; +SET SESSION debug_dbug="-d,exchange_partition_fail_9"; diff --git a/storage/xtradb/dict/dict0boot.cc b/storage/xtradb/dict/dict0boot.cc index 0a21264e23d..138d3131e09 100644 --- a/storage/xtradb/dict/dict0boot.cc +++ b/storage/xtradb/dict/dict0boot.cc @@ -464,12 +464,22 @@ dict_boot(void) if (err == DB_SUCCESS) { if (srv_read_only_mode && !ibuf_is_empty()) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Change buffer must be empty when --innodb-read-only " - "is set!"); + if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Change buffer must be empty when --innodb-read-only " + "is set!" + "You can try to recover the database with innodb_force_recovery=5"); + + err = DB_ERROR; + } else { + ib_logf(IB_LOG_LEVEL_WARN, + "Change buffer not empty when --innodb-read-only " + "is set! but srv_force_recovery = %lu, ignoring.", + srv_force_recovery); + } + } - err = DB_ERROR; - } else { + if (err == DB_SUCCESS) { /* Load definitions of other indexes on system tables */ dict_load_sys_table(dict_sys->sys_tables); diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index b60a0e9ddaf..2da234ad094 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -739,11 +739,9 @@ fil_node_open_file( } } - if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) { + if (size_bytes >= (1024*1024)) { /* Truncate the size to whole extent size. */ - size_bytes = ut_2pow_round(size_bytes, - FSP_EXTENT_SIZE * - UNIV_PAGE_SIZE); + size_bytes = ut_2pow_round(size_bytes, (1024*1024)); } if (!fsp_flags_is_compressed(flags)) { @@ -5683,7 +5681,7 @@ fil_space_get_node( /* Found! */ break; } else { - *block_offset -= node->size; + (*block_offset) -= node->size; node = UT_LIST_GET_NEXT(chain, node); } } diff --git a/storage/xtradb/include/log0crypt.h b/storage/xtradb/include/log0crypt.h index 7e737853465..6b164e90d6e 100644 --- a/storage/xtradb/include/log0crypt.h +++ b/storage/xtradb/include/log0crypt.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. -Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -117,4 +117,12 @@ log_crypt_print_error( /*==================*/ log_crypt_err_t err_info); /*!< out: error info */ +/*********************************************************************//** +Print checkpoint no from log block and all encryption keys from +checkpoints if they are present. Used for problem analysis. */ +void +log_crypt_print_checkpoint_keys( +/*============================*/ + const byte* log_block); + #endif // log0crypt.h diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index 9228c25d8be..980ac337002 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -80,20 +80,37 @@ private: # elif defined(HAVE_FAKE_PAUSE_INSTRUCTION) # define UT_RELAX_CPU() __asm__ __volatile__ ("rep; nop") -# elif defined(HAVE_ATOMIC_BUILTINS) -# define UT_RELAX_CPU() do { \ - volatile lint volatile_var; \ - os_compare_and_swap_lint(&volatile_var, 0, 1); \ - } while (0) # elif defined(HAVE_WINDOWS_ATOMICS) /* In the Win32 API, the x86 PAUSE instruction is executed by calling the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() +# elif defined(__powerpc__) +#include <sys/platform/ppc.h> +# define UT_RELAX_CPU() do { \ + volatile lint volatile_var = __ppc_get_timebase(); \ + } while (0) # else # define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */ # endif +#if defined (__GNUC__) +# define UT_COMPILER_BARRIER() __asm__ __volatile__ ("":::"memory") +#elif defined (_MSC_VER) +# define UT_COMPILER_BARRIER() _ReadWriteBarrier() +#else +# define UT_COMPILER_BARRIER() +#endif + +# if defined(HAVE_HMT_PRIORITY_INSTRUCTION) +#include <sys/platform/ppc.h> +# define UT_LOW_PRIORITY_CPU() __ppc_set_ppr_low() +# define UT_RESUME_PRIORITY_CPU() __ppc_set_ppr_med() +# else +# define UT_LOW_PRIORITY_CPU() ((void)0) +# define UT_RESUME_PRIORITY_CPU() ((void)0) +# endif + /*********************************************************************//** Delays execution for at most max_wait_us microseconds or returns earlier if cond becomes true. @@ -334,7 +351,7 @@ Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ UNIV_INTERN -ulint +void ut_delay( /*=====*/ ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */ diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index c3044daafad..6d69f441019 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -6890,7 +6890,7 @@ lock_clust_rec_modify_check_and_lock( lock_rec_convert_impl_to_expl(block, rec, index, offsets); lock_mutex_enter(); - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); ut_ad(lock_table_has(trx, index->table, LOCK_IX)); @@ -6954,7 +6954,7 @@ lock_sec_rec_modify_check_and_lock( index record, and this would not have been possible if another active transaction had modified this secondary index record. */ - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); lock_mutex_enter(); ut_ad(lock_table_has(trx, index->table, LOCK_IX)); @@ -7063,7 +7063,7 @@ lock_sec_rec_read_check_and_lock( lock_rec_convert_impl_to_expl(block, rec, index, offsets); } - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); lock_mutex_enter(); ut_ad(mode != LOCK_X @@ -7146,7 +7146,7 @@ lock_clust_rec_read_check_and_lock( } lock_mutex_enter(); - trx_t* trx = thr_get_trx(thr); + trx_t* trx __attribute__((unused))= thr_get_trx(thr); ut_ad(mode != LOCK_X || lock_table_has(trx, index->table, LOCK_IX)); diff --git a/storage/xtradb/log/log0crypt.cc b/storage/xtradb/log/log0crypt.cc index 852148899e9..db2e84d7e45 100644 --- a/storage/xtradb/log/log0crypt.cc +++ b/storage/xtradb/log/log0crypt.cc @@ -127,12 +127,35 @@ static const crypt_info_t* get_crypt_info( /*===========*/ - const byte* log_block) { + const byte* log_block) +{ ib_uint64_t checkpoint_no = log_block_get_checkpoint_no(log_block); return get_crypt_info(checkpoint_no); } /*********************************************************************//** +Print checkpoint no from log block and all encryption keys from +checkpoints if they are present. Used for problem analysis. */ +void +log_crypt_print_checkpoint_keys( +/*============================*/ + const byte* log_block) +{ + ib_uint64_t checkpoint_no = log_block_get_checkpoint_no(log_block); + + if (crypt_info.size()) { + fprintf(stderr, "InnoDB: redo log checkpoint: %lu [ chk key ]: ", checkpoint_no); + for (size_t i = 0; i < crypt_info.size(); i++) { + struct crypt_info_t* it = &crypt_info[i]; + fprintf(stderr, "[ %lu %u ] ", + it->checkpoint_no, + it->key_version); + } + fprintf(stderr, "\n"); + } +} + +/*********************************************************************//** Call AES CTR to encrypt/decrypt log blocks. */ static Crypt_result @@ -278,12 +301,22 @@ Add crypt info to set if it is not already present @return true if successfull, false if not- */ static bool -add_crypt_info(crypt_info_t* info) +add_crypt_info( +/*===========*/ + crypt_info_t* info, /*!< in: crypt info */ + bool checkpoint_read)/*!< in: do we read checkpoint */ { + const crypt_info_t* found=NULL; /* so that no one is searching array while we modify it */ ut_ad(mutex_own(&(log_sys->mutex))); - if (get_crypt_info(info->checkpoint_no) != NULL) { + found = get_crypt_info(info->checkpoint_no); + + /* If one crypt info is found then we add a new one only if we + are reading checkpoint from the log. New checkpoints will always + use the first created crypt info. */ + if (found != NULL && + ( found->checkpoint_no == info->checkpoint_no || !checkpoint_read)) { // already present... return true; } @@ -356,7 +389,7 @@ log_crypt_set_ver_and_key( } - add_crypt_info(&info); + add_crypt_info(&info, false); } /******************************************************** @@ -514,7 +547,7 @@ log_crypt_read_checkpoint_buf( memcpy(info.crypt_msg, buf + 8, MY_AES_BLOCK_SIZE); memcpy(info.crypt_nonce, buf + 24, MY_AES_BLOCK_SIZE); - if (!add_crypt_info(&info)) { + if (!add_crypt_info(&info, true)) { return false; } buf += LOG_CRYPT_ENTRY_SIZE; diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index f98adbbca08..23ca8b1381f 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -2786,6 +2786,8 @@ recv_scan_log_recs( /* Garbage or an incompletely written log block */ + /* Print checkpoint encryption keys if present */ + log_crypt_print_checkpoint_keys(log_block); finished = TRUE; if (maybe_encrypted) { diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index b2b3e256211..2bb094e115d 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -1561,7 +1561,7 @@ os_file_set_nocache_if_needed(os_file_t file, const char* name, } if (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT - || (type == OS_LOG_FILE + || (type == OS_DATA_FILE && (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT || (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT_NO_FSYNC)))) { os_file_set_nocache(file, name, mode_str); diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc index 4eade1fe26e..acedb56879a 100644 --- a/storage/xtradb/ut/ut0ut.cc +++ b/storage/xtradb/ut/ut0ut.cc @@ -46,9 +46,6 @@ Created 5/11/1994 Heikki Tuuri # include <string> #endif /* UNIV_HOTBACKUP */ -/** A constant to prevent the compiler from optimizing ut_delay() away. */ -UNIV_INTERN ibool ut_always_false = FALSE; - #ifdef __WIN__ /*****************************************************************//** NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix @@ -398,25 +395,21 @@ Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ UNIV_INTERN -ulint +void ut_delay( /*=====*/ ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */ { - ulint i, j; + ulint i; - j = 0; + UT_LOW_PRIORITY_CPU(); for (i = 0; i < delay * 50; i++) { - j += i; UT_RELAX_CPU(); + UT_COMPILER_BARRIER(); } - if (ut_always_false) { - ut_always_false = (ibool) j; - } - - return(j); + UT_RESUME_PRIORITY_CPU(); } #endif /* !UNIV_HOTBACKUP */ diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index 28d2fd1515e..5b9793f388d 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -256,7 +256,7 @@ void dispcset(FILE *f,CHARSET_INFO *cs) fprintf(f," 255, /* max_sort_char */\n"); fprintf(f," ' ', /* pad_char */\n"); fprintf(f," 0, /* escape_with_backslash_is_dangerous */\n"); - + fprintf(f," 1, /* levels_for_order */\n"); fprintf(f," &my_charset_8bit_handler,\n"); if (cs->state & MY_CS_BINSORT) fprintf(f," &my_collation_8bit_bin_handler,\n"); @@ -270,9 +270,9 @@ static void fprint_copyright(FILE *file) { fprintf(file, -"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems Inc.\n" +"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.\n" " Copyright 2010-2011 Monty Program Ab\n" -" Copyright (c) 2003, 2011, Oracle and/or its affiliates\n" +" Copyright (c) 2000, 2011, Oracle and/or its affiliates.\n" "\n" " This program is free software; you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" @@ -333,7 +333,7 @@ main(int argc, char **argv __attribute__((unused))) fprintf(f, " ./conf_to_src ../sql/share/charsets/ > FILE\n"); fprintf(f, "*/\n\n"); fprint_copyright(f); - fprintf(f,"#include <my_global.h>\n"); + fprintf(f,"#include \"strings_def.h\"\n"); fprintf(f,"#include <m_ctype.h>\n\n"); diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 52494b7dfb3..469d3a5be6c 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -199,6 +199,7 @@ static const uchar sort_order_eucjpms[]= #define IS_MB2_KATA(x,y) (iseucjpms_ss2(x) && iskata(y)) #define IS_MB2_CHAR(x,y) (IS_MB2_KATA(x,y) || IS_MB2_JIS(x,y)) #define IS_MB3_CHAR(x,y,z) (iseucjpms_ss3(x) && IS_MB2_JIS(y,z)) +#define IS_MB_PREFIX2(x,y) (iseucjpms_ss3(x) && iseucjpms(y)) #define DEFINE_ASIAN_ROUTINES #include "ctype-mb.ic" diff --git a/strings/ctype-mb.ic b/strings/ctype-mb.ic index 6fc4d6e3db4..2df9c9d5e49 100644 --- a/strings/ctype-mb.ic +++ b/strings/ctype-mb.ic @@ -75,7 +75,13 @@ MY_FUNCTION_NAME(charlen)(CHARSET_INFO *cs __attribute__((unused)), #ifdef IS_MB3_CHAR if (b + 3 > e) + { +#ifdef IS_MB_PREFIX2 + if (!IS_MB_PREFIX2(b[0], b[1])) + return MY_CS_ILSEQ; +#endif return MY_CS_TOOSMALLN(3); + } if (IS_MB3_CHAR(b[0], b[1], b[2])) return 3; /* Three-byte character */ #endif diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 67e68901573..b24fdb3075f 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -198,6 +198,7 @@ static const uchar sort_order_ujis[]= #define IS_MB2_KATA(x,y) (isujis_ss2(x) && iskata(y)) #define IS_MB2_CHAR(x, y) (IS_MB2_KATA(x,y) || IS_MB2_JIS(x,y)) #define IS_MB3_CHAR(x, y, z) (isujis_ss3(x) && IS_MB2_JIS(y,z)) +#define IS_MB_PREFIX2(x,y) (isujis_ss3(x) && isujis(y)) #define DEFINE_ASIAN_ROUTINES #include "ctype-mb.ic" diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 7cc59f6aca5..7af1249f596 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16227,7 +16227,6 @@ static void test_change_user() const char *db= "mysqltest_user_test_database"; int rc; MYSQL* conn; - DBUG_ENTER("test_change_user"); myheader("test_change_user"); @@ -16240,6 +16239,9 @@ static void test_change_user() rc= mysql_query(mysql, buff); myquery(rc); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + sprintf(buff, "grant select on %s.* to %s@'%%' identified by '%s'", db, @@ -17481,7 +17483,6 @@ static void test_wl4166_2() mysql_stmt_close(stmt); rc= mysql_query(mysql, "drop table t1"); myquery(rc); - } diff --git a/unittest/sql/explain_filename-t.cc b/unittest/sql/explain_filename-t.cc index 69ce51c0446..a737ebec608 100644 --- a/unittest/sql/explain_filename-t.cc +++ b/unittest/sql/explain_filename-t.cc @@ -26,7 +26,8 @@ char to[BUFLEN]; char from[BUFLEN]; -const char *error_messages[1000]; +static const char *error_messages_txt[1000]; +static const char **error_messages[1]= { error_messages_txt }; int setup() { @@ -34,12 +35,12 @@ int setup() my_default_lc_messages = &my_locale_en_US; /* Populate the necessary error messages */ - error_messages[ER_DATABASE_NAME - ER_ERROR_FIRST] = "Database"; - error_messages[ER_TABLE_NAME - ER_ERROR_FIRST] = "Table"; - error_messages[ER_PARTITION_NAME - ER_ERROR_FIRST] = "Partition"; - error_messages[ER_SUBPARTITION_NAME - ER_ERROR_FIRST] = "Subpartition"; - error_messages[ER_TEMPORARY_NAME - ER_ERROR_FIRST] = "Temporary"; - error_messages[ER_RENAMED_NAME - ER_ERROR_FIRST] = "Renamed"; + error_messages[0][ER_DATABASE_NAME - ER_ERROR_FIRST] = "Database"; + error_messages[0][ER_TABLE_NAME - ER_ERROR_FIRST] = "Table"; + error_messages[0][ER_PARTITION_NAME - ER_ERROR_FIRST] = "Partition"; + error_messages[0][ER_SUBPARTITION_NAME - ER_ERROR_FIRST] = "Subpartition"; + error_messages[0][ER_TEMPORARY_NAME - ER_ERROR_FIRST] = "Temporary"; + error_messages[0][ER_RENAMED_NAME - ER_ERROR_FIRST] = "Renamed"; my_default_lc_messages->errmsgs->errmsgs = error_messages; diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index 3425a76427b..978a5c9c90d 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -542,17 +542,6 @@ Value="utf8" /> </Component> - <!--- Grant service account permission to the database folder (Windows 7 and later) --> - <Component Id="C.serviceaccount.permission" Guid="*" Directory='DATADIR' Transitive='yes'> - <Condition><![CDATA[SERVICENAME AND (VersionNT > 600)]]></Condition> - <RegistryValue Root='HKLM' - Key='SOFTWARE\Monty Program AB\@CPACK_WIX_PACKAGE_NAME@' - Name='servicepermission' Value='1' Type='string' KeyPath='yes'/> - <CreateFolder> - <util:PermissionEx User="NT SERVICE\[SERVICENAME]" GenericAll="yes" /> - </CreateFolder> - </Component> - <!-- Shortcuts in program menu (mysql client etc) --> <Component Id="c.shortcuts" Guid="*" Directory="ShortcutFolder"> <!-- shortcut to my.ini--> |