diff --git a/.gitattributes b/.gitattributes index 266acd5812a..852eec4d638 100644 --- a/.gitattributes +++ b/.gitattributes @@ -24,6 +24,7 @@ pcre/testdata/greppatN4 -text *.frm binary *.MYD binary *.MYI binary +*.class binary *.c diff=cpp *.h diff=cpp diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh index 1d7cf5561ad..39346270af9 100755 --- a/BUILD/autorun.sh +++ b/BUILD/autorun.sh @@ -19,8 +19,6 @@ # Create MySQL cmake configure wrapper -die() { echo "$@"; exit 1; } - # Use a configure script that will call CMake. path=`dirname $0` cp $path/cmake_configure.sh $path/../configure diff --git a/CMakeLists.txt b/CMakeLists.txt index ab981bc330f..cc696e36682 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,12 +187,16 @@ IF (WITH_ASAN) # gcc 4.8.1 and new versions of clang MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -O1 -Wno-error -fPIC" DEBUG RELWITHDEBINFO) + SET(HAVE_C_FSANITIZE ${HAVE_C__fsanitize_address__O1__Wno_error__fPIC}) + SET(HAVE_CXX_FSANITIZE ${HAVE_CXX__fsanitize_address__O1__Wno_error__fPIC}) IF(HAVE_C_FSANITIZE AND HAVE_CXX_FSANITIZE) SET(WITH_ASAN_OK 1) ELSE() # older versions of clang MY_CHECK_AND_SET_COMPILER_FLAG("-faddress-sanitizer -O1 -fPIC" DEBUG RELWITHDEBINFO) + SET(HAVE_C_FADDRESS ${HAVE_C__faddress_sanitizer__O1__fPIC}) + SET(HAVE_CXX_FADDRESS ${HAVE_CXX__faddress_sanitizer__O1__fPIC}) IF(HAVE_C_FADDRESS AND HAVE_CXX_FADDRESS) SET(WITH_ASAN_OK 1) ENDIF() diff --git a/CREDITS b/CREDITS index 1f071e4fb44..f0e6de7f08f 100644 --- a/CREDITS +++ b/CREDITS @@ -1,24 +1,26 @@ MariaDB is brought to you by the MariaDB Foundation, a non profit organization registered in the USA. -The current main members and sponsors of the MariaDB Foundation are: +The current main sponsors of the MariaDB Foundation are: -MariaDB Corporation http://www.mariadb.com (2013 - 2016) -Booking.com http://www.booking.com (2013 - 2016) -Parallels http://www.parallels.com/products/plesk (2013 - 2016) -Automattic http://automattic.com (2014 - 2016) -Verkkokauppa.com http://verkkokauppa.com (2015 - 2016) -Visma http://visma.com/ (2015 - 2016) -Webyog http://webyog.com (2015 - 2016) -Wikimedia Foundation http://wikimedia.org (2015 - 2016) -Acronis http://acronis.com (2016) +Booking.com http://www.booking.com (2013 - 2016) +Development Bank of Singapore http://dbs.com (2016) +MariaDB Corporation https://www.mariadb.com (2013 - 2016) +Visma http://visma.com (2015 - 2016) +Acronis http://acronis.com (2016) +Nexedi https://www.nexedi.com (2016) +Automattic https://automattic.com (2014 - 2016) +Verkkokauppa.com https://www.verkkokauppa.com (2015 - 2016) +Virtuozzo https://virtuozzo.com (2016) -For a full list of supporters and sponsors see +For a full list of sponsors, see https://mariadb.org/about/supporters/ +and for individual contributors, see +https://mariadb.org/donate/individual-sponsors/ -You can also do this by running SHOW CONTRIBUTORS. +You can also get the list of sponsors by running SHOW CONTRIBUTORS. -For all corporate memberships and sponsorships please contact the +For all corporate sponsorships please contact the MariaDB Foundation Board via foundation@mariadb.org. The MariaDB Foundation is responsible for the MariaDB source @@ -38,7 +40,7 @@ following services to the MariaDB community: To be able to do the above we need help from corporations and individuals! You can help support MariaDB by becoming a MariaDB developer or a -member or sponsor of the MariaDB Foundation. To donate or sponsor, +sponsor of the MariaDB Foundation. To donate or sponsor, go to https://mariadb.org/donate/ You can get a list of all the main authors of MariaDB / MySQL by running diff --git a/VERSION b/VERSION index 9032212ff31..d921401f495 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=1 -MYSQL_VERSION_PATCH=15 +MYSQL_VERSION_PATCH=18 diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 91e0b9fb405..fe9db6ea93d 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -235,8 +235,6 @@ my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - int error = 0; - switch(optid) { case 'c': opt_count_iterations= 1; @@ -284,8 +282,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '?': case 'I': /* Info */ - error++; - break; + usage(); + exit(0); case OPT_CHARSETS_DIR: #if MYSQL_VERSION_ID > 32300 charsets_dir = argument; @@ -296,11 +294,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt->name); break; } - if (error) - { - usage(); - exit(1); - } return 0; } diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index df5801ecbf6..3a6f5462ced 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -240,13 +240,13 @@ static int process_selected_tables(char *db, char **table_names, int tables); static int process_all_tables_in_db(char *database); static int process_one_db(char *database); static int use_db(char *database); -static int handle_request_for_tables(char *tables, size_t length, my_bool view); +static int handle_request_for_tables(char *, size_t, my_bool, my_bool); static int dbConnect(char *host, char *user,char *passwd); static void dbDisconnect(char *host); static void DBerror(MYSQL *mysql, const char *when); static void safe_exit(int error); static void print_result(); -static uint fixed_name_length(const char *name); +static size_t fixed_name_length(const char *name); static char *fix_table_name(char *dest, char *src); int what_to_do = 0; @@ -577,7 +577,7 @@ static int process_selected_tables(char *db, char **table_names, int tables) } *--end = 0; handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1, - opt_do_views != 0); + opt_do_views != 0, opt_all_in_1); my_free(table_names_comma_sep); } else @@ -588,16 +588,16 @@ static int process_selected_tables(char *db, char **table_names, int tables) view= is_view(table); if (view < 0) continue; - handle_request_for_tables(table, table_len, (view == 1)); + handle_request_for_tables(table, table_len, view == 1, opt_all_in_1); } DBUG_RETURN(0); } /* process_selected_tables */ -static uint fixed_name_length(const char *name) +static size_t fixed_name_length(const char *name) { const char *p; - uint extra_length= 2; /* count the first/last backticks */ + size_t extra_length= 2; /* count the first/last backticks */ DBUG_ENTER("fixed_name_length"); for (p= name; *p; p++) @@ -605,7 +605,7 @@ static uint fixed_name_length(const char *name) if (*p == '`') extra_length++; } - DBUG_RETURN((uint) ((p - name) + extra_length)); + DBUG_RETURN((size_t) ((p - name) + extra_length)); } @@ -616,13 +616,9 @@ static char *fix_table_name(char *dest, char *src) *dest++= '`'; for (; *src; src++) { - switch (*src) { - case '`': /* escape backtick character */ + if (*src == '`') *dest++= '`'; - /* fall through */ - default: - *dest++= *src; - } + *dest++= *src; } *dest++= '`'; @@ -664,7 +660,7 @@ static int process_all_tables_in_db(char *database) */ char *tables, *end; - uint tot_length = 0; + size_t tot_length = 0; char *views, *views_end; uint tot_views_length = 0; @@ -711,9 +707,9 @@ static int process_all_tables_in_db(char *database) *--end = 0; *--views_end = 0; if (tot_length) - handle_request_for_tables(tables + 1, tot_length - 1, FALSE); + handle_request_for_tables(tables + 1, tot_length - 1, FALSE, opt_all_in_1); if (tot_views_length) - handle_request_for_tables(views + 1, tot_views_length - 1, TRUE); + handle_request_for_tables(views + 1, tot_views_length - 1, TRUE, opt_all_in_1); my_free(tables); my_free(views); } @@ -739,7 +735,7 @@ static int process_all_tables_in_db(char *database) !strcmp(row[0], "slow_log"))) continue; /* Skip logging tables */ - handle_request_for_tables(row[0], fixed_name_length(row[0]), view); + handle_request_for_tables(row[0], fixed_name_length(row[0]), view, opt_all_in_1); } } mysql_free_result(res); @@ -769,7 +765,9 @@ static int fix_table_storage_name(const char *name) if (strncmp(name, "#mysql50#", 9)) DBUG_RETURN(1); - sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9); + my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE %`s TO %`s", + name, name + 9); + rc= run_query(qbuf, 1); if (verbose) printf("%-50s %s\n", name, rc ? "FAILED" : "OK"); @@ -784,7 +782,8 @@ static int fix_database_storage_name(const char *name) if (strncmp(name, "#mysql50#", 9)) DBUG_RETURN(1); - sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name); + my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE %`s UPGRADE DATA DIRECTORY " + "NAME", name); rc= run_query(qbuf, 1); if (verbose) printf("%-50s %s\n", name, rc ? "FAILED" : "OK"); @@ -797,16 +796,14 @@ static int rebuild_table(char *name) int rc= 0; DBUG_ENTER("rebuild_table"); - query= (char*)my_malloc(sizeof(char) * (12 + fixed_name_length(name) + 6 + 1), + query= (char*)my_malloc(sizeof(char) * (12 + strlen(name) + 6 + 1), MYF(MY_WME)); if (!query) DBUG_RETURN(1); - ptr= strmov(query, "ALTER TABLE "); - ptr= fix_table_name(ptr, name); - ptr= strxmov(ptr, " FORCE", NullS); + ptr= strxmov(query, "ALTER TABLE ", name, " FORCE", NullS); if (verbose >= 3) puts(query); - if (mysql_real_query(sock, query, (uint)(ptr - query))) + if (mysql_real_query(sock, query, (ulong)(ptr - query))) { fprintf(stderr, "Failed to %s\n", query); fprintf(stderr, "Error: %s\n", mysql_error(sock)); @@ -867,11 +864,12 @@ static int disable_binlog() return run_query("SET SQL_LOG_BIN=0", 0); } -static int handle_request_for_tables(char *tables, size_t length, my_bool view) +static int handle_request_for_tables(char *tables, size_t length, + my_bool view, my_bool dont_quote) { char *query, *end, options[100], message[100]; char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name; - uint query_length= 0; + size_t query_length= 0, query_size= sizeof(char)*(length+110); const char *op = 0; const char *tab_view; DBUG_ENTER("handle_request_for_tables"); @@ -924,10 +922,12 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view) DBUG_RETURN(fix_table_storage_name(tables)); } - if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME)))) + if (!(query =(char *) my_malloc(query_size, MYF(MY_WME)))) DBUG_RETURN(1); - if (opt_all_in_1) + if (dont_quote) { + DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size); + /* No backticks here as we added them before */ query_length= sprintf(query, "%s%s%s %s", op, tab_view, tables, options); @@ -943,7 +943,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view) (int) (ptr - org))); table_name= table_name_buff; ptr= strxmov(ptr, " ", options, NullS); - query_length= (uint) (ptr - query); + query_length= (size_t) (ptr - query); } if (verbose >= 3) puts(query); @@ -969,6 +969,13 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view) DBUG_RETURN(0); } +static void insert_table_name(DYNAMIC_ARRAY *arr, char *in, size_t dblen) +{ + char buf[NAME_LEN*2+2]; + in[dblen]= 0; + my_snprintf(buf, sizeof(buf), "%`s.%`s", in, in + dblen + 1); + insert_dynamic(arr, (uchar*) buf); +} static void print_result() { @@ -976,16 +983,13 @@ static void print_result() MYSQL_ROW row; char prev[(NAME_LEN+9)*3+2]; char prev_alter[MAX_ALTER_STR_SIZE]; - char *db_name; - uint length_of_db; + size_t length_of_db= strlen(sock->db); uint i; my_bool found_error=0, table_rebuild=0; DYNAMIC_ARRAY *array4repair= &tables4repair; DBUG_ENTER("print_result"); res = mysql_use_result(sock); - db_name= sock->db; - length_of_db= strlen(db_name); prev[0] = '\0'; prev_alter[0]= 0; @@ -1009,16 +1013,10 @@ static void print_result() if (prev_alter[0]) insert_dynamic(&alter_table_cmds, (uchar*) prev_alter); else - { - char *table_name= prev + (length_of_db+1); - insert_dynamic(&tables4rebuild, (uchar*) table_name); - } + insert_table_name(&tables4rebuild, prev, length_of_db); } else - { - char *table_name= prev + (length_of_db+1); - insert_dynamic(array4repair, table_name); - } + insert_table_name(array4repair, prev, length_of_db); } array4repair= &tables4repair; found_error=0; @@ -1063,16 +1061,10 @@ static void print_result() if (prev_alter[0]) insert_dynamic(&alter_table_cmds, prev_alter); else - { - char *table_name= prev + (length_of_db+1); - insert_dynamic(&tables4rebuild, table_name); - } + insert_table_name(&tables4rebuild, prev, length_of_db); } else - { - char *table_name= prev + (length_of_db+1); - insert_dynamic(array4repair, table_name); - } + insert_table_name(array4repair, prev, length_of_db); } mysql_free_result(res); DBUG_VOID_RETURN; @@ -1209,7 +1201,7 @@ int main(int argc, char **argv) process_databases(argv); if (opt_auto_repair) { - uint i; + size_t i; if (!opt_silent && (tables4repair.elements || tables4rebuild.elements)) puts("\nRepairing tables"); @@ -1217,7 +1209,7 @@ int main(int argc, char **argv) for (i = 0; i < tables4repair.elements ; i++) { char *name= (char*) dynamic_array_ptr(&tables4repair, i); - handle_request_for_tables(name, fixed_name_length(name), FALSE); + handle_request_for_tables(name, fixed_name_length(name), FALSE, TRUE); } for (i = 0; i < tables4rebuild.elements ; i++) rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i)); @@ -1228,7 +1220,7 @@ int main(int argc, char **argv) for (i = 0; i < views4repair.elements ; i++) { char *name= (char*) dynamic_array_ptr(&views4repair, i); - handle_request_for_tables(name, fixed_name_length(name), TRUE); + handle_request_for_tables(name, fixed_name_length(name), TRUE, TRUE); } } ret= MY_TEST(first_error); diff --git a/client/mysqldump.c b/client/mysqldump.c index ae59380544a..f2576861fc0 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -92,7 +92,7 @@ static void add_load_option(DYNAMIC_STRING *str, const char *option, const char *option_value); -static ulong find_set(TYPELIB *lib, const char *x, uint length, +static ulong find_set(TYPELIB *lib, const char *x, size_t length, char **err_pos, uint *err_len); static char *alloc_query_str(ulong size); @@ -896,7 +896,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_set_charset= 0; opt_compatible_mode_str= argument; opt_compatible_mode= find_set(&compatible_mode_typelib, - argument, (uint) strlen(argument), + argument, strlen(argument), &err_ptr, &err_len); if (err_len) { @@ -906,7 +906,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } #if !defined(DBUG_OFF) { - uint size_for_sql_mode= 0; + size_t size_for_sql_mode= 0; const char **ptr; for (ptr= compatible_mode_names; *ptr; ptr++) size_for_sql_mode+= strlen(*ptr); @@ -1177,8 +1177,8 @@ static int fetch_db_collation(const char *db_name, break; } - strncpy(db_cl_name, db_cl_row[0], db_cl_size); - db_cl_name[db_cl_size - 1]= 0; /* just in case. */ + strncpy(db_cl_name, db_cl_row[0], db_cl_size-1); + db_cl_name[db_cl_size - 1]= 0; } while (FALSE); @@ -1311,7 +1311,7 @@ get_gtid_pos(char *out_gtid_pos, int master) static char *my_case_str(const char *str, - uint str_len, + size_t str_len, const char *token, uint token_len) { @@ -1527,7 +1527,7 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name) */ static char *cover_definer_clause(const char *stmt_str, - uint stmt_length, + size_t stmt_length, const char *definer_version_str, uint definer_version_length, const char *stmt_version_str, @@ -1727,14 +1727,14 @@ static void dbDisconnect(char *host) } /* dbDisconnect */ -static void unescape(FILE *file,char *pos,uint length) +static void unescape(FILE *file,char *pos, size_t length) { char *tmp; DBUG_ENTER("unescape"); if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME)))) die(EX_MYSQLERR, "Couldn't allocate memory"); - mysql_real_escape_string(&mysql_connection, tmp, pos, length); + mysql_real_escape_string(&mysql_connection, tmp, pos, (ulong)length); fputc('\'', file); fputs(tmp, file); fputc('\'', file); @@ -1868,7 +1868,7 @@ static char *quote_for_equal(const char *name, char *buff) Quote '<' '>' '&' '\"' chars and print a string to the xml_file. */ -static void print_quoted_xml(FILE *xml_file, const char *str, ulong len, +static void print_quoted_xml(FILE *xml_file, const char *str, size_t len, my_bool is_attribute_name) { const char *end; @@ -2129,7 +2129,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name, squeezed to a single hyphen. */ -static void print_xml_comment(FILE *xml_file, ulong len, +static void print_xml_comment(FILE *xml_file, size_t len, const char *comment_string) { const char* end; @@ -2246,7 +2246,7 @@ static uint dump_events_for_db(char *db) DBUG_ENTER("dump_events_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); - mysql_real_escape_string(mysql, db_name_buff, db, strlen(db)); + mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db)); /* nice comments */ print_comment(sql_file, 0, @@ -2366,7 +2366,6 @@ static uint dump_events_for_db(char *db) (const char *) delimiter); my_free(query_str); - restore_time_zone(sql_file, delimiter); restore_sql_mode(sql_file, delimiter); @@ -2459,7 +2458,7 @@ static uint dump_routines_for_db(char *db) DBUG_ENTER("dump_routines_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); - mysql_real_escape_string(mysql, db_name_buff, db, strlen(db)); + mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db)); /* nice comments */ print_comment(sql_file, 0, @@ -2517,9 +2516,9 @@ static uint dump_routines_for_db(char *db) if the user has EXECUTE privilege he see routine names, but NOT the routine body of other routines that are not the creator of! */ - DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d", + DBUG_PRINT("info",("length of body for %s row[2] '%s' is %zu", routine_name, row[2] ? row[2] : "(null)", - row[2] ? (int) strlen(row[2]) : 0)); + row[2] ? strlen(row[2]) : 0)); if (row[2] == NULL) { print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n", @@ -4107,7 +4106,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables) int i; char name_buff[NAME_LEN*2+3]; - mysql_real_escape_string(mysql, name_buff, db, strlen(db)); + mysql_real_escape_string(mysql, name_buff, db, (ulong)strlen(db)); init_dynamic_string_checked(&dynamic_where, " AND TABLESPACE_NAME IN (" "SELECT DISTINCT TABLESPACE_NAME FROM" @@ -4120,7 +4119,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables) for (i=0 ; imax_length) length=field->max_length; @@ -505,7 +506,8 @@ static int list_tables(MYSQL *mysql,const char *db,const char *table) { const char *header; - uint head_length, counter = 0; + size_t head_length; + uint counter = 0; char query[NAME_LEN + 100], rows[NAME_LEN], fields[16]; MYSQL_FIELD *field; MYSQL_RES *result; @@ -542,7 +544,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table) putchar('\n'); header="Tables"; - head_length=(uint) strlen(header); + head_length= strlen(header); field=mysql_fetch_field(result); if (head_length < field->max_length) head_length=field->max_length; @@ -660,7 +662,7 @@ list_table_status(MYSQL *mysql,const char *db,const char *wild) len= sizeof(query); len-= my_snprintf(query, len, "show table status from `%s`", db); if (wild && wild[0] && len) - strxnmov(query + strlen(query), len, " like '", wild, "'", NullS); + strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS); if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql))) { fprintf(stderr,"%s: Cannot get status for db: %s, table: %s: %s\n", @@ -693,7 +695,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table, const char *wild) { char query[NAME_LEN + 100]; - int len; + size_t len; MYSQL_RES *result; MYSQL_ROW row; ulong UNINIT_VAR(rows); @@ -723,7 +725,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table, len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`", table); if (wild && wild[0] && len) - strxnmov(query + strlen(query), len, " like '", wild, "'", NullS); + strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS); if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql))) { fprintf(stderr,"%s: Cannot list columns in db: %s, table: %s: %s\n", @@ -771,10 +773,10 @@ list_fields(MYSQL *mysql,const char *db,const char *table, *****************************************************************************/ static void -print_header(const char *header,uint head_length,...) +print_header(const char *header,size_t head_length,...) { va_list args; - uint length,i,str_length,pre_space; + size_t length,i,str_length,pre_space; const char *field; va_start(args,head_length); @@ -797,10 +799,10 @@ print_header(const char *header,uint head_length,...) putchar('|'); for (;;) { - str_length=(uint) strlen(field); + str_length= strlen(field); if (str_length > length) str_length=length+1; - pre_space=(uint) (((int) length-(int) str_length)/2)+1; + pre_space= ((length- str_length)/2)+1; for (i=0 ; i < pre_space ; i++) putchar(' '); for (i = 0 ; i < str_length ; i++) @@ -834,11 +836,11 @@ print_header(const char *header,uint head_length,...) static void -print_row(const char *header,uint head_length,...) +print_row(const char *header,size_t head_length,...) { va_list args; const char *field; - uint i,length,field_length; + size_t i,length,field_length; va_start(args,head_length); field=header; length=head_length; @@ -847,7 +849,7 @@ print_row(const char *header,uint head_length,...) putchar('|'); putchar(' '); fputs(field,stdout); - field_length=(uint) strlen(field); + field_length= strlen(field); for (i=field_length ; i <= length ; i++) putchar(' '); if (!(field=va_arg(args,char *))) @@ -861,10 +863,10 @@ print_row(const char *header,uint head_length,...) static void -print_trailer(uint head_length,...) +print_trailer(size_t head_length,...) { va_list args; - uint length,i; + size_t length,i; va_start(args,head_length); length=head_length; @@ -907,7 +909,7 @@ static void print_res_top(MYSQL_RES *result) mysql_field_seek(result,0); while((field = mysql_fetch_field(result))) { - if ((length=(uint) strlen(field->name)) > field->max_length) + if ((length= strlen(field->name)) > field->max_length) field->max_length=length; else length=field->max_length; diff --git a/client/mysqltest.cc b/client/mysqltest.cc index bdd240e57e9..c388fd79dd7 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -121,7 +121,7 @@ static my_bool tty_password= 0; static my_bool opt_mark_progress= 0; static my_bool ps_protocol= 0, ps_protocol_enabled= 0; static my_bool sp_protocol= 0, sp_protocol_enabled= 0; -static my_bool view_protocol= 0, view_protocol_enabled= 0, wait_longer= 0; +static my_bool view_protocol= 0, view_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool parsing_disabled= 0; static my_bool display_result_vertically= FALSE, display_result_lower= FALSE, @@ -181,6 +181,7 @@ static uint my_end_arg= 0; static uint opt_tail_lines= 0; static uint opt_connect_timeout= 0; +static uint opt_wait_for_pos_timeout= 0; static char delimiter[MAX_DELIMITER_LENGTH]= ";"; static uint delimiter_length= 1; @@ -4657,7 +4658,7 @@ void do_sync_with_master2(struct st_command *command, long offset, MYSQL_ROW row; MYSQL *mysql= cur_con->mysql; char query_buf[FN_REFLEN+128]; - int timeout= wait_longer ? 1500 : 300; /* seconds */ + int timeout= opt_wait_for_pos_timeout; if (!master_pos.file[0]) die("Calling 'sync_with_master' without calling 'save_master_pos'"); @@ -5012,7 +5013,7 @@ static int my_kill(int pid, int sig) void do_shutdown_server(struct st_command *command) { - long timeout= wait_longer ? 60*5 : 60; + long timeout= opt_wait_for_pos_timeout ? opt_wait_for_pos_timeout / 5 : 300; int pid; DYNAMIC_STRING ds_pidfile_name; MYSQL* mysql = cur_con->mysql; @@ -6953,9 +6954,10 @@ static struct my_option my_long_options[] = "Number of seconds before connection timeout.", &opt_connect_timeout, &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG, 120, 0, 3600 * 12, 0, 0, 0}, - {"wait-longer-for-timeouts", 0, - "Wait longer for timeouts. Useful when running under valgrind", - &wait_longer, &wait_longer, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"wait_for_pos_timeout", 0, + "Number of seconds to wait for master_pos_wait", + &opt_wait_for_pos_timeout, &opt_wait_for_pos_timeout, 0, GET_UINT, + REQUIRED_ARG, 300, 0, 3600 * 12, 0, 0, 0}, {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake index 303d5d8d3c8..ef675959059 100644 --- a/cmake/check_compiler_flag.cmake +++ b/cmake/check_compiler_flag.cmake @@ -15,7 +15,7 @@ SET(fail_patterns ) MACRO (MY_CHECK_C_COMPILER_FLAG flag) - STRING(REGEX REPLACE "[-,= ]" "_" result "HAVE_C_${flag}") + STRING(REGEX REPLACE "[-,= +]" "_" result "HAVE_C_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${result} @@ -24,7 +24,7 @@ MACRO (MY_CHECK_C_COMPILER_FLAG flag) ENDMACRO() MACRO (MY_CHECK_CXX_COMPILER_FLAG flag) - STRING(REGEX REPLACE "[-,= ]" "_" result "HAVE_CXX_${flag}") + STRING(REGEX REPLACE "[-,= +]" "_" result "HAVE_CXX_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result} @@ -40,7 +40,7 @@ FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag) ENDIF() MY_CHECK_C_COMPILER_FLAG(${flag}) MY_CHECK_CXX_COMPILER_FLAG(${flag}) - STRING(REGEX REPLACE "[-,= ]" "_" result "${flag}") + STRING(REGEX REPLACE "[-,= +]" "_" result "${flag}") FOREACH(lang C CXX) IF (HAVE_${lang}_${result}) IF(ARGN) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 88e8da7cdbe..818264f9edf 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -214,7 +214,8 @@ MACRO(MYSQL_ADD_PLUGIN) ELSE() SET(ver "") ENDIF() - SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT} PARENT_SCOPE) + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT}) + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} PARENT_SCOPE) IF (NOT ARG_CLIENT) SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB${ver}" PARENT_SCOPE) diff --git a/cmake/systemd.cmake b/cmake/systemd.cmake index b0161cf9114..17f44f76634 100644 --- a/cmake/systemd.cmake +++ b/cmake/systemd.cmake @@ -55,9 +55,10 @@ MACRO(CHECK_SYSTEMD) IF(HAVE_SYSTEMD AND HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF) ADD_DEFINITIONS(-DHAVE_SYSTEMD) - SET(SYSTEMD_SCRIPTS mariadb-service-convert galera_new_cluster) + SET(SYSTEMD_SCRIPTS mariadb-service-convert galera_new_cluster galera_recovery) SET(SYSTEMD_DEB_FILES "usr/bin/mariadb-service-convert usr/bin/galera_new_cluster + usr/bin/galera_recovery ${INSTALL_SYSTEMD_UNITDIR}/mariadb.service ${INSTALL_SYSTEMD_UNITDIR}/mariadb@.service ${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d/use_galera_new_cluster.conf") diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index de7fb5eb946..067a9f128a2 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -26,7 +26,7 @@ ENDIF() OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) # Set the patch version -SET(WSREP_PATCH_VERSION "13") +SET(WSREP_PATCH_VERSION "16") # Obtain wsrep API version FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION diff --git a/configure.cmake b/configure.cmake index 5b8bc3688c7..896226de954 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1107,7 +1107,7 @@ CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec "time.h" STRUCT_TIMESPEC_HAS_TV CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_nsec "time.h" STRUCT_TIMESPEC_HAS_TV_NSEC) IF(NOT MSVC) - CHECK_C_SOURCE_RUNS( + CHECK_C_SOURCE_COMPILES( " #define _GNU_SOURCE #include diff --git a/debian/control b/debian/control index f331b3e519f..cb602510d95 100644 --- a/debian/control +++ b/debian/control @@ -404,10 +404,10 @@ Description: MariaDB database regression test suite (metapackage for the latest Package: mariadb-connect-engine-10.1 Architecture: any -Depends: libxml2, mariadb-server-10.1, unixODBC +Depends: libxml2, mariadb-server-10.1, unixodbc Build-Depends: libxml2-dev, mariadb-server-10.1, - unixODBC-dev, + unixodbc-dev, ${misc:Depends}, ${shlibs:Depends} Description: Connect storage engine for MariaDB diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index 7777da25aa1..5cdf1dedc27 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -50,10 +50,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), switch(optid) { case 'V': printf("%s version %s by Jani Tolonen\n", progname, VER); - exit(-1); + exit(0); case 'I': case '?': usage(); + exit(0); } return 0; } @@ -69,7 +70,10 @@ int main(int argc, char *argv[]) exit(-1); if (!argv[0] || !argv[1] || (pid= atoi(argv[0])) <= 0 || (t= atoi(argv[1])) <= 0) + { usage(); + exit(-1); + } for (; t > 0; t--) { if (kill((pid_t) pid, sig)) @@ -100,5 +104,4 @@ void usage(void) printf("integer arguments.\n\n"); printf("Options:\n"); my_print_help(my_long_options); - exit(-1); } diff --git a/extra/perror.c b/extra/perror.c index 11a703c8666..062a04003c2 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -222,7 +222,7 @@ static my_bool print_win_error_msg(DWORD error, my_bool verbose) will ignore calls to register already registered error numbers. */ -static const char **get_handler_error_messages() +static const char **get_handler_error_messages(void) { return handler_error_messages; } diff --git a/extra/yassl/src/log.cpp b/extra/yassl/src/log.cpp index 13c68295747..c4be306a7b8 100644 --- a/extra/yassl/src/log.cpp +++ b/extra/yassl/src/log.cpp @@ -1,6 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB - Use is subject to license terms + Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/m_ctype.h b/include/m_ctype.h index 497ba6de927..dcbfb604f03 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -131,6 +131,7 @@ typedef struct my_uca_level_info_st uchar *lengths; uint16 **weights; MY_CONTRACTIONS contractions; + uint levelno; } MY_UCA_WEIGHT_LEVEL; diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index fb2525e3a12..fad6e532de9 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -45,7 +45,7 @@ C_MODE_START #if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE) void my_init_stacktrace(); void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack); -void my_safe_print_str(const char* val, int max_len); +int my_safe_print_str(const char* val, int max_len); void my_write_core(int sig); #if BACKTRACE_DEMANGLE char *my_demangle(const char *mangled_name, int *status); diff --git a/include/my_tree.h b/include/my_tree.h index f8be55f84b2..02cab02b52e 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/myisam.h b/include/myisam.h index 88ce401fabc..f7a3ae8cc8a 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -331,7 +331,8 @@ typedef struct st_sort_info my_off_t filelength, dupp, buff_length; ha_rows max_records; uint current_key, total_keys; - uint got_error, threads_running; + volatile uint got_error; + uint threads_running; myf myf_rw; enum data_file_type new_data_file_type; } MI_SORT_INFO; diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 5c3a9210ce8..32d87b7391c 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -27,7 +27,7 @@ typedef struct st_net { char save_char; char net_skip_rest_factor; my_bool thread_specific_malloc; - my_bool compress; + unsigned char compress; my_bool unused3; void *thd; unsigned int last_errno; diff --git a/include/mysql_com.h b/include/mysql_com.h index a3790a44c1d..23be12bdc43 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -377,7 +377,7 @@ typedef struct st_net { char save_char; char net_skip_rest_factor; my_bool thread_specific_malloc; - my_bool compress; + unsigned char compress; my_bool unused3; /* Please remove with the next incompatible ABI change. */ /* Pointer to query object in query cache, do not equal NULL (0) for diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index d4df327930d..515105f49e8 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -122,8 +122,12 @@ ADD_DEPENDENCIES(sql_embedded GenError GenServerSource) # On Unix, it is libmysqld.a IF(WIN32) SET(MYSQLSERVER_OUTPUT_NAME mysqlserver) + SET(COMPONENT_MYSQLSERVER "Embedded") + SET(COMPONENT_LIBMYSQLD "Embedded") ELSE() SET(MYSQLSERVER_OUTPUT_NAME mysqld) + SET(COMPONENT_MYSQLSERVER "Development") + SET(COMPONENT_LIBMYSQLD "Server") ENDIF() @@ -148,9 +152,9 @@ FOREACH(LIB ${LIBS}) ENDFOREACH() MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS} - OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Development) + OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT ${COMPONENT_MYSQLSERVER}) -INSTALL(FILES embedded_priv.h DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development) +INSTALL(FILES embedded_priv.h DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT ${COMPONENT_MYSQLSERVER}) # Visual Studio users need debug static library IF(MSVC) @@ -177,7 +181,7 @@ ENDFOREACH() IF(NOT DISABLE_SHARED) MERGE_LIBRARIES(libmysqld SHARED mysqlserver EXPORTS ${EMBEDDED_API} - COMPONENT Server) + COMPONENT ${COMPONENT_LIBMYSQLD}) IF(UNIX) # Name the shared library, handle versioning (provides same api as client # library hence the same version) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index a313c624078..63424af27f6 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -333,6 +333,12 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) THD *thd; my_bool res; + if (stmt->param_count && !stmt->bind_param_done) + { + set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate, NULL); + DBUG_RETURN(1); + } + int4store(header, stmt->stmt_id); header[4]= (uchar) stmt->flags; thd= (THD*)stmt->mysql->thd; diff --git a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test index 18b6c0532f2..aa360c9c803 100644 --- a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test +++ b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test @@ -155,7 +155,7 @@ connection master; f6 ENUM('a', 'b', 'c') default 'a', f7 DECIMAL(17,9) default '1000.00', f8 MEDIUMBLOB, - f9 NUMERIC(6,4) default '2000.00', + f9 NUMERIC(6,2) default '2000.00', f10 VARCHAR(1024), f11 BINARY(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f12 SET('a', 'b', 'c') default 'b') @@ -178,7 +178,7 @@ connection master; f5 DOUBLE DEFAULT '2.00', f6 DECIMAL(17,9) default '1000.00', f7 MEDIUMBLOB, - f8 NUMERIC(6,4) default '2000.00', + f8 NUMERIC(6,2) default '2000.00', f9 VARCHAR(1024), f10 BINARY(20) not null default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f11 CHAR(255)) diff --git a/mysql-test/include/ctype_uca_w2.inc b/mysql-test/include/ctype_uca_w2.inc index 86ed7ddd134..b59f73b8a63 100644 --- a/mysql-test/include/ctype_uca_w2.inc +++ b/mysql-test/include/ctype_uca_w2.inc @@ -22,6 +22,13 @@ SELECT HEX(a), HEX(WEIGHT_STRING(a AS CHAR(4) LEVEL 2)) FROM t1; SELECT HEX(a), HEX(WEIGHT_STRING(a AS CHAR(4) LEVEL 3)) FROM t1; DROP TABLE t1; +CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (_ucs2 0x3400); +INSERT INTO t1 VALUES (_ucs2 0xF001); +SELECT HEX(CONVERT(a USING ucs2)) AS ucs2, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1; +DROP TABLE t1; + CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; SHOW CREATE TABLE t1; INSERT INTO t1 VALUES ('A'),('À'),('Á'),('Â'),('Ã'),('Ä'),('Å'); diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 17b2fd5b2bc..b5b16461781 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -45,6 +45,8 @@ loose-feedback-debug-startup-interval=20 loose-feedback-debug-first-interval=60 loose-feedback-debug-interval=60 +loose-pam-debug + loose-innodb_data_file_path= ibdata1:12M:autoextend loose-innodb_buffer_pool_size= 8M loose-innodb_lru_scan_depth= 100 diff --git a/mysql-test/include/report-features.test b/mysql-test/include/report-features.test deleted file mode 100644 index 75879f67165..00000000000 --- a/mysql-test/include/report-features.test +++ /dev/null @@ -1,12 +0,0 @@ -# -# show server variables -# - ---disable_query_log ---echo ===== ENGINES ===== -show engines; ---echo ===== VARIABLES ===== -show variables; ---echo ===== STOP ===== ---enable_query_log -exit; diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc index 96240e36db7..6f64ef45440 100644 --- a/mysql-test/include/wait_until_connected_again.inc +++ b/mysql-test/include/wait_until_connected_again.inc @@ -14,7 +14,7 @@ while ($mysql_errno) # Strangely enough, the server might return "Too many connections" # while being shutdown, thus 1040 is an "allowed" error # See BUG#36228 - --error 0,1040,1053,2002,2003,2005,2006,2013 + --error 0,1040,1053,2002,2003,2005,2006,2013,1927 show status; dec $counter; diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc index 71361682442..658bf0be739 100644 --- a/mysql-test/include/wait_until_disconnected.inc +++ b/mysql-test/include/wait_until_disconnected.inc @@ -12,7 +12,7 @@ while (!$mysql_errno) # Strangely enough, the server might return "Too many connections" # while being shutdown, thus 1040 is an "allowed" error. # See BUG#36228. - --error 0,1040,1053,2002,2003,2005,2006,2013 + --error 0,1040,1053,2002,2003,2005,2006,2013,1927 show status; dec $counter; diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index a9b4f9a4ecc..f3ee772cca3 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -338,7 +338,7 @@ sub dump_core { my ($self)= @_; return if IS_WINDOWS; my $pid= $self->{SAFE_PID}; - die "Can't cet core from not started process" unless defined $pid; + die "Can't get core from not started process" unless defined $pid; _verbose("Sending ABRT to $self"); kill ("ABRT", $pid); return 1; diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 8c2b67c2fda..2be903abf42 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -311,6 +311,7 @@ sub combinations_from_file($$) } our %disabled; +our %disabled_wildcards; sub parse_disabled { my ($filename, $suitename) = @_; @@ -319,10 +320,18 @@ sub parse_disabled { chomp; next if /^\s*#/ or /^\s*$/; mtr_error("Syntax error in $filename line $.") - unless /^\s*(?:([-0-9A-Za-z_\/]+)\.)?([-0-9A-Za-z_#]+)\s*:\s*(.*?)\s*$/; - mtr_error("Wrong suite name in $filename line $.") + unless /^\s*(?:([-0-9A-Za-z_\/]+)\.)?([-0-9A-Za-z_#\*]+)\s*:\s*(.*?)\s*$/; + mtr_error("Wrong suite name in $filename line $.: suitename = $suitename but the file says $1") if defined $1 and defined $suitename and $1 ne $suitename; - $disabled{($1 || $suitename || '') . ".$2"} = $3; + my ($sname, $casename, $text)= (($1 || $suitename || ''), $2, $3); + + if ($casename =~ /\*/) { + # Wildcard + $disabled_wildcards{$sname . ".$casename"}= $text; + } + else { + $disabled{$sname . ".$casename"}= $text; + } } close DISABLED; } @@ -720,6 +729,14 @@ sub collect_one_test_case { # Check for disabled tests # ---------------------------------------------------------------------- my $disable = $disabled{".$tname"} || $disabled{$name}; + if (not $disable) { + foreach my $w (keys %disabled_wildcards) { + if ($name =~ /^$w/) { + $disable= $disabled_wildcards{$w}; + last; + } + } + } if (not defined $disable and $suite->{parent}) { $disable = $disabled{$suite->{parent}->{name} . ".$tname"}; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index aa46d70cfc5..c6a71b91f69 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -284,7 +284,6 @@ my $opt_port_base= $ENV{'MTR_PORT_BASE'} || "auto"; my $build_thread= 0; my $opt_record; -my $opt_report_features; our $opt_resfile= $ENV{'MTR_RESULT_FILE'} || 0; @@ -317,7 +316,6 @@ our $opt_user = "root"; our $opt_valgrind= 0; my $opt_valgrind_mysqld= 0; my $opt_valgrind_mysqltest= 0; -my @default_valgrind_args= ("--show-reachable=yes"); my @valgrind_args; my $opt_strace= 0; my $opt_strace_client; @@ -352,6 +350,7 @@ my $source_dist= -d "../sql"; my $opt_max_save_core= env_or_val(MTR_MAX_SAVE_CORE => 5); my $opt_max_save_datadir= env_or_val(MTR_MAX_SAVE_DATADIR => 20); my $opt_max_test_fail= env_or_val(MTR_MAX_TEST_FAIL => 10); +my $opt_core_on_failure= 0; my $opt_parallel= $ENV{MTR_PARALLEL} || 1; my $opt_port_group_size = $ENV{MTR_PORT_GROUP_SIZE} || 20; @@ -429,21 +428,6 @@ sub main { exit 0; } - if ( $opt_report_features ) { - # Put "report features" as the first test to run - my $tinfo = My::Test->new - ( - name => 'report_features', - # No result_file => Prints result - path => 'include/report-features.test', - template_path => "include/default_my.cnf", - master_opt => [], - slave_opt => [], - suite => 'main', - ); - unshift(@$tests, $tinfo); - } - ####################################################################### my $num_tests= @$tests; if ( $opt_parallel eq "auto" ) { @@ -1157,6 +1141,7 @@ sub command_line_setup { 'max-save-core=i' => \$opt_max_save_core, 'max-save-datadir=i' => \$opt_max_save_datadir, 'max-test-fail=i' => \$opt_max_test_fail, + 'core-on-failure' => \$opt_core_on_failure, # Coverage, profiling etc 'gcov' => \$opt_gcov, @@ -1190,7 +1175,6 @@ sub command_line_setup { 'client-libdir=s' => \$path_client_libdir, # Misc - 'report-features' => \$opt_report_features, 'comment=s' => \$opt_comment, 'fast' => \$opt_fast, 'force-restart' => \$opt_force_restart, @@ -1722,17 +1706,27 @@ sub command_line_setup { # Set special valgrind options unless options passed on command line push(@valgrind_args, "--trace-children=yes") unless @valgrind_args; + unshift(@valgrind_args, "--tool=callgrind"); + } + + # default to --tool=memcheck + if ($opt_valgrind && ! grep(/^--tool=/i, @valgrind_args)) + { + # Set valgrind_option unless already defined + push(@valgrind_args, ("--show-reachable=yes", "--leak-check=yes", + "--num-callers=16")) + unless @valgrind_args; + unshift(@valgrind_args, "--tool=memcheck"); } if ( $opt_valgrind ) { - # Set valgrind_options to default unless already defined - push(@valgrind_args, @default_valgrind_args) - unless @valgrind_args; - # Make valgrind run in quiet mode so it only print errors push(@valgrind_args, "--quiet" ); + push(@valgrind_args, "--suppressions=${glob_mysql_test_dir}/valgrind.supp") + if -f "$glob_mysql_test_dir/valgrind.supp"; + mtr_report("Running valgrind with options \"", join(" ", @valgrind_args), "\""); } @@ -1783,9 +1777,12 @@ sub set_build_thread_ports($) { if ( lc($opt_build_thread) eq 'auto' ) { my $found_free = 0; $build_thread = 300; # Start attempts from here + my $build_thread_upper = $build_thread + ($opt_parallel > 1500 + ? 3000 + : 2 * $opt_parallel) + 300; while (! $found_free) { - $build_thread= mtr_get_unique_id($build_thread, 349); + $build_thread= mtr_get_unique_id($build_thread, $build_thread_upper); if ( !defined $build_thread ) { mtr_error("Could not get a unique build thread id"); } @@ -3761,6 +3758,7 @@ sub run_testcase ($$) { my $print_freq=20; mtr_verbose("Running test:", $tinfo->{name}); + $ENV{'MTR_TEST_NAME'} = $tinfo->{name}; resfile_report_test($tinfo) if $opt_resfile; # Allow only alpanumerics pluss _ - + . in combination names, @@ -4148,7 +4146,7 @@ sub run_testcase ($$) { } # Try to dump core for mysqltest and all servers - foreach my $proc ($test, started(all_servers())) + foreach my $proc ($test, started(all_servers())) { mtr_print("Trying to dump core for $proc"); if ($proc->dump_core()) @@ -4833,7 +4831,9 @@ sub after_failure ($) { sub report_failure_and_restart ($) { my $tinfo= shift; - if ($opt_valgrind_mysqld && ($tinfo->{'warnings'} || $tinfo->{'timeout'})) { + if ($opt_valgrind_mysqld && ($tinfo->{'warnings'} || $tinfo->{'timeout'}) && + $opt_core_on_failure == 0) + { # In these cases we may want valgrind report from normal termination $tinfo->{'dont_kill_server'}= 1; } @@ -5481,6 +5481,13 @@ sub start_mysqltest ($) { mtr_add_arg($args, "--sleep=%d", $opt_sleep); } + if ( $opt_valgrind ) + { + # We are running server under valgrind, which causes some replication + # test to be much slower, notable rpl_mdev6020. Increase timeout. + mtr_add_arg($args, "--wait-for-pos-timeout=1500"); + } + if ( $opt_ssl ) { # Turn on SSL for _all_ test cases if option --ssl was used @@ -5491,12 +5498,6 @@ sub start_mysqltest ($) { mtr_add_arg($args, "--max-connections=%d", $opt_max_connections); } - if ( $opt_valgrind ) - { - # Longer timeouts when running with valgrind - mtr_add_arg($args, "--wait-longer-for-timeouts"); - } - if ( $opt_embedded_server ) { @@ -5816,29 +5817,15 @@ sub valgrind_arguments { my $args= shift; my $exe= shift; - if ( $opt_callgrind) + # Ensure the jemalloc works with mysqld + if ($$exe =~ /mysqld/) { - mtr_add_arg($args, "--tool=callgrind"); - mtr_add_arg($args, "--base=$opt_vardir/log"); - } - else - { - mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option - mtr_add_arg($args, "--leak-check=yes"); - mtr_add_arg($args, "--num-callers=16"); - mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir) - if -f "$glob_mysql_test_dir/valgrind.supp"; - - # Ensure the jemalloc works with mysqld - if ($$exe =~ /mysqld/) - { - my %somalloc=( - 'system jemalloc' => 'libjemalloc*', - 'bundled jemalloc' => 'NONE' - ); - my ($syn) = $somalloc{$mysqld_variables{'version-malloc-library'}}; - mtr_add_arg($args, '--soname-synonyms=somalloc=%s', $syn) if $syn; - } + my %somalloc=( + 'system jemalloc' => 'libjemalloc*', + 'bundled jemalloc' => 'NONE' + ); + my ($syn) = $somalloc{$mysqld_variables{'version-malloc-library'}}; + mtr_add_arg($args, '--soname-synonyms=somalloc=%s', $syn) if $syn; } # Add valgrind options, can be overriden by user @@ -6130,6 +6117,7 @@ Options for debugging the product the current test run. Defaults to $opt_max_test_fail, set to 0 for no limit. Set it's default with MTR_MAX_TEST_FAIL + core-in-failure Generate a core even if run server is run with valgrind Options for valgrind @@ -6213,7 +6201,6 @@ Misc options gprof Collect profiling information using gprof. experimental= Refer to list of tests considered experimental; failures will be marked exp-fail instead of fail. - report-features First run a "test" that reports mysql features timestamp Print timestamp before each test report line timediff With --timestamp, also print time passed since *previous* test started diff --git a/mysql-test/r/contributors.result b/mysql-test/r/contributors.result index 1820c0a5f06..918ceaa496f 100644 --- a/mysql-test/r/contributors.result +++ b/mysql-test/r/contributors.result @@ -1,13 +1,14 @@ SHOW CONTRIBUTORS; Name Location Comment -Booking.com http://www.booking.com Founding member of the MariaDB Foundation -MariaDB Corporation https://mariadb.com Founding member of the MariaDB Foundation -Auttomattic http://automattic.com Member of the MariaDB Foundation -Visma http://visma.com Member of the MariaDB Foundation -Nexedi http://www.nexedi.com Member of the MariaDB Foundation -Acronis http://www.acronis.com Member of the MariaDB Foundation -Verkkokauppa.com Finland Sponsor of the MariaDB Foundation -Webyog Bangalore Sponsor of the MariaDB Foundation +Booking.com http://www.booking.com Founding member, Platinum Sponsor of the MariaDB Foundation +MariaDB Corporation https://mariadb.com Founding member, Gold Sponsor of the MariaDB Foundation +Visma http://visma.com Gold Sponsor of the MariaDB Foundation +DBS http://dbs.com Gold Sponsor of the MariaDB Foundation +Nexedi https://www.nexedi.com Silver Sponsor of the MariaDB Foundation +Acronis http://www.acronis.com Silver Sponsor of the MariaDB Foundation +Auttomattic https://automattic.com Bronze Sponsor of the MariaDB Foundation +Verkkokauppa.com https://virtuozzo.com Bronze Sponsor of the MariaDB Foundation +Virtuozzo https://virtuozzo.com/ Bronze Sponsor of the MariaDB Foundation Google USA Sponsoring encryption, parallel replication and GTID Facebook USA Sponsoring non-blocking API, LIMIT ROWS EXAMINED etc Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index cad46f34c75..3987ff7c16f 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -939,6 +939,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 7 diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result index ed25fbadf45..7df3704cfa1 100644 --- a/mysql-test/r/create_or_replace.result +++ b/mysql-test/r/create_or_replace.result @@ -262,11 +262,11 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2 +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table test.t1; ERROR 42000: A table must have at least 1 column show tables; @@ -274,10 +274,10 @@ Tables_in_test t2 select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2 +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 create or replace table mysqltest2.t2; ERROR 42000: A table must have at least 1 column select * from information_schema.metadata_lock_info; @@ -289,11 +289,11 @@ create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2 +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' show tables; @@ -301,10 +301,10 @@ Tables_in_test t2 select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2 +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' select * from information_schema.metadata_lock_info; @@ -398,31 +398,31 @@ create table t1 (a int); lock table t1 write, t2 read; select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1 -# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +# MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 (i int); select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1 -# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +# MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 like t2; select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1 -# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +# MDL_SHARED_READ NULL Table metadata lock test t2 create or replace table t1 select 1 as f1; select * from information_schema.metadata_lock_info; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock -# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1 -# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2 -# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test +# MDL_INTENTION_EXCLUSIVE NULL Global read lock +# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test +# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +# MDL_SHARED_READ NULL Table metadata lock test t2 drop table t1; unlock tables; # diff --git a/mysql-test/r/ctype_ldml.result b/mysql-test/r/ctype_ldml.result index acb92a8363b..d333c03143b 100644 --- a/mysql-test/r/ctype_ldml.result +++ b/mysql-test/r/ctype_ldml.result @@ -460,6 +460,7 @@ utf8mb4_test_400_ci utf8mb4 328 8 latin1_test2 latin1 332 1 utf8_bengali_standard_ci utf8 336 8 utf8_bengali_traditional_ci utf8 337 8 +utf8_implicit_weights_ci utf8 338 8 utf8_phone_ci utf8 352 8 utf8_test_ci utf8 353 8 utf8_5624_1 utf8 354 8 @@ -1156,3 +1157,25 @@ Warning 1273 Expansion too long: 'a\u002Daaaaaa10' # # Search for occurrences of [ERROR] Syntax error at '[strength tertiary]' Occurances : 2 +# +# MDEV-8686 A user defined collation utf8_confusables doesn't work +# +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_implicit_weights_ci); +INSERT INTO t1 VALUES ('a'),('b'),('c'); +INSERT INTO t1 VALUES (_ucs2 0x1500),(_ucs2 0x1501); +INSERT INTO t1 VALUES (_ucs2 0x3400),(_ucs2 0x3560),(_ucs2 0x3561),(_ucs2 0x3600); +INSERT INTO t1 VALUES (_ucs2 0x3700),(_ucs2 0x3701); +SELECT HEX(CONVERT(a USING ucs2)) AS ch, HEX(WEIGHT_STRING(a)) AS w, HEX(WEIGHT_STRING(a COLLATE utf8_unicode_ci)) AS ducet FROM t1 ORDER BY a,ch; +ch w ducet +0061 0E33 0E33 +3561 0E33 FB80B561 +0063 0E60 0E60 +1500 0E60 1BAD +0062 FB80B400 0E4A +3400 FB80B400 FB80B400 +3560 FB80B560 FB80B560 +1501 FB80B600 1BAE +3600 FB80B600 FB80B600 +3700 FB80B700 FB80B700 +3701 FB80B700 FB80B701 +DROP TABLE t1; diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index c84da0d7496..2555749fa8c 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -277,9 +277,40 @@ CREATE TABLE t1 ( a VARCHAR(1) ); INSERT INTO t1 VALUES ('m'),('n'); CREATE VIEW v1 AS SELECT 'w' ; SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v1 ); -ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<=' +a +m +n drop view v1; drop table t1; SET character_set_connection = default; SET optimizer_switch= default; #End of 5.3 tests +# +# Start of 5.5 tests +# +# +# MDEV-10181 Illegal mix of collation for a field and an ASCII string as a view field +# +SET NAMES utf8; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES ('A'),('a'),('B'),('b'); +CREATE VIEW v1 AS SELECT 'a'; +SELECT * FROM v1,t1 where t1.a=v1.a; +a a +a A +a a +DROP VIEW v1; +DROP TABLE t1; +SET NAMES utf8; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES ('a'),('b'),('c'); +CREATE VIEW v1 AS SELECT 'a' AS a UNION SELECT 'b'; +SELECT * FROM v1,t1 WHERE t1.a=v1.a; +a a +a a +b b +DROP VIEW v1; +DROP TABLE t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 1609e7fc320..d9cba536814 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -14033,6 +14033,19 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) CHARACTER SET utf8 COLLATE utf8_thai_520_w2 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_ucs2 0x3400); +INSERT INTO t1 VALUES (_ucs2 0xF001); +SELECT HEX(CONVERT(a USING ucs2)) AS ucs2, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1; +ucs2 HEX(a) HEX(WEIGHT_STRING(a)) +3400 E39080 FB80B4000020 +F001 EF8081 FBC1F0010020 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf8 COLLATE utf8_thai_520_w2 NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('A'),('À'),('Á'),('Â'),('Ã'),('Ä'),('Å'); SELECT a, HEX(WEIGHT_STRING(a LEVEL 2)) FROM t1 ORDER BY a; a HEX(WEIGHT_STRING(a LEVEL 2)) @@ -14714,6 +14727,19 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) CHARACTER SET ucs2 COLLATE ucs2_thai_520_w2 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_ucs2 0x3400); +INSERT INTO t1 VALUES (_ucs2 0xF001); +SELECT HEX(CONVERT(a USING ucs2)) AS ucs2, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1; +ucs2 HEX(a) HEX(WEIGHT_STRING(a)) +3400 3400 FB80B4000020 +F001 F001 FBC1F0010020 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET ucs2 COLLATE ucs2_thai_520_w2 NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('A'),('À'),('Á'),('Â'),('Ã'),('Ä'),('Å'); SELECT a, HEX(WEIGHT_STRING(a LEVEL 2)) FROM t1 ORDER BY a; a HEX(WEIGHT_STRING(a LEVEL 2)) diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result index 1ee06062fb6..1e4c77ea83d 100644 --- a/mysql-test/r/ctype_utf16_uca.result +++ b/mysql-test/r/ctype_utf16_uca.result @@ -6663,6 +6663,19 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) CHARACTER SET utf16 COLLATE utf16_thai_520_w2 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_ucs2 0x3400); +INSERT INTO t1 VALUES (_ucs2 0xF001); +SELECT HEX(CONVERT(a USING ucs2)) AS ucs2, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1; +ucs2 HEX(a) HEX(WEIGHT_STRING(a)) +3400 3400 FB80B4000020 +F001 F001 FBC1F0010020 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf16 COLLATE utf16_thai_520_w2 NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('A'),('À'),('Á'),('Â'),('Ã'),('Ä'),('Å'); SELECT a, HEX(WEIGHT_STRING(a LEVEL 2)) FROM t1 ORDER BY a; a HEX(WEIGHT_STRING(a LEVEL 2)) diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result index dab23a80a43..234a01bb108 100644 --- a/mysql-test/r/ctype_utf32_uca.result +++ b/mysql-test/r/ctype_utf32_uca.result @@ -6683,6 +6683,19 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) CHARACTER SET utf32 COLLATE utf32_thai_520_w2 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_ucs2 0x3400); +INSERT INTO t1 VALUES (_ucs2 0xF001); +SELECT HEX(CONVERT(a USING ucs2)) AS ucs2, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1; +ucs2 HEX(a) HEX(WEIGHT_STRING(a)) +3400 00003400 FB80B4000020 +F001 0000F001 FBC1F0010020 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf32 COLLATE utf32_thai_520_w2 NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('A'),('À'),('Á'),('Â'),('Ã'),('Ä'),('Å'); SELECT a, HEX(WEIGHT_STRING(a LEVEL 2)) FROM t1 ORDER BY a; a HEX(WEIGHT_STRING(a LEVEL 2)) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 63815bfa9ff..08c85372574 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -6209,6 +6209,45 @@ OCTET_LENGTH(a) a 255 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA DROP TABLE t1; # +# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +# +# +SET NAMES utf8; +SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data; +data +131072 +SELECT length(data) AS len FROM ( +SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data +) AS sub; +len +131072 +SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data; +data +131070 +SELECT length(data) AS len FROM ( +SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data +) AS sub; +len +131070 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub; +len +73532 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub; +len +73534 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub; +len +73556 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub; +len +131070 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub; +len +131072 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub; +len +131074 +# # End of 5.5 tests # # diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index 10d77ae1502..97ef4d36168 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -2825,6 +2825,40 @@ OCTET_LENGTH(a) a 252 😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎 DROP TABLE t1; # +# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +# +# +SET NAMES utf8mb4; +SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data; +data +65532 +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub; +len +65532 +SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data; +data +65538 +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub; +len +65538 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub; +len +65532 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub; +len +65535 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub; +len +65538 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub; +len +196605 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; +len +196608 +# # End of 5.5 tests # # diff --git a/mysql-test/r/ctype_utf8mb4_uca.result b/mysql-test/r/ctype_utf8mb4_uca.result index b711dfb65c8..4792d746709 100644 --- a/mysql-test/r/ctype_utf8mb4_uca.result +++ b/mysql-test/r/ctype_utf8mb4_uca.result @@ -5373,6 +5373,19 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_thai_520_w2 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_ucs2 0x3400); +INSERT INTO t1 VALUES (_ucs2 0xF001); +SELECT HEX(CONVERT(a USING ucs2)) AS ucs2, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1; +ucs2 HEX(a) HEX(WEIGHT_STRING(a)) +3400 E39080 FB80B4000020 +F001 EF8081 FBC1F0010020 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT SPACE(10) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_thai_520_w2 NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('A'),('À'),('Á'),('Â'),('Ã'),('Ä'),('Å'); SELECT a, HEX(WEIGHT_STRING(a LEVEL 2)) FROM t1 ORDER BY a; a HEX(WEIGHT_STRING(a LEVEL 2)) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 1d643333424..08709c6def0 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -621,13 +621,13 @@ SELECT f3 FROM t2 HAVING f3 >= 8 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY system NULL NULL NULL NULL 1 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 sq.f2 1 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 const 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(); Using join buffer (flat, BNL join) 4 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 2 DERIVED t1 system NULL NULL NULL NULL 1 100.00 Warnings: Note 1276 Field or reference 'sq.f2' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 6 AS `f1` from (select `test`.`t2`.`f3` from `test`.`t2` having (`test`.`t2`.`f3` >= 8)) semi join (`test`.`t2`) where ((`test`.`t2`.`f3` = 6) and (9 = ``.`f3`)) +Note 1003 select 6 AS `f1` from (select `test`.`t2`.`f3` from `test`.`t2` having (`test`.`t2`.`f3` >= 8)) semi join (`test`.`t2`) where ((`test`.`t2`.`f3` = 6) and (``.`f3` = 9)) DROP TABLE t2,t1; # # MDEV-9462: Out of memory using explain on 2 empty tables diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index 5783247b673..9849068c894 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -79,6 +79,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -93,6 +94,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 12 @@ -166,6 +168,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -180,6 +183,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 12 @@ -232,6 +236,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -248,6 +253,7 @@ Handler_read_key 11 Handler_read_last 0 Handler_read_next 3 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 11 Handler_read_rnd_deleted 0 Handler_read_rnd_next 36 @@ -323,6 +329,7 @@ Handler_read_key 22 Handler_read_last 0 Handler_read_next 22 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 60 @@ -340,6 +347,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -356,6 +364,7 @@ Handler_read_key 11 Handler_read_last 0 Handler_read_next 3 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 11 Handler_read_rnd_deleted 0 Handler_read_rnd_next 36 @@ -451,6 +460,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 2 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 39 diff --git a/mysql-test/r/events_1.result b/mysql-test/r/events_1.result index 153137bc4f9..a105dcd2125 100644 --- a/mysql-test/r/events_1.result +++ b/mysql-test/r/events_1.result @@ -470,6 +470,26 @@ DROP EVENT ev1; SHOW EVENTS; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +# +# MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH +# +CREATE TABLE t1 (a INT); +CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +events_test ev1 root@localhost SYSTEM RECURRING NULL 5 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +SET sql_mode=PAD_CHAR_TO_FULL_LENGTH; +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +events_test ev1 root@localhost SYSTEM RECURRING NULL 5 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +DROP EVENT ev1; +CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +events_test ev1 root@localhost SYSTEM RECURRING NULL 5 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +DROP EVENT ev1; +DROP TABLE t1; +SET sql_mode=DEFAULT; # # End of tests diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 0d9d4ffff9f..10d50193352 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -2274,6 +2274,45 @@ EXECUTE stmt; t2_id GROUP_CONCAT(IF (t6.b, t6.f, t5.f) ORDER BY 1) DROP TABLE t1,t2,t3,t4,t5,t6; # +# MDEV-10500 CASE/IF Statement returns multiple values and shifts further result values to the next column +# +CREATE TABLE t1 ( +id int not null AUTO_INCREMENT, +active bool not null, +data1 bigint, +data2 bigint, +data3 bigint, +primary key (id) +); +INSERT INTO t1 (active,data1,data2,data3) VALUES (1,null,100,200); +SELECT +CASE WHEN active THEN SUM(data1) END AS C_1, +SUM(data2) AS C_2, +SUM(data3) AS C_3 +FROM t1; +C_1 C_2 C_3 +NULL 100 200 +SELECT +IF(active, SUM(data1), 5) AS C_1, +SUM(data2) AS C_2, +SUM(data3) AS C_3 +FROM t1; +C_1 C_2 C_3 +NULL 100 200 +DROP TABLE t1; +# +# MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +# +SELECT STDDEV_POP(f) FROM (SELECT "1e+309" AS f UNION SELECT "-1e+309" AS f) tbl; +STDDEV_POP(f) +1.7976931348623157e308 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1e+309' +Warning 1292 Truncated incorrect DOUBLE value: '-1e+309' +SELECT STDDEV(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT -1.7976931348623157e+308 AS f) tbl; +STDDEV(f) +1.7976931348623157e308 +# # MDEV-8852 Implicit or explicit CAST from MAX(string) to INT,DOUBLE,DECIMAL does not produce warnings # SELECT MAX('x') << 1, CAST(MAX('x') AS DOUBLE), CAST(MAX('x') AS DECIMAL); @@ -2340,5 +2379,58 @@ companynr AVG(fld1) avg1 avg2 37 9223372036854775805.0000 9223372036854775805 9223372036854775805 DROP TABLE t1; # +# case where aggregate resolved in the local SELECT +# but outer ones are checked +# +create table t10 (a int , b int, c int); +insert into t10 values (0,0,0),(1,1,1); +create table t11 as select * from t10; +create table t12 as select * from t10; +explain extended select a from t10 where c<3 or a in (select c from t12 union select max(t10.b) from t11 group by t11.c); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t10 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t12 ALL NULL NULL NULL NULL 2 100.00 Using where +3 DEPENDENT UNION t11 ALL NULL NULL NULL NULL 2 100.00 Using temporary +NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1276 Field or reference 'test.t10.b' of SELECT #3 was resolved in SELECT #1 +Note 1003 select `test`.`t10`.`a` AS `a` from `test`.`t10` where ((`test`.`t10`.`c` < 3) or <`test`.`t10`.`a`,`test`.`t10`.`b`>((`test`.`t10`.`a`,(select `test`.`t12`.`c` from `test`.`t12` where ((`test`.`t10`.`a`) = `test`.`t12`.`c`) union select max(`test`.`t10`.`b`) from `test`.`t11` group by `test`.`t11`.`c` having ((`test`.`t10`.`a`) = (max(`test`.`t10`.`b`))))))) +drop table t10,t11,t12; +# +# MDEV-10017: Get unexpected `Empty Set` for correlated subquery +# with aggregate functions +# +create table t1(c1 int, c2 int, c3 int); +insert into t1 values(1,1,1),(2,2,2),(3,3,3); +select * from t1; +c1 c2 c3 +1 1 1 +2 2 2 +3 3 3 +create table t2(c1 int, c2 int); +insert into t2 values(2,2); +select * from t2; +c1 c2 +2 2 +explain extended +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt)); +ERROR HY000: Invalid use of group function +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt)); +ERROR HY000: Invalid use of group function +explain extended +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+tt.c1) from t2 tt)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 +2 DEPENDENT SUBQUERY t system NULL NULL NULL NULL 1 100.00 +3 DEPENDENT SUBQUERY tt system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #3 was resolved in SELECT #1 +Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` having (`test`.`t1`.`c1` >= <`test`.`t1`.`c1`>((select 2 AS `c` from dual order by (select min((`test`.`t1`.`c1` + 2)) from dual)))) +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+tt.c1) from t2 tt)); +c1 +2 +3 +drop table t1,t2; +# # End of 10.1 tests # diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 33a997c8004..1855fa72523 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -813,6 +813,25 @@ EXECUTE s; DROP TABLE t1; # End of 5.3 tests # +# Start of 10.0 tests +# +# +# MDEV-10020 InnoDB NOT IN Query Crash When One Item Is NULL +# +CREATE TABLE t1 +( +a INT(11), +b VARCHAR(10), +KEY (b) +); +INSERT INTO t1 VALUES (1,'x'),(2,'y'),(3,'z'); +SELECT * FROM t1 WHERE b NOT IN (NULL, '', 'A'); +a b +DROP TABLE t1; +# +# Start of 10.1 tests +# +# # MDEV-8755 Equal field propagation is not performed any longer for the IN list when multiple comparison types # CREATE TABLE t1 (a INT); diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index f8e89dbc1c2..f694d25cb04 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -787,12 +787,18 @@ select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; 5.9 div 2 1.23456789e3 DIV 2 1.23456789e9 DIV 2 1.23456789e19 DIV 2 2 617 617283945 6172839450000000000 # +# MDEV-10467 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +SELECT STDDEV_SAMP(ROUND('0', 309)) FROM t1; +STDDEV_SAMP(ROUND('0', 309)) +0 +DROP TABLE t1; +# # End of 5.5 tests # # -# Start of 10.0 tests -# -# # MDEV-5781 Item_sum_std::val_real(): Assertion `nr >= 0.0' fails on query with STDDEV_POP, ROUND and variable # SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table; diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 700fda2e182..06ea89d9ab8 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -570,6 +570,13 @@ AND 57813X540X1723 = 'Test'; N AVG 0 NULL drop table t1; +SELECT NAME_CONST('a', -(1 OR 2)) OR 1; +ERROR HY000: Incorrect arguments to NAME_CONST +SELECT NAME_CONST('a', -(1 AND 2)) OR 1; +ERROR HY000: Incorrect arguments to NAME_CONST +SELECT NAME_CONST('a', -(1)) OR 1; +NAME_CONST('a', -(1)) OR 1 +1 # # End of 5.5 tests # diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index ad51010de30..a6c63e6593a 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2806,3 +2806,332 @@ Warning 1292 Truncated incorrect time value: '-1441:00:00' # # End of 10.0 tests # +# +# Start of 10.1 tests +# +# +# MDEV-10317 EXCTACT(MINUTE_MICROSECOND) truncates data +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('1999-12-31 23:59:59.999999'); +SELECT +a, +EXTRACT(YEAR FROM a), +EXTRACT(YEAR_MONTH FROM a), +EXTRACT(QUARTER FROM a), +EXTRACT(MONTH FROM a), +EXTRACT(WEEK FROM a), +EXTRACT(DAY FROM a), +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY_MINUTE FROM a), +EXTRACT(DAY_SECOND FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(HOUR_MINUTE FROM a), +EXTRACT(HOUR_SECOND FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(MINUTE_SECOND FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a), +EXTRACT(DAY_MICROSECOND FROM a), +EXTRACT(HOUR_MICROSECOND FROM a), +EXTRACT(MINUTE_MICROSECOND FROM a), +EXTRACT(SECOND_MICROSECOND FROM a) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 12 26 26 Y 128 6 63 +def EXTRACT(YEAR FROM a) 3 4 4 Y 32896 0 63 +def EXTRACT(YEAR_MONTH FROM a) 3 6 6 Y 32896 0 63 +def EXTRACT(QUARTER FROM a) 3 2 1 Y 32896 0 63 +def EXTRACT(MONTH FROM a) 3 2 2 Y 32896 0 63 +def EXTRACT(WEEK FROM a) 3 2 2 Y 32896 0 63 +def EXTRACT(DAY FROM a) 3 2 2 Y 32896 0 63 +def EXTRACT(DAY_HOUR FROM a) 3 5 4 Y 32896 0 63 +def EXTRACT(DAY_MINUTE FROM a) 3 7 6 Y 32896 0 63 +def EXTRACT(DAY_SECOND FROM a) 3 9 8 Y 32896 0 63 +def EXTRACT(HOUR FROM a) 3 3 2 Y 32896 0 63 +def EXTRACT(HOUR_MINUTE FROM a) 3 5 4 Y 32896 0 63 +def EXTRACT(HOUR_SECOND FROM a) 3 7 6 Y 32896 0 63 +def EXTRACT(MINUTE FROM a) 3 3 2 Y 32896 0 63 +def EXTRACT(MINUTE_SECOND FROM a) 3 5 4 Y 32896 0 63 +def EXTRACT(SECOND FROM a) 3 3 2 Y 32896 0 63 +def EXTRACT(MICROSECOND FROM a) 3 7 6 Y 32896 0 63 +def EXTRACT(DAY_MICROSECOND FROM a) 8 15 14 Y 32896 0 63 +def EXTRACT(HOUR_MICROSECOND FROM a) 8 13 12 Y 32896 0 63 +def EXTRACT(MINUTE_MICROSECOND FROM a) 8 11 10 Y 32896 0 63 +def EXTRACT(SECOND_MICROSECOND FROM a) 3 9 8 Y 32896 0 63 +a 1999-12-31 23:59:59.999999 +EXTRACT(YEAR FROM a) 1999 +EXTRACT(YEAR_MONTH FROM a) 199912 +EXTRACT(QUARTER FROM a) 4 +EXTRACT(MONTH FROM a) 12 +EXTRACT(WEEK FROM a) 52 +EXTRACT(DAY FROM a) 31 +EXTRACT(DAY_HOUR FROM a) 3123 +EXTRACT(DAY_MINUTE FROM a) 312359 +EXTRACT(DAY_SECOND FROM a) 31235959 +EXTRACT(HOUR FROM a) 23 +EXTRACT(HOUR_MINUTE FROM a) 2359 +EXTRACT(HOUR_SECOND FROM a) 235959 +EXTRACT(MINUTE FROM a) 59 +EXTRACT(MINUTE_SECOND FROM a) 5959 +EXTRACT(SECOND FROM a) 59 +EXTRACT(MICROSECOND FROM a) 999999 +EXTRACT(DAY_MICROSECOND FROM a) 31235959999999 +EXTRACT(HOUR_MICROSECOND FROM a) 235959999999 +EXTRACT(MINUTE_MICROSECOND FROM a) 5959999999 +EXTRACT(SECOND_MICROSECOND FROM a) 59999999 +CREATE TABLE t2 AS SELECT +a, +EXTRACT(YEAR FROM a), +EXTRACT(YEAR_MONTH FROM a), +EXTRACT(QUARTER FROM a), +EXTRACT(MONTH FROM a), +EXTRACT(WEEK FROM a), +EXTRACT(DAY FROM a), +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY_MINUTE FROM a), +EXTRACT(DAY_SECOND FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(HOUR_MINUTE FROM a), +EXTRACT(HOUR_SECOND FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(MINUTE_SECOND FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a), +EXTRACT(DAY_MICROSECOND FROM a), +EXTRACT(HOUR_MICROSECOND FROM a), +EXTRACT(MINUTE_MICROSECOND FROM a), +EXTRACT(SECOND_MICROSECOND FROM a) +FROM t1; +SELECT * FROM t2; +a 1999-12-31 23:59:59.999999 +EXTRACT(YEAR FROM a) 1999 +EXTRACT(YEAR_MONTH FROM a) 199912 +EXTRACT(QUARTER FROM a) 4 +EXTRACT(MONTH FROM a) 12 +EXTRACT(WEEK FROM a) 52 +EXTRACT(DAY FROM a) 31 +EXTRACT(DAY_HOUR FROM a) 3123 +EXTRACT(DAY_MINUTE FROM a) 312359 +EXTRACT(DAY_SECOND FROM a) 31235959 +EXTRACT(HOUR FROM a) 23 +EXTRACT(HOUR_MINUTE FROM a) 2359 +EXTRACT(HOUR_SECOND FROM a) 235959 +EXTRACT(MINUTE FROM a) 59 +EXTRACT(MINUTE_SECOND FROM a) 5959 +EXTRACT(SECOND FROM a) 59 +EXTRACT(MICROSECOND FROM a) 999999 +EXTRACT(DAY_MICROSECOND FROM a) 31235959999999 +EXTRACT(HOUR_MICROSECOND FROM a) 235959999999 +EXTRACT(MINUTE_MICROSECOND FROM a) 5959999999 +EXTRACT(SECOND_MICROSECOND FROM a) 59999999 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) DEFAULT NULL, + `EXTRACT(YEAR FROM a)` int(4) DEFAULT NULL, + `EXTRACT(YEAR_MONTH FROM a)` int(6) DEFAULT NULL, + `EXTRACT(QUARTER FROM a)` int(2) DEFAULT NULL, + `EXTRACT(MONTH FROM a)` int(2) DEFAULT NULL, + `EXTRACT(WEEK FROM a)` int(2) DEFAULT NULL, + `EXTRACT(DAY FROM a)` int(2) DEFAULT NULL, + `EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL, + `EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL, + `EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL, + `EXTRACT(HOUR FROM a)` int(3) DEFAULT NULL, + `EXTRACT(HOUR_MINUTE FROM a)` int(5) DEFAULT NULL, + `EXTRACT(HOUR_SECOND FROM a)` int(7) DEFAULT NULL, + `EXTRACT(MINUTE FROM a)` int(3) DEFAULT NULL, + `EXTRACT(MINUTE_SECOND FROM a)` int(5) DEFAULT NULL, + `EXTRACT(SECOND FROM a)` int(3) DEFAULT NULL, + `EXTRACT(MICROSECOND FROM a)` int(7) DEFAULT NULL, + `EXTRACT(DAY_MICROSECOND FROM a)` bigint(15) DEFAULT NULL, + `EXTRACT(HOUR_MICROSECOND FROM a)` bigint(13) DEFAULT NULL, + `EXTRACT(MINUTE_MICROSECOND FROM a)` bigint(11) DEFAULT NULL, + `EXTRACT(SECOND_MICROSECOND FROM a)` int(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1,t2; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-838:59:59.999999'),('838:59:59.999999'); +SELECT +a, +EXTRACT(YEAR FROM a), +EXTRACT(YEAR_MONTH FROM a), +EXTRACT(QUARTER FROM a), +EXTRACT(MONTH FROM a), +EXTRACT(WEEK FROM a), +EXTRACT(DAY FROM a), +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY_MINUTE FROM a), +EXTRACT(DAY_SECOND FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(HOUR_MINUTE FROM a), +EXTRACT(HOUR_SECOND FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(MINUTE_SECOND FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a), +EXTRACT(DAY_MICROSECOND FROM a), +EXTRACT(HOUR_MICROSECOND FROM a), +EXTRACT(MINUTE_MICROSECOND FROM a), +EXTRACT(SECOND_MICROSECOND FROM a) +FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 11 17 17 Y 128 6 63 +def EXTRACT(YEAR FROM a) 3 4 1 Y 32896 0 63 +def EXTRACT(YEAR_MONTH FROM a) 3 6 1 Y 32896 0 63 +def EXTRACT(QUARTER FROM a) 3 2 1 Y 32896 0 63 +def EXTRACT(MONTH FROM a) 3 2 1 Y 32896 0 63 +def EXTRACT(WEEK FROM a) 3 2 9 Y 32896 0 63 +def EXTRACT(DAY FROM a) 3 2 2 Y 32896 0 63 +def EXTRACT(DAY_HOUR FROM a) 3 5 5 Y 32896 0 63 +def EXTRACT(DAY_MINUTE FROM a) 3 7 7 Y 32896 0 63 +def EXTRACT(DAY_SECOND FROM a) 3 9 9 Y 32896 0 63 +def EXTRACT(HOUR FROM a) 3 3 3 Y 32896 0 63 +def EXTRACT(HOUR_MINUTE FROM a) 3 5 5 Y 32896 0 63 +def EXTRACT(HOUR_SECOND FROM a) 3 7 7 Y 32896 0 63 +def EXTRACT(MINUTE FROM a) 3 3 3 Y 32896 0 63 +def EXTRACT(MINUTE_SECOND FROM a) 3 5 5 Y 32896 0 63 +def EXTRACT(SECOND FROM a) 3 3 3 Y 32896 0 63 +def EXTRACT(MICROSECOND FROM a) 3 7 7 Y 32896 0 63 +def EXTRACT(DAY_MICROSECOND FROM a) 8 15 15 Y 32896 0 63 +def EXTRACT(HOUR_MICROSECOND FROM a) 8 13 13 Y 32896 0 63 +def EXTRACT(MINUTE_MICROSECOND FROM a) 8 11 11 Y 32896 0 63 +def EXTRACT(SECOND_MICROSECOND FROM a) 3 9 9 Y 32896 0 63 +a -838:59:59.999999 +EXTRACT(YEAR FROM a) 0 +EXTRACT(YEAR_MONTH FROM a) 0 +EXTRACT(QUARTER FROM a) 0 +EXTRACT(MONTH FROM a) 0 +EXTRACT(WEEK FROM a) 613566757 +EXTRACT(DAY FROM a) 34 +EXTRACT(DAY_HOUR FROM a) -3422 +EXTRACT(DAY_MINUTE FROM a) -342259 +EXTRACT(DAY_SECOND FROM a) -34225959 +EXTRACT(HOUR FROM a) -22 +EXTRACT(HOUR_MINUTE FROM a) -2259 +EXTRACT(HOUR_SECOND FROM a) -225959 +EXTRACT(MINUTE FROM a) -59 +EXTRACT(MINUTE_SECOND FROM a) -5959 +EXTRACT(SECOND FROM a) -59 +EXTRACT(MICROSECOND FROM a) -999999 +EXTRACT(DAY_MICROSECOND FROM a) -34225959999999 +EXTRACT(HOUR_MICROSECOND FROM a) -225959999999 +EXTRACT(MINUTE_MICROSECOND FROM a) -5959999999 +EXTRACT(SECOND_MICROSECOND FROM a) -59999999 +a 838:59:59.999999 +EXTRACT(YEAR FROM a) 0 +EXTRACT(YEAR_MONTH FROM a) 0 +EXTRACT(QUARTER FROM a) 0 +EXTRACT(MONTH FROM a) 0 +EXTRACT(WEEK FROM a) 613566757 +EXTRACT(DAY FROM a) 34 +EXTRACT(DAY_HOUR FROM a) 3422 +EXTRACT(DAY_MINUTE FROM a) 342259 +EXTRACT(DAY_SECOND FROM a) 34225959 +EXTRACT(HOUR FROM a) 22 +EXTRACT(HOUR_MINUTE FROM a) 2259 +EXTRACT(HOUR_SECOND FROM a) 225959 +EXTRACT(MINUTE FROM a) 59 +EXTRACT(MINUTE_SECOND FROM a) 5959 +EXTRACT(SECOND FROM a) 59 +EXTRACT(MICROSECOND FROM a) 999999 +EXTRACT(DAY_MICROSECOND FROM a) 34225959999999 +EXTRACT(HOUR_MICROSECOND FROM a) 225959999999 +EXTRACT(MINUTE_MICROSECOND FROM a) 5959999999 +EXTRACT(SECOND_MICROSECOND FROM a) 59999999 +CREATE TABLE t2 AS SELECT +a, +EXTRACT(YEAR FROM a), +EXTRACT(YEAR_MONTH FROM a), +EXTRACT(QUARTER FROM a), +EXTRACT(MONTH FROM a), +EXTRACT(WEEK FROM a), +EXTRACT(DAY FROM a), +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY_MINUTE FROM a), +EXTRACT(DAY_SECOND FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(HOUR_MINUTE FROM a), +EXTRACT(HOUR_SECOND FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(MINUTE_SECOND FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a), +EXTRACT(DAY_MICROSECOND FROM a), +EXTRACT(HOUR_MICROSECOND FROM a), +EXTRACT(MINUTE_MICROSECOND FROM a), +EXTRACT(SECOND_MICROSECOND FROM a) +FROM t1; +SELECT * FROM t2; +a -838:59:59.999999 +EXTRACT(YEAR FROM a) 0 +EXTRACT(YEAR_MONTH FROM a) 0 +EXTRACT(QUARTER FROM a) 0 +EXTRACT(MONTH FROM a) 0 +EXTRACT(WEEK FROM a) 613566757 +EXTRACT(DAY FROM a) 34 +EXTRACT(DAY_HOUR FROM a) -3422 +EXTRACT(DAY_MINUTE FROM a) -342259 +EXTRACT(DAY_SECOND FROM a) -34225959 +EXTRACT(HOUR FROM a) -22 +EXTRACT(HOUR_MINUTE FROM a) -2259 +EXTRACT(HOUR_SECOND FROM a) -225959 +EXTRACT(MINUTE FROM a) -59 +EXTRACT(MINUTE_SECOND FROM a) -5959 +EXTRACT(SECOND FROM a) -59 +EXTRACT(MICROSECOND FROM a) -999999 +EXTRACT(DAY_MICROSECOND FROM a) -34225959999999 +EXTRACT(HOUR_MICROSECOND FROM a) -225959999999 +EXTRACT(MINUTE_MICROSECOND FROM a) -5959999999 +EXTRACT(SECOND_MICROSECOND FROM a) -59999999 +a 838:59:59.999999 +EXTRACT(YEAR FROM a) 0 +EXTRACT(YEAR_MONTH FROM a) 0 +EXTRACT(QUARTER FROM a) 0 +EXTRACT(MONTH FROM a) 0 +EXTRACT(WEEK FROM a) 613566757 +EXTRACT(DAY FROM a) 34 +EXTRACT(DAY_HOUR FROM a) 3422 +EXTRACT(DAY_MINUTE FROM a) 342259 +EXTRACT(DAY_SECOND FROM a) 34225959 +EXTRACT(HOUR FROM a) 22 +EXTRACT(HOUR_MINUTE FROM a) 2259 +EXTRACT(HOUR_SECOND FROM a) 225959 +EXTRACT(MINUTE FROM a) 59 +EXTRACT(MINUTE_SECOND FROM a) 5959 +EXTRACT(SECOND FROM a) 59 +EXTRACT(MICROSECOND FROM a) 999999 +EXTRACT(DAY_MICROSECOND FROM a) 34225959999999 +EXTRACT(HOUR_MICROSECOND FROM a) 225959999999 +EXTRACT(MINUTE_MICROSECOND FROM a) 5959999999 +EXTRACT(SECOND_MICROSECOND FROM a) 59999999 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(6) DEFAULT NULL, + `EXTRACT(YEAR FROM a)` int(4) DEFAULT NULL, + `EXTRACT(YEAR_MONTH FROM a)` int(6) DEFAULT NULL, + `EXTRACT(QUARTER FROM a)` int(2) DEFAULT NULL, + `EXTRACT(MONTH FROM a)` int(2) DEFAULT NULL, + `EXTRACT(WEEK FROM a)` int(2) DEFAULT NULL, + `EXTRACT(DAY FROM a)` int(2) DEFAULT NULL, + `EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL, + `EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL, + `EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL, + `EXTRACT(HOUR FROM a)` int(3) DEFAULT NULL, + `EXTRACT(HOUR_MINUTE FROM a)` int(5) DEFAULT NULL, + `EXTRACT(HOUR_SECOND FROM a)` int(7) DEFAULT NULL, + `EXTRACT(MINUTE FROM a)` int(3) DEFAULT NULL, + `EXTRACT(MINUTE_SECOND FROM a)` int(5) DEFAULT NULL, + `EXTRACT(SECOND FROM a)` int(3) DEFAULT NULL, + `EXTRACT(MICROSECOND FROM a)` int(7) DEFAULT NULL, + `EXTRACT(DAY_MICROSECOND FROM a)` bigint(15) DEFAULT NULL, + `EXTRACT(HOUR_MICROSECOND FROM a)` bigint(13) DEFAULT NULL, + `EXTRACT(MINUTE_MICROSECOND FROM a)` bigint(11) DEFAULT NULL, + `EXTRACT(SECOND_MICROSECOND FROM a)` int(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1,t2; +# +# End of 10.1 tests +# diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index bd14f21010b..cf58a2dc6f5 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -710,7 +710,7 @@ mysqltest_db1.t3 preload_keys status OK # RENAME (doesn't work for temporary tables, thus should fail). # RENAME TABLE t3 TO t3_1; -ERROR 42000: DROP, ALTER command denied to user 'mysqltest_u1'@'localhost' for table 't3' +ERROR 42000: INSERT, CREATE command denied to user 'mysqltest_u1'@'localhost' for table 't3_1' # # HANDLER OPEN/READ/CLOSE. # diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 3ef73bb1943..adf1a3c9ab3 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2692,3 +2692,37 @@ select distinct a from t1 group by 'a'; a 2001-02-02 drop table t1; +# +# MDEV-10324: Server crash in get_sel_arg_for_keypart or Assertion `n < size()' failed in Mem_root_array +# +CREATE TABLE t1 ( +job_id int(10) unsigned NOT NULL AUTO_INCREMENT, +job_cmd varbinary(60) NOT NULL DEFAULT '', +job_namespace int(11) NOT NULL, +job_title varbinary(255) NOT NULL, +job_params blob NOT NULL, +job_timestamp varbinary(14) DEFAULT NULL, +job_random int(10) unsigned NOT NULL DEFAULT '0', +job_token varbinary(32) NOT NULL DEFAULT '', +job_token_timestamp varbinary(14) DEFAULT NULL, +job_sha1 varbinary(32) NOT NULL DEFAULT '', +job_attempts int(10) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (job_id), +KEY job_cmd (job_cmd,job_namespace,job_title,job_params(128)), +KEY job_timestamp (job_timestamp), +KEY job_sha1 (job_sha1), +KEY job_cmd_token (job_cmd,job_token,job_random), +KEY job_cmd_token_id (job_cmd,job_token,job_id) +); +INSERT INTO t1 VALUES +(NULL, 'foo', 1, 'foo', 'foo', 'foo', 1, 'foo', 'foo', 'foo', 1), +(NULL, 'bar', 2, 'bar', 'bar', 'bar', 2, 'bar', 'bar', 'bar', 2); +SELECT DISTINCT job_cmd FROM t1 WHERE job_cmd IN ('foobar','null'); +job_cmd +drop table t1; +CREATE TABLE t1 (f1 INT NOT NULL, f2 VARCHAR(3) NOT NULL, KEY(f1), KEY(f2, f1)); +INSERT INTO t1 VALUES (0,'foo'),(1,'bar'); +SELECT 1 IN ( SELECT COUNT( DISTINCT f2 ) FROM t1 WHERE f1 <= 4 ); +1 IN ( SELECT COUNT( DISTINCT f2 ) FROM t1 WHERE f1 <= 4 ) +0 +drop table t1; diff --git a/mysql-test/r/group_by_innodb.result b/mysql-test/r/group_by_innodb.result index 381e0d7493c..bf6b25f31fa 100644 --- a/mysql-test/r/group_by_innodb.result +++ b/mysql-test/r/group_by_innodb.result @@ -123,4 +123,39 @@ id xtext optionen 2 number 22,25 1 select Kabel mit Stecker 5-polig,Kabel ohne Stecker DROP TABLE t1, t2; +# Port of testcase: +# +# Bug#20819199 ASSERTION FAILED IN TEST_IF_SKIP_SORT_ORDER +# +CREATE TABLE t0 ( a INT ); +INSERT INTO t0 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +a INT, +b INT, +PRIMARY KEY (pk), +KEY idx1 (a), +KEY idx2 (b, a), +KEY idx3 (a, b) +) ENGINE = InnoDB; +INSERT INTO t1 (a, b) SELECT t01.a, t02.a FROM t0 t01, t0 t02; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx3 idx3 5 NULL 100 Using where; Using index +SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; +a MAX(b) +1 10 +2 10 +3 10 +4 10 +5 10 +6 10 +7 10 +8 10 +9 10 +10 10 +DROP TABLE t0, t1; # End of tests diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index cf867dd1e18..7d57222aafd 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2378,6 +2378,7 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 0 +Handler_read_retry 0 EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by @@ -2387,6 +2388,7 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 0 +Handler_read_retry 0 FLUSH STATUS; SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; max(b) a @@ -2398,6 +2400,7 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 0 +Handler_read_retry 0 FLUSH STATUS; (SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); @@ -2410,6 +2413,7 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 16 Handler_read_next 0 +Handler_read_retry 0 EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); id select_type table type possible_keys key key_len ref rows Extra @@ -2462,6 +2466,7 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 0 +Handler_read_retry 0 DELETE FROM t3; FLUSH STATUS; INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) @@ -2470,12 +2475,14 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 0 +Handler_read_retry 0 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 0 +Handler_read_retry 0 FLUSH STATUS; DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1) > 10000; @@ -2484,6 +2491,7 @@ SHOW STATUS LIKE 'handler_read__e%'; Variable_name Value Handler_read_key 8 Handler_read_next 1 +Handler_read_retry 0 DROP TABLE t1,t2,t3; CREATE TABLE t1 (a int, INDEX idx(a)); INSERT INTO t1 VALUES diff --git a/mysql-test/r/handler_read_last.result b/mysql-test/r/handler_read_last.result index 574c3c25ab1..9dd3784673a 100644 --- a/mysql-test/r/handler_read_last.result +++ b/mysql-test/r/handler_read_last.result @@ -12,6 +12,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -26,6 +27,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -42,6 +44,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 2 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -58,6 +61,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 2 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/help.result b/mysql-test/r/help.result index 3a266567175..aefe6f8381e 100644 --- a/mysql-test/r/help.result +++ b/mysql-test/r/help.result @@ -148,6 +148,21 @@ help 'impossible_category_1'; source_category_name name is_it_category impossible_category_1 impossible_function_1 N impossible_category_1 impossible_function_2 N +# MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH +help 'impossible_function_1'; +name description example +impossible_function_1 description of + impossible_function1 + example of + impossible_function1 +SET sql_mode=PAD_CHAR_TO_FULL_LENGTH; +help 'impossible_function_1'; +name description example +impossible_function_1 description of + impossible_function1 + example of + impossible_function1 +SET sql_mode=DEFAULT; set sql_mode=""; alter table mysql.help_relation engine=innodb; alter table mysql.help_keyword engine=innodb; diff --git a/mysql-test/r/information_schema_stats.result b/mysql-test/r/information_schema_stats.result new file mode 100644 index 00000000000..bc2ce9f0294 --- /dev/null +++ b/mysql-test/r/information_schema_stats.result @@ -0,0 +1,70 @@ +set global userstat=1; +create table just_a_test(id int,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30)); +insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'), +(2,'fb','lb','china_b',22222222,'fb_lb@163.com','Arizona'), +(3,'fc','lc','china_c',33333333,'fc_lc@163.com','California'), +(4,'fd','ld','china_d',44444444,'fd_ld@163.com','Utah'), +(5,'fe','le','china_e',55555555,'fe_le@163.com','Arizona'); +alter table just_a_test add primary key (id); +alter table just_a_test add key IND_just_a_test_first_name_last_name(first_name,last_name); +alter table just_a_test add key IND_just_a_test_state(state); +select count(*) from just_a_test where first_name='fc' and last_name='lc'; +count(*) +1 +select count(*) from just_a_test where state = 'California'; +count(*) +2 +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +test just_a_test IND_just_a_test_first_name_last_name 1 +test just_a_test IND_just_a_test_state 2 +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +test just_a_test 18 5 5 +alter table just_a_test drop key IND_just_a_test_first_name_last_name; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +test just_a_test IND_just_a_test_state 2 +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +test just_a_test 23 5 5 +alter table just_a_test drop column state; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +test just_a_test 28 5 5 +drop table just_a_test; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +create table just_a_test(id int not null primary key,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30),key(first_name,last_name),key(state)); +insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'), +(2,'fb','lb','china_b',22222222,'fb_lb@163.com','Arizona'), +(3,'fc','lc','china_c',33333333,'fc_lc@163.com','California'), +(4,'fd','ld','china_d',44444444,'fd_ld@163.com','Utah'), +(5,'fe','le','china_e',55555555,'fe_le@163.com','Arizona'); +select count(*) from just_a_test where first_name='fc' and last_name='lc'; +count(*) +1 +select count(*) from just_a_test where state = 'California'; +count(*) +2 +select count(*) from just_a_test where id between 2 and 4; +count(*) +3 +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +test just_a_test PRIMARY 5 +test just_a_test first_name 1 +test just_a_test state 2 +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +test just_a_test 8 5 15 +drop table just_a_test; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES +set global userstat=0; diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result index cae402a9f12..1305be86e5a 100644 --- a/mysql-test/r/innodb_ext_key.result +++ b/mysql-test/r/innodb_ext_key.result @@ -20,6 +20,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 5 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -39,6 +40,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 1 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -60,6 +62,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -81,6 +84,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -102,6 +106,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 6 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -123,6 +128,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 1 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -146,6 +152,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 6 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -169,6 +176,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 3 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -188,6 +196,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 6 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -207,6 +216,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -228,6 +238,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 6 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -249,6 +260,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -270,6 +282,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 5 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -291,6 +304,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -317,6 +331,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 9 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 9 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -343,6 +358,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 2 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 2 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -370,6 +386,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 9 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 9 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -397,6 +414,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 3 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 3 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -422,6 +440,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 9 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 3 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -447,6 +466,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 3 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 3 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -477,6 +497,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 294 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -507,6 +528,7 @@ Handler_read_key 21 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -529,6 +551,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 1230 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -551,6 +574,7 @@ Handler_read_key 6 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -581,6 +605,7 @@ Handler_read_key 3 Handler_read_last 0 Handler_read_next 26 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -610,6 +635,7 @@ Handler_read_key 3 Handler_read_last 0 Handler_read_next 3 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -807,6 +833,7 @@ Handler_read_key 10 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 11 @@ -828,6 +855,7 @@ Handler_read_key 10 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 11 @@ -1040,5 +1068,70 @@ a 1 drop table t1, t2; set optimizer_switch=@save_optimizer_switch; +# +# MDEV-10325: Queries examines all rows of a tables when it should not +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 ( +pk int not null, +col1 varchar(32), +filler varchar(100), +key idx1(col1(10)), +primary key (pk) +)engine=innodb; +insert into t1 +select +A.a + 10*B.a + 100*C.a, +concat('1234567890-', 1000+ A.a + 10*B.a + 100*C.a), +repeat('filler-data-', 4) +from +t0 A, t0 B, t0 C; +drop table t0,t1; +# +# MDEV-10360: Extended keys: index properties depend on index order +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 ( +index_id bigint(20) unsigned NOT NULL, +index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , +index_object_id int(10) unsigned NOT NULL DEFAULT '0' , +index_date_updated int(10) unsigned DEFAULT NULL , +PRIMARY KEY (index_id), +KEY object (index_class(181),index_object_id), +KEY index_date_updated (index_date_updated) +) engine=innodb; +create table t2 ( +index_id bigint(20) unsigned NOT NULL, +index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , +index_object_id int(10) unsigned NOT NULL DEFAULT '0' , +index_date_updated int(10) unsigned DEFAULT NULL , +PRIMARY KEY (index_id), +KEY index_date_updated (index_date_updated), +KEY object (index_class(181),index_object_id) +) engine=innodb; +insert into t1 select +@a:=A.a + 10*B.a + 100*C.a, +concat('val-', @a), +123456, +A.a + 10*B.a +from +t0 A, t0 B, t0 C; +insert into t2 select * from t1; +# This must have the same query plan as the query below it: +# type=range, key=index_date_updated, key_len=13 +explain +select * from t1 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range index_date_updated index_date_updated 13 NULL # Using index condition +# This used to work from the start: +explain +select * from t2 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range index_date_updated index_date_updated 13 NULL # Using index condition +drop table t0,t1,t2; set optimizer_switch=@save_ext_key_optimizer_switch; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/r/insert_innodb.result b/mysql-test/r/insert_innodb.result index ffba9388ec4..e5e2b4b8623 100644 --- a/mysql-test/r/insert_innodb.result +++ b/mysql-test/r/insert_innodb.result @@ -28,3 +28,18 @@ ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (` UPDATE t1, t2 SET t1.fld1= t1.fld1 + 3; ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) DROP TABLE t2, t1; +# +# BUG#22037930: INSERT IGNORE FAILS TO IGNORE FOREIGN +# KEY CONSTRAINT +CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= INNODB; +CREATE TABLE t2 (fld1 VARCHAR(10), fld2 INT NOT NULL, +CONSTRAINT fk FOREIGN KEY (fld2) REFERENCES t1(fld1)) ENGINE= INNODB; +# Without patch, reports incorrect error. +INSERT INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def'; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +REPLACE INTO t2 VALUES('abc', 2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +INSERT IGNORE INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def'; +Warnings: +Warning 1452 Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +DROP TABLE t2, t1; diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 8bfc4e9215e..3f4a26a728e 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -701,6 +701,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 1 diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index e7292e8ddce..d500b38a8dc 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -860,6 +860,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 5 @@ -1271,6 +1272,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 1 diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 266c8332b36..b3dfc0835f0 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1244,6 +1244,7 @@ Handler_read_key 5 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 6 @@ -1805,6 +1806,7 @@ Handler_read_key 4 Handler_read_last 0 Handler_read_next 5 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 1048581 @@ -1819,6 +1821,7 @@ Handler_read_key 4 Handler_read_last 0 Handler_read_next 5 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 1048581 diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 5710dac519d..158e845d730 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1255,6 +1255,7 @@ Handler_read_key 5 Handler_read_last 0 Handler_read_next 9 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 3 Handler_read_rnd_deleted 0 Handler_read_rnd_next 6 @@ -1816,6 +1817,7 @@ Handler_read_key 4 Handler_read_last 0 Handler_read_next 5 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 1048581 @@ -1830,6 +1832,7 @@ Handler_read_key 4 Handler_read_last 0 Handler_read_next 5 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 1048581 diff --git a/mysql-test/r/limit_rows_examined.result b/mysql-test/r/limit_rows_examined.result index 130d17ae270..1f829d545f6 100644 --- a/mysql-test/r/limit_rows_examined.result +++ b/mysql-test/r/limit_rows_examined.result @@ -751,6 +751,7 @@ Handler_read_key 5 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 46 @@ -775,6 +776,7 @@ Handler_read_key 5 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 2 Handler_read_rnd_deleted 1 Handler_read_rnd_next 47 diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 8cd3b0a7ac8..c54d9a8277f 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -531,7 +531,7 @@ DROP TABLE t1; # Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U # CREATE TABLE t1(f1 INT); -SELECT 0xE1BB30 INTO OUTFILE 't1.dat'; +SELECT 0xE1C330 INTO OUTFILE 't1.dat'; LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8; DROP TABLE t1; # @@ -556,3 +556,27 @@ FIELDS TERMINATED BY 't' LINES TERMINATED BY ''; Got one of the listed errors SET @@sql_mode= @old_mode; DROP TABLE t1; + +# +# Bug#23080148 - Backport of Bug#20683959. +# Bug#20683959 LOAD DATA INFILE IGNORES A SPECIFIC ROW SILENTLY +# UNDER DB CHARSET IS UTF8. +# +CREATE DATABASE d1 CHARSET latin1; +USE d1; +CREATE TABLE t1 (val TEXT); +LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1; +SELECT COUNT(*) FROM t1; +COUNT(*) +1 +SELECT HEX(val) FROM t1; +HEX(val) +C38322525420406E696F757A656368756E3A20E98198E2889AF58081AEE7B99DE4B88AE383A3E7B99DE69690F58087B3E7B9A7EFBDA8E7B99DEFBDB3E7B99DE78999E880B3E7B8BAEFBDAAE7B9A7E89699E296A1E7B8BAE4BBA3EFBD8CE7B8BAEFBDA9E7B8B2E2889AE38184E7B99DEFBDB3E7B99DE4B88AE383A3E7B99DE69690F58087B3E7B9A7EFBDA8E7B99DEFBDB3E7B99DE5B3A8EFBD84E8ABA0EFBDA8E89C89F580948EE599AAE7B8BAEFBDAAE7B8BAE9A198EFBDA9EFBDB1E7B9A7E581B5E289A0E7B8BAEFBDBEE7B9A7E9A194EFBDA9E882B4EFBDA5EFBDB5E980A7F5808B96E28693E99EABE38287E58F99E7B8BAE58AB1E28691E7B8BAF5808B9AE7828AE98095EFBDB1E7B8BAEFBDAFE7B8B2E288ABE6A89FE89EB3E6BA98F58081ADE88EA0EFBDBAE98095E6BA98F58081AEE89D93EFBDBAE8AD9BEFBDACE980A7F5808B96E28693E7B8BAF580918EE288AAE7B8BAE4B88AEFBC9EE7B8BAE4B99DE28691E7B8BAF5808B96EFBCA0E88DB3E6A68AEFBDB9EFBDB3E981B2E5B3A8E296A1E7B8BAE7A4BCE7828AE88DB3E6A68AEFBDB0EFBDBDE7B8BAA0E7B8BAE88B93EFBDBEE5B899EFBC9E +CREATE DATABASE d2 CHARSET utf8; +USE d2; +CREATE TABLE t1 (val TEXT); +LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1; +ERROR HY000: Invalid utf8 character string: 'Ã"RT @niouzechun: \9058\221A' +DROP TABLE d1.t1, d2.t1; +DROP DATABASE d1; +DROP DATABASE d2; diff --git a/mysql-test/r/locale.result b/mysql-test/r/locale.result index c28cedae8b1..95c1f51fd87 100644 --- a/mysql-test/r/locale.result +++ b/mysql-test/r/locale.result @@ -102,6 +102,34 @@ SELECT monthname('2001-03-01'); monthname('2001-03-01') März # +# MDEV-10052 Illegal mix of collations with DAYNAME(date_field)<>varchar_field +# +SET NAMES utf8; +CREATE TABLE t1 (c VARCHAR(8) CHARACTER SET latin1, d DATE); +INSERT INTO t1 VALUES ('test',now()); +Warnings: +Note 1265 Data truncated for column 'd' at row 1 +SET lc_time_names=ru_RU; +SELECT c FROM t1 WHERE DAYNAME(d)<>c; +ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<>' +SELECT c FROM t1 WHERE MONTHNAME(d)<>c; +ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<>' +SET lc_time_names=en_US; +SELECT c FROM t1 WHERE DAYNAME(d)<>c; +c +test +SELECT c FROM t1 WHERE MONTHNAME(d)<>c; +c +test +SET NAMES latin1; +SELECT c FROM t1 WHERE DAYNAME(d)<>c; +c +test +SELECT c FROM t1 WHERE MONTHNAME(d)<>c; +c +test +DROP TABLE t1; +# # Start of 5.6 tests # # diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index c680339536b..5991a5fd25a 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -1040,4 +1040,36 @@ f1 f2 1 97 DROP TABLE t1, t2; DROP VIEW v1; +# +# MDEV-5973: MySQL Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0 +# FROM STORAGE ENGINE) WITH MULTI-TABLE UPDATE +# +CREATE TABLE table_11757486 (field1 tinyint) ENGINE=INNODB; +INSERT INTO table_11757486 VALUES (0),(0); +SET SESSION SQL_MODE='STRICT_ALL_TABLES'; +UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1; +Warnings: +Warning 1264 Out of range value for column 'field1' at row 1 +Warning 1264 Out of range value for column 'field1' at row 2 +UPDATE IGNORE table_11757486 SET field1=128; +Warnings: +Warning 1264 Out of range value for column 'field1' at row 1 +Warning 1264 Out of range value for column 'field1' at row 2 +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. +UPDATE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1; +ERROR 22003: Out of range value for column 'field1' at row 1 +UPDATE table_11757486 SET field1=128; +ERROR 22003: Out of range value for column 'field1' at row 1 +SET SESSION SQL_MODE=''; +UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1; +Warnings: +Warning 1264 Out of range value for column 'field1' at row 1 +Warning 1264 Out of range value for column 'field1' at row 2 +UPDATE IGNORE table_11757486 SET field1=128; +Warnings: +Warning 1264 Out of range value for column 'field1' at row 1 +Warning 1264 Out of range value for column 'field1' at row 2 +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. +DROP TABLE table_11757486; +SET SESSION SQL_MODE=default; end of 10.0 tests diff --git a/mysql-test/r/myisam_enable_keys-10506.result b/mysql-test/r/myisam_enable_keys-10506.result new file mode 100644 index 00000000000..e7ffba787f0 --- /dev/null +++ b/mysql-test/r/myisam_enable_keys-10506.result @@ -0,0 +1,114 @@ +CREATE TABLE t1 ( +pk INT AUTO_INCREMENT, +i INT, +d DATE, +dt DATETIME, +v VARCHAR(1), +PRIMARY KEY (pk), +KEY (dt) +) ENGINE=MyISAM; +INSERT INTO t1 (i, d, dt, v) VALUES +(9, '2005-07-23', '2004-05-13 01:01:39', 't'), +(2, '2009-11-01', '2003-12-24 07:39:29', 'h'), +(6, NULL, '2008-07-03 05:32:22', 'l'), +(6, '2007-07-16', '2008-08-28 18:46:11', 'j'), +(5, NULL, '2001-07-12 21:27:00', 'h'), +(3, '2007-07-22', '1900-01-01 00:00:00', 'p'), +(2, '2000-11-21', '2007-05-25 11:58:54', 'g'), +(6, '1900-01-01', '2009-06-03 17:11:10', 'i'), +(2, '2008-02-10', '2001-06-15 16:20:07', 'p'), +(3, '2009-06-04', '1900-01-01 00:00:00', 'h'), +(9, '2007-04-25', '1900-01-01 00:00:00', 'e'), +(9, '2006-03-02', '1900-01-01 00:00:00', 'e'), +(1, '1900-01-01', '2002-11-08 09:33:27', 'u'), +(7, '2008-07-13', '2007-08-07 17:35:52', 'j'), +(0, '2004-11-12', '2006-05-01 00:00:00', 'e'), +(0, '1900-01-01', '2003-05-01 00:00:00', 'z'), +(1, '2009-09-02', '2007-02-12 09:30:49', 'w'), +(0, '2004-11-06', '1900-01-01 00:00:00', 't'), +(4, '2003-01-06', '2002-07-03 02:51:11', 'i'), +(6, '2006-01-14', '2008-02-26 04:57:32', 'i'), +(0, '2002-01-19', '2009-02-12 00:00:00', 'i'), +(8, '2007-02-12', '1900-01-01 00:00:00', 'b'), +(4, '1900-01-01', '2001-05-16 05:28:40', 'm'), +(2, '2005-07-16', NULL, 'j'), +(1, '2004-09-04', '2001-01-24 21:45:18', 'v'), +(3, '2009-07-01', NULL, NULL), +(2, '2009-07-21', '2002-07-24 00:00:00', 'h'), +(4, NULL, '2001-11-03 12:22:30', 'q'), +(1, '2002-06-22', '2008-06-17 03:17:59', 'f'), +(7, '2005-06-23', '2005-12-24 00:00:00', 'p'), +(6, '2001-05-20', '2008-10-23 00:00:00', NULL), +(3, '2001-10-01', '2000-10-12 16:32:35', 'o'), +(3, '2001-01-07', '2005-09-11 10:09:54', 'w'), +(6, '2007-11-02', '2009-09-10 01:44:18', 'l'), +(6, NULL, NULL, 'i'), +(9, NULL, '2002-05-18 15:21:55', 'd'), +(4, '2008-12-21', '2004-10-15 10:09:54', 'j'), +(6, '2003-10-05', '2009-07-13 03:51:02', 'e'), +(2, '2001-03-03', '1900-01-01 00:00:00', 'e'), +(2, '2007-04-04', '2001-11-08 21:14:52', 'q'), +(5, NULL, '2006-12-02 00:00:00', 'm'), +(0, '2009-01-04', '1900-01-01 00:00:00', NULL), +(8, '2008-04-03', '2005-01-01 11:55:18', 'q'), +(8, NULL, '2005-02-28 03:44:02', 'w'), +(0, '2003-08-22', NULL, 'c'), +(9, '1900-01-01', NULL, 'y'), +(NULL, NULL, '2006-08-25 16:28:09', 'g'), +(5, '2004-07-04', '2002-08-11 00:00:00', 'z'), +(1, '1900-01-01', '2007-07-22 21:19:18', 'm'), +(2, '2007-02-04', '2006-02-10 18:41:38', 't'), +(2, '1900-01-01', '2009-02-16 14:58:58', 'd'), +(7, '2001-03-14', '2007-08-14 00:00:00', 'h'), +(0, NULL, '1900-01-01 00:00:00', NULL), +(1, '2008-10-05', NULL, 'f'), +(6, '2001-11-25', '2008-12-03 06:59:23', 'l'), +(NULL, '2003-01-27', '2008-10-04 00:00:00', 'g'), +(8, '2008-08-08', '2009-07-07 07:00:21', 'v'), +(8, '2006-07-03', '2001-04-15 00:00:00', NULL), +(5, '2002-11-21', '2007-07-08 04:01:58', 'm'), +(5, '2006-04-08', '2007-09-23 00:01:35', 'i'), +(5, '2001-05-06', '2008-05-15 00:00:00', 'h'), +(7, '1900-01-01', '1900-01-01 00:00:00', 'u'), +(30, '2007-04-16', '2004-03-05 23:35:38', 'o'), +(NULL, '1900-01-01', '2007-08-25 01:32:47', 'z'), +(6, '2004-12-03', '1900-01-01 00:00:00', 'o'), +(8, '2001-06-23', '1900-01-01 00:00:00', 'f'), +(NULL, '2008-12-15', '2001-05-19 08:28:28', 'a'), +(9, '2000-02-15', '2009-09-03 06:07:22', 'd'), +(2, '2001-08-05', '2006-10-08 07:17:27', 'k'), +(5, '2004-01-17', '2003-09-06 20:36:01', 'd'), +(4, '2003-10-01', '2001-02-05 18:10:49', 'u'), +(4, '2003-07-28', '2001-01-07 16:11:37', 'h'), +(0, '1900-01-01', '2008-08-01 05:26:38', 'w'), +(9, '1900-01-01', '2001-05-08 00:00:00', 't'), +(1, '2000-04-17', '2008-07-10 21:26:28', 'i'), +(8, '2002-01-05', '2006-08-06 20:56:35', 'k'), +(9, '2001-04-10', '2003-02-17 00:00:00', 'z'), +(0, '2009-12-04', NULL, 'h'), +(7, NULL, '2004-10-27 00:29:57', 'h'), +(2, '2006-03-07', '2008-03-04 06:14:13', 'b'), +(0, '2001-10-15', '2001-03-17 00:00:00', 'm'), +(5, '1900-01-01', '2009-02-21 11:35:50', 'i'), +(4, NULL, '1900-01-01 00:00:00', 'w'), +(5, '2009-04-05', '1900-01-01 00:00:00', 'm'), +(6, '2001-03-19', '2001-04-12 00:00:00', 'q'), +(NULL, '2009-12-08', '2001-12-04 20:21:01', 'k'), +(2, '2005-02-09', '2001-05-27 08:41:01', 'l'), +(9, '2004-05-25', '2004-09-18 00:00:00', 'c'), +(3, '2005-01-17', '2002-09-12 11:18:48', 'd'), +(0, '2003-08-28', '1900-01-01 00:00:00', 'k'), +(6, '2006-10-11', '2003-10-28 03:31:02', 'a'), +(5, '1900-01-01', '2001-08-22 10:20:09', 'p'), +(8, '1900-01-01', '2008-04-24 00:00:00', 'o'), +(4, '2005-08-18', '2006-11-10 10:08:49', 'e'), +(NULL, '2007-03-12', '2007-10-16 00:00:00', 'n'), +(1, '2000-11-18', '2009-05-27 12:25:07', 't'), +(4, '2001-03-03', NULL, 'u'), +(3, '2003-09-11', '2001-09-10 18:10:10', 'f'), +(4, '2007-06-17', '1900-01-01 00:00:00', 't'), +(NULL, '2008-09-11', '2004-06-07 23:17:09', 'k'); +ALTER TABLE t1 ADD UNIQUE KEY ind1 (pk, d, i, v); +ALTER TABLE t1 ADD UNIQUE KEY ind2 (d, v); +ERROR 23000: Duplicate entry '2008-09-11-k' for key 'ind2' +DROP TABLE t1; diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index 033b4086985..8894616fbb3 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -343,10 +343,37 @@ DROP TABLE bug47205; # #MDEV-6128:[PATCH] mysqlcheck wrongly escapes '.' in table names # -CREATE TABLE test.`t.1` (id int); +create table `t.1` (id int); +create view `v.1` as select 1; mysqlcheck test t.1 test.t.1 OK -drop table test.`t.1`; +mysqlcheck --all-in-1 test t.1 +test.t.1 OK +mysqlcheck --all-in-1 --databases --process-views test +test.t.1 OK +test.v.1 OK +create table `t.2`(a varchar(20) primary key) default character set utf8 collate utf8_general_ci engine=innodb; +flush table `t.2`; +mysqlcheck --check-upgrade --auto-repair test +test.t.1 OK +test.t.2 +error : Table rebuild required. Please do "ALTER TABLE `t.2` FORCE" or dump/reload to fix it! +test.t.3 Needs upgrade + +Repairing tables +test.t.3 OK +check table `t.1`, `t.2`, `t.3`; +Table Op Msg_type Msg_text +test.t.1 check status OK +test.t.2 check status OK +test.t.3 check status OK +check table `t.1`, `t.2`, `t.3` for upgrade; +Table Op Msg_type Msg_text +test.t.1 check status OK +test.t.2 check status OK +test.t.3 check status OK +drop view `v.1`; +drop table test.`t.1`, `t.2`, `t.3`; # # MDEV-8123 mysqlcheck: new --process-views option conflicts with --quick, --extended and such # @@ -376,6 +403,62 @@ Repairing views test.v1 OK drop view v1; drop table t1; +create table `#mysql50#t1``1` (a int) engine=myisam; +show tables; +Tables_in_test +t1`1 +drop table `t1``1`; +call mtr.add_suppression("ha_myisam"); +call mtr.add_suppression("Checking table"); +create database mysqltest1; +create table mysqltest1.t1 (a int) engine=myisam; +create table t2 (a int); +check table mysqltest1.t1; +Table Op Msg_type Msg_text +mysqltest1.t1 check warning Size of datafile is: 4 Should be: 0 +mysqltest1.t1 check error got error: 0 when reading datafile at record: 0 +mysqltest1.t1 check error Corrupt +mtr.global_suppressions Table is already up to date +mtr.test_suppressions Table is already up to date +mysql.column_stats Table is already up to date +mysql.columns_priv Table is already up to date +mysql.db Table is already up to date +mysql.event Table is already up to date +mysql.func Table is already up to date +mysql.gtid_slave_pos Table is already up to date +mysql.help_category Table is already up to date +mysql.help_keyword Table is already up to date +mysql.help_relation Table is already up to date +mysql.help_topic Table is already up to date +mysql.host Table is already up to date +mysql.index_stats Table is already up to date +mysql.innodb_index_stats OK +mysql.innodb_table_stats OK +mysql.plugin Table is already up to date +mysql.proc Table is already up to date +mysql.procs_priv Table is already up to date +mysql.proxies_priv Table is already up to date +mysql.roles_mapping Table is already up to date +mysql.servers Table is already up to date +mysql.table_stats Table is already up to date +mysql.tables_priv Table is already up to date +mysql.time_zone Table is already up to date +mysql.time_zone_leap_second Table is already up to date +mysql.time_zone_name Table is already up to date +mysql.time_zone_transition Table is already up to date +mysql.time_zone_transition_type Table is already up to date +mysql.user Table is already up to date +mysqltest1.t1 +warning : Table is marked as crashed +warning : Size of datafile is: 4 Should be: 0 +error : got error: 0 when reading datafile at record: 0 +error : Corrupt +test.t2 Table is already up to date + +Repairing tables +mysqltest1.t1 OK +drop table t2; +drop database mysqltest1; # #MDEV-7384 [PATCH] add PERSISENT FOR ALL option to mysqlanalyze/mysqlcheck # diff --git a/mysql-test/r/named_pipe.result b/mysql-test/r/named_pipe.result index ddd48f0ba91..43fb44beece 100644 --- a/mysql-test/r/named_pipe.result +++ b/mysql-test/r/named_pipe.result @@ -2154,3 +2154,4 @@ Privat (Private Nutzung) Mobilfunk Warnings: Warning 1052 Column 'kundentyp' in group statement is ambiguous drop table t1; +FOUND /\[ERROR\] Create named pipe failed/ in second-mysqld.err diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index 0d012e283b5..fcaaeb2192f 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -1572,5 +1572,22 @@ SELECT * FROM t1 WHERE NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(N i DROP TABLE t1; # +# MDEV-10236 Where expression with NOT function gives incorrect result +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1),(2),(3); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`c1` is not null) >= ((not(1)))) is not null) +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +c1 +1 +2 +3 +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index e80851329a4..81bfa1ac994 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -429,6 +429,7 @@ Handler_read_key 6 Handler_read_last 0 Handler_read_next 2 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 5 diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index 852fdee51ee..294ddaf7884 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -58,8 +58,8 @@ mysqltest: Could not open connection 'default': 2026 SSL connection error: Unabl SHOW STATUS LIKE 'Ssl_cipher'; Variable_name Value Ssl_cipher DHE-RSA-AES256-SHA -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +have_ssl +1 End of 5.0 tests DROP TABLE IF EXISTS thread_status; DROP EVENT IF EXISTS event_status; @@ -204,9 +204,9 @@ result is still running; no cipher request crashed the server GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; FLUSH PRIVILEGES; -SHOW STATUS LIKE 'Ssl_cipher'; -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; +have_ssl +1 DROP USER bug42158@localhost; set global sql_mode=default; End of 5.1 tests diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 03e7c48951a..50ac3435596 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1163,7 +1163,7 @@ INSERT INTO t1 SELECT a +32, b +32 FROM t1; INSERT INTO t1 SELECT a +64, b +64 FROM t1; EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL ab 4 NULL 10 Using index for group-by +1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using index SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; a 1 @@ -2864,6 +2864,7 @@ Handler_read_key 250 Handler_read_last 0 Handler_read_next 249 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 249 Handler_read_rnd_deleted 0 Handler_read_rnd_next 250 @@ -2882,6 +2883,7 @@ Handler_read_key 250 Handler_read_last 0 Handler_read_next 249 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 250 diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 01cc9d79aaf..78a0c6079b0 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -643,6 +643,26 @@ CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW SET default_storage_engine = NEW.INNODB; ERROR 42S22: Unknown column 'INNODB' in 'NEW' DROP TABLE t1; +select 0==0; +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 '=0' at line 1 +select 1=!0, 1 = ! 0; +1=!0 1 = ! 0 +1 1 +select !!0, ! ! 0; +!!0 ! ! 0 +0 0 +select 2>!0, 2 > ! 0; +2>!0 2 > ! 0 +1 1 +select 0<=!0, 0 <= !0; +0<=!0 0 <= !0 +1 1 +select 1< 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_RND_NEXT 3 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 4 locks (1 table, 1 partition lock/unlock) FLUSH STATUS; SELECT a FROM t1 PARTITION (p0); @@ -31,7 +31,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_RND_NEXT 3 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 4 locks (1 table, 1 partition lock/unlock) FLUSH STATUS; INSERT INTO v1 VALUES (10); @@ -39,14 +39,14 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 2 # 4 locks (1 table, 1 partition lock/unlock) FLUSH STATUS; SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 2 locks (1 table, all partitions pruned) FLUSH STATUS; SELECT * FROM v1; @@ -59,7 +59,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_RND_NEXT 4 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 4 locks (1 table, 1 partition lock/unlock) FLUSH STATUS; SELECT a FROM t1 PARTITION (p0); @@ -72,7 +72,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_RND_NEXT 4 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 4 locks (1 table, 1 partition lock/unlock) SELECT * FROM t1; a @@ -89,14 +89,14 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 2 # 4 locks (1 table, 1 partition lock/unlock) FLUSH STATUS; SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 2 locks (1 table, all partitions pruned) SELECT * FROM v1; a @@ -121,7 +121,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 2 # 4 locks (1 table, 1 partition lock/unlock) FLUSH STATUS; @@ -131,7 +131,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 2 locks (1 table, all partitions pruned) FLUSH STATUS; INSERT INTO v1 VALUES (32); @@ -140,7 +140,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 4 locks (1 table, 1 partition lock/unlock) SELECT * FROM v1; a @@ -166,12 +166,12 @@ FLUSH STATUS; SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 # OK, seems to add number of variables processed before HANDLER_WRITE # and number of variables + 1 evaluated in the previous call in RND_NEXT CREATE TABLE t1 @@ -233,7 +233,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 2 # Should be 1 commit # 4 external locks (due to pruning of locks) @@ -250,7 +250,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 2 # Should be 1 commit # 4 external locks @@ -262,7 +262,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # should be 1 commit # 9 locks (1 ha_partition + 8 ha_innobase) # 17 writes (internal I_S) @@ -271,8 +271,8 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 HANDLER_WRITE 2 # + 1 commit # + 19 rnd next (internal I_S) @@ -282,8 +282,8 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 -HANDLER_READ_RND_NEXT 52 -HANDLER_TMP_WRITE 72 +HANDLER_READ_RND_NEXT 54 +HANDLER_TMP_WRITE 75 HANDLER_WRITE 2 # + 9 locks (unlocks) # + 19 rnd next (internal I_S) @@ -338,7 +338,7 @@ ERROR HY000: Unknown partition 'pNonexistent' in table 't1' SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # should have failed before locking (only 17 internal I_S writes) FLUSH STATUS; SELECT * FROM t1 PARTITION (subp2); @@ -348,7 +348,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Should be 1 commit # 4 locks (1 ha_partition + 1 ha_innobase) x 2 (lock/unlock) # 1 read first (also calls index_read) @@ -366,7 +366,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 3 HANDLER_READ_NEXT 3 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Should be 1 commit # 8 locks (1 ha_partition + 2 + 1 ha_innobase) x 2 # 3 read first (one for each partition) @@ -379,7 +379,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 1 commit # 18 locks # 18 READ KEY from opening a new partition table instance, @@ -398,8 +398,8 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 HANDLER_READ_FIRST 1 HANDLER_READ_NEXT 3 -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 # + 1 commit # + 1 read first (read first key from index in one partition) # + 2 read key (innobase_get_index from index_init + from index_first) @@ -415,8 +415,8 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 3 HANDLER_READ_FIRST 3 HANDLER_READ_NEXT 4 -HANDLER_READ_RND_NEXT 52 -HANDLER_TMP_WRITE 72 +HANDLER_READ_RND_NEXT 54 +HANDLER_TMP_WRITE 75 # + 1 commit # + 2 read first (one for each subpart) # + 4 read key (innobase_get_index from index_init + from index_first) @@ -431,8 +431,8 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 4 HANDLER_READ_FIRST 3 HANDLER_READ_NEXT 4 -HANDLER_READ_RND_NEXT 78 -HANDLER_TMP_WRITE 97 +HANDLER_READ_RND_NEXT 81 +HANDLER_TMP_WRITE 101 # No matching partition, only internal I_S. SELECT * FROM t1 PARTITION (pNeg) WHERE a = 100; a b @@ -443,8 +443,8 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 5 HANDLER_READ_FIRST 3 HANDLER_READ_NEXT 4 -HANDLER_READ_RND_NEXT 104 -HANDLER_TMP_WRITE 122 +HANDLER_READ_RND_NEXT 108 +HANDLER_TMP_WRITE 127 # + 18 for unlock (same as lock above) (100 is not in pNeg, no match) # Test that EXPLAIN PARTITION works EXPLAIN PARTITIONS SELECT * FROM t1 PARTITION (pNonexistent); @@ -460,7 +460,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 8 locks (1 ha_partition + 3 ha_innobase) x 2 (lock/unlock) EXPLAIN PARTITIONS SELECT * FROM t1 PARTITION (subp3) AS TableAlias; id select_type table partitions type possible_keys key key_len ref rows Extra @@ -513,7 +513,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 1 # 2 locks (1 ha_partition) x 2 (lock/unlock), Was 4 locks before WL4443 # explicit pruning says part_id 0 and implicit pruning says part_id 1 @@ -526,7 +526,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 2 # 1 commit # 4 locks (1 ha_partition + 1 ha_innobase) x 2 (lock/unlock) @@ -544,7 +544,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_KEY 2 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 2 HANDLER_WRITE 2 # 1 commit @@ -566,7 +566,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 1 commit # 9 locks # 17 write (internal I_S) @@ -578,8 +578,8 @@ HANDLER_COMMIT 2 HANDLER_DELETE 2 HANDLER_READ_KEY 1 HANDLER_READ_NEXT 1 -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 # + 1 commit # + 1 delete (one row deleted) # + 3 read key (1 innodb_get_index in records_in_range, @@ -596,9 +596,9 @@ HANDLER_COMMIT 2 HANDLER_DELETE 2 HANDLER_READ_KEY 1 HANDLER_READ_NEXT 1 -HANDLER_READ_RND_NEXT 52 +HANDLER_READ_RND_NEXT 54 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 72 +HANDLER_TMP_WRITE 75 HANDLER_WRITE 1 # Failed before start_stmt/execution. # + 19 rnd next (internal I_S) @@ -612,9 +612,9 @@ HANDLER_COMMIT 3 HANDLER_DELETE 2 HANDLER_READ_KEY 1 HANDLER_READ_NEXT 1 -HANDLER_READ_RND_NEXT 78 +HANDLER_READ_RND_NEXT 81 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 97 +HANDLER_TMP_WRITE 101 HANDLER_WRITE 3 # + 1 commit # + 19 rnd next (internal I_S) @@ -627,9 +627,9 @@ HANDLER_COMMIT 4 HANDLER_DELETE 2 HANDLER_READ_KEY 3 HANDLER_READ_NEXT 1 -HANDLER_READ_RND_NEXT 104 +HANDLER_READ_RND_NEXT 108 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 122 +HANDLER_TMP_WRITE 127 HANDLER_UPDATE 2 HANDLER_WRITE 5 # + 1 commit @@ -650,9 +650,9 @@ HANDLER_DELETE 2 HANDLER_READ_FIRST 1 HANDLER_READ_KEY 3 HANDLER_READ_NEXT 4 -HANDLER_READ_RND_NEXT 130 +HANDLER_READ_RND_NEXT 135 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 147 +HANDLER_TMP_WRITE 153 HANDLER_UPDATE 2 HANDLER_WRITE 5 # + 1 commit @@ -670,9 +670,9 @@ HANDLER_DELETE 2 HANDLER_READ_FIRST 1 HANDLER_READ_KEY 3 HANDLER_READ_NEXT 4 -HANDLER_READ_RND_NEXT 156 +HANDLER_READ_RND_NEXT 162 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 172 +HANDLER_TMP_WRITE 179 HANDLER_UPDATE 2 HANDLER_WRITE 5 # + 9 locks @@ -696,7 +696,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 4 HANDLER_READ_NEXT 5 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 1 commit # 10 locks (1 ha_partition + 4 ha_innobase) x 2 (lock/unlock) # 4 read first (for reading the first row in 4 partitions) @@ -709,7 +709,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 10 locks (table + 4 partition) x (lock + unlock) SELECT * FROM t1 PARTITION (pNeg, `p10-99`); a b @@ -720,7 +720,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 3 # 6 locks (1 ha_partition + 2 ha_innobase) x 2 (lock+unlock) # 1 rollback @@ -732,7 +732,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 10 # 10 lock (1 ha_partition + 4 ha_innobase) x 2 (lock + unlock) ALTER TABLE t1 TRUNCATE PARTITION pNeg, `p10-99`; @@ -742,7 +742,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 9 locks # 18 read key (ALTER forces table to be closed, see above for open) LOAD DATA INFILE 'loadtest.txt' INTO TABLE t1 PARTITION (pNeg, `p10-99`); @@ -750,8 +750,8 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 HANDLER_WRITE 10 # + 23 write (18 internal I_S + 5 rows) UNLOCK TABLES; @@ -759,8 +759,8 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 -HANDLER_READ_RND_NEXT 52 -HANDLER_TMP_WRITE 72 +HANDLER_READ_RND_NEXT 54 +HANDLER_TMP_WRITE 75 HANDLER_WRITE 10 # + 9 locks # @@ -773,7 +773,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_RND_NEXT 2 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 2 # 1 commit # 4 lock (1 ha_partition + 1 ha_innobase) x 2 (lock + unlock) @@ -791,7 +791,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_KEY 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 2 # 1 commit # 4 lock @@ -806,7 +806,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_KEY 1 HANDLER_READ_RND 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 2 # 1 commit # 4 lock @@ -819,7 +819,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Nothing, since impossible PARTITION+WHERE clause. FLUSH STATUS; UPDATE t1 PARTITION(subp0) SET a = -2, b = concat(b, ', Updated from a = 100') @@ -828,7 +828,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Nothing, since impossible PARTITION+WHERE clause. FLUSH STATUS; UPDATE t1 PARTITION(`p100-99999`) SET a = -2, b = concat(b, ', Updated from a = 100') @@ -840,7 +840,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_READ_KEY 1 HANDLER_READ_RND 1 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 1 # 6 lock # 4 read key (1 index init + 1 index read + 1 rnd init + 1 rnd pos) @@ -856,7 +856,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_READ_KEY 1 HANDLER_READ_RND 1 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 1 HANDLER_WRITE 1 # 10 locks @@ -874,7 +874,7 @@ HANDLER_COMMIT 1 HANDLER_DELETE 1 HANDLER_READ_KEY 1 HANDLER_READ_RND 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_UPDATE 1 HANDLER_WRITE 1 # 1 commit @@ -902,7 +902,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Nothing (no matching partition found) FLUSH STATUS; UPDATE t1 PARTITION (pNeg) SET b = concat(b, ', Updated2') WHERE a = 1000000; @@ -910,7 +910,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Nothing (no matching partition found) FLUSH STATUS; LOCK TABLE t1 WRITE; @@ -918,7 +918,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 9 locks UPDATE t1 PARTITION (subp7) SET b = concat(b, ', Updated to 103'), a = 103 WHERE a = 101; SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS @@ -927,8 +927,8 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 HANDLER_READ_KEY 1 HANDLER_READ_RND 1 -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 HANDLER_UPDATE 2 # + 4 read key # + 1 read rnd @@ -941,8 +941,8 @@ HANDLER_COMMIT 3 HANDLER_DELETE 1 HANDLER_READ_KEY 2 HANDLER_READ_RND 2 -HANDLER_READ_RND_NEXT 52 -HANDLER_TMP_WRITE 72 +HANDLER_READ_RND_NEXT 54 +HANDLER_TMP_WRITE 75 HANDLER_UPDATE 3 HANDLER_WRITE 1 # + 1 delete @@ -957,8 +957,8 @@ HANDLER_COMMIT 3 HANDLER_DELETE 1 HANDLER_READ_KEY 2 HANDLER_READ_RND 2 -HANDLER_READ_RND_NEXT 78 -HANDLER_TMP_WRITE 97 +HANDLER_READ_RND_NEXT 81 +HANDLER_TMP_WRITE 101 HANDLER_UPDATE 3 HANDLER_WRITE 1 + 9 locks @@ -986,7 +986,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_DELETE 2 HANDLER_READ_KEY 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 1 delete # 4 locks (pruning works!). # 1 read key (index read) @@ -998,7 +998,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_DELETE 2 HANDLER_READ_RND_NEXT 3 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 1 delete # 4 locks # 1 read first @@ -1010,7 +1010,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 9 locks DELETE FROM t1 PARTITION (subp1) WHERE b = 'p0-9:subp3'; SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS @@ -1018,8 +1018,8 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 2 HANDLER_READ_KEY 1 -HANDLER_READ_RND_NEXT 26 -HANDLER_TMP_WRITE 47 +HANDLER_READ_RND_NEXT 27 +HANDLER_TMP_WRITE 49 # + 3 read key (1 innodb_get_index in records_in_range # + 1 innobase_get_index in index_init + 1 index read) DELETE FROM t1 PARTITION (`p0-9`) WHERE b = 'p0-9:subp3'; @@ -1030,8 +1030,8 @@ HANDLER_COMMIT 3 HANDLER_DELETE 2 HANDLER_READ_KEY 3 HANDLER_READ_NEXT 1 -HANDLER_READ_RND_NEXT 52 -HANDLER_TMP_WRITE 72 +HANDLER_READ_RND_NEXT 54 +HANDLER_TMP_WRITE 75 # + 1 delete # + 6 read key (same as above, but for two subpartitions) # + 1 read next (read next after found row) @@ -1043,8 +1043,8 @@ HANDLER_COMMIT 3 HANDLER_DELETE 2 HANDLER_READ_KEY 3 HANDLER_READ_NEXT 1 -HANDLER_READ_RND_NEXT 78 -HANDLER_TMP_WRITE 97 +HANDLER_READ_RND_NEXT 81 +HANDLER_TMP_WRITE 101 # + 9 locks # Test multi-table DELETE # Can be expressed in two different ways. @@ -1057,7 +1057,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 5 HANDLER_READ_NEXT 5 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 10 # 24 locks (2 table, 5 + 5 subpartitions lock/unlock) FLUSH STATUS; @@ -1066,7 +1066,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 14 locks (1 table, 6 subpartitions lock/unlock) FLUSH STATUS; INSERT INTO t2 PARTITION (subp3) SELECT * FROM t1 PARTITION (subp3, `p10-99`, `p100-99999`); @@ -1076,7 +1076,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_READ_FIRST 5 HANDLER_ROLLBACK 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 1 # 16 locks (2 tables, 1 + 5 subpartitions lock/unlock) FLUSH STATUS; @@ -1091,7 +1091,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 5 HANDLER_READ_NEXT 5 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 7 # 16 locks (2 tables, 1 + 5 subpartitions lock/unlock) TRUNCATE TABLE t2; @@ -1103,7 +1103,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 5 HANDLER_READ_NEXT 5 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 10 # 30 locks (2 table, 8 + 5 subpartitions lock/unlock) FLUSH STATUS; @@ -1114,7 +1114,7 @@ VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_FIRST 5 HANDLER_READ_NEXT 7 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 HANDLER_WRITE 7 # 14 locks (2 table, 5 subpartitions lock/unlock) SHOW CREATE TABLE t1; @@ -1201,7 +1201,7 @@ WHERE t1.a = t3.a AND t3.b = 'subp3'' at line 1 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # Multi table delete without any matching rows FLUSH STATUS; DELETE t1, t2 FROM t1 PARTITION (pNeg), t3, t2 PARTITION (subp3) @@ -1211,7 +1211,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 HANDLER_READ_RND_NEXT 3 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 12 locks (3 in t1, 1 in t3, 2 in t2) x 2 (lock + unlock) # 1 read first (first rnd_next in t2) # 4 read key (1 innodb_get_index in rnd_init in t2 + index read in t2 @@ -1231,7 +1231,7 @@ HANDLER_READ_KEY 2 HANDLER_READ_NEXT 2 HANDLER_READ_RND 4 HANDLER_READ_RND_NEXT 16 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 4 delete (2 in t2 + 2 in t3) # 12 locks (3 in t2, 1 in t3, 2 in t1) x 2 (lock + unlock) # 3 read first (1 in t1 + 1 in t3 + 1 in t3, for second row in t1) @@ -1279,7 +1279,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; VARIABLE_NAME VARIABLE_VALUE HANDLER_COMMIT 1 -HANDLER_TMP_WRITE 22 +HANDLER_TMP_WRITE 23 # 6 locks (lock/unlock two subpartitions + table) # Test on non partitioned table SELECT * FROM t3 PARTITION (pNeg); diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index e8a7eb133fb..ca6a5cf876a 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -3950,6 +3950,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -3964,6 +3965,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -3978,6 +3980,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 8 @@ -3992,6 +3995,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index 326d37ee560..f54020c44d4 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -789,3 +789,5 @@ execute stmt1; 1 drop prepare stmt1; drop table t1; +select ?+1; +Got one of the listed errors diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index a0e44f91d44..5adb8225b38 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -2114,6 +2114,37 @@ a b 1 1 drop table t2; # +# MDEV-10228: Delete missing rows with OR conditions +# (The example uses UPDATE, because UPDATE allows to use index hints +# and so it's possible to make an example that works with any storage +# engine) +# +CREATE TABLE t1 ( +key1varchar varchar(14) NOT NULL, +key2int int(11) NOT NULL DEFAULT '0', +col1 int, +PRIMARY KEY (key1varchar,key2int), +KEY key1varchar (key1varchar), +KEY key2int (key2int) +) DEFAULT CHARSET=utf8; +insert into t1 values +('value1',0, 0), +('value1',1, 0), +('value1',1000685, 0), +('value1',1003560, 0), +('value1',1004807, 0); +update t1 force index (PRIMARY) set col1=12345 +where (key1varchar='value1' AND (key2int <=1 OR key2int > 1)); +# The following must show col1=12345 for all rows: +select * from t1; +key1varchar key2int col1 +value1 0 12345 +value1 1 12345 +value1 1000685 12345 +value1 1003560 12345 +value1 1004807 12345 +drop table t1; +# # BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE # CREATE TABLE t1 (pk INT PRIMARY KEY); @@ -2288,5 +2319,16 @@ Warnings: Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1 DROP TABLE t1; # +# MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in +# sel_trees_can_be_ored(RANGE_OPT_PARAM*, SEL_TREE*, SEL_TREE*, key_map*) +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM t1 WHERE pk != 1000 OR pk IN ( 1000, 0, 1, 100, 2 ) OR pk >= 5; +pk +1 +2 +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result index c16d3b4adae..4ef7c0b658c 100644 --- a/mysql-test/r/range_mrr_icp.result +++ b/mysql-test/r/range_mrr_icp.result @@ -2116,6 +2116,37 @@ a b 1 1 drop table t2; # +# MDEV-10228: Delete missing rows with OR conditions +# (The example uses UPDATE, because UPDATE allows to use index hints +# and so it's possible to make an example that works with any storage +# engine) +# +CREATE TABLE t1 ( +key1varchar varchar(14) NOT NULL, +key2int int(11) NOT NULL DEFAULT '0', +col1 int, +PRIMARY KEY (key1varchar,key2int), +KEY key1varchar (key1varchar), +KEY key2int (key2int) +) DEFAULT CHARSET=utf8; +insert into t1 values +('value1',0, 0), +('value1',1, 0), +('value1',1000685, 0), +('value1',1003560, 0), +('value1',1004807, 0); +update t1 force index (PRIMARY) set col1=12345 +where (key1varchar='value1' AND (key2int <=1 OR key2int > 1)); +# The following must show col1=12345 for all rows: +select * from t1; +key1varchar key2int col1 +value1 0 12345 +value1 1 12345 +value1 1000685 12345 +value1 1003560 12345 +value1 1004807 12345 +drop table t1; +# # BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE # CREATE TABLE t1 (pk INT PRIMARY KEY); @@ -2290,6 +2321,17 @@ Warnings: Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column 'a' at row 1 DROP TABLE t1; # +# MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in +# sel_trees_can_be_ored(RANGE_OPT_PARAM*, SEL_TREE*, SEL_TREE*, key_map*) +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM t1 WHERE pk != 1000 OR pk IN ( 1000, 0, 1, 100, 2 ) OR pk >= 5; +pk +1 +2 +DROP TABLE t1; +# # End of 10.1 tests # set optimizer_switch=@mrr_icp_extra_tmp; diff --git a/mysql-test/r/range_vs_index_merge.result b/mysql-test/r/range_vs_index_merge.result index 1b12a9f5512..9af359a55f3 100644 --- a/mysql-test/r/range_vs_index_merge.result +++ b/mysql-test/r/range_vs_index_merge.result @@ -1310,6 +1310,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 385 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 377 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1338,6 +1339,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 59 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1367,6 +1369,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 59 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/range_vs_index_merge_innodb.result b/mysql-test/r/range_vs_index_merge_innodb.result index 8428936d25f..601ae9b7613 100644 --- a/mysql-test/r/range_vs_index_merge_innodb.result +++ b/mysql-test/r/range_vs_index_merge_innodb.result @@ -1311,6 +1311,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 385 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 377 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1339,6 +1340,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 59 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1368,6 +1370,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 59 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 9dbf6e0c46b..ca8b235ba31 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4351,6 +4351,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 6 diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index 81e52929881..4659b0753ed 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -4362,6 +4362,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 10 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 10 Handler_read_rnd_deleted 1 Handler_read_rnd_next 6 diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index 9dbf6e0c46b..ca8b235ba31 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -4351,6 +4351,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 6 diff --git a/mysql-test/r/single_delete_update.result b/mysql-test/r/single_delete_update.result index cdf97e20238..85e79f53c89 100644 --- a/mysql-test/r/single_delete_update.result +++ b/mysql-test/r/single_delete_update.result @@ -29,6 +29,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -48,6 +49,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -84,6 +86,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -103,6 +106,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -136,6 +140,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -155,6 +160,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -192,6 +198,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -211,6 +218,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -242,6 +250,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -261,6 +270,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -290,6 +300,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -309,6 +320,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -341,6 +353,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 7 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -365,6 +378,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 7 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -403,6 +417,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -422,6 +437,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -458,6 +474,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -477,6 +494,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -522,6 +540,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -547,6 +566,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -566,6 +586,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -603,6 +624,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -622,6 +644,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -663,6 +686,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -682,6 +706,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -720,6 +745,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -739,6 +765,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -776,6 +803,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -795,6 +823,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -826,6 +855,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -845,6 +875,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -875,6 +906,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -894,6 +926,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -927,6 +960,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 7 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -951,6 +985,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 7 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -993,6 +1028,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1012,6 +1048,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1053,6 +1090,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -1072,6 +1110,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -1111,6 +1150,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 4 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1136,6 +1176,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -1155,6 +1196,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 4 +Handler_read_retry 0 Handler_read_rnd 5 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/sp-prelocking.result b/mysql-test/r/sp-prelocking.result index 9e82a966268..5b594e9ea55 100644 --- a/mysql-test/r/sp-prelocking.result +++ b/mysql-test/r/sp-prelocking.result @@ -320,3 +320,23 @@ c2 DROP TRIGGER t1_ai; DROP TABLE t1, t2; End of 5.0 tests +# +# Bug#21142859: FUNCTION UPDATING A VIEW FAILS TO FIND TABLE THAT ACTUALLY EXISTS +# +CREATE TABLE t1 SELECT 1 AS fld1, 'A' AS fld2; +CREATE TABLE t2 (fld3 INT, fld4 CHAR(1)); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TRIGGER t1_au AFTER UPDATE ON t1 +FOR EACH ROW INSERT INTO t2 VALUES (new.fld1, new.fld2); +CREATE FUNCTION f1() RETURNS INT +BEGIN +UPDATE v1 SET fld2='B' WHERE fld1=1; +RETURN row_count(); +END ! +# Without the patch, an error was getting reported. +SELECT f1(); +f1() +1 +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1,t2; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 9453a1da3ca..c69ec67ae9b 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7716,6 +7716,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -7727,6 +7728,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 4097 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/ssl.result b/mysql-test/r/ssl.result index 57427a228eb..e74aef8b940 100644 --- a/mysql-test/r/ssl.result +++ b/mysql-test/r/ssl.result @@ -1,6 +1,6 @@ -SHOW STATUS LIKE 'Ssl_cipher'; -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; +have_ssl +1 SHOW STATUS LIKE 'Ssl_server_not_before'; Variable_name Value Ssl_server_not_before Apr 25 14:55:05 2015 GMT @@ -2163,12 +2163,17 @@ Privat (Private Nutzung) Mobilfunk Warnings: Warning 1052 Column 'kundentyp' in group statement is ambiguous drop table t1; -SHOW STATUS LIKE 'Ssl_cipher'; -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; +have_ssl +1 select aes_decrypt('MySQL','adf'); aes_decrypt('MySQL','adf') NULL select 'still connected?'; still connected? still connected? +create user mysqltest_1@localhost; +grant usage on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; +Variable_name Value +Ssl_cipher EDH-RSA-DES-CBC3-SHA +drop user mysqltest_1@localhost; diff --git a/mysql-test/r/ssl_ca.result b/mysql-test/r/ssl_ca.result new file mode 100644 index 00000000000..83a98902581 --- /dev/null +++ b/mysql-test/r/ssl_ca.result @@ -0,0 +1,24 @@ +# +# Bug#21920657: SSL-CA FAILS SILENTLY IF THE PATH CANNOT BE FOUND +# +# try to connect with wrong '--ssl-ca' path : should fail +ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed +# try to connect with correct '--ssl-ca' path : should connect +have_ssl +1 +# +# Bug#21920678: SSL-CA DOES NOT ACCEPT ~USER TILDE HOME DIRECTORY +# PATH SUBSTITUTION +# +# try to connect with '--ssl-ca' option using tilde home directoy +# path substitution : should connect +have_ssl +1 +# try to connect with '--ssl-key' option using tilde home directoy +# path substitution : should connect +have_ssl +1 +# try to connect with '--ssl-cert' option using tilde home directoy +# path substitution : should connect +have_ssl +1 diff --git a/mysql-test/r/ssl_compress.result b/mysql-test/r/ssl_compress.result index 31f484ab58c..d6a65c2b06d 100644 --- a/mysql-test/r/ssl_compress.result +++ b/mysql-test/r/ssl_compress.result @@ -1,6 +1,6 @@ -SHOW STATUS LIKE 'Ssl_cipher'; -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; +have_ssl +1 SHOW STATUS LIKE 'Compression'; Variable_name Value Compression ON @@ -2160,9 +2160,9 @@ Privat (Private Nutzung) Mobilfunk Warnings: Warning 1052 Column 'kundentyp' in group statement is ambiguous drop table t1; -SHOW STATUS LIKE 'Ssl_cipher'; -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; +have_ssl +1 SHOW STATUS LIKE 'Compression'; Variable_name Value Compression ON diff --git a/mysql-test/r/ssl_timeout.result b/mysql-test/r/ssl_timeout.result index 356e931ba4d..d9ef0f7a16f 100644 --- a/mysql-test/r/ssl_timeout.result +++ b/mysql-test/r/ssl_timeout.result @@ -1,7 +1,7 @@ # connect with read timeout so SLEEP() should timeout # Check ssl turned on -SHOW STATUS LIKE 'Ssl_cipher'; -Variable_name Value -Ssl_cipher DHE-RSA-AES256-SHA +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; +have_ssl +1 SELECT SLEEP(600); ERROR HY000: Lost connection to MySQL server during query diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result index 55afd159053..7c82936d30a 100644 --- a/mysql-test/r/status.result +++ b/mysql-test/r/status.result @@ -288,6 +288,7 @@ Handler_read_key 4 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 7 Handler_read_rnd_deleted 0 Handler_read_rnd_next 23 @@ -305,7 +306,7 @@ Created_tmp_files 0 Created_tmp_tables 2 Handler_tmp_update 2 Handler_tmp_write 7 -Rows_tmp_read 42 +Rows_tmp_read 43 drop table t1; CREATE TABLE t1 (i int(11) DEFAULT NULL, KEY i (i) ) ENGINE=MyISAM; insert into t1 values (1),(2),(3),(4),(5); @@ -330,6 +331,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 2 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 1 Handler_read_rnd_next 2 diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 6a531997d79..042bf68cda0 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -6892,6 +6892,7 @@ Handler_read_key 8 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 @@ -6929,6 +6930,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -7157,5 +7159,21 @@ INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); f foo +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); +f +foo drop table t1; SET NAMES default; +# +# MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +# +SET NAMES utf8; +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +f1 f2 f3 +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); +f1 f2 f3 +DROP TABLE t1, t2; +SET NAMES default; +End of 10.1 tests diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index 24d9f0de35a..31e0f66f961 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -124,6 +124,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 41 @@ -889,6 +890,7 @@ ERROR 42S22: Unknown column 'c' in 'field list' SHOW WARNINGS; Level Code Message Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1981 Aggregate function 'count()' of SELECT #3 belongs to SELECT #2 Note 1276 Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2 Error 1054 Unknown column 'c' in 'field list' DROP TABLE t1; diff --git a/mysql-test/r/subselect3_jcl6.result b/mysql-test/r/subselect3_jcl6.result index 19d3d25148f..8d976f8ddf8 100644 --- a/mysql-test/r/subselect3_jcl6.result +++ b/mysql-test/r/subselect3_jcl6.result @@ -134,6 +134,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 41 @@ -899,6 +900,7 @@ ERROR 42S22: Unknown column 'c' in 'field list' SHOW WARNINGS; Level Code Message Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1981 Aggregate function 'count()' of SELECT #3 belongs to SELECT #2 Note 1276 Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2 Error 1054 Unknown column 'c' in 'field list' DROP TABLE t1; diff --git a/mysql-test/r/subselect_cache.result b/mysql-test/r/subselect_cache.result index 8ca6bf52e0e..97a5f5a77f6 100644 --- a/mysql-test/r/subselect_cache.result +++ b/mysql-test/r/subselect_cache.result @@ -36,6 +36,7 @@ Handler_read_key 7 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 31 @@ -289,6 +290,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 61 @@ -316,6 +318,7 @@ Handler_read_key 7 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 31 @@ -342,6 +345,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 61 @@ -369,6 +373,7 @@ Handler_read_key 7 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 31 @@ -395,6 +400,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 61 @@ -494,6 +500,7 @@ Handler_read_key 7 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 442 @@ -592,6 +599,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 472 @@ -615,6 +623,7 @@ Handler_read_key 17 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 0 Handler_read_rnd_next 36 @@ -637,6 +646,7 @@ Handler_read_key 10 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 0 Handler_read_rnd_next 86 @@ -660,6 +670,7 @@ Handler_read_key 17 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 0 Handler_read_rnd_next 41 @@ -682,6 +693,7 @@ Handler_read_key 10 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 0 Handler_read_rnd_next 91 @@ -711,6 +723,7 @@ Handler_read_key 7 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 31 @@ -739,6 +752,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 61 @@ -762,6 +776,7 @@ Handler_read_key 7 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 1 Handler_read_rnd_next 36 @@ -784,6 +799,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 4 Handler_read_rnd_deleted 1 Handler_read_rnd_next 66 @@ -883,6 +899,7 @@ Handler_read_key 70 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 141 @@ -981,6 +998,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 671 @@ -1606,6 +1624,7 @@ Handler_read_key 11 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 145 @@ -1636,6 +1655,7 @@ Handler_read_key 32 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 84 @@ -1669,6 +1689,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 127 @@ -1699,6 +1720,7 @@ Handler_read_key 13 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 69 @@ -1890,6 +1912,7 @@ Handler_read_key 15 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 57 @@ -1916,6 +1939,7 @@ Handler_read_key 21 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 37 @@ -1943,6 +1967,7 @@ Handler_read_key 15 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 57 @@ -1969,6 +1994,7 @@ Handler_read_key 22 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 8 Handler_read_rnd_deleted 0 Handler_read_rnd_next 41 @@ -2011,6 +2037,7 @@ Handler_read_key 15 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -2049,6 +2076,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 151 @@ -2086,6 +2114,7 @@ Handler_read_key 15 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 43 @@ -2123,6 +2152,7 @@ Handler_read_key 18 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 27 diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index c9fa7c0c672..af3df9ec811 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -1139,6 +1139,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1981 Aggregate function 'max()' of SELECT #3 belongs to SELECT #1 Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>((`test`.`t1`.`a`,(select `test`.`t2`.`c` from `test`.`t2` where ((<`test`.`t2`.`d`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>((`test`.`t2`.`d`,(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having ((`test`.`t2`.`d`) >= (`test`.`t3`.`e`)))))) and ((`test`.`t1`.`a`) = `test`.`t2`.`c`))))) select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); @@ -2237,6 +2238,7 @@ Handler_read_key 5000 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 6003 @@ -2261,6 +2263,19 @@ PREPARE stmt FROM ' EXECUTE stmt; EXECUTE stmt; DROP TABLE t1,t2,t3; +# +# MDEV-10389: Query returns different results on a debug vs non-debug build of the same revision +# +CREATE TABLE t1 (i1 INT, i2 INT NOT NULL); +INSERT INTO t1 VALUES (1,4),(2,6); +SELECT * FROM t1 AS alias1 +WHERE alias1.i1 IN ( +SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 ) +); +i1 i2 +1 4 +2 6 +DROP TABLE t1; set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --git a/mysql-test/r/subselect_no_exists_to_in.result b/mysql-test/r/subselect_no_exists_to_in.result index aa6843409c0..f5191487ddf 100644 --- a/mysql-test/r/subselect_no_exists_to_in.result +++ b/mysql-test/r/subselect_no_exists_to_in.result @@ -6892,6 +6892,7 @@ Handler_read_key 8 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 @@ -6929,6 +6930,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -7157,8 +7159,24 @@ INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); f foo +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); +f +foo drop table t1; SET NAMES default; +# +# MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +# +SET NAMES utf8; +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +f1 f2 f3 +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); +f1 f2 f3 +DROP TABLE t1, t2; +SET NAMES default; +End of 10.1 tests set optimizer_switch=default; select @@optimizer_switch like '%exists_to_in=off%'; @@optimizer_switch like '%exists_to_in=off%' diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index 754aec1db20..14bd38175ce 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -6886,6 +6886,7 @@ Handler_read_key 8 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 @@ -6923,6 +6924,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -7150,8 +7152,24 @@ INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); f foo +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); +f +foo drop table t1; SET NAMES default; +# +# MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +# +SET NAMES utf8; +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +f1 f2 f3 +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); +f1 f2 f3 +DROP TABLE t1, t2; +SET NAMES default; +End of 10.1 tests set optimizer_switch=default; select @@optimizer_switch like '%materialization=on%'; @@optimizer_switch like '%materialization=on%' diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index e05dd4d140d..7964df42f88 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -6883,6 +6883,7 @@ Handler_read_key 8 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 @@ -6920,6 +6921,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -7148,6 +7150,22 @@ INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); f foo +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); +f +foo drop table t1; SET NAMES default; +# +# MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +# +SET NAMES utf8; +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +f1 f2 f3 +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); +f1 f2 f3 +DROP TABLE t1, t2; +SET NAMES default; +End of 10.1 tests set @optimizer_switch_for_subselect_test=null; diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result index 71ade62b423..650e7e1e2a6 100644 --- a/mysql-test/r/subselect_no_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -6898,6 +6898,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 58 @@ -6935,6 +6936,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -7163,8 +7165,24 @@ INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); f foo +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); +f +foo drop table t1; SET NAMES default; +# +# MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +# +SET NAMES utf8; +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +f1 f2 f3 +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); +f1 f2 f3 +DROP TABLE t1, t2; +SET NAMES default; +End of 10.1 tests set optimizer_switch=default; select @@optimizer_switch like '%subquery_cache=on%'; @@optimizer_switch like '%subquery_cache=on%' diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index 43d191b1225..2350100314b 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -6883,6 +6883,7 @@ Handler_read_key 8 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 @@ -6920,6 +6921,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 16 @@ -7148,7 +7150,23 @@ INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); f foo +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); +f +foo drop table t1; SET NAMES default; +# +# MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +# +SET NAMES utf8; +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +f1 f2 f3 +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); +f1 f2 f3 +DROP TABLE t1, t2; +SET NAMES default; +End of 10.1 tests set @optimizer_switch_for_subselect_test=null; set @join_cache_level_for_subselect_test=NULL; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index 2f3777a47fd..9aa223b83f2 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -1173,6 +1173,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1981 Aggregate function 'max()' of SELECT #3 belongs to SELECT #1 Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <`test`.`t1`.`a`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>((`test`.`t1`.`a`,(select `test`.`t2`.`c` from `test`.`t2` where ((<`test`.`t2`.`d`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>((`test`.`t2`.`d`,(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having ((`test`.`t2`.`d`) >= (`test`.`t3`.`e`)))))) and ((`test`.`t1`.`a`) = `test`.`t2`.`c`))))) select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); @@ -2277,6 +2278,7 @@ Handler_read_key 5000 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 6003 @@ -2301,3 +2303,16 @@ PREPARE stmt FROM ' EXECUTE stmt; EXECUTE stmt; DROP TABLE t1,t2,t3; +# +# MDEV-10389: Query returns different results on a debug vs non-debug build of the same revision +# +CREATE TABLE t1 (i1 INT, i2 INT NOT NULL); +INSERT INTO t1 VALUES (1,4),(2,6); +SELECT * FROM t1 AS alias1 +WHERE alias1.i1 IN ( +SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 ) +); +i1 i2 +1 4 +2 6 +DROP TABLE t1; diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result index ee0b3ab6d48..0ecdcf0058a 100644 --- a/mysql-test/r/temp_table.result +++ b/mysql-test/r/temp_table.result @@ -291,6 +291,9 @@ test.t1 repair status OK test.t2 repair status OK test.t3 repair status OK DROP TABLES t1, t2, t3; +CREATE TEMPORARY TABLE t1 (a int); +RENAME TABLE t1 TO t2; +DROP TABLE t2; create temporary temporary table t1 (a int); 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 'temporary table t1 (a int)' at line 1 flush status; diff --git a/mysql-test/r/trigger_null-8605.result b/mysql-test/r/trigger_null-8605.result index e024bc6b7d2..b187fc19554 100644 --- a/mysql-test/r/trigger_null-8605.result +++ b/mysql-test/r/trigger_null-8605.result @@ -318,9 +318,8 @@ id delete from t1; create trigger t1_bi before insert on t1 for each row begin end; insert t1 values (0); -select * from t1; -id -0 +insert t1 (id) values (0); +ERROR 23000: Duplicate entry '0' for key 'PRIMARY' drop table t1; create table t1 (a int not null, b int); create trigger trgi before update on t1 for each row do 1; diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 55de3b39f2d..d2587d7199e 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -165,6 +165,7 @@ str_to_date( '', a ) NULL DROP TABLE t1; CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); +SET timestamp=UNIX_TIMESTAMP('2016-07-21 14:48:18'); INSERT INTO t1 VALUES (DATE(NOW()), 1); SELECT COUNT(*) FROM t1 WHERE a = NOW(); COUNT(*) @@ -192,6 +193,7 @@ COUNT(*) EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SET timestamp=DEFAULT; DROP TABLE t1; CREATE TABLE t1 (a DATE); CREATE TABLE t2 (a DATE); @@ -440,6 +442,7 @@ select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1; drop table t1; # # MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null +# MDEV-9972 Least function retuns date in date time format # CREATE TABLE t1 ( id BIGINT NOT NULL, diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 16990c2414d..bf09ec8d0eb 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -834,6 +834,14 @@ a b a b DEALLOCATE PREPARE stmt1; DROP TABLE t1,t2; # +# MDEV-9374 having '2015-01-01 01:00:00.000001' > coalesce(NULL) returns true +# +CREATE TABLE t1 (c1 DATETIME(0)); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 HAVING '2015-01-01 01:00:00.000001' > COALESCE(c1); +c1 +DROP TABLE t1; +# # End of 5.5 tests # # diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 1942d07c9ab..2f6a3ea2a61 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -2151,5 +2151,95 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a a 6 const 1 Using where; Using index; Using filesort DROP TABLE t1; # +# MDEV-8502 DECIMAL accepts out of range DEFAULT values +# +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000.0); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000e0); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '10000.0'); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '10000.1'); +ERROR 42000: Invalid default value for 'a' +# +# MDEV-10277 Redundant NOTE when inserting '0.00001 ' into a DECIMAL(2,1) column +# +CREATE TABLE t1 (a DECIMAL(2,1)); +INSERT INTO t1 VALUES ('0.00001 '); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1e-10000 '); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('0.1 '); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('0.111 '); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +0.0 +0.0 +0.1 +0.1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '1e-10000'); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(2,1) DEFAULT '0.0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '0.1 '); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(2,1) DEFAULT '0.1' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '0.10001 '); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(2,1) DEFAULT '0.1' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '0.10001'); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(2,1) DEFAULT '0.1' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 0.10001); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(2,1) DEFAULT '0.1' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 0.10001e0); +Warnings: +Note 1265 Data truncated for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` decimal(2,1) DEFAULT '0.1' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index a0c35c6e0ca..49141e33709 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -276,6 +276,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -289,6 +290,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 2 Handler_read_rnd_deleted 0 Handler_read_rnd_next 9 @@ -301,6 +303,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -313,6 +316,7 @@ Handler_read_key 0 Handler_read_last 1 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -326,6 +330,7 @@ Handler_read_key 0 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 2 Handler_read_rnd_next 7 @@ -381,6 +386,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 1 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 1 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -420,6 +426,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -432,6 +439,7 @@ Handler_read_key 2 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -443,6 +451,7 @@ Handler_read_key 3 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -454,6 +463,7 @@ Handler_read_key 3 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -699,6 +709,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 1 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 2 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/mysql-test/r/userstat.result b/mysql-test/r/userstat.result index 5ce10d96643..f818ab9c0a7 100644 --- a/mysql-test/r/userstat.result +++ b/mysql-test/r/userstat.result @@ -119,6 +119,7 @@ Handler_read_key 9 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 5 @@ -135,16 +136,12 @@ handler_read_key set @@global.userstat=0; select * from information_schema.index_statistics; TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ -test t1 PRIMARY 2 select * from information_schema.table_statistics; TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES -test t1 6 13 13 show table_statistics; Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes -test t1 6 13 13 show index_statistics; Table_schema Table_name Index_name Rows_read -test t1 PRIMARY 2 select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;; TOTAL_CONNECTIONS 2 TOTAL_SSL_CONNECTIONS 1 diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index d4a2a9b1b79..f695419903e 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4265,6 +4265,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -4288,6 +4289,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 17 @@ -5551,6 +5553,21 @@ test.v1 check Error 'test.v1' is not BASE TABLE test.v1 check status Operation failed drop view v1; drop table t1; +# +# MDEV-10419: crash in mariadb 10.1.16-MariaDB-1~trusty +# +CREATE TABLE t1 (c1 CHAR(13)); +CREATE TABLE t2 (c2 CHAR(13)); +CREATE FUNCTION f() RETURNS INT RETURN 0; +CREATE OR REPLACE VIEW v1 AS select f() from t1 where c1 in (select c2 from t2); +DROP FUNCTION f; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `f`() AS `f()` from `t1` where `test`.`t1`.`c1` in (select `test`.`t2`.`c2` from `t2`) latin1 latin1_swedish_ci +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1; +drop table t1,t2; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/r/xtradb_mrr.result b/mysql-test/r/xtradb_mrr.result index 15b750d2fd3..c238d0530af 100644 --- a/mysql-test/r/xtradb_mrr.result +++ b/mysql-test/r/xtradb_mrr.result @@ -311,10 +311,10 @@ concat('c-', 1000 + C.a, '-c'), 'filler' from t1 A, t1 B, t1 C; explain -select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a'; +select count(length(a) + length(filler)) from t2 force index (a) where a>='a-1000-a' and a <'a-1001-a'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range a a 9 NULL 99 Using index condition; Rowid-ordered scan -select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a'; +select count(length(a) + length(filler)) from t2 force index (a) where a>='a-1000-a' and a <'a-1001-a'; count(length(a) + length(filler)) 100 drop table t2; diff --git a/mysql-test/std_data/Index.xml b/mysql-test/std_data/Index.xml index 5139db0554a..b66fdfee55c 100644 --- a/mysql-test/std_data/Index.xml +++ b/mysql-test/std_data/Index.xml @@ -1117,6 +1117,16 @@ + + + \u3400b + a\u3561 + c\u1500 + \u3600\u1501 + \u3700\u3701 + + + diff --git a/mysql-test/std_data/bug20683959loaddata.txt b/mysql-test/std_data/bug20683959loaddata.txt new file mode 100644 index 00000000000..1878cc78879 --- /dev/null +++ b/mysql-test/std_data/bug20683959loaddata.txt @@ -0,0 +1 @@ +Ã"RT @niouzechun: 遘√õ€�®繝上ャ繝斐õ€‡³繧ィ繝ウ繝牙耳縺ェ繧薙□縺代l縺ゥ縲√い繝ウ繝上ャ繝斐õ€‡³繧ィ繝ウ繝峨d諠ィ蜉õ€”Ž噪縺ェ縺願ゥア繧偵≠縺セ繧顔ゥ肴・オ逧õ€‹–↓鞫ょ叙縺励↑縺õ€‹š炊逕ア縺ッ縲∫樟螳溘õ€�­莠コ逕溘õ€�®蝓コ譛ャ逧õ€‹–↓縺õ€‘Ž∪縺上>縺九↑縺õ€‹–@荳榊ケウ遲峨□縺礼炊荳榊ース縺 縺苓セ帙> diff --git a/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result b/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result new file mode 100644 index 00000000000..b366bde4daf --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_dmls_on_tmp_tables_readonly.result @@ -0,0 +1,59 @@ +DROP TABLE IF EXISTS t1 ; +# READ_ONLY does nothing to SUPER users +# so we use a non-SUPER one: +CREATE USER test@localhost; +GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; +connect con1,localhost,test,,test; +connection default; +SET GLOBAL READ_ONLY=1; +connection con1; +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB; +# Test INSERTS with autocommit being off and on. +BEGIN; +INSERT INTO t1 VALUES (10); +COMMIT; +INSERT INTO t1 VALUES (20); +# Test UPDATES with autocommit being off and on. +BEGIN; +UPDATE t1 SET a=30 WHERE a=10; +COMMIT; +UPDATE t1 SET a=40 WHERE a=20; +connection default; +SET GLOBAL READ_ONLY=0; +# Test scenario where global read_only is enabled in the middle of transaction. +# Test INSERT operations on temporary tables, INSERTs should be successful even +# when global read_only is enabled. +connection con1; +BEGIN; +INSERT INTO t1 VALUES(50); +connection default; +SET GLOBAL READ_ONLY=1; +connection con1; +SELECT @@GLOBAL.READ_ONLY; +@@GLOBAL.READ_ONLY +1 +COMMIT; +connection default; +SET GLOBAL READ_ONLY=0; +# Test UPDATE operations on temporary tables, UPDATEs should be successful even +# when global read_only is enabled. +connection con1; +BEGIN; +UPDATE t1 SET a=60 WHERE a=50; +connection default; +SET GLOBAL READ_ONLY=1; +connection con1; +SELECT @@GLOBAL.READ_ONLY; +@@GLOBAL.READ_ONLY +1 +COMMIT; +SELECT * FROM t1; +a +30 +40 +60 +# Clean up +connection default; +SET GLOBAL READ_ONLY=0; +disconnect con1; +DROP USER test@localhost; diff --git a/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test b/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test new file mode 100644 index 00000000000..0fa35d57745 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test @@ -0,0 +1,92 @@ +# ==== Purpose ==== +# +# Check that DMLs are allowed on temporary tables, when server is in read only +# mode and binary log is enabled with binlog-format being stmt/mixed mode. +# +# ==== Implementation ==== +# +# Start the server with binary log being enabled. Mark the server as read only. +# Create a non-SUPER user and let the user to create a temporary table and +# perform DML operations on that temporary table. DMLs should not be blocked +# with a 'server read-only mode' error. +# +# ==== References ==== +# +# Bug#12818255: READ-ONLY OPTION DOES NOT ALLOW INSERTS/UPDATES ON TEMPORARY +# TABLES +# Bug#14294223: CHANGES NOT ALLOWED TO TEMPORARY TABLES ON READ-ONLY SERVERS +############################################################################### +--source include/have_log_bin.inc +--source include/have_innodb.inc +--disable_warnings +DROP TABLE IF EXISTS t1 ; +--enable_warnings + +--enable_connect_log +--echo # READ_ONLY does nothing to SUPER users +--echo # so we use a non-SUPER one: +CREATE USER test@localhost; +GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; + +connect (con1,localhost,test,,test); + +connection default; +SET GLOBAL READ_ONLY=1; + +connection con1; +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB; + +--echo # Test INSERTS with autocommit being off and on. +BEGIN; +INSERT INTO t1 VALUES (10); +COMMIT; +INSERT INTO t1 VALUES (20); + +--echo # Test UPDATES with autocommit being off and on. +BEGIN; +UPDATE t1 SET a=30 WHERE a=10; +COMMIT; +UPDATE t1 SET a=40 WHERE a=20; + +connection default; +SET GLOBAL READ_ONLY=0; + +--echo # Test scenario where global read_only is enabled in the middle of transaction. +--echo # Test INSERT operations on temporary tables, INSERTs should be successful even +--echo # when global read_only is enabled. +connection con1; +BEGIN; +INSERT INTO t1 VALUES(50); + +connection default; +SET GLOBAL READ_ONLY=1; + +connection con1; +SELECT @@GLOBAL.READ_ONLY; +COMMIT; + +connection default; +SET GLOBAL READ_ONLY=0; + +--echo # Test UPDATE operations on temporary tables, UPDATEs should be successful even +--echo # when global read_only is enabled. +connection con1; +BEGIN; +UPDATE t1 SET a=60 WHERE a=50; + +connection default; +SET GLOBAL READ_ONLY=1; + +connection con1; +SELECT @@GLOBAL.READ_ONLY; +COMMIT; + +SELECT * FROM t1; + +--echo # Clean up +connection default; +SET GLOBAL READ_ONLY=0; + +disconnect con1; +DROP USER test@localhost; +--disable_connect_log diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc index e19f8b4f820..cd060e7a370 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc @@ -152,7 +152,7 @@ connection default; let $wait_timeout= 10; let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST -WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1'; +WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1' AND state=''; --source include/wait_condition.inc --replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" eval SHOW CREATE TABLE $table; diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 25f20e01521..5f8d9c6ddff 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -28,3 +28,5 @@ galera_flush : mysql-wsrep/issues/229 galera_transaction_read_only : mysql-wsrep/issues/229 galera_gcs_fragment : Incorrect arguments to SET galera_flush_local : Fails sporadically +galera_binlog_stmt_autoinc : TODO: investigate +galera_concurrent_ctas : Test times out, investigate diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index 1dbaad4f699..e5cf769a910 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -9,7 +9,6 @@ default-storage-engine=innodb wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 # enforce read-committed characteristics across the cluster -wsrep-causal-reads=ON wsrep-sync-wait=7 [mysqld.1] @@ -17,7 +16,7 @@ wsrep-sync-wait=7 #ist_port=@OPT.port #sst_port=@OPT.port wsrep-cluster-address=gcomm:// -wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;gcache.size=10M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' @@ -26,7 +25,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;gcache.size=10M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' diff --git a/mysql-test/suite/galera/include/auto_increment_offset_restore.inc b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc new file mode 100644 index 00000000000..6218dfd6f2c --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc @@ -0,0 +1,35 @@ +# See auto_increment_offset_restore.inc for details. + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_1) +{ + --die ERROR IN TEST: $auto_increment_offset_node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_2) +{ + --die ERROR IN TEST: $auto_increment_offset_node_2 must be set before sourcing auto_increment_offset_save.inc +} + +# Restore original auto_increment_offset values. +--disable_query_log +--connection $node_1 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; +--connection $node_2 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; + +if ($node_3) +{ +--connection $node_3 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; +} +--enable_query_log diff --git a/mysql-test/suite/galera/include/auto_increment_offset_save.inc b/mysql-test/suite/galera/include/auto_increment_offset_save.inc new file mode 100644 index 00000000000..3c4db3f381c --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_save.inc @@ -0,0 +1,37 @@ +# This file can be used to save the @@global.auto_increment_offset value at +# the beginning of any test that intends to restart any of the participating +# nodes. This is required as the node may get auto-assigned a different +# auto_increment_offset value on restart, which could cause MTR's internal +# post-check to fail. auto_increment_offset_restore.inc can be used at the +# end of the test to restore these saved values. + +# Parameters +# ---------- +# $node_1 +# Connection handle for 1st node +# $node_2 +# Connection handle for 2nd node +# $node_3 (optional) +# Connection handle for 3rd node + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +--connection $node_1 +let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; +--connection $node_2 +let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; + +if ($node_3) +{ + --connection $node_3 + let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +} + diff --git a/mysql-test/suite/galera/r/GAL-382.result b/mysql-test/suite/galera/r/GAL-382.result new file mode 100644 index 00000000000..0c7365f3005 --- /dev/null +++ b/mysql-test/suite/galera/r/GAL-382.result @@ -0,0 +1,6 @@ +create table t1 (i int, j int, k int, primary key pk(i)) engine=innodb; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +create table t2 (i int, j int, k int, primary key pk(i, j, k), index idx(i, k, j)) engine=innodb; +replace into t2 (i, j, k) select /*!99997 */ i, k, j from t1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/MW-252.result b/mysql-test/suite/galera/r/MW-252.result new file mode 100644 index 00000000000..c422edcb82a --- /dev/null +++ b/mysql-test/suite/galera/r/MW-252.result @@ -0,0 +1,7 @@ +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +FLUSH TABLES WITH READ LOCK; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 +1 +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/MW-258.result b/mysql-test/suite/galera/r/MW-258.result new file mode 100644 index 00000000000..1b4d4ae0de8 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-258.result @@ -0,0 +1,34 @@ +CREATE TABLE t1 (f1 INTEGER); +LOCK TABLE t1 WRITE; +value prior to RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +ALTER TABLE t1 ADD COLUMN f2 INTEGER;; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +ALTER TABLE t1 ADD COLUMN f3 INTEGER;; +value during RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 2 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +UNLOCK TABLES; +value after RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +Variable_name Value +wsrep_desync_count 0 +SHOW VARIABLES LIKE 'wsrep_desync'; +Variable_name Value +wsrep_desync OFF +SET GLOBAL wsrep_desync=0; +Warnings: +Warning 1231 'wsrep_desync' is already OFF. +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/MW-259.result b/mysql-test/suite/galera/r/MW-259.result new file mode 100644 index 00000000000..df76e959de5 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-259.result @@ -0,0 +1,12 @@ +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET GLOBAL wsrep_desync=0; +Warnings: +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;; +SET GLOBAL wsrep_desync=1;; +SET DEBUG_SYNC= 'now SIGNAL continue'; +DROP TABLE t1; +SET GLOBAL wsrep_desync=0; +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/r/MW-284.result b/mysql-test/suite/galera/r/MW-284.result new file mode 100644 index 00000000000..3ff131674ea --- /dev/null +++ b/mysql-test/suite/galera/r/MW-284.result @@ -0,0 +1,14 @@ +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +START SLAVE; +include/wait_for_slave_param.inc [Slave_IO_Running] +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +include/wait_for_slave_to_start.inc +INSERT INTO t1 VALUES (1); +DROP TABLE t1; +STOP SLAVE; +RESET SLAVE ALL; +CALL mtr.add_suppression('failed registering on master'); +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/r/MW-285.result b/mysql-test/suite/galera/r/MW-285.result new file mode 100644 index 00000000000..8c5a21fcbee --- /dev/null +++ b/mysql-test/suite/galera/r/MW-285.result @@ -0,0 +1,19 @@ +CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; +CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; +CREATE TABLE child ( +id INT PRIMARY KEY, +parent1_id INT, +parent2_id INT, +FOREIGN KEY (parent1_id) REFERENCES parent1(id), +FOREIGN KEY (parent1_id) REFERENCES parent2(id) +) ENGINE=InnoDB; +INSERT INTO parent1 VALUES (1); +INSERT INTO parent2 VALUES (1); +INSERT INTO child VALUES (1,1,1); +INSERT INTO child VALUES (2,1,1); +SET foreign_key_checks=OFF; +DROP TABLE parent1; +UPDATE child SET parent1_id=2 WHERE id=1; +DROP TABLE child; +DROP TABLE parent2; +SET foreign_key_checks=ON; diff --git a/mysql-test/suite/galera/r/MW-286.result b/mysql-test/suite/galera/r/MW-286.result new file mode 100644 index 00000000000..adc996c1cbe --- /dev/null +++ b/mysql-test/suite/galera/r/MW-286.result @@ -0,0 +1,13 @@ +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;; +SET GLOBAL wsrep_desync = TRUE; +SET wsrep_on = FALSE; +ALTER TABLE t1 ADD PRIMARY KEY (f1); +ERROR 70100: Query execution was interrupted +SET wsrep_on = TRUE; +SET GLOBAL wsrep_desync = FALSE; +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/MW-292.result b/mysql-test/suite/galera/r/MW-292.result new file mode 100644 index 00000000000..f038f880efa --- /dev/null +++ b/mysql-test/suite/galera/r/MW-292.result @@ -0,0 +1,30 @@ +CREATE TABLE rand_table (f1 FLOAT); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (2, 'a'); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE t1 SET f2 = 'b' WHERE f1 = 1; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; +f1 f2 +2 a +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; +COMMIT;; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +UPDATE t1 SET f2 = 'c' WHERE f1 = 2; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; +SELECT TIMEDIFF(SYSDATE(), NOW()) < 2; +TIMEDIFF(SYSDATE(), NOW()) < 2 +1 +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +SELECT COUNT(DISTINCT f1) = 10 FROM rand_table; +COUNT(DISTINCT f1) = 10 +1 +wsrep_local_replays +1 +DROP TABLE t1; +DROP TABLE rand_table; diff --git a/mysql-test/suite/galera/r/MW-44.result b/mysql-test/suite/galera/r/MW-44.result new file mode 100644 index 00000000000..28a6f1ac8dd --- /dev/null +++ b/mysql-test/suite/galera/r/MW-44.result @@ -0,0 +1,14 @@ +TRUNCATE TABLE mysql.general_log; +TRUNCATE TABLE mysql.general_log; +SET SESSION wsrep_osu_method=TOI; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET SESSION wsrep_osu_method=RSU; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +SET SESSION wsrep_osu_method=TOI; +SELECT COUNT(*) = 2 FROM mysql.general_log WHERE argument LIKE 'CREATE%' OR argument LIKE 'ALTER%'; +COUNT(*) = 2 +1 +SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument NOT LIKE 'SELECT%'; +COUNT(*) = 0 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/create.result b/mysql-test/suite/galera/r/create.result index d23fb186f5e..99b8022393d 100644 --- a/mysql-test/suite/galera/r/create.result +++ b/mysql-test/suite/galera/r/create.result @@ -68,4 +68,17 @@ CREATE TABLE `t2` (`c1` INT) ENGINE=INNODB SELECT * FROM t1; COMMIT; SET autocommit=1; DROP TABLE t1, t2; +# +# MDEV-10235: Deadlock in CREATE TABLE ... AS SELECT .. if result set +# is empty in Galera +# +CREATE TABLE t1(c1 INT) ENGINE=INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t2 AS SELECT * FROM t1 WHERE c1=2; +SELECT * FROM t1; +c1 +1 +SELECT * FROM t2; +c1 +DROP TABLE t1, t2; # End of tests diff --git a/mysql-test/suite/galera/r/galera#414.result b/mysql-test/suite/galera/r/galera#414.result new file mode 100644 index 00000000000..029961f9463 --- /dev/null +++ b/mysql-test/suite/galera/r/galera#414.result @@ -0,0 +1,5 @@ +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +CALL mtr.add_suppression("Failed to set packet size"); +CALL mtr.add_suppression("Failed to set packet size"); diff --git a/mysql-test/suite/galera/r/galera_as_master.result b/mysql-test/suite/galera/r/galera_as_master.result index d87a744000c..e96d39aea0c 100644 --- a/mysql-test/suite/galera/r/galera_as_master.result +++ b/mysql-test/suite/galera/r/galera_as_master.result @@ -46,3 +46,4 @@ SET SQL_LOG_BIN=OFF; DROP TABLE t2, t3; STOP SLAVE; RESET SLAVE ALL; +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result new file mode 100644 index 00000000000..b6314b862c2 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result @@ -0,0 +1,82 @@ +START SLAVE; +SET SESSION binlog_format='STATEMENT'; +CREATE TABLE t1 ( +i int(11) NOT NULL AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text', +PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +insert into t1(i) values(null); +select * from t1; +i c +1 dummy_text +insert into t1(i) values(null), (null), (null); +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +SET SESSION auto_increment_increment=7; +insert into t1(i) values(null), (null), (null); +SET SESSION auto_increment_offset=5; +insert into t1(i) values(null), (null), (null); +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +8 dummy_text +15 dummy_text +22 dummy_text +33 dummy_text +40 dummy_text +47 dummy_text +show variables like 'binlog_format'; +Variable_name Value +binlog_format STATEMENT +show variables like '%auto_increment%'; +Variable_name Value +auto_increment_increment 7 +auto_increment_offset 5 +wsrep_auto_increment_control ON +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +8 dummy_text +15 dummy_text +22 dummy_text +33 dummy_text +40 dummy_text +47 dummy_text +show variables like 'binlog_format'; +Variable_name Value +binlog_format ROW +show variables like 'auto_increment_increment'; +Variable_name Value +auto_increment_increment 2 +select * from t1; +i c +1 dummy_text +2 dummy_text +3 dummy_text +4 dummy_text +8 dummy_text +15 dummy_text +22 dummy_text +33 dummy_text +40 dummy_text +47 dummy_text +show variables like 'binlog_format'; +Variable_name Value +binlog_format ROW +show variables like 'auto_increment_increment'; +Variable_name Value +auto_increment_increment 2 +DROP TABLE t1; +STOP SLAVE; +RESET SLAVE ALL; +RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result index fd20f8db2f9..365ea31f292 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result +++ b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result @@ -12,7 +12,7 @@ STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); -CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)"); +CALL mtr.add_suppression("Transport endpoint is not connected"); CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213"); CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); RESET MASTER; 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..96ed226c3ab 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 @@ -6,9 +6,10 @@ SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; -SELECT * FROM t1; -f1 -2 +SET SESSION wsrep_sync_wait = 7; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 wsrep_local_aborts_increment 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 6879ecf67fc..b6a16f72ec3 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -32,8 +32,8 @@ WSREP_GTID_DOMAIN_ID 0 WSREP_GTID_MODE OFF WSREP_LOAD_DATA_SPLITTING ON WSREP_LOG_CONFLICTS OFF -WSREP_MAX_WS_ROWS 131072 -WSREP_MAX_WS_SIZE 1073741824 +WSREP_MAX_WS_ROWS 0 +WSREP_MAX_WS_SIZE 2147483647 WSREP_MYSQL_REPLICATION_BUNDLE 0 WSREP_NOTIFY_CMD WSREP_ON ON @@ -50,12 +50,12 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 7 -; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 10M; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; +; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; COUNT(*) -57 +58 SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters' @@ -76,6 +76,7 @@ WSREP_COMMIT_OOOE WSREP_COMMIT_OOOL WSREP_COMMIT_WINDOW WSREP_CONNECTED +WSREP_DESYNC_COUNT WSREP_EVS_DELAYED WSREP_EVS_EVICT_LIST WSREP_EVS_REPL_LATENCY 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..9463b5f8eef 100644 --- a/mysql-test/suite/galera/r/galera_gcs_fc_limit.result +++ b/mysql-test/suite/galera/r/galera_gcs_fc_limit.result @@ -4,7 +4,7 @@ SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; -FLUSH TABLES WITH READ LOCK; +LOCK TABLE t1 WRITE; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (4); diff --git a/mysql-test/suite/galera/r/galera_ist_recv_bind.result b/mysql-test/suite/galera/r/galera_ist_recv_bind.result new file mode 100644 index 00000000000..de4e07fbe41 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_recv_bind.result @@ -0,0 +1,13 @@ +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; +@@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%' +1 +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; +@@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%' +1 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_kill_ddl.result b/mysql-test/suite/galera/r/galera_kill_ddl.result index 8dd36497dfb..b83226bbd42 100644 --- a/mysql-test/suite/galera/r/galera_kill_ddl.result +++ b/mysql-test/suite/galera/r/galera_kill_ddl.result @@ -5,7 +5,4 @@ ALTER TABLE t1 ADD COLUMN f2 INTEGER; 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 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_log_output_csv.result b/mysql-test/suite/galera/r/galera_log_output_csv.result index 07a78469578..cdb5ee49f3e 100644 --- a/mysql-test/suite/galera/r/galera_log_output_csv.result +++ b/mysql-test/suite/galera/r/galera_log_output_csv.result @@ -9,9 +9,6 @@ SELECT 1 = 1 FROM t1; SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 1 = 1 FROM t1'; COUNT(*) = 1 1 -SELECT COUNT(*) > 0 FROM mysql.general_log WHERE argument = 'CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB'; -COUNT(*) > 0 -1 SELECT 2 = 2 FROM t1; 2 = 2 1 diff --git a/mysql-test/suite/galera/r/galera_parallel_simple.result b/mysql-test/suite/galera/r/galera_parallel_simple.result index 294a94baed3..6d023c38a57 100644 --- a/mysql-test/suite/galera/r/galera_parallel_simple.result +++ b/mysql-test/suite/galera/r/galera_parallel_simple.result @@ -1,6 +1,7 @@ CREATE TABLE t1 (id INT) ENGINE=InnoDB; CREATE TABLE t2 (id INT) ENGINE=InnoDB; SET GLOBAL wsrep_slave_threads = 2; +LOCK TABLE t1 WRITE; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); INSERT INTO t1 VALUES (1); @@ -13,15 +14,15 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); +SET SESSION wsrep_sync_wait = 0; +UNLOCK TABLES; +SET SESSION wsrep_sync_wait = 7; SELECT COUNT(*) = 10 FROM t1; COUNT(*) = 10 0 SELECT COUNT(*) = 10 FROM t2; COUNT(*) = 10 0 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'committed%'; -COUNT(*) = 2 -1 SET GLOBAL wsrep_slave_threads = 1;; DROP TABLE t1; DROP TABLE t2; 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..f7914a1b803 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 @@ -6,3 +6,7 @@ SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 DROP TABLE t1; +CALL mtr.add_suppression("Maximum writeset size exceeded by"); +CALL mtr.add_suppression("transaction size limit"); +CALL mtr.add_suppression("transaction size exceeded"); +CALL mtr.add_suppression("rbr write fail"); diff --git a/mysql-test/suite/galera/r/galera_roles.result b/mysql-test/suite/galera/r/galera_roles.result index c0cdbc0e338..6312250c18d 100644 --- a/mysql-test/suite/galera/r/galera_roles.result +++ b/mysql-test/suite/galera/r/galera_roles.result @@ -69,8 +69,8 @@ SET ROLE role1; FLUSH TABLES; SELECT * FROM mysql.roles_mapping; Host User Role Admin_option - role1 Y localhost foo role1 N +localhost root role1 Y SHOW TABLES FROM test1; Tables_in_test1 t1 @@ -153,4 +153,43 @@ role1 # Connect with node_1 DROP USER foo@localhost; DROP DATABASE test1; +# +# MDEV-10566: Create role statement replicated inconsistently in Galera Cluster +# + +# On node_1 +CREATE USER foo@localhost; +CREATE ROLE role1; +CREATE ROLE role2 WITH ADMIN CURRENT_USER; +CREATE ROLE role3 WITH ADMIN foo@localhost; +CREATE ROLE role4 WITH ADMIN role1; +SELECT * FROM mysql.roles_mapping; +Host User Role Admin_option + role1 role4 Y +localhost foo role3 Y +localhost root role1 Y +localhost root role2 Y +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; +GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT +role1 role4 YES NULL +root@localhost role1 YES NO +root@localhost role2 YES NO + +# On node_2 +SELECT * FROM mysql.roles_mapping; +Host User Role Admin_option + role1 role4 Y +localhost foo role3 Y +localhost root role1 Y +localhost root role2 Y +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; +GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT +role1 role4 YES NULL +root@localhost role1 YES NO +root@localhost role2 YES NO +DROP ROLE role1; +DROP ROLE role2; +DROP ROLE role3; +DROP ROLE role4; +DROP USER foo@localhost; # End of test 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..08980389392 100644 --- a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result +++ b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result @@ -22,12 +22,11 @@ SET GLOBAL wsrep_desync=0; Warnings: Warning 1231 'wsrep_desync' is already OFF. SET wsrep_OSU_method=RSU; -SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +SET DEBUG_SYNC = 'alter_table_before_create_table_no_lock WAIT_FOR continue'; ALTER TABLE t1 ADD COLUMN f2 INTEGER;; -SET GLOBAL wsrep_desync=1; -ERROR HY000: Operation 'desync' failed for SET GLOBAL wsrep_desync=1 -SET GLOBAL wsrep_desync=0; +SET GLOBAL wsrep_desync=1;; SET DEBUG_SYNC= 'now SIGNAL continue'; +SET GLOBAL wsrep_desync=0; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/galera_ssl_upgrade.result b/mysql-test/suite/galera/r/galera_ssl_upgrade.result index c0f2e84dc6f..b24671d120d 100644 --- a/mysql-test/suite/galera/r/galera_ssl_upgrade.result +++ b/mysql-test/suite/galera/r/galera_ssl_upgrade.result @@ -4,21 +4,12 @@ VARIABLE_VALUE = 'Synced' SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 -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 -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 diff --git a/mysql-test/suite/galera/r/galera_transaction_replay.result b/mysql-test/suite/galera/r/galera_transaction_replay.result index bfafa506fe6..eec9ba03ef5 100644 --- a/mysql-test/suite/galera/r/galera_transaction_replay.result +++ b/mysql-test/suite/galera/r/galera_transaction_replay.result @@ -30,3 +30,30 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; COUNT(*) = 1 1 DROP TABLE t1; +CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 0), (3, 0); +SELECT * FROM t1; +i j +1 0 +3 0 +PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0"; +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; +EXECUTE stmt1;; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +INSERT INTO t1 VALUES(2,2); +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; +SELECT * FROM t1; +i j +1 1 +2 2 +3 1 +SELECT * FROM t1; +i j +1 1 +2 2 +3 1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; 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..f286ae72308 100644 --- a/mysql-test/suite/galera/r/galera_var_desync_on.result +++ b/mysql-test/suite/galera/r/galera_var_desync_on.result @@ -26,4 +26,6 @@ INSERT INTO t1 VALUES (11); SELECT COUNT(*) = 11 FROM t1; COUNT(*) = 11 1 +CALL mtr.add_suppression("Protocol violation"); DROP TABLE t1; +CALL mtr.add_suppression("Protocol violation"); diff --git a/mysql-test/suite/galera/r/galera_var_max_ws_rows.result b/mysql-test/suite/galera/r/galera_var_max_ws_rows.result new file mode 100644 index 00000000000..6e239c70a3e --- /dev/null +++ b/mysql-test/suite/galera/r/galera_var_max_ws_rows.result @@ -0,0 +1,115 @@ +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; +SET GLOBAL wsrep_max_ws_rows = 4; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +INSERT INTO t1 (f2) VALUES (5); +ERROR HY000: wsrep_max_ws_rows exceeded +COMMIT; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +UPDATE t1 SET f2 = 10 WHERE f2 = 4; +ERROR HY000: wsrep_max_ws_rows exceeded +COMMIT; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +DELETE FROM t1 WHERE f2 = 1; +ERROR HY000: wsrep_max_ws_rows exceeded +COMMIT; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET GLOBAL wsrep_max_ws_rows = 5; +INSERT INTO t1 (f2) VALUES (1),(2),(3),(4),(5); +SET GLOBAL wsrep_max_ws_rows = 4; +UPDATE t1 SET f2 = f2 + 10; +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +DELETE FROM t1 WHERE f2 < 10; +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +INSERT INTO t1 (f2) SELECT * FROM ten; +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +INSERT INTO t1 (f2) VALUES (10),(20),(30),(40),(50); +ERROR HY000: wsrep_max_ws_rows exceeded +SELECT COUNT(*) = 5 FROM t1; +COUNT(*) = 5 +1 +SET GLOBAL wsrep_max_ws_rows = 10; +DELETE FROM t1 WHERE f2 < 10; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET GLOBAL wsrep_max_ws_rows = 100; +SELECT COUNT(*) = 100 FROM t1; +COUNT(*) = 100 +1 +DELETE FROM t1 WHERE f2 < 101; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET GLOBAL wsrep_max_ws_rows = 9999; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +ERROR HY000: wsrep_max_ws_rows exceeded +SET GLOBAL wsrep_max_ws_rows = 10000; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +SET GLOBAL wsrep_max_ws_rows = 9999; +UPDATE t1 SET f2 = 2 WHERE f2 = 1; +ERROR HY000: wsrep_max_ws_rows exceeded +SET GLOBAL wsrep_max_ws_rows = 10000; +UPDATE t1 SET f2 = 2 WHERE f2 = 1; +SET GLOBAL wsrep_max_ws_rows = 9999; +DELETE FROM t1 WHERE f2 = 2; +ERROR HY000: wsrep_max_ws_rows exceeded +SET GLOBAL wsrep_max_ws_rows = 10000; +DELETE FROM t1 WHERE f2 = 2; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET AUTOCOMMIT = ON; +SET GLOBAL wsrep_max_ws_rows = 1; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +SET AUTOCOMMIT = OFF; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +ERROR HY000: wsrep_max_ws_rows exceeded +DROP TABLE t1; +DROP TABLE ten; 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..fe92fd888e5 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 @@ -5,4 +5,13 @@ ERROR HY000: Got error 90 "Message too long" during COMMIT SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; +SELECT @@wsrep_max_ws_size = 10000; +@@wsrep_max_ws_size = 10000 +1 +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=20000'; +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; +SET GLOBAL wsrep_max_ws_size = 20000; +provider_options_match +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..df9cdfbd159 100644 --- a/mysql-test/suite/galera/r/galera_var_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_var_sync_wait.result @@ -1,3 +1,12 @@ +# +# MDEV-10161: wsrep_sync_wait not enabled when set to 1 in config file +# +SELECT @@global.wsrep_sync_wait; +@@global.wsrep_sync_wait +7 +SELECT @@global.wsrep_causal_reads; +@@global.wsrep_causal_reads +1 CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; SET GLOBAL wsrep_sync_wait = 1; SHOW TABLES LIKE '%t1'; diff --git a/mysql-test/suite/galera/r/mdev_10518.result b/mysql-test/suite/galera/r/mdev_10518.result new file mode 100644 index 00000000000..b2a3e0a65ef --- /dev/null +++ b/mysql-test/suite/galera/r/mdev_10518.result @@ -0,0 +1,74 @@ +# On node_1 +list of GTID variables : +gtid_domain_id 1 +gtid_binlog_pos +gtid_binlog_state +gtid_current_pos +gtid_slave_pos +wsrep_gtid_domain_id 4294967295 +wsrep_gtid_mode 1 +# On node_2 +list of GTID variables : +gtid_domain_id 2 +gtid_binlog_pos +gtid_binlog_state +gtid_current_pos +gtid_slave_pos +wsrep_gtid_domain_id 4294967295 +wsrep_gtid_mode 1 +# On node_1 +CREATE TABLE t1(i INT) ENGINE=INNODB; +CREATE TABLE t2(i INT) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1); +SELECT * FROM t1; +i +1 +SELECT * FROM t2; +i +list of GTID variables : +gtid_domain_id 1 +gtid_binlog_pos 4294967295-1-3 +gtid_binlog_state 4294967295-1-3 +gtid_current_pos 4294967295-1-3 +gtid_slave_pos +wsrep_gtid_domain_id 4294967295 +wsrep_gtid_mode 1 +# On node_2 +SELECT * FROM t1; +i +1 +list of GTID variables : +gtid_domain_id 2 +gtid_binlog_pos 4294967295-1-3 +gtid_binlog_state 4294967295-1-3 +gtid_current_pos +gtid_slave_pos +wsrep_gtid_domain_id 4294967295 +wsrep_gtid_mode 1 +# On node_1 +INSERT INTO t2 VALUES(1); +SELECT * FROM t2; +i +1 +list of GTID variables : +gtid_domain_id 1 +gtid_binlog_pos 1-1-1,4294967295-1-3 +gtid_binlog_state 1-1-1,4294967295-1-3 +gtid_current_pos 1-1-1,4294967295-1-3 +gtid_slave_pos +wsrep_gtid_domain_id 4294967295 +wsrep_gtid_mode 1 +# On node_2 +SELECT * FROM t2; +i +list of GTID variables : +gtid_domain_id 2 +gtid_binlog_pos 4294967295-1-3 +gtid_binlog_state 4294967295-1-3 +gtid_current_pos +gtid_slave_pos +wsrep_gtid_domain_id 4294967295 +wsrep_gtid_mode 1 +# On node_1 +DROP TABLE t1, t2; +# End of test diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index b3795b91666..2da2b3ad503 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -67,7 +67,6 @@ push @::global_suppressions, qr|WSREP: gcs_caused\(\) returned .*|, qr|WSREP: Protocol violation. JOIN message sender .* is not in state transfer \(SYNCED\). Message ignored.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), - qr(WSREP: cannot get fake InnoDB transaction ID), ); diff --git a/mysql-test/suite/galera/t/GAL-382.test b/mysql-test/suite/galera/t/GAL-382.test new file mode 100644 index 00000000000..05cc7346055 --- /dev/null +++ b/mysql-test/suite/galera/t/GAL-382.test @@ -0,0 +1,16 @@ +# +# GAL-382 InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno in trx0sys.cc line 356 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 + +create table t1 (i int, j int, k int, primary key pk(i)) engine=innodb; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +create table t2 (i int, j int, k int, primary key pk(i, j, k), index idx(i, k, j)) engine=innodb; +replace into t2 (i, j, k) select /*!99997 */ i, k, j from t1; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/MW-252.test b/mysql-test/suite/galera/t/MW-252.test new file mode 100644 index 00000000000..dfb82e8070a --- /dev/null +++ b/mysql-test/suite/galera/t/MW-252.test @@ -0,0 +1,42 @@ +# +# MW-252 - Check that FTWRL causes the node to become desynced +# and not subject to flow control +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +FLUSH TABLES WITH READ LOCK; + +# Node #1 is now desynced +--let $wait_condition = SELECT VARIABLE_VALUE = 'Donor/Desynced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Node #2 can issue updates without flow control kicking in +--connection node_2 + +--let $count = 100 +--disable_query_log +while ($count) +{ + INSERT INTO t1 VALUES (1); + --dec $count +} +--enable_query_log + +# Restore cluster +--connection node_1 +UNLOCK TABLES; + +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 100 FROM t1 +--source include/wait_condition.inc + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-258.test b/mysql-test/suite/galera/t/MW-258.test new file mode 100644 index 00000000000..f5519f8a081 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-258.test @@ -0,0 +1,41 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER); +LOCK TABLE t1 WRITE; +--echo value prior to RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +SHOW VARIABLES LIKE 'wsrep_desync'; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +--send ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1b +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_osu_method = RSU; +--send ALTER TABLE t1 ADD COLUMN f3 INTEGER; + +--sleep 5 +--connection node_1 +--echo value during RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +SHOW VARIABLES LIKE 'wsrep_desync'; +UNLOCK TABLES; + +--connection node_1a +--reap +--connection node_1b +--reap + +--connection node_1 +--echo value after RSU: +SHOW STATUS LIKE 'wsrep_desync_count'; +SHOW VARIABLES LIKE 'wsrep_desync'; +SET GLOBAL wsrep_desync=0; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-259.test b/mysql-test/suite/galera/t/MW-259.test new file mode 100644 index 00000000000..7298285f6ff --- /dev/null +++ b/mysql-test/suite/galera/t/MW-259.test @@ -0,0 +1,42 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +SET GLOBAL wsrep_desync=0; +SET wsrep_OSU_method=RSU; + +SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +--send ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_1a + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables' +--source include/wait_condition.inc + +# wsrep_desync=1 will block +--send SET GLOBAL wsrep_desync=1; + +--connection node_1b +--sleep 2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'SET GLOBAL wsrep_desync=1' +--source include/wait_condition.inc + +SET DEBUG_SYNC= 'now SIGNAL continue'; +DROP TABLE t1; +SET GLOBAL wsrep_desync=0; + +--connection node_1 +--reap + +--connection node_1a +--reap + +# Cleanup +SET DEBUG_SYNC= 'RESET'; + diff --git a/mysql-test/suite/galera/t/MW-284.cnf b/mysql-test/suite/galera/t/MW-284.cnf new file mode 100644 index 00000000000..52fd3093931 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-284.cnf @@ -0,0 +1 @@ +!include ../galera_2nodes_as_master.cnf diff --git a/mysql-test/suite/galera/t/MW-284.test b/mysql-test/suite/galera/t/MW-284.test new file mode 100644 index 00000000000..f3ce1b0dc91 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-284.test @@ -0,0 +1,58 @@ +# +# MW-284 Slave I/O retry on ER_COM_UNKNOWN_ERROR +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1, MASTER_USER='root', MASTER_CONNECT_RETRY=1; +--enable_query_log + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' +--source include/wait_condition.inc +SET SESSION wsrep_on = ON; + +--connection node_3 +START SLAVE; +--sleep 1 +--let $slave_param= Slave_IO_Running +--let $slave_param_value= Connecting +--source include/wait_for_slave_param.inc + +--connection node_1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +# We expect the slave to reconnect and resume replication + +--connection node_3 +--source include/wait_for_slave_to_start.inc + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) > 0 FROM t1 +--source include/wait_condition.inc + +# Cleanup + +--connection node_1 +DROP TABLE t1; + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; + +CALL mtr.add_suppression('failed registering on master'); +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); diff --git a/mysql-test/suite/galera/t/MW-285.test b/mysql-test/suite/galera/t/MW-285.test new file mode 100644 index 00000000000..1c567f7b250 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-285.test @@ -0,0 +1,31 @@ +# +# Broken FK constraints cause assertions +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; +CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB; + +CREATE TABLE child ( + id INT PRIMARY KEY, + parent1_id INT, + parent2_id INT, + FOREIGN KEY (parent1_id) REFERENCES parent1(id), + FOREIGN KEY (parent1_id) REFERENCES parent2(id) +) ENGINE=InnoDB; + +INSERT INTO parent1 VALUES (1); +INSERT INTO parent2 VALUES (1); +INSERT INTO child VALUES (1,1,1); +INSERT INTO child VALUES (2,1,1); + +SET foreign_key_checks=OFF; +DROP TABLE parent1; + +UPDATE child SET parent1_id=2 WHERE id=1; + +DROP TABLE child; +DROP TABLE parent2; +SET foreign_key_checks=ON; diff --git a/mysql-test/suite/galera/t/MW-286.test b/mysql-test/suite/galera/t/MW-286.test new file mode 100644 index 00000000000..1b2e322f078 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-286.test @@ -0,0 +1,32 @@ +# +# MW-286 Spurious deadlock error after error with wsrep_desync and wsrep_on +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/big_test.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +# Insert some values before the ALTER +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +# Insert more values while the ALTER is running +--send INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_2 +SET GLOBAL wsrep_desync = TRUE; +SET wsrep_on = FALSE; + +--error ER_QUERY_INTERRUPTED +ALTER TABLE t1 ADD PRIMARY KEY (f1); + +SET wsrep_on = TRUE; +SET GLOBAL wsrep_desync = FALSE; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/MW-292.test b/mysql-test/suite/galera/t/MW-292.test new file mode 100644 index 00000000000..ecb1273759e --- /dev/null +++ b/mysql-test/suite/galera/t/MW-292.test @@ -0,0 +1,79 @@ +# +# MW-292 Reset timestamp after transaction replay +# +# We force transaction replay to happen and then we check that NOW() is not stuck in time. +# As a bonus we also check that RAND() continues to return random values after replay +# +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` + +CREATE TABLE rand_table (f1 FLOAT); +CREATE TABLE t1 (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; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; + +# Block the commit +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_1 +--send COMMIT; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--source include/galera_wait_sync_point.inc + +# Issue a conflicting update on node #2 +--connection node_2 +UPDATE t1 SET f2 = 'c' WHERE f1 = 2; + +# Wait for both transactions to be blocked +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event::find_row%'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; +--source include/wait_condition.inc + +# Unblock the commit +--connection node_1a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +# Commit succeeds via replay +--connection node_1 +--reap + +# Confirm that NOW() is not stuck in time relative to SYSDATE(); +--sleep 3 +SELECT TIMEDIFF(SYSDATE(), NOW()) < 2; + +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); +INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND()); + +SELECT COUNT(DISTINCT f1) = 10 FROM rand_table; + +# wsrep_local_replays has increased by 1 +--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` +--disable_query_log +--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; +--enable_query_log + +--connection node_2 +DROP TABLE t1; +DROP TABLE rand_table; diff --git a/mysql-test/suite/galera/t/MW-44-master.opt b/mysql-test/suite/galera/t/MW-44-master.opt new file mode 100644 index 00000000000..a15aa0a99d9 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-44-master.opt @@ -0,0 +1 @@ +--log-output=TABLE diff --git a/mysql-test/suite/galera/t/MW-44.test b/mysql-test/suite/galera/t/MW-44.test new file mode 100644 index 00000000000..55a3fd57f80 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-44.test @@ -0,0 +1,25 @@ +# +# MW-44: DDL is logged in the general_log on the slave +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +TRUNCATE TABLE mysql.general_log; + +--connection node_2 +TRUNCATE TABLE mysql.general_log; + +--connection node_1 +SET SESSION wsrep_osu_method=TOI; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +SET SESSION wsrep_osu_method=RSU; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +SET SESSION wsrep_osu_method=TOI; + +SELECT COUNT(*) = 2 FROM mysql.general_log WHERE argument LIKE 'CREATE%' OR argument LIKE 'ALTER%'; + +--connection node_2 +SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument NOT LIKE 'SELECT%'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/create.test b/mysql-test/suite/galera/t/create.test index 9d0ab215cbb..96a6640c21f 100644 --- a/mysql-test/suite/galera/t/create.test +++ b/mysql-test/suite/galera/t/create.test @@ -68,6 +68,22 @@ SET autocommit=1; # Cleanup DROP TABLE t1, t2; + +--echo # +--echo # MDEV-10235: Deadlock in CREATE TABLE ... AS SELECT .. if result set +--echo # is empty in Galera +--echo # +--connection node_1 +CREATE TABLE t1(c1 INT) ENGINE=INNODB; +INSERT INTO t1 VALUES(1); +CREATE TABLE t2 AS SELECT * FROM t1 WHERE c1=2; + +--connection node_2 +SELECT * FROM t1; +SELECT * FROM t2; +# Cleanup +DROP TABLE t1, t2; + --source include/galera_end.inc --echo # End of tests diff --git a/mysql-test/suite/galera/t/galera#414.cnf b/mysql-test/suite/galera/t/galera#414.cnf new file mode 100644 index 00000000000..fbd1c58754f --- /dev/null +++ b/mysql-test/suite/galera/t/galera#414.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcs.max_packet_size=2' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcs.max_packet_size=2' + diff --git a/mysql-test/suite/galera/t/galera#414.test b/mysql-test/suite/galera/t/galera#414.test new file mode 100644 index 00000000000..b426e6510b6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera#414.test @@ -0,0 +1,32 @@ +# +# codership/galera#414 Shutdown crashes node if the node started with `gcs.max_packet_size=2` +# + +--source include/big_test.inc +--source include/galera_cluster.inc + +# We perform the shutdown/restart sequence in here. If there was a crash during shutdown, MTR will detect it + +--connection node_2 +--source include/shutdown_mysqld.inc + +--connection node_1 +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--source include/start_mysqld.inc + +--connection node_1 +SET SESSION wsrep_on = ON; +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_1 +CALL mtr.add_suppression("Failed to set packet size"); + +--connection node_2 +CALL mtr.add_suppression("Failed to set packet size"); + diff --git a/mysql-test/suite/galera/t/galera_as_master.test b/mysql-test/suite/galera/t/galera_as_master.test index c5d4db9f192..93f9224b258 100644 --- a/mysql-test/suite/galera/t/galera_as_master.test +++ b/mysql-test/suite/galera/t/galera_as_master.test @@ -60,3 +60,6 @@ DROP TABLE t2, t3; STOP SLAVE; RESET SLAVE ALL; + +CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); + diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf b/mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf new file mode 100644 index 00000000000..9449ec9cf40 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.cnf @@ -0,0 +1 @@ +!include ../galera_2nodes_as_slave.cnf diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test new file mode 100644 index 00000000000..9292badc480 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test @@ -0,0 +1,83 @@ +# +# Test Galera as a slave to a MySQL master +# +# The galera/galera_2node_slave.cnf describes the setup of the nodes +# + +--source include/have_innodb.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 + +## +## Verify the correct operation of the auto-increment when +## the binlog format set to the 'STATEMENT' on the master node: +## + +SET SESSION binlog_format='STATEMENT'; + +CREATE TABLE t1 ( + i int(11) NOT NULL AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text', + PRIMARY KEY (i) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1(i) values(null); + +select * from t1; + +insert into t1(i) values(null), (null), (null); + +select * from t1; + +SET SESSION auto_increment_increment=7; +insert into t1(i) values(null), (null), (null); + +SET SESSION auto_increment_offset=5; +insert into t1(i) values(null), (null), (null); + +select * from t1; + +show variables like 'binlog_format'; +show variables like '%auto_increment%'; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 10 FROM t1; +--source include/wait_condition.inc + +select * from t1; + +show variables like 'binlog_format'; +show variables like 'auto_increment_increment'; + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 + +select * from t1; + +show variables like 'binlog_format'; +show variables like 'auto_increment_increment'; + +--connection node_1 +DROP TABLE t1; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; + +--connection node_1 +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test index 5914e52d851..46a93458271 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test +++ b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test @@ -87,7 +87,7 @@ RESET SLAVE ALL; CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); -CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)"); +CALL mtr.add_suppression("Transport endpoint is not connected"); CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213"); CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); diff --git a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test index dbbe3b3c483..e32089ce21e 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test @@ -27,9 +27,8 @@ UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; ---let $wait_condition = SELECT COUNT(*) = 1 FROM t1 ---source include/wait_condition.inc -SELECT * FROM t1; +SET SESSION wsrep_sync_wait = 7; +SELECT COUNT(*) = 1 FROM t1; --let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` diff --git a/mysql-test/suite/galera/t/galera_defaults.test b/mysql-test/suite/galera/t/galera_defaults.test index 1cbb19cc405..3b1cb7b8650 100644 --- a/mysql-test/suite/galera/t/galera_defaults.test +++ b/mysql-test/suite/galera/t/galera_defaults.test @@ -13,7 +13,7 @@ # Make sure that the test is operating on the right version of galera library. --disable_query_log ---let $galera_version=3.9 +--let $galera_version=25.3.17 source ../wsrep/include/check_galera_version.inc; --enable_query_log diff --git a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test index fd77ec0a0eb..721d84ecb05 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test +++ b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test @@ -16,7 +16,7 @@ SELECT COUNT(*) = 1 FROM t1; SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; # Block the slave applier thread -FLUSH TABLES WITH READ LOCK; +LOCK TABLE t1 WRITE; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.cnf b/mysql-test/suite/galera/t/galera_ist_recv_bind.cnf new file mode 100644 index 00000000000..2628f05eaef --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;ist.recv_bind=127.0.0.1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;ist.recv_bind=127.0.0.1' + diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.test b/mysql-test/suite/galera/t/galera_ist_recv_bind.test new file mode 100644 index 00000000000..cb7329073ad --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.test @@ -0,0 +1,54 @@ +# +# Test ist.recv_bind option. Since MTR can not do proper testing with multiple interfaces and such, we +# simply confirm that the option can be set (in the galera_ist_recv_bind.cnf file) and that IST works as expected +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; + +--connection node_2 +SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; + +# Isolate node #2 + +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +SET SESSION wsrep_on = ON; + +# Node #2 is now isolated. Run some transactions to accumulate writesets for IST + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +# Restore node #2 + +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +# Confirm that IST has taken place + +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc + +# Cleanup + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index eae28bdbcd7..931daaad30d 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -9,6 +9,11 @@ --source include/have_debug_sync.inc --source suite/galera/include/galera_have_debug_sync.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'), (4, 'a'), (5, 'a'),(6, 'a'); @@ -106,3 +111,9 @@ SELECT COUNT(*) = 0 FROM t3; --connection node_1 DROP TABLE t1, t2, t3; + +# Restore original auto_increment_offset values. +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera/t/galera_kill_ddl.test b/mysql-test/suite/galera/t/galera_kill_ddl.test index 3c2bce5b9c9..90f3f30cc76 100644 --- a/mysql-test/suite/galera/t/galera_kill_ddl.test +++ b/mysql-test/suite/galera/t/galera_kill_ddl.test @@ -28,8 +28,13 @@ ALTER TABLE t1 ADD COLUMN f2 INTEGER; --source include/galera_connect.inc --connection node_2a +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1'; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --connection node_1 --disable_query_log diff --git a/mysql-test/suite/galera/t/galera_log_output_csv.test b/mysql-test/suite/galera/t/galera_log_output_csv.test index 00009396f6a..94ae3dd6168 100644 --- a/mysql-test/suite/galera/t/galera_log_output_csv.test +++ b/mysql-test/suite/galera/t/galera_log_output_csv.test @@ -17,9 +17,6 @@ SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 1 = 1 FROM t1'; --connection node_2 -# CREATE TABLE from master is also present in the slave query log, but is logged twice, mysql-wsrep#44 -SELECT COUNT(*) > 0 FROM mysql.general_log WHERE argument = 'CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB'; - SELECT 2 = 2 FROM t1; SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 2 = 2 FROM t1'; diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test index b1dc14deb5b..e078a342c16 100644 --- a/mysql-test/suite/galera/t/galera_parallel_simple.test +++ b/mysql-test/suite/galera/t/galera_parallel_simple.test @@ -13,6 +13,7 @@ CREATE TABLE t2 (id INT) ENGINE=InnoDB; --connection node_2 SET GLOBAL wsrep_slave_threads = 2; +LOCK TABLE t1 WRITE; --connection node_1 INSERT INTO t1 VALUES (1); @@ -34,10 +35,20 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); --connection node_2 +SET SESSION wsrep_sync_wait = 0; + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Waiting for table metadata lock%'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'applied write set%'; +--source include/wait_condition.inc + +UNLOCK TABLES; + +SET SESSION wsrep_sync_wait = 7; SELECT COUNT(*) = 10 FROM t1; SELECT COUNT(*) = 10 FROM t2; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'committed%'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; diff --git a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test index f63215ebe4a..84fd3a91857 100644 --- a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test +++ b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test @@ -6,10 +6,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 --let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` @@ -40,10 +39,8 @@ SET GLOBAL wsrep_cluster_address = ''; --source include/start_mysqld.inc --source include/wait_until_connected_again.inc ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera/t/galera_repl_max_ws_size.test b/mysql-test/suite/galera/t/galera_repl_max_ws_size.test index 37a2f7d4ce3..60b866ae018 100644 --- a/mysql-test/suite/galera/t/galera_repl_max_ws_size.test +++ b/mysql-test/suite/galera/t/galera_repl_max_ws_size.test @@ -23,3 +23,7 @@ SELECT COUNT(*) = 0 FROM t1; DROP TABLE t1; +CALL mtr.add_suppression("Maximum writeset size exceeded by"); +CALL mtr.add_suppression("transaction size limit"); +CALL mtr.add_suppression("transaction size exceeded"); +CALL mtr.add_suppression("rbr write fail"); diff --git a/mysql-test/suite/galera/t/galera_restart_nochanges.test b/mysql-test/suite/galera/t/galera_restart_nochanges.test index a61332cefd6..0a6a0c5ccbe 100644 --- a/mysql-test/suite/galera/t/galera_restart_nochanges.test +++ b/mysql-test/suite/galera/t/galera_restart_nochanges.test @@ -6,10 +6,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; @@ -18,6 +17,10 @@ INSERT INTO t1 VALUES (1); --connection node_2 --source include/restart_mysqld.inc +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + --let $galera_connection_name = node_2a --let $galera_server_number = 2 --source include/galera_connect.inc @@ -29,11 +32,9 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_roles.test b/mysql-test/suite/galera/t/galera_roles.test index f9a15126e5e..16e417d1fdb 100644 --- a/mysql-test/suite/galera/t/galera_roles.test +++ b/mysql-test/suite/galera/t/galera_roles.test @@ -163,5 +163,37 @@ disconnect foo_node_2; DROP USER foo@localhost; DROP DATABASE test1; +--echo # +--echo # MDEV-10566: Create role statement replicated inconsistently in Galera Cluster +--echo # +--echo +--echo # On node_1 +--connection node_1 +CREATE USER foo@localhost; +CREATE ROLE role1; +CREATE ROLE role2 WITH ADMIN CURRENT_USER; +CREATE ROLE role3 WITH ADMIN foo@localhost; +CREATE ROLE role4 WITH ADMIN role1; + +--sorted_result +SELECT * FROM mysql.roles_mapping; +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; + +--echo +--echo # On node_2 +--connection node_2 +--sorted_result +SELECT * FROM mysql.roles_mapping; +--sorted_result +SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES; + +# Cleanup +DROP ROLE role1; +DROP ROLE role2; +DROP ROLE role3; +DROP ROLE role4; +DROP USER foo@localhost; + --source include/galera_end.inc --echo # End of test diff --git a/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test index 36ec8563cbe..882f846fe67 100644 --- a/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test +++ b/mysql-test/suite/galera/t/galera_rsu_wsrep_desync.test @@ -17,9 +17,11 @@ SET wsrep_OSU_method=RSU; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; --send ALTER TABLE t1 ADD COLUMN f2 INTEGER; ---connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 ---connection node_1a +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +--connection node_1a --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables' --source include/wait_condition.inc @@ -44,24 +46,32 @@ CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; SET GLOBAL wsrep_desync=0; SET wsrep_OSU_method=RSU; -SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +SET DEBUG_SYNC = 'alter_table_before_create_table_no_lock WAIT_FOR continue'; --send ALTER TABLE t1 ADD COLUMN f2 INTEGER; --connection node_1a ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_open_tables' +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_before_create_table_no_lock' --source include/wait_condition.inc -# This transition is currently not allowed ---error ER_CANNOT_USER -SET GLOBAL wsrep_desync=1; -SET GLOBAL wsrep_desync=0; +# wsrep_desync=1 will block +--send SET GLOBAL wsrep_desync=1; + + +--connection node_1b +--sleep 2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'SET GLOBAL wsrep_desync=1' +--source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL continue'; --connection node_1 --reap +--connection node_1a +--reap +SET GLOBAL wsrep_desync=0; + SHOW CREATE TABLE t1; # Restore old state @@ -74,5 +84,3 @@ CALL mtr.add_suppression("desync failed"); --connection node_2 CALL mtr.add_suppression("Protocol violation"); - - diff --git a/mysql-test/suite/galera/t/galera_split_brain.test b/mysql-test/suite/galera/t/galera_split_brain.test index e0298e55422..22f6370241c 100644 --- a/mysql-test/suite/galera/t/galera_split_brain.test +++ b/mysql-test/suite/galera/t/galera_split_brain.test @@ -6,17 +6,16 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + call mtr.add_suppression("WSREP: TO isolation failed for: "); --connection node_1 --let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` -# Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; - --connection node_2 --source include/kill_galera.inc @@ -44,10 +43,8 @@ SET GLOBAL wsrep_cluster_address = ''; --source include/wait_until_connected_again.inc # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_ssl_upgrade.test b/mysql-test/suite/galera/t/galera_ssl_upgrade.test index 07aac0fbe92..a424942da30 100644 --- a/mysql-test/suite/galera/t/galera_ssl_upgrade.test +++ b/mysql-test/suite/galera/t/galera_ssl_upgrade.test @@ -18,7 +18,8 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --source include/start_mysqld.inc --source include/wait_until_connected_again.inc -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; # 3. Restart node #2 with the new socket.ssl_ca , socket.ssl_cert and socket.ssl_key @@ -29,7 +30,8 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --source include/start_mysqld.inc --source include/wait_until_connected_again.inc -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; # 4. Restart node #1 with the new socket.ssl_ca , socket.ssl_cert and socket.ssl_key @@ -40,7 +42,8 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --source include/start_mysqld.inc --source include/wait_until_connected_again.inc -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; # Upgrade complete. Both nodes now use the new key and certificate diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test index b4302f7d195..353a7c38a73 100644 --- a/mysql-test/suite/galera/t/galera_suspend_slave.test +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -8,10 +8,9 @@ --source include/have_innodb.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; @@ -56,11 +55,7 @@ SELECT COUNT(*) = 1 FROM t1; DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2a ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_transaction_replay.test b/mysql-test/suite/galera/t/galera_transaction_replay.test index bd5288a51c6..29870829ba3 100644 --- a/mysql-test/suite/galera/t/galera_transaction_replay.test +++ b/mysql-test/suite/galera/t/galera_transaction_replay.test @@ -40,7 +40,7 @@ UPDATE t1 SET f2 = 'c' WHERE f1 = 2; # Wait for both transactions to be blocked --connection node_1a ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'System lock'; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event::find_row%'; --source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; @@ -69,3 +69,56 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b'; SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; DROP TABLE t1; + +#echo "# test for PS replaying" + +# +# test replaying of prepared statements +# +--connection node_1 +CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 0), (3, 0); +SELECT * FROM t1; + +PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0"; + +# block the commit of PS +--connection node_1a +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_1 +--send EXECUTE stmt1; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--source include/galera_wait_sync_point.inc + +# Issue a conflicting update on node_2 +--connection node_2 +#UPDATE t1 SET j=2; +INSERT INTO t1 VALUES(2,2); + + +# Wait until applying begins in node_1 +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Write_rows_log_event::write_row%'; +--source include/wait_condition.inc + +# Unblock the PS commit +--connection node_1a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +# Commit succeeds +--connection node_1 +--reap +SELECT * FROM t1; + +--connection node_2 +SELECT * FROM t1; + +--connection node_1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_desync_on.test b/mysql-test/suite/galera/t/galera_var_desync_on.test index fb0fb9f762a..06c5d30a769 100644 --- a/mysql-test/suite/galera/t/galera_var_desync_on.test +++ b/mysql-test/suite/galera/t/galera_var_desync_on.test @@ -55,4 +55,8 @@ INSERT INTO t1 VALUES (11); # Replication continues normally SELECT COUNT(*) = 11 FROM t1; +CALL mtr.add_suppression("Protocol violation"); DROP TABLE t1; + +--connection node_1 +CALL mtr.add_suppression("Protocol violation"); diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 9eea8efdaf3..dfd8d5ecf29 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -5,13 +5,10 @@ --source include/galera_cluster.inc --source include/have_innodb.inc ---disable_query_log # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; ---enable_query_log +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_2 --let $wsrep_cluster_address_saved = `SELECT @@global.wsrep_cluster_address` @@ -49,13 +46,8 @@ SELECT * FROM t1; # Cleanup DROP TABLE t1; ---disable_query_log # Restore original auto_increment_offset values. ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---enable_query_log +--source include/auto_increment_offset_restore.inc --source include/galera_end.inc --echo # End of test diff --git a/mysql-test/suite/galera/t/galera_var_max_ws_rows.test b/mysql-test/suite/galera/t/galera_var_max_ws_rows.test new file mode 100644 index 00000000000..944238bf1aa --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_max_ws_rows.test @@ -0,0 +1,155 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +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; + +--let $wsrep_max_ws_rows_orig = `SELECT @@wsrep_max_ws_rows` +SET GLOBAL wsrep_max_ws_rows = 4; + +# Test that wsrep_max_ws_rows is enforced with multi statement transactions + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (5); +COMMIT; +SELECT COUNT(*) = 0 FROM t1; + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +--error ER_ERROR_DURING_COMMIT +UPDATE t1 SET f2 = 10 WHERE f2 = 4; +COMMIT; +SELECT COUNT(*) = 0 FROM t1; + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); +INSERT INTO t1 (f2) VALUES (3); +INSERT INTO t1 (f2) VALUES (4); +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1 WHERE f2 = 1; +COMMIT; +SELECT COUNT(*) = 0 FROM t1; + + +# Test that wsrep_max_ws_rows is enforced on sigle statements + +SET GLOBAL wsrep_max_ws_rows = 5; +INSERT INTO t1 (f2) VALUES (1),(2),(3),(4),(5); +SET GLOBAL wsrep_max_ws_rows = 4; + +--error ER_ERROR_DURING_COMMIT +UPDATE t1 SET f2 = f2 + 10; +SELECT COUNT(*) = 5 FROM t1; + +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1 WHERE f2 < 10; +SELECT COUNT(*) = 5 FROM t1; + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) SELECT * FROM ten; +SELECT COUNT(*) = 5 FROM t1; + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (10),(20),(30),(40),(50); +SELECT COUNT(*) = 5 FROM t1; + +# Fewer than wsrep_max_ws_rows is OK + +SET GLOBAL wsrep_max_ws_rows = 10; +DELETE FROM t1 WHERE f2 < 10; +SELECT COUNT(*) = 0 FROM t1; + +# Test a series of transactions + +--disable_query_log +SET GLOBAL wsrep_max_ws_rows = 5; +let $i= 100; +while ($i) +{ + START TRANSACTION; + --eval INSERT INTO t1 (f2) VALUES ($i); + COMMIT; + dec $i; +} +--enable_query_log +SET GLOBAL wsrep_max_ws_rows = 100; +SELECT COUNT(*) = 100 FROM t1; +DELETE FROM t1 WHERE f2 < 101; +SELECT COUNT(*) = 0 FROM t1; + +# Test large statements + +SET GLOBAL wsrep_max_ws_rows = 9999; +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +SET GLOBAL wsrep_max_ws_rows = 10000; +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +SET GLOBAL wsrep_max_ws_rows = 9999; +--error ER_ERROR_DURING_COMMIT +UPDATE t1 SET f2 = 2 WHERE f2 = 1; +SET GLOBAL wsrep_max_ws_rows = 10000; +UPDATE t1 SET f2 = 2 WHERE f2 = 1; + +SET GLOBAL wsrep_max_ws_rows = 9999; +--error ER_ERROR_DURING_COMMIT +DELETE FROM t1 WHERE f2 = 2; +SET GLOBAL wsrep_max_ws_rows = 10000; +DELETE FROM t1 WHERE f2 = 2; + +SELECT COUNT(*) = 0 FROM t1; + + +# Test that wsrep_max_ws_rows is reset when switching autocommit mode + +SET AUTOCOMMIT = ON; +SET GLOBAL wsrep_max_ws_rows = 1; + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + +INSERT INTO t1 (f2) VALUES (1); +INSERT INTO t1 (f2) VALUES (2); + + +SET AUTOCOMMIT = OFF; +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + + +# Test that wsrep_max_ws_rows is reset on implicit commits + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); + +START TRANSACTION; +INSERT INTO t1 (f2) VALUES (1); +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 (f2) VALUES (2); + + +--disable_query_log +--eval SET GLOBAL wsrep_max_ws_rows = $wsrep_max_ws_rows_orig +--enable_query_log + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_var_max_ws_size.test b/mysql-test/suite/galera/t/galera_var_max_ws_size.test index b66ef2d5ee2..8eb93bda9be 100644 --- a/mysql-test/suite/galera/t/galera_var_max_ws_size.test +++ b/mysql-test/suite/galera/t/galera_var_max_ws_size.test @@ -16,6 +16,29 @@ SET GLOBAL wsrep_max_ws_size = 1024; INSERT INTO t1 VALUES (DEFAULT, REPEAT('X', 1024)); SELECT COUNT(*) = 0 FROM t1; +# +# Changing repl.max_ws_size also changes wsrep_max_ws_size +# + +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; +SELECT @@wsrep_max_ws_size = 10000; + + +# +# Changing wsrep_max_ws_size is equivalent to changing repl.max_ws_size +# + +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=20000'; +--let $provider_options = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=10000'; + +SET GLOBAL wsrep_max_ws_size = 20000; +--let $provider_options_updated = `SELECT @@wsrep_provider_options` + +--disable_query_log +--eval SELECT STRCMP('$provider_options', '$provider_options_updated') = 0 AS provider_options_match +--enable_query_log + --disable_query_log --eval SET GLOBAL wsrep_max_ws_size = $wsrep_max_ws_size_orig --enable_query_log diff --git a/mysql-test/suite/galera/t/galera_var_sync_wait.test b/mysql-test/suite/galera/t/galera_var_sync_wait.test index 935c271a4d6..288ad62226f 100644 --- a/mysql-test/suite/galera/t/galera_var_sync_wait.test +++ b/mysql-test/suite/galera/t/galera_var_sync_wait.test @@ -5,6 +5,13 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--echo # +--echo # MDEV-10161: wsrep_sync_wait not enabled when set to 1 in config file +--echo # +# galera_2nodes.cnf sets wsrep_sync_wait to 7 +SELECT @@global.wsrep_sync_wait; +SELECT @@global.wsrep_causal_reads; + --let $wsrep_sync_wait_orig = `SELECT @@wsrep_sync_wait` --connection node_1 diff --git a/mysql-test/suite/galera/t/mdev_10518.cnf b/mysql-test/suite/galera/t/mdev_10518.cnf new file mode 100644 index 00000000000..482334c2f8a --- /dev/null +++ b/mysql-test/suite/galera/t/mdev_10518.cnf @@ -0,0 +1,17 @@ +!include ../galera_2nodes.cnf + +[mysqld] +log-bin +log-slave-updates + +[mysqld.1] +gtid_domain_id=1 +wsrep_gtid_mode=ON +# Maximum allowed wsrep_gtid_domain_id. +wsrep_gtid_domain_id=4294967295 + +[mysqld.2] +gtid_domain_id=2 +wsrep_gtid_mode=ON +#wsrep_gitd_domain_id value will be inherited from donor node (mysqld.1) +#wsrep_gitd_domain_id=X diff --git a/mysql-test/suite/galera/t/mdev_10518.test b/mysql-test/suite/galera/t/mdev_10518.test new file mode 100644 index 00000000000..c4127b4f655 --- /dev/null +++ b/mysql-test/suite/galera/t/mdev_10518.test @@ -0,0 +1,53 @@ +# Test for @@wsrep_gtid_mode and @@wsrep_gtid_domain_id variables +# +# When @@wsrep_gtid_mode=ON, all DDL/DML commands and transactions that +# are meant to be replicated over Galera cluster nodes are tagged with +# galera gtid_domain_id (@@wsrep_gtid_domain_id), while others are tagged +# with the local domain_id (@@gtid_domain_id). + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--echo # On node_1 +--connection node_1 +# print initial GTIDs +source include/print_gtid.inc; + +--echo # On node_2 +--connection node_2 +# print initial GTIDs +source include/print_gtid.inc; + +--echo # 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); +SELECT * FROM t1; +SELECT * FROM t2; +source include/print_gtid.inc; + +--echo # On node_2 +--connection node_2 +SELECT * FROM t1; +source include/print_gtid.inc; + +--echo # On node_1 +--connection node_1 +INSERT INTO t2 VALUES(1); +SELECT * FROM t2; +source include/print_gtid.inc; + +--echo # On node_2 +--connection node_2 +SELECT * FROM t2; +source include/print_gtid.inc; + +--echo # On node_1 +--connection node_1 +# Cleanup +DROP TABLE t1, t2; + +--source include/galera_end.inc +--echo # End of test + diff --git a/mysql-test/suite/galera/t/mysql-wsrep#237.test b/mysql-test/suite/galera/t/mysql-wsrep#237.test index f2dd6bce711..cba8dfeb275 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#237.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#237.test @@ -28,6 +28,7 @@ SET DEBUG_SYNC= 'now SIGNAL continue'; --connection node_1 --reap +# Cleanup DROP TABLE t; --connection node_1a SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#31.test b/mysql-test/suite/galera/t/mysql-wsrep#31.test index eaace5d50dd..c669d4834ba 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#31.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#31.test @@ -1,6 +1,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --connection node_1 CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; @@ -36,4 +41,13 @@ if ($galera_wsrep_start_position != $expected_position) DROP TABLE t1; DROP DATABASE db; +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/wait_until_connected_again.inc + +# Restore original auto_increment_offset values. +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc + diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf index 2a06c1cd5a9..eaa2899968c 100644 --- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf +++ b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf @@ -18,7 +18,7 @@ wsrep-sync-wait=7 #ist_port=@OPT.port #sst_port=@OPT.port wsrep-cluster-address=gcomm:// -wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M' +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' @@ -27,7 +27,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' @@ -36,7 +36,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' #ist_port=@OPT.port #sst_port=@OPT.port wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S' wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result index f5a4cad4a23..69995acb982 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result +++ b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result @@ -3,9 +3,6 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET SESSION wsrep_sync_wait = 0; -SHOW STATUS LIKE 'wsrep_cluster_status'; -Variable_name Value -wsrep_cluster_status non-Primary SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1'; SHOW STATUS LIKE 'wsrep_cluster_size'; Variable_name Value diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result index 85f923ad55e..6fb931638ef 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result +++ b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result @@ -1,6 +1,8 @@ SET GLOBAL wsrep_provider_options = 'pc.weight=3'; Suspending node ... SET SESSION wsrep_sync_wait=0; +SET SESSION wsrep_on=OFF; +SET SESSION wsrep_on=ON; SHOW STATUS LIKE 'wsrep_cluster_size'; Variable_name Value wsrep_cluster_size 2 diff --git a/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test b/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test index e19169a350c..b4fe10bff0d 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test +++ b/mysql-test/suite/galera_3nodes/t/galera_certification_ccc.test @@ -10,12 +10,10 @@ --source include/galera_connect.inc # Save original auto_increment_offset values. ---connection node_1 -let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; ---connection node_2 -let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; ---connection node_3 -let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; @@ -49,12 +47,7 @@ SELECT COUNT(*) = 2 FROM t1; DROP TABLE t1; # Restore original auto_increment_offset values. ---disable_query_log ---connection node_1 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; ---connection node_2 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; ---connection node_3 ---eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; ---enable_query_log +--source ../galera/include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test index af4a5fbf9d6..a6660bd08d1 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test +++ b/mysql-test/suite/galera_3nodes/t/galera_innobackupex_backup.test @@ -13,8 +13,8 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); SELECT COUNT(*) = 10 FROM t1; --exec rm -rf $MYSQL_TMP_DIR/innobackupex_backup ---exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-backup.log ---exec innobackupex $MYSQL_TMP_DIR/innobackupex_backup --apply-log --galera-info --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-apply.log +--exec innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 $MYSQL_TMP_DIR/innobackupex_backup --galera-info --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-backup.log +--exec innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 $MYSQL_TMP_DIR/innobackupex_backup --apply-log --galera-info --port=$NODE_MYPORT_2 --host=127.0.0.1 --no-timestamp > $MYSQL_TMP_DIR/innobackupex-apply.log --source include/kill_galera.inc --sleep 1 @@ -23,7 +23,7 @@ SELECT COUNT(*) = 10 FROM t1; INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); --exec rm -rf $MYSQLTEST_VARDIR/mysqld.2/data/* ---exec innobackupex --copy-back $MYSQL_TMP_DIR/innobackupex_backup --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --port=$NODE_MYPORT_2 --host=127.0.0.1 > $MYSQL_TMP_DIR/innobackupex-restore.log +--exec innobackupex --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group=mysqld.2 --copy-back $MYSQL_TMP_DIR/innobackupex_backup --port=$NODE_MYPORT_2 --host=127.0.0.1 > $MYSQL_TMP_DIR/innobackupex-restore.log # # Convert the xtrabackup_galera_info into a grastate.dat file diff --git a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test index 7d8bbb39e35..8575d99f066 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test @@ -82,6 +82,8 @@ INSERT INTO t1 VALUES (51), (52), (53), (54), (55); --connection node_3 --source include/wait_until_connected_again.inc +sleep 5; + # Final checks --connection node_2 SELECT COUNT(*) = 30 FROM t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf new file mode 100644 index 00000000000..d560b675427 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.cnf @@ -0,0 +1,5 @@ +# We need a dedicated .cnf file, even if empty, in order to force this test to run +# alone on a freshly started cluster. Otherwise there are adverse interactions with +# prior tests such as galera_3nodes.galera_innobackupex_backup + +!include ../galera_3nodes.cnf diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test index 6172ffcc743..f8381a3324b 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test @@ -23,7 +23,8 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; # Node #2 should be non-primary SET SESSION wsrep_sync_wait = 0; -SHOW STATUS LIKE 'wsrep_cluster_status'; +--let $wait_condition = SELECT variable_value = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status'; +--source include/wait_condition.inc # Signal node #2 to bootstrap --connection node_2 diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf new file mode 100644 index 00000000000..57026ce6928 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.cnf @@ -0,0 +1,5 @@ +# We need a dedicated .cnf file, even if empty, in order to force this test to run +# alone on a freshly started cluster. Otherwise there are adverse interactions with +# following tests such as galera_3nodes.galera_var_dirty_reads2 + +!include ../galera_3nodes.cnf diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test index 6585f1934a4..c118b7481bc 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test @@ -19,6 +19,11 @@ SET GLOBAL wsrep_provider_options = 'pc.weight=3'; SET SESSION wsrep_sync_wait=0; --source include/wait_until_connected_again.inc +SET SESSION wsrep_on=OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' +--source include/wait_condition.inc +SET SESSION wsrep_on=ON; + # We can not use SELECT queries here, as only SHOW is allowed to run. # For nodes #2 and #3, we expect a non-primary component of size 2 @@ -45,7 +50,7 @@ SHOW STATUS LIKE 'wsrep_local_state_comment'; --connection node_1 --source include/galera_resume.inc ---sleep 5 +--sleep 10 --source include/wait_until_connected_again.inc # For Node #1, we expect a primary component of size 1 diff --git a/mysql-test/suite/innodb/r/innodb-alter-table.result b/mysql-test/suite/innodb/r/innodb-alter-table.result index 514b8b7935f..c4460a7226b 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-table.result +++ b/mysql-test/suite/innodb/r/innodb-alter-table.result @@ -135,3 +135,53 @@ child CREATE TABLE `child` ( CONSTRAINT `child_ibfk_1` FOREIGN KEY (`c`) REFERENCES `parent` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE child, parent; +CREATE TABLE IF NOT EXISTS ticket ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +mask VARCHAR(16) DEFAULT '' NOT NULL, +subject VARCHAR(255) DEFAULT '' NOT NULL, +is_closed TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL, +is_deleted TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL, +team_id INT UNSIGNED DEFAULT 0 NOT NULL, +category_id INT UNSIGNED DEFAULT 0 NOT NULL, +first_message_id INT UNSIGNED DEFAULT 0 NOT NULL, +created_date INT UNSIGNED, +updated_date INT UNSIGNED, +due_date INT UNSIGNED, +first_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0, +last_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0, +spam_score DECIMAL(4,4) NOT NULL DEFAULT 0, +spam_training VARCHAR(1) NOT NULL DEFAULT '', +interesting_words VARCHAR(255) NOT NULL DEFAULT '', +next_action VARCHAR(255) NOT NULL DEFAULT '', +PRIMARY KEY (id) +) ENGINE=InnoDB; +ALTER TABLE ticket +CHANGE COLUMN team_id group_id INT UNSIGNED NOT NULL DEFAULT 0, +CHANGE COLUMN category_id bucket_id INT UNSIGNED NOT NULL DEFAULT 0, +ADD COLUMN org_id INT UNSIGNED NOT NULL DEFAULT 0, +ADD INDEX org_id (org_id); +SHOW CREATE TABLE ticket; +Table Create Table +ticket CREATE TABLE `ticket` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `mask` varchar(16) NOT NULL DEFAULT '', + `subject` varchar(255) NOT NULL DEFAULT '', + `is_closed` tinyint(1) unsigned NOT NULL DEFAULT '0', + `is_deleted` tinyint(1) unsigned NOT NULL DEFAULT '0', + `group_id` int(10) unsigned NOT NULL DEFAULT '0', + `bucket_id` int(10) unsigned NOT NULL DEFAULT '0', + `first_message_id` int(10) unsigned NOT NULL DEFAULT '0', + `created_date` int(10) unsigned DEFAULT NULL, + `updated_date` int(10) unsigned DEFAULT NULL, + `due_date` int(10) unsigned DEFAULT NULL, + `first_wrote_address_id` int(10) unsigned NOT NULL DEFAULT '0', + `last_wrote_address_id` int(10) unsigned NOT NULL DEFAULT '0', + `spam_score` decimal(4,4) NOT NULL DEFAULT '0.0000', + `spam_training` varchar(1) NOT NULL DEFAULT '', + `interesting_words` varchar(255) NOT NULL DEFAULT '', + `next_action` varchar(255) NOT NULL DEFAULT '', + `org_id` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `org_id` (`org_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE ticket; diff --git a/mysql-test/suite/innodb/r/innodb-alter-tempfile.result b/mysql-test/suite/innodb/r/innodb-alter-tempfile.result index ce13ad0978b..3cc973ca3a3 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-tempfile.result +++ b/mysql-test/suite/innodb/r/innodb-alter-tempfile.result @@ -4,6 +4,10 @@ # Temporary tablename will be unique. This makes sure that future # in-place ALTERs of the same table will not be blocked due to # temporary tablename. +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed +"); +call mtr.add_suppression("InnoDB: file read of space .* page .*"); +call mtr.add_suppression("InnoDB: Trying to recover it from the doublewrite buffer."); # Crash the server in ha_innobase::commit_inplace_alter_table() CREATE TABLE t1 (f1 INT NOT NULL, f2 INT NOT NULL) ENGINE=innodb; SET debug='d,innodb_alter_commit_crash_before_commit'; diff --git a/mysql-test/suite/innodb/r/innodb-fk-warnings.result b/mysql-test/suite/innodb/r/innodb-fk-warnings.result index eddedfc3620..d7c7acfb424 100644 --- a/mysql-test/suite/innodb/r/innodb-fk-warnings.result +++ b/mysql-test/suite/innodb/r/innodb-fk-warnings.result @@ -70,6 +70,20 @@ Level Code Message Warning 150 Alter table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary close to foreign key(b) references t1(a). Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed") Warning 1215 Cannot add foreign key constraint +create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb; +ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +show warnings; +Level Code Message +Warning 150 Create table `mysqld.1`.`t2` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary near 'foreign key(a) references t1(a)) engine=innodb'. +Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +Warning 1215 Cannot add foreign key constraint +alter table t1 add foreign key(b) references t1(a); +ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed") +show warnings; +Level Code Message +Warning 150 Alter table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary near 'foreign key(b) references t1(a)'. +Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed") +Warning 1215 Cannot add foreign key constraint drop table t1; create table t1(a int not null primary key, b int, key(b)) engine=innodb; alter table t1 add foreign key(a,b) references t1(a); diff --git a/mysql-test/suite/innodb/r/innodb-fkcheck.result b/mysql-test/suite/innodb/r/innodb-fkcheck.result new file mode 100644 index 00000000000..c6beabb0f50 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-fkcheck.result @@ -0,0 +1,89 @@ +set global innodb_file_per_table = 1; +drop table if exists b; +drop database if exists bug_fk; +create database bug_fk; +use bug_fk; +CREATE TABLE b ( +b int unsigned NOT NULL, +d1 datetime NOT NULL, +PRIMARY KEY (b,d1) +) ENGINE=InnoDB; +CREATE TABLE c ( +b int unsigned NOT NULL, +d1 datetime NOT NULL, +d2 datetime NOT NULL, +PRIMARY KEY (b,d1), +CONSTRAINT b_fk FOREIGN KEY (b) REFERENCES b (b) +) ENGINE=InnoDB; +show warnings; +Level Code Message +set foreign_key_checks = 0; +DROP TABLE IF EXISTS b; +show create table c; +Table Create Table +c CREATE TABLE `c` ( + `b` int(10) unsigned NOT NULL, + `d1` datetime NOT NULL, + `d2` datetime NOT NULL, + PRIMARY KEY (`b`,`d1`), + CONSTRAINT `b_fk` FOREIGN KEY (`b`) REFERENCES `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE TABLE b ( +b bigint unsigned NOT NULL, +d1 date NOT NULL, +PRIMARY KEY (b,d1) +) ENGINE=InnoDB; +ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed") +show warnings; +Level Code Message +Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed") +Warning 1215 Cannot add foreign key constraint +DROP TABLE IF EXISTS d; +Warnings: +Note 1051 Unknown table 'bug_fk.d' +CREATE TABLE d ( +b bigint unsigned NOT NULL, +d1 date NOT NULL, +PRIMARY KEY (b,d1), +CONSTRAINT bd_fk FOREIGN KEY (b) REFERENCES b (b) +) ENGINE=InnoDB; +show warnings; +Level Code Message +set foreign_key_checks = 1; +show create table c; +Table Create Table +c CREATE TABLE `c` ( + `b` int(10) unsigned NOT NULL, + `d1` datetime NOT NULL, + `d2` datetime NOT NULL, + PRIMARY KEY (`b`,`d1`), + CONSTRAINT `b_fk` FOREIGN KEY (`b`) REFERENCES `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +show create table d; +Table Create Table +d CREATE TABLE `d` ( + `b` bigint(20) unsigned NOT NULL, + `d1` date NOT NULL, + PRIMARY KEY (`b`,`d1`), + CONSTRAINT `bd_fk` FOREIGN KEY (`b`) REFERENCES `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE TABLE b ( +b bigint unsigned NOT NULL, +d1 date NOT NULL, +PRIMARY KEY (b,d1) +) ENGINE=InnoDB; +ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed") +show warnings; +Level Code Message +Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed") +Warning 1215 Cannot add foreign key constraint +set foreign_key_checks=0; +drop table c; +drop table d; +create table b(id int) engine=innodb; +show warnings; +Level Code Message +b.frm +b.ibd +drop table if exists b; +drop database if exists bug_fk; diff --git a/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff b/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff new file mode 100644 index 00000000000..4aea0b451ec --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff @@ -0,0 +1,56 @@ +--- suite/innodb/r/innodb-wl5522.result ++++ suite/innodb/r/innodb-wl5522.reject +@@ -580,7 +580,7 @@ + ERROR HY000: Tablespace has been discarded for table 't1' + restore: t1 .ibd and .cfg files + ALTER TABLE t1 IMPORT TABLESPACE; +-ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0) ++ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0) + unlink: t1.ibd + unlink: t1.cfg + DROP TABLE t1; +@@ -592,7 +592,7 @@ + ERROR HY000: Tablespace has been discarded for table 't1' + restore: t1 .ibd and .cfg files + ALTER TABLE t1 IMPORT TABLESPACE; +-ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0) ++ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0) + unlink: t1.ibd + unlink: t1.cfg + DROP TABLE t1; +@@ -766,7 +766,7 @@ + ERROR HY000: Tablespace has been discarded for table 't1' + restore: t1 .ibd and .cfg files + ALTER TABLE t1 IMPORT TABLESPACE; +-ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1) ++ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1) + unlink: t1.ibd + unlink: t1.cfg + DROP TABLE t1; +@@ -778,7 +778,7 @@ + ERROR HY000: Tablespace has been discarded for table 't1' + restore: t1 .ibd and .cfg files + ALTER TABLE t1 IMPORT TABLESPACE; +-ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1) ++ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1) + unlink: t1.ibd + unlink: t1.cfg + DROP TABLE t1; +@@ -955,7 +955,7 @@ + ERROR HY000: Tablespace has been discarded for table 't1' + restore: t1 .ibd and .cfg files + ALTER TABLE t1 IMPORT TABLESPACE; +-ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21) ++ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21) + unlink: t1.ibd + unlink: t1.cfg + DROP TABLE t1; +@@ -967,7 +967,7 @@ + ERROR HY000: Tablespace has been discarded for table 't1' + restore: t1 .ibd and .cfg files + ALTER TABLE t1 IMPORT TABLESPACE; +-ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21) ++ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21) + unlink: t1.ibd + unlink: t1.cfg + DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result index 353303825e5..0ef6f65d0ff 100644 --- a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result +++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result @@ -1,82 +1,48 @@ -set names utf8; -CREATE TABLE corrupt_bit_test_ā( -a INT AUTO_INCREMENT PRIMARY KEY, -b CHAR(100), -c INT, -z INT, -INDEX(b)) -ENGINE=InnoDB; -INSERT INTO corrupt_bit_test_ā VALUES(0,'x',1, 1); -CREATE UNIQUE INDEX idxā ON corrupt_bit_test_ā(c, b); -CREATE UNIQUE INDEX idxē ON corrupt_bit_test_ā(z, b); -SELECT * FROM corrupt_bit_test_ā; a b c z 1 x 1 1 -select @@unique_checks; -@@unique_checks -0 -select @@innodb_change_buffering_debug; -@@innodb_change_buffering_debug -1 -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_ā; -select count(*) from corrupt_bit_test_ā; count(*) -1024 -CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c); -INSERT INTO corrupt_bit_test_ā VALUES(13000,'x',1,1); -CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z); -check table corrupt_bit_test_ā; +2 Table Op Msg_type Msg_text -test.corrupt_bit_test_ā check Warning InnoDB: The B-tree of index "idxā" is corrupted. -test.corrupt_bit_test_ā check Warning InnoDB: The B-tree of index "idxē" is corrupted. +test.corrupt_bit_test_ā check Warning InnoDB: Index "idx" is marked as corrupted +test.corrupt_bit_test_ā check Warning InnoDB: Index "idxā" is marked as corrupted +test.corrupt_bit_test_ā check Warning InnoDB: Index "idxē" is marked as corrupted test.corrupt_bit_test_ā check error Corrupt -select c from corrupt_bit_test_ā; +ERROR HY000: Index "idx" is corrupted +ERROR HY000: Index "idx" is corrupted ERROR HY000: Index corrupt_bit_test_ā is corrupted -select z from corrupt_bit_test_ā; ERROR HY000: Index corrupt_bit_test_ā is corrupted -show warnings; Level Code Message Warning 180 InnoDB: Index "idxē" for table "test"."corrupt_bit_test_ā" is marked as corrupted Error 1712 Index corrupt_bit_test_ā is corrupted -insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001); -select * from corrupt_bit_test_ā use index(primary) where a = 10001; a b c z 10001 a 20001 20001 -begin; -insert into corrupt_bit_test_ā values (10002, "a", 20002, 20002); -delete from corrupt_bit_test_ā where a = 10001; -insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001); -rollback; -drop index idxā on corrupt_bit_test_ā; -check table corrupt_bit_test_ā; Table Op Msg_type Msg_text +test.corrupt_bit_test_ā check Warning InnoDB: Index "idx" is marked as corrupted test.corrupt_bit_test_ā check Warning InnoDB: Index "idxē" is marked as corrupted test.corrupt_bit_test_ā check error Corrupt -set names utf8; -select z from corrupt_bit_test_ā; ERROR HY000: Index corrupt_bit_test_ā is corrupted -drop index idxē on corrupt_bit_test_ā; -select z from corrupt_bit_test_ā limit 10; +Table Create Table +corrupt_bit_test_ā CREATE TABLE `corrupt_bit_test_ā` ( + `a` int(11) NOT NULL AUTO_INCREMENT, + `b` char(100) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `z` int(11) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `idxē` (`z`,`b`), + KEY `idx` (`b`) +) ENGINE=InnoDB AUTO_INCREMENT=10003 DEFAULT CHARSET=latin1 +ERROR HY000: Index "idx" is corrupted +ERROR HY000: Index "idx" is corrupted +Table Create Table +corrupt_bit_test_ā CREATE TABLE `corrupt_bit_test_ā` ( + `a` int(11) NOT NULL AUTO_INCREMENT, + `b` char(100) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `z` int(11) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx` (`b`) +) ENGINE=InnoDB AUTO_INCREMENT=10003 DEFAULT CHARSET=latin1 z 20001 1 -1 2 -11 -12 -21 -22 -31 -32 -drop table corrupt_bit_test_ā; -DROP DATABASE pad; -SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/innodb/r/innodb_ctype_ldml.result b/mysql-test/suite/innodb/r/innodb_ctype_ldml.result index 0008de141dc..fefadb2ecb0 100644 --- a/mysql-test/suite/innodb/r/innodb_ctype_ldml.result +++ b/mysql-test/suite/innodb/r/innodb_ctype_ldml.result @@ -396,6 +396,7 @@ utf8mb4_test_400_ci utf8mb4 328 8 latin1_test2 latin1 332 1 utf8_bengali_standard_ci utf8 336 8 utf8_bengali_traditional_ci utf8 337 8 +utf8_implicit_weights_ci utf8 338 8 utf8_phone_ci utf8 352 8 utf8_test_ci utf8 353 8 utf8_5624_1 utf8 354 8 diff --git a/mysql-test/suite/innodb/t/innodb-alter-table.test b/mysql-test/suite/innodb/t/innodb-alter-table.test index 2ad9c8791cb..45342b4a218 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-table.test +++ b/mysql-test/suite/innodb/t/innodb-alter-table.test @@ -138,3 +138,36 @@ SHOW CREATE TABLE child; DROP TABLE child, parent; +# +# MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash +# +CREATE TABLE IF NOT EXISTS ticket ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + mask VARCHAR(16) DEFAULT '' NOT NULL, + subject VARCHAR(255) DEFAULT '' NOT NULL, + is_closed TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL, + is_deleted TINYINT(1) UNSIGNED DEFAULT 0 NOT NULL, + team_id INT UNSIGNED DEFAULT 0 NOT NULL, + category_id INT UNSIGNED DEFAULT 0 NOT NULL, + first_message_id INT UNSIGNED DEFAULT 0 NOT NULL, + created_date INT UNSIGNED, + updated_date INT UNSIGNED, + due_date INT UNSIGNED, + first_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0, + last_wrote_address_id INT UNSIGNED NOT NULL DEFAULT 0, + spam_score DECIMAL(4,4) NOT NULL DEFAULT 0, + spam_training VARCHAR(1) NOT NULL DEFAULT '', + interesting_words VARCHAR(255) NOT NULL DEFAULT '', + next_action VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY (id) +) ENGINE=InnoDB; + +ALTER TABLE ticket + CHANGE COLUMN team_id group_id INT UNSIGNED NOT NULL DEFAULT 0, + CHANGE COLUMN category_id bucket_id INT UNSIGNED NOT NULL DEFAULT 0, + ADD COLUMN org_id INT UNSIGNED NOT NULL DEFAULT 0, + ADD INDEX org_id (org_id); + +SHOW CREATE TABLE ticket; + +DROP TABLE ticket; diff --git a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test index ec1ea35f1cf..e1e736fc678 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test +++ b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test @@ -20,6 +20,13 @@ --echo # in-place ALTERs of the same table will not be blocked due to --echo # temporary tablename. +# As we intentionally crash below, there could be partially written +# pages that are then recovered from the doublewrite buffer +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed +"); +call mtr.add_suppression("InnoDB: file read of space .* page .*"); +call mtr.add_suppression("InnoDB: Trying to recover it from the doublewrite buffer."); + let datadir= `select @@datadir`; --let $_server_id= `SELECT @@server_id` diff --git a/mysql-test/suite/innodb/t/innodb-fk-warnings.test b/mysql-test/suite/innodb/t/innodb-fk-warnings.test index a95a7f55a40..f45ae00d788 100644 --- a/mysql-test/suite/innodb/t/innodb-fk-warnings.test +++ b/mysql-test/suite/innodb/t/innodb-fk-warnings.test @@ -87,16 +87,16 @@ create temporary table t1(a int not null primary key, b int, key(b)) engine=inno --echo Warning 150 Alter table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary close to foreign key(b) references t1(a). --echo Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed") --echo Warning 1215 Cannot add foreign key constraint -#--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ -#--error 1005 -#create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb; -#--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ -#show warnings; -#--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ -#--error 1005 -#alter table t1 add foreign key(b) references t1(a); -#--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ -#show warnings; +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +--error 1005 +create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb; +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +show warnings; +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +--error 1005 +alter table t1 add foreign key(b) references t1(a); +--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/ +show warnings; drop table t1; # diff --git a/mysql-test/suite/innodb/t/innodb-fkcheck.test b/mysql-test/suite/innodb/t/innodb-fkcheck.test new file mode 100644 index 00000000000..51e36ae6984 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-fkcheck.test @@ -0,0 +1,115 @@ +--source include/have_innodb.inc + +# +# MDEV-10083: Orphan ibd file when playing with foreign keys +# +--disable_query_log +SET @start_global_fpt = @@global.innodb_file_per_table; +SET @start_global_fkc = @@global.foreign_key_checks; +--enable_query_log + +set global innodb_file_per_table = 1; + +--disable_warnings +drop table if exists b; +drop database if exists bug_fk; +--enable_warnings + +let $MYSQLD_DATADIR = `select @@datadir`; + +create database bug_fk; +use bug_fk; + +CREATE TABLE b ( + b int unsigned NOT NULL, + d1 datetime NOT NULL, + PRIMARY KEY (b,d1) +) ENGINE=InnoDB; + +CREATE TABLE c ( + b int unsigned NOT NULL, + d1 datetime NOT NULL, + d2 datetime NOT NULL, + PRIMARY KEY (b,d1), + CONSTRAINT b_fk FOREIGN KEY (b) REFERENCES b (b) +) ENGINE=InnoDB; + +show warnings; + +set foreign_key_checks = 0; + +DROP TABLE IF EXISTS b; + +show create table c; + +# +# Note that column b has different type in parent table +# +--error 1005 +CREATE TABLE b ( + b bigint unsigned NOT NULL, + d1 date NOT NULL, + PRIMARY KEY (b,d1) +) ENGINE=InnoDB; + +show warnings; + +DROP TABLE IF EXISTS d; + +CREATE TABLE d ( + b bigint unsigned NOT NULL, + d1 date NOT NULL, + PRIMARY KEY (b,d1), + CONSTRAINT bd_fk FOREIGN KEY (b) REFERENCES b (b) +) ENGINE=InnoDB; + +show warnings; + +set foreign_key_checks = 1; + +show create table c; +show create table d; + +# +# Table c column b used on foreign key has different type +# compared referenced column b in table b, but this +# create still produced b.ibd file. This is because +# we row_drop_table_for_mysql was called and referenced +# table is not allowed to be dropped even in case +# when actual create is not successfull. +# +--error 1005 +CREATE TABLE b ( + b bigint unsigned NOT NULL, + d1 date NOT NULL, + PRIMARY KEY (b,d1) +) ENGINE=InnoDB; + +show warnings; + +--list_files $MYSQLD_DATADIR/bug_fk b* + +set foreign_key_checks=0; + +drop table c; +drop table d; + +--list_files $MYSQLD_DATADIR/bug_fk b* + +create table b(id int) engine=innodb; +show warnings; + +--list_files $MYSQLD_DATADIR/bug_fk b* + +# +# Cleanup +# +--disable_query_log +SET @@global.innodb_file_per_table = @start_global_fpt; +SET @@global.foreign_key_checks = @start_global_fkc; +--enable_query_log + +--disable_warnings +drop table if exists b; +drop database if exists bug_fk; +--enable_warnings diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test index d6d77076b83..ee04e8d66fc 100644 --- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test +++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test @@ -2,46 +2,24 @@ # Test for persistent corrupt bit for corrupted index and table # -- source include/have_innodb.inc --- source include/have_innodb_16k.inc - -# Issues with innodb_change_buffering_debug on Windows, so the test scenario -# cannot be created on windows ---source include/not_windows.inc - +#-- source include/have_innodb_16k.inc +-- source include/not_embedded.inc # This test needs debug server ---source include/have_debug.inc +-- source include/have_debug.inc -- disable_query_log -call mtr.add_suppression("Flagged corruption of idx.*in CHECK TABLE"); -# This test setup is extracted from bug56680.test: -# The flag innodb_change_buffering_debug is only available in debug builds. -# It instructs InnoDB to try to evict pages from the buffer pool when -# change buffering is possible, so that the change buffer will be used -# whenever possible. -SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; -SET GLOBAL innodb_change_buffering_debug = 1; - -# Turn off Unique Check to create corrupted index with dup key -SET UNIQUE_CHECKS=0; - -CREATE DATABASE pad; -let $i=338; -while ($i) -{ ---eval CREATE TABLE pad.t$i(a INT PRIMARY KEY)ENGINE=InnoDB; - dec $i; -} - --- enable_query_log +call mtr.add_suppression("Flagged corruption of idx.*in"); set names utf8; +SET UNIQUE_CHECKS=0; + CREATE TABLE corrupt_bit_test_ā( a INT AUTO_INCREMENT PRIMARY KEY, b CHAR(100), c INT, z INT, - INDEX(b)) + INDEX idx(b)) ENGINE=InnoDB; INSERT INTO corrupt_bit_test_ā VALUES(0,'x',1, 1); @@ -54,37 +32,20 @@ CREATE UNIQUE INDEX idxē ON corrupt_bit_test_ā(z, b); SELECT * FROM corrupt_bit_test_ā; -select @@unique_checks; -select @@innodb_change_buffering_debug; - -# Create enough rows for the table, so that the insert buffer will be -# used for modifying the secondary index page. There must be multiple -# index pages, because changes to the root page are never buffered. - INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_ā; -INSERT INTO corrupt_bit_test_ā SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_ā; select count(*) from corrupt_bit_test_ā; -CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c); - -# Create a dup key error on index "idxē" and "idxā" by inserting a dup value -INSERT INTO corrupt_bit_test_ā VALUES(13000,'x',1,1); - -# creating an index should succeed even if other secondary indexes are corrupted -CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z); - -# Check table will find the unique indexes corrupted -# with dup key +# This will flag all secondary indexes corrupted +SET SESSION debug_dbug="+d,dict_set_index_corrupted"; check table corrupt_bit_test_ā; +SET SESSION debug_dbug=""; + +# Cannot create new indexes while corrupted indexes exist +--error ER_INDEX_CORRUPT +CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c); +--error ER_INDEX_CORRUPT +CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z); # This selection intend to use the corrupted index. Expect to fail -- error ER_INDEX_CORRUPT @@ -109,7 +70,6 @@ delete from corrupt_bit_test_ā where a = 10001; insert into corrupt_bit_test_ā values (10001, "a", 20001, 20001); rollback; -# Drop one corrupted index before reboot drop index idxā on corrupt_bit_test_ā; check table corrupt_bit_test_ā; @@ -119,14 +79,26 @@ set names utf8; -- error ER_INDEX_CORRUPT select z from corrupt_bit_test_ā; +show create table corrupt_bit_test_ā; + # Drop the corrupted index drop index idxē on corrupt_bit_test_ā; +# Cannot create new indexes while a corrupt index exists. +--error ER_INDEX_CORRUPT +CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c); +--error ER_INDEX_CORRUPT +CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z); + +show create table corrupt_bit_test_ā; +drop index idx on corrupt_bit_test_ā; + +# Now that there exist no corrupted indexes, we can create new indexes. +CREATE INDEX idx3 ON corrupt_bit_test_ā(b, c); +CREATE INDEX idx4 ON corrupt_bit_test_ā(b, z); + # Now select back to normal select z from corrupt_bit_test_ā limit 10; # Drop table drop table corrupt_bit_test_ā; -DROP DATABASE pad; - -SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/perfschema/r/nesting.result b/mysql-test/suite/perfschema/r/nesting.result index 2bf65c30e4a..e17b3009758 100644 --- a/mysql-test/suite/perfschema/r/nesting.result +++ b/mysql-test/suite/perfschema/r/nesting.result @@ -167,75 +167,77 @@ relative_event_id relative_end_event_id event_name comment nesting_event_type re 57 58 stage/sql/cleaning up (stage) STATEMENT 40 58 58 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 57 59 59 idle idle NULL NULL -60 76 statement/sql/select select "This is the first part of a multi query" as payload; +60 77 statement/sql/select select "This is the first part of a multi query" as payload; select "And this is the second part of a multi query" as payload; select "With a third part to make things complete" as payload NULL NULL -61 64 stage/sql/init (stage) STATEMENT 60 +61 65 stage/sql/init (stage) STATEMENT 60 62 62 wait/io/socket/sql/client_connection recv STAGE 61 63 63 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 61 64 64 wait/io/file/sql/query_log write STAGE 61 -65 65 stage/sql/checking permissions (stage) STATEMENT 60 -66 66 stage/sql/Opening tables (stage) STATEMENT 60 -67 67 stage/sql/After opening tables (stage) STATEMENT 60 -68 68 stage/sql/init (stage) STATEMENT 60 -69 69 stage/sql/optimizing (stage) STATEMENT 60 -70 70 stage/sql/executing (stage) STATEMENT 60 -71 71 stage/sql/end (stage) STATEMENT 60 -72 72 stage/sql/query end (stage) STATEMENT 60 -73 73 stage/sql/closing tables (stage) STATEMENT 60 -74 76 stage/sql/freeing items (stage) STATEMENT 60 -75 75 wait/io/socket/sql/client_connection send STAGE 74 -76 76 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 74 -77 91 statement/sql/select select "And this is the second part of a multi query" as payload; +65 65 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 61 +66 66 stage/sql/checking permissions (stage) STATEMENT 60 +67 67 stage/sql/Opening tables (stage) STATEMENT 60 +68 68 stage/sql/After opening tables (stage) STATEMENT 60 +69 69 stage/sql/init (stage) STATEMENT 60 +70 70 stage/sql/optimizing (stage) STATEMENT 60 +71 71 stage/sql/executing (stage) STATEMENT 60 +72 72 stage/sql/end (stage) STATEMENT 60 +73 73 stage/sql/query end (stage) STATEMENT 60 +74 74 stage/sql/closing tables (stage) STATEMENT 60 +75 77 stage/sql/freeing items (stage) STATEMENT 60 +76 76 wait/io/socket/sql/client_connection send STAGE 75 +77 77 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 75 +78 93 statement/sql/select select "And this is the second part of a multi query" as payload; select "With a third part to make things complete" as payload NULL NULL -78 79 stage/sql/init (stage) STATEMENT 77 -79 79 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 78 -80 80 stage/sql/checking permissions (stage) STATEMENT 77 -81 81 stage/sql/Opening tables (stage) STATEMENT 77 -82 82 stage/sql/After opening tables (stage) STATEMENT 77 -83 83 stage/sql/init (stage) STATEMENT 77 -84 84 stage/sql/optimizing (stage) STATEMENT 77 -85 85 stage/sql/executing (stage) STATEMENT 77 -86 86 stage/sql/end (stage) STATEMENT 77 -87 87 stage/sql/query end (stage) STATEMENT 77 -88 88 stage/sql/closing tables (stage) STATEMENT 77 -89 91 stage/sql/freeing items (stage) STATEMENT 77 -90 90 wait/io/socket/sql/client_connection send STAGE 89 -91 91 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 89 -92 108 statement/sql/select select "With a third part to make things complete" as payload NULL NULL -93 94 stage/sql/init (stage) STATEMENT 92 -94 94 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 93 -95 95 stage/sql/checking permissions (stage) STATEMENT 92 -96 96 stage/sql/Opening tables (stage) STATEMENT 92 -97 97 stage/sql/After opening tables (stage) STATEMENT 92 -98 98 stage/sql/init (stage) STATEMENT 92 -99 99 stage/sql/optimizing (stage) STATEMENT 92 -100 100 stage/sql/executing (stage) STATEMENT 92 -101 101 stage/sql/end (stage) STATEMENT 92 -102 102 stage/sql/query end (stage) STATEMENT 92 -103 103 stage/sql/closing tables (stage) STATEMENT 92 -104 104 stage/sql/freeing items (stage) STATEMENT 92 -105 105 wait/io/socket/sql/client_connection send STATEMENT 92 -106 106 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 92 -107 108 stage/sql/cleaning up (stage) STATEMENT 92 -108 108 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 107 -109 109 idle idle NULL NULL -110 128 statement/sql/select select "MARKER_END" as marker NULL NULL -111 114 stage/sql/init (stage) STATEMENT 110 -112 112 wait/io/socket/sql/client_connection recv STAGE 111 -113 113 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 111 -114 114 wait/io/file/sql/query_log write STAGE 111 -115 115 stage/sql/checking permissions (stage) STATEMENT 110 -116 116 stage/sql/Opening tables (stage) STATEMENT 110 -117 117 stage/sql/After opening tables (stage) STATEMENT 110 -118 118 stage/sql/init (stage) STATEMENT 110 -119 119 stage/sql/optimizing (stage) STATEMENT 110 -120 120 stage/sql/executing (stage) STATEMENT 110 -121 121 stage/sql/end (stage) STATEMENT 110 -122 122 stage/sql/query end (stage) STATEMENT 110 -123 123 stage/sql/closing tables (stage) STATEMENT 110 -124 124 stage/sql/freeing items (stage) STATEMENT 110 -125 125 wait/io/socket/sql/client_connection send STATEMENT 110 -126 126 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 110 -127 128 stage/sql/cleaning up (stage) STATEMENT 110 -128 128 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 127 +79 81 stage/sql/init (stage) STATEMENT 78 +80 80 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 79 +81 81 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 79 +82 82 stage/sql/checking permissions (stage) STATEMENT 78 +83 83 stage/sql/Opening tables (stage) STATEMENT 78 +84 84 stage/sql/After opening tables (stage) STATEMENT 78 +85 85 stage/sql/init (stage) STATEMENT 78 +86 86 stage/sql/optimizing (stage) STATEMENT 78 +87 87 stage/sql/executing (stage) STATEMENT 78 +88 88 stage/sql/end (stage) STATEMENT 78 +89 89 stage/sql/query end (stage) STATEMENT 78 +90 90 stage/sql/closing tables (stage) STATEMENT 78 +91 93 stage/sql/freeing items (stage) STATEMENT 78 +92 92 wait/io/socket/sql/client_connection send STAGE 91 +93 93 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 91 +94 110 statement/sql/select select "With a third part to make things complete" as payload NULL NULL +95 96 stage/sql/init (stage) STATEMENT 94 +96 96 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 95 +97 97 stage/sql/checking permissions (stage) STATEMENT 94 +98 98 stage/sql/Opening tables (stage) STATEMENT 94 +99 99 stage/sql/After opening tables (stage) STATEMENT 94 +100 100 stage/sql/init (stage) STATEMENT 94 +101 101 stage/sql/optimizing (stage) STATEMENT 94 +102 102 stage/sql/executing (stage) STATEMENT 94 +103 103 stage/sql/end (stage) STATEMENT 94 +104 104 stage/sql/query end (stage) STATEMENT 94 +105 105 stage/sql/closing tables (stage) STATEMENT 94 +106 106 stage/sql/freeing items (stage) STATEMENT 94 +107 107 wait/io/socket/sql/client_connection send STATEMENT 94 +108 108 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 94 +109 110 stage/sql/cleaning up (stage) STATEMENT 94 +110 110 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 109 +111 111 idle idle NULL NULL +112 130 statement/sql/select select "MARKER_END" as marker NULL NULL +113 116 stage/sql/init (stage) STATEMENT 112 +114 114 wait/io/socket/sql/client_connection recv STAGE 113 +115 115 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 113 +116 116 wait/io/file/sql/query_log write STAGE 113 +117 117 stage/sql/checking permissions (stage) STATEMENT 112 +118 118 stage/sql/Opening tables (stage) STATEMENT 112 +119 119 stage/sql/After opening tables (stage) STATEMENT 112 +120 120 stage/sql/init (stage) STATEMENT 112 +121 121 stage/sql/optimizing (stage) STATEMENT 112 +122 122 stage/sql/executing (stage) STATEMENT 112 +123 123 stage/sql/end (stage) STATEMENT 112 +124 124 stage/sql/query end (stage) STATEMENT 112 +125 125 stage/sql/closing tables (stage) STATEMENT 112 +126 126 stage/sql/freeing items (stage) STATEMENT 112 +127 127 wait/io/socket/sql/client_connection send STATEMENT 112 +128 128 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 112 +129 130 stage/sql/cleaning up (stage) STATEMENT 112 +130 130 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 129 diff --git a/mysql-test/suite/perfschema/r/sizing_low.result b/mysql-test/suite/perfschema/r/sizing_low.result index dce5a994099..a698f55aa07 100644 --- a/mysql-test/suite/perfschema/r/sizing_low.result +++ b/mysql-test/suite/perfschema/r/sizing_low.result @@ -67,3 +67,4 @@ Performance_schema_table_instances_lost 0 Performance_schema_thread_classes_lost 0 Performance_schema_thread_instances_lost 0 Performance_schema_users_lost 0 +CALL mtr.add_suppression("innodb_open_files should not be greater than the open_files_limit."); diff --git a/mysql-test/suite/perfschema/r/start_server_low_digest.result b/mysql-test/suite/perfschema/r/start_server_low_digest.result index ba71e4ea6b0..8cc92f21964 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_digest.result +++ b/mysql-test/suite/perfschema/r/start_server_low_digest.result @@ -8,5 +8,5 @@ SELECT 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+1+1+1+1+1+1+1+1+1+1+1+1 #################################### SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long; event_name digest digest_text sql_text -statement/sql/truncate 9d8bb20bae9d3c7cdfd36bc9d78b1d63 TRUNCATE TABLE truncate table events_statements_history_long -statement/sql/select d4c5d748dcc95f29805e3c04d47d7f64 SELECT ? + ? + SELECT 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+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+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 +statement/sql/truncate e1c917a43f978456fab15240f89372ca TRUNCATE TABLE truncate table events_statements_history_long +statement/sql/select 3f7ca34376814d0e985337bd588b5ffd SELECT ? + ? + SELECT 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+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+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 diff --git a/mysql-test/suite/perfschema/r/table_name.result b/mysql-test/suite/perfschema/r/table_name.result new file mode 100644 index 00000000000..d6369ffc79e --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_name.result @@ -0,0 +1,156 @@ + +# +# TEST 1: Normal tables prefixed with "#sql" and "sql". +# +USE test; +CREATE TABLE `#sql_1` (a int, b text); +INSERT INTO `#sql_1` VALUES(1,'one'); + +CREATE TABLE `sql_1` (a int, b text); +INSERT INTO `sql_1` VALUES(1,'one'); + +# Verify that the tables are treated as normal tables . + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name +TABLE test #sql_1 +TABLE test sql_1 + +# Drop the tables, verify that the table objects are removed. + +DROP TABLE `#sql_1`; +DROP TABLE `sql_1`; + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# +# TEST 2: Temporary tables, no special prefix. +# +CREATE TEMPORARY TABLE sql_temp2_myisam (a int, b text) ENGINE=MYISAM; +INSERT INTO sql_temp2_myisam VALUES(1,'one'); + +CREATE TEMPORARY TABLE sql_temp2_innodb (a int, b text) ENGINE=INNODB; +INSERT INTO sql_temp2_innodb VALUES(1,'one'); + +# Confirm that the temporary tables are ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# Drop the tables, verify that the table objects are not created. + +DROP TABLE sql_temp2_myisam; +DROP TABLE sql_temp2_innodb; + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# +# TEST 3: Temporary tables with the "#sql" prefix. +# +CREATE TEMPORARY TABLE `#sql_temp3_myisam` (a int, b text) ENGINE=MYISAM; +CHECK TABLE `#sql_temp3_myisam`; +Table Op Msg_type Msg_text +test.#sql_temp3_myisam check status OK +INSERT INTO `#sql_temp3_myisam` VALUES(1,'one'); + +CREATE TEMPORARY TABLE `#sql_temp3_innodb` (a int, b text) ENGINE=INNODB; +CHECK TABLE `#sql_temp3_innodb`; +Table Op Msg_type Msg_text +test.#sql_temp3_innodb check status OK +INSERT INTO `#sql_temp3_innodb` VALUES(1,'one'); + +# Confirm that the temporary tables are ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# Drop the temporary tables. + +DROP TABLE `#sql_temp3_myisam`; +DROP TABLE `#sql_temp3_innodb`; + +# Confirm that the temporary tables are still ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# +# TEST 4: Special case: MyISAM temporary tables are recreated as non-temporary +# when they are truncated. +# +CREATE TEMPORARY TABLE `sql_temp4_myisam` (a int, b text) ENGINE=MYISAM; +INSERT INTO `sql_temp4_myisam` VALUES(1,'one'); + +CREATE TEMPORARY TABLE `#sql_temp4_myisam` (a int, b text) ENGINE=MYISAM; +INSERT INTO `#sql_temp4_myisam` VALUES(1,'one'); + +# Confirm that the MyISAM temporary tables are ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# Truncate the MyISAM temporary tables, forcing them to be recreated as non-temporary. + +TRUNCATE TABLE `sql_temp4_myisam`; +TRUNCATE TABLE `#sql_temp4_myisam`; + +# Confirm that the recreated MyISAM tables are still regarded as temporary and ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# Drop the recreated MyISAM tables; + +DROP TABLE `sql_temp4_myisam`; +DROP TABLE `#sql_temp4_myisam`; + +# Confirm that the recreated temporary tables are still ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# +# TEST 5: Generate temporary tables with ALTER MyISAM table. +# +USE test; +CREATE TABLE t1 (a int) ENGINE=MYISAM; +INSERT INTO t1 VALUES (1), (2), (3); +ALTER TABLE t1 ADD COLUMN (b int); + +# Confirm that the recreated temporary tables are still ignored. + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name + +# Drop the MyISAM table + +DROP TABLE t1; + +# Confirm that no tables remain; + +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +object_type object_schema object_name diff --git a/mysql-test/suite/perfschema/t/sizing_low.test b/mysql-test/suite/perfschema/t/sizing_low.test index 4d02d41aecd..56446fd6973 100644 --- a/mysql-test/suite/perfschema/t/sizing_low.test +++ b/mysql-test/suite/perfschema/t/sizing_low.test @@ -7,3 +7,4 @@ --source ../include/sizing_auto.inc +CALL mtr.add_suppression("innodb_open_files should not be greater than the open_files_limit."); diff --git a/mysql-test/suite/perfschema/t/table_name.test b/mysql-test/suite/perfschema/t/table_name.test new file mode 100644 index 00000000000..a8179f2d1f8 --- /dev/null +++ b/mysql-test/suite/perfschema/t/table_name.test @@ -0,0 +1,165 @@ +# +# Performance Schema +# +# Verify that the Performance Schema correctly identifies normal and temporary +# tables with non-standard names. + +# The server uses the table name prefix "#sql" for temporary and intermediate +# tables, however user-defined tables having the "#sql" prefix are also permitted. +# Independent of the table name, temporary or intermediate tables always have the +# "#sql" prefix in the filename. (For non-temporary tables starting with "#", +# the "#" is encoded to @0023 in the filename.) +# +# Given the ambiguity with temporary table names, the Performance Schema identifies +# temporary tables tables either by the table category or by the filename. +# +--source include/have_perfschema.inc +--source include/have_innodb.inc +--source include/not_embedded.inc + +--echo +--echo # +--echo # TEST 1: Normal tables prefixed with "#sql" and "sql". +--echo # +USE test; +CREATE TABLE `#sql_1` (a int, b text); +# INSERT forces path through get_table_share() +INSERT INTO `#sql_1` VALUES(1,'one'); +--echo +CREATE TABLE `sql_1` (a int, b text); +INSERT INTO `sql_1` VALUES(1,'one'); +--echo +--echo # Verify that the tables are treated as normal tables . +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +--echo +--echo # Drop the tables, verify that the table objects are removed. +--echo +DROP TABLE `#sql_1`; +DROP TABLE `sql_1`; +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; + +--echo +--echo # +--echo # TEST 2: Temporary tables, no special prefix. +--echo # +CREATE TEMPORARY TABLE sql_temp2_myisam (a int, b text) ENGINE=MYISAM; +INSERT INTO sql_temp2_myisam VALUES(1,'one'); +--echo +CREATE TEMPORARY TABLE sql_temp2_innodb (a int, b text) ENGINE=INNODB; +INSERT INTO sql_temp2_innodb VALUES(1,'one'); +--echo +--echo # Confirm that the temporary tables are ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +--echo +--echo # Drop the tables, verify that the table objects are not created. +--echo +DROP TABLE sql_temp2_myisam; +DROP TABLE sql_temp2_innodb; +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; + +--echo +--echo # +--echo # TEST 3: Temporary tables with the "#sql" prefix. +--echo # +CREATE TEMPORARY TABLE `#sql_temp3_myisam` (a int, b text) ENGINE=MYISAM; +CHECK TABLE `#sql_temp3_myisam`; +INSERT INTO `#sql_temp3_myisam` VALUES(1,'one'); +--echo +CREATE TEMPORARY TABLE `#sql_temp3_innodb` (a int, b text) ENGINE=INNODB; +CHECK TABLE `#sql_temp3_innodb`; +INSERT INTO `#sql_temp3_innodb` VALUES(1,'one'); +--echo +--echo # Confirm that the temporary tables are ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +--echo +--echo # Drop the temporary tables. +--echo +DROP TABLE `#sql_temp3_myisam`; +DROP TABLE `#sql_temp3_innodb`; +--echo +--echo # Confirm that the temporary tables are still ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; + +--echo +--echo # +--echo # TEST 4: Special case: MyISAM temporary tables are recreated as non-temporary +--echo # when they are truncated. +--echo # +CREATE TEMPORARY TABLE `sql_temp4_myisam` (a int, b text) ENGINE=MYISAM; +INSERT INTO `sql_temp4_myisam` VALUES(1,'one'); +--echo +CREATE TEMPORARY TABLE `#sql_temp4_myisam` (a int, b text) ENGINE=MYISAM; +INSERT INTO `#sql_temp4_myisam` VALUES(1,'one'); +--echo +--echo # Confirm that the MyISAM temporary tables are ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +--echo +--echo # Truncate the MyISAM temporary tables, forcing them to be recreated as non-temporary. +--echo +TRUNCATE TABLE `sql_temp4_myisam`; +TRUNCATE TABLE `#sql_temp4_myisam`; +--echo +--echo # Confirm that the recreated MyISAM tables are still regarded as temporary and ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +--echo +--echo # Drop the recreated MyISAM tables; +--echo +DROP TABLE `sql_temp4_myisam`; +DROP TABLE `#sql_temp4_myisam`; +--echo +--echo # Confirm that the recreated temporary tables are still ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; + +--echo +--echo # +--echo # TEST 5: Generate temporary tables with ALTER MyISAM table. +--echo # +USE test; +CREATE TABLE t1 (a int) ENGINE=MYISAM; +INSERT INTO t1 VALUES (1), (2), (3); +# Force a path throug mysql_alter_table() and ha_create_table(). +ALTER TABLE t1 ADD COLUMN (b int); +--echo +--echo # Confirm that the recreated temporary tables are still ignored. +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; +--echo +--echo # Drop the MyISAM table +--echo +DROP TABLE t1; + +--echo +--echo # Confirm that no tables remain; +--echo +SELECT object_type, object_schema, object_name +FROM performance_schema.objects_summary_global_by_type +WHERE object_schema="test"; diff --git a/mysql-test/suite/plugins/r/pam_cleartext.result b/mysql-test/suite/plugins/r/pam_cleartext.result index 00e0e94618e..824e8329cc3 100644 --- a/mysql-test/suite/plugins/r/pam_cleartext.result +++ b/mysql-test/suite/plugins/r/pam_cleartext.result @@ -2,9 +2,12 @@ install plugin pam soname 'auth_pam.so'; create user test_pam identified via pam using 'mariadb_mtr'; create user pam_test; grant proxy on pam_test to test_pam; -show variables like 'pam%'; +show variables like 'pam_use_%'; Variable_name Value pam_use_cleartext_plugin ON +# +# same test as in pam.test now fails +# drop user test_pam; drop user pam_test; uninstall plugin pam; diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 2577a36cad4..83b88ed0480 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -165,7 +165,7 @@ CREATE USER u1 IDENTIFIED BY 'pwd-123'; GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; SET PASSWORD FOR u1 = PASSWORD('pwd 098'); SET PASSWORD FOR u1=; -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 '=' at line 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 '' at line 1 CREATE USER u3 IDENTIFIED BY ''; drop user u1, u2, u3; select 2; diff --git a/mysql-test/suite/plugins/r/simple_password_check.result b/mysql-test/suite/plugins/r/simple_password_check.result index bbb96bb8c38..6848a37999c 100644 --- a/mysql-test/suite/plugins/r/simple_password_check.result +++ b/mysql-test/suite/plugins/r/simple_password_check.result @@ -85,7 +85,11 @@ grant select on *.* to foo1; drop user foo1; set global simple_password_check_digits=3; set global simple_password_check_letters_same_case=3; +Warnings: +Warning 1292 Adjusted the value of simple_password_check_minimal_length from 8 to 10 set global simple_password_check_other_characters=3; +Warnings: +Warning 1292 Adjusted the value of simple_password_check_minimal_length from 10 to 12 show variables like 'simple_password_check_%'; Variable_name Value simple_password_check_digits 3 diff --git a/mysql-test/suite/plugins/r/thread_pool_server_audit.result b/mysql-test/suite/plugins/r/thread_pool_server_audit.result index 2577a36cad4..83b88ed0480 100644 --- a/mysql-test/suite/plugins/r/thread_pool_server_audit.result +++ b/mysql-test/suite/plugins/r/thread_pool_server_audit.result @@ -165,7 +165,7 @@ CREATE USER u1 IDENTIFIED BY 'pwd-123'; GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; SET PASSWORD FOR u1 = PASSWORD('pwd 098'); SET PASSWORD FOR u1=; -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 '=' at line 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 '' at line 1 CREATE USER u3 IDENTIFIED BY ''; drop user u1, u2, u3; select 2; diff --git a/mysql-test/suite/plugins/t/pam.test b/mysql-test/suite/plugins/t/pam.test index 1871e5801a3..8a95d6baed2 100644 --- a/mysql-test/suite/plugins/t/pam.test +++ b/mysql-test/suite/plugins/t/pam.test @@ -29,5 +29,6 @@ EOF --remove_file $MYSQLTEST_VARDIR/tmp/pam_bad.txt drop user test_pam; drop user pam_test; +let $count_sessions= 1; +--source include/wait_until_count_sessions.inc uninstall plugin pam; - diff --git a/mysql-test/suite/plugins/t/pam_cleartext.test b/mysql-test/suite/plugins/t/pam_cleartext.test index 6b9bf087ce5..29ed7430649 100644 --- a/mysql-test/suite/plugins/t/pam_cleartext.test +++ b/mysql-test/suite/plugins/t/pam_cleartext.test @@ -1,13 +1,24 @@ --source pam_init.inc -show variables like 'pam%'; +show variables like 'pam_use_%'; +--write_file $MYSQLTEST_VARDIR/tmp/pam_good.txt +not very secret challenge +9225 +select user(), current_user(), database(); +EOF + +--echo # +--echo # same test as in pam.test now fails +--echo # --error 1 ---exec echo FAIL | $MYSQL_TEST -u test_pam --plugin-dir=$plugindir +--exec $MYSQL_TEST -u test_pam --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/pam_good.txt + +--remove_file $MYSQLTEST_VARDIR/tmp/pam_good.txt drop user test_pam; drop user pam_test; ---disable_warnings +let $count_sessions= 1; +--source include/wait_until_count_sessions.inc uninstall plugin pam; - diff --git a/mysql-test/suite/roles/rpl_grant_revoke_current_role-8638.result b/mysql-test/suite/roles/rpl_grant_revoke_current_role-8638.result new file mode 100644 index 00000000000..67af4a068d6 --- /dev/null +++ b/mysql-test/suite/roles/rpl_grant_revoke_current_role-8638.result @@ -0,0 +1,21 @@ +include/master-slave.inc +[connection master] +create role r1; +set role r1; +grant select on db.* to current_role; +revoke all privileges, grant option from current_role; +drop role r1; +include/rpl_end.inc +connection server_2; +connection server_2; +connection server_2; +connection server_2; +connection server_1; +connection server_1; +connection server_1; +connection server_2; +connection server_1; +connection server_2; +connection server_2; +connection server_1; +connection server_1; diff --git a/mysql-test/suite/roles/rpl_grant_revoke_current_role-8638.test b/mysql-test/suite/roles/rpl_grant_revoke_current_role-8638.test new file mode 100644 index 00000000000..6a6c4f2a756 --- /dev/null +++ b/mysql-test/suite/roles/rpl_grant_revoke_current_role-8638.test @@ -0,0 +1,12 @@ +--source include/master-slave.inc +--source include/have_binlog_format_mixed.inc + +--enable_connect_log + +create role r1; +set role r1; +grant select on db.* to current_role; +revoke all privileges, grant option from current_role; +drop role r1; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/roles/set_role-9614.result b/mysql-test/suite/roles/set_role-9614.result new file mode 100644 index 00000000000..37f6db070c0 --- /dev/null +++ b/mysql-test/suite/roles/set_role-9614.result @@ -0,0 +1,99 @@ +# +# MDEV-9614 Roles and Users Longer than 6 characters +# +# This test case checks the edge case presented in the MDEV. The +# real issue is actually apparent when the username is longer than the +# rolename. +# +# We need a separate database not including test or test_% names. Due to +# default privileges given on these databases. +# +DROP DATABASE IF EXISTS `bug_db`; +Warnings: +Note 1008 Can't drop database 'bug_db'; database doesn't exist +# +# The first user did not show the bug as john's length is smaller +# than client. The bug is apparent most of the time for usertestjohn. +# +CREATE USER `john`@`%`; +CREATE USER `usertestjohn`@`%`; +CREATE ROLE `client`; +# +# Setup the required tables. +# +CREATE DATABASE `bug_db`; +CREATE TABLE `bug_db`.`t0`(`c0` INT); +# +# Setup select privileges only on the role. Setting the role should give +# select access to bug_db.t0. +# +GRANT SELECT ON `bug_db`.`t0` TO `client`; +GRANT `client` TO `john`@`%`; +GRANT `client` TO `usertestjohn`@`%`; +# +# Check to see grants are set. +# +SHOW GRANTS FOR `john`@`%`; +Grants for john@% +GRANT client TO 'john'@'%' +GRANT USAGE ON *.* TO 'john'@'%' +SHOW GRANTS FOR `usertestjohn`@`%`; +Grants for usertestjohn@% +GRANT client TO 'usertestjohn'@'%' +GRANT USAGE ON *.* TO 'usertestjohn'@'%' +SHOW GRANTS FOR `client`; +Grants for client +GRANT USAGE ON *.* TO 'client' +GRANT SELECT ON `bug_db`.`t0` TO 'client' +show databases; +Database +bug_db +information_schema +mtr +mysql +performance_schema +test +# +# Try using the database as john. +# +connect john, localhost, john,,information_schema; +show databases; +Database +information_schema +test +set role client; +show databases; +Database +bug_db +information_schema +test +use bug_db; +# +# Try using the database as usertestjohn. +# +connect usertestjohn, localhost, usertestjohn,,information_schema; +show databases; +Database +information_schema +test +set role client; +show databases; +Database +bug_db +information_schema +test +show grants; +Grants for usertestjohn@% +GRANT client TO 'usertestjohn'@'%' +GRANT USAGE ON *.* TO 'usertestjohn'@'%' +GRANT USAGE ON *.* TO 'client' +GRANT SELECT ON `bug_db`.`t0` TO 'client' +use bug_db; +# +# Cleanup +# +connection default; +drop user john; +drop user usertestjohn; +drop role client; +drop database bug_db; diff --git a/mysql-test/suite/roles/set_role-9614.test b/mysql-test/suite/roles/set_role-9614.test new file mode 100644 index 00000000000..5e9f7dacf19 --- /dev/null +++ b/mysql-test/suite/roles/set_role-9614.test @@ -0,0 +1,79 @@ +--source include/not_embedded.inc + +--echo # +--echo # MDEV-9614 Roles and Users Longer than 6 characters +--echo # +--echo # This test case checks the edge case presented in the MDEV. The +--echo # real issue is actually apparent when the username is longer than the +--echo # rolename. + +--enable_connect_log +--echo # +--echo # We need a separate database not including test or test_% names. Due to +--echo # default privileges given on these databases. +--echo # +DROP DATABASE IF EXISTS `bug_db`; + +--echo # +--echo # The first user did not show the bug as john's length is smaller +--echo # than client. The bug is apparent most of the time for usertestjohn. +--echo # +CREATE USER `john`@`%`; +CREATE USER `usertestjohn`@`%`; +CREATE ROLE `client`; + +--echo # +--echo # Setup the required tables. +--echo # +CREATE DATABASE `bug_db`; +CREATE TABLE `bug_db`.`t0`(`c0` INT); + +--echo # +--echo # Setup select privileges only on the role. Setting the role should give +--echo # select access to bug_db.t0. +--echo # +GRANT SELECT ON `bug_db`.`t0` TO `client`; +GRANT `client` TO `john`@`%`; +GRANT `client` TO `usertestjohn`@`%`; + +--echo # +--echo # Check to see grants are set. +--echo # +SHOW GRANTS FOR `john`@`%`; +SHOW GRANTS FOR `usertestjohn`@`%`; +SHOW GRANTS FOR `client`; + +show databases; + +--echo # +--echo # Try using the database as john. +--echo # +connect (john, localhost, john,,information_schema); + +show databases; +set role client; +show databases; +use bug_db; + +--echo # +--echo # Try using the database as usertestjohn. +--echo # +connect (usertestjohn, localhost, usertestjohn,,information_schema); + +show databases; +set role client; +show databases; + +show grants; +use bug_db; + + +--echo # +--echo # Cleanup +--echo # +connection default; +drop user john; +drop user usertestjohn; +drop role client; +drop database bug_db; +--disable_connect_log diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result b/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result index e5e690bdf52..1e0ac5ab940 100644 --- a/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result @@ -96,13 +96,11 @@ f5 DOUBLE DEFAULT '2.00', f6 ENUM('a', 'b', 'c') default 'a', f7 DECIMAL(17,9) default '1000.00', f8 MEDIUMBLOB, -f9 NUMERIC(6,4) default '2000.00', +f9 NUMERIC(6,2) default '2000.00', f10 VARCHAR(1024), f11 BINARY(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f12 SET('a', 'b', 'c') default 'b') ENGINE='InnoDB'; -Warnings: -Warning 1264 Out of range value for column 'f9' at row 1 CREATE TABLE t3 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), /* extra */ @@ -119,13 +117,11 @@ CREATE TABLE t4 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), f5 DOUBLE DEFAULT '2.00', f6 DECIMAL(17,9) default '1000.00', f7 MEDIUMBLOB, -f8 NUMERIC(6,4) default '2000.00', +f8 NUMERIC(6,2) default '2000.00', f9 VARCHAR(1024), f10 BINARY(20) not null default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f11 CHAR(255)) ENGINE='InnoDB'; -Warnings: -Warning 1264 Out of range value for column 'f8' at row 1 CREATE TABLE t31 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), /* extra */ @@ -184,9 +180,6 @@ INSERT into t2 values (2, 2, 2, 'second', (3, 3, 3, 'third', 3.0, 'b', 3000.0003, 'f8: medium size blob', 3000, 'f10: some var char', '01234567', 'c'); -Warnings: -Warning 1264 Out of range value for column 'f9' at row 1 -Warning 1264 Out of range value for column 'f9' at row 2 INSERT into t3 set f1=1, f2=1, f3=1, f4='first', f10='f10: some var char'; INSERT into t4 set f1=1, f2=1, f3=1, f4='first', f7='f7: medium size blob', f10='f10: binary data'; diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result b/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result index 9247ceb1030..38ef9dbff80 100644 --- a/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result +++ b/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result @@ -96,13 +96,11 @@ f5 DOUBLE DEFAULT '2.00', f6 ENUM('a', 'b', 'c') default 'a', f7 DECIMAL(17,9) default '1000.00', f8 MEDIUMBLOB, -f9 NUMERIC(6,4) default '2000.00', +f9 NUMERIC(6,2) default '2000.00', f10 VARCHAR(1024), f11 BINARY(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f12 SET('a', 'b', 'c') default 'b') ENGINE='MyISAM'; -Warnings: -Warning 1264 Out of range value for column 'f9' at row 1 CREATE TABLE t3 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), /* extra */ @@ -119,13 +117,11 @@ CREATE TABLE t4 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), f5 DOUBLE DEFAULT '2.00', f6 DECIMAL(17,9) default '1000.00', f7 MEDIUMBLOB, -f8 NUMERIC(6,4) default '2000.00', +f8 NUMERIC(6,2) default '2000.00', f9 VARCHAR(1024), f10 BINARY(20) not null default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f11 CHAR(255)) ENGINE='MyISAM'; -Warnings: -Warning 1264 Out of range value for column 'f8' at row 1 CREATE TABLE t31 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), /* extra */ @@ -184,9 +180,6 @@ INSERT into t2 values (2, 2, 2, 'second', (3, 3, 3, 'third', 3.0, 'b', 3000.0003, 'f8: medium size blob', 3000, 'f10: some var char', '01234567', 'c'); -Warnings: -Warning 1264 Out of range value for column 'f9' at row 1 -Warning 1264 Out of range value for column 'f9' at row 2 INSERT into t3 set f1=1, f2=1, f3=1, f4='first', f10='f10: some var char'; INSERT into t4 set f1=1, f2=1, f3=1, f4='first', f7='f7: medium size blob', f10='f10: binary data'; diff --git a/mysql-test/suite/rpl/r/rpl_ignore_table.result b/mysql-test/suite/rpl/r/rpl_ignore_table.result index aa5f6d3e6db..75445bec823 100644 --- a/mysql-test/suite/rpl/r/rpl_ignore_table.result +++ b/mysql-test/suite/rpl/r/rpl_ignore_table.result @@ -144,4 +144,5 @@ HEX(word) SELECT * FROM tmptbl504451f4258$1; ERROR 42S02: Table 'test.tmptbl504451f4258$1' doesn't exist DROP TABLE t5; +flush privileges; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_ignore_table.test b/mysql-test/suite/rpl/t/rpl_ignore_table.test index f9b01c83917..111b6159ec7 100644 --- a/mysql-test/suite/rpl/t/rpl_ignore_table.test +++ b/mysql-test/suite/rpl/t/rpl_ignore_table.test @@ -1,6 +1,6 @@ -source include/master-slave.inc; let collation=utf8_unicode_ci; ---source include/have_collation.inc +source include/have_collation.inc; +source include/master-slave.inc; call mtr.add_suppression("Can't find record in 't.'"); call mtr.add_suppression("Can't find record in 'user'"); @@ -181,6 +181,7 @@ SELECT HEX(word) FROM t5; SELECT * FROM tmptbl504451f4258$1; connection master; DROP TABLE t5; +flush privileges; sync_slave_with_master; --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_mdev6020.test b/mysql-test/suite/rpl/t/rpl_mdev6020.test index 2fd342f5eda..8484e3e11c0 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev6020.test +++ b/mysql-test/suite/rpl/t/rpl_mdev6020.test @@ -1,8 +1,10 @@ +# Running this with valgrind can take > 5000 seconds with xtradb +--source include/not_valgrind.inc + --source include/have_innodb.inc --source include/have_partition.inc --source include/have_binlog_format_mixed_or_row.inc --source include/master-slave.inc - --connection slave --source include/stop_slave.inc diff --git a/mysql-test/suite/sys_vars/r/general_log_file_basic.result b/mysql-test/suite/sys_vars/r/general_log_file_basic.result index 369ef7844db..c7c24f155ca 100644 --- a/mysql-test/suite/sys_vars/r/general_log_file_basic.result +++ b/mysql-test/suite/sys_vars/r/general_log_file_basic.result @@ -12,6 +12,16 @@ SET @@global.general_log_file = mytest.log; ERROR 42000: Incorrect argument type to variable 'general_log_file' SET @@global.general_log_file = 12; ERROR 42000: Incorrect argument type to variable 'general_log_file' +SET @@global.general_log_file = 'my.cnf'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf' +SET @@global.general_log_file = '/tmp/my.cnf'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of '/tmp/my.cnf' +SET @@global.general_log_file = '.my.cnf'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf' +SET @@global.general_log_file = 'my.cnf\0foo'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf' +SET @@global.general_log_file = 'my.ini'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.ini' '#----------------------FN_DYNVARS_004_03------------------------#' SELECT @@global.general_log_file = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result b/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result index f45c568ff4a..a64666f6298 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result @@ -9,6 +9,16 @@ SET @@global.slow_query_log_file = mytest.log; ERROR 42000: Incorrect argument type to variable 'slow_query_log_file' SET @@global.slow_query_log_file = 12; ERROR 42000: Incorrect argument type to variable 'slow_query_log_file' +SET @@global.slow_query_log_file = 'my.cnf'; +ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'my.cnf' +SET @@global.slow_query_log_file = '/tmp/my.cnf'; +ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/tmp/my.cnf' +SET @@global.general_log_file = '.my.cnf'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf' +SET @@global.general_log_file = 'my.cnf\0foo'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf' +SET @@global.general_log_file = 'my.ini'; +ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.ini' '#----------------------FN_DYNVARS_004_03------------------------#' SELECT @@global.slow_query_log_file = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES diff --git a/mysql-test/suite/sys_vars/r/sysvars_aria.result b/mysql-test/suite/sys_vars/r/sysvars_aria.result index 2948b2ad3fc..1308992e771 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_aria.result +++ b/mysql-test/suite/sys_vars/r/sysvars_aria.result @@ -54,7 +54,7 @@ VARIABLE_COMMENT Encrypt tables (only for tables with ROW_FORMAT=PAGE (default) NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ARIA_FORCE_START_AFTER_RECOVERY_FAILURES @@ -208,7 +208,7 @@ VARIABLE_COMMENT Maintain page checksums (can be overridden per table with PAGE_ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_RECOVER @@ -292,6 +292,6 @@ VARIABLE_COMMENT Whether temporary tables should be MyISAM or Aria NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff index 799ad90a474..3164d094528 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_debug,32bit.rdiff @@ -9,16 +9,3 @@ VARIABLE_COMMENT Extra sleep (in microseconds) to add to binlog fsync(), for debugging NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -35,10 +35,10 @@ - GLOBAL_VALUE_ORIGIN COMPILE-TIME - DEFAULT_VALUE 0 - VARIABLE_SCOPE GLOBAL --VARIABLE_TYPE BIGINT UNSIGNED -+VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Call my_debug_put_break_here() if crc matches this number (for debug) - NUMERIC_MIN_VALUE 0 --NUMERIC_MAX_VALUE 18446744073709551615 -+NUMERIC_MAX_VALUE 4294967295 - NUMERIC_BLOCK_SIZE 1 - ENUM_VALUE_LIST NULL - READ_ONLY NO diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff index c04f4fe3e2d..930fa18541f 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff @@ -111,7 +111,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY YES +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_BUFFER_POOL_SIZE @@ -150,7 +150,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_CLEANER_FLUSH_CHUNK_SIZE @@ -343,7 +343,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FAST_SHUTDOWN @@ -578,7 +578,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_LOCKS_UNSAFE_FOR_BINLOG @@ -624,7 +624,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL - ENUM_VALUE_LIST NULL + ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL -VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES @@ -695,7 +695,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_LOG_CHECKSUM_ALGORITHM @@ -850,7 +850,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_PRIORITY_IO @@ -864,7 +864,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_PRIORITY_MASTER @@ -878,7 +878,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_PRIORITY_PURGE @@ -892,7 +892,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_PURGE_BATCH_SIZE @@ -1134,7 +1134,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT NONE +VARIABLE_NAME INNODB_TRACK_REDO_LOG_NOW @@ -1148,7 +1148,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG @@ -1196,7 +1196,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_MTFLUSH @@ -1217,7 +1217,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY YES +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_SYS_MALLOC @@ -1227,8 +1227,8 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.30 -+GLOBAL_VALUE 5.6.29-76.2 +-GLOBAL_VALUE 5.6.32 ++GLOBAL_VALUE 5.6.31-77.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff index 002cf66300a..aafc0a9e806 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff @@ -36,7 +36,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY YES +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_BUFFER_POOL_SIZE @@ -66,7 +66,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_CLEANER_FLUSH_CHUNK_SIZE @@ -213,7 +213,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FAST_SHUTDOWN @@ -290,7 +290,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_LOCKS_UNSAFE_FOR_BINLOG @@ -311,7 +311,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_LOG_ARCH_DIR @@ -430,7 +430,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_PRIORITY_IO @@ -444,7 +444,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_PRIORITY_MASTER @@ -458,7 +458,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_PRIORITY_PURGE @@ -472,7 +472,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_PURGE_BATCH_SIZE @@ -586,7 +586,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT NONE +VARIABLE_NAME INNODB_TRACK_REDO_LOG_NOW @@ -600,7 +600,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG @@ -630,7 +630,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_MTFLUSH @@ -651,7 +651,7 @@ +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST NULL ++ENUM_VALUE_LIST OFF,ON +READ_ONLY YES +COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_SYS_MALLOC @@ -661,8 +661,8 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.30 -+GLOBAL_VALUE 5.6.29-76.2 +-GLOBAL_VALUE 5.6.32 ++GLOBAL_VALUE 5.6.31-77.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 4f09270a6aa..8ef0d449042 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -16,7 +16,7 @@ VARIABLE_COMMENT Attempt flushing dirty pages to avoid IO bursts at checkpoints. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_ADAPTIVE_FLUSHING_LWM @@ -44,7 +44,7 @@ VARIABLE_COMMENT Enable InnoDB adaptive hash index (enabled by default). Disabl NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_ADAPTIVE_MAX_SLEEP_DELAY @@ -100,7 +100,7 @@ VARIABLE_COMMENT Disable row lock when direct access InnoDB through InnoDB APIs NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_API_ENABLE_BINLOG @@ -114,7 +114,7 @@ VARIABLE_COMMENT Enable binlog for applications direct access InnoDB through Inn NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_API_ENABLE_MDL @@ -128,7 +128,7 @@ VARIABLE_COMMENT Enable MDL for applications direct access InnoDB through InnoDB NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_API_TRX_LEVEL @@ -198,7 +198,7 @@ VARIABLE_COMMENT Enable scrubbing of compressed data by background threads (same NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BACKGROUND_SCRUB_DATA_INTERVAL @@ -226,7 +226,7 @@ VARIABLE_COMMENT Enable scrubbing of uncompressed data by background threads (sa NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_DUMP_AT_SHUTDOWN @@ -240,7 +240,7 @@ VARIABLE_COMMENT Dump the buffer pool into a file named @@innodb_buffer_pool_fil NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_DUMP_NOW @@ -254,7 +254,7 @@ VARIABLE_COMMENT Trigger an immediate dump of the buffer pool into a file named NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_DUMP_PCT @@ -324,7 +324,7 @@ VARIABLE_COMMENT Abort a currently running load of the buffer pool NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_LOAD_AT_STARTUP @@ -338,7 +338,7 @@ VARIABLE_COMMENT Load the buffer pool from a file named @@innodb_buffer_pool_fil NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_LOAD_NOW @@ -352,7 +352,7 @@ VARIABLE_COMMENT Trigger an immediate load of the buffer pool from a file named NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_SIZE @@ -394,7 +394,7 @@ VARIABLE_COMMENT Force dirty page flush now NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_CHANGE_BUFFERING @@ -450,7 +450,7 @@ VARIABLE_COMMENT DEPRECATED. Use innodb_checksum_algorithm=NONE instead of setti NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_CHECKSUM_ALGORITHM @@ -478,7 +478,7 @@ VARIABLE_COMMENT Enable INFORMATION_SCHEMA.innodb_cmp_per_index, may have negati NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_COMMIT_CONCURRENCY @@ -604,7 +604,7 @@ VARIABLE_COMMENT Perform extra scrubbing to increase test exposure NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_DEFAULT_ENCRYPTION_KEY_ID @@ -632,7 +632,7 @@ VARIABLE_COMMENT Enable/disable InnoDB defragmentation (default FALSE). When set NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_DEFRAGMENT_FILL_FACTOR @@ -716,7 +716,7 @@ VARIABLE_COMMENT Disable change buffering merges by the master thread NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_DISABLE_SORT_FILE_CACHE @@ -730,7 +730,7 @@ VARIABLE_COMMENT Whether to disable OS system file cache for sort I/O NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_DOUBLEWRITE @@ -744,7 +744,7 @@ VARIABLE_COMMENT Enable InnoDB doublewrite buffer (enabled by default). Disable NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_DOUBLEWRITE_BATCH_SIZE @@ -814,7 +814,7 @@ VARIABLE_COMMENT Enable redo log encryption NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_ENCRYPT_TABLES @@ -884,7 +884,7 @@ VARIABLE_COMMENT Whether to perform system file format check. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_FILE_FORMAT_MAX @@ -912,7 +912,7 @@ VARIABLE_COMMENT Stores each InnoDB table to an .ibd file in the database dir. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_FIL_MAKE_PAGE_DIRTY_DEBUG @@ -1010,7 +1010,7 @@ VARIABLE_COMMENT Force InnoDB to load metadata of corrupted table. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_FORCE_PRIMARY_KEY @@ -1024,7 +1024,7 @@ VARIABLE_COMMENT Do not allow to create table without primary key (off by defaul NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FORCE_RECOVERY @@ -1094,7 +1094,7 @@ VARIABLE_COMMENT Whether to enable additional FTS diagnostic printout NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FT_ENABLE_STOPWORD @@ -1108,7 +1108,7 @@ VARIABLE_COMMENT Create FTS index with stopword. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FT_MAX_TOKEN_SIZE @@ -1248,7 +1248,7 @@ VARIABLE_COMMENT Enable scrubbing of data NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_INSTRUMENT_SEMAPHORES @@ -1262,7 +1262,7 @@ VARIABLE_COMMENT Enable semaphore request instrumentation. This could have some NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_IO_CAPACITY @@ -1304,7 +1304,7 @@ VARIABLE_COMMENT Support large index prefix length of REC_VERSION_56_MAX_INDEX_C NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG @@ -1332,7 +1332,7 @@ VARIABLE_COMMENT DEPRECATED. This option may be removed in future releases. Plea NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_LOCK_WAIT_TIMEOUT @@ -1374,7 +1374,7 @@ VARIABLE_COMMENT Force checkpoint now NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES @@ -1388,7 +1388,7 @@ VARIABLE_COMMENT Enables/disables the logging of entire compressed page images. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_LOG_FILES_IN_GROUP @@ -1654,7 +1654,7 @@ VARIABLE_COMMENT Only optimize the Fulltext index of the table NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_PAGE_HASH_LOCKS @@ -1696,7 +1696,7 @@ VARIABLE_COMMENT Enable prefix optimization to sometimes avoid cluster index loo NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_PRINT_ALL_DEADLOCKS @@ -1710,7 +1710,7 @@ VARIABLE_COMMENT Print all deadlocks to MySQL error log (off by default) NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_PURGE_BATCH_SIZE @@ -1738,7 +1738,7 @@ VARIABLE_COMMENT Set purge state to RUN NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_PURGE_STOP_NOW @@ -1752,7 +1752,7 @@ VARIABLE_COMMENT Set purge state to STOP NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_PURGE_THREADS @@ -1780,7 +1780,7 @@ VARIABLE_COMMENT Whether to use read ahead for random access within an extent. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_READ_AHEAD_THRESHOLD @@ -1822,7 +1822,7 @@ VARIABLE_COMMENT Start InnoDB in read only mode (off by default) NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_REPLICATION_DELAY @@ -1850,7 +1850,7 @@ VARIABLE_COMMENT Roll back the complete transaction on lock wait timeout, for 4. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_ROLLBACK_SEGMENTS @@ -1892,7 +1892,7 @@ VARIABLE_COMMENT Enable background redo log (ib_logfile0, ib_logfile1...) scrubb NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_SCRUB_LOG_SPEED @@ -1962,7 +1962,7 @@ VARIABLE_COMMENT InnoDB automatic recalculation of persistent statistics enabled NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_STATS_METHOD @@ -2004,7 +2004,7 @@ VARIABLE_COMMENT Enable statistics gathering for metadata commands such as SHOW NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_STATS_PERSISTENT @@ -2018,7 +2018,7 @@ VARIABLE_COMMENT InnoDB persistent statistics enabled for all tables unless over NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_STATS_PERSISTENT_SAMPLE_PAGES @@ -2060,7 +2060,7 @@ VARIABLE_COMMENT Enable traditional statistic calculation based on number of con NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_STATS_TRANSIENT_SAMPLE_PAGES @@ -2088,7 +2088,7 @@ VARIABLE_COMMENT Enable InnoDB monitor output to the error log. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_STATUS_OUTPUT_LOCKS @@ -2102,7 +2102,7 @@ VARIABLE_COMMENT Enable InnoDB lock monitor output to the error log. Requires in NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_STRICT_MODE @@ -2116,7 +2116,7 @@ VARIABLE_COMMENT Use strict mode when evaluating create options. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_SUPPORT_XA @@ -2130,7 +2130,7 @@ VARIABLE_COMMENT Enable InnoDB support for the XA two-phase commit NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_SYNC_ARRAY_SIZE @@ -2172,7 +2172,7 @@ VARIABLE_COMMENT Enable InnoDB locking in LOCK TABLES NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_THREAD_CONCURRENCY @@ -2228,7 +2228,7 @@ VARIABLE_COMMENT Pause actual purging any delete-marked records, but merely upda NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME INNODB_TRX_RSEG_N_SLOTS_DEBUG @@ -2298,7 +2298,7 @@ VARIABLE_COMMENT Prevent partial page writes, via atomic writes.The option is us NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_FALLOCATE @@ -2312,7 +2312,7 @@ VARIABLE_COMMENT Preallocate files fast, using operating system functionality. O NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_MTFLUSH @@ -2326,7 +2326,7 @@ VARIABLE_COMMENT Use multi-threaded flush. Default FALSE. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_SYS_MALLOC @@ -2340,7 +2340,7 @@ VARIABLE_COMMENT DEPRECATED. This option may be removed in future releases, toge NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME INNODB_USE_TRIM @@ -2354,12 +2354,12 @@ VARIABLE_COMMENT Use trim. Default FALSE. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.30 +GLOBAL_VALUE 5.6.32 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 8b373d7d77f..ae61832eb0a 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -230,7 +230,7 @@ VARIABLE_COMMENT Run fast part of group commit in a single thread, to optimize k NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME BINLOG_ROW_IMAGE @@ -2274,7 +2274,7 @@ VARIABLE_COMMENT Use memory mapping for reading and writing MyISAM tables NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME MYSQL56_TEMPORAL_FORMAT diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index e33decf0f0d..0797110926e 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -230,7 +230,7 @@ VARIABLE_COMMENT Run fast part of group commit in a single thread, to optimize k NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME BINLOG_ROW_IMAGE @@ -2470,7 +2470,7 @@ VARIABLE_COMMENT Use memory mapping for reading and writing MyISAM tables NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST NULL +ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NONE VARIABLE_NAME MYSQL56_TEMPORAL_FORMAT diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 4d7b03690af..36d04afb80d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -162,7 +162,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE OFF VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT To use a workaround forbad autoincrement value +VARIABLE_COMMENT Enable a workaround to handle the cases where inserting a DEFAULT value into an auto-increment column could fail with duplicate key error NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL @@ -241,13 +241,13 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME WSREP_MAX_WS_ROWS SESSION_VALUE NULL -GLOBAL_VALUE 131072 +GLOBAL_VALUE 0 GLOBAL_VALUE_ORIGIN COMPILE-TIME -DEFAULT_VALUE 131072 +DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Max number of rows in write set -NUMERIC_MIN_VALUE 1 +NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL @@ -255,14 +255,14 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME WSREP_MAX_WS_SIZE SESSION_VALUE NULL -GLOBAL_VALUE 1073741824 +GLOBAL_VALUE 2147483647 GLOBAL_VALUE_ORIGIN COMPILE-TIME -DEFAULT_VALUE 1073741824 +DEFAULT_VALUE 2147483647 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Max write set size (bytes) NUMERIC_MIN_VALUE 1024 -NUMERIC_MAX_VALUE 4294901759 +NUMERIC_MAX_VALUE 2147483647 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO @@ -311,9 +311,9 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME WSREP_NODE_NAME SESSION_VALUE NULL -GLOBAL_VALUE +GLOBAL_VALUE HOSTNAME GLOBAL_VALUE_ORIGIN COMPILE-TIME -DEFAULT_VALUE +DEFAULT_VALUE HOSTNAME VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR VARIABLE_COMMENT Node name @@ -367,7 +367,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME WSREP_PATCH_VERSION SESSION_VALUE NULL -GLOBAL_VALUE wsrep_25.13 +GLOBAL_VALUE wsrep_25.16 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result b/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result index 52fede2f538..90925e71c32 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_desync_basic.result @@ -20,7 +20,7 @@ SET @@global.wsrep_desync=ON; Got one of the listed errors SELECT @@global.wsrep_desync; @@global.wsrep_desync -1 +0 # valid values SET @@global.wsrep_desync='OFF'; @@ -31,7 +31,7 @@ SET @@global.wsrep_desync=ON; Got one of the listed errors SELECT @@global.wsrep_desync; @@global.wsrep_desync -1 +0 SET @@global.wsrep_desync=default; SELECT @@global.wsrep_desync; @@global.wsrep_desync diff --git a/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result b/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result index 15438a2afd5..d96bc8708c5 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_max_ws_rows_basic.result @@ -6,7 +6,7 @@ SET @wsrep_max_ws_rows_global_saved = @@global.wsrep_max_ws_rows; # default SELECT @@global.wsrep_max_ws_rows; @@global.wsrep_max_ws_rows -131072 +0 # scope SELECT @@session.wsrep_max_ws_rows; @@ -26,11 +26,9 @@ SELECT @@global.wsrep_max_ws_rows; @@global.wsrep_max_ws_rows 131073 SET @@global.wsrep_max_ws_rows=0; -Warnings: -Warning 1292 Truncated incorrect wsrep_max_ws_rows value: '0' SELECT @@global.wsrep_max_ws_rows; @@global.wsrep_max_ws_rows -1 +0 SET @@global.wsrep_max_ws_rows=default; SELECT @global.wsrep_max_ws_rows; @global.wsrep_max_ws_rows diff --git a/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result b/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result index 26d8d823a5c..689da3e9cb0 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_max_ws_size_basic.result @@ -1,39 +1,38 @@ # # wsrep_max_ws_size # -# save the initial value -SET @wsrep_max_ws_size_global_saved = @@global.wsrep_max_ws_size; # default SELECT @@global.wsrep_max_ws_size; @@global.wsrep_max_ws_size -1073741824 +2147483647 # scope SELECT @@session.wsrep_max_ws_size; ERROR HY000: Variable 'wsrep_max_ws_size' is a GLOBAL variable SET @@global.wsrep_max_ws_size=1; -Warnings: -Warning 1292 Truncated incorrect wsrep_max_ws_size value: '1' +ERROR HY000: WSREP (galera) not started SELECT @@global.wsrep_max_ws_size; @@global.wsrep_max_ws_size -1024 +2147483647 # valid values SET @@global.wsrep_max_ws_size=1073741824; +ERROR HY000: WSREP (galera) not started SELECT @@global.wsrep_max_ws_size; @@global.wsrep_max_ws_size -1073741824 +2147483647 SET @@global.wsrep_max_ws_size=1073741825; +ERROR HY000: WSREP (galera) not started SELECT @@global.wsrep_max_ws_size; @@global.wsrep_max_ws_size -1073741825 +2147483647 SET @@global.wsrep_max_ws_size=0; -Warnings: -Warning 1292 Truncated incorrect wsrep_max_ws_size value: '0' +ERROR HY000: WSREP (galera) not started SELECT @@global.wsrep_max_ws_size; @@global.wsrep_max_ws_size -1024 +2147483647 SET @@global.wsrep_max_ws_size=default; +ERROR HY000: WSREP (galera) not started SELECT @global.wsrep_max_ws_size; @global.wsrep_max_ws_size NULL @@ -47,12 +46,8 @@ SELECT @global.wsrep_max_ws_size; @global.wsrep_max_ws_size NULL SET @@global.wsrep_max_ws_size=-1; -Warnings: -Warning 1292 Truncated incorrect wsrep_max_ws_size value: '-1' +ERROR HY000: WSREP (galera) not started SELECT @global.wsrep_max_ws_size; @global.wsrep_max_ws_size NULL - -# restore the initial value -SET @@global.wsrep_max_ws_size = @wsrep_max_ws_size_global_saved; # End of test diff --git a/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result b/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result index 9657e6bf428..763d0612a1b 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_node_name_basic.result @@ -4,10 +4,10 @@ call mtr.add_suppression("WSREP: Failed to get provider options"); # save the initial value SET @wsrep_node_name_global_saved = @@global.wsrep_node_name; -# default -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +# default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 # scope SELECT @@session.wsrep_node_name; @@ -27,21 +27,34 @@ SELECT @@global.wsrep_node_name; @@global.wsrep_node_name hyphenated-node-name SET @@global.wsrep_node_name=default; -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +# default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 # invalid values SET @@global.wsrep_node_name=NULL; ERROR 42000: Variable 'wsrep_node_name' can't be set to the value of 'NULL' -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 SET @@global.wsrep_node_name=1; ERROR 42000: Incorrect argument type to variable 'wsrep_node_name' -SELECT @@global.wsrep_node_name; -@@global.wsrep_node_name - +SELECT COUNT(@@global.wsrep_node_name); +COUNT(@@global.wsrep_node_name) +1 +# +# MDEV-6699 : wsrep_node_name not automaticly set to hostname +# +SET @@global.wsrep_node_name=default; +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname'; +@@GLOBAL.wsrep_node_name = VARIABLE_VALUE +1 +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name'; +@@GLOBAL.wsrep_node_name = VARIABLE_VALUE +1 # restore the initial value SET @@global.wsrep_node_name = @wsrep_node_name_global_saved; diff --git a/mysql-test/suite/sys_vars/t/general_log_file_basic.test b/mysql-test/suite/sys_vars/t/general_log_file_basic.test index 12362fa123c..0a169b472e2 100644 --- a/mysql-test/suite/sys_vars/t/general_log_file_basic.test +++ b/mysql-test/suite/sys_vars/t/general_log_file_basic.test @@ -58,6 +58,20 @@ SET @@global.general_log_file = mytest.log; --error ER_WRONG_TYPE_FOR_VAR SET @@global.general_log_file = 12; +# +# MDEV-10465 +# +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = 'my.cnf'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = '/tmp/my.cnf'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = '.my.cnf'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = 'my.cnf\0foo'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = 'my.ini'; + --echo '#----------------------FN_DYNVARS_004_03------------------------#' ############################################################################## diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test b/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test index 28fc17f6077..69ca5f21f62 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test @@ -56,6 +56,20 @@ SET @@global.slow_query_log_file = mytest.log; --error ER_WRONG_TYPE_FOR_VAR SET @@global.slow_query_log_file = 12; +# +# MDEV-10465 +# +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.slow_query_log_file = 'my.cnf'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.slow_query_log_file = '/tmp/my.cnf'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = '.my.cnf'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = 'my.cnf\0foo'; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.general_log_file = 'my.ini'; + --echo '#----------------------FN_DYNVARS_004_03------------------------#' ############################################################################## # Check if the value in GLOBAL Tables matches values in variable # diff --git a/mysql-test/suite/sys_vars/t/sysvars_wsrep.test b/mysql-test/suite/sys_vars/t/sysvars_wsrep.test index 32af7d3a5ca..700b129fd62 100644 --- a/mysql-test/suite/sys_vars/t/sysvars_wsrep.test +++ b/mysql-test/suite/sys_vars/t/sysvars_wsrep.test @@ -1,8 +1,11 @@ --source include/have_wsrep.inc --source include/word_size.inc --let $datadir = `SELECT @@datadir` +--let $hostname = `SELECT @@hostname` --replace_result $datadir DATADIR +--let $hostname_regex=/^$hostname\$/HOSTNAME/ +--replace_regex $hostname_regex --vertical_results select * from information_schema.system_variables where variable_name like 'wsrep%' diff --git a/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test b/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test index e7af4558f24..50506ed12df 100644 --- a/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test +++ b/mysql-test/suite/sys_vars/t/wsrep_max_ws_size_basic.test @@ -4,9 +4,6 @@ --echo # wsrep_max_ws_size --echo # ---echo # save the initial value -SET @wsrep_max_ws_size_global_saved = @@global.wsrep_max_ws_size; - --echo # default SELECT @@global.wsrep_max_ws_size; @@ -14,17 +11,22 @@ SELECT @@global.wsrep_max_ws_size; --echo # scope --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.wsrep_max_ws_size; +--error ER_WRONG_ARGUMENTS SET @@global.wsrep_max_ws_size=1; SELECT @@global.wsrep_max_ws_size; --echo --echo # valid values +--error ER_WRONG_ARGUMENTS SET @@global.wsrep_max_ws_size=1073741824; SELECT @@global.wsrep_max_ws_size; +--error ER_WRONG_ARGUMENTS SET @@global.wsrep_max_ws_size=1073741825; SELECT @@global.wsrep_max_ws_size; +--error ER_WRONG_ARGUMENTS SET @@global.wsrep_max_ws_size=0; SELECT @@global.wsrep_max_ws_size; +--error ER_WRONG_ARGUMENTS SET @@global.wsrep_max_ws_size=default; SELECT @global.wsrep_max_ws_size; @@ -35,11 +37,8 @@ SET @@global.wsrep_max_ws_size=NULL; --error ER_WRONG_TYPE_FOR_VAR SET @@global.wsrep_max_ws_size='junk'; SELECT @global.wsrep_max_ws_size; +--error ER_WRONG_ARGUMENTS SET @@global.wsrep_max_ws_size=-1; SELECT @global.wsrep_max_ws_size; ---echo ---echo # restore the initial value -SET @@global.wsrep_max_ws_size = @wsrep_max_ws_size_global_saved; - --echo # End of test diff --git a/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test b/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test index 1f3ccc0de2c..7bc9bec8b95 100644 --- a/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test +++ b/mysql-test/suite/sys_vars/t/wsrep_node_name_basic.test @@ -9,8 +9,8 @@ call mtr.add_suppression("WSREP: Failed to get provider options"); --echo # save the initial value SET @wsrep_node_name_global_saved = @@global.wsrep_node_name; ---echo # default -SELECT @@global.wsrep_node_name; +--echo # default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); --echo --echo # scope @@ -26,16 +26,26 @@ SELECT @@global.wsrep_node_name; SET @@global.wsrep_node_name='hyphenated-node-name'; SELECT @@global.wsrep_node_name; SET @@global.wsrep_node_name=default; -SELECT @@global.wsrep_node_name; +--echo # default (expect 1) +SELECT COUNT(@@global.wsrep_node_name); --echo --echo # invalid values --error ER_WRONG_VALUE_FOR_VAR SET @@global.wsrep_node_name=NULL; -SELECT @@global.wsrep_node_name; +SELECT COUNT(@@global.wsrep_node_name); --error ER_WRONG_TYPE_FOR_VAR SET @@global.wsrep_node_name=1; -SELECT @@global.wsrep_node_name; +SELECT COUNT(@@global.wsrep_node_name); + +--echo # +--echo # MDEV-6699 : wsrep_node_name not automaticly set to hostname +--echo # +SET @@global.wsrep_node_name=default; +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='hostname'; +SELECT @@GLOBAL.wsrep_node_name = VARIABLE_VALUE FROM +INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_node_name'; --echo --echo # restore the initial value diff --git a/mysql-test/suite/vcol/r/charsets.result b/mysql-test/suite/vcol/r/charsets.result new file mode 100644 index 00000000000..d06edc544d9 --- /dev/null +++ b/mysql-test/suite/vcol/r/charsets.result @@ -0,0 +1,31 @@ +set names utf8; +create table t1 ( +a int, +b varchar(100) as (if(a,collation('й'),hex('ю'))) +) character set koi8r; +insert t1 (a) values (0),(1); +select * from t1; +a b +0 D18E +1 utf8_general_ci +set names latin1; +select * from t1; +a b +0 D18E +1 utf8_general_ci +flush tables; +select * from t1; +a b +0 D18E +1 latin1_swedish_ci +set names koi8r; +select * from t1; +a b +0 D18E +1 latin1_swedish_ci +flush tables; +select * from t1; +a b +0 D18E +1 koi8r_general_ci +drop table t1; diff --git a/mysql-test/suite/vcol/t/charsets.test b/mysql-test/suite/vcol/t/charsets.test new file mode 100644 index 00000000000..32fb9a7741c --- /dev/null +++ b/mysql-test/suite/vcol/t/charsets.test @@ -0,0 +1,24 @@ +# +# This shows a bug in vcol charset handling. +# vcol definition is stored in the connection charset when a table was created +# vcol is parsed in the connection charset when a table was opened +# +# this cannot be fixed without changing frm format, so we only +# fix it in 10.2. +# +set names utf8; +create table t1 ( + a int, + b varchar(100) as (if(a,collation('й'),hex('ю'))) +) character set koi8r; +insert t1 (a) values (0),(1); +select * from t1; +set names latin1; +select * from t1; +flush tables; +select * from t1; +set names koi8r; +select * from t1; +flush tables; +select * from t1; +drop table t1; diff --git a/mysql-test/suite/wsrep/r/binlog_format.result b/mysql-test/suite/wsrep/r/binlog_format.result index d996371c056..1ca90bd626d 100644 --- a/mysql-test/suite/wsrep/r/binlog_format.result +++ b/mysql-test/suite/wsrep/r/binlog_format.result @@ -1,5 +1,5 @@ call mtr.add_suppression("WSREP: MariaDB Galera does not support binlog format.*"); -call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID"); +call mtr.add_suppression("WSREP: Cannot get fake transaction ID from storage engine."); # # MDEV-4227: Galera server should stop crashing on setting binlog_format STATEMENT # diff --git a/mysql-test/suite/wsrep/r/mdev_10186.result b/mysql-test/suite/wsrep/r/mdev_10186.result new file mode 100644 index 00000000000..f966c443569 --- /dev/null +++ b/mysql-test/suite/wsrep/r/mdev_10186.result @@ -0,0 +1,11 @@ +# +# MDEV-10186: mysqld crash when runtime setting +# wsrep_cluster_address without wsrep_on=ON +# +SELECT @@wsrep_on; +@@wsrep_on +0 +SELECT @@GLOBAL.wsrep_provider; +@@GLOBAL.wsrep_provider +/usr/lib/galera/libgalera_smm.so +SET @@GLOBAL.wsrep_cluster_address='gcomm://'; diff --git a/mysql-test/suite/wsrep/suite.pm b/mysql-test/suite/wsrep/suite.pm index a7939c2e333..b6c5bf15ca1 100644 --- a/mysql-test/suite/wsrep/suite.pm +++ b/mysql-test/suite/wsrep/suite.pm @@ -26,8 +26,6 @@ push @::global_suppressions, ( qr(WSREP: Could not open saved state file for reading: .*), qr(WSREP: Could not open state file for reading: .*), - qr(WSREP: option --wsrep-causal-reads is deprecated), - qr(WSREP: --wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=0), qr|WSREP: access file\(.*gvwstate.dat\) failed\(No such file or directory\)|, ); diff --git a/mysql-test/suite/wsrep/t/binlog_format.test b/mysql-test/suite/wsrep/t/binlog_format.test index a2dc8542322..85864256862 100644 --- a/mysql-test/suite/wsrep/t/binlog_format.test +++ b/mysql-test/suite/wsrep/t/binlog_format.test @@ -2,7 +2,7 @@ --source include/have_binlog_format_row.inc call mtr.add_suppression("WSREP: MariaDB Galera does not support binlog format.*"); -call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID"); +call mtr.add_suppression("WSREP: Cannot get fake transaction ID from storage engine."); --echo # --echo # MDEV-4227: Galera server should stop crashing on setting binlog_format STATEMENT diff --git a/mysql-test/suite/wsrep/t/mdev_10186.opt b/mysql-test/suite/wsrep/t/mdev_10186.opt new file mode 100644 index 00000000000..e2655959c62 --- /dev/null +++ b/mysql-test/suite/wsrep/t/mdev_10186.opt @@ -0,0 +1 @@ +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=0 diff --git a/mysql-test/suite/wsrep/t/mdev_10186.test b/mysql-test/suite/wsrep/t/mdev_10186.test new file mode 100644 index 00000000000..ec5e9462821 --- /dev/null +++ b/mysql-test/suite/wsrep/t/mdev_10186.test @@ -0,0 +1,12 @@ +--source include/have_wsrep_provider.inc +--source include/have_binlog_format_row.inc + +--echo # +--echo # MDEV-10186: mysqld crash when runtime setting +--echo # wsrep_cluster_address without wsrep_on=ON +--echo # + +SELECT @@wsrep_on; +SELECT @@GLOBAL.wsrep_provider; +SET @@GLOBAL.wsrep_cluster_address='gcomm://'; + diff --git a/mysql-test/suite/wsrep/t/variables.test b/mysql-test/suite/wsrep/t/variables.test index d77dc4e66f9..1769f567848 100644 --- a/mysql-test/suite/wsrep/t/variables.test +++ b/mysql-test/suite/wsrep/t/variables.test @@ -29,7 +29,7 @@ CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*") --disable_query_log eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER'; ---let $galera_version=3.9 +--let $galera_version=25.3.17 source include/check_galera_version.inc; --enable_query_log diff --git a/mysql-test/t/bootstrap.test b/mysql-test/t/bootstrap.test index 35f0a46af70..a7e0ff17494 100644 --- a/mysql-test/t/bootstrap.test +++ b/mysql-test/t/bootstrap.test @@ -90,3 +90,13 @@ drop table t1; --replace_result .dll .so select * from mysql.plugin; truncate table mysql.plugin; + + +# +# MDEV-9969 mysql_install_db error processing ignore_db_dirs. +# +--write_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql +use test; +EOF +--exec $MYSQLD_BOOTSTRAP_CMD --ignore-db-dirs='some_dir' --ignore-db-dirs='some_dir' < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 +--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test index 3e37910380c..6d744679d67 100644 --- a/mysql-test/t/create_or_replace.test +++ b/mysql-test/t/create_or_replace.test @@ -214,15 +214,18 @@ create table test.t1 (i int); create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; --error ER_TABLE_MUST_HAVE_COLUMNS create or replace table test.t1; show tables; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; --error ER_TABLE_MUST_HAVE_COLUMNS create or replace table mysqltest2.t2; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; create table t1 (i int); drop table t1; @@ -231,15 +234,18 @@ create table test.t1 (i int); create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; --error ER_DUP_FIELDNAME create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; show tables; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; --error ER_DUP_FIELDNAME create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; create table t1 (i int); drop table t1; @@ -317,15 +323,19 @@ drop view t1; create table t1 (a int); lock table t1 write, t2 read; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; create or replace table t1 (i int); --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; create or replace table t1 like t2; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; create or replace table t1 select 1 as f1; --replace_column 1 # +--sorted_result select * from information_schema.metadata_lock_info; drop table t1; unlock tables; diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test index 1b9d7c9d4ad..1ea8002a2eb 100644 --- a/mysql-test/t/ctype_ldml.test +++ b/mysql-test/t/ctype_ldml.test @@ -397,3 +397,15 @@ perl; print "Occurances : $count_error\n"; close(FILE); EOF + + +--echo # +--echo # MDEV-8686 A user defined collation utf8_confusables doesn't work +--echo # +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_implicit_weights_ci); +INSERT INTO t1 VALUES ('a'),('b'),('c'); +INSERT INTO t1 VALUES (_ucs2 0x1500),(_ucs2 0x1501); +INSERT INTO t1 VALUES (_ucs2 0x3400),(_ucs2 0x3560),(_ucs2 0x3561),(_ucs2 0x3600); +INSERT INTO t1 VALUES (_ucs2 0x3700),(_ucs2 0x3701); +SELECT HEX(CONVERT(a USING ucs2)) AS ch, HEX(WEIGHT_STRING(a)) AS w, HEX(WEIGHT_STRING(a COLLATE utf8_unicode_ci)) AS ducet FROM t1 ORDER BY a,ch; +DROP TABLE t1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index ee07ef24def..81c04fc9c30 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -220,7 +220,6 @@ SET character_set_connection = utf8; CREATE TABLE t1 ( a VARCHAR(1) ); INSERT INTO t1 VALUES ('m'),('n'); CREATE VIEW v1 AS SELECT 'w' ; ---error ER_CANT_AGGREGATE_2COLLATIONS SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v1 ); drop view v1; drop table t1; @@ -228,3 +227,30 @@ SET character_set_connection = default; SET optimizer_switch= default; --echo #End of 5.3 tests + +--echo # +--echo # Start of 5.5 tests +--echo # + +--echo # +--echo # MDEV-10181 Illegal mix of collation for a field and an ASCII string as a view field +--echo # +SET NAMES utf8; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES ('A'),('a'),('B'),('b'); +CREATE VIEW v1 AS SELECT 'a'; +SELECT * FROM v1,t1 where t1.a=v1.a; +DROP VIEW v1; +DROP TABLE t1; + +SET NAMES utf8; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES ('a'),('b'),('c'); +CREATE VIEW v1 AS SELECT 'a' AS a UNION SELECT 'b'; +SELECT * FROM v1,t1 WHERE t1.a=v1.a; +DROP VIEW v1; +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 85ffed943cf..aa947a309d5 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1678,6 +1678,29 @@ ALTER TABLE t1 MODIFY a TINYTEXT CHARACTER SET utf8; SELECT OCTET_LENGTH(a),a FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +--echo # +--echo # + +SET NAMES utf8; +SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data; +SELECT length(data) AS len FROM ( + SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data +) AS sub; + +SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data; +SELECT length(data) AS len FROM ( + SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data +) AS sub; + +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub; + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 2fe9b5e6544..149a9a0498c 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1821,6 +1821,26 @@ SELECT OCTET_LENGTH(a),a FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +--echo # +--echo # + +SET NAMES utf8mb4; +SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data; +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub; + +SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data; +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub; + +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/events_1.test b/mysql-test/t/events_1.test index 88120b0cd4f..9768127f458 100644 --- a/mysql-test/t/events_1.test +++ b/mysql-test/t/events_1.test @@ -461,6 +461,25 @@ DROP EVENT ev1; SHOW EVENTS; +--echo # +--echo # MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH +--echo # +CREATE TABLE t1 (a INT); +CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; +--replace_column 8 # 9 # +SHOW EVENTS; +SET sql_mode=PAD_CHAR_TO_FULL_LENGTH; +--replace_column 8 # 9 # +SHOW EVENTS; +DROP EVENT ev1; +CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; +--replace_column 8 # 9 # +SHOW EVENTS; +DROP EVENT ev1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + + --echo --echo # --echo # End of tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 47477c72004..7e342928ef8 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1566,6 +1566,37 @@ EXECUTE stmt; DROP TABLE t1,t2,t3,t4,t5,t6; +--echo # +--echo # MDEV-10500 CASE/IF Statement returns multiple values and shifts further result values to the next column +--echo # + +CREATE TABLE t1 ( + id int not null AUTO_INCREMENT, + active bool not null, + data1 bigint, + data2 bigint, + data3 bigint, + primary key (id) +); +INSERT INTO t1 (active,data1,data2,data3) VALUES (1,null,100,200); +SELECT + CASE WHEN active THEN SUM(data1) END AS C_1, + SUM(data2) AS C_2, + SUM(data3) AS C_3 +FROM t1; +SELECT + IF(active, SUM(data1), 5) AS C_1, + SUM(data2) AS C_2, + SUM(data3) AS C_3 +FROM t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +--echo # +SELECT STDDEV_POP(f) FROM (SELECT "1e+309" AS f UNION SELECT "-1e+309" AS f) tbl; +SELECT STDDEV(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT -1.7976931348623157e+308 AS f) tbl; + --echo # --echo # MDEV-8852 Implicit or explicit CAST from MAX(string) to INT,DOUBLE,DECIMAL does not produce warnings --echo # @@ -1616,6 +1647,38 @@ INSERT INTO t1 VALUES (3,0x7FFFFFFFFFFFFFFC,37); SELECT companynr, AVG(fld1), AVG(fld1)<<0 AS avg1, CAST(AVG(fld1) AS UNSIGNED)<<0 AS avg2 FROM t1 GROUP BY companynr; DROP TABLE t1; +--echo # +--echo # case where aggregate resolved in the local SELECT +--echo # but outer ones are checked +--echo # +create table t10 (a int , b int, c int); +insert into t10 values (0,0,0),(1,1,1); +create table t11 as select * from t10; +create table t12 as select * from t10; +explain extended select a from t10 where c<3 or a in (select c from t12 union select max(t10.b) from t11 group by t11.c); +drop table t10,t11,t12; +--echo # +--echo # MDEV-10017: Get unexpected `Empty Set` for correlated subquery +--echo # with aggregate functions +--echo # + +create table t1(c1 int, c2 int, c3 int); +insert into t1 values(1,1,1),(2,2,2),(3,3,3); +select * from t1; +create table t2(c1 int, c2 int); +insert into t2 values(2,2); +select * from t2; +--error ER_INVALID_GROUP_FUNC_USE +explain extended +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt)); +--error ER_INVALID_GROUP_FUNC_USE +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt)); + +explain extended +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+tt.c1) from t2 tt)); +select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+tt.c1) from t2 tt)); +drop table t1,t2; + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index fab39b04484..9e848aa1847 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -607,6 +607,28 @@ DROP TABLE t1; --echo # End of 5.3 tests + +--echo # +--echo # Start of 10.0 tests +--echo # + +--echo # +--echo # MDEV-10020 InnoDB NOT IN Query Crash When One Item Is NULL +--echo # +CREATE TABLE t1 +( + a INT(11), + b VARCHAR(10), + KEY (b) +); +INSERT INTO t1 VALUES (1,'x'),(2,'y'),(3,'z'); +SELECT * FROM t1 WHERE b NOT IN (NULL, '', 'A'); +DROP TABLE t1; + +--echo # +--echo # Start of 10.1 tests +--echo # + --echo # --echo # MDEV-8755 Equal field propagation is not performed any longer for the IN list when multiple comparison types --echo # diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index da478080ab4..8cacb4c575a 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -580,11 +580,15 @@ select 5 div 2.0; select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; --echo # ---echo # End of 5.5 tests +--echo # MDEV-10467 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() --echo # +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +SELECT STDDEV_SAMP(ROUND('0', 309)) FROM t1; +DROP TABLE t1; --echo # ---echo # Start of 10.0 tests +--echo # End of 5.5 tests --echo # --echo # @@ -592,7 +596,6 @@ select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; --echo # SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table; - --echo # --echo # End of 10.0 tests --echo # diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 47afb6664a5..b874700f29d 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -596,6 +596,16 @@ AND 57813X540X1723 = 'Test'; drop table t1; +# +# Bug#12735545 - PARSER STACK OVERFLOW WITH NAME_CONST +# CONTAINING OR EXPRESSION +# +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST('a', -(1 OR 2)) OR 1; +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST('a', -(1 AND 2)) OR 1; +SELECT NAME_CONST('a', -(1)) OR 1; + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 18293f31dd2..12b7c92688f 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1712,3 +1712,77 @@ SELECT --echo # --echo # End of 10.0 tests --echo # + +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-10317 EXCTACT(MINUTE_MICROSECOND) truncates data +--echo # + +let $query= +SELECT + a, + EXTRACT(YEAR FROM a), + EXTRACT(YEAR_MONTH FROM a), + EXTRACT(QUARTER FROM a), + EXTRACT(MONTH FROM a), + EXTRACT(WEEK FROM a), + EXTRACT(DAY FROM a), + EXTRACT(DAY_HOUR FROM a), + EXTRACT(DAY_MINUTE FROM a), + EXTRACT(DAY_SECOND FROM a), + EXTRACT(HOUR FROM a), + EXTRACT(HOUR_MINUTE FROM a), + EXTRACT(HOUR_SECOND FROM a), + EXTRACT(MINUTE FROM a), + EXTRACT(MINUTE_SECOND FROM a), + EXTRACT(SECOND FROM a), + EXTRACT(MICROSECOND FROM a), + EXTRACT(DAY_MICROSECOND FROM a), + EXTRACT(HOUR_MICROSECOND FROM a), + EXTRACT(MINUTE_MICROSECOND FROM a), + EXTRACT(SECOND_MICROSECOND FROM a) +FROM t1; + + +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('1999-12-31 23:59:59.999999'); + +--vertical_results +--enable_metadata +--disable_ps_protocol +--eval $query +--enable_ps_protocol +--disable_metadata +--horizontal_results + +--eval CREATE TABLE t2 AS $query +--vertical_results +SELECT * FROM t2; +--horizontal_results +SHOW CREATE TABLE t2; +DROP TABLE t1,t2; + +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-838:59:59.999999'),('838:59:59.999999'); + +--vertical_results +--enable_metadata +--disable_ps_protocol +--eval $query +--enable_ps_protocol +--disable_metadata +--horizontal_results + +--eval CREATE TABLE t2 AS $query +--vertical_results +SELECT * FROM t2; +--horizontal_results +SHOW CREATE TABLE t2; +DROP TABLE t1,t2; + +--echo # +--echo # End of 10.1 tests +--echo # diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 5d8b79b9fca..4aa5c10ece8 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1803,3 +1803,39 @@ 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; + +--echo # +--echo # MDEV-10324: Server crash in get_sel_arg_for_keypart or Assertion `n < size()' failed in Mem_root_array +--echo # +CREATE TABLE t1 ( + job_id int(10) unsigned NOT NULL AUTO_INCREMENT, + job_cmd varbinary(60) NOT NULL DEFAULT '', + job_namespace int(11) NOT NULL, + job_title varbinary(255) NOT NULL, + job_params blob NOT NULL, + job_timestamp varbinary(14) DEFAULT NULL, + job_random int(10) unsigned NOT NULL DEFAULT '0', + job_token varbinary(32) NOT NULL DEFAULT '', + job_token_timestamp varbinary(14) DEFAULT NULL, + job_sha1 varbinary(32) NOT NULL DEFAULT '', + job_attempts int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (job_id), + KEY job_cmd (job_cmd,job_namespace,job_title,job_params(128)), + KEY job_timestamp (job_timestamp), + KEY job_sha1 (job_sha1), + KEY job_cmd_token (job_cmd,job_token,job_random), + KEY job_cmd_token_id (job_cmd,job_token,job_id) +); + +INSERT INTO t1 VALUES + (NULL, 'foo', 1, 'foo', 'foo', 'foo', 1, 'foo', 'foo', 'foo', 1), + (NULL, 'bar', 2, 'bar', 'bar', 'bar', 2, 'bar', 'bar', 'bar', 2); + +SELECT DISTINCT job_cmd FROM t1 WHERE job_cmd IN ('foobar','null'); +drop table t1; + +CREATE TABLE t1 (f1 INT NOT NULL, f2 VARCHAR(3) NOT NULL, KEY(f1), KEY(f2, f1)); +INSERT INTO t1 VALUES (0,'foo'),(1,'bar'); +SELECT 1 IN ( SELECT COUNT( DISTINCT f2 ) FROM t1 WHERE f1 <= 4 ); +drop table t1; + diff --git a/mysql-test/t/group_by_innodb.test b/mysql-test/t/group_by_innodb.test index e072a94fada..ed65e0c3e57 100644 --- a/mysql-test/t/group_by_innodb.test +++ b/mysql-test/t/group_by_innodb.test @@ -125,4 +125,34 @@ ORDER BY id DESC; DROP TABLE t1, t2; +--echo # Port of testcase: +--echo # +--echo # Bug#20819199 ASSERTION FAILED IN TEST_IF_SKIP_SORT_ORDER +--echo # + +CREATE TABLE t0 ( a INT ); +INSERT INTO t0 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); + +CREATE TABLE t1 ( + pk INT NOT NULL AUTO_INCREMENT, + a INT, + b INT, + PRIMARY KEY (pk), + KEY idx1 (a), + KEY idx2 (b, a), + KEY idx3 (a, b) +) ENGINE = InnoDB; + +INSERT INTO t1 (a, b) SELECT t01.a, t02.a FROM t0 t01, t0 t02; + +ANALYZE TABLE t1; + +let $query= +SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; + +eval EXPLAIN $query; +eval $query; + +DROP TABLE t0, t1; + --echo # End of tests diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test index 43e61136e05..dc5dc1cee5f 100644 --- a/mysql-test/t/help.test +++ b/mysql-test/t/help.test @@ -61,6 +61,12 @@ help '%function_7'; help '%category_2'; help 'impossible_function_1'; help 'impossible_category_1'; + +--echo # MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH +help 'impossible_function_1'; +SET sql_mode=PAD_CHAR_TO_FULL_LENGTH; +help 'impossible_function_1'; +SET sql_mode=DEFAULT; ############## set sql_mode=""; diff --git a/mysql-test/t/information_schema_stats.test b/mysql-test/t/information_schema_stats.test new file mode 100644 index 00000000000..c7f39894ce7 --- /dev/null +++ b/mysql-test/t/information_schema_stats.test @@ -0,0 +1,46 @@ +# +# MDEV-8633: information_schema.index_statistics doesn't delete item when drop table indexes or drop table; +# +set global userstat=1; +create table just_a_test(id int,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30)); +insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'), +(2,'fb','lb','china_b',22222222,'fb_lb@163.com','Arizona'), +(3,'fc','lc','china_c',33333333,'fc_lc@163.com','California'), +(4,'fd','ld','china_d',44444444,'fd_ld@163.com','Utah'), +(5,'fe','le','china_e',55555555,'fe_le@163.com','Arizona'); +alter table just_a_test add primary key (id); +alter table just_a_test add key IND_just_a_test_first_name_last_name(first_name,last_name); +alter table just_a_test add key IND_just_a_test_state(state); +select count(*) from just_a_test where first_name='fc' and last_name='lc'; +select count(*) from just_a_test where state = 'California'; +--sorted_result +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +alter table just_a_test drop key IND_just_a_test_first_name_last_name; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +alter table just_a_test drop column state; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +drop table just_a_test; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +# +# Test direct drop table +# +create table just_a_test(id int not null primary key,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30),key(first_name,last_name),key(state)); +insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'), +(2,'fb','lb','china_b',22222222,'fb_lb@163.com','Arizona'), +(3,'fc','lc','china_c',33333333,'fc_lc@163.com','California'), +(4,'fd','ld','china_d',44444444,'fd_ld@163.com','Utah'), +(5,'fe','le','china_e',55555555,'fe_le@163.com','Arizona'); +select count(*) from just_a_test where first_name='fc' and last_name='lc'; +select count(*) from just_a_test where state = 'California'; +select count(*) from just_a_test where id between 2 and 4; +--sorted_result +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +drop table just_a_test; +select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; +select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; +set global userstat=0; diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test index 9f3a89ff948..bf94b7dd3d5 100644 --- a/mysql-test/t/innodb_ext_key.test +++ b/mysql-test/t/innodb_ext_key.test @@ -693,5 +693,90 @@ drop table t1, t2; set optimizer_switch=@save_optimizer_switch; +--echo # +--echo # MDEV-10325: Queries examines all rows of a tables when it should not +--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 not null, + col1 varchar(32), + filler varchar(100), + key idx1(col1(10)), + primary key (pk) +)engine=innodb; + +insert into t1 +select + A.a + 10*B.a + 100*C.a, + concat('1234567890-', 1000+ A.a + 10*B.a + 100*C.a), + repeat('filler-data-', 4) +from + t0 A, t0 B, t0 C; + +let $q=explain select * from t1 where col1='1234567890-a'; +let $rows=query_get_value($q, rows, 1); +if ($rows < 2) +{ + --echo The EXPLAIN should not produce a query plan with type=ref, rows=1 + --die Fix for MDEV-10325 didnt work; +} + +drop table t0,t1; + +--echo # +--echo # MDEV-10360: Extended keys: index properties depend on index order +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 ( + index_id bigint(20) unsigned NOT NULL, + index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , + index_object_id int(10) unsigned NOT NULL DEFAULT '0' , + index_date_updated int(10) unsigned DEFAULT NULL , + + PRIMARY KEY (index_id), + KEY object (index_class(181),index_object_id), + KEY index_date_updated (index_date_updated) +) engine=innodb; + +create table t2 ( + index_id bigint(20) unsigned NOT NULL, + index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , + index_object_id int(10) unsigned NOT NULL DEFAULT '0' , + index_date_updated int(10) unsigned DEFAULT NULL , + + PRIMARY KEY (index_id), + KEY index_date_updated (index_date_updated), + KEY object (index_class(181),index_object_id) +) engine=innodb; + +insert into t1 select + @a:=A.a + 10*B.a + 100*C.a, + concat('val-', @a), + 123456, + A.a + 10*B.a +from + t0 A, t0 B, t0 C; + +insert into t2 select * from t1; + +--echo # This must have the same query plan as the query below it: +--echo # type=range, key=index_date_updated, key_len=13 +--replace_column 9 # +explain +select * from t1 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; + +--echo # This used to work from the start: +--replace_column 9 # +explain +select * from t2 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; + +drop table t0,t1,t2; + set optimizer_switch=@save_ext_key_optimizer_switch; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/t/insert_innodb.test b/mysql-test/t/insert_innodb.test index 8c8d2690c11..68b6ca4e315 100644 --- a/mysql-test/t/insert_innodb.test +++ b/mysql-test/t/insert_innodb.test @@ -41,3 +41,24 @@ UPDATE t1, t2 SET t2.fld2= t2.fld2 + 3; UPDATE t1, t2 SET t1.fld1= t1.fld1 + 3; DROP TABLE t2, t1; + +--echo # +--echo # BUG#22037930: INSERT IGNORE FAILS TO IGNORE FOREIGN +--echo # KEY CONSTRAINT + +CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= INNODB; + +CREATE TABLE t2 (fld1 VARCHAR(10), fld2 INT NOT NULL, +CONSTRAINT fk FOREIGN KEY (fld2) REFERENCES t1(fld1)) ENGINE= INNODB; + +--echo # Without patch, reports incorrect error. +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def'; +--error ER_NO_REFERENCED_ROW_2 +REPLACE INTO t2 VALUES('abc', 2); + +--enable_warnings +INSERT IGNORE INTO t2 VALUES('abc', 2) ON DUPLICATE KEY UPDATE fld1= 'def'; +--disable_warnings + +DROP TABLE t2, t1; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 35243864c04..7d0f3852b66 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -612,7 +612,7 @@ disconnect con1; --echo # CREATE TABLE t1(f1 INT); -EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat'; +EVAL SELECT 0xE1C330 INTO OUTFILE 't1.dat'; --disable_warnings LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8; --enable_warnings @@ -658,3 +658,26 @@ SET @@sql_mode= @old_mode; --remove_file $MYSQLTEST_VARDIR/mysql DROP TABLE t1; +--echo +--echo # +--echo # Bug#23080148 - Backport of Bug#20683959. +--echo # Bug#20683959 LOAD DATA INFILE IGNORES A SPECIFIC ROW SILENTLY +--echo # UNDER DB CHARSET IS UTF8. +--echo # + +CREATE DATABASE d1 CHARSET latin1; +USE d1; +CREATE TABLE t1 (val TEXT); +LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1; +SELECT COUNT(*) FROM t1; +SELECT HEX(val) FROM t1; + +CREATE DATABASE d2 CHARSET utf8; +USE d2; +CREATE TABLE t1 (val TEXT); +--error ER_INVALID_CHARACTER_STRING +LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1; + +DROP TABLE d1.t1, d2.t1; +DROP DATABASE d1; +DROP DATABASE d2; diff --git a/mysql-test/t/locale.test b/mysql-test/t/locale.test index 5d1fd24d750..b1fbc40f0c8 100644 --- a/mysql-test/t/locale.test +++ b/mysql-test/t/locale.test @@ -64,6 +64,25 @@ SELECT monthname('2001-01-01'); SELECT monthname('2001-02-01'); SELECT monthname('2001-03-01'); +--echo # +--echo # MDEV-10052 Illegal mix of collations with DAYNAME(date_field)<>varchar_field +--echo # +SET NAMES utf8; +CREATE TABLE t1 (c VARCHAR(8) CHARACTER SET latin1, d DATE); +INSERT INTO t1 VALUES ('test',now()); +SET lc_time_names=ru_RU; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT c FROM t1 WHERE DAYNAME(d)<>c; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT c FROM t1 WHERE MONTHNAME(d)<>c; +SET lc_time_names=en_US; +SELECT c FROM t1 WHERE DAYNAME(d)<>c; +SELECT c FROM t1 WHERE MONTHNAME(d)<>c; +SET NAMES latin1; +SELECT c FROM t1 WHERE DAYNAME(d)<>c; +SELECT c FROM t1 WHERE MONTHNAME(d)<>c; +DROP TABLE t1; + --echo # --echo # Start of 5.6 tests --echo # diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index d54c2ab7c55..0297280340d 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -1083,4 +1083,28 @@ SELECT * FROM v1; DROP TABLE t1, t2; DROP VIEW v1; +--echo # +--echo # MDEV-5973: MySQL Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0 +--echo # FROM STORAGE ENGINE) WITH MULTI-TABLE UPDATE +--echo # + +CREATE TABLE table_11757486 (field1 tinyint) ENGINE=INNODB; +INSERT INTO table_11757486 VALUES (0),(0); +SET SESSION SQL_MODE='STRICT_ALL_TABLES'; +UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1; +UPDATE IGNORE table_11757486 SET field1=128; + +--error ER_WARN_DATA_OUT_OF_RANGE +UPDATE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1; +--error ER_WARN_DATA_OUT_OF_RANGE +UPDATE table_11757486 SET field1=128; + +SET SESSION SQL_MODE=''; +UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1; +UPDATE IGNORE table_11757486 SET field1=128; + +DROP TABLE table_11757486; + +SET SESSION SQL_MODE=default; + --echo end of 10.0 tests diff --git a/mysql-test/t/myisam_enable_keys-10506.test b/mysql-test/t/myisam_enable_keys-10506.test new file mode 100644 index 00000000000..8e1c058c3f0 --- /dev/null +++ b/mysql-test/t/myisam_enable_keys-10506.test @@ -0,0 +1,117 @@ +# +# MDEV-10506 Protocol::end_statement(): Assertion `0' failed upon ALTER TABLE +# +CREATE TABLE t1 ( + pk INT AUTO_INCREMENT, + i INT, + d DATE, + dt DATETIME, + v VARCHAR(1), + PRIMARY KEY (pk), + KEY (dt) +) ENGINE=MyISAM; +INSERT INTO t1 (i, d, dt, v) VALUES + (9, '2005-07-23', '2004-05-13 01:01:39', 't'), + (2, '2009-11-01', '2003-12-24 07:39:29', 'h'), + (6, NULL, '2008-07-03 05:32:22', 'l'), + (6, '2007-07-16', '2008-08-28 18:46:11', 'j'), + (5, NULL, '2001-07-12 21:27:00', 'h'), + (3, '2007-07-22', '1900-01-01 00:00:00', 'p'), + (2, '2000-11-21', '2007-05-25 11:58:54', 'g'), + (6, '1900-01-01', '2009-06-03 17:11:10', 'i'), + (2, '2008-02-10', '2001-06-15 16:20:07', 'p'), + (3, '2009-06-04', '1900-01-01 00:00:00', 'h'), + (9, '2007-04-25', '1900-01-01 00:00:00', 'e'), + (9, '2006-03-02', '1900-01-01 00:00:00', 'e'), + (1, '1900-01-01', '2002-11-08 09:33:27', 'u'), + (7, '2008-07-13', '2007-08-07 17:35:52', 'j'), + (0, '2004-11-12', '2006-05-01 00:00:00', 'e'), + (0, '1900-01-01', '2003-05-01 00:00:00', 'z'), + (1, '2009-09-02', '2007-02-12 09:30:49', 'w'), + (0, '2004-11-06', '1900-01-01 00:00:00', 't'), + (4, '2003-01-06', '2002-07-03 02:51:11', 'i'), + (6, '2006-01-14', '2008-02-26 04:57:32', 'i'), + (0, '2002-01-19', '2009-02-12 00:00:00', 'i'), + (8, '2007-02-12', '1900-01-01 00:00:00', 'b'), + (4, '1900-01-01', '2001-05-16 05:28:40', 'm'), + (2, '2005-07-16', NULL, 'j'), + (1, '2004-09-04', '2001-01-24 21:45:18', 'v'), + (3, '2009-07-01', NULL, NULL), + (2, '2009-07-21', '2002-07-24 00:00:00', 'h'), + (4, NULL, '2001-11-03 12:22:30', 'q'), + (1, '2002-06-22', '2008-06-17 03:17:59', 'f'), + (7, '2005-06-23', '2005-12-24 00:00:00', 'p'), + (6, '2001-05-20', '2008-10-23 00:00:00', NULL), + (3, '2001-10-01', '2000-10-12 16:32:35', 'o'), + (3, '2001-01-07', '2005-09-11 10:09:54', 'w'), + (6, '2007-11-02', '2009-09-10 01:44:18', 'l'), + (6, NULL, NULL, 'i'), + (9, NULL, '2002-05-18 15:21:55', 'd'), + (4, '2008-12-21', '2004-10-15 10:09:54', 'j'), + (6, '2003-10-05', '2009-07-13 03:51:02', 'e'), + (2, '2001-03-03', '1900-01-01 00:00:00', 'e'), + (2, '2007-04-04', '2001-11-08 21:14:52', 'q'), + (5, NULL, '2006-12-02 00:00:00', 'm'), + (0, '2009-01-04', '1900-01-01 00:00:00', NULL), + (8, '2008-04-03', '2005-01-01 11:55:18', 'q'), + (8, NULL, '2005-02-28 03:44:02', 'w'), + (0, '2003-08-22', NULL, 'c'), + (9, '1900-01-01', NULL, 'y'), + (NULL, NULL, '2006-08-25 16:28:09', 'g'), + (5, '2004-07-04', '2002-08-11 00:00:00', 'z'), + (1, '1900-01-01', '2007-07-22 21:19:18', 'm'), + (2, '2007-02-04', '2006-02-10 18:41:38', 't'), + (2, '1900-01-01', '2009-02-16 14:58:58', 'd'), + (7, '2001-03-14', '2007-08-14 00:00:00', 'h'), + (0, NULL, '1900-01-01 00:00:00', NULL), + (1, '2008-10-05', NULL, 'f'), + (6, '2001-11-25', '2008-12-03 06:59:23', 'l'), + (NULL, '2003-01-27', '2008-10-04 00:00:00', 'g'), + (8, '2008-08-08', '2009-07-07 07:00:21', 'v'), + (8, '2006-07-03', '2001-04-15 00:00:00', NULL), + (5, '2002-11-21', '2007-07-08 04:01:58', 'm'), + (5, '2006-04-08', '2007-09-23 00:01:35', 'i'), + (5, '2001-05-06', '2008-05-15 00:00:00', 'h'), + (7, '1900-01-01', '1900-01-01 00:00:00', 'u'), + (30, '2007-04-16', '2004-03-05 23:35:38', 'o'), + (NULL, '1900-01-01', '2007-08-25 01:32:47', 'z'), + (6, '2004-12-03', '1900-01-01 00:00:00', 'o'), + (8, '2001-06-23', '1900-01-01 00:00:00', 'f'), + (NULL, '2008-12-15', '2001-05-19 08:28:28', 'a'), + (9, '2000-02-15', '2009-09-03 06:07:22', 'd'), + (2, '2001-08-05', '2006-10-08 07:17:27', 'k'), + (5, '2004-01-17', '2003-09-06 20:36:01', 'd'), + (4, '2003-10-01', '2001-02-05 18:10:49', 'u'), + (4, '2003-07-28', '2001-01-07 16:11:37', 'h'), + (0, '1900-01-01', '2008-08-01 05:26:38', 'w'), + (9, '1900-01-01', '2001-05-08 00:00:00', 't'), + (1, '2000-04-17', '2008-07-10 21:26:28', 'i'), + (8, '2002-01-05', '2006-08-06 20:56:35', 'k'), + (9, '2001-04-10', '2003-02-17 00:00:00', 'z'), + (0, '2009-12-04', NULL, 'h'), + (7, NULL, '2004-10-27 00:29:57', 'h'), + (2, '2006-03-07', '2008-03-04 06:14:13', 'b'), + (0, '2001-10-15', '2001-03-17 00:00:00', 'm'), + (5, '1900-01-01', '2009-02-21 11:35:50', 'i'), + (4, NULL, '1900-01-01 00:00:00', 'w'), + (5, '2009-04-05', '1900-01-01 00:00:00', 'm'), + (6, '2001-03-19', '2001-04-12 00:00:00', 'q'), + (NULL, '2009-12-08', '2001-12-04 20:21:01', 'k'), + (2, '2005-02-09', '2001-05-27 08:41:01', 'l'), + (9, '2004-05-25', '2004-09-18 00:00:00', 'c'), + (3, '2005-01-17', '2002-09-12 11:18:48', 'd'), + (0, '2003-08-28', '1900-01-01 00:00:00', 'k'), + (6, '2006-10-11', '2003-10-28 03:31:02', 'a'), + (5, '1900-01-01', '2001-08-22 10:20:09', 'p'), + (8, '1900-01-01', '2008-04-24 00:00:00', 'o'), + (4, '2005-08-18', '2006-11-10 10:08:49', 'e'), + (NULL, '2007-03-12', '2007-10-16 00:00:00', 'n'), + (1, '2000-11-18', '2009-05-27 12:25:07', 't'), + (4, '2001-03-03', NULL, 'u'), + (3, '2003-09-11', '2001-09-10 18:10:10', 'f'), + (4, '2007-06-17', '1900-01-01 00:00:00', 't'), + (NULL, '2008-09-11', '2004-06-07 23:17:09', 'k'); +ALTER TABLE t1 ADD UNIQUE KEY ind1 (pk, d, i, v); +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE KEY ind2 (d, v); +DROP TABLE t1; diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index 88f0d034bf0..779ea8d13d4 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -309,15 +309,36 @@ CHECK TABLE bug47205 FOR UPGRADE; DROP TABLE bug47205; + --echo # --echo #MDEV-6128:[PATCH] mysqlcheck wrongly escapes '.' in table names --echo # -CREATE TABLE test.`t.1` (id int); +create table `t.1` (id int); +create view `v.1` as select 1; --echo mysqlcheck test t.1 --exec $MYSQL_CHECK test t.1 +--echo mysqlcheck --all-in-1 test t.1 +--exec $MYSQL_CHECK --all-in-1 test t.1 +--echo mysqlcheck --all-in-1 --databases --process-views test +--exec $MYSQL_CHECK --all-in-1 --databases --process-views test -drop table test.`t.1`; +create table `t.2`(a varchar(20) primary key) default character set utf8 collate utf8_general_ci engine=innodb; +flush table `t.2`; +--remove_file $MYSQLD_DATADIR/test/t@002e2.frm +--copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/t@002e2.frm + +--copy_file std_data/bug36055.frm $MYSQLD_DATADIR/test/t@002e3.frm +--copy_file std_data/bug36055.MYD $MYSQLD_DATADIR/test/t@002e3.MYD +--copy_file std_data/bug36055.MYI $MYSQLD_DATADIR/test/t@002e3.MYI + +--echo mysqlcheck --check-upgrade --auto-repair test +--exec $MYSQL_CHECK --check-upgrade --auto-repair test + +check table `t.1`, `t.2`, `t.3`; +check table `t.1`, `t.2`, `t.3` for upgrade; +drop view `v.1`; +drop table test.`t.1`, `t.2`, `t.3`; --echo # --echo # MDEV-8123 mysqlcheck: new --process-views option conflicts with --quick, --extended and such @@ -350,6 +371,33 @@ create table t1(a int); drop view v1; drop table t1; +create table `#mysql50#t1``1` (a int) engine=myisam; +--exec $MYSQL_CHECK --fix-table-names --databases test +show tables; +drop table `t1``1`; + +# +# MDEV-9440 mysqlcheck -A --auto-repair selects wrong database when trying to repair broken table +# +call mtr.add_suppression("ha_myisam"); +call mtr.add_suppression("Checking table"); +create database mysqltest1; +create table mysqltest1.t1 (a int) engine=myisam; +create table t2 (a int); + +let $datadir= `select @@datadir`; +remove_file $datadir/mysqltest1/t1.MYD; +write_file $datadir/mysqltest1/t1.MYD; +foo +EOF + +check table mysqltest1.t1; + +--exec $MYSQL_CHECK -A --auto-repair --fast + +drop table t2; +drop database mysqltest1; + --echo # --echo #MDEV-7384 [PATCH] add PERSISENT FOR ALL option to mysqlanalyze/mysqlcheck --echo # diff --git a/mysql-test/t/named_pipe.test b/mysql-test/t/named_pipe.test index 8dcab3329e4..af74c200e96 100644 --- a/mysql-test/t/named_pipe.test +++ b/mysql-test/t/named_pipe.test @@ -22,3 +22,12 @@ connect(pipe_con,localhost,root,,,,,PIPE); connection default; disconnect pipe_con; + +# MDEV-10383 : check that other server cannot 'bind' on the same pipe +let $MYSQLD_DATADIR= `select @@datadir`; +--error 1 +--exec $MYSQLD_CMD --enable-named-pipe --skip-networking --log-error=second-mysqld.err +let SEARCH_FILE=$MYSQLD_DATADIR/second-mysqld.err; +let SEARCH_RANGE= -50; +let SEARCH_PATTERN=\[ERROR\] Create named pipe failed; +source include/search_pattern_in_file.inc; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index a5db4442183..84b3f069683 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -1007,6 +1007,17 @@ SELECT * FROM t1 WHERE NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(N DROP TABLE t1; +--echo # +--echo # MDEV-10236 Where expression with NOT function gives incorrect result +--echo # +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1),(2),(3); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +DROP TABLE t1; + + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 837206e2717..eea74b5b012 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -134,8 +134,7 @@ drop table t1; # verification of servers certificate by setting both ca certificate # and ca path to NULL # ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA ---exec $MYSQL --ssl --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem -e "SHOW STATUS LIKE 'ssl_Cipher'" 2>&1 +--exec $MYSQL --ssl --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem -e "SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'" 2>&1 --echo End of 5.0 tests # @@ -259,8 +258,7 @@ select 'is still running; no cipher request crashed the server' as result from d GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; FLUSH PRIVILEGES; connect(con1,localhost,bug42158,,,,,SSL); ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA -SHOW STATUS LIKE 'Ssl_cipher'; +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; disconnect con1; connection default; DROP USER bug42158@localhost; diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 0a19b03a4eb..eec8a162748 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -759,6 +759,22 @@ CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW SET default_storage_engine = NEW.INNODB; DROP TABLE t1; +# +# MDEV-8328 Evaluation of two "!" operators depends on space in beetween +# +--error ER_PARSE_ERROR +select 0==0; +select 1=!0, 1 = ! 0; +select !!0, ! ! 0; +select 2>!0, 2 > ! 0; +select 0<=!0, 0 <= !0; +select 1< 1)); +--echo # The following must show col1=12345 for all rows: +select * from t1; +drop table t1; + --echo # --echo # BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE --echo # @@ -1816,6 +1845,15 @@ INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'); EXPLAIN SELECT * FROM t1 WHERE a<=>'😎'; DROP TABLE t1; +--echo # +--echo # MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in +--echo # sel_trees_can_be_ored(RANGE_OPT_PARAM*, SEL_TREE*, SEL_TREE*, key_map*) +--echo # +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM t1 WHERE pk != 1000 OR pk IN ( 1000, 0, 1, 100, 2 ) OR pk >= 5; +DROP TABLE t1; + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/sp-prelocking.test b/mysql-test/t/sp-prelocking.test index 966c59a5789..c1378d59196 100644 --- a/mysql-test/t/sp-prelocking.test +++ b/mysql-test/t/sp-prelocking.test @@ -388,3 +388,29 @@ DROP TABLE t1, t2; --echo End of 5.0 tests +--echo # +--echo # Bug#21142859: FUNCTION UPDATING A VIEW FAILS TO FIND TABLE THAT ACTUALLY EXISTS +--echo # + +CREATE TABLE t1 SELECT 1 AS fld1, 'A' AS fld2; +CREATE TABLE t2 (fld3 INT, fld4 CHAR(1)); + +CREATE VIEW v1 AS SELECT * FROM t1; + +CREATE TRIGGER t1_au AFTER UPDATE ON t1 +FOR EACH ROW INSERT INTO t2 VALUES (new.fld1, new.fld2); + +DELIMITER !; +CREATE FUNCTION f1() RETURNS INT +BEGIN + UPDATE v1 SET fld2='B' WHERE fld1=1; + RETURN row_count(); +END ! +DELIMITER ;! + +--echo # Without the patch, an error was getting reported. +SELECT f1(); + +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1,t2; diff --git a/mysql-test/t/ssl.test b/mysql-test/t/ssl.test index 21733f7e594..9a08b273b6b 100644 --- a/mysql-test/t/ssl.test +++ b/mysql-test/t/ssl.test @@ -11,8 +11,7 @@ connect (ssl_con,localhost,root,,,,,SSL); # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA -SHOW STATUS LIKE 'Ssl_cipher'; +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; # Check ssl expiration SHOW STATUS LIKE 'Ssl_server_not_before'; @@ -22,8 +21,7 @@ SHOW STATUS LIKE 'Ssl_server_not_after'; -- source include/common-tests.inc # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA -SHOW STATUS LIKE 'Ssl_cipher'; +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; # # MDEV-7697 Client reports ERROR 2006 (MySQL server has gone away) or ERROR 2013 (Lost connection to MySQL server during query) while executing AES* functions under SSL @@ -34,5 +32,10 @@ select 'still connected?'; connection default; disconnect ssl_con; +create user mysqltest_1@localhost; +grant usage on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; +--exec $MYSQL -umysqltest_1 --ssl-cipher=EDH-RSA-DES-CBC3-SHA -e "show status like 'ssl_cipher'" 2>&1 +drop user mysqltest_1@localhost; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/ssl_ca.test b/mysql-test/t/ssl_ca.test new file mode 100644 index 00000000000..8d830a75879 --- /dev/null +++ b/mysql-test/t/ssl_ca.test @@ -0,0 +1,32 @@ +--source include/have_ssl_communication.inc +--source include/not_embedded.inc + +--echo # +--echo # Bug#21920657: SSL-CA FAILS SILENTLY IF THE PATH CANNOT BE FOUND +--echo # + +--echo # try to connect with wrong '--ssl-ca' path : should fail +--error 1 +--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/wrong-cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'" 2>&1 + +--echo # try to connect with correct '--ssl-ca' path : should connect +--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'" + +--echo # +--echo # Bug#21920678: SSL-CA DOES NOT ACCEPT ~USER TILDE HOME DIRECTORY +--echo # PATH SUBSTITUTION +--echo # + +--let $mysql_test_dir_path= `SELECT IF(LENGTH('$HOME'), REPLACE('=$MYSQL_TEST_DIR', '=$HOME', '=~'), '=$MYSQL_TEST_DIR')` + +--echo # try to connect with '--ssl-ca' option using tilde home directoy +--echo # path substitution : should connect +--exec $MYSQL --ssl-ca$mysql_test_dir_path/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'" + +--echo # try to connect with '--ssl-key' option using tilde home directoy +--echo # path substitution : should connect +--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key$mysql_test_dir_path/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'" + +--echo # try to connect with '--ssl-cert' option using tilde home directoy +--echo # path substitution : should connect +--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert$mysql_test_dir_path/std_data/client-cert.pem test -e "SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'" diff --git a/mysql-test/t/ssl_compress.test b/mysql-test/t/ssl_compress.test index 28f3453c23e..588d4555db8 100644 --- a/mysql-test/t/ssl_compress.test +++ b/mysql-test/t/ssl_compress.test @@ -11,8 +11,7 @@ connect (ssl_compress_con,localhost,root,,,,,SSL COMPRESS); # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA -SHOW STATUS LIKE 'Ssl_cipher'; +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; # Check compression turned on SHOW STATUS LIKE 'Compression'; @@ -21,8 +20,7 @@ SHOW STATUS LIKE 'Compression'; -- source include/common-tests.inc # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA -SHOW STATUS LIKE 'Ssl_cipher'; +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; # Check compression turned on SHOW STATUS LIKE 'Compression'; diff --git a/mysql-test/t/ssl_timeout.test b/mysql-test/t/ssl_timeout.test index 806b928aca0..430fe7130de 100644 --- a/mysql-test/t/ssl_timeout.test +++ b/mysql-test/t/ssl_timeout.test @@ -7,8 +7,7 @@ connect (ssl_con,localhost,root,,,,,SSL read_timeout=5); --echo # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA -SHOW STATUS LIKE 'Ssl_cipher'; +SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; # --error CR_SERVER_LOST --error 2013 diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 3599b523d91..dba2154ef73 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -6009,5 +6009,22 @@ SET NAMES utf8; CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM; INSERT INTO t1 VALUES ('foo'); SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' ); +SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar'); drop table t1; SET NAMES default; + +--echo # +--echo # MDEV-10045: Server crashes in Time_and_counter_tracker::incr_loops +--echo # +SET NAMES utf8; + +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT UNSIGNED) ENGINE=MyISAM; +CREATE TABLE t2 (f3 INT) ENGINE=MyISAM; + +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo' UNION SELECT 'bar' ); +SELECT * FROM t1, t2 WHERE f3 = f2 AND f1 > ANY ( SELECT 'foo'); + +DROP TABLE t1, t2; +SET NAMES default; + +--echo End of 10.1 tests diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index d2bafa86028..559b380a7dc 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1925,3 +1925,15 @@ EXECUTE stmt; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-10389: Query returns different results on a debug vs non-debug build of the same revision +--echo # +CREATE TABLE t1 (i1 INT, i2 INT NOT NULL); +INSERT INTO t1 VALUES (1,4),(2,6); + +SELECT * FROM t1 AS alias1 +WHERE alias1.i1 IN ( + SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 ) +); +DROP TABLE t1; + diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 987fbf7e848..43621cf6ba1 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -320,6 +320,10 @@ REPAIR TABLE t1, t2, t3; DROP TABLES t1, t2, t3; +CREATE TEMPORARY TABLE t1 (a int); +RENAME TABLE t1 TO t2; +DROP TABLE t2; + # # CREATE TEMPORARY TEMPORARY TABLE # diff --git a/mysql-test/t/trigger_null-8605.test b/mysql-test/t/trigger_null-8605.test index 4b51ccd5606..748768a1849 100644 --- a/mysql-test/t/trigger_null-8605.test +++ b/mysql-test/t/trigger_null-8605.test @@ -336,7 +336,8 @@ select * from t1; delete from t1; create trigger t1_bi before insert on t1 for each row begin end; insert t1 values (0); -select * from t1; +--error ER_DUP_ENTRY +insert t1 (id) values (0); drop table t1; # diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index ce76ad410b6..63c89f318fc 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -169,18 +169,8 @@ DROP TABLE t1; # CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); -## The current sub test could fail (difference to expected result) if we -## have just reached midnight. -## (Bug#41776 type_date.test may fail if run around midnight) -## Therefore we sleep a bit if we are too close to midnight. -## The complete test itself needs in average less than 1 second. -## Therefore a time_distance to midnight of 5 seconds should be sufficient. -if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`) -{ - # We are here when CURTIME() is between '23:59:56' and '23:59:59'. - # So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'. - --real_sleep 5 -} + +SET timestamp=UNIX_TIMESTAMP('2016-07-21 14:48:18'); INSERT INTO t1 VALUES (DATE(NOW()), 1); SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); @@ -192,6 +182,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; ALTER TABLE t1 DROP PRIMARY KEY; SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +SET timestamp=DEFAULT; DROP TABLE t1; @@ -387,6 +378,7 @@ drop table t1; --echo # --echo # MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null +--echo # MDEV-9972 Least function retuns date in date time format --echo # CREATE TABLE t1 ( id BIGINT NOT NULL, diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 444ab02d223..6b752b1a978 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -610,6 +610,14 @@ EXECUTE stmt1; DEALLOCATE PREPARE stmt1; DROP TABLE t1,t2; +--echo # +--echo # MDEV-9374 having '2015-01-01 01:00:00.000001' > coalesce(NULL) returns true +--echo # +CREATE TABLE t1 (c1 DATETIME(0)); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 HAVING '2015-01-01 01:00:00.000001' > COALESCE(c1); +DROP TABLE t1; + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 86066309acc..b84d01e93be 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1684,6 +1684,57 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5); EXPLAIN SELECT * FROM t1 WHERE a='ax' ORDER BY a; DROP TABLE t1; + +--echo # +--echo # MDEV-8502 DECIMAL accepts out of range DEFAULT values +--echo # + +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000); +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000.0); +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000e0); +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '10000.0'); +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '10000.1'); + +--echo # +--echo # MDEV-10277 Redundant NOTE when inserting '0.00001 ' into a DECIMAL(2,1) column +--echo # +CREATE TABLE t1 (a DECIMAL(2,1)); +INSERT INTO t1 VALUES ('0.00001 '); +INSERT INTO t1 VALUES ('1e-10000 '); +INSERT INTO t1 VALUES ('0.1 '); +INSERT INTO t1 VALUES ('0.111 '); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '1e-10000'); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '0.1 '); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '0.10001 '); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '0.10001'); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 0.10001); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 0.10001e0); +SHOW CREATE TABLE t1; +DROP TABLE t1; + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index f1288e6a63d..006634d9ba9 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5502,6 +5502,21 @@ alter table v1 check partition p1; drop view v1; drop table t1; + +--echo # +--echo # MDEV-10419: crash in mariadb 10.1.16-MariaDB-1~trusty +--echo # +CREATE TABLE t1 (c1 CHAR(13)); +CREATE TABLE t2 (c2 CHAR(13)); + +CREATE FUNCTION f() RETURNS INT RETURN 0; +CREATE OR REPLACE VIEW v1 AS select f() from t1 where c1 in (select c2 from t2); +DROP FUNCTION f; + +SHOW CREATE VIEW v1; + +drop view v1; +drop table t1,t2; --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- diff --git a/mysql-test/t/xtradb_mrr.test b/mysql-test/t/xtradb_mrr.test index 260eb9f3955..d994c182ccc 100644 --- a/mysql-test/t/xtradb_mrr.test +++ b/mysql-test/t/xtradb_mrr.test @@ -33,8 +33,8 @@ insert into t2 select from t1 A, t1 B, t1 C; explain -select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a'; -select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a'; +select count(length(a) + length(filler)) from t2 force index (a) where a>='a-1000-a' and a <'a-1001-a'; +select count(length(a) + length(filler)) from t2 force index (a) where a>='a-1000-a' and a <'a-1001-a'; drop table t2; # Try a very big rowid diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests new file mode 100644 index 00000000000..daba2ea8ae8 --- /dev/null +++ b/mysql-test/unstable-tests @@ -0,0 +1,355 @@ +############################################################################## +# +# List the test cases which, unlike tests from disabled.def files, +# can still be run on the current tree meaningfully, but are known +# or suspected to fail sporadically on different reasons. +# +# Most common reasons are either test failures observed in buildbot, +# or recent modifications to the tests which make their stability +# unknown. +# +# Tests included due to recent modifications are later removed from the +# list, if during a certain period they do not fail (and are not +# modified again). Tests included due to intermittent failures are +# removed when corresponding bug reports are closed. +# +# Separate the test case name and the comment with ':'. +# +# . : MDEV-xxxxx - +# +# '*' wildcard in testcase names is supported. +# +# To use the list, run MTR with --skip-test-list=unstable-tests option. +# +############################################################################## + +main.analyze_stmt_slow_query_log : MDEV-7558 - wrong result +main.bootstrap : Modified on 2016-06-18 (MDEV-9969) +main.create_delayed : MDEV-10605 - failed with timeout +main.create_or_replace : Modified on 2016-06-23 (MDEV-9728) +main.ctype_recoding : Modified on 2016-06-10 (MDEV-10181) +main.ctype_utf8 : Modified on 2016-06-21 (merge) +main.ctype_utf8mb4 : Modified on 2016-06-21 (merge) +main.ctype_utf16le : MDEV-10675: timeout or extra warnings +main.events_1 : Modified on 2016-06-21 (MDEV-9524) +main.func_group : Modified on 2016-08-08 (MDEV-10468) +main.func_in : Modified on 2016-06-20 (MDEV-10020) +main.func_math : Modified on 2016-08-10 (merge) +main.func_misc : Modified on 2016-08-10 (merge) +main.grant2 : Modified on 2016-07-18 (MDEV-8569) +main.help : Modified on 2016-06-21 (MDEV-9524) +main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown +main.index_intersect_innodb : MDEV-10643 - failed with timeout +main.index_merge_innodb : MDEV-7142 - sporadic wrong execution plan +main.information_schema_stats : Modified on 2016-07-25 (MDEV-10428) +main.innodb_mysql_lock : MDEV-7861 - sporadic lock detection failure +main.insert_innodb : Modified on 2016-06-14 (merge from upstream) +main.loaddata : Modified on 2016-08-10 (merge) +main.locale : Modified on 2016-06-21 (merge) +main.mdev-504 : MDEV-10607 - sporadic "can't connect" +main.mdev375 : MDEV-10607 - sporadic "can't connect" +main.merge : MDEV-10607 - sporadic "can't connect" +main.multi_update : Modified on 2016-06-20 (MDEV-5973) +main.myisam_enable_keys-10506 : New test, added on 2016-08-10 (MDEV-10506) +main.mysqlcheck : Modified on 2016-08-10 (merge) +main.mysqldump : MDEV-10512 - sporadic assertion failure +main.mysqltest : MDEV-9269 - fails on Alpha +main.named_pipe : Modified on 2016-08-02 (MDEV-10383) +main.openssl_1 : Modified on 2016-07-11 (MDEV-10211) +main.order_by_optimizer_innodb : MDEV-10683 - wrong execution plan +main.parser : Modified on 2016-06-21 (merge) +main.pool_of_threads : MDEV-10100 - sporadic error on detecting max connections +main.ps_1general : Modified on 2016-07-12 (merge) +main.range : Modified on 2016-08-10 (merge) +main.range_mrr_icp : Modified on 2016-08-10 (merge) +main.query_cache : MDEV-10611 - sporadic mutex problem +main.show_explain : MDEV-10674 - sporadic failure +main.shutdown : MDEV-10612 - sporadic crashes +main.sp-prelocking : Modified on 2016-08-10 (merge) +main.sp-security : MDEV-10607 - sporadic "can't connect" +main.ssl : MDEV-10211 - different ciphers on some platforms +main.ssl_ca : Modified on 2016-07-11 (MDEV-10211) +main.ssl_compress : Modified on 2016-07-11 (MDEV-10211) +main.ssl_timeout : Modified on 2016-07-11 (MDEV-10211) +main.stat_tables_par_innodb : MDEV-10515 - sporadic wrong results +main.status : MDEV-8510 - sporadic wrong result +main.status_user : Modified on 2016-06-20 (MDEV-8633) +main.subselect : Modified in 10.1.17 +main.subselect_innodb : MDEV-10614 - sporadic wrong results +main.subselect_sj_mat : Modified in 10.1.17 +main.temp_table : Modified on 2016-06-18 (MDEV-8569) +main.type_date : Modified on 2016-08-10 (merge) +main.type_datetime : Modified on 2016-06-16 (MDEV-9374) +main.type_datetime_hires : MDEV-10687 - timeout +main.view : Modified on 2016-08-10 (merge) +main.xtradb_mrr : Modified on 2016-08-04 (MDEV-9946) + +#---------------------------------------------------------------- + +archive.archive-big : MDEV-10615 - table is marked as crashed +archive.discover : MDEV-10510 - table is marked as crashed + +#---------------------------------------------------------------- + +binlog.binlog_commit_wait : MDEV-10150 - Error: too much time elapsed +binlog.binlog_dmls_on_tmp_tables_readonly : New test, added on 2016-05-04 (upstream) +binlog.binlog_xa_recover : MDEV-8517 - Extra checkpoint + +#---------------------------------------------------------------- + +connect.tbl : MDEV-9844, MDEV-10179 - sporadic crashes, valgrind warnings, wrong results +connect.jdbc : New test, added on 2016-07-15 +connect.jdbc-new : New test, added on 2016-07-14 +connect.jdbc-oracle : New test, added on 2016-07-13 +connect.jdbc-postgresql : New test, added on 2016-07-13 + +#---------------------------------------------------------------- + +galera.GAL-382 : New test, added in 10.1.17 +galera.MW-252 : New test, added in 10.1.17 +galera.MW-258 : New test, added in 10.1.17 +galera.MW-259 : New test, added in 10.1.17 +galera.MW-285 : New test, added in 10.1.17 +galera.MW-286 : New test, added in 10.1.17 +galera.MW-292 : New test, added in 10.1.17 +galera.MW-44 : New test, added in 10.1.17 +galera.galera#414 : New test, added in 10.1.17 +galera.galera_as_slave_autoinc : New test, added in 10.1.17 +galera.galera_as_slave_nonprim : Modified in 10.1.17 +galera.galera_bf_abort_flush_for_export : Modified in 10.1.17 +galera.galera_gcs_fc_limit : Modified in 10.1.17 +galera.galera_ist_recv_bind : New test, added in 10.1.17 +galera.galera_ist_restart_joiner : Modified in 10.1.17 +galera.galera_kill_ddl : Modified in 10.1.17 +galera.galera_parallel_simple : Modified in 10.1.17 +galera.galera_pc_ignore_sb : Modified in 10.1.17 +galera.galera_restart_nochanges : Modified in 10.1.17 +galera.galera_roles : Modified in 10.1.17 +galera.galera_rsu_wsrep_desync : Modified in 10.1.17 +galera.galera_split_brain : Modified in 10.1.17 +galera.galera_ssl_upgrade : Modified in 10.1.17 +galera.galera_suspend_slave : Modified in 10.1.17 +galera.galera_transaction_replay : Modified in 10.1.17 +galera.galera_var_dirty_reads : Modified in 10.1.17 +galera.galera_var_max_ws_rows : New test, added in 10.1.17 +galera.galera_var_max_ws_size : Modified in 10.1.17 +galera.mdev_10518 : New test, added in 10.1.17 +galera.mysql-wsrep#31 : Modified in 10.1.17 + +galera_3nodes.galera_certification_ccc : Modified in 10.1.17 +galera_3nodes.galera_innobackupex_backup : Modified in 10.1.17 +galera_3nodes.galera_ist_gcache_rollover : Modified in 10.1.17 +galera_3nodes.galera_pc_bootstrap : Modified in 10.1.17 +galera_3nodes.galera_pc_weight : Modified in 10.1.17 + +#---------------------------------------------------------------- + +encryption.create_or_replace : MDEV-9359 - Assertion failure +encryption.innodb-bad-key-shutdown : MDEV-9105 - valgrind warnings, assertion failures +encryption.innodb_encryption_discard_import : MDEV-9099 - warnings, errors, crash +encryption.innodb_encryption_filekeys : MDEV-9062 - timeouts +encryption.innodb_first_page : MDEV-10689 - crashes +encryption.innodb_onlinealter_encryption : MDEV-10099 - wrong results +encryption.innodb-page_encryption : MDEV-10641 - mutex problem + +#---------------------------------------------------------------- + +federated.federatedx : MDEV-10617 - Wrong checksum, timeouts +federated.federated_innodb : MDEV-10617, MDEV-10417 - Wrong checksum, timeouts, fails on Mips +federated.federated_partition : MDEV-10417 - Fails on Mips +federated.federated_transactions : MDEV-10617, MDEV-10417 - Wrong checksum, timeouts, fails on Mips + +#---------------------------------------------------------------- + +funcs_1.processlist_priv_no_prot : Include file modified on 2016-07-12 (merge) +funcs_1.processlist_priv_ps : Include file modified on 2016-07-12 (merge) +funcs_2.memory_charset : MDEV-10290 - timeout + +#---------------------------------------------------------------- + +innodb.binlog_consistent : MDEV-10618 - Server fails to start +innodb.innodb-alter-table : MDEV-10619 - Testcase timeout +innodb.innodb-alter-tempfile : Modified on 2016-08-09 (MDEV-10469) +innodb.innodb_blob_truncate : MDEV-10377 - Assertion failure +innodb.innodb-bug-14068765 : MDEV-9105 - valgrind warnings, assertion failures +innodb.innodb_corrupt_bit : Modified on 2016-06-21 (merge) +innodb.innodb-bug-14084530 : MDEV-9105 - valgrind warnings, assertion failures +innodb.innodb_bug30423 : MDEV-7311 - Wrong number of rows in the plan +innodb.innodb-fk-warnings : Modified on 2016-07-18 (MDEV-8569) +innodb.innodb-fkcheck : Modified on 2016-06-13 (MDEV-10083) +innodb.innodb-page_compression_zip : MDEV-10641 - mutex problem +innodb.innodb_stats : MDEV-10682 - wrong result +innodb.innodb_sys_semaphore_waits : MDEV-10331 - wrong result +innodb.innodb-wl5522 : MDEV-9105 - valgrind warnings, assertion failures +innodb.innodb-wl5522-1 : MDEV-9105 - valgrind warnings, assertion failures +innodb.innodb-wl5522-debug-zip : MDEV-10427 - Warning: database page corruption +innodb.innodb-wl5522-zip : MDEV-9105 - valgrind warnings, assertion failures +innodb.xa_recovery : MDEV-10685 - warnings + +#---------------------------------------------------------------- + +innodb_zip.innodb_prefix_index_liftedlimit : MDEV-10686 - timeout + +#---------------------------------------------------------------- + +mroonga/storage.column_datetime_32bit_2038 : Wrong result on Alpha +mroonga/storage.column_datetime_32bit_before_unix_epoch : Wrong result on Alpha +mroonga/storage.column_datetime_32bit_max : Wrong result on Alpha +mroonga/storage.column_datetime_32bit_out_of_range : Wrong result on Alpha +mroonga/storage.index_multiple_column_unique_date_32bit_equal : Wrong result on Alpha +mroonga/storage.index_multiple_column_unique_date_order_32bit_desc : Wrong result on Alpha +mroonga/storage.index_multiple_column_unique_datetime_index_read : MDEV-8643 - valgrind warnings +mroonga/storage.repair_table_no_index_file : MDEV-9364 - wrong result + +#---------------------------------------------------------------- + +multi_source.gtid : MDEV-10620, MDEV-10417 - Timeout in wait condition, fails on Mips +multi_source.info_logs : MDEV-10042 - wrong result +multi_source.multisource : MDEV-10417 - Fails on Mips +multi_source.reset_slave : MDEV-10690 - wrong result +multi_source.simple : MDEV-4633 - Wrong slave status output +multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_received_heartbeats + +#---------------------------------------------------------------- + +parts.partition_float_myisam : MDEV-10621 - Testcase timeout +parts.partition_int_myisam : MDEV-10621 - Testcase timeout + +#---------------------------------------------------------------- + +perfschema.digest_table_full : Modified on 2016-06-21 (merge) +perfschema.func_file_io : MDEV-5708 - fails for s390x +perfschema.func_mutex : MDEV-5708 - fails for s390x +perfschema.rpl_gtid_func : Modified on 2016-06-21 (merge) +perfschema.setup_actors : MDEV-10679 - rare crash +perfschema.sizing_low : Modified on 2016-04-26 (5.6.30 merge) +perfschema.socket_summary_by_event_name_func : MDEV-10622 - Socket summary tables do not match +perfschema.start_server_low_digest : Modified on 2016-06-21 (merge) +perfschema.statement_digest : Modified on 2016-06-21 (merge) +perfschema.statement_digest_consumers : Modified on 2016-06-21 (merge) +perfschema.statement_digest_long_query : Modified on 2016-06-21 (merge) +perfschema.table_name : New test, added on 2016-04-26 (5.6.30 merge) +perfschema.threads_mysql : MDEV-10677 - sporadic wrong result + +#---------------------------------------------------------------- + +plugins.feedback_plugin_send : MDEV-7932 - ssl failed for url +plugins.pam : Modified on 2016-08-03 (MDEV-7329) +plugins.pam_cleartext : Modified on 2016-08-03 +plugins.server_audit : MDEV-9562 - crashes on sol10-sparc +plugins.thread_pool_server_audit : MDEV-9562 - crashes on sol10-sparc + +#---------------------------------------------------------------- + +roles.rpl_grant_revoke_current_role-8638 : New test, added on 2016-06-20 (MDEV-8638) +roles.set_role-9614 : New test, added on 2016-05-30 (MDEV-9614) + +#---------------------------------------------------------------- + +rpl.last_insert_id : MDEV-10625 - warnings in error log +rpl.rpl_auto_increment : MDEV-10417 - Fails on Mips +rpl.rpl_auto_increment_bug45679 : MDEV-10417 - Fails on Mips +rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log +rpl.rpl_binlog_index : MDEV-9501 - Warning: failed registering on master +rpl.rpl_checksum_cache : MDEV-10626 - Testcase timeout +rpl.rpl_circular_for_4_hosts : MDEV-10627 - Testcase timeout +rpl.rpl_ddl : MDEV-10417 - Fails on Mips +rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result +rpl.rpl_gtid_basic : MDEV-10681 - server startup problem +rpl.rpl_gtid_crash : MDEV-9501 - Warning: failed registering on master +rpl.rpl_gtid_master_promote : MDEV-10628 - Timeout in sync_with_master +rpl.rpl_gtid_mdev9033 : MDEV-10680 - warnings +rpl.rpl_gtid_stop_start : MDEV-10629 - Crash on shutdown +rpl.rpl_gtid_until : MDEV-10625 - warnings in error log +rpl.rpl_ignore_table : Modified on 2016-06-22 +rpl.rpl_innodb_bug30888 : MDEV-10417 - Fails on Mips +rpl.rpl_insert : MDEV-9329 - Fails on Ubuntu/s390x +rpl.rpl_insert_delayed : MDEV-9329 - Fails on Ubuntu/s390x +rpl.rpl_invoked_features : MDEV-10417 - Fails on Mips +rpl.rpl_mdev6020 : MDEV-10630, MDEV-10417 - Timeouts, fails on Mips +rpl.rpl_mdev6386 : MDEV-10631 - Wrong result on slave +rpl.rpl_parallel : MDEV-10632, MDEV-10653 - Failures to sync, timeouts +rpl.rpl_parallel_optimistic : MDEV-10511 - timeout +rpl.rpl_parallel_temptable : MDEV-10356 - Crash in close_thread_tables +rpl.rpl_partition_innodb : MDEV-10417 - Fails on Mips +rpl.rpl_row_drop_create_temp_table : MDEV-10626 - Testcase timeout +rpl.rpl_row_log_innodb : MDEV-10688 - Wrong result +rpl.rpl_row_sp001 : MDEV-9329 - Fails on Ubuntu/s390x +rpl.rpl_show_slave_hosts : MDEV-10681 - server startup problem +rpl.rpl_semi_sync_uninstall_plugin : MDEV-7140 - Wrong plugin status +rpl.rpl_slave_grp_exec : MDEV-10514 - Unexpected deadlock +rpl.rpl_switch_stm_row_mixed : MDEV-10611 - Wrong usage of mutex +rpl.rpl_sync : MDEV-10633 - Database page corruption +rpl.rpl_temporary_error2 : MDEV-10634 - Wrong number of retries +rpl.sec_behind_master-5114 : MDEV-8518 - Wrong value of Seconds_Behind_Master +rpl.rpl_skip_replication : MDEV-9268 - Fails with timeout in sync_slave_with_master on Alpha + +#---------------------------------------------------------------- + +spider.* : MDEV-9329 - tests are too memory-consuming + +spider/bg.direct_aggregate : MDEV-7098 - Trying to unlock mutex that wasn't locked +spider/bg.direct_aggregate_part : MDEV-7098 - Trying to unlock mutex that wasn't locked +spider/bg.ha : MDEV-7914, MDEV-9329 - Crash, failures on s390x +spider/bg.ha_part : MDEV-9329 - Fails on Ubuntu/s390x +spider/bg.spider_fixes : MDEV-7098, MDEV-9329 - Mutex problem, failures on s390x +spider/bg.vp_fixes : MDEV-9329 - Fails on Ubuntu/s390x + +#---------------------------------------------------------------- + +stress.ddl_innodb : MDEV-10635 - Testcase timeout + +#---------------------------------------------------------------- + +sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x +sys_vars.general_log_file_basic : Modified on 2016-08-09 (MDEV-10465) +sys_vars.keep_files_on_create_basic : MDEV-10676 - timeout +sys_vars.slow_query_log_file_basic : Modified on 2016-08-09 (MDEV-10465) +sys_vars.sysvars_innodb : MDEV-6958 - error-prone rdiffs +sys_vars.sysvars_server_embedded : MDEV-6958 - error-prone rdiffs +sys_vars.innodb_buffer_pool_dump_pct_basic : MDEV-10651 - sporadic failure on file_exists +sys_vars.innodb_fatal_semaphore_wait_threshold : MDEV-10513 - crashes +sys_vars.sysvars_wsrep : Modified in 10.1.17 +sys_vars.wsrep_max_ws_size_basic : Modified in 10.1.17 + +#---------------------------------------------------------------- + +tokudb.background_job_manager : MDEV-10327 - Assertion failure on server shutdown +tokudb.cluster_filter : MDEV-10678 - Wrong execution plan +tokudb.cluster_filter_hidden : MDEV-10678 - Wrong execution plan +tokudb.cluster_filter_unpack_varchar : MDEV-10636 - Wrong execution plan +tokudb.i_s_tokudb_lock_waits_released : Modified in 10.1.17 +tokudb.i_s_tokudb_locks_released : Modified in 10.1.17 +tokudb.* : MDEV-9891 - massive crashes on shutdown + +tokudb_alter_table.* : MDEV-9891 - massive crashes on shutdown + +tokudb_bugs.checkpoint_lock : MDEV-10637 - Wrong processlist output +tokudb_bugs.checkpoint_lock_3 : MDEV-10637 - Wrong processlist output +tokudb_bugs.* : MDEV-9891 - massive crashes on shutdown + +tokudb_parts.* : MDEV-9891 - massive crashes on shutdown + +rpl-tokudb.* : MDEV-9891 - massive crashes on shutdown, also modified on 2016-06-10 (Merge) + +tokudb_add_index.* : MDEV-9891 - massive crashes on shutdown +tokudb_backup.* : MDEV-9891 - massive crashes on shutdown +tokudb_mariadb.* : MDEV-9891 - massive crashes on shutdown +tokudb_sys_vars.* : MDEV-9891 - massive crashes on shutdown +tokudb_rpl.* : MDEV-9891 - massive crashes on shutdown + +#---------------------------------------------------------------- + +unit.ma_test_loghandler : MDEV-10638 - record read not ok + +#---------------------------------------------------------------- + +vcol.charsets : Added on 2016-06-23 +vcol.not_supported : MDEV-10639 - Testcase timeout +vcol.vcol_keys_innodb : MDEV-10639 - Testcase timeout + +#---------------------------------------------------------------- + +wsrep.* : MDEV-10041 - server crashes sporadically during bootstrap + + diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index fd5699b04c6..b2b264e17fa 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -19,36 +19,6 @@ # Suppress some common (not fatal) errors in system libraries found by valgrind # -# -# Pthread doesn't free all thread specific memory before program exists -# -{ - pthread allocate_tls memory loss - Memcheck:Leak - fun:calloc - fun:_dl_allocate_tls - fun:allocate_stack - fun:pthread_create* -} - -{ - pthread allocate_tls memory loss - Memcheck:Leak - fun:calloc - fun:_dl_allocate_tls - fun:pthread_create* - -} - -{ - pthread allocate_tls memory loss - Memcheck:Leak - fun:calloc - obj:/lib*/ld*.so - fun:_dl_allocate_tls - fun:pthread_create* -} - { pthead_exit memory loss 1 Memcheck:Leak @@ -89,52 +59,6 @@ fun:_dl_map_object_from_fd } -{ - pthread allocate_dtv memory loss - Memcheck:Leak - fun:calloc - fun:allocate_dtv - fun:_dl_allocate_tls_storage - fun:__GI__dl_allocate_tls - fun:pthread_create -} - -{ - pthread allocate_dtv memory loss second - Memcheck:Leak - fun:calloc - fun:allocate_dtv - fun:_dl_allocate_tls - fun:pthread_create* -} - -{ - pthread memalign memory loss - Memcheck:Leak - fun:memalign - fun:_dl_allocate_tls_storage - fun:__GI__dl_allocate_tls - fun:pthread_create -} - -{ - pthread memalign memory loss2 - Memcheck:Leak - fun:memalign - fun:tls_get_addr_tail - ... - fun:*ha_initialize_handlerton* -} - -{ - pthread memalign memory loss3 - Memcheck:Leak - fun:memalign - fun:tls_get_addr_tail - ... - fun:*ha_finalize_handlerton* -} - { pthread pthread_key_create Memcheck:Leak @@ -1006,18 +930,6 @@ fun:nptl_pthread_exit_hack_handler } -# -# Pthread doesn't free all thread specific memory before program exists -# -{ - pthread allocate_tls memory loss in 2.6.1. - Memcheck:Leak - fun:calloc - obj:*/ld-*.so - fun:_dl_allocate_tls - fun:pthread_create* -} - { memory "leak" in backtrace() of glibc 2.9 (not present in 2.13) Memcheck:Leak @@ -1170,6 +1082,23 @@ fun:gethostbyaddr_r } +# +# Detached threads may not complete deiniitialization by the time shutdown +# thread calls exit. This is unfortunate property of detached threads, which +# we currently can only ignore. Unfortunately there is no way to distinguish +# between false positives generated by detached threads and real memory leaks +# generated by not joined joinable threads. So we hide both cases. +# +# To avoid enumeration of the whole variety of possible traces we ignore all +# "possibly lost" blocks allocated by pthread_create (and it's callees). +# +{ + Detached threads memory loss + Memcheck:Leak + match-leak-kinds:possible + ... + fun:pthread_create* +} { ConnectSE: unixODBC SQLAllocEnv leaves some "still reachable" pointers @@ -1293,25 +1222,6 @@ fun:dlerror } -{ - GitHub codership/mysql-wsrep#176 - Memcheck:Leak - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - { GitHub codership/galera#330 Memcheck:Leak @@ -1405,31 +1315,6 @@ g codership/mysql-wsrep/issues#176 fun:_Z16wsrep_set_paramsRN6galera10ReplicatorEPKc } -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE -} - -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z21wsrep_provider_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - { codership/mysql-wsrep/issues#176 Memcheck:Leak @@ -1540,72 +1425,6 @@ g codership/mysql-wsrep/issues#176 fun:_Z24do_handle_one_connectionP3THD } -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - match-leak-kinds: possible - fun:malloc - fun:strdup - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - match-leak-kinds: definite - fun:malloc - fun:strdup - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z29wsrep_provider_options_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - -{ - codership/mysql-wsrep/issues#176 - Memcheck:Leak - match-leak-kinds: definite - fun:malloc - fun:strdup - fun:_Z16wsrep_get_paramsRKN6galera10ReplicatorE - fun:galera_parameters_get - fun:_ZL24refresh_provider_optionsv - fun:_Z21wsrep_provider_updateP7sys_varP3THD13enum_var_type - fun:_ZN7sys_var6updateEP3THDP7set_var - fun:_ZN7set_var6updateEP3THD - fun:_Z17sql_set_variablesP3THDP4ListI12set_var_baseE - fun:_Z21mysql_execute_commandP3THD - fun:_Z11mysql_parseP3THDPcjP12Parser_state - fun:_ZL17wsrep_mysql_parseP3THDPcjP12Parser_state - fun:_Z16dispatch_command19enum_server_commandP3THDPcj - fun:_Z10do_commandP3THD - fun:_Z24do_handle_one_connectionP3THD - fun:handle_one_connection -} - { codership/galera#331 Memcheck:Leak @@ -1632,4 +1451,3 @@ g codership/mysql-wsrep/issues#176 fun:start_thread fun:clone } - diff --git a/mysys/errors.c b/mysys/errors.c index 11e7d04e79e..2d29740a689 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -1,6 +1,5 @@ -/* - Copyright (c) 2000, 2013, Oracle and/or its affiliates - Copyright (c) 1995, 2013, Monty Program Ab +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index db8d0b51ada..daf99065eb0 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -614,6 +614,7 @@ int _my_b_cache_read(IO_CACHE *info, uchar *Buffer, size_t Count) { /* End of file. Return, what we did copy from the buffer. */ info->error= (int) left_length; + info->seek_not_done=1; DBUG_RETURN(1); } /* @@ -631,6 +632,7 @@ int _my_b_cache_read(IO_CACHE *info, uchar *Buffer, size_t Count) */ info->error= (read_length == (size_t) -1 ? -1 : (int) (read_length+left_length)); + info->seek_not_done=1; DBUG_RETURN(1); } Count-=length; @@ -683,6 +685,7 @@ int _my_b_cache_read(IO_CACHE *info, uchar *Buffer, size_t Count) /* For a read error, return -1, otherwise, what we got in total. */ info->error= length == (size_t) -1 ? -1 : (int) (length+left_length); info->read_pos=info->read_end=info->buffer; + info->seek_not_done=1; DBUG_RETURN(1); } /* @@ -1925,6 +1928,7 @@ void die(const char* fmt, ...) fprintf(stderr,"Error:"); vfprintf(stderr, fmt,va_args); fprintf(stderr,", errno=%d\n", errno); + va_end(va_args); exit(1); } diff --git a/mysys/my_context.c b/mysys/my_context.c index e4ca4143baf..017cebdc110 100644 --- a/mysys/my_context.c +++ b/mysys/my_context.c @@ -696,30 +696,27 @@ my_context_destroy(struct my_context *c) int my_context_spawn(struct my_context *c, void (*f)(void *), void *d) { - void *current_fiber; c->user_func= f; c->user_arg= d; + return my_context_continue(c); +} + +int +my_context_continue(struct my_context *c) +{ /* This seems to be a common trick to run ConvertThreadToFiber() only on the first occurence in a thread, in a way that works on multiple Windows versions. */ - current_fiber= GetCurrentFiber(); + void *current_fiber= GetCurrentFiber(); if (current_fiber == NULL || current_fiber == (void *)0x1e00) current_fiber= ConvertThreadToFiber(c); c->app_fiber= current_fiber; DBUG_SWAP_CODE_STATE(&c->dbug_state); SwitchToFiber(c->lib_fiber); DBUG_SWAP_CODE_STATE(&c->dbug_state); - return c->return_value; -} -int -my_context_continue(struct my_context *c) -{ - DBUG_SWAP_CODE_STATE(&c->dbug_state); - SwitchToFiber(c->lib_fiber); - DBUG_SWAP_CODE_STATE(&c->dbug_state); return c->return_value; } diff --git a/mysys/my_error.c b/mysys/my_error.c index 5d16091e0be..44d112bc049 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -217,7 +217,7 @@ 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) (void), uint first, uint last) { struct my_err_head *meh_p; struct my_err_head **search_meh_pp; diff --git a/mysys/my_write.c b/mysys/my_write.c index a7985997036..43735c18f0a 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2011, 2016, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 4cc767f924d..395659238b3 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -129,13 +129,32 @@ static int safe_print_str(const char *addr, int max_len) #endif -void my_safe_print_str(const char* val, int max_len) +/* + Attempt to print a char * pointer as a string. + + SYNOPSIS + Prints either until the end of string ('\0'), or max_len characters have + been printed. + + RETURN VALUE + 0 Pointer was within the heap address space. + The string was printed fully, or until the end of the heap address space. + 1 Pointer is outside the heap address space. Printed as invalid. + + NOTE + On some systems, we can have valid pointers outside the heap address space. + This is through the use of mmap inside malloc calls. When this function + returns 1, it does not mean 100% that the pointer is corrupted. +*/ + +int my_safe_print_str(const char* val, int max_len) { char *heap_end; #ifdef __linux__ + // Try and make use of /proc filesystem to safely print memory contents. if (!safe_print_str(val, max_len)) - return; + return 0; #endif heap_end= (char*) sbrk(0); @@ -143,12 +162,14 @@ void my_safe_print_str(const char* val, int max_len) if (!PTR_SANE(val)) { my_safe_printf_stderr("%s", "is an invalid pointer"); - return; + return 1; } for (; max_len && PTR_SANE(val) && *val; --max_len) my_write_stderr((val++), 1); my_safe_printf_stderr("%s", "\n"); + + return 0; } #if defined(HAVE_PRINTSTACK) @@ -727,7 +748,7 @@ void my_write_core(int unused) } -void my_safe_print_str(const char *val, int len) +int my_safe_print_str(const char *val, int len) { __try { @@ -737,6 +758,7 @@ void my_safe_print_str(const char *val, int len) { my_safe_printf_stderr("%s", "is an invalid string pointer"); } + return 0; } #endif /*__WIN__*/ diff --git a/mysys/testhash.c b/mysys/testhash.c index 3359b5dce29..96b106bec14 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -169,7 +169,9 @@ static int do_test() for (j=0 ; j < 1000 ; j++) if (key1[j] > 1) break; - if (key1[j] > 1) + // j will be 1000 only if we have no keys in the hash. This only happens + // when the parameter recant is set to 0 via command line argument. + if (j < 1000 && key1[j] > 1) { HASH_SEARCH_STATE state; printf("- Testing identical read\n"); diff --git a/mysys/tree.c b/mysys/tree.c index a9fc542faf6..ab810c64c67 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2010, 2016, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/pcre/AUTHORS b/pcre/AUTHORS index d33723f198a..342417a8a19 100644 --- a/pcre/AUTHORS +++ b/pcre/AUTHORS @@ -8,7 +8,7 @@ Email domain: cam.ac.uk University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2015 University of Cambridge +Copyright (c) 1997-2016 University of Cambridge All rights reserved @@ -19,7 +19,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2010-2015 Zoltan Herczeg +Copyright(c) 2010-2016 Zoltan Herczeg All rights reserved. @@ -30,7 +30,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2009-2015 Zoltan Herczeg +Copyright(c) 2009-2016 Zoltan Herczeg All rights reserved. diff --git a/pcre/CMakeLists.txt b/pcre/CMakeLists.txt index a4faef6f47a..91e2e781fc2 100644 --- a/pcre/CMakeLists.txt +++ b/pcre/CMakeLists.txt @@ -65,6 +65,7 @@ # so it has been removed. # 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".") # 2013-11-05 PH added support for PARENS_NEST_LIMIT +# 2016-03-01 PH applied Chris Wilson's patch for MSVC static build PROJECT(PCRE C CXX) diff --git a/pcre/ChangeLog b/pcre/ChangeLog index 5e5bf188cea..a34f845f8a1 100644 --- a/pcre/ChangeLog +++ b/pcre/ChangeLog @@ -4,12 +4,104 @@ ChangeLog for PCRE Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All development is happening in the PCRE2 10.xx series. +Version 8.39 14-June-2016 +------------------------- + +1. If PCRE_AUTO_CALLOUT was set on a pattern that had a (?# comment between + an item and its qualifier (for example, A(?#comment)?B) pcre_compile() + misbehaved. This bug was found by the LLVM fuzzer. + +2. Similar to the above, if an isolated \E was present between an item and its + qualifier when PCRE_AUTO_CALLOUT was set, pcre_compile() misbehaved. This + bug was found by the LLVM fuzzer. + +3. Further to 8.38/46, negated classes such as [^[:^ascii:]\d] were also not + working correctly in UCP mode. + +4. The POSIX wrapper function regexec() crashed if the option REG_STARTEND + was set when the pmatch argument was NULL. It now returns REG_INVARG. + +5. Allow for up to 32-bit numbers in the ordin() function in pcregrep. + +6. An empty \Q\E sequence between an item and its qualifier caused + pcre_compile() to misbehave when auto callouts were enabled. This bug was + found by the LLVM fuzzer. + +7. If a pattern that was compiled with PCRE_EXTENDED started with white + space or a #-type comment that was followed by (?-x), which turns off + PCRE_EXTENDED, and there was no subsequent (?x) to turn it on again, + pcre_compile() assumed that (?-x) applied to the whole pattern and + consequently mis-compiled it. This bug was found by the LLVM fuzzer. + +8. A call of pcre_copy_named_substring() for a named substring whose number + was greater than the space in the ovector could cause a crash. + +9. Yet another buffer overflow bug involved duplicate named groups with a + group that reset capture numbers (compare 8.38/7 below). Once again, I have + just allowed for more memory, even if not needed. (A proper fix is + implemented in PCRE2, but it involves a lot of refactoring.) + +10. pcre_get_substring_list() crashed if the use of \K in a match caused the + start of the match to be earlier than the end. + +11. Migrating appropriate PCRE2 JIT improvements to PCRE. + +12. A pattern such as /(?<=((?C)0))/, which has a callout inside a lookbehind + assertion, caused pcretest to generate incorrect output, and also to read + uninitialized memory (detected by ASAN or valgrind). + +13. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply + nested set of parentheses of sufficient size caused an overflow of the + compiling workspace (which was diagnosed, but of course is not desirable). + +14. And yet another buffer overflow bug involving duplicate named groups, this + time nested, with a nested back reference. Yet again, I have just allowed + for more memory, because anything more needs all the refactoring that has + been done for PCRE2. An example pattern that provoked this bug is: + /((?J)(?'R'(?'R'(?'R'(?'R'(?'R'(?|(\k'R'))))))))/ and the bug was + registered as CVE-2016-1283. + +15. pcretest went into a loop if global matching was requested with an ovector + size less than 2. It now gives an error message. This bug was found by + afl-fuzz. + +16. An invalid pattern fragment such as (?(?C)0 was not diagnosing an error + ("assertion expected") when (?(?C) was not followed by an opening + parenthesis. + +17. Fixed typo ("&&" for "&") in pcre_study(). Fortunately, this could not + actually affect anything, by sheer luck. + +18. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC + static compilation. + +19. Modified the RunTest script to incorporate a valgrind suppressions file so + that certain errors, provoked by the SSE2 instruction set when JIT is used, + are ignored. + +20. A racing condition is fixed in JIT reported by Mozilla. + +21. Minor code refactor to avoid "array subscript is below array bounds" + compiler warning. + +22. Minor code refactor to avoid "left shift of negative number" warning. + +23. Fix typo causing compile error when 16- or 32-bit JIT is compiled without + UCP support. + +24. Refactor to avoid compiler warnings in pcrecpp.cc. + +25. Refactor to fix a typo in pcre_jit_test.c + +26. Patch to support compiling pcrecpp.cc with Intel compiler. + + Version 8.38 23-November-2015 ----------------------------- 1. If a group that contained a recursive back reference also contained a forward reference subroutine call followed by a non-forward-reference - subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to + subroutine call, for example /.((?2)(?R)\1)()/, pcre_compile() failed to compile correct code, leading to undefined behaviour or an internally detected error. This bug was discovered by the LLVM fuzzer. diff --git a/pcre/LICENCE b/pcre/LICENCE index 9f6f98e477f..dd977af971b 100644 --- a/pcre/LICENCE +++ b/pcre/LICENCE @@ -25,7 +25,7 @@ Email domain: cam.ac.uk University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2015 University of Cambridge +Copyright (c) 1997-2016 University of Cambridge All rights reserved. @@ -36,7 +36,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2010-2015 Zoltan Herczeg +Copyright(c) 2010-2016 Zoltan Herczeg All rights reserved. @@ -47,7 +47,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2009-2015 Zoltan Herczeg +Copyright(c) 2009-2016 Zoltan Herczeg All rights reserved. diff --git a/pcre/NEWS b/pcre/NEWS index 7e42dcb3603..0ca1bab2a4c 100644 --- a/pcre/NEWS +++ b/pcre/NEWS @@ -1,6 +1,15 @@ News about PCRE releases ------------------------ +Release 8.39 14-June-2016 +------------------------- + +Some appropriate PCRE2 JIT improvements have been retro-fitted to PCRE1. Apart +from that, this is another bug-fix release. Note that this library (now called +PCRE1) is now being maintained for bug fixes only. New projects are advised to +use the new PCRE2 libraries. + + Release 8.38 23-November-2015 ----------------------------- diff --git a/pcre/RunGrepTest b/pcre/RunGrepTest index a6e93d34892..721ec5184ab 100755 --- a/pcre/RunGrepTest +++ b/pcre/RunGrepTest @@ -67,6 +67,15 @@ fi ./pcretest -C utf >/dev/null utf8=$? +# We need valgrind suppressions when JIT is in use. (This isn't perfect because +# some tests are run with -no-jit, but as PCRE1 is in maintenance only, I have +# not bothered about that.) + +./pcretest -C jit >/dev/null +if [ $? -eq 1 -a "$valgrind" != "" ] ; then + valgrind="$valgrind --suppressions=./testdata/valgrind-jit.supp" +fi + echo "Testing pcregrep main features" echo "---------------------------- Test 1 ------------------------------" >testtrygrep diff --git a/pcre/RunTest b/pcre/RunTest index 67cfbf07cf9..357a739b75f 100755 --- a/pcre/RunTest +++ b/pcre/RunTest @@ -178,6 +178,7 @@ nojit= sim= skip= valgrind= +vjs= # This is in case the caller has set aliases (as I do - PH) unset cp ls mv rm @@ -357,6 +358,9 @@ $sim ./pcretest -C jit >/dev/null jit=$? if [ $jit -ne 0 -a "$nojit" != "yes" ] ; then jitopt=-s+ + if [ "$valgrind" != "" ] ; then + vjs="--suppressions=$testdata/valgrind-jit.supp" + fi fi # If no specific tests were requested, select all. Those that are not @@ -423,7 +427,7 @@ for bmode in "$test8" "$test16" "$test32"; do if [ $do1 = yes ] ; then echo $title1 for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput1 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput1 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput1 testtry if [ $? != 0 ] ; then exit 1; fi @@ -441,7 +445,7 @@ fi if [ $do2 = yes ] ; then echo $title2 "(not UTF-$bits)" for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput2 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput2 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput2 testtry if [ $? != 0 ] ; then exit 1; fi @@ -504,7 +508,7 @@ if [ $do3 = yes ] ; then if [ "$locale" != "" ] ; then echo $title3 "(using '$locale' locale)" for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $infile testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $infile testtry if [ $? = 0 ] ; then if $cf $outfile testtry >teststdout || \ $cf $outfile2 testtry >teststdout || \ @@ -540,7 +544,7 @@ if [ $do4 = yes ] ; then echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput4 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput4 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput4 testtry if [ $? != 0 ] ; then exit 1; fi @@ -560,7 +564,7 @@ if [ $do5 = yes ] ; then echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput5 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput5 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput5 testtry if [ $? != 0 ] ; then exit 1; fi @@ -580,7 +584,7 @@ if [ $do6 = yes ] ; then echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput6 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput6 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput6 testtry if [ $? != 0 ] ; then exit 1; fi @@ -602,7 +606,7 @@ if [ $do7 = yes ] ; then echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput7 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput7 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput7 testtry if [ $? != 0 ] ; then exit 1; fi @@ -698,7 +702,7 @@ if [ $do12 = yes ] ; then if [ $jit -eq 0 -o "$nojit" = "yes" ] ; then echo " Skipped because JIT is not available or not usable" else - $sim $valgrind ./pcretest -q $bmode $testdata/testinput12 testtry + $sim $valgrind $vjs ./pcretest -q $bmode $testdata/testinput12 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput12 testtry if [ $? != 0 ] ; then exit 1; fi @@ -735,7 +739,7 @@ if [ "$do14" = yes ] ; then cp -f $testdata/saved16 testsaved16 cp -f $testdata/saved32 testsaved32 for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput14 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput14 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput14 testtry if [ $? != 0 ] ; then exit 1; fi @@ -759,7 +763,7 @@ if [ "$do15" = yes ] ; then echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput15 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput15 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput15 testtry if [ $? != 0 ] ; then exit 1; fi @@ -783,7 +787,7 @@ if [ $do16 = yes ] ; then echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput16 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput16 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput16 testtry if [ $? != 0 ] ; then exit 1; fi @@ -805,7 +809,7 @@ if [ $do17 = yes ] ; then echo " Skipped when running 8-bit tests" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput17 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput17 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput17 testtry if [ $? != 0 ] ; then exit 1; fi @@ -829,7 +833,7 @@ if [ $do18 = yes ] ; then echo " Skipped because UTF-$bits support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput18 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput18 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput18-$bits testtry if [ $? != 0 ] ; then exit 1; fi @@ -853,7 +857,7 @@ if [ $do19 = yes ] ; then echo " Skipped because Unicode property support is not available" else for opt in "" "-s" $jitopt; do - $sim $valgrind ./pcretest -q $bmode $opt $testdata/testinput19 testtry + $sim $valgrind ${opt:+$vjs} ./pcretest -q $bmode $opt $testdata/testinput19 testtry if [ $? = 0 ] ; then $cf $testdata/testoutput19 testtry if [ $? != 0 ] ; then exit 1; fi diff --git a/pcre/configure.ac b/pcre/configure.ac index 9ebe598746c..3cefaf100f9 100644 --- a/pcre/configure.ac +++ b/pcre/configure.ac @@ -9,18 +9,18 @@ dnl The PCRE_PRERELEASE feature is for identifying release candidates. It might dnl be defined as -RC2, for example. For real releases, it should be empty. m4_define(pcre_major, [8]) -m4_define(pcre_minor, [38]) +m4_define(pcre_minor, [39]) m4_define(pcre_prerelease, []) -m4_define(pcre_date, [2015-11-23]) +m4_define(pcre_date, [2016-06-14]) # NOTE: The CMakeLists.txt file searches for the above variables in the first # 50 lines of this file. Please update that if the variables above are moved. # Libtool shared library interface versions (current:revision:age) -m4_define(libpcre_version, [3:6:2]) -m4_define(libpcre16_version, [2:6:2]) -m4_define(libpcre32_version, [0:6:0]) -m4_define(libpcreposix_version, [0:3:0]) +m4_define(libpcre_version, [3:7:2]) +m4_define(libpcre16_version, [2:7:2]) +m4_define(libpcre32_version, [0:7:0]) +m4_define(libpcreposix_version, [0:4:0]) m4_define(libpcrecpp_version, [0:1:0]) AC_PREREQ(2.57) diff --git a/pcre/doc/html/pcreapi.html b/pcre/doc/html/pcreapi.html index b401ecc76df..2d7adf185a6 100644 --- a/pcre/doc/html/pcreapi.html +++ b/pcre/doc/html/pcreapi.html @@ -315,9 +315,8 @@ documentation for details of how to do this. It is a non-standard way of building PCRE, for use in environments that have limited stacks. Because of the greater use of memory management, it runs more slowly. Separate functions are provided so that special-purpose external code can be used for this case. When -used, these functions are always called in a stack-like manner (last obtained, -first freed), and always for memory blocks of the same size. There is a -discussion about PCRE's stack usage in the +used, these functions always allocate memory blocks of the same size. There is +a discussion about PCRE's stack usage in the pcrestack documentation.

@@ -2913,9 +2912,9 @@ Cambridge CB2 3QH, England.


REVISION

-Last updated: 09 February 2014 +Last updated: 18 December 2015
-Copyright © 1997-2014 University of Cambridge. +Copyright © 1997-2015 University of Cambridge.

Return to the PCRE index page. diff --git a/pcre/doc/pcre.txt b/pcre/doc/pcre.txt index 76a47c79eff..f5eb347e18a 100644 --- a/pcre/doc/pcre.txt +++ b/pcre/doc/pcre.txt @@ -1814,84 +1814,83 @@ PCRE API OVERVIEW ments that have limited stacks. Because of the greater use of memory management, it runs more slowly. Separate functions are provided so that special-purpose external code can be used for this case. When - used, these functions are always called in a stack-like manner (last - obtained, first freed), and always for memory blocks of the same size. - There is a discussion about PCRE's stack usage in the pcrestack docu- + used, these functions always allocate memory blocks of the same size. + There is a discussion about PCRE's stack usage in the pcrestack docu- mentation. The global variable pcre_callout initially contains NULL. It can be set - by the caller to a "callout" function, which PCRE will then call at - specified points during a matching operation. Details are given in the + by the caller to a "callout" function, which PCRE will then call at + specified points during a matching operation. Details are given in the pcrecallout documentation. The global variable pcre_stack_guard initially contains NULL. It can be - set by the caller to a function that is called by PCRE whenever it - starts to compile a parenthesized part of a pattern. When parentheses + set by the caller to a function that is called by PCRE whenever it + starts to compile a parenthesized part of a pattern. When parentheses are nested, PCRE uses recursive function calls, which use up the system - stack. This function is provided so that applications with restricted - stacks can force a compilation error if the stack runs out. The func- + stack. This function is provided so that applications with restricted + stacks can force a compilation error if the stack runs out. The func- tion should return zero if all is well, or non-zero to force an error. NEWLINES - PCRE supports five different conventions for indicating line breaks in - strings: a single CR (carriage return) character, a single LF (line- + PCRE supports five different conventions for indicating line breaks in + strings: a single CR (carriage return) character, a single LF (line- feed) character, the two-character sequence CRLF, any of the three pre- - ceding, or any Unicode newline sequence. The Unicode newline sequences - are the three just mentioned, plus the single characters VT (vertical + ceding, or any Unicode newline sequence. The Unicode newline sequences + are the three just mentioned, plus the single characters VT (vertical tab, U+000B), FF (form feed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS (paragraph separator, U+2029). - Each of the first three conventions is used by at least one operating - system as its standard newline sequence. When PCRE is built, a default - can be specified. The default default is LF, which is the Unix stan- - dard. When PCRE is run, the default can be overridden, either when a + Each of the first three conventions is used by at least one operating + system as its standard newline sequence. When PCRE is built, a default + can be specified. The default default is LF, which is the Unix stan- + dard. When PCRE is run, the default can be overridden, either when a pattern is compiled, or when it is matched. At compile time, the newline convention can be specified by the options - argument of pcre_compile(), or it can be specified by special text at + argument of pcre_compile(), or it can be specified by special text at the start of the pattern itself; this overrides any other settings. See the pcrepattern page for details of the special character sequences. In the PCRE documentation the word "newline" is used to mean "the char- - acter or pair of characters that indicate a line break". The choice of - newline convention affects the handling of the dot, circumflex, and + acter or pair of characters that indicate a line break". The choice of + newline convention affects the handling of the dot, circumflex, and dollar metacharacters, the handling of #-comments in /x mode, and, when - CRLF is a recognized line ending sequence, the match position advance- + CRLF is a recognized line ending sequence, the match position advance- ment for a non-anchored pattern. There is more detail about this in the section on pcre_exec() options below. - The choice of newline convention does not affect the interpretation of - the \n or \r escape sequences, nor does it affect what \R matches, + The choice of newline convention does not affect the interpretation of + the \n or \r escape sequences, nor does it affect what \R matches, which is controlled in a similar way, but by separate options. MULTITHREADING - The PCRE functions can be used in multi-threading applications, with + The PCRE functions can be used in multi-threading applications, with the proviso that the memory management functions pointed to by pcre_malloc, pcre_free, pcre_stack_malloc, and pcre_stack_free, and the - callout and stack-checking functions pointed to by pcre_callout and + callout and stack-checking functions pointed to by pcre_callout and pcre_stack_guard, are shared by all threads. - The compiled form of a regular expression is not altered during match- + The compiled form of a regular expression is not altered during match- ing, so the same compiled pattern can safely be used by several threads at once. - If the just-in-time optimization feature is being used, it needs sepa- - rate memory stack areas for each thread. See the pcrejit documentation + If the just-in-time optimization feature is being used, it needs sepa- + rate memory stack areas for each thread. See the pcrejit documentation for more details. SAVING PRECOMPILED PATTERNS FOR LATER USE The compiled form of a regular expression can be saved and re-used at a - later time, possibly by a different program, and even on a host other - than the one on which it was compiled. Details are given in the - pcreprecompile documentation, which includes a description of the - pcre_pattern_to_host_byte_order() function. However, compiling a regu- - lar expression with one version of PCRE for use with a different ver- + later time, possibly by a different program, and even on a host other + than the one on which it was compiled. Details are given in the + pcreprecompile documentation, which includes a description of the + pcre_pattern_to_host_byte_order() function. However, compiling a regu- + lar expression with one version of PCRE for use with a different ver- sion is not guaranteed to work and may cause crashes. @@ -1899,45 +1898,45 @@ CHECKING BUILD-TIME OPTIONS int pcre_config(int what, void *where); - The function pcre_config() makes it possible for a PCRE client to dis- + The function pcre_config() makes it possible for a PCRE client to dis- cover which optional features have been compiled into the PCRE library. - The pcrebuild documentation has more details about these optional fea- + The pcrebuild documentation has more details about these optional fea- tures. - The first argument for pcre_config() is an integer, specifying which + The first argument for pcre_config() is an integer, specifying which information is required; the second argument is a pointer to a variable - into which the information is placed. The returned value is zero on - success, or the negative error code PCRE_ERROR_BADOPTION if the value - in the first argument is not recognized. The following information is + into which the information is placed. The returned value is zero on + success, or the negative error code PCRE_ERROR_BADOPTION if the value + in the first argument is not recognized. The following information is available: PCRE_CONFIG_UTF8 - The output is an integer that is set to one if UTF-8 support is avail- - able; otherwise it is set to zero. This value should normally be given + The output is an integer that is set to one if UTF-8 support is avail- + able; otherwise it is set to zero. This value should normally be given to the 8-bit version of this function, pcre_config(). If it is given to - the 16-bit or 32-bit version of this function, the result is + the 16-bit or 32-bit version of this function, the result is PCRE_ERROR_BADOPTION. PCRE_CONFIG_UTF16 The output is an integer that is set to one if UTF-16 support is avail- - able; otherwise it is set to zero. This value should normally be given + able; otherwise it is set to zero. This value should normally be given to the 16-bit version of this function, pcre16_config(). If it is given - to the 8-bit or 32-bit version of this function, the result is + to the 8-bit or 32-bit version of this function, the result is PCRE_ERROR_BADOPTION. PCRE_CONFIG_UTF32 The output is an integer that is set to one if UTF-32 support is avail- - able; otherwise it is set to zero. This value should normally be given + able; otherwise it is set to zero. This value should normally be given to the 32-bit version of this function, pcre32_config(). If it is given - to the 8-bit or 16-bit version of this function, the result is + to the 8-bit or 16-bit version of this function, the result is PCRE_ERROR_BADOPTION. PCRE_CONFIG_UNICODE_PROPERTIES - The output is an integer that is set to one if support for Unicode + The output is an integer that is set to one if support for Unicode character properties is available; otherwise it is set to zero. PCRE_CONFIG_JIT @@ -1947,80 +1946,80 @@ CHECKING BUILD-TIME OPTIONS PCRE_CONFIG_JITTARGET - The output is a pointer to a zero-terminated "const char *" string. If + The output is a pointer to a zero-terminated "const char *" string. If JIT support is available, the string contains the name of the architec- - ture for which the JIT compiler is configured, for example "x86 32bit - (little endian + unaligned)". If JIT support is not available, the + ture for which the JIT compiler is configured, for example "x86 32bit + (little endian + unaligned)". If JIT support is not available, the result is NULL. PCRE_CONFIG_NEWLINE - The output is an integer whose value specifies the default character - sequence that is recognized as meaning "newline". The values that are + The output is an integer whose value specifies the default character + sequence that is recognized as meaning "newline". The values that are supported in ASCII/Unicode environments are: 10 for LF, 13 for CR, 3338 - for CRLF, -2 for ANYCRLF, and -1 for ANY. In EBCDIC environments, CR, - ANYCRLF, and ANY yield the same values. However, the value for LF is - normally 21, though some EBCDIC environments use 37. The corresponding - values for CRLF are 3349 and 3365. The default should normally corre- + for CRLF, -2 for ANYCRLF, and -1 for ANY. In EBCDIC environments, CR, + ANYCRLF, and ANY yield the same values. However, the value for LF is + normally 21, though some EBCDIC environments use 37. The corresponding + values for CRLF are 3349 and 3365. The default should normally corre- spond to the standard sequence for your operating system. PCRE_CONFIG_BSR The output is an integer whose value indicates what character sequences - the \R escape sequence matches by default. A value of 0 means that \R - matches any Unicode line ending sequence; a value of 1 means that \R + the \R escape sequence matches by default. A value of 0 means that \R + matches any Unicode line ending sequence; a value of 1 means that \R matches only CR, LF, or CRLF. The default can be overridden when a pat- tern is compiled or matched. PCRE_CONFIG_LINK_SIZE - The output is an integer that contains the number of bytes used for + The output is an integer that contains the number of bytes used for internal linkage in compiled regular expressions. For the 8-bit library, the value can be 2, 3, or 4. For the 16-bit library, the value - is either 2 or 4 and is still a number of bytes. For the 32-bit + is either 2 or 4 and is still a number of bytes. For the 32-bit library, the value is either 2 or 4 and is still a number of bytes. The default value of 2 is sufficient for all but the most massive patterns, - since it allows the compiled pattern to be up to 64K in size. Larger - values allow larger regular expressions to be compiled, at the expense + since it allows the compiled pattern to be up to 64K in size. Larger + values allow larger regular expressions to be compiled, at the expense of slower matching. PCRE_CONFIG_POSIX_MALLOC_THRESHOLD - The output is an integer that contains the threshold above which the - POSIX interface uses malloc() for output vectors. Further details are + The output is an integer that contains the threshold above which the + POSIX interface uses malloc() for output vectors. Further details are given in the pcreposix documentation. PCRE_CONFIG_PARENS_LIMIT The output is a long integer that gives the maximum depth of nesting of - parentheses (of any kind) in a pattern. This limit is imposed to cap + parentheses (of any kind) in a pattern. This limit is imposed to cap the amount of system stack used when a pattern is compiled. It is spec- - ified when PCRE is built; the default is 250. This limit does not take + ified when PCRE is built; the default is 250. This limit does not take into account the stack that may already be used by the calling applica- - tion. For finer control over compilation stack usage, you can set a + tion. For finer control over compilation stack usage, you can set a pointer to an external checking function in pcre_stack_guard. PCRE_CONFIG_MATCH_LIMIT - The output is a long integer that gives the default limit for the num- - ber of internal matching function calls in a pcre_exec() execution. + The output is a long integer that gives the default limit for the num- + ber of internal matching function calls in a pcre_exec() execution. Further details are given with pcre_exec() below. PCRE_CONFIG_MATCH_LIMIT_RECURSION The output is a long integer that gives the default limit for the depth - of recursion when calling the internal matching function in a - pcre_exec() execution. Further details are given with pcre_exec() + of recursion when calling the internal matching function in a + pcre_exec() execution. Further details are given with pcre_exec() below. PCRE_CONFIG_STACKRECURSE - The output is an integer that is set to one if internal recursion when + The output is an integer that is set to one if internal recursion when running pcre_exec() is implemented by recursive function calls that use - the stack to remember their state. This is the usual way that PCRE is + the stack to remember their state. This is the usual way that PCRE is compiled. The output is zero if PCRE was compiled to use blocks of data - on the heap instead of recursive function calls. In this case, - pcre_stack_malloc and pcre_stack_free are called to manage memory + on the heap instead of recursive function calls. In this case, + pcre_stack_malloc and pcre_stack_free are called to manage memory blocks on the heap, thus avoiding the use of the stack. @@ -2037,67 +2036,67 @@ COMPILING A PATTERN Either of the functions pcre_compile() or pcre_compile2() can be called to compile a pattern into an internal form. The only difference between - the two interfaces is that pcre_compile2() has an additional argument, - errorcodeptr, via which a numerical error code can be returned. To - avoid too much repetition, we refer just to pcre_compile() below, but + the two interfaces is that pcre_compile2() has an additional argument, + errorcodeptr, via which a numerical error code can be returned. To + avoid too much repetition, we refer just to pcre_compile() below, but the information applies equally to pcre_compile2(). The pattern is a C string terminated by a binary zero, and is passed in - the pattern argument. A pointer to a single block of memory that is - obtained via pcre_malloc is returned. This contains the compiled code + the pattern argument. A pointer to a single block of memory that is + obtained via pcre_malloc is returned. This contains the compiled code and related data. The pcre type is defined for the returned block; this is a typedef for a structure whose contents are not externally defined. It is up to the caller to free the memory (via pcre_free) when it is no longer required. - Although the compiled code of a PCRE regex is relocatable, that is, it + Although the compiled code of a PCRE regex is relocatable, that is, it does not depend on memory location, the complete pcre data block is not - fully relocatable, because it may contain a copy of the tableptr argu- + fully relocatable, because it may contain a copy of the tableptr argu- ment, which is an address (see below). The options argument contains various bit settings that affect the com- - pilation. It should be zero if no options are required. The available - options are described below. Some of them (in particular, those that - are compatible with Perl, but some others as well) can also be set and - unset from within the pattern (see the detailed description in the - pcrepattern documentation). For those options that can be different in - different parts of the pattern, the contents of the options argument + pilation. It should be zero if no options are required. The available + options are described below. Some of them (in particular, those that + are compatible with Perl, but some others as well) can also be set and + unset from within the pattern (see the detailed description in the + pcrepattern documentation). For those options that can be different in + different parts of the pattern, the contents of the options argument specifies their settings at the start of compilation and execution. The - PCRE_ANCHORED, PCRE_BSR_xxx, PCRE_NEWLINE_xxx, PCRE_NO_UTF8_CHECK, and - PCRE_NO_START_OPTIMIZE options can be set at the time of matching as + PCRE_ANCHORED, PCRE_BSR_xxx, PCRE_NEWLINE_xxx, PCRE_NO_UTF8_CHECK, and + PCRE_NO_START_OPTIMIZE options can be set at the time of matching as well as at compile time. If errptr is NULL, pcre_compile() returns NULL immediately. Otherwise, - if compilation of a pattern fails, pcre_compile() returns NULL, and + if compilation of a pattern fails, pcre_compile() returns NULL, and sets the variable pointed to by errptr to point to a textual error mes- sage. This is a static string that is part of the library. You must not - try to free it. Normally, the offset from the start of the pattern to + try to free it. Normally, the offset from the start of the pattern to the data unit that was being processed when the error was discovered is - placed in the variable pointed to by erroffset, which must not be NULL - (if it is, an immediate error is given). However, for an invalid UTF-8 - or UTF-16 string, the offset is that of the first data unit of the + placed in the variable pointed to by erroffset, which must not be NULL + (if it is, an immediate error is given). However, for an invalid UTF-8 + or UTF-16 string, the offset is that of the first data unit of the failing character. - Some errors are not detected until the whole pattern has been scanned; - in these cases, the offset passed back is the length of the pattern. - Note that the offset is in data units, not characters, even in a UTF + Some errors are not detected until the whole pattern has been scanned; + in these cases, the offset passed back is the length of the pattern. + Note that the offset is in data units, not characters, even in a UTF mode. It may sometimes point into the middle of a UTF-8 or UTF-16 char- acter. - If pcre_compile2() is used instead of pcre_compile(), and the error- - codeptr argument is not NULL, a non-zero error code number is returned - via this argument in the event of an error. This is in addition to the + If pcre_compile2() is used instead of pcre_compile(), and the error- + codeptr argument is not NULL, a non-zero error code number is returned + via this argument in the event of an error. This is in addition to the textual error message. Error codes and messages are listed below. - If the final argument, tableptr, is NULL, PCRE uses a default set of - character tables that are built when PCRE is compiled, using the - default C locale. Otherwise, tableptr must be an address that is the - result of a call to pcre_maketables(). This value is stored with the - compiled pattern, and used again by pcre_exec() and pcre_dfa_exec() - when the pattern is matched. For more discussion, see the section on + If the final argument, tableptr, is NULL, PCRE uses a default set of + character tables that are built when PCRE is compiled, using the + default C locale. Otherwise, tableptr must be an address that is the + result of a call to pcre_maketables(). This value is stored with the + compiled pattern, and used again by pcre_exec() and pcre_dfa_exec() + when the pattern is matched. For more discussion, see the section on locale support below. - This code fragment shows a typical straightforward call to pcre_com- + This code fragment shows a typical straightforward call to pcre_com- pile(): pcre *re; @@ -2110,181 +2109,181 @@ COMPILING A PATTERN &erroffset, /* for error offset */ NULL); /* use default character tables */ - The following names for option bits are defined in the pcre.h header + The following names for option bits are defined in the pcre.h header file: PCRE_ANCHORED If this bit is set, the pattern is forced to be "anchored", that is, it - is constrained to match only at the first matching point in the string - that is being searched (the "subject string"). This effect can also be - achieved by appropriate constructs in the pattern itself, which is the + is constrained to match only at the first matching point in the string + that is being searched (the "subject string"). This effect can also be + achieved by appropriate constructs in the pattern itself, which is the only way to do it in Perl. PCRE_AUTO_CALLOUT If this bit is set, pcre_compile() automatically inserts callout items, - all with number 255, before each pattern item. For discussion of the + all with number 255, before each pattern item. For discussion of the callout facility, see the pcrecallout documentation. PCRE_BSR_ANYCRLF PCRE_BSR_UNICODE These options (which are mutually exclusive) control what the \R escape - sequence matches. The choice is either to match only CR, LF, or CRLF, + sequence matches. The choice is either to match only CR, LF, or CRLF, or to match any Unicode newline sequence. The default is specified when PCRE is built. It can be overridden from within the pattern, or by set- ting an option when a compiled pattern is matched. PCRE_CASELESS - If this bit is set, letters in the pattern match both upper and lower - case letters. It is equivalent to Perl's /i option, and it can be - changed within a pattern by a (?i) option setting. In UTF-8 mode, PCRE - always understands the concept of case for characters whose values are - less than 128, so caseless matching is always possible. For characters - with higher values, the concept of case is supported if PCRE is com- - piled with Unicode property support, but not otherwise. If you want to - use caseless matching for characters 128 and above, you must ensure - that PCRE is compiled with Unicode property support as well as with + If this bit is set, letters in the pattern match both upper and lower + case letters. It is equivalent to Perl's /i option, and it can be + changed within a pattern by a (?i) option setting. In UTF-8 mode, PCRE + always understands the concept of case for characters whose values are + less than 128, so caseless matching is always possible. For characters + with higher values, the concept of case is supported if PCRE is com- + piled with Unicode property support, but not otherwise. If you want to + use caseless matching for characters 128 and above, you must ensure + that PCRE is compiled with Unicode property support as well as with UTF-8 support. PCRE_DOLLAR_ENDONLY - If this bit is set, a dollar metacharacter in the pattern matches only - at the end of the subject string. Without this option, a dollar also - matches immediately before a newline at the end of the string (but not - before any other newlines). The PCRE_DOLLAR_ENDONLY option is ignored - if PCRE_MULTILINE is set. There is no equivalent to this option in + If this bit is set, a dollar metacharacter in the pattern matches only + at the end of the subject string. Without this option, a dollar also + matches immediately before a newline at the end of the string (but not + before any other newlines). The PCRE_DOLLAR_ENDONLY option is ignored + if PCRE_MULTILINE is set. There is no equivalent to this option in Perl, and no way to set it within a pattern. PCRE_DOTALL - If this bit is set, a dot metacharacter in the pattern matches a char- + If this bit is set, a dot metacharacter in the pattern matches a char- acter of any value, including one that indicates a newline. However, it - only ever matches one character, even if newlines are coded as CRLF. - Without this option, a dot does not match when the current position is + only ever matches one character, even if newlines are coded as CRLF. + Without this option, a dot does not match when the current position is at a newline. This option is equivalent to Perl's /s option, and it can - be changed within a pattern by a (?s) option setting. A negative class + be changed within a pattern by a (?s) option setting. A negative class such as [^a] always matches newline characters, independent of the set- ting of this option. PCRE_DUPNAMES - If this bit is set, names used to identify capturing subpatterns need + If this bit is set, names used to identify capturing subpatterns need not be unique. This can be helpful for certain types of pattern when it - is known that only one instance of the named subpattern can ever be - matched. There are more details of named subpatterns below; see also + is known that only one instance of the named subpattern can ever be + matched. There are more details of named subpatterns below; see also the pcrepattern documentation. PCRE_EXTENDED - If this bit is set, most white space characters in the pattern are - totally ignored except when escaped or inside a character class. How- - ever, white space is not allowed within sequences such as (?> that - introduce various parenthesized subpatterns, nor within a numerical - quantifier such as {1,3}. However, ignorable white space is permitted + If this bit is set, most white space characters in the pattern are + totally ignored except when escaped or inside a character class. How- + ever, white space is not allowed within sequences such as (?> that + introduce various parenthesized subpatterns, nor within a numerical + quantifier such as {1,3}. However, ignorable white space is permitted between an item and a following quantifier and between a quantifier and a following + that indicates possessiveness. White space did not used to include the VT character (code 11), because Perl did not treat this character as white space. However, Perl changed - at release 5.18, so PCRE followed at release 8.34, and VT is now + at release 5.18, so PCRE followed at release 8.34, and VT is now treated as white space. - PCRE_EXTENDED also causes characters between an unescaped # outside a - character class and the next newline, inclusive, to be ignored. - PCRE_EXTENDED is equivalent to Perl's /x option, and it can be changed + PCRE_EXTENDED also causes characters between an unescaped # outside a + character class and the next newline, inclusive, to be ignored. + PCRE_EXTENDED is equivalent to Perl's /x option, and it can be changed within a pattern by a (?x) option setting. - Which characters are interpreted as newlines is controlled by the - options passed to pcre_compile() or by a special sequence at the start - of the pattern, as described in the section entitled "Newline conven- + Which characters are interpreted as newlines is controlled by the + options passed to pcre_compile() or by a special sequence at the start + of the pattern, as described in the section entitled "Newline conven- tions" in the pcrepattern documentation. Note that the end of this type - of comment is a literal newline sequence in the pattern; escape + of comment is a literal newline sequence in the pattern; escape sequences that happen to represent a newline do not count. - This option makes it possible to include comments inside complicated - patterns. Note, however, that this applies only to data characters. - White space characters may never appear within special character + This option makes it possible to include comments inside complicated + patterns. Note, however, that this applies only to data characters. + White space characters may never appear within special character sequences in a pattern, for example within the sequence (?( that intro- duces a conditional subpattern. PCRE_EXTRA - This option was invented in order to turn on additional functionality - of PCRE that is incompatible with Perl, but it is currently of very - little use. When set, any backslash in a pattern that is followed by a - letter that has no special meaning causes an error, thus reserving - these combinations for future expansion. By default, as in Perl, a - backslash followed by a letter with no special meaning is treated as a + This option was invented in order to turn on additional functionality + of PCRE that is incompatible with Perl, but it is currently of very + little use. When set, any backslash in a pattern that is followed by a + letter that has no special meaning causes an error, thus reserving + these combinations for future expansion. By default, as in Perl, a + backslash followed by a letter with no special meaning is treated as a literal. (Perl can, however, be persuaded to give an error for this, by - running it with the -w option.) There are at present no other features - controlled by this option. It can also be set by a (?X) option setting + running it with the -w option.) There are at present no other features + controlled by this option. It can also be set by a (?X) option setting within a pattern. PCRE_FIRSTLINE - If this option is set, an unanchored pattern is required to match - before or at the first newline in the subject string, though the + If this option is set, an unanchored pattern is required to match + before or at the first newline in the subject string, though the matched text may continue over the newline. PCRE_JAVASCRIPT_COMPAT If this option is set, PCRE's behaviour is changed in some ways so that - it is compatible with JavaScript rather than Perl. The changes are as + it is compatible with JavaScript rather than Perl. The changes are as follows: - (1) A lone closing square bracket in a pattern causes a compile-time - error, because this is illegal in JavaScript (by default it is treated + (1) A lone closing square bracket in a pattern causes a compile-time + error, because this is illegal in JavaScript (by default it is treated as a data character). Thus, the pattern AB]CD becomes illegal when this option is set. - (2) At run time, a back reference to an unset subpattern group matches - an empty string (by default this causes the current matching alterna- - tive to fail). A pattern such as (\1)(a) succeeds when this option is - set (assuming it can find an "a" in the subject), whereas it fails by + (2) At run time, a back reference to an unset subpattern group matches + an empty string (by default this causes the current matching alterna- + tive to fail). A pattern such as (\1)(a) succeeds when this option is + set (assuming it can find an "a" in the subject), whereas it fails by default, for Perl compatibility. (3) \U matches an upper case "U" character; by default \U causes a com- pile time error (Perl uses \U to upper case subsequent characters). (4) \u matches a lower case "u" character unless it is followed by four - hexadecimal digits, in which case the hexadecimal number defines the - code point to match. By default, \u causes a compile time error (Perl + hexadecimal digits, in which case the hexadecimal number defines the + code point to match. By default, \u causes a compile time error (Perl uses it to upper case the following character). - (5) \x matches a lower case "x" character unless it is followed by two - hexadecimal digits, in which case the hexadecimal number defines the - code point to match. By default, as in Perl, a hexadecimal number is + (5) \x matches a lower case "x" character unless it is followed by two + hexadecimal digits, in which case the hexadecimal number defines the + code point to match. By default, as in Perl, a hexadecimal number is always expected after \x, but it may have zero, one, or two digits (so, for example, \xz matches a binary zero character followed by z). PCRE_MULTILINE - By default, for the purposes of matching "start of line" and "end of + By default, for the purposes of matching "start of line" and "end of line", PCRE treats the subject string as consisting of a single line of - characters, even if it actually contains newlines. The "start of line" + characters, even if it actually contains newlines. The "start of line" metacharacter (^) matches only at the start of the string, and the "end - of line" metacharacter ($) matches only at the end of the string, or - before a terminating newline (except when PCRE_DOLLAR_ENDONLY is set). - Note, however, that unless PCRE_DOTALL is set, the "any character" - metacharacter (.) does not match at a newline. This behaviour (for ^, + of line" metacharacter ($) matches only at the end of the string, or + before a terminating newline (except when PCRE_DOLLAR_ENDONLY is set). + Note, however, that unless PCRE_DOTALL is set, the "any character" + metacharacter (.) does not match at a newline. This behaviour (for ^, $, and dot) is the same as Perl. - When PCRE_MULTILINE it is set, the "start of line" and "end of line" - constructs match immediately following or immediately before internal - newlines in the subject string, respectively, as well as at the very - start and end. This is equivalent to Perl's /m option, and it can be + When PCRE_MULTILINE it is set, the "start of line" and "end of line" + constructs match immediately following or immediately before internal + newlines in the subject string, respectively, as well as at the very + start and end. This is equivalent to Perl's /m option, and it can be changed within a pattern by a (?m) option setting. If there are no new- - lines in a subject string, or no occurrences of ^ or $ in a pattern, + lines in a subject string, or no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect. PCRE_NEVER_UTF This option locks out interpretation of the pattern as UTF-8 (or UTF-16 - or UTF-32 in the 16-bit and 32-bit libraries). In particular, it pre- - vents the creator of the pattern from switching to UTF interpretation + or UTF-32 in the 16-bit and 32-bit libraries). In particular, it pre- + vents the creator of the pattern from switching to UTF interpretation by starting the pattern with (*UTF). This may be useful in applications that process patterns from external sources. The combination of PCRE_UTF8 and PCRE_NEVER_UTF also causes an error. @@ -2295,41 +2294,41 @@ COMPILING A PATTERN PCRE_NEWLINE_ANYCRLF PCRE_NEWLINE_ANY - These options override the default newline definition that was chosen - when PCRE was built. Setting the first or the second specifies that a - newline is indicated by a single character (CR or LF, respectively). - Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by the - two-character CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies + These options override the default newline definition that was chosen + when PCRE was built. Setting the first or the second specifies that a + newline is indicated by a single character (CR or LF, respectively). + Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by the + two-character CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three preceding sequences should be recognized. Setting - PCRE_NEWLINE_ANY specifies that any Unicode newline sequence should be + PCRE_NEWLINE_ANY specifies that any Unicode newline sequence should be recognized. - In an ASCII/Unicode environment, the Unicode newline sequences are the - three just mentioned, plus the single characters VT (vertical tab, + In an ASCII/Unicode environment, the Unicode newline sequences are the + three just mentioned, plus the single characters VT (vertical tab, U+000B), FF (form feed, U+000C), NEL (next line, U+0085), LS (line sep- - arator, U+2028), and PS (paragraph separator, U+2029). For the 8-bit + arator, U+2028), and PS (paragraph separator, U+2029). For the 8-bit library, the last two are recognized only in UTF-8 mode. - When PCRE is compiled to run in an EBCDIC (mainframe) environment, the + When PCRE is compiled to run in an EBCDIC (mainframe) environment, the code for CR is 0x0d, the same as ASCII. However, the character code for - LF is normally 0x15, though in some EBCDIC environments 0x25 is used. - Whichever of these is not LF is made to correspond to Unicode's NEL - character. EBCDIC codes are all less than 256. For more details, see + LF is normally 0x15, though in some EBCDIC environments 0x25 is used. + Whichever of these is not LF is made to correspond to Unicode's NEL + character. EBCDIC codes are all less than 256. For more details, see the pcrebuild documentation. - The newline setting in the options word uses three bits that are + The newline setting in the options word uses three bits that are treated as a number, giving eight possibilities. Currently only six are - used (default plus the five values above). This means that if you set - more than one newline option, the combination may or may not be sensi- + used (default plus the five values above). This means that if you set + more than one newline option, the combination may or may not be sensi- ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to - PCRE_NEWLINE_CRLF, but other combinations may yield unused numbers and + PCRE_NEWLINE_CRLF, but other combinations may yield unused numbers and cause an error. - The only time that a line break in a pattern is specially recognized - when compiling is when PCRE_EXTENDED is set. CR and LF are white space - characters, and so are ignored in this mode. Also, an unescaped # out- - side a character class indicates a comment that lasts until after the - next line break sequence. In other circumstances, line break sequences + The only time that a line break in a pattern is specially recognized + when compiling is when PCRE_EXTENDED is set. CR and LF are white space + characters, and so are ignored in this mode. Also, an unescaped # out- + side a character class indicates a comment that lasts until after the + next line break sequence. In other circumstances, line break sequences in patterns are treated as literal data. The newline option that is set at compile time becomes the default that @@ -2338,79 +2337,79 @@ COMPILING A PATTERN PCRE_NO_AUTO_CAPTURE If this option is set, it disables the use of numbered capturing paren- - theses in the pattern. Any opening parenthesis that is not followed by - ? behaves as if it were followed by ?: but named parentheses can still - be used for capturing (and they acquire numbers in the usual way). + theses in the pattern. Any opening parenthesis that is not followed by + ? behaves as if it were followed by ?: but named parentheses can still + be used for capturing (and they acquire numbers in the usual way). There is no equivalent of this option in Perl. PCRE_NO_AUTO_POSSESS - If this option is set, it disables "auto-possessification". This is an - optimization that, for example, turns a+b into a++b in order to avoid - backtracks into a+ that can never be successful. However, if callouts - are in use, auto-possessification means that some of them are never + If this option is set, it disables "auto-possessification". This is an + optimization that, for example, turns a+b into a++b in order to avoid + backtracks into a+ that can never be successful. However, if callouts + are in use, auto-possessification means that some of them are never taken. You can set this option if you want the matching functions to do - a full unoptimized search and run all the callouts, but it is mainly + a full unoptimized search and run all the callouts, but it is mainly provided for testing purposes. PCRE_NO_START_OPTIMIZE - This is an option that acts at matching time; that is, it is really an - option for pcre_exec() or pcre_dfa_exec(). If it is set at compile - time, it is remembered with the compiled pattern and assumed at match- - ing time. This is necessary if you want to use JIT execution, because - the JIT compiler needs to know whether or not this option is set. For + This is an option that acts at matching time; that is, it is really an + option for pcre_exec() or pcre_dfa_exec(). If it is set at compile + time, it is remembered with the compiled pattern and assumed at match- + ing time. This is necessary if you want to use JIT execution, because + the JIT compiler needs to know whether or not this option is set. For details see the discussion of PCRE_NO_START_OPTIMIZE below. PCRE_UCP - This option changes the way PCRE processes \B, \b, \D, \d, \S, \s, \W, - \w, and some of the POSIX character classes. By default, only ASCII - characters are recognized, but if PCRE_UCP is set, Unicode properties - are used instead to classify characters. More details are given in the - section on generic character types in the pcrepattern page. If you set - PCRE_UCP, matching one of the items it affects takes much longer. The - option is available only if PCRE has been compiled with Unicode prop- + This option changes the way PCRE processes \B, \b, \D, \d, \S, \s, \W, + \w, and some of the POSIX character classes. By default, only ASCII + characters are recognized, but if PCRE_UCP is set, Unicode properties + are used instead to classify characters. More details are given in the + section on generic character types in the pcrepattern page. If you set + PCRE_UCP, matching one of the items it affects takes much longer. The + option is available only if PCRE has been compiled with Unicode prop- erty support. PCRE_UNGREEDY - This option inverts the "greediness" of the quantifiers so that they - are not greedy by default, but become greedy if followed by "?". It is - not compatible with Perl. It can also be set by a (?U) option setting + This option inverts the "greediness" of the quantifiers so that they + are not greedy by default, but become greedy if followed by "?". It is + not compatible with Perl. It can also be set by a (?U) option setting within the pattern. PCRE_UTF8 - This option causes PCRE to regard both the pattern and the subject as + This option causes PCRE to regard both the pattern and the subject as strings of UTF-8 characters instead of single-byte strings. However, it - is available only when PCRE is built to include UTF support. If not, - the use of this option provokes an error. Details of how this option + is available only when PCRE is built to include UTF support. If not, + the use of this option provokes an error. Details of how this option changes the behaviour of PCRE are given in the pcreunicode page. PCRE_NO_UTF8_CHECK When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is - automatically checked. There is a discussion about the validity of - UTF-8 strings in the pcreunicode page. If an invalid UTF-8 sequence is - found, pcre_compile() returns an error. If you already know that your - pattern is valid, and you want to skip this check for performance rea- - sons, you can set the PCRE_NO_UTF8_CHECK option. When it is set, the + automatically checked. There is a discussion about the validity of + UTF-8 strings in the pcreunicode page. If an invalid UTF-8 sequence is + found, pcre_compile() returns an error. If you already know that your + pattern is valid, and you want to skip this check for performance rea- + sons, you can set the PCRE_NO_UTF8_CHECK option. When it is set, the effect of passing an invalid UTF-8 string as a pattern is undefined. It may cause your program to crash or loop. Note that this option can also - be passed to pcre_exec() and pcre_dfa_exec(), to suppress the validity - checking of subject strings only. If the same string is being matched - many times, the option can be safely set for the second and subsequent + be passed to pcre_exec() and pcre_dfa_exec(), to suppress the validity + checking of subject strings only. If the same string is being matched + many times, the option can be safely set for the second and subsequent matchings to improve performance. COMPILATION ERROR CODES - The following table lists the error codes than may be returned by - pcre_compile2(), along with the error messages that may be returned by - both compiling functions. Note that error messages are always 8-bit - ASCII strings, even in 16-bit or 32-bit mode. As PCRE has developed, - some error codes have fallen out of use. To avoid confusion, they have + The following table lists the error codes than may be returned by + pcre_compile2(), along with the error messages that may be returned by + both compiling functions. Note that error messages are always 8-bit + ASCII strings, even in 16-bit or 32-bit mode. As PCRE has developed, + some error codes have fallen out of use. To avoid confusion, they have not been re-used. 0 no error @@ -2504,7 +2503,7 @@ COMPILATION ERROR CODES 84 group name must start with a non-digit 85 parentheses are too deeply nested (stack check) - The numbers 32 and 10000 in errors 48 and 49 are defaults; different + The numbers 32 and 10000 in errors 48 and 49 are defaults; different values may be used if the limits were changed when PCRE was built. @@ -2513,64 +2512,64 @@ STUDYING A PATTERN pcre_extra *pcre_study(const pcre *code, int options, const char **errptr); - If a compiled pattern is going to be used several times, it is worth + If a compiled pattern is going to be used several times, it is worth spending more time analyzing it in order to speed up the time taken for - matching. The function pcre_study() takes a pointer to a compiled pat- + matching. The function pcre_study() takes a pointer to a compiled pat- tern as its first argument. If studying the pattern produces additional - information that will help speed up matching, pcre_study() returns a - pointer to a pcre_extra block, in which the study_data field points to + information that will help speed up matching, pcre_study() returns a + pointer to a pcre_extra block, in which the study_data field points to the results of the study. The returned value from pcre_study() can be passed directly to - pcre_exec() or pcre_dfa_exec(). However, a pcre_extra block also con- - tains other fields that can be set by the caller before the block is + pcre_exec() or pcre_dfa_exec(). However, a pcre_extra block also con- + tains other fields that can be set by the caller before the block is passed; these are described below in the section on matching a pattern. - If studying the pattern does not produce any useful information, - pcre_study() returns NULL by default. In that circumstance, if the + If studying the pattern does not produce any useful information, + pcre_study() returns NULL by default. In that circumstance, if the calling program wants to pass any of the other fields to pcre_exec() or - pcre_dfa_exec(), it must set up its own pcre_extra block. However, if - pcre_study() is called with the PCRE_STUDY_EXTRA_NEEDED option, it + pcre_dfa_exec(), it must set up its own pcre_extra block. However, if + pcre_study() is called with the PCRE_STUDY_EXTRA_NEEDED option, it returns a pcre_extra block even if studying did not find any additional - information. It may still return NULL, however, if an error occurs in + information. It may still return NULL, however, if an error occurs in pcre_study(). - The second argument of pcre_study() contains option bits. There are + The second argument of pcre_study() contains option bits. There are three further options in addition to PCRE_STUDY_EXTRA_NEEDED: PCRE_STUDY_JIT_COMPILE PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE - If any of these are set, and the just-in-time compiler is available, - the pattern is further compiled into machine code that executes much - faster than the pcre_exec() interpretive matching function. If the - just-in-time compiler is not available, these options are ignored. All + If any of these are set, and the just-in-time compiler is available, + the pattern is further compiled into machine code that executes much + faster than the pcre_exec() interpretive matching function. If the + just-in-time compiler is not available, these options are ignored. All undefined bits in the options argument must be zero. - JIT compilation is a heavyweight optimization. It can take some time - for patterns to be analyzed, and for one-off matches and simple pat- - terns the benefit of faster execution might be offset by a much slower + JIT compilation is a heavyweight optimization. It can take some time + for patterns to be analyzed, and for one-off matches and simple pat- + terns the benefit of faster execution might be offset by a much slower study time. Not all patterns can be optimized by the JIT compiler. For - those that cannot be handled, matching automatically falls back to the - pcre_exec() interpreter. For more details, see the pcrejit documenta- + those that cannot be handled, matching automatically falls back to the + pcre_exec() interpreter. For more details, see the pcrejit documenta- tion. - The third argument for pcre_study() is a pointer for an error message. - If studying succeeds (even if no data is returned), the variable it - points to is set to NULL. Otherwise it is set to point to a textual + The third argument for pcre_study() is a pointer for an error message. + If studying succeeds (even if no data is returned), the variable it + points to is set to NULL. Otherwise it is set to point to a textual error message. This is a static string that is part of the library. You - must not try to free it. You should test the error pointer for NULL + must not try to free it. You should test the error pointer for NULL after calling pcre_study(), to be sure that it has run successfully. - When you are finished with a pattern, you can free the memory used for + When you are finished with a pattern, you can free the memory used for the study data by calling pcre_free_study(). This function was added to - the API for release 8.20. For earlier versions, the memory could be - freed with pcre_free(), just like the pattern itself. This will still - work in cases where JIT optimization is not used, but it is advisable + the API for release 8.20. For earlier versions, the memory could be + freed with pcre_free(), just like the pattern itself. This will still + work in cases where JIT optimization is not used, but it is advisable to change to the new function when convenient. - This is a typical way in which pcre_study() is used (except that in a + This is a typical way in which pcre_study() is used (except that in a real application there should be tests for errors): int rc; @@ -2590,29 +2589,29 @@ STUDYING A PATTERN Studying a pattern does two things: first, a lower bound for the length of subject string that is needed to match the pattern is computed. This does not mean that there are any strings of that length that match, but - it does guarantee that no shorter strings match. The value is used to + it does guarantee that no shorter strings match. The value is used to avoid wasting time by trying to match strings that are shorter than the - lower bound. You can find out the value in a calling program via the + lower bound. You can find out the value in a calling program via the pcre_fullinfo() function. Studying a pattern is also useful for non-anchored patterns that do not - have a single fixed starting character. A bitmap of possible starting - bytes is created. This speeds up finding a position in the subject at + have a single fixed starting character. A bitmap of possible starting + bytes is created. This speeds up finding a position in the subject at which to start matching. (In 16-bit mode, the bitmap is used for 16-bit - values less than 256. In 32-bit mode, the bitmap is used for 32-bit + values less than 256. In 32-bit mode, the bitmap is used for 32-bit values less than 256.) - These two optimizations apply to both pcre_exec() and pcre_dfa_exec(), - and the information is also used by the JIT compiler. The optimiza- - tions can be disabled by setting the PCRE_NO_START_OPTIMIZE option. - You might want to do this if your pattern contains callouts or (*MARK) - and you want to make use of these facilities in cases where matching + These two optimizations apply to both pcre_exec() and pcre_dfa_exec(), + and the information is also used by the JIT compiler. The optimiza- + tions can be disabled by setting the PCRE_NO_START_OPTIMIZE option. + You might want to do this if your pattern contains callouts or (*MARK) + and you want to make use of these facilities in cases where matching fails. - PCRE_NO_START_OPTIMIZE can be specified at either compile time or exe- - cution time. However, if PCRE_NO_START_OPTIMIZE is passed to + PCRE_NO_START_OPTIMIZE can be specified at either compile time or exe- + cution time. However, if PCRE_NO_START_OPTIMIZE is passed to pcre_exec(), (that is, after any JIT compilation has happened) JIT exe- - cution is disabled. For JIT execution to work with PCRE_NO_START_OPTI- + cution is disabled. For JIT execution to work with PCRE_NO_START_OPTI- MIZE, the option must be set at compile time. There is a longer discussion of PCRE_NO_START_OPTIMIZE below. @@ -2620,65 +2619,65 @@ STUDYING A PATTERN LOCALE SUPPORT - PCRE handles caseless matching, and determines whether characters are - letters, digits, or whatever, by reference to a set of tables, indexed - by character code point. When running in UTF-8 mode, or in the 16- or + PCRE handles caseless matching, and determines whether characters are + letters, digits, or whatever, by reference to a set of tables, indexed + by character code point. When running in UTF-8 mode, or in the 16- or 32-bit libraries, this applies only to characters with code points less - than 256. By default, higher-valued code points never match escapes - such as \w or \d. However, if PCRE is built with Unicode property sup- - port, all characters can be tested with \p and \P, or, alternatively, - the PCRE_UCP option can be set when a pattern is compiled; this causes - \w and friends to use Unicode property support instead of the built-in + than 256. By default, higher-valued code points never match escapes + such as \w or \d. However, if PCRE is built with Unicode property sup- + port, all characters can be tested with \p and \P, or, alternatively, + the PCRE_UCP option can be set when a pattern is compiled; this causes + \w and friends to use Unicode property support instead of the built-in tables. - The use of locales with Unicode is discouraged. If you are handling - characters with code points greater than 128, you should either use + The use of locales with Unicode is discouraged. If you are handling + characters with code points greater than 128, you should either use Unicode support, or use locales, but not try to mix the two. - PCRE contains an internal set of tables that are used when the final - argument of pcre_compile() is NULL. These are sufficient for many + PCRE contains an internal set of tables that are used when the final + argument of pcre_compile() is NULL. These are sufficient for many applications. Normally, the internal tables recognize only ASCII char- acters. However, when PCRE is built, it is possible to cause the inter- nal tables to be rebuilt in the default "C" locale of the local system, which may cause them to be different. - The internal tables can always be overridden by tables supplied by the + The internal tables can always be overridden by tables supplied by the application that calls PCRE. These may be created in a different locale - from the default. As more and more applications change to using Uni- + from the default. As more and more applications change to using Uni- code, the need for this locale support is expected to die away. - External tables are built by calling the pcre_maketables() function, - which has no arguments, in the relevant locale. The result can then be - passed to pcre_compile() as often as necessary. For example, to build - and use tables that are appropriate for the French locale (where - accented characters with values greater than 128 are treated as let- + External tables are built by calling the pcre_maketables() function, + which has no arguments, in the relevant locale. The result can then be + passed to pcre_compile() as often as necessary. For example, to build + and use tables that are appropriate for the French locale (where + accented characters with values greater than 128 are treated as let- ters), the following code could be used: setlocale(LC_CTYPE, "fr_FR"); tables = pcre_maketables(); re = pcre_compile(..., tables); - The locale name "fr_FR" is used on Linux and other Unix-like systems; + The locale name "fr_FR" is used on Linux and other Unix-like systems; if you are using Windows, the name for the French locale is "french". - When pcre_maketables() runs, the tables are built in memory that is - obtained via pcre_malloc. It is the caller's responsibility to ensure - that the memory containing the tables remains available for as long as + When pcre_maketables() runs, the tables are built in memory that is + obtained via pcre_malloc. It is the caller's responsibility to ensure + that the memory containing the tables remains available for as long as it is needed. The pointer that is passed to pcre_compile() is saved with the compiled - pattern, and the same tables are used via this pointer by pcre_study() - and also by pcre_exec() and pcre_dfa_exec(). Thus, for any single pat- + pattern, and the same tables are used via this pointer by pcre_study() + and also by pcre_exec() and pcre_dfa_exec(). Thus, for any single pat- tern, compilation, studying and matching all happen in the same locale, but different patterns can be processed in different locales. - It is possible to pass a table pointer or NULL (indicating the use of + It is possible to pass a table pointer or NULL (indicating the use of the internal tables) to pcre_exec() or pcre_dfa_exec() (see the discus- sion below in the section on matching a pattern). This facility is pro- - vided for use with pre-compiled patterns that have been saved and - reloaded. Character tables are not saved with patterns, so if a non- + vided for use with pre-compiled patterns that have been saved and + reloaded. Character tables are not saved with patterns, so if a non- standard table was used at compile time, it must be provided again when - the reloaded pattern is matched. Attempting to use this facility to + the reloaded pattern is matched. Attempting to use this facility to match a pattern in a different locale from the one in which it was com- piled is likely to lead to anomalous (usually incorrect) results. @@ -2688,15 +2687,15 @@ INFORMATION ABOUT A PATTERN int pcre_fullinfo(const pcre *code, const pcre_extra *extra, int what, void *where); - The pcre_fullinfo() function returns information about a compiled pat- - tern. It replaces the pcre_info() function, which was removed from the + The pcre_fullinfo() function returns information about a compiled pat- + tern. It replaces the pcre_info() function, which was removed from the library at version 8.30, after more than 10 years of obsolescence. - The first argument for pcre_fullinfo() is a pointer to the compiled - pattern. The second argument is the result of pcre_study(), or NULL if - the pattern was not studied. The third argument specifies which piece - of information is required, and the fourth argument is a pointer to a - variable to receive the data. The yield of the function is zero for + The first argument for pcre_fullinfo() is a pointer to the compiled + pattern. The second argument is the result of pcre_study(), or NULL if + the pattern was not studied. The third argument specifies which piece + of information is required, and the fourth argument is a pointer to a + variable to receive the data. The yield of the function is zero for success, or one of the following negative numbers: PCRE_ERROR_NULL the argument code was NULL @@ -2707,10 +2706,10 @@ INFORMATION ABOUT A PATTERN PCRE_ERROR_BADOPTION the value of what was invalid PCRE_ERROR_UNSET the requested field is not set - The "magic number" is placed at the start of each compiled pattern as - an simple check against passing an arbitrary memory pointer. The endi- + The "magic number" is placed at the start of each compiled pattern as + an simple check against passing an arbitrary memory pointer. The endi- anness error can occur if a compiled pattern is saved and reloaded on a - different host. Here is a typical call of pcre_fullinfo(), to obtain + different host. Here is a typical call of pcre_fullinfo(), to obtain the length of the compiled pattern: int rc; @@ -2721,81 +2720,81 @@ INFORMATION ABOUT A PATTERN PCRE_INFO_SIZE, /* what is required */ &length); /* where to put the data */ - The possible values for the third argument are defined in pcre.h, and + The possible values for the third argument are defined in pcre.h, and are as follows: PCRE_INFO_BACKREFMAX - Return the number of the highest back reference in the pattern. The - fourth argument should point to an int variable. Zero is returned if + Return the number of the highest back reference in the pattern. The + fourth argument should point to an int variable. Zero is returned if there are no back references. PCRE_INFO_CAPTURECOUNT - Return the number of capturing subpatterns in the pattern. The fourth + Return the number of capturing subpatterns in the pattern. The fourth argument should point to an int variable. PCRE_INFO_DEFAULT_TABLES - Return a pointer to the internal default character tables within PCRE. - The fourth argument should point to an unsigned char * variable. This + Return a pointer to the internal default character tables within PCRE. + The fourth argument should point to an unsigned char * variable. This information call is provided for internal use by the pcre_study() func- - tion. External callers can cause PCRE to use its internal tables by + tion. External callers can cause PCRE to use its internal tables by passing a NULL table pointer. PCRE_INFO_FIRSTBYTE (deprecated) Return information about the first data unit of any matched string, for - a non-anchored pattern. The name of this option refers to the 8-bit - library, where data units are bytes. The fourth argument should point - to an int variable. Negative values are used for special cases. How- - ever, this means that when the 32-bit library is in non-UTF-32 mode, - the full 32-bit range of characters cannot be returned. For this rea- - son, this value is deprecated; use PCRE_INFO_FIRSTCHARACTERFLAGS and + a non-anchored pattern. The name of this option refers to the 8-bit + library, where data units are bytes. The fourth argument should point + to an int variable. Negative values are used for special cases. How- + ever, this means that when the 32-bit library is in non-UTF-32 mode, + the full 32-bit range of characters cannot be returned. For this rea- + son, this value is deprecated; use PCRE_INFO_FIRSTCHARACTERFLAGS and PCRE_INFO_FIRSTCHARACTER instead. - If there is a fixed first value, for example, the letter "c" from a - pattern such as (cat|cow|coyote), its value is returned. In the 8-bit - library, the value is always less than 256. In the 16-bit library the + If there is a fixed first value, for example, the letter "c" from a + pattern such as (cat|cow|coyote), its value is returned. In the 8-bit + library, the value is always less than 256. In the 16-bit library the value can be up to 0xffff. In the 32-bit library the value can be up to 0x10ffff. If there is no fixed first value, and if either - (a) the pattern was compiled with the PCRE_MULTILINE option, and every + (a) the pattern was compiled with the PCRE_MULTILINE option, and every branch starts with "^", or (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set (if it were set, the pattern would be anchored), - -1 is returned, indicating that the pattern matches only at the start - of a subject string or after any newline within the string. Otherwise + -1 is returned, indicating that the pattern matches only at the start + of a subject string or after any newline within the string. Otherwise -2 is returned. For anchored patterns, -2 is returned. PCRE_INFO_FIRSTCHARACTER - Return the value of the first data unit (non-UTF character) of any - matched string in the situation where PCRE_INFO_FIRSTCHARACTERFLAGS - returns 1; otherwise return 0. The fourth argument should point to an + Return the value of the first data unit (non-UTF character) of any + matched string in the situation where PCRE_INFO_FIRSTCHARACTERFLAGS + returns 1; otherwise return 0. The fourth argument should point to an uint_t variable. - In the 8-bit library, the value is always less than 256. In the 16-bit - library the value can be up to 0xffff. In the 32-bit library in UTF-32 - mode the value can be up to 0x10ffff, and up to 0xffffffff when not + In the 8-bit library, the value is always less than 256. In the 16-bit + library the value can be up to 0xffff. In the 32-bit library in UTF-32 + mode the value can be up to 0x10ffff, and up to 0xffffffff when not using UTF-32 mode. PCRE_INFO_FIRSTCHARACTERFLAGS Return information about the first data unit of any matched string, for - a non-anchored pattern. The fourth argument should point to an int + a non-anchored pattern. The fourth argument should point to an int variable. - If there is a fixed first value, for example, the letter "c" from a - pattern such as (cat|cow|coyote), 1 is returned, and the character - value can be retrieved using PCRE_INFO_FIRSTCHARACTER. If there is no + If there is a fixed first value, for example, the letter "c" from a + pattern such as (cat|cow|coyote), 1 is returned, and the character + value can be retrieved using PCRE_INFO_FIRSTCHARACTER. If there is no fixed first value, and if either - (a) the pattern was compiled with the PCRE_MULTILINE option, and every + (a) the pattern was compiled with the PCRE_MULTILINE option, and every branch starts with "^", or (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not @@ -2807,139 +2806,139 @@ INFORMATION ABOUT A PATTERN PCRE_INFO_FIRSTTABLE - If the pattern was studied, and this resulted in the construction of a - 256-bit table indicating a fixed set of values for the first data unit - in any matching string, a pointer to the table is returned. Otherwise - NULL is returned. The fourth argument should point to an unsigned char + If the pattern was studied, and this resulted in the construction of a + 256-bit table indicating a fixed set of values for the first data unit + in any matching string, a pointer to the table is returned. Otherwise + NULL is returned. The fourth argument should point to an unsigned char * variable. PCRE_INFO_HASCRORLF - Return 1 if the pattern contains any explicit matches for CR or LF - characters, otherwise 0. The fourth argument should point to an int - variable. An explicit match is either a literal CR or LF character, or + Return 1 if the pattern contains any explicit matches for CR or LF + characters, otherwise 0. The fourth argument should point to an int + variable. An explicit match is either a literal CR or LF character, or \r or \n. PCRE_INFO_JCHANGED - Return 1 if the (?J) or (?-J) option setting is used in the pattern, - otherwise 0. The fourth argument should point to an int variable. (?J) + Return 1 if the (?J) or (?-J) option setting is used in the pattern, + otherwise 0. The fourth argument should point to an int variable. (?J) and (?-J) set and unset the local PCRE_DUPNAMES option, respectively. PCRE_INFO_JIT - Return 1 if the pattern was studied with one of the JIT options, and + Return 1 if the pattern was studied with one of the JIT options, and just-in-time compiling was successful. The fourth argument should point - to an int variable. A return value of 0 means that JIT support is not - available in this version of PCRE, or that the pattern was not studied - with a JIT option, or that the JIT compiler could not handle this par- - ticular pattern. See the pcrejit documentation for details of what can + to an int variable. A return value of 0 means that JIT support is not + available in this version of PCRE, or that the pattern was not studied + with a JIT option, or that the JIT compiler could not handle this par- + ticular pattern. See the pcrejit documentation for details of what can and cannot be handled. PCRE_INFO_JITSIZE - If the pattern was successfully studied with a JIT option, return the - size of the JIT compiled code, otherwise return zero. The fourth argu- + If the pattern was successfully studied with a JIT option, return the + size of the JIT compiled code, otherwise return zero. The fourth argu- ment should point to a size_t variable. PCRE_INFO_LASTLITERAL - Return the value of the rightmost literal data unit that must exist in - any matched string, other than at its start, if such a value has been + Return the value of the rightmost literal data unit that must exist in + any matched string, other than at its start, if such a value has been recorded. The fourth argument should point to an int variable. If there is no such value, -1 is returned. For anchored patterns, a last literal - value is recorded only if it follows something of variable length. For + value is recorded only if it follows something of variable length. For example, for the pattern /^a\d+z\d+/ the returned value is "z", but for /^a\dz\d/ the returned value is -1. - Since for the 32-bit library using the non-UTF-32 mode, this function - is unable to return the full 32-bit range of characters, this value is + Since for the 32-bit library using the non-UTF-32 mode, this function + is unable to return the full 32-bit range of characters, this value is deprecated; instead the PCRE_INFO_REQUIREDCHARFLAGS and PCRE_INFO_REQUIREDCHAR values should be used. PCRE_INFO_MATCH_EMPTY - Return 1 if the pattern can match an empty string, otherwise 0. The + Return 1 if the pattern can match an empty string, otherwise 0. The fourth argument should point to an int variable. PCRE_INFO_MATCHLIMIT - If the pattern set a match limit by including an item of the form - (*LIMIT_MATCH=nnnn) at the start, the value is returned. The fourth - argument should point to an unsigned 32-bit integer. If no such value - has been set, the call to pcre_fullinfo() returns the error + If the pattern set a match limit by including an item of the form + (*LIMIT_MATCH=nnnn) at the start, the value is returned. The fourth + argument should point to an unsigned 32-bit integer. If no such value + has been set, the call to pcre_fullinfo() returns the error PCRE_ERROR_UNSET. PCRE_INFO_MAXLOOKBEHIND - Return the number of characters (NB not data units) in the longest - lookbehind assertion in the pattern. This information is useful when - doing multi-segment matching using the partial matching facilities. + Return the number of characters (NB not data units) in the longest + lookbehind assertion in the pattern. This information is useful when + doing multi-segment matching using the partial matching facilities. Note that the simple assertions \b and \B require a one-character look- - behind. \A also registers a one-character lookbehind, though it does - not actually inspect the previous character. This is to ensure that at + behind. \A also registers a one-character lookbehind, though it does + not actually inspect the previous character. This is to ensure that at least one character from the old segment is retained when a new segment is processed. Otherwise, if there are no lookbehinds in the pattern, \A might match incorrectly at the start of a new segment. PCRE_INFO_MINLENGTH - If the pattern was studied and a minimum length for matching subject - strings was computed, its value is returned. Otherwise the returned + If the pattern was studied and a minimum length for matching subject + strings was computed, its value is returned. Otherwise the returned value is -1. The value is a number of characters, which in UTF mode may - be different from the number of data units. The fourth argument should - point to an int variable. A non-negative value is a lower bound to the - length of any matching string. There may not be any strings of that - length that do actually match, but every string that does match is at + be different from the number of data units. The fourth argument should + point to an int variable. A non-negative value is a lower bound to the + length of any matching string. There may not be any strings of that + length that do actually match, but every string that does match is at least that long. PCRE_INFO_NAMECOUNT PCRE_INFO_NAMEENTRYSIZE PCRE_INFO_NAMETABLE - PCRE supports the use of named as well as numbered capturing parenthe- - ses. The names are just an additional way of identifying the parenthe- + PCRE supports the use of named as well as numbered capturing parenthe- + ses. The names are just an additional way of identifying the parenthe- ses, which still acquire numbers. Several convenience functions such as - pcre_get_named_substring() are provided for extracting captured sub- - strings by name. It is also possible to extract the data directly, by - first converting the name to a number in order to access the correct + pcre_get_named_substring() are provided for extracting captured sub- + strings by name. It is also possible to extract the data directly, by + first converting the name to a number in order to access the correct pointers in the output vector (described with pcre_exec() below). To do - the conversion, you need to use the name-to-number map, which is + the conversion, you need to use the name-to-number map, which is described by these three values. The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size - of each entry; both of these return an int value. The entry size - depends on the length of the longest name. PCRE_INFO_NAMETABLE returns + of each entry; both of these return an int value. The entry size + depends on the length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first entry of the table. This is a pointer to char in the 8-bit library, where the first two bytes of each entry are the num- - ber of the capturing parenthesis, most significant byte first. In the - 16-bit library, the pointer points to 16-bit data units, the first of - which contains the parenthesis number. In the 32-bit library, the - pointer points to 32-bit data units, the first of which contains the - parenthesis number. The rest of the entry is the corresponding name, + ber of the capturing parenthesis, most significant byte first. In the + 16-bit library, the pointer points to 16-bit data units, the first of + which contains the parenthesis number. In the 32-bit library, the + pointer points to 32-bit data units, the first of which contains the + parenthesis number. The rest of the entry is the corresponding name, zero terminated. - The names are in alphabetical order. If (?| is used to create multiple - groups with the same number, as described in the section on duplicate + The names are in alphabetical order. If (?| is used to create multiple + groups with the same number, as described in the section on duplicate subpattern numbers in the pcrepattern page, the groups may be given the - same name, but there is only one entry in the table. Different names - for groups of the same number are not permitted. Duplicate names for + same name, but there is only one entry in the table. Different names + for groups of the same number are not permitted. Duplicate names for subpatterns with different numbers are permitted, but only if PCRE_DUP- - NAMES is set. They appear in the table in the order in which they were - found in the pattern. In the absence of (?| this is the order of - increasing number; when (?| is used this is not necessarily the case + NAMES is set. They appear in the table in the order in which they were + found in the pattern. In the absence of (?| this is the order of + increasing number; when (?| is used this is not necessarily the case because later subpatterns may have lower numbers. - As a simple example of the name/number table, consider the following + As a simple example of the name/number table, consider the following pattern after compilation by the 8-bit library (assume PCRE_EXTENDED is set, so white space - including newlines - is ignored): (? (?(\d\d)?\d\d) - (?\d\d) - (?\d\d) ) - There are four named subpatterns, so the table has four entries, and - each entry in the table is eight bytes long. The table is as follows, + There are four named subpatterns, so the table has four entries, and + each entry in the table is eight bytes long. The table is as follows, with non-printing bytes shows in hexadecimal, and undefined bytes shown as ??: @@ -2948,31 +2947,31 @@ INFORMATION ABOUT A PATTERN 00 04 m o n t h 00 00 02 y e a r 00 ?? - When writing code to extract data from named subpatterns using the - name-to-number map, remember that the length of the entries is likely + When writing code to extract data from named subpatterns using the + name-to-number map, remember that the length of the entries is likely to be different for each compiled pattern. PCRE_INFO_OKPARTIAL - Return 1 if the pattern can be used for partial matching with - pcre_exec(), otherwise 0. The fourth argument should point to an int - variable. From release 8.00, this always returns 1, because the - restrictions that previously applied to partial matching have been - lifted. The pcrepartial documentation gives details of partial match- + Return 1 if the pattern can be used for partial matching with + pcre_exec(), otherwise 0. The fourth argument should point to an int + variable. From release 8.00, this always returns 1, because the + restrictions that previously applied to partial matching have been + lifted. The pcrepartial documentation gives details of partial match- ing. PCRE_INFO_OPTIONS - Return a copy of the options with which the pattern was compiled. The - fourth argument should point to an unsigned long int variable. These + Return a copy of the options with which the pattern was compiled. The + fourth argument should point to an unsigned long int variable. These option bits are those specified in the call to pcre_compile(), modified by any top-level option settings at the start of the pattern itself. In - other words, they are the options that will be in force when matching - starts. For example, if the pattern /(?im)abc(?-i)d/ is compiled with - the PCRE_EXTENDED option, the result is PCRE_CASELESS, PCRE_MULTILINE, + other words, they are the options that will be in force when matching + starts. For example, if the pattern /(?im)abc(?-i)d/ is compiled with + the PCRE_EXTENDED option, the result is PCRE_CASELESS, PCRE_MULTILINE, and PCRE_EXTENDED. - A pattern is automatically anchored by PCRE if all of its top-level + A pattern is automatically anchored by PCRE if all of its top-level alternatives begin with one of the following: ^ unless PCRE_MULTILINE is set @@ -2986,53 +2985,53 @@ INFORMATION ABOUT A PATTERN PCRE_INFO_RECURSIONLIMIT - If the pattern set a recursion limit by including an item of the form + If the pattern set a recursion limit by including an item of the form (*LIMIT_RECURSION=nnnn) at the start, the value is returned. The fourth - argument should point to an unsigned 32-bit integer. If no such value - has been set, the call to pcre_fullinfo() returns the error + argument should point to an unsigned 32-bit integer. If no such value + has been set, the call to pcre_fullinfo() returns the error PCRE_ERROR_UNSET. PCRE_INFO_SIZE - Return the size of the compiled pattern in bytes (for all three + Return the size of the compiled pattern in bytes (for all three libraries). The fourth argument should point to a size_t variable. This - value does not include the size of the pcre structure that is returned - by pcre_compile(). The value that is passed as the argument to - pcre_malloc() when pcre_compile() is getting memory in which to place + value does not include the size of the pcre structure that is returned + by pcre_compile(). The value that is passed as the argument to + pcre_malloc() when pcre_compile() is getting memory in which to place the compiled data is the value returned by this option plus the size of - the pcre structure. Studying a compiled pattern, with or without JIT, + the pcre structure. Studying a compiled pattern, with or without JIT, does not alter the value returned by this option. PCRE_INFO_STUDYSIZE - Return the size in bytes (for all three libraries) of the data block + Return the size in bytes (for all three libraries) of the data block pointed to by the study_data field in a pcre_extra block. If pcre_extra - is NULL, or there is no study data, zero is returned. The fourth argu- - ment should point to a size_t variable. The study_data field is set by + is NULL, or there is no study data, zero is returned. The fourth argu- + ment should point to a size_t variable. The study_data field is set by pcre_study() to record information that will speed up matching (see the - section entitled "Studying a pattern" above). The format of the - study_data block is private, but its length is made available via this - option so that it can be saved and restored (see the pcreprecompile + section entitled "Studying a pattern" above). The format of the + study_data block is private, but its length is made available via this + option so that it can be saved and restored (see the pcreprecompile documentation for details). PCRE_INFO_REQUIREDCHARFLAGS - Returns 1 if there is a rightmost literal data unit that must exist in + Returns 1 if there is a rightmost literal data unit that must exist in any matched string, other than at its start. The fourth argument should - point to an int variable. If there is no such value, 0 is returned. If + point to an int variable. If there is no such value, 0 is returned. If returning 1, the character value itself can be retrieved using PCRE_INFO_REQUIREDCHAR. For anchored patterns, a last literal value is recorded only if it fol- - lows something of variable length. For example, for the pattern - /^a\d+z\d+/ the returned value 1 (with "z" returned from + lows something of variable length. For example, for the pattern + /^a\d+z\d+/ the returned value 1 (with "z" returned from PCRE_INFO_REQUIREDCHAR), but for /^a\dz\d/ the returned value is 0. PCRE_INFO_REQUIREDCHAR - Return the value of the rightmost literal data unit that must exist in - any matched string, other than at its start, if such a value has been - recorded. The fourth argument should point to an uint32_t variable. If + Return the value of the rightmost literal data unit that must exist in + any matched string, other than at its start, if such a value has been + recorded. The fourth argument should point to an uint32_t variable. If there is no such value, 0 is returned. @@ -3040,21 +3039,21 @@ REFERENCE COUNTS int pcre_refcount(pcre *code, int adjust); - The pcre_refcount() function is used to maintain a reference count in + The pcre_refcount() function is used to maintain a reference count in the data block that contains a compiled pattern. It is provided for the - benefit of applications that operate in an object-oriented manner, + benefit of applications that operate in an object-oriented manner, where different parts of the application may be using the same compiled pattern, but you want to free the block when they are all done. When a pattern is compiled, the reference count field is initialized to - zero. It is changed only by calling this function, whose action is to - add the adjust value (which may be positive or negative) to it. The + zero. It is changed only by calling this function, whose action is to + add the adjust value (which may be positive or negative) to it. The yield of the function is the new value. However, the value of the count - is constrained to lie between 0 and 65535, inclusive. If the new value + is constrained to lie between 0 and 65535, inclusive. If the new value is outside these limits, it is forced to the appropriate limit value. - Except when it is zero, the reference count is not correctly preserved - if a pattern is compiled on one host and then transferred to a host + Except when it is zero, the reference count is not correctly preserved + if a pattern is compiled on one host and then transferred to a host whose byte-order is different. (This seems a highly unlikely scenario.) @@ -3064,22 +3063,22 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION const char *subject, int length, int startoffset, int options, int *ovector, int ovecsize); - The function pcre_exec() is called to match a subject string against a - compiled pattern, which is passed in the code argument. If the pattern - was studied, the result of the study should be passed in the extra - argument. You can call pcre_exec() with the same code and extra argu- - ments as many times as you like, in order to match different subject + The function pcre_exec() is called to match a subject string against a + compiled pattern, which is passed in the code argument. If the pattern + was studied, the result of the study should be passed in the extra + argument. You can call pcre_exec() with the same code and extra argu- + ments as many times as you like, in order to match different subject strings with the same pattern. - This function is the main matching facility of the library, and it - operates in a Perl-like manner. For specialist use there is also an - alternative matching function, which is described below in the section + This function is the main matching facility of the library, and it + operates in a Perl-like manner. For specialist use there is also an + alternative matching function, which is described below in the section about the pcre_dfa_exec() function. - In most applications, the pattern will have been compiled (and option- - ally studied) in the same process that calls pcre_exec(). However, it + In most applications, the pattern will have been compiled (and option- + ally studied) in the same process that calls pcre_exec(). However, it is possible to save compiled patterns and study data, and then use them - later in different processes, possibly even on different hosts. For a + later in different processes, possibly even on different hosts. For a discussion about this, see the pcreprecompile documentation. Here is an example of a simple call to pcre_exec(): @@ -3098,10 +3097,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION Extra data for pcre_exec() - If the extra argument is not NULL, it must point to a pcre_extra data - block. The pcre_study() function returns such a block (when it doesn't - return NULL), but you can also create one for yourself, and pass addi- - tional information in it. The pcre_extra block contains the following + If the extra argument is not NULL, it must point to a pcre_extra data + block. The pcre_study() function returns such a block (when it doesn't + return NULL), but you can also create one for yourself, and pass addi- + tional information in it. The pcre_extra block contains the following fields (not necessarily in this order): unsigned long int flags; @@ -3113,13 +3112,13 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION const unsigned char *tables; unsigned char **mark; - In the 16-bit version of this structure, the mark field has type + In the 16-bit version of this structure, the mark field has type "PCRE_UCHAR16 **". - In the 32-bit version of this structure, the mark field has type + In the 32-bit version of this structure, the mark field has type "PCRE_UCHAR32 **". - The flags field is used to specify which of the other fields are set. + The flags field is used to specify which of the other fields are set. The flag bits are: PCRE_EXTRA_CALLOUT_DATA @@ -3130,134 +3129,134 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_EXTRA_STUDY_DATA PCRE_EXTRA_TABLES - Other flag bits should be set to zero. The study_data field and some- - times the executable_jit field are set in the pcre_extra block that is - returned by pcre_study(), together with the appropriate flag bits. You - should not set these yourself, but you may add to the block by setting + Other flag bits should be set to zero. The study_data field and some- + times the executable_jit field are set in the pcre_extra block that is + returned by pcre_study(), together with the appropriate flag bits. You + should not set these yourself, but you may add to the block by setting other fields and their corresponding flag bits. The match_limit field provides a means of preventing PCRE from using up - a vast amount of resources when running patterns that are not going to - match, but which have a very large number of possibilities in their - search trees. The classic example is a pattern that uses nested unlim- + a vast amount of resources when running patterns that are not going to + match, but which have a very large number of possibilities in their + search trees. The classic example is a pattern that uses nested unlim- ited repeats. - Internally, pcre_exec() uses a function called match(), which it calls - repeatedly (sometimes recursively). The limit set by match_limit is - imposed on the number of times this function is called during a match, - which has the effect of limiting the amount of backtracking that can + Internally, pcre_exec() uses a function called match(), which it calls + repeatedly (sometimes recursively). The limit set by match_limit is + imposed on the number of times this function is called during a match, + which has the effect of limiting the amount of backtracking that can take place. For patterns that are not anchored, the count restarts from zero for each position in the subject string. When pcre_exec() is called with a pattern that was successfully studied - with a JIT option, the way that the matching is executed is entirely + with a JIT option, the way that the matching is executed is entirely different. However, there is still the possibility of runaway matching that goes on for a very long time, and so the match_limit value is also used in this case (but in a different way) to limit how long the match- ing can continue. - The default value for the limit can be set when PCRE is built; the - default default is 10 million, which handles all but the most extreme - cases. You can override the default by suppling pcre_exec() with a - pcre_extra block in which match_limit is set, and - PCRE_EXTRA_MATCH_LIMIT is set in the flags field. If the limit is + The default value for the limit can be set when PCRE is built; the + default default is 10 million, which handles all but the most extreme + cases. You can override the default by suppling pcre_exec() with a + pcre_extra block in which match_limit is set, and + PCRE_EXTRA_MATCH_LIMIT is set in the flags field. If the limit is exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT. - A value for the match limit may also be supplied by an item at the + A value for the match limit may also be supplied by an item at the start of a pattern of the form (*LIMIT_MATCH=d) - where d is a decimal number. However, such a setting is ignored unless - d is less than the limit set by the caller of pcre_exec() or, if no + where d is a decimal number. However, such a setting is ignored unless + d is less than the limit set by the caller of pcre_exec() or, if no such limit is set, less than the default. - The match_limit_recursion field is similar to match_limit, but instead + The match_limit_recursion field is similar to match_limit, but instead of limiting the total number of times that match() is called, it limits - the depth of recursion. The recursion depth is a smaller number than - the total number of calls, because not all calls to match() are recur- + the depth of recursion. The recursion depth is a smaller number than + the total number of calls, because not all calls to match() are recur- sive. This limit is of use only if it is set smaller than match_limit. - Limiting the recursion depth limits the amount of machine stack that - can be used, or, when PCRE has been compiled to use memory on the heap - instead of the stack, the amount of heap memory that can be used. This - limit is not relevant, and is ignored, when matching is done using JIT + Limiting the recursion depth limits the amount of machine stack that + can be used, or, when PCRE has been compiled to use memory on the heap + instead of the stack, the amount of heap memory that can be used. This + limit is not relevant, and is ignored, when matching is done using JIT compiled code. - The default value for match_limit_recursion can be set when PCRE is - built; the default default is the same value as the default for - match_limit. You can override the default by suppling pcre_exec() with - a pcre_extra block in which match_limit_recursion is set, and - PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the flags field. If the + The default value for match_limit_recursion can be set when PCRE is + built; the default default is the same value as the default for + match_limit. You can override the default by suppling pcre_exec() with + a pcre_extra block in which match_limit_recursion is set, and + PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the flags field. If the limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT. - A value for the recursion limit may also be supplied by an item at the + A value for the recursion limit may also be supplied by an item at the start of a pattern of the form (*LIMIT_RECURSION=d) - where d is a decimal number. However, such a setting is ignored unless - d is less than the limit set by the caller of pcre_exec() or, if no + where d is a decimal number. However, such a setting is ignored unless + d is less than the limit set by the caller of pcre_exec() or, if no such limit is set, less than the default. - The callout_data field is used in conjunction with the "callout" fea- + The callout_data field is used in conjunction with the "callout" fea- ture, and is described in the pcrecallout documentation. - The tables field is provided for use with patterns that have been pre- + The tables field is provided for use with patterns that have been pre- compiled using custom character tables, saved to disc or elsewhere, and - then reloaded, because the tables that were used to compile a pattern - are not saved with it. See the pcreprecompile documentation for a dis- - cussion of saving compiled patterns for later use. If NULL is passed + then reloaded, because the tables that were used to compile a pattern + are not saved with it. See the pcreprecompile documentation for a dis- + cussion of saving compiled patterns for later use. If NULL is passed using this mechanism, it forces PCRE's internal tables to be used. - Warning: The tables that pcre_exec() uses must be the same as those - that were used when the pattern was compiled. If this is not the case, + Warning: The tables that pcre_exec() uses must be the same as those + that were used when the pattern was compiled. If this is not the case, the behaviour of pcre_exec() is undefined. Therefore, when a pattern is - compiled and matched in the same process, this field should never be + compiled and matched in the same process, this field should never be set. In this (the most common) case, the correct table pointer is auto- - matically passed with the compiled pattern from pcre_compile() to + matically passed with the compiled pattern from pcre_compile() to pcre_exec(). - If PCRE_EXTRA_MARK is set in the flags field, the mark field must be - set to point to a suitable variable. If the pattern contains any back- - tracking control verbs such as (*MARK:NAME), and the execution ends up - with a name to pass back, a pointer to the name string (zero termi- - nated) is placed in the variable pointed to by the mark field. The - names are within the compiled pattern; if you wish to retain such a - name you must copy it before freeing the memory of a compiled pattern. - If there is no name to pass back, the variable pointed to by the mark - field is set to NULL. For details of the backtracking control verbs, + If PCRE_EXTRA_MARK is set in the flags field, the mark field must be + set to point to a suitable variable. If the pattern contains any back- + tracking control verbs such as (*MARK:NAME), and the execution ends up + with a name to pass back, a pointer to the name string (zero termi- + nated) is placed in the variable pointed to by the mark field. The + names are within the compiled pattern; if you wish to retain such a + name you must copy it before freeing the memory of a compiled pattern. + If there is no name to pass back, the variable pointed to by the mark + field is set to NULL. For details of the backtracking control verbs, see the section entitled "Backtracking control" in the pcrepattern doc- umentation. Option bits for pcre_exec() - The unused bits of the options argument for pcre_exec() must be zero. - The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx, - PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NOTEMPTY_ATSTART, - PCRE_NO_START_OPTIMIZE, PCRE_NO_UTF8_CHECK, PCRE_PARTIAL_HARD, and + The unused bits of the options argument for pcre_exec() must be zero. + The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx, + PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NOTEMPTY_ATSTART, + PCRE_NO_START_OPTIMIZE, PCRE_NO_UTF8_CHECK, PCRE_PARTIAL_HARD, and PCRE_PARTIAL_SOFT. - If the pattern was successfully studied with one of the just-in-time + If the pattern was successfully studied with one of the just-in-time (JIT) compile options, the only supported options for JIT execution are - PCRE_NO_UTF8_CHECK, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, - PCRE_NOTEMPTY_ATSTART, PCRE_PARTIAL_HARD, and PCRE_PARTIAL_SOFT. If an - unsupported option is used, JIT execution is disabled and the normal + PCRE_NO_UTF8_CHECK, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, + PCRE_NOTEMPTY_ATSTART, PCRE_PARTIAL_HARD, and PCRE_PARTIAL_SOFT. If an + unsupported option is used, JIT execution is disabled and the normal interpretive code in pcre_exec() is run. PCRE_ANCHORED - The PCRE_ANCHORED option limits pcre_exec() to matching at the first - matching position. If a pattern was compiled with PCRE_ANCHORED, or - turned out to be anchored by virtue of its contents, it cannot be made + The PCRE_ANCHORED option limits pcre_exec() to matching at the first + matching position. If a pattern was compiled with PCRE_ANCHORED, or + turned out to be anchored by virtue of its contents, it cannot be made unachored at matching time. PCRE_BSR_ANYCRLF PCRE_BSR_UNICODE These options (which are mutually exclusive) control what the \R escape - sequence matches. The choice is either to match only CR, LF, or CRLF, - or to match any Unicode newline sequence. These options override the + sequence matches. The choice is either to match only CR, LF, or CRLF, + or to match any Unicode newline sequence. These options override the choice that was made or defaulted when the pattern was compiled. PCRE_NEWLINE_CR @@ -3266,345 +3265,345 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_NEWLINE_ANYCRLF PCRE_NEWLINE_ANY - These options override the newline definition that was chosen or - defaulted when the pattern was compiled. For details, see the descrip- - tion of pcre_compile() above. During matching, the newline choice - affects the behaviour of the dot, circumflex, and dollar metacharac- - ters. It may also alter the way the match position is advanced after a + These options override the newline definition that was chosen or + defaulted when the pattern was compiled. For details, see the descrip- + tion of pcre_compile() above. During matching, the newline choice + affects the behaviour of the dot, circumflex, and dollar metacharac- + ters. It may also alter the way the match position is advanced after a match failure for an unanchored pattern. - When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is - set, and a match attempt for an unanchored pattern fails when the cur- - rent position is at a CRLF sequence, and the pattern contains no - explicit matches for CR or LF characters, the match position is + When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is + set, and a match attempt for an unanchored pattern fails when the cur- + rent position is at a CRLF sequence, and the pattern contains no + explicit matches for CR or LF characters, the match position is advanced by two characters instead of one, in other words, to after the CRLF. The above rule is a compromise that makes the most common cases work as - expected. For example, if the pattern is .+A (and the PCRE_DOTALL + expected. For example, if the pattern is .+A (and the PCRE_DOTALL option is not set), it does not match the string "\r\nA" because, after - failing at the start, it skips both the CR and the LF before retrying. - However, the pattern [\r\n]A does match that string, because it con- + failing at the start, it skips both the CR and the LF before retrying. + However, the pattern [\r\n]A does match that string, because it con- tains an explicit CR or LF reference, and so advances only by one char- acter after the first failure. An explicit match for CR of LF is either a literal appearance of one of - those characters, or one of the \r or \n escape sequences. Implicit - matches such as [^X] do not count, nor does \s (which includes CR and + those characters, or one of the \r or \n escape sequences. Implicit + matches such as [^X] do not count, nor does \s (which includes CR and LF in the characters that it matches). - Notwithstanding the above, anomalous effects may still occur when CRLF + Notwithstanding the above, anomalous effects may still occur when CRLF is a valid newline sequence and explicit \r or \n escapes appear in the pattern. PCRE_NOTBOL This option specifies that first character of the subject string is not - the beginning of a line, so the circumflex metacharacter should not - match before it. Setting this without PCRE_MULTILINE (at compile time) - causes circumflex never to match. This option affects only the behav- + the beginning of a line, so the circumflex metacharacter should not + match before it. Setting this without PCRE_MULTILINE (at compile time) + causes circumflex never to match. This option affects only the behav- iour of the circumflex metacharacter. It does not affect \A. PCRE_NOTEOL This option specifies that the end of the subject string is not the end - of a line, so the dollar metacharacter should not match it nor (except - in multiline mode) a newline immediately before it. Setting this with- + of a line, so the dollar metacharacter should not match it nor (except + in multiline mode) a newline immediately before it. Setting this with- out PCRE_MULTILINE (at compile time) causes dollar never to match. This - option affects only the behaviour of the dollar metacharacter. It does + option affects only the behaviour of the dollar metacharacter. It does not affect \Z or \z. PCRE_NOTEMPTY An empty string is not considered to be a valid match if this option is - set. If there are alternatives in the pattern, they are tried. If all - the alternatives match the empty string, the entire match fails. For + set. If there are alternatives in the pattern, they are tried. If all + the alternatives match the empty string, the entire match fails. For example, if the pattern a?b? - is applied to a string not beginning with "a" or "b", it matches an - empty string at the start of the subject. With PCRE_NOTEMPTY set, this + is applied to a string not beginning with "a" or "b", it matches an + empty string at the start of the subject. With PCRE_NOTEMPTY set, this match is not valid, so PCRE searches further into the string for occur- rences of "a" or "b". PCRE_NOTEMPTY_ATSTART - This is like PCRE_NOTEMPTY, except that an empty string match that is - not at the start of the subject is permitted. If the pattern is + This is like PCRE_NOTEMPTY, except that an empty string match that is + not at the start of the subject is permitted. If the pattern is anchored, such a match can occur only if the pattern contains \K. - Perl has no direct equivalent of PCRE_NOTEMPTY or - PCRE_NOTEMPTY_ATSTART, but it does make a special case of a pattern - match of the empty string within its split() function, and when using - the /g modifier. It is possible to emulate Perl's behaviour after + Perl has no direct equivalent of PCRE_NOTEMPTY or + PCRE_NOTEMPTY_ATSTART, but it does make a special case of a pattern + match of the empty string within its split() function, and when using + the /g modifier. It is possible to emulate Perl's behaviour after matching a null string by first trying the match again at the same off- - set with PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED, and then if that + set with PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED, and then if that fails, by advancing the starting offset (see below) and trying an ordi- - nary match again. There is some code that demonstrates how to do this - in the pcredemo sample program. In the most general case, you have to - check to see if the newline convention recognizes CRLF as a newline, - and if so, and the current character is CR followed by LF, advance the + nary match again. There is some code that demonstrates how to do this + in the pcredemo sample program. In the most general case, you have to + check to see if the newline convention recognizes CRLF as a newline, + and if so, and the current character is CR followed by LF, advance the starting offset by two characters instead of one. PCRE_NO_START_OPTIMIZE - There are a number of optimizations that pcre_exec() uses at the start - of a match, in order to speed up the process. For example, if it is + There are a number of optimizations that pcre_exec() uses at the start + of a match, in order to speed up the process. For example, if it is known that an unanchored match must start with a specific character, it - searches the subject for that character, and fails immediately if it - cannot find it, without actually running the main matching function. + searches the subject for that character, and fails immediately if it + cannot find it, without actually running the main matching function. This means that a special item such as (*COMMIT) at the start of a pat- - tern is not considered until after a suitable starting point for the - match has been found. Also, when callouts or (*MARK) items are in use, + tern is not considered until after a suitable starting point for the + match has been found. Also, when callouts or (*MARK) items are in use, these "start-up" optimizations can cause them to be skipped if the pat- tern is never actually used. The start-up optimizations are in effect a pre-scan of the subject that takes place before the pattern is run. - The PCRE_NO_START_OPTIMIZE option disables the start-up optimizations, - possibly causing performance to suffer, but ensuring that in cases - where the result is "no match", the callouts do occur, and that items + The PCRE_NO_START_OPTIMIZE option disables the start-up optimizations, + possibly causing performance to suffer, but ensuring that in cases + where the result is "no match", the callouts do occur, and that items such as (*COMMIT) and (*MARK) are considered at every possible starting - position in the subject string. If PCRE_NO_START_OPTIMIZE is set at - compile time, it cannot be unset at matching time. The use of + position in the subject string. If PCRE_NO_START_OPTIMIZE is set at + compile time, it cannot be unset at matching time. The use of PCRE_NO_START_OPTIMIZE at matching time (that is, passing it to - pcre_exec()) disables JIT execution; in this situation, matching is + pcre_exec()) disables JIT execution; in this situation, matching is always done using interpretively. - Setting PCRE_NO_START_OPTIMIZE can change the outcome of a matching + Setting PCRE_NO_START_OPTIMIZE can change the outcome of a matching operation. Consider the pattern (*COMMIT)ABC - When this is compiled, PCRE records the fact that a match must start - with the character "A". Suppose the subject string is "DEFABC". The - start-up optimization scans along the subject, finds "A" and runs the - first match attempt from there. The (*COMMIT) item means that the pat- - tern must match the current starting position, which in this case, it - does. However, if the same match is run with PCRE_NO_START_OPTIMIZE - set, the initial scan along the subject string does not happen. The - first match attempt is run starting from "D" and when this fails, - (*COMMIT) prevents any further matches being tried, so the overall - result is "no match". If the pattern is studied, more start-up opti- - mizations may be used. For example, a minimum length for the subject + When this is compiled, PCRE records the fact that a match must start + with the character "A". Suppose the subject string is "DEFABC". The + start-up optimization scans along the subject, finds "A" and runs the + first match attempt from there. The (*COMMIT) item means that the pat- + tern must match the current starting position, which in this case, it + does. However, if the same match is run with PCRE_NO_START_OPTIMIZE + set, the initial scan along the subject string does not happen. The + first match attempt is run starting from "D" and when this fails, + (*COMMIT) prevents any further matches being tried, so the overall + result is "no match". If the pattern is studied, more start-up opti- + mizations may be used. For example, a minimum length for the subject may be recorded. Consider the pattern (*MARK:A)(X|Y) - The minimum length for a match is one character. If the subject is - "ABC", there will be attempts to match "ABC", "BC", "C", and then - finally an empty string. If the pattern is studied, the final attempt - does not take place, because PCRE knows that the subject is too short, - and so the (*MARK) is never encountered. In this case, studying the - pattern does not affect the overall match result, which is still "no + The minimum length for a match is one character. If the subject is + "ABC", there will be attempts to match "ABC", "BC", "C", and then + finally an empty string. If the pattern is studied, the final attempt + does not take place, because PCRE knows that the subject is too short, + and so the (*MARK) is never encountered. In this case, studying the + pattern does not affect the overall match result, which is still "no match", but it does affect the auxiliary information that is returned. PCRE_NO_UTF8_CHECK When PCRE_UTF8 is set at compile time, the validity of the subject as a - UTF-8 string is automatically checked when pcre_exec() is subsequently + UTF-8 string is automatically checked when pcre_exec() is subsequently called. The entire string is checked before any other processing takes - place. The value of startoffset is also checked to ensure that it - points to the start of a UTF-8 character. There is a discussion about - the validity of UTF-8 strings in the pcreunicode page. If an invalid - sequence of bytes is found, pcre_exec() returns the error + place. The value of startoffset is also checked to ensure that it + points to the start of a UTF-8 character. There is a discussion about + the validity of UTF-8 strings in the pcreunicode page. If an invalid + sequence of bytes is found, pcre_exec() returns the error PCRE_ERROR_BADUTF8 or, if PCRE_PARTIAL_HARD is set and the problem is a truncated character at the end of the subject, PCRE_ERROR_SHORTUTF8. In - both cases, information about the precise nature of the error may also - be returned (see the descriptions of these errors in the section enti- - tled Error return values from pcre_exec() below). If startoffset con- + both cases, information about the precise nature of the error may also + be returned (see the descriptions of these errors in the section enti- + tled Error return values from pcre_exec() below). If startoffset con- tains a value that does not point to the start of a UTF-8 character (or to the end of the subject), PCRE_ERROR_BADUTF8_OFFSET is returned. - If you already know that your subject is valid, and you want to skip - these checks for performance reasons, you can set the - PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to - do this for the second and subsequent calls to pcre_exec() if you are - making repeated calls to find all the matches in a single subject - string. However, you should be sure that the value of startoffset - points to the start of a character (or the end of the subject). When + If you already know that your subject is valid, and you want to skip + these checks for performance reasons, you can set the + PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to + do this for the second and subsequent calls to pcre_exec() if you are + making repeated calls to find all the matches in a single subject + string. However, you should be sure that the value of startoffset + points to the start of a character (or the end of the subject). When PCRE_NO_UTF8_CHECK is set, the effect of passing an invalid string as a - subject or an invalid value of startoffset is undefined. Your program + subject or an invalid value of startoffset is undefined. Your program may crash or loop. PCRE_PARTIAL_HARD PCRE_PARTIAL_SOFT - These options turn on the partial matching feature. For backwards com- - patibility, PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial - match occurs if the end of the subject string is reached successfully, - but there are not enough subject characters to complete the match. If + These options turn on the partial matching feature. For backwards com- + patibility, PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial + match occurs if the end of the subject string is reached successfully, + but there are not enough subject characters to complete the match. If this happens when PCRE_PARTIAL_SOFT (but not PCRE_PARTIAL_HARD) is set, - matching continues by testing any remaining alternatives. Only if no - complete match can be found is PCRE_ERROR_PARTIAL returned instead of - PCRE_ERROR_NOMATCH. In other words, PCRE_PARTIAL_SOFT says that the - caller is prepared to handle a partial match, but only if no complete + matching continues by testing any remaining alternatives. Only if no + complete match can be found is PCRE_ERROR_PARTIAL returned instead of + PCRE_ERROR_NOMATCH. In other words, PCRE_PARTIAL_SOFT says that the + caller is prepared to handle a partial match, but only if no complete match can be found. - If PCRE_PARTIAL_HARD is set, it overrides PCRE_PARTIAL_SOFT. In this - case, if a partial match is found, pcre_exec() immediately returns - PCRE_ERROR_PARTIAL, without considering any other alternatives. In - other words, when PCRE_PARTIAL_HARD is set, a partial match is consid- + If PCRE_PARTIAL_HARD is set, it overrides PCRE_PARTIAL_SOFT. In this + case, if a partial match is found, pcre_exec() immediately returns + PCRE_ERROR_PARTIAL, without considering any other alternatives. In + other words, when PCRE_PARTIAL_HARD is set, a partial match is consid- ered to be more important that an alternative complete match. - In both cases, the portion of the string that was inspected when the + In both cases, the portion of the string that was inspected when the partial match was found is set as the first matching string. There is a - more detailed discussion of partial and multi-segment matching, with + more detailed discussion of partial and multi-segment matching, with examples, in the pcrepartial documentation. The string to be matched by pcre_exec() - The subject string is passed to pcre_exec() as a pointer in subject, a - length in length, and a starting offset in startoffset. The units for - length and startoffset are bytes for the 8-bit library, 16-bit data - items for the 16-bit library, and 32-bit data items for the 32-bit + The subject string is passed to pcre_exec() as a pointer in subject, a + length in length, and a starting offset in startoffset. The units for + length and startoffset are bytes for the 8-bit library, 16-bit data + items for the 16-bit library, and 32-bit data items for the 32-bit library. - If startoffset is negative or greater than the length of the subject, - pcre_exec() returns PCRE_ERROR_BADOFFSET. When the starting offset is - zero, the search for a match starts at the beginning of the subject, - and this is by far the most common case. In UTF-8 or UTF-16 mode, the - offset must point to the start of a character, or the end of the sub- - ject (in UTF-32 mode, one data unit equals one character, so all off- - sets are valid). Unlike the pattern string, the subject may contain + If startoffset is negative or greater than the length of the subject, + pcre_exec() returns PCRE_ERROR_BADOFFSET. When the starting offset is + zero, the search for a match starts at the beginning of the subject, + and this is by far the most common case. In UTF-8 or UTF-16 mode, the + offset must point to the start of a character, or the end of the sub- + ject (in UTF-32 mode, one data unit equals one character, so all off- + sets are valid). Unlike the pattern string, the subject may contain binary zeroes. - A non-zero starting offset is useful when searching for another match - in the same subject by calling pcre_exec() again after a previous suc- - cess. Setting startoffset differs from just passing over a shortened - string and setting PCRE_NOTBOL in the case of a pattern that begins + A non-zero starting offset is useful when searching for another match + in the same subject by calling pcre_exec() again after a previous suc- + cess. Setting startoffset differs from just passing over a shortened + string and setting PCRE_NOTBOL in the case of a pattern that begins with any kind of lookbehind. For example, consider the pattern \Biss\B - which finds occurrences of "iss" in the middle of words. (\B matches - only if the current position in the subject is not a word boundary.) - When applied to the string "Mississipi" the first call to pcre_exec() - finds the first occurrence. If pcre_exec() is called again with just - the remainder of the subject, namely "issipi", it does not match, + which finds occurrences of "iss" in the middle of words. (\B matches + only if the current position in the subject is not a word boundary.) + When applied to the string "Mississipi" the first call to pcre_exec() + finds the first occurrence. If pcre_exec() is called again with just + the remainder of the subject, namely "issipi", it does not match, because \B is always false at the start of the subject, which is deemed - to be a word boundary. However, if pcre_exec() is passed the entire + to be a word boundary. However, if pcre_exec() is passed the entire string again, but with startoffset set to 4, it finds the second occur- - rence of "iss" because it is able to look behind the starting point to + rence of "iss" because it is able to look behind the starting point to discover that it is preceded by a letter. - Finding all the matches in a subject is tricky when the pattern can + Finding all the matches in a subject is tricky when the pattern can match an empty string. It is possible to emulate Perl's /g behaviour by - first trying the match again at the same offset, with the - PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED options, and then if that - fails, advancing the starting offset and trying an ordinary match + first trying the match again at the same offset, with the + PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED options, and then if that + fails, advancing the starting offset and trying an ordinary match again. There is some code that demonstrates how to do this in the pcre- demo sample program. In the most general case, you have to check to see - if the newline convention recognizes CRLF as a newline, and if so, and + if the newline convention recognizes CRLF as a newline, and if so, and the current character is CR followed by LF, advance the starting offset by two characters instead of one. - If a non-zero starting offset is passed when the pattern is anchored, + If a non-zero starting offset is passed when the pattern is anchored, one attempt to match at the given offset is made. This can only succeed - if the pattern does not require the match to be at the start of the + if the pattern does not require the match to be at the start of the subject. How pcre_exec() returns captured substrings - In general, a pattern matches a certain portion of the subject, and in - addition, further substrings from the subject may be picked out by - parts of the pattern. Following the usage in Jeffrey Friedl's book, - this is called "capturing" in what follows, and the phrase "capturing - subpattern" is used for a fragment of a pattern that picks out a sub- - string. PCRE supports several other kinds of parenthesized subpattern + In general, a pattern matches a certain portion of the subject, and in + addition, further substrings from the subject may be picked out by + parts of the pattern. Following the usage in Jeffrey Friedl's book, + this is called "capturing" in what follows, and the phrase "capturing + subpattern" is used for a fragment of a pattern that picks out a sub- + string. PCRE supports several other kinds of parenthesized subpattern that do not cause substrings to be captured. Captured substrings are returned to the caller via a vector of integers - whose address is passed in ovector. The number of elements in the vec- - tor is passed in ovecsize, which must be a non-negative number. Note: + whose address is passed in ovector. The number of elements in the vec- + tor is passed in ovecsize, which must be a non-negative number. Note: this argument is NOT the size of ovector in bytes. - The first two-thirds of the vector is used to pass back captured sub- - strings, each substring using a pair of integers. The remaining third - of the vector is used as workspace by pcre_exec() while matching cap- - turing subpatterns, and is not available for passing back information. - The number passed in ovecsize should always be a multiple of three. If + The first two-thirds of the vector is used to pass back captured sub- + strings, each substring using a pair of integers. The remaining third + of the vector is used as workspace by pcre_exec() while matching cap- + turing subpatterns, and is not available for passing back information. + The number passed in ovecsize should always be a multiple of three. If it is not, it is rounded down. - When a match is successful, information about captured substrings is - returned in pairs of integers, starting at the beginning of ovector, - and continuing up to two-thirds of its length at the most. The first - element of each pair is set to the offset of the first character in a - substring, and the second is set to the offset of the first character - after the end of a substring. These values are always data unit off- - sets, even in UTF mode. They are byte offsets in the 8-bit library, - 16-bit data item offsets in the 16-bit library, and 32-bit data item + When a match is successful, information about captured substrings is + returned in pairs of integers, starting at the beginning of ovector, + and continuing up to two-thirds of its length at the most. The first + element of each pair is set to the offset of the first character in a + substring, and the second is set to the offset of the first character + after the end of a substring. These values are always data unit off- + sets, even in UTF mode. They are byte offsets in the 8-bit library, + 16-bit data item offsets in the 16-bit library, and 32-bit data item offsets in the 32-bit library. Note: they are not character counts. - The first pair of integers, ovector[0] and ovector[1], identify the - portion of the subject string matched by the entire pattern. The next - pair is used for the first capturing subpattern, and so on. The value + The first pair of integers, ovector[0] and ovector[1], identify the + portion of the subject string matched by the entire pattern. The next + pair is used for the first capturing subpattern, and so on. The value returned by pcre_exec() is one more than the highest numbered pair that - has been set. For example, if two substrings have been captured, the - returned value is 3. If there are no capturing subpatterns, the return + has been set. For example, if two substrings have been captured, the + returned value is 3. If there are no capturing subpatterns, the return value from a successful match is 1, indicating that just the first pair of offsets has been set. If a capturing subpattern is matched repeatedly, it is the last portion of the string that it matched that is returned. - If the vector is too small to hold all the captured substring offsets, + If the vector is too small to hold all the captured substring offsets, it is used as far as possible (up to two-thirds of its length), and the - function returns a value of zero. If neither the actual string matched - nor any captured substrings are of interest, pcre_exec() may be called - with ovector passed as NULL and ovecsize as zero. However, if the pat- - tern contains back references and the ovector is not big enough to - remember the related substrings, PCRE has to get additional memory for - use during matching. Thus it is usually advisable to supply an ovector + function returns a value of zero. If neither the actual string matched + nor any captured substrings are of interest, pcre_exec() may be called + with ovector passed as NULL and ovecsize as zero. However, if the pat- + tern contains back references and the ovector is not big enough to + remember the related substrings, PCRE has to get additional memory for + use during matching. Thus it is usually advisable to supply an ovector of reasonable size. - There are some cases where zero is returned (indicating vector over- - flow) when in fact the vector is exactly the right size for the final + There are some cases where zero is returned (indicating vector over- + flow) when in fact the vector is exactly the right size for the final match. For example, consider the pattern (a)(?:(b)c|bd) - If a vector of 6 elements (allowing for only 1 captured substring) is + If a vector of 6 elements (allowing for only 1 captured substring) is given with subject string "abd", pcre_exec() will try to set the second captured string, thereby recording a vector overflow, before failing to - match "c" and backing up to try the second alternative. The zero - return, however, does correctly indicate that the maximum number of + match "c" and backing up to try the second alternative. The zero + return, however, does correctly indicate that the maximum number of slots (namely 2) have been filled. In similar cases where there is tem- - porary overflow, but the final number of used slots is actually less + porary overflow, but the final number of used slots is actually less than the maximum, a non-zero value is returned. The pcre_fullinfo() function can be used to find out how many capturing - subpatterns there are in a compiled pattern. The smallest size for - ovector that will allow for n captured substrings, in addition to the + subpatterns there are in a compiled pattern. The smallest size for + ovector that will allow for n captured substrings, in addition to the offsets of the substring matched by the whole pattern, is (n+1)*3. - It is possible for capturing subpattern number n+1 to match some part + It is possible for capturing subpattern number n+1 to match some part of the subject when subpattern n has not been used at all. For example, - if the string "abc" is matched against the pattern (a|(z))(bc) the + if the string "abc" is matched against the pattern (a|(z))(bc) the return from the function is 4, and subpatterns 1 and 3 are matched, but - 2 is not. When this happens, both values in the offset pairs corre- + 2 is not. When this happens, both values in the offset pairs corre- sponding to unused subpatterns are set to -1. - Offset values that correspond to unused subpatterns at the end of the - expression are also set to -1. For example, if the string "abc" is - matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not - matched. The return from the function is 2, because the highest used - capturing subpattern number is 1, and the offsets for for the second - and third capturing subpatterns (assuming the vector is large enough, + Offset values that correspond to unused subpatterns at the end of the + expression are also set to -1. For example, if the string "abc" is + matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not + matched. The return from the function is 2, because the highest used + capturing subpattern number is 1, and the offsets for for the second + and third capturing subpatterns (assuming the vector is large enough, of course) are set to -1. - Note: Elements in the first two-thirds of ovector that do not corre- - spond to capturing parentheses in the pattern are never changed. That - is, if a pattern contains n capturing parentheses, no more than ovec- - tor[0] to ovector[2n+1] are set by pcre_exec(). The other elements (in + Note: Elements in the first two-thirds of ovector that do not corre- + spond to capturing parentheses in the pattern are never changed. That + is, if a pattern contains n capturing parentheses, no more than ovec- + tor[0] to ovector[2n+1] are set by pcre_exec(). The other elements (in the first two-thirds) retain whatever values they previously had. - Some convenience functions are provided for extracting the captured + Some convenience functions are provided for extracting the captured substrings as separate strings. These are described below. Error return values from pcre_exec() - If pcre_exec() fails, it returns a negative number. The following are + If pcre_exec() fails, it returns a negative number. The following are defined in the header file: PCRE_ERROR_NOMATCH (-1) @@ -3613,7 +3612,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_ERROR_NULL (-2) - Either code or subject was passed as NULL, or ovector was NULL and + Either code or subject was passed as NULL, or ovector was NULL and ovecsize was not zero. PCRE_ERROR_BADOPTION (-3) @@ -3622,82 +3621,82 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_ERROR_BADMAGIC (-4) - PCRE stores a 4-byte "magic number" at the start of the compiled code, + PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch the case when it is passed a junk pointer and to detect when a pattern that was compiled in an environment of one endianness is run in - an environment with the other endianness. This is the error that PCRE + an environment with the other endianness. This is the error that PCRE gives when the magic number is not present. PCRE_ERROR_UNKNOWN_OPCODE (-5) While running the pattern match, an unknown item was encountered in the - compiled pattern. This error could be caused by a bug in PCRE or by + compiled pattern. This error could be caused by a bug in PCRE or by overwriting of the compiled pattern. PCRE_ERROR_NOMEMORY (-6) - If a pattern contains back references, but the ovector that is passed + If a pattern contains back references, but the ovector that is passed to pcre_exec() is not big enough to remember the referenced substrings, - PCRE gets a block of memory at the start of matching to use for this - purpose. If the call via pcre_malloc() fails, this error is given. The + PCRE gets a block of memory at the start of matching to use for this + purpose. If the call via pcre_malloc() fails, this error is given. The memory is automatically freed at the end of matching. - This error is also given if pcre_stack_malloc() fails in pcre_exec(). - This can happen only when PCRE has been compiled with --disable-stack- + This error is also given if pcre_stack_malloc() fails in pcre_exec(). + This can happen only when PCRE has been compiled with --disable-stack- for-recursion. PCRE_ERROR_NOSUBSTRING (-7) - This error is used by the pcre_copy_substring(), pcre_get_substring(), + This error is used by the pcre_copy_substring(), pcre_get_substring(), and pcre_get_substring_list() functions (see below). It is never returned by pcre_exec(). PCRE_ERROR_MATCHLIMIT (-8) - The backtracking limit, as specified by the match_limit field in a - pcre_extra structure (or defaulted) was reached. See the description + The backtracking limit, as specified by the match_limit field in a + pcre_extra structure (or defaulted) was reached. See the description above. PCRE_ERROR_CALLOUT (-9) This error is never generated by pcre_exec() itself. It is provided for - use by callout functions that want to yield a distinctive error code. + use by callout functions that want to yield a distinctive error code. See the pcrecallout documentation for details. PCRE_ERROR_BADUTF8 (-10) - A string that contains an invalid UTF-8 byte sequence was passed as a - subject, and the PCRE_NO_UTF8_CHECK option was not set. If the size of - the output vector (ovecsize) is at least 2, the byte offset to the - start of the the invalid UTF-8 character is placed in the first ele- - ment, and a reason code is placed in the second element. The reason + A string that contains an invalid UTF-8 byte sequence was passed as a + subject, and the PCRE_NO_UTF8_CHECK option was not set. If the size of + the output vector (ovecsize) is at least 2, the byte offset to the + start of the the invalid UTF-8 character is placed in the first ele- + ment, and a reason code is placed in the second element. The reason codes are listed in the following section. For backward compatibility, - if PCRE_PARTIAL_HARD is set and the problem is a truncated UTF-8 char- - acter at the end of the subject (reason codes 1 to 5), + if PCRE_PARTIAL_HARD is set and the problem is a truncated UTF-8 char- + acter at the end of the subject (reason codes 1 to 5), PCRE_ERROR_SHORTUTF8 is returned instead of PCRE_ERROR_BADUTF8. PCRE_ERROR_BADUTF8_OFFSET (-11) - The UTF-8 byte sequence that was passed as a subject was checked and - found to be valid (the PCRE_NO_UTF8_CHECK option was not set), but the - value of startoffset did not point to the beginning of a UTF-8 charac- + The UTF-8 byte sequence that was passed as a subject was checked and + found to be valid (the PCRE_NO_UTF8_CHECK option was not set), but the + value of startoffset did not point to the beginning of a UTF-8 charac- ter or the end of the subject. PCRE_ERROR_PARTIAL (-12) - The subject string did not match, but it did match partially. See the + The subject string did not match, but it did match partially. See the pcrepartial documentation for details of partial matching. PCRE_ERROR_BADPARTIAL (-13) - This code is no longer in use. It was formerly returned when the - PCRE_PARTIAL option was used with a compiled pattern containing items - that were not supported for partial matching. From release 8.00 + This code is no longer in use. It was formerly returned when the + PCRE_PARTIAL option was used with a compiled pattern containing items + that were not supported for partial matching. From release 8.00 onwards, there are no restrictions on partial matching. PCRE_ERROR_INTERNAL (-14) - An unexpected internal error has occurred. This error could be caused + An unexpected internal error has occurred. This error could be caused by a bug in PCRE or by overwriting of the compiled pattern. PCRE_ERROR_BADCOUNT (-15) @@ -3707,7 +3706,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_ERROR_RECURSIONLIMIT (-21) The internal recursion limit, as specified by the match_limit_recursion - field in a pcre_extra structure (or defaulted) was reached. See the + field in a pcre_extra structure (or defaulted) was reached. See the description above. PCRE_ERROR_BADNEWLINE (-23) @@ -3721,29 +3720,29 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_ERROR_SHORTUTF8 (-25) - This error is returned instead of PCRE_ERROR_BADUTF8 when the subject - string ends with a truncated UTF-8 character and the PCRE_PARTIAL_HARD - option is set. Information about the failure is returned as for - PCRE_ERROR_BADUTF8. It is in fact sufficient to detect this case, but - this special error code for PCRE_PARTIAL_HARD precedes the implementa- - tion of returned information; it is retained for backwards compatibil- + This error is returned instead of PCRE_ERROR_BADUTF8 when the subject + string ends with a truncated UTF-8 character and the PCRE_PARTIAL_HARD + option is set. Information about the failure is returned as for + PCRE_ERROR_BADUTF8. It is in fact sufficient to detect this case, but + this special error code for PCRE_PARTIAL_HARD precedes the implementa- + tion of returned information; it is retained for backwards compatibil- ity. PCRE_ERROR_RECURSELOOP (-26) This error is returned when pcre_exec() detects a recursion loop within - the pattern. Specifically, it means that either the whole pattern or a - subpattern has been called recursively for the second time at the same + the pattern. Specifically, it means that either the whole pattern or a + subpattern has been called recursively for the second time at the same position in the subject string. Some simple patterns that might do this - are detected and faulted at compile time, but more complicated cases, + are detected and faulted at compile time, but more complicated cases, in particular mutual recursions between two different subpatterns, can- not be detected until run time. PCRE_ERROR_JIT_STACKLIMIT (-27) - This error is returned when a pattern that was successfully studied - using a JIT compile option is being matched, but the memory available - for the just-in-time processing stack is not large enough. See the + This error is returned when a pattern that was successfully studied + using a JIT compile option is being matched, but the memory available + for the just-in-time processing stack is not large enough. See the pcrejit documentation for more details. PCRE_ERROR_BADMODE (-28) @@ -3753,38 +3752,38 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_ERROR_BADENDIANNESS (-29) - This error is given if a pattern that was compiled and saved is - reloaded on a host with different endianness. The utility function + This error is given if a pattern that was compiled and saved is + reloaded on a host with different endianness. The utility function pcre_pattern_to_host_byte_order() can be used to convert such a pattern so that it runs on the new host. PCRE_ERROR_JIT_BADOPTION - This error is returned when a pattern that was successfully studied - using a JIT compile option is being matched, but the matching mode - (partial or complete match) does not correspond to any JIT compilation - mode. When the JIT fast path function is used, this error may be also - given for invalid options. See the pcrejit documentation for more + This error is returned when a pattern that was successfully studied + using a JIT compile option is being matched, but the matching mode + (partial or complete match) does not correspond to any JIT compilation + mode. When the JIT fast path function is used, this error may be also + given for invalid options. See the pcrejit documentation for more details. PCRE_ERROR_BADLENGTH (-32) - This error is given if pcre_exec() is called with a negative value for + This error is given if pcre_exec() is called with a negative value for the length argument. Error numbers -16 to -20, -22, and 30 are not used by pcre_exec(). Reason codes for invalid UTF-8 strings - This section applies only to the 8-bit library. The corresponding - information for the 16-bit and 32-bit libraries is given in the pcre16 + This section applies only to the 8-bit library. The corresponding + information for the 16-bit and 32-bit libraries is given in the pcre16 and pcre32 pages. When pcre_exec() returns either PCRE_ERROR_BADUTF8 or PCRE_ERROR_SHORT- - UTF8, and the size of the output vector (ovecsize) is at least 2, the - offset of the start of the invalid UTF-8 character is placed in the + UTF8, and the size of the output vector (ovecsize) is at least 2, the + offset of the start of the invalid UTF-8 character is placed in the first output vector element (ovector[0]) and a reason code is placed in - the second element (ovector[1]). The reason codes are given names in + the second element (ovector[1]). The reason codes are given names in the pcre.h header file: PCRE_UTF8_ERR1 @@ -3793,10 +3792,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_UTF8_ERR4 PCRE_UTF8_ERR5 - The string ends with a truncated UTF-8 character; the code specifies - how many bytes are missing (1 to 5). Although RFC 3629 restricts UTF-8 - characters to be no longer than 4 bytes, the encoding scheme (origi- - nally defined by RFC 2279) allows for up to 6 bytes, and this is + The string ends with a truncated UTF-8 character; the code specifies + how many bytes are missing (1 to 5). Although RFC 3629 restricts UTF-8 + characters to be no longer than 4 bytes, the encoding scheme (origi- + nally defined by RFC 2279) allows for up to 6 bytes, and this is checked first; hence the possibility of 4 or 5 missing bytes. PCRE_UTF8_ERR6 @@ -3806,24 +3805,24 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_UTF8_ERR10 The two most significant bits of the 2nd, 3rd, 4th, 5th, or 6th byte of - the character do not have the binary value 0b10 (that is, either the + the character do not have the binary value 0b10 (that is, either the most significant bit is 0, or the next bit is 1). PCRE_UTF8_ERR11 PCRE_UTF8_ERR12 - A character that is valid by the RFC 2279 rules is either 5 or 6 bytes + A character that is valid by the RFC 2279 rules is either 5 or 6 bytes long; these code points are excluded by RFC 3629. PCRE_UTF8_ERR13 - A 4-byte character has a value greater than 0x10fff; these code points + A 4-byte character has a value greater than 0x10fff; these code points are excluded by RFC 3629. PCRE_UTF8_ERR14 - A 3-byte character has a value in the range 0xd800 to 0xdfff; this - range of code points are reserved by RFC 3629 for use with UTF-16, and + A 3-byte character has a value in the range 0xd800 to 0xdfff; this + range of code points are reserved by RFC 3629 for use with UTF-16, and so are excluded from UTF-8. PCRE_UTF8_ERR15 @@ -3832,28 +3831,28 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION PCRE_UTF8_ERR18 PCRE_UTF8_ERR19 - A 2-, 3-, 4-, 5-, or 6-byte character is "overlong", that is, it codes - for a value that can be represented by fewer bytes, which is invalid. - For example, the two bytes 0xc0, 0xae give the value 0x2e, whose cor- + A 2-, 3-, 4-, 5-, or 6-byte character is "overlong", that is, it codes + for a value that can be represented by fewer bytes, which is invalid. + For example, the two bytes 0xc0, 0xae give the value 0x2e, whose cor- rect coding uses just one byte. PCRE_UTF8_ERR20 The two most significant bits of the first byte of a character have the - binary value 0b10 (that is, the most significant bit is 1 and the sec- - ond is 0). Such a byte can only validly occur as the second or subse- + binary value 0b10 (that is, the most significant bit is 1 and the sec- + ond is 0). Such a byte can only validly occur as the second or subse- quent byte of a multi-byte character. PCRE_UTF8_ERR21 - The first byte of a character has the value 0xfe or 0xff. These values + The first byte of a character has the value 0xfe or 0xff. These values can never occur in a valid UTF-8 string. PCRE_UTF8_ERR22 - This error code was formerly used when the presence of a so-called - "non-character" caused an error. Unicode corrigendum #9 makes it clear - that such characters should not cause a string to be rejected, and so + This error code was formerly used when the presence of a so-called + "non-character" caused an error. Unicode corrigendum #9 makes it clear + that such characters should not cause a string to be rejected, and so this code is no longer in use and is never returned. @@ -3870,78 +3869,78 @@ EXTRACTING CAPTURED SUBSTRINGS BY NUMBER int pcre_get_substring_list(const char *subject, int *ovector, int stringcount, const char ***listptr); - Captured substrings can be accessed directly by using the offsets - returned by pcre_exec() in ovector. For convenience, the functions + Captured substrings can be accessed directly by using the offsets + returned by pcre_exec() in ovector. For convenience, the functions pcre_copy_substring(), pcre_get_substring(), and pcre_get_sub- - string_list() are provided for extracting captured substrings as new, - separate, zero-terminated strings. These functions identify substrings - by number. The next section describes functions for extracting named + string_list() are provided for extracting captured substrings as new, + separate, zero-terminated strings. These functions identify substrings + by number. The next section describes functions for extracting named substrings. - A substring that contains a binary zero is correctly extracted and has - a further zero added on the end, but the result is not, of course, a C - string. However, you can process such a string by referring to the - length that is returned by pcre_copy_substring() and pcre_get_sub- + A substring that contains a binary zero is correctly extracted and has + a further zero added on the end, but the result is not, of course, a C + string. However, you can process such a string by referring to the + length that is returned by pcre_copy_substring() and pcre_get_sub- string(). Unfortunately, the interface to pcre_get_substring_list() is - not adequate for handling strings containing binary zeros, because the + not adequate for handling strings containing binary zeros, because the end of the final string is not independently indicated. - The first three arguments are the same for all three of these func- - tions: subject is the subject string that has just been successfully + The first three arguments are the same for all three of these func- + tions: subject is the subject string that has just been successfully matched, ovector is a pointer to the vector of integer offsets that was passed to pcre_exec(), and stringcount is the number of substrings that - were captured by the match, including the substring that matched the + were captured by the match, including the substring that matched the entire regular expression. This is the value returned by pcre_exec() if - it is greater than zero. If pcre_exec() returned zero, indicating that - it ran out of space in ovector, the value passed as stringcount should + it is greater than zero. If pcre_exec() returned zero, indicating that + it ran out of space in ovector, the value passed as stringcount should be the number of elements in the vector divided by three. - The functions pcre_copy_substring() and pcre_get_substring() extract a - single substring, whose number is given as stringnumber. A value of - zero extracts the substring that matched the entire pattern, whereas - higher values extract the captured substrings. For pcre_copy_sub- - string(), the string is placed in buffer, whose length is given by - buffersize, while for pcre_get_substring() a new block of memory is - obtained via pcre_malloc, and its address is returned via stringptr. - The yield of the function is the length of the string, not including + The functions pcre_copy_substring() and pcre_get_substring() extract a + single substring, whose number is given as stringnumber. A value of + zero extracts the substring that matched the entire pattern, whereas + higher values extract the captured substrings. For pcre_copy_sub- + string(), the string is placed in buffer, whose length is given by + buffersize, while for pcre_get_substring() a new block of memory is + obtained via pcre_malloc, and its address is returned via stringptr. + The yield of the function is the length of the string, not including the terminating zero, or one of these error codes: PCRE_ERROR_NOMEMORY (-6) - The buffer was too small for pcre_copy_substring(), or the attempt to + The buffer was too small for pcre_copy_substring(), or the attempt to get memory failed for pcre_get_substring(). PCRE_ERROR_NOSUBSTRING (-7) There is no substring whose number is stringnumber. - The pcre_get_substring_list() function extracts all available sub- - strings and builds a list of pointers to them. All this is done in a + The pcre_get_substring_list() function extracts all available sub- + strings and builds a list of pointers to them. All this is done in a single block of memory that is obtained via pcre_malloc. The address of - the memory block is returned via listptr, which is also the start of - the list of string pointers. The end of the list is marked by a NULL - pointer. The yield of the function is zero if all went well, or the + the memory block is returned via listptr, which is also the start of + the list of string pointers. The end of the list is marked by a NULL + pointer. The yield of the function is zero if all went well, or the error code PCRE_ERROR_NOMEMORY (-6) if the attempt to get the memory block failed. - When any of these functions encounter a substring that is unset, which - can happen when capturing subpattern number n+1 matches some part of - the subject, but subpattern n has not been used at all, they return an + When any of these functions encounter a substring that is unset, which + can happen when capturing subpattern number n+1 matches some part of + the subject, but subpattern n has not been used at all, they return an empty string. This can be distinguished from a genuine zero-length sub- - string by inspecting the appropriate offset in ovector, which is nega- + string by inspecting the appropriate offset in ovector, which is nega- tive for unset substrings. - The two convenience functions pcre_free_substring() and pcre_free_sub- - string_list() can be used to free the memory returned by a previous + The two convenience functions pcre_free_substring() and pcre_free_sub- + string_list() can be used to free the memory returned by a previous call of pcre_get_substring() or pcre_get_substring_list(), respec- - tively. They do nothing more than call the function pointed to by - pcre_free, which of course could be called directly from a C program. - However, PCRE is used in some situations where it is linked via a spe- - cial interface to another programming language that cannot use - pcre_free directly; it is for these cases that the functions are pro- + tively. They do nothing more than call the function pointed to by + pcre_free, which of course could be called directly from a C program. + However, PCRE is used in some situations where it is linked via a spe- + cial interface to another programming language that cannot use + pcre_free directly; it is for these cases that the functions are pro- vided. @@ -3960,7 +3959,7 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME int stringcount, const char *stringname, const char **stringptr); - To extract a substring by name, you first have to find associated num- + To extract a substring by name, you first have to find associated num- ber. For example, for this pattern (a+)b(?\d+)... @@ -3969,35 +3968,35 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME be unique (PCRE_DUPNAMES was not set), you can find the number from the name by calling pcre_get_stringnumber(). The first argument is the com- piled pattern, and the second is the name. The yield of the function is - the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no + the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no subpattern of that name. Given the number, you can extract the substring directly, or use one of the functions described in the previous section. For convenience, there are also two functions that do the whole job. - Most of the arguments of pcre_copy_named_substring() and - pcre_get_named_substring() are the same as those for the similarly - named functions that extract by number. As these are described in the - previous section, they are not re-described here. There are just two + Most of the arguments of pcre_copy_named_substring() and + pcre_get_named_substring() are the same as those for the similarly + named functions that extract by number. As these are described in the + previous section, they are not re-described here. There are just two differences: - First, instead of a substring number, a substring name is given. Sec- + First, instead of a substring number, a substring name is given. Sec- ond, there is an extra argument, given at the start, which is a pointer - to the compiled pattern. This is needed in order to gain access to the + to the compiled pattern. This is needed in order to gain access to the name-to-number translation table. - These functions call pcre_get_stringnumber(), and if it succeeds, they - then call pcre_copy_substring() or pcre_get_substring(), as appropri- - ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate names, the + These functions call pcre_get_stringnumber(), and if it succeeds, they + then call pcre_copy_substring() or pcre_get_substring(), as appropri- + ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate names, the behaviour may not be what you want (see the next section). Warning: If the pattern uses the (?| feature to set up multiple subpat- - terns with the same number, as described in the section on duplicate - subpattern numbers in the pcrepattern page, you cannot use names to - distinguish the different subpatterns, because names are not included - in the compiled code. The matching process uses only numbers. For this - reason, the use of different names for subpatterns of the same number + terns with the same number, as described in the section on duplicate + subpattern numbers in the pcrepattern page, you cannot use names to + distinguish the different subpatterns, because names are not included + in the compiled code. The matching process uses only numbers. For this + reason, the use of different names for subpatterns of the same number causes an error at compile time. @@ -4006,76 +4005,76 @@ DUPLICATE SUBPATTERN NAMES int pcre_get_stringtable_entries(const pcre *code, const char *name, char **first, char **last); - When a pattern is compiled with the PCRE_DUPNAMES option, names for - subpatterns are not required to be unique. (Duplicate names are always - allowed for subpatterns with the same number, created by using the (?| - feature. Indeed, if such subpatterns are named, they are required to + When a pattern is compiled with the PCRE_DUPNAMES option, names for + subpatterns are not required to be unique. (Duplicate names are always + allowed for subpatterns with the same number, created by using the (?| + feature. Indeed, if such subpatterns are named, they are required to use the same names.) Normally, patterns with duplicate names are such that in any one match, - only one of the named subpatterns participates. An example is shown in + only one of the named subpatterns participates. An example is shown in the pcrepattern documentation. - When duplicates are present, pcre_copy_named_substring() and - pcre_get_named_substring() return the first substring corresponding to - the given name that is set. If none are set, PCRE_ERROR_NOSUBSTRING - (-7) is returned; no data is returned. The pcre_get_stringnumber() - function returns one of the numbers that are associated with the name, + When duplicates are present, pcre_copy_named_substring() and + pcre_get_named_substring() return the first substring corresponding to + the given name that is set. If none are set, PCRE_ERROR_NOSUBSTRING + (-7) is returned; no data is returned. The pcre_get_stringnumber() + function returns one of the numbers that are associated with the name, but it is not defined which it is. - If you want to get full details of all captured substrings for a given - name, you must use the pcre_get_stringtable_entries() function. The + If you want to get full details of all captured substrings for a given + name, you must use the pcre_get_stringtable_entries() function. The first argument is the compiled pattern, and the second is the name. The - third and fourth are pointers to variables which are updated by the + third and fourth are pointers to variables which are updated by the function. After it has run, they point to the first and last entries in - the name-to-number table for the given name. The function itself - returns the length of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if - there are none. The format of the table is described above in the sec- - tion entitled Information about a pattern above. Given all the rele- - vant entries for the name, you can extract each of their numbers, and + the name-to-number table for the given name. The function itself + returns the length of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if + there are none. The format of the table is described above in the sec- + tion entitled Information about a pattern above. Given all the rele- + vant entries for the name, you can extract each of their numbers, and hence the captured data, if any. FINDING ALL POSSIBLE MATCHES - The traditional matching function uses a similar algorithm to Perl, + The traditional matching function uses a similar algorithm to Perl, which stops when it finds the first match, starting at a given point in - the subject. If you want to find all possible matches, or the longest - possible match, consider using the alternative matching function (see - below) instead. If you cannot use the alternative function, but still - need to find all possible matches, you can kludge it up by making use + the subject. If you want to find all possible matches, or the longest + possible match, consider using the alternative matching function (see + below) instead. If you cannot use the alternative function, but still + need to find all possible matches, you can kludge it up by making use of the callout facility, which is described in the pcrecallout documen- tation. What you have to do is to insert a callout right at the end of the pat- - tern. When your callout function is called, extract and save the cur- - rent matched substring. Then return 1, which forces pcre_exec() to - backtrack and try other alternatives. Ultimately, when it runs out of + tern. When your callout function is called, extract and save the cur- + rent matched substring. Then return 1, which forces pcre_exec() to + backtrack and try other alternatives. Ultimately, when it runs out of matches, pcre_exec() will yield PCRE_ERROR_NOMATCH. OBTAINING AN ESTIMATE OF STACK USAGE - Matching certain patterns using pcre_exec() can use a lot of process - stack, which in certain environments can be rather limited in size. - Some users find it helpful to have an estimate of the amount of stack - that is used by pcre_exec(), to help them set recursion limits, as - described in the pcrestack documentation. The estimate that is output + Matching certain patterns using pcre_exec() can use a lot of process + stack, which in certain environments can be rather limited in size. + Some users find it helpful to have an estimate of the amount of stack + that is used by pcre_exec(), to help them set recursion limits, as + described in the pcrestack documentation. The estimate that is output by pcretest when called with the -m and -C options is obtained by call- - ing pcre_exec with the values NULL, NULL, NULL, -999, and -999 for its + ing pcre_exec with the values NULL, NULL, NULL, -999, and -999 for its first five arguments. - Normally, if its first argument is NULL, pcre_exec() immediately - returns the negative error code PCRE_ERROR_NULL, but with this special - combination of arguments, it returns instead a negative number whose - absolute value is the approximate stack frame size in bytes. (A nega- - tive number is used so that it is clear that no match has happened.) - The value is approximate because in some cases, recursive calls to + Normally, if its first argument is NULL, pcre_exec() immediately + returns the negative error code PCRE_ERROR_NULL, but with this special + combination of arguments, it returns instead a negative number whose + absolute value is the approximate stack frame size in bytes. (A nega- + tive number is used so that it is clear that no match has happened.) + The value is approximate because in some cases, recursive calls to pcre_exec() occur when there are one or two additional variables on the stack. - If PCRE has been compiled to use the heap instead of the stack for - recursion, the value returned is the size of each block that is + If PCRE has been compiled to use the heap instead of the stack for + recursion, the value returned is the size of each block that is obtained from the heap. @@ -4086,26 +4085,26 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION int options, int *ovector, int ovecsize, int *workspace, int wscount); - The function pcre_dfa_exec() is called to match a subject string - against a compiled pattern, using a matching algorithm that scans the - subject string just once, and does not backtrack. This has different - characteristics to the normal algorithm, and is not compatible with - Perl. Some of the features of PCRE patterns are not supported. Never- - theless, there are times when this kind of matching can be useful. For - a discussion of the two matching algorithms, and a list of features - that pcre_dfa_exec() does not support, see the pcrematching documenta- + The function pcre_dfa_exec() is called to match a subject string + against a compiled pattern, using a matching algorithm that scans the + subject string just once, and does not backtrack. This has different + characteristics to the normal algorithm, and is not compatible with + Perl. Some of the features of PCRE patterns are not supported. Never- + theless, there are times when this kind of matching can be useful. For + a discussion of the two matching algorithms, and a list of features + that pcre_dfa_exec() does not support, see the pcrematching documenta- tion. - The arguments for the pcre_dfa_exec() function are the same as for + The arguments for the pcre_dfa_exec() function are the same as for pcre_exec(), plus two extras. The ovector argument is used in a differ- - ent way, and this is described below. The other common arguments are - used in the same way as for pcre_exec(), so their description is not + ent way, and this is described below. The other common arguments are + used in the same way as for pcre_exec(), so their description is not repeated here. - The two additional arguments provide workspace for the function. The - workspace vector should contain at least 20 elements. It is used for + The two additional arguments provide workspace for the function. The + workspace vector should contain at least 20 elements. It is used for keeping track of multiple paths through the pattern tree. More - workspace will be needed for patterns and subjects where there are a + workspace will be needed for patterns and subjects where there are a lot of potential matches. Here is an example of a simple call to pcre_dfa_exec(): @@ -4127,55 +4126,55 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION Option bits for pcre_dfa_exec() - The unused bits of the options argument for pcre_dfa_exec() must be - zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEW- + The unused bits of the options argument for pcre_dfa_exec() must be + zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEW- LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, - PCRE_NOTEMPTY_ATSTART, PCRE_NO_UTF8_CHECK, PCRE_BSR_ANYCRLF, - PCRE_BSR_UNICODE, PCRE_NO_START_OPTIMIZE, PCRE_PARTIAL_HARD, PCRE_PAR- - TIAL_SOFT, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last - four of these are exactly the same as for pcre_exec(), so their + PCRE_NOTEMPTY_ATSTART, PCRE_NO_UTF8_CHECK, PCRE_BSR_ANYCRLF, + PCRE_BSR_UNICODE, PCRE_NO_START_OPTIMIZE, PCRE_PARTIAL_HARD, PCRE_PAR- + TIAL_SOFT, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last + four of these are exactly the same as for pcre_exec(), so their description is not repeated here. PCRE_PARTIAL_HARD PCRE_PARTIAL_SOFT - These have the same general effect as they do for pcre_exec(), but the - details are slightly different. When PCRE_PARTIAL_HARD is set for - pcre_dfa_exec(), it returns PCRE_ERROR_PARTIAL if the end of the sub- - ject is reached and there is still at least one matching possibility + These have the same general effect as they do for pcre_exec(), but the + details are slightly different. When PCRE_PARTIAL_HARD is set for + pcre_dfa_exec(), it returns PCRE_ERROR_PARTIAL if the end of the sub- + ject is reached and there is still at least one matching possibility that requires additional characters. This happens even if some complete matches have also been found. When PCRE_PARTIAL_SOFT is set, the return code PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if the end - of the subject is reached, there have been no complete matches, but - there is still at least one matching possibility. The portion of the - string that was inspected when the longest partial match was found is - set as the first matching string in both cases. There is a more - detailed discussion of partial and multi-segment matching, with exam- + of the subject is reached, there have been no complete matches, but + there is still at least one matching possibility. The portion of the + string that was inspected when the longest partial match was found is + set as the first matching string in both cases. There is a more + detailed discussion of partial and multi-segment matching, with exam- ples, in the pcrepartial documentation. PCRE_DFA_SHORTEST - Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to + Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to stop as soon as it has found one match. Because of the way the alterna- - tive algorithm works, this is necessarily the shortest possible match + tive algorithm works, this is necessarily the shortest possible match at the first possible matching point in the subject string. PCRE_DFA_RESTART When pcre_dfa_exec() returns a partial match, it is possible to call it - again, with additional subject characters, and have it continue with - the same match. The PCRE_DFA_RESTART option requests this action; when - it is set, the workspace and wscount options must reference the same - vector as before because data about the match so far is left in them + again, with additional subject characters, and have it continue with + the same match. The PCRE_DFA_RESTART option requests this action; when + it is set, the workspace and wscount options must reference the same + vector as before because data about the match so far is left in them after a partial match. There is more discussion of this facility in the pcrepartial documentation. Successful returns from pcre_dfa_exec() - When pcre_dfa_exec() succeeds, it may have matched more than one sub- + When pcre_dfa_exec() succeeds, it may have matched more than one sub- string in the subject. Note, however, that all the matches from one run - of the function start at the same point in the subject. The shorter - matches are all initial substrings of the longer matches. For example, + of the function start at the same point in the subject. The shorter + matches are all initial substrings of the longer matches. For example, if the pattern <.*> @@ -4190,79 +4189,79 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION - On success, the yield of the function is a number greater than zero, - which is the number of matched substrings. The substrings themselves - are returned in ovector. Each string uses two elements; the first is - the offset to the start, and the second is the offset to the end. In - fact, all the strings have the same start offset. (Space could have - been saved by giving this only once, but it was decided to retain some - compatibility with the way pcre_exec() returns data, even though the + On success, the yield of the function is a number greater than zero, + which is the number of matched substrings. The substrings themselves + are returned in ovector. Each string uses two elements; the first is + the offset to the start, and the second is the offset to the end. In + fact, all the strings have the same start offset. (Space could have + been saved by giving this only once, but it was decided to retain some + compatibility with the way pcre_exec() returns data, even though the meaning of the strings is different.) The strings are returned in reverse order of length; that is, the long- - est matching string is given first. If there were too many matches to - fit into ovector, the yield of the function is zero, and the vector is - filled with the longest matches. Unlike pcre_exec(), pcre_dfa_exec() + est matching string is given first. If there were too many matches to + fit into ovector, the yield of the function is zero, and the vector is + filled with the longest matches. Unlike pcre_exec(), pcre_dfa_exec() can use the entire ovector for returning matched strings. - NOTE: PCRE's "auto-possessification" optimization usually applies to - character repeats at the end of a pattern (as well as internally). For - example, the pattern "a\d+" is compiled as if it were "a\d++" because + NOTE: PCRE's "auto-possessification" optimization usually applies to + character repeats at the end of a pattern (as well as internally). For + example, the pattern "a\d+" is compiled as if it were "a\d++" because there is no point even considering the possibility of backtracking into - the repeated digits. For DFA matching, this means that only one possi- - ble match is found. If you really do want multiple matches in such - cases, either use an ungreedy repeat ("a\d+?") or set the + the repeated digits. For DFA matching, this means that only one possi- + ble match is found. If you really do want multiple matches in such + cases, either use an ungreedy repeat ("a\d+?") or set the PCRE_NO_AUTO_POSSESS option when compiling. Error returns from pcre_dfa_exec() - The pcre_dfa_exec() function returns a negative number when it fails. - Many of the errors are the same as for pcre_exec(), and these are - described above. There are in addition the following errors that are + The pcre_dfa_exec() function returns a negative number when it fails. + Many of the errors are the same as for pcre_exec(), and these are + described above. There are in addition the following errors that are specific to pcre_dfa_exec(): PCRE_ERROR_DFA_UITEM (-16) - This return is given if pcre_dfa_exec() encounters an item in the pat- - tern that it does not support, for instance, the use of \C or a back + This return is given if pcre_dfa_exec() encounters an item in the pat- + tern that it does not support, for instance, the use of \C or a back reference. PCRE_ERROR_DFA_UCOND (-17) - This return is given if pcre_dfa_exec() encounters a condition item - that uses a back reference for the condition, or a test for recursion + This return is given if pcre_dfa_exec() encounters a condition item + that uses a back reference for the condition, or a test for recursion in a specific group. These are not supported. PCRE_ERROR_DFA_UMLIMIT (-18) - This return is given if pcre_dfa_exec() is called with an extra block - that contains a setting of the match_limit or match_limit_recursion - fields. This is not supported (these fields are meaningless for DFA + This return is given if pcre_dfa_exec() is called with an extra block + that contains a setting of the match_limit or match_limit_recursion + fields. This is not supported (these fields are meaningless for DFA matching). PCRE_ERROR_DFA_WSSIZE (-19) - This return is given if pcre_dfa_exec() runs out of space in the + This return is given if pcre_dfa_exec() runs out of space in the workspace vector. PCRE_ERROR_DFA_RECURSE (-20) - When a recursive subpattern is processed, the matching function calls - itself recursively, using private vectors for ovector and workspace. - This error is given if the output vector is not large enough. This + When a recursive subpattern is processed, the matching function calls + itself recursively, using private vectors for ovector and workspace. + This error is given if the output vector is not large enough. This should be extremely rare, as a vector of size 1000 is used. PCRE_ERROR_DFA_BADRESTART (-30) - When pcre_dfa_exec() is called with the PCRE_DFA_RESTART option, some - plausibility checks are made on the contents of the workspace, which - should contain data about the previous partial match. If any of these + When pcre_dfa_exec() is called with the PCRE_DFA_RESTART option, some + plausibility checks are made on the contents of the workspace, which + should contain data about the previous partial match. If any of these checks fail, this error is given. SEE ALSO - pcre16(3), pcre32(3), pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), + pcre16(3), pcre32(3), pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepartial(3), pcreposix(3), pcreprecompile(3), pcre- sample(3), pcrestack(3). @@ -4276,8 +4275,8 @@ AUTHOR REVISION - Last updated: 09 February 2014 - Copyright (c) 1997-2014 University of Cambridge. + Last updated: 18 December 2015 + Copyright (c) 1997-2015 University of Cambridge. ------------------------------------------------------------------------------ diff --git a/pcre/doc/pcreapi.3 b/pcre/doc/pcreapi.3 index ab3eaa0b521..6e7c7c6e3ce 100644 --- a/pcre/doc/pcreapi.3 +++ b/pcre/doc/pcreapi.3 @@ -1,4 +1,4 @@ -.TH PCREAPI 3 "09 February 2014" "PCRE 8.35" +.TH PCREAPI 3 "18 December 2015" "PCRE 8.39" .SH NAME PCRE - Perl-compatible regular expressions .sp @@ -273,9 +273,8 @@ documentation for details of how to do this. It is a non-standard way of building PCRE, for use in environments that have limited stacks. Because of the greater use of memory management, it runs more slowly. Separate functions are provided so that special-purpose external code can be used for this case. When -used, these functions are always called in a stack-like manner (last obtained, -first freed), and always for memory blocks of the same size. There is a -discussion about PCRE's stack usage in the +used, these functions always allocate memory blocks of the same size. There is +a discussion about PCRE's stack usage in the .\" HREF \fBpcrestack\fP .\" @@ -2914,6 +2913,6 @@ Cambridge CB2 3QH, England. .rs .sp .nf -Last updated: 09 February 2014 -Copyright (c) 1997-2014 University of Cambridge. +Last updated: 18 December 2015 +Copyright (c) 1997-2015 University of Cambridge. .fi diff --git a/pcre/pcre_compile.c b/pcre/pcre_compile.c index 4d3b3139dea..7cd39501230 100644 --- a/pcre/pcre_compile.c +++ b/pcre/pcre_compile.c @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2014 University of Cambridge + Copyright (c) 1997-2016 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -485,7 +485,7 @@ static const char error_texts[] = "lookbehind assertion is not fixed length\0" "malformed number or name after (?(\0" "conditional group contains more than two branches\0" - "assertion expected after (?(\0" + "assertion expected after (?( or (?(?C)\0" "(?R or (?[+-]digits must be followed by )\0" /* 30 */ "unknown POSIX class name\0" @@ -560,6 +560,7 @@ static const char error_texts[] = /* 85 */ "parentheses are too deeply nested (stack check)\0" "digits missing in \\x{} or \\o{}\0" + "regular expression is too complicated\0" ; /* Table to identify digits and hex digits. This is used when compiling @@ -4566,6 +4567,10 @@ for (;; ptr++) pcre_uint32 ec; pcre_uchar mcbuffer[8]; + /* Come here to restart the loop without advancing the pointer. */ + + REDO_LOOP: + /* Get next character in the pattern */ c = *ptr; @@ -4591,7 +4596,8 @@ for (;; ptr++) if (code > cd->start_workspace + cd->workspace_size - WORK_SIZE_SAFETY_MARGIN) /* Check for overrun */ { - *errorcodeptr = ERR52; + *errorcodeptr = (code >= cd->start_workspace + cd->workspace_size)? + ERR52 : ERR87; goto FAILED; } @@ -4645,9 +4651,10 @@ for (;; ptr++) goto FAILED; } - /* If in \Q...\E, check for the end; if not, we have a literal */ + /* If in \Q...\E, check for the end; if not, we have a literal. Otherwise an + isolated \E is ignored. */ - if (inescq && c != CHAR_NULL) + if (c != CHAR_NULL) { if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E) { @@ -4655,7 +4662,7 @@ for (;; ptr++) ptr++; continue; } - else + else if (inescq) { if (previous_callout != NULL) { @@ -4670,18 +4677,27 @@ for (;; ptr++) } goto NORMAL_CHAR; } - /* Control does not reach here. */ + + /* Check for the start of a \Q...\E sequence. We must do this here rather + than later in case it is immediately followed by \E, which turns it into a + "do nothing" sequence. */ + + if (c == CHAR_BACKSLASH && ptr[1] == CHAR_Q) + { + inescq = TRUE; + ptr++; + continue; + } } - /* In extended mode, skip white space and comments. We need a loop in order - to check for more white space and more comments after a comment. */ + /* In extended mode, skip white space and comments. */ if ((options & PCRE_EXTENDED) != 0) { - for (;;) + const pcre_uchar *wscptr = ptr; + while (MAX_255(c) && (cd->ctypes[c] & ctype_space) != 0) c = *(++ptr); + if (c == CHAR_NUMBER_SIGN) { - while (MAX_255(c) && (cd->ctypes[c] & ctype_space) != 0) c = *(++ptr); - if (c != CHAR_NUMBER_SIGN) break; ptr++; while (*ptr != CHAR_NULL) { @@ -4695,8 +4711,29 @@ for (;; ptr++) if (utf) FORWARDCHAR(ptr); #endif } - c = *ptr; /* Either NULL or the char after a newline */ } + + /* If we skipped any characters, restart the loop. Otherwise, we didn't see + a comment. */ + + if (ptr > wscptr) goto REDO_LOOP; + } + + /* Skip over (?# comments. We need to do this here because we want to know if + the next thing is a quantifier, and these comments may come between an item + and its quantifier. */ + + if (c == CHAR_LEFT_PARENTHESIS && ptr[1] == CHAR_QUESTION_MARK && + ptr[2] == CHAR_NUMBER_SIGN) + { + ptr += 3; + while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++; + if (*ptr == CHAR_NULL) + { + *errorcodeptr = ERR18; + goto FAILED; + } + continue; } /* See if the next thing is a quantifier. */ @@ -4820,15 +4857,15 @@ for (;; ptr++) if (STRNCMP_UC_C8(ptr+1, STRING_WEIRD_STARTWORD, 6) == 0) { nestptr = ptr + 7; - ptr = sub_start_of_word - 1; - continue; + ptr = sub_start_of_word; + goto REDO_LOOP; } if (STRNCMP_UC_C8(ptr+1, STRING_WEIRD_ENDWORD, 6) == 0) { nestptr = ptr + 7; - ptr = sub_end_of_word - 1; - continue; + ptr = sub_end_of_word; + goto REDO_LOOP; } /* Handle a real character class. */ @@ -5046,20 +5083,22 @@ for (;; ptr++) ptr = tempptr + 1; continue; - /* For the other POSIX classes (ascii, xdigit) we are going to fall - through to the non-UCP case and build a bit map for characters with - code points less than 256. If we are in a negated POSIX class - within a non-negated overall class, characters with code points - greater than 255 must all match. In the special case where we have - not yet generated any xclass data, and this is the final item in - the overall class, we need do nothing: later on, the opcode + /* For the other POSIX classes (ascii, cntrl, xdigit) we are going + to fall through to the non-UCP case and build a bit map for + characters with code points less than 256. If we are in a negated + POSIX class, characters with code points greater than 255 must + either all match or all not match. In the special case where we + have not yet generated any xclass data, and this is the final item + in the overall class, we need do nothing: later on, the opcode OP_NCLASS will be used to indicate that characters greater than 255 are acceptable. If we have already seen an xclass item or one may follow (we have to assume that it might if this is not the end of - the class), explicitly match all wide codepoints. */ + the class), explicitly list all wide codepoints, which will then + either not match or match, depending on whether the class is or is + not negated. */ default: - if (!negate_class && local_negate && + if (local_negate && (xclass || tempptr[2] != CHAR_RIGHT_SQUARE_BRACKET)) { *class_uchardata++ = XCL_RANGE; @@ -6529,21 +6568,6 @@ for (;; ptr++) case CHAR_LEFT_PARENTHESIS: ptr++; - /* First deal with comments. Putting this code right at the start ensures - that comments have no bad side effects. */ - - if (ptr[0] == CHAR_QUESTION_MARK && ptr[1] == CHAR_NUMBER_SIGN) - { - ptr += 2; - while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++; - if (*ptr == CHAR_NULL) - { - *errorcodeptr = ERR18; - goto FAILED; - } - continue; - } - /* Now deal with various "verbs" that can be introduced by '*'. */ if (ptr[0] == CHAR_ASTERISK && (ptr[1] == ':' @@ -6604,8 +6628,21 @@ for (;; ptr++) cd->had_accept = TRUE; for (oc = cd->open_caps; oc != NULL; oc = oc->next) { - *code++ = OP_CLOSE; - PUT2INC(code, 0, oc->number); + if (lengthptr != NULL) + { +#ifdef COMPILE_PCRE8 + *lengthptr += 1 + IMM2_SIZE; +#elif defined COMPILE_PCRE16 + *lengthptr += 2 + IMM2_SIZE; +#elif defined COMPILE_PCRE32 + *lengthptr += 4 + IMM2_SIZE; +#endif + } + else + { + *code++ = OP_CLOSE; + PUT2INC(code, 0, oc->number); + } } setverb = *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT; @@ -6734,6 +6771,15 @@ for (;; ptr++) for (i = 3;; i++) if (!IS_DIGIT(ptr[i])) break; if (ptr[i] == CHAR_RIGHT_PARENTHESIS) tempptr += i + 1; + + /* tempptr should now be pointing to the opening parenthesis of the + assertion condition. */ + + if (*tempptr != CHAR_LEFT_PARENTHESIS) + { + *errorcodeptr = ERR28; + goto FAILED; + } } /* For conditions that are assertions, check the syntax, and then exit @@ -7258,7 +7304,7 @@ for (;; ptr++) issue is fixed "properly" in PCRE2. As PCRE1 is now in maintenance only mode, we finesse the bug by allowing more memory always. */ - *lengthptr += 2 + 2*LINK_SIZE; + *lengthptr += 4 + 4*LINK_SIZE; /* It is even worse than that. The current reference may be to an existing named group with a different number (so apparently not @@ -7274,7 +7320,12 @@ for (;; ptr++) so far in order to get the number. If the name is not found, leave the value of recno as 0 for a forward reference. */ - else + /* This patch (removing "else") fixes a problem when a reference is + to multiple identically named nested groups from within the nest. + Once again, it is not the "proper" fix, and it results in an + over-allocation of memory. */ + + /* else */ { ng = cd->named_groups; for (i = 0; i < cd->names_found; i++, ng++) @@ -7585,39 +7636,15 @@ for (;; ptr++) newoptions = (options | set) & (~unset); /* If the options ended with ')' this is not the start of a nested - group with option changes, so the options change at this level. If this - item is right at the start of the pattern, the options can be - abstracted and made external in the pre-compile phase, and ignored in - the compile phase. This can be helpful when matching -- for instance in - caseless checking of required bytes. - - If the code pointer is not (cd->start_code + 1 + LINK_SIZE), we are - definitely *not* at the start of the pattern because something has been - compiled. In the pre-compile phase, however, the code pointer can have - that value after the start, because it gets reset as code is discarded - during the pre-compile. However, this can happen only at top level - if - we are within parentheses, the starting BRA will still be present. At - any parenthesis level, the length value can be used to test if anything - has been compiled at that level. Thus, a test for both these conditions - is necessary to ensure we correctly detect the start of the pattern in - both phases. - + group with option changes, so the options change at this level. If we are not at the pattern start, reset the greedy defaults and the case value for firstchar and reqchar. */ if (*ptr == CHAR_RIGHT_PARENTHESIS) { - if (code == cd->start_code + 1 + LINK_SIZE && - (lengthptr == NULL || *lengthptr == 2 + 2*LINK_SIZE)) - { - cd->external_options = newoptions; - } - else - { - greedy_default = ((newoptions & PCRE_UNGREEDY) != 0); - greedy_non_default = greedy_default ^ 1; - req_caseopt = ((newoptions & PCRE_CASELESS) != 0)? REQ_CASELESS:0; - } + greedy_default = ((newoptions & PCRE_UNGREEDY) != 0); + greedy_non_default = greedy_default ^ 1; + req_caseopt = ((newoptions & PCRE_CASELESS) != 0)? REQ_CASELESS:0; /* Change options at this level, and pass them back for use in subsequent branches. */ @@ -7896,16 +7923,6 @@ for (;; ptr++) c = ec; else { - if (escape == ESC_Q) /* Handle start of quoted string */ - { - if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E) - ptr += 2; /* avoid empty string */ - else inescq = TRUE; - continue; - } - - if (escape == ESC_E) continue; /* Perl ignores an orphan \E */ - /* For metasequences that actually match a character, we disable the setting of a first character if it hasn't already been set. */ diff --git a/pcre/pcre_get.c b/pcre/pcre_get.c index 8094b34bbfb..9475d5e88cd 100644 --- a/pcre/pcre_get.c +++ b/pcre/pcre_get.c @@ -250,6 +250,7 @@ Arguments: code the compiled regex stringname the name of the capturing substring ovector the vector of matched substrings + stringcount number of captured substrings Returns: the number of the first that is set, or the number of the last one if none are set, @@ -258,13 +259,16 @@ Returns: the number of the first that is set, #if defined COMPILE_PCRE8 static int -get_first_set(const pcre *code, const char *stringname, int *ovector) +get_first_set(const pcre *code, const char *stringname, int *ovector, + int stringcount) #elif defined COMPILE_PCRE16 static int -get_first_set(const pcre16 *code, PCRE_SPTR16 stringname, int *ovector) +get_first_set(const pcre16 *code, PCRE_SPTR16 stringname, int *ovector, + int stringcount) #elif defined COMPILE_PCRE32 static int -get_first_set(const pcre32 *code, PCRE_SPTR32 stringname, int *ovector) +get_first_set(const pcre32 *code, PCRE_SPTR32 stringname, int *ovector, + int stringcount) #endif { const REAL_PCRE *re = (const REAL_PCRE *)code; @@ -295,7 +299,7 @@ if (entrysize <= 0) return entrysize; for (entry = (pcre_uchar *)first; entry <= (pcre_uchar *)last; entry += entrysize) { int n = GET2(entry, 0); - if (ovector[n*2] >= 0) return n; + if (n < stringcount && ovector[n*2] >= 0) return n; } return GET2(entry, 0); } @@ -402,7 +406,7 @@ pcre32_copy_named_substring(const pcre32 *code, PCRE_SPTR32 subject, PCRE_UCHAR32 *buffer, int size) #endif { -int n = get_first_set(code, stringname, ovector); +int n = get_first_set(code, stringname, ovector, stringcount); if (n <= 0) return n; #if defined COMPILE_PCRE8 return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size); @@ -457,7 +461,10 @@ pcre_uchar **stringlist; pcre_uchar *p; for (i = 0; i < double_count; i += 2) - size += sizeof(pcre_uchar *) + IN_UCHARS(ovector[i+1] - ovector[i] + 1); + { + size += sizeof(pcre_uchar *) + IN_UCHARS(1); + if (ovector[i+1] > ovector[i]) size += IN_UCHARS(ovector[i+1] - ovector[i]); + } stringlist = (pcre_uchar **)(PUBL(malloc))(size); if (stringlist == NULL) return PCRE_ERROR_NOMEMORY; @@ -473,7 +480,7 @@ p = (pcre_uchar *)(stringlist + stringcount + 1); for (i = 0; i < double_count; i += 2) { - int len = ovector[i+1] - ovector[i]; + int len = (ovector[i+1] > ovector[i])? (ovector[i+1] - ovector[i]) : 0; memcpy(p, subject + ovector[i], IN_UCHARS(len)); *stringlist++ = p; p += len; @@ -619,7 +626,7 @@ pcre32_get_named_substring(const pcre32 *code, PCRE_SPTR32 subject, PCRE_SPTR32 *stringptr) #endif { -int n = get_first_set(code, stringname, ovector); +int n = get_first_set(code, stringname, ovector, stringcount); if (n <= 0) return n; #if defined COMPILE_PCRE8 return pcre_get_substring(subject, ovector, stringcount, n, stringptr); diff --git a/pcre/pcre_internal.h b/pcre/pcre_internal.h index f7a5ee7aa6f..2923b29f82d 100644 --- a/pcre/pcre_internal.h +++ b/pcre/pcre_internal.h @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2014 University of Cambridge + Copyright (c) 1997-2016 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -275,7 +275,7 @@ pcre.h(.in) and disable (comment out) this message. */ typedef pcre_uint16 pcre_uchar; #define UCHAR_SHIFT (1) -#define IN_UCHARS(x) ((x) << UCHAR_SHIFT) +#define IN_UCHARS(x) ((x) * 2) #define MAX_255(c) ((c) <= 255u) #define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default)) @@ -283,7 +283,7 @@ typedef pcre_uint16 pcre_uchar; typedef pcre_uint32 pcre_uchar; #define UCHAR_SHIFT (2) -#define IN_UCHARS(x) ((x) << UCHAR_SHIFT) +#define IN_UCHARS(x) ((x) * 4) #define MAX_255(c) ((c) <= 255u) #define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default)) @@ -2289,7 +2289,7 @@ enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59, ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, - ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERRCOUNT }; + ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERR87, ERRCOUNT }; /* JIT compiling modes. The function list is indexed by them. */ diff --git a/pcre/pcre_jit_compile.c b/pcre/pcre_jit_compile.c index 445de0cbefe..4f15a27ac28 100644 --- a/pcre/pcre_jit_compile.c +++ b/pcre/pcre_jit_compile.c @@ -168,13 +168,13 @@ typedef struct jit_arguments { pcre_uchar *mark_ptr; void *callout_data; /* Everything else after. */ - pcre_uint32 limit_match; + sljit_u32 limit_match; int real_offset_count; int offset_count; - pcre_uint8 notbol; - pcre_uint8 noteol; - pcre_uint8 notempty; - pcre_uint8 notempty_atstart; + sljit_u8 notbol; + sljit_u8 noteol; + sljit_u8 notempty; + sljit_u8 notempty_atstart; } jit_arguments; typedef struct executable_functions { @@ -183,8 +183,8 @@ typedef struct executable_functions { sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES]; PUBL(jit_callback) callback; void *userdata; - pcre_uint32 top_bracket; - pcre_uint32 limit_match; + sljit_u32 top_bracket; + sljit_u32 limit_match; } executable_functions; typedef struct jump_list { @@ -277,11 +277,25 @@ typedef struct braminzero_backtrack { struct sljit_label *matchingpath; } braminzero_backtrack; -typedef struct iterator_backtrack { +typedef struct char_iterator_backtrack { backtrack_common common; /* Next iteration. */ struct sljit_label *matchingpath; -} iterator_backtrack; + union { + jump_list *backtracks; + struct { + unsigned int othercasebit; + pcre_uchar chr; + BOOL enabled; + } charpos; + } u; +} char_iterator_backtrack; + +typedef struct ref_iterator_backtrack { + backtrack_common common; + /* Next iteration. */ + struct sljit_label *matchingpath; +} ref_iterator_backtrack; typedef struct recurse_entry { struct recurse_entry *next; @@ -321,40 +335,46 @@ typedef struct compiler_common { /* First byte code. */ pcre_uchar *start; /* Maps private data offset to each opcode. */ - sljit_si *private_data_ptrs; + sljit_s32 *private_data_ptrs; /* Chain list of read-only data ptrs. */ void *read_only_data_head; /* Tells whether the capturing bracket is optimized. */ - pcre_uint8 *optimized_cbracket; + sljit_u8 *optimized_cbracket; /* Tells whether the starting offset is a target of then. */ - pcre_uint8 *then_offsets; + sljit_u8 *then_offsets; /* Current position where a THEN must jump. */ then_trap_backtrack *then_trap; /* Starting offset of private data for capturing brackets. */ - int cbra_ptr; + sljit_s32 cbra_ptr; /* Output vector starting point. Must be divisible by 2. */ - int ovector_start; + sljit_s32 ovector_start; + /* Points to the starting character of the current match. */ + sljit_s32 start_ptr; /* Last known position of the requested byte. */ - int req_char_ptr; + sljit_s32 req_char_ptr; /* Head of the last recursion. */ - int recursive_head_ptr; - /* First inspected character for partial matching. */ - int start_used_ptr; + sljit_s32 recursive_head_ptr; + /* First inspected character for partial matching. + (Needed for avoiding zero length partial matches.) */ + sljit_s32 start_used_ptr; /* Starting pointer for partial soft matches. */ - int hit_start; - /* End pointer of the first line. */ - int first_line_end; + sljit_s32 hit_start; + /* Pointer of the match end position. */ + sljit_s32 match_end_ptr; /* Points to the marked string. */ - int mark_ptr; + sljit_s32 mark_ptr; /* Recursive control verb management chain. */ - int control_head_ptr; + sljit_s32 control_head_ptr; /* Points to the last matched capture block index. */ - int capture_last_ptr; - /* Points to the starting position of the current match. */ - int start_ptr; + sljit_s32 capture_last_ptr; + /* Fast forward skipping byte code pointer. */ + pcre_uchar *fast_forward_bc_ptr; + /* Locals used by fast fail optimization. */ + sljit_s32 fast_fail_start_ptr; + sljit_s32 fast_fail_end_ptr; /* Flipped and lower case tables. */ - const pcre_uint8 *fcc; + const sljit_u8 *fcc; sljit_sw lcc; /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */ int mode; @@ -366,20 +386,20 @@ typedef struct compiler_common { BOOL has_skip_arg; /* (*THEN) is found in the pattern. */ BOOL has_then; - /* Needs to know the start position anytime. */ - BOOL needs_start_ptr; + /* (*SKIP) or (*SKIP:arg) is found in lookbehind assertion. */ + BOOL has_skip_in_assert_back; /* Currently in recurse or negative assert. */ BOOL local_exit; /* Currently in a positive assert. */ BOOL positive_assert; /* Newline control. */ int nltype; - pcre_uint32 nlmax; - pcre_uint32 nlmin; + sljit_u32 nlmax; + sljit_u32 nlmin; int newline; int bsr_nltype; - pcre_uint32 bsr_nlmax; - pcre_uint32 bsr_nlmin; + sljit_u32 bsr_nlmax; + sljit_u32 bsr_nlmin; /* Dollar endonly. */ int endonly; /* Tables. */ @@ -419,6 +439,7 @@ typedef struct compiler_common { BOOL utf; #ifdef SUPPORT_UCP BOOL use_ucp; + jump_list *getucd; #endif #ifdef COMPILE_PCRE8 jump_list *utfreadchar; @@ -426,9 +447,6 @@ typedef struct compiler_common { jump_list *utfreadtype8; #endif #endif /* SUPPORT_UTF */ -#ifdef SUPPORT_UCP - jump_list *getucd; -#endif } compiler_common; /* For byte_sequence_compare. */ @@ -439,27 +457,27 @@ typedef struct compare_context { #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED int ucharptr; union { - sljit_si asint; - sljit_uh asushort; + sljit_s32 asint; + sljit_u16 asushort; #if defined COMPILE_PCRE8 - sljit_ub asbyte; - sljit_ub asuchars[4]; + sljit_u8 asbyte; + sljit_u8 asuchars[4]; #elif defined COMPILE_PCRE16 - sljit_uh asuchars[2]; + sljit_u16 asuchars[2]; #elif defined COMPILE_PCRE32 - sljit_ui asuchars[1]; + sljit_u32 asuchars[1]; #endif } c; union { - sljit_si asint; - sljit_uh asushort; + sljit_s32 asint; + sljit_u16 asushort; #if defined COMPILE_PCRE8 - sljit_ub asbyte; - sljit_ub asuchars[4]; + sljit_u8 asbyte; + sljit_u8 asuchars[4]; #elif defined COMPILE_PCRE16 - sljit_uh asuchars[2]; + sljit_u16 asuchars[2]; #elif defined COMPILE_PCRE32 - sljit_ui asuchars[1]; + sljit_u32 asuchars[1]; #endif } oc; #endif @@ -501,14 +519,14 @@ the start pointers when the end of the capturing group has not yet reached. */ #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start]) #if defined COMPILE_PCRE8 -#define MOV_UCHAR SLJIT_MOV_UB -#define MOVU_UCHAR SLJIT_MOVU_UB +#define MOV_UCHAR SLJIT_MOV_U8 +#define MOVU_UCHAR SLJIT_MOVU_U8 #elif defined COMPILE_PCRE16 -#define MOV_UCHAR SLJIT_MOV_UH -#define MOVU_UCHAR SLJIT_MOVU_UH +#define MOV_UCHAR SLJIT_MOV_U16 +#define MOVU_UCHAR SLJIT_MOVU_U16 #elif defined COMPILE_PCRE32 -#define MOV_UCHAR SLJIT_MOV_UI -#define MOVU_UCHAR SLJIT_MOVU_UI +#define MOV_UCHAR SLJIT_MOV_U32 +#define MOVU_UCHAR SLJIT_MOVU_U32 #else #error Unsupported compiling mode #endif @@ -564,11 +582,6 @@ SLJIT_ASSERT(*cc >= OP_KET && *cc <= OP_KETRPOS); return count; } -static int ones_in_half_byte[16] = { - /* 0 */ 0, 1, 1, 2, /* 4 */ 1, 2, 2, 3, - /* 8 */ 1, 2, 2, 3, /* 12 */ 2, 3, 3, 4 -}; - /* Functions whose might need modification for all new supported opcodes: next_opcode check_opcode_types @@ -780,6 +793,7 @@ static BOOL check_opcode_types(compiler_common *common, pcre_uchar *cc, pcre_uch { int count; pcre_uchar *slot; +pcre_uchar *assert_back_end = cc - 1; /* Calculate important variables (like stack size) and checks whether all opcodes are supported. */ while (cc < ccend) @@ -850,15 +864,19 @@ while (cc < ccend) cc += 2 + 2 * LINK_SIZE; break; + case OP_ASSERTBACK: + slot = bracketend(cc); + if (slot > assert_back_end) + assert_back_end = slot; + cc += 1 + LINK_SIZE; + break; + case OP_THEN_ARG: common->has_then = TRUE; common->control_head_ptr = 1; /* Fall through. */ case OP_PRUNE_ARG: - common->needs_start_ptr = TRUE; - /* Fall through. */ - case OP_MARK: if (common->mark_ptr == 0) { @@ -871,17 +889,20 @@ while (cc < ccend) case OP_THEN: common->has_then = TRUE; common->control_head_ptr = 1; - /* Fall through. */ + cc += 1; + break; - case OP_PRUNE: case OP_SKIP: - common->needs_start_ptr = TRUE; + if (cc < assert_back_end) + common->has_skip_in_assert_back = TRUE; cc += 1; break; case OP_SKIP_ARG: common->control_head_ptr = 1; common->has_skip_arg = TRUE; + if (cc < assert_back_end) + common->has_skip_in_assert_back = TRUE; cc += 1 + 2 + cc[1]; break; @@ -895,8 +916,189 @@ while (cc < ccend) return TRUE; } +static BOOL is_accelerated_repeat(pcre_uchar *cc) +{ +switch(*cc) + { + case OP_TYPESTAR: + case OP_TYPEMINSTAR: + case OP_TYPEPLUS: + case OP_TYPEMINPLUS: + case OP_TYPEPOSSTAR: + case OP_TYPEPOSPLUS: + return (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI); + + case OP_STAR: + case OP_MINSTAR: + case OP_PLUS: + case OP_MINPLUS: + case OP_POSSTAR: + case OP_POSPLUS: + + case OP_STARI: + case OP_MINSTARI: + case OP_PLUSI: + case OP_MINPLUSI: + case OP_POSSTARI: + case OP_POSPLUSI: + + case OP_NOTSTAR: + case OP_NOTMINSTAR: + case OP_NOTPLUS: + case OP_NOTMINPLUS: + case OP_NOTPOSSTAR: + case OP_NOTPOSPLUS: + + case OP_NOTSTARI: + case OP_NOTMINSTARI: + case OP_NOTPLUSI: + case OP_NOTMINPLUSI: + case OP_NOTPOSSTARI: + case OP_NOTPOSPLUSI: + return TRUE; + + case OP_CLASS: + case OP_NCLASS: +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + case OP_XCLASS: + cc += (*cc == OP_XCLASS) ? GET(cc, 1) : (int)(1 + (32 / sizeof(pcre_uchar))); +#else + cc += (1 + (32 / sizeof(pcre_uchar))); +#endif + + switch(*cc) + { + case OP_CRSTAR: + case OP_CRMINSTAR: + case OP_CRPLUS: + case OP_CRMINPLUS: + case OP_CRPOSSTAR: + case OP_CRPOSPLUS: + return TRUE; + } + break; + } +return FALSE; +} + +static SLJIT_INLINE BOOL detect_fast_forward_skip(compiler_common *common, int *private_data_start) +{ +pcre_uchar *cc = common->start; +pcre_uchar *end; + +/* Skip not repeated brackets. */ +while (TRUE) + { + switch(*cc) + { + case OP_SOD: + case OP_SOM: + case OP_SET_SOM: + case OP_NOT_WORD_BOUNDARY: + case OP_WORD_BOUNDARY: + case OP_EODN: + case OP_EOD: + case OP_CIRC: + case OP_CIRCM: + case OP_DOLL: + case OP_DOLLM: + /* Zero width assertions. */ + cc++; + continue; + } + + if (*cc != OP_BRA && *cc != OP_CBRA) + break; + + end = cc + GET(cc, 1); + if (*end != OP_KET || PRIVATE_DATA(end) != 0) + return FALSE; + if (*cc == OP_CBRA) + { + if (common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0) + return FALSE; + cc += IMM2_SIZE; + } + cc += 1 + LINK_SIZE; + } + +if (is_accelerated_repeat(cc)) + { + common->fast_forward_bc_ptr = cc; + common->private_data_ptrs[(cc + 1) - common->start] = *private_data_start; + *private_data_start += sizeof(sljit_sw); + return TRUE; + } +return FALSE; +} + +static SLJIT_INLINE void detect_fast_fail(compiler_common *common, pcre_uchar *cc, int *private_data_start, sljit_s32 depth) +{ + pcre_uchar *next_alt; + + SLJIT_ASSERT(*cc == OP_BRA || *cc == OP_CBRA); + + if (*cc == OP_CBRA && common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0) + return; + + next_alt = bracketend(cc) - (1 + LINK_SIZE); + if (*next_alt != OP_KET || PRIVATE_DATA(next_alt) != 0) + return; + + do + { + next_alt = cc + GET(cc, 1); + + cc += 1 + LINK_SIZE + ((*cc == OP_CBRA) ? IMM2_SIZE : 0); + + while (TRUE) + { + switch(*cc) + { + case OP_SOD: + case OP_SOM: + case OP_SET_SOM: + case OP_NOT_WORD_BOUNDARY: + case OP_WORD_BOUNDARY: + case OP_EODN: + case OP_EOD: + case OP_CIRC: + case OP_CIRCM: + case OP_DOLL: + case OP_DOLLM: + /* Zero width assertions. */ + cc++; + continue; + } + break; + } + + if (depth > 0 && (*cc == OP_BRA || *cc == OP_CBRA)) + detect_fast_fail(common, cc, private_data_start, depth - 1); + + if (is_accelerated_repeat(cc)) + { + common->private_data_ptrs[(cc + 1) - common->start] = *private_data_start; + + if (common->fast_fail_start_ptr == 0) + common->fast_fail_start_ptr = *private_data_start; + + *private_data_start += sizeof(sljit_sw); + common->fast_fail_end_ptr = *private_data_start; + + if (*private_data_start > SLJIT_MAX_LOCAL_SIZE) + return; + } + + cc = next_alt; + } + while (*cc == OP_ALT); +} + static int get_class_iterator_size(pcre_uchar *cc) { +sljit_u32 min; +sljit_u32 max; switch(*cc) { case OP_CRSTAR: @@ -911,9 +1113,14 @@ switch(*cc) case OP_CRRANGE: case OP_CRMINRANGE: - if (GET2(cc, 1) == GET2(cc, 1 + IMM2_SIZE)) - return 0; - return 2; + min = GET2(cc, 1); + max = GET2(cc, 1 + IMM2_SIZE); + if (max == 0) + return (*cc == OP_CRRANGE) ? 2 : 1; + max -= min; + if (max > 2) + max = 2; + return max; default: return 0; @@ -1186,14 +1393,14 @@ while (cc < ccend) case OP_CLASS: case OP_NCLASS: - size += 1 + 32 / sizeof(pcre_uchar); space = get_class_iterator_size(cc + size); + size = 1 + 32 / sizeof(pcre_uchar); break; #if defined SUPPORT_UTF || !defined COMPILE_PCRE8 case OP_XCLASS: - size = GET(cc, 1); space = get_class_iterator_size(cc + size); + size = GET(cc, 1); break; #endif @@ -1406,6 +1613,7 @@ while (cc < ccend) case OP_CLASS: case OP_NCLASS: case OP_XCLASS: + case OP_CALLOUT: cc = next_opcode(common, cc); SLJIT_ASSERT(cc != NULL); @@ -1990,7 +2198,7 @@ if (save) SLJIT_ASSERT(cc == ccend && stackptr == stacktop && (save || (tmp1empty && tmp2empty))); } -static SLJIT_INLINE pcre_uchar *set_then_offsets(compiler_common *common, pcre_uchar *cc, pcre_uint8 *current_offset) +static SLJIT_INLINE pcre_uchar *set_then_offsets(compiler_common *common, pcre_uchar *cc, sljit_u8 *current_offset) { pcre_uchar *end = bracketend(cc); BOOL has_alternatives = cc[GET(cc, 1)] == OP_ALT; @@ -2113,6 +2321,7 @@ static SLJIT_INLINE void allocate_stack(compiler_common *common, int size) /* May destroy all locals and registers except TMP2. */ DEFINE_COMPILER; +SLJIT_ASSERT(size > 0); OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw)); #ifdef DESTROY_REGISTERS OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345); @@ -2127,6 +2336,8 @@ add_stub(common, CMP(SLJIT_GREATER, STACK_TOP, 0, STACK_LIMIT, 0)); static SLJIT_INLINE void free_stack(compiler_common *common, int size) { DEFINE_COMPILER; + +SLJIT_ASSERT(size > 0); OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw)); } @@ -2190,6 +2401,18 @@ else } } +static SLJIT_INLINE void reset_fast_fail(compiler_common *common) +{ +DEFINE_COMPILER; +sljit_s32 i; + +SLJIT_ASSERT(common->fast_fail_start_ptr < common->fast_fail_end_ptr); + +OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +for (i = common->fast_fail_start_ptr; i < common->fast_fail_end_ptr; i += sizeof(sljit_sw)) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), i, TMP1, 0); +} + static SLJIT_INLINE void do_reset_match(compiler_common *common, int length) { DEFINE_COMPILER; @@ -2262,7 +2485,7 @@ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(1), STR_PTR, 0); OP1(SLJIT_MOV, SLJIT_R0, 0, ARGUMENTS, 0); if (common->mark_ptr != 0) OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr); -OP1(SLJIT_MOV_SI, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, offset_count)); +OP1(SLJIT_MOV_S32, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, offset_count)); if (common->mark_ptr != 0) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_R2, 0); OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, offsets), SLJIT_IMM, sizeof(int)); @@ -2277,7 +2500,7 @@ OP2(SLJIT_ADD, SLJIT_S0, 0, SLJIT_S0, 0, SLJIT_IMM, sizeof(sljit_sw)); #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_R2), sizeof(int), SLJIT_S1, 0); +OP1(SLJIT_MOVU_S32, SLJIT_MEM1(SLJIT_R2), sizeof(int), SLJIT_S1, 0); OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1); JUMPTO(SLJIT_NOT_ZERO, loop); JUMPHERE(early_quit); @@ -2310,7 +2533,7 @@ SLJIT_ASSERT(common->start_used_ptr != 0 && common->start_ptr != 0 OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_PARTIAL); -OP1(SLJIT_MOV_SI, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, real_offset_count)); +OP1(SLJIT_MOV_S32, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, real_offset_count)); CMPTO(SLJIT_SIG_LESS, SLJIT_R2, 0, SLJIT_IMM, 2, quit); /* Store match begin and end. */ @@ -2322,7 +2545,7 @@ OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == JIT_PARTIAL_HA #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 OP2(SLJIT_ASHR, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), 2 * sizeof(int), SLJIT_R2, 0); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(SLJIT_R1), 2 * sizeof(int), SLJIT_R2, 0); JUMPHERE(jump); OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_used_ptr : common->hit_start); @@ -2330,13 +2553,13 @@ OP2(SLJIT_SUB, SLJIT_S1, 0, STR_END, 0, SLJIT_S0, 0); #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), sizeof(int), SLJIT_S1, 0); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(SLJIT_R1), sizeof(int), SLJIT_S1, 0); OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_S0, 0); #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 OP2(SLJIT_ASHR, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R2, 0); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R2, 0); JUMPTO(SLJIT_JUMP, quit); } @@ -2573,7 +2796,7 @@ else JUMPHERE(jump); } -static void peek_char(compiler_common *common, pcre_uint32 max) +static void peek_char(compiler_common *common, sljit_u32 max) { /* Reads the character into TMP1, keeps STR_PTR. Does not check STR_END. TMP2 Destroyed. */ @@ -2618,12 +2841,12 @@ if (common->utf) #if defined SUPPORT_UTF && defined COMPILE_PCRE8 -static BOOL is_char7_bitset(const pcre_uint8 *bitset, BOOL nclass) +static BOOL is_char7_bitset(const sljit_u8 *bitset, BOOL nclass) { /* Tells whether the character codes below 128 are enough to determine a match. */ -const pcre_uint8 value = nclass ? 0xff : 0; -const pcre_uint8 *end = bitset + 32; +const sljit_u8 value = nclass ? 0xff : 0; +const sljit_u8 *end = bitset + 32; bitset += 16; do @@ -2648,12 +2871,12 @@ SLJIT_ASSERT(common->utf); OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); if (full_read) { jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xc0); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); JUMPHERE(jump); } @@ -2661,7 +2884,7 @@ if (full_read) #endif /* SUPPORT_UTF && COMPILE_PCRE8 */ -static void read_char_range(compiler_common *common, pcre_uint32 min, pcre_uint32 max, BOOL update_str_ptr) +static void read_char_range(compiler_common *common, sljit_u32 min, sljit_u32 max, BOOL update_str_ptr) { /* Reads the precise value of a character into TMP1, if the character is between min and max (c >= min && c <= max). Otherwise it returns with a value @@ -2692,7 +2915,7 @@ if (common->utf) { OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xf0); if (update_str_ptr) - OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0x7); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); @@ -2716,7 +2939,7 @@ if (common->utf) { OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xe0); if (update_str_ptr) - OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0xf); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); @@ -2736,7 +2959,7 @@ if (common->utf) add_jump(compiler, (max < 0x10000) ? &common->utfreadchar16 : &common->utfreadchar, JUMP(SLJIT_FAST_CALL)); else if (max < 128) { - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); } else @@ -2745,7 +2968,7 @@ if (common->utf) if (!update_str_ptr) OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); else - OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); @@ -2815,7 +3038,7 @@ if (common->utf) { /* This can be an extra read in some situations, but hopefully it is needed in most cases. */ - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xc0); if (!update_str_ptr) { @@ -2827,7 +3050,7 @@ if (common->utf) OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); JUMPHERE(jump2); } else @@ -2842,7 +3065,7 @@ if (common->utf) OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); jump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255); #endif -OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); #if !defined COMPILE_PCRE8 JUMPHERE(jump); #endif @@ -3034,7 +3257,7 @@ compare = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0x3); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0); -OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); JUMPHERE(compare); @@ -3043,7 +3266,7 @@ sljit_emit_fast_return(compiler, RETURN_ADDR, 0); /* We only have types for characters less than 256. */ JUMPHERE(jump); -OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); +OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); @@ -3069,26 +3292,26 @@ SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && sizeof(ucd_record) == 8); sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT); -OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1)); +OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1)); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2)); -OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1); +OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype)); -OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); } #endif -static SLJIT_INLINE struct sljit_label *mainloop_entry(compiler_common *common, BOOL hascrorlf, BOOL firstline) +static SLJIT_INLINE struct sljit_label *mainloop_entry(compiler_common *common, BOOL hascrorlf) { DEFINE_COMPILER; struct sljit_label *mainloop; struct sljit_label *newlinelabel = NULL; struct sljit_jump *start; struct sljit_jump *end = NULL; -struct sljit_jump *nl = NULL; +struct sljit_jump *end2 = NULL; #if defined SUPPORT_UTF && !defined COMPILE_PCRE32 struct sljit_jump *singlechar; #endif @@ -3096,14 +3319,13 @@ jump_list *newline = NULL; BOOL newlinecheck = FALSE; BOOL readuchar = FALSE; -if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY || - common->nltype == NLTYPE_ANYCRLF || common->newline > 255)) +if (!(hascrorlf || (common->match_end_ptr != 0)) && + (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF || common->newline > 255)) newlinecheck = TRUE; -if (firstline) +if (common->match_end_ptr != 0) { /* Search for the end of the first line. */ - SLJIT_ASSERT(common->first_line_end != 0); OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0); if (common->nltype == NLTYPE_FIXED && common->newline > 255) @@ -3116,19 +3338,19 @@ if (firstline) CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop); CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop); JUMPHERE(end); - OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); } else { end = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); mainloop = LABEL(); /* Continual stores does not cause data dependency. */ - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0); + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, STR_PTR, 0); read_char_range(common, common->nlmin, common->nlmax, TRUE); check_newlinechar(common, common->nltype, &newline, TRUE); CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop); JUMPHERE(end); - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0); + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, STR_PTR, 0); set_jumps(newline, LABEL()); } @@ -3149,7 +3371,7 @@ if (newlinecheck) OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); - nl = JUMP(SLJIT_JUMP); + end2 = JUMP(SLJIT_JUMP); } mainloop = LABEL(); @@ -3172,7 +3394,7 @@ OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); if (common->utf) { singlechar = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); JUMPHERE(singlechar); } @@ -3194,51 +3416,52 @@ JUMPHERE(start); if (newlinecheck) { JUMPHERE(end); - JUMPHERE(nl); + JUMPHERE(end2); } return mainloop; } #define MAX_N_CHARS 16 -#define MAX_N_BYTES 8 +#define MAX_DIFF_CHARS 6 -static SLJIT_INLINE void add_prefix_byte(pcre_uint8 byte, pcre_uint8 *bytes) +static SLJIT_INLINE void add_prefix_char(pcre_uchar chr, pcre_uchar *chars) { -pcre_uint8 len = bytes[0]; -int i; +pcre_uchar i, len; +len = chars[0]; if (len == 255) return; if (len == 0) { - bytes[0] = 1; - bytes[1] = byte; + chars[0] = 1; + chars[1] = chr; return; } for (i = len; i > 0; i--) - if (bytes[i] == byte) + if (chars[i] == chr) return; -if (len >= MAX_N_BYTES - 1) +if (len >= MAX_DIFF_CHARS - 1) { - bytes[0] = 255; + chars[0] = 255; return; } len++; -bytes[len] = byte; -bytes[0] = len; +chars[len] = chr; +chars[0] = len; } -static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars, pcre_uint32 *rec_count) +static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uchar *chars, int max_chars, sljit_u32 *rec_count) { /* Recursive function, which scans prefix literals. */ -BOOL last, any, caseless; +BOOL last, any, class, caseless; int len, repeat, len_save, consumed = 0; -pcre_uint32 chr, mask; +sljit_u32 chr; /* Any unicode character. */ +sljit_u8 *bytes, *bytes_end, byte; pcre_uchar *alternative, *cc_save, *oc; #if defined SUPPORT_UTF && defined COMPILE_PCRE8 pcre_uchar othercase[8]; @@ -3257,6 +3480,7 @@ while (TRUE) last = TRUE; any = FALSE; + class = FALSE; caseless = FALSE; switch (*cc) @@ -3320,7 +3544,7 @@ while (TRUE) #ifdef SUPPORT_UTF if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc); #endif - max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars, rec_count); + max_chars = scan_prefix(common, cc + len, chars, max_chars, rec_count); if (max_chars == 0) return consumed; last = FALSE; @@ -3343,7 +3567,7 @@ while (TRUE) alternative = cc + GET(cc, 1); while (*alternative == OP_ALT) { - max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars, rec_count); + max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, max_chars, rec_count); if (max_chars == 0) return consumed; alternative += GET(alternative, 1); @@ -3356,18 +3580,17 @@ while (TRUE) case OP_CLASS: #if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && !is_char7_bitset((const pcre_uint8 *)(cc + 1), FALSE)) return consumed; + if (common->utf && !is_char7_bitset((const sljit_u8 *)(cc + 1), FALSE)) + return consumed; #endif - any = TRUE; - cc += 1 + 32 / sizeof(pcre_uchar); + class = TRUE; break; case OP_NCLASS: #if defined SUPPORT_UTF && !defined COMPILE_PCRE32 if (common->utf) return consumed; #endif - any = TRUE; - cc += 1 + 32 / sizeof(pcre_uchar); + class = TRUE; break; #if defined SUPPORT_UTF || !defined COMPILE_PCRE8 @@ -3382,7 +3605,7 @@ while (TRUE) case OP_DIGIT: #if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_digit, FALSE)) + if (common->utf && !is_char7_bitset((const sljit_u8 *)common->ctypes - cbit_length + cbit_digit, FALSE)) return consumed; #endif any = TRUE; @@ -3391,7 +3614,7 @@ while (TRUE) case OP_WHITESPACE: #if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_space, FALSE)) + if (common->utf && !is_char7_bitset((const sljit_u8 *)common->ctypes - cbit_length + cbit_space, FALSE)) return consumed; #endif any = TRUE; @@ -3400,7 +3623,7 @@ while (TRUE) case OP_WORDCHAR: #if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_word, FALSE)) + if (common->utf && !is_char7_bitset((const sljit_u8 *)common->ctypes - cbit_length + cbit_word, FALSE)) return consumed; #endif any = TRUE; @@ -3423,10 +3646,10 @@ while (TRUE) cc++; break; -#ifdef SUPPORT_UCP +#ifdef SUPPORT_UTF case OP_NOTPROP: case OP_PROP: -#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +#ifndef COMPILE_PCRE32 if (common->utf) return consumed; #endif any = TRUE; @@ -3455,27 +3678,14 @@ while (TRUE) if (any) { -#if defined COMPILE_PCRE8 - mask = 0xff; -#elif defined COMPILE_PCRE16 - mask = 0xffff; -#elif defined COMPILE_PCRE32 - mask = 0xffffffff; -#else - SLJIT_ASSERT_STOP(); -#endif - do { - chars[0] = mask; - chars[1] = mask; - bytes[0] = 255; + chars[0] = 255; consumed++; if (--max_chars == 0) return consumed; - chars += 2; - bytes += MAX_N_BYTES; + chars += MAX_DIFF_CHARS; } while (--repeat > 0); @@ -3483,6 +3693,103 @@ while (TRUE) continue; } + if (class) + { + bytes = (sljit_u8*) (cc + 1); + cc += 1 + 32 / sizeof(pcre_uchar); + + switch (*cc) + { + case OP_CRSTAR: + case OP_CRMINSTAR: + case OP_CRPOSSTAR: + case OP_CRQUERY: + case OP_CRMINQUERY: + case OP_CRPOSQUERY: + max_chars = scan_prefix(common, cc + 1, chars, max_chars, rec_count); + if (max_chars == 0) + return consumed; + break; + + default: + case OP_CRPLUS: + case OP_CRMINPLUS: + case OP_CRPOSPLUS: + break; + + case OP_CRRANGE: + case OP_CRMINRANGE: + case OP_CRPOSRANGE: + repeat = GET2(cc, 1); + if (repeat <= 0) + return consumed; + break; + } + + do + { + if (bytes[31] & 0x80) + chars[0] = 255; + else if (chars[0] != 255) + { + bytes_end = bytes + 32; + chr = 0; + do + { + byte = *bytes++; + SLJIT_ASSERT((chr & 0x7) == 0); + if (byte == 0) + chr += 8; + else + { + do + { + if ((byte & 0x1) != 0) + add_prefix_char(chr, chars); + byte >>= 1; + chr++; + } + while (byte != 0); + chr = (chr + 7) & ~7; + } + } + while (chars[0] != 255 && bytes < bytes_end); + bytes = bytes_end - 32; + } + + consumed++; + if (--max_chars == 0) + return consumed; + chars += MAX_DIFF_CHARS; + } + while (--repeat > 0); + + switch (*cc) + { + case OP_CRSTAR: + case OP_CRMINSTAR: + case OP_CRPOSSTAR: + return consumed; + + case OP_CRQUERY: + case OP_CRMINQUERY: + case OP_CRPOSQUERY: + cc++; + break; + + case OP_CRRANGE: + case OP_CRMINRANGE: + case OP_CRPOSRANGE: + if (GET2(cc, 1) != GET2(cc, 1 + IMM2_SIZE)) + return consumed; + cc += 1 + 2 * IMM2_SIZE; + break; + } + + repeat = 1; + continue; + } + len = 1; #ifdef SUPPORT_UTF if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc); @@ -3505,7 +3812,10 @@ while (TRUE) } } else + { caseless = FALSE; + othercase[0] = 0; /* Stops compiler warning - PH */ + } len_save = len; cc_save = cc; @@ -3515,43 +3825,16 @@ while (TRUE) do { chr = *cc; -#ifdef COMPILE_PCRE32 - if (SLJIT_UNLIKELY(chr == NOTACHAR)) - return consumed; -#endif - add_prefix_byte((pcre_uint8)chr, bytes); + add_prefix_char(*cc, chars); - mask = 0; if (caseless) - { - add_prefix_byte((pcre_uint8)*oc, bytes); - mask = *cc ^ *oc; - chr |= mask; - } - -#ifdef COMPILE_PCRE32 - if (chars[0] == NOTACHAR && chars[1] == 0) -#else - if (chars[0] == NOTACHAR) -#endif - { - chars[0] = chr; - chars[1] = mask; - } - else - { - mask |= chars[0] ^ chr; - chr |= mask; - chars[0] = chr; - chars[1] |= mask; - } + add_prefix_char(*oc, chars); len--; consumed++; if (--max_chars == 0) return consumed; - chars += 2; - bytes += MAX_N_BYTES; + chars += MAX_DIFF_CHARS; cc++; oc++; } @@ -3570,163 +3853,576 @@ while (TRUE) } } -static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common, BOOL firstline) +#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) + +static sljit_s32 character_to_int32(pcre_uchar chr) +{ +sljit_s32 value = (sljit_s32)chr; +#if defined COMPILE_PCRE8 +#define SSE2_COMPARE_TYPE_INDEX 0 +return (value << 24) | (value << 16) | (value << 8) | value; +#elif defined COMPILE_PCRE16 +#define SSE2_COMPARE_TYPE_INDEX 1 +return (value << 16) | value; +#elif defined COMPILE_PCRE32 +#define SSE2_COMPARE_TYPE_INDEX 2 +return value; +#else +#error "Unsupported unit width" +#endif +} + +static SLJIT_INLINE void fast_forward_first_char2_sse2(compiler_common *common, pcre_uchar char1, pcre_uchar char2) +{ +DEFINE_COMPILER; +struct sljit_label *start; +struct sljit_jump *quit[3]; +struct sljit_jump *nomatch; +sljit_u8 instruction[8]; +sljit_s32 tmp1_ind = sljit_get_register_index(TMP1); +sljit_s32 tmp2_ind = sljit_get_register_index(TMP2); +sljit_s32 str_ptr_ind = sljit_get_register_index(STR_PTR); +BOOL load_twice = FALSE; +pcre_uchar bit; + +bit = char1 ^ char2; +if (!is_powerof2(bit)) + bit = 0; + +if ((char1 != char2) && bit == 0) + load_twice = TRUE; + +quit[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); + +/* First part (unaligned start) */ + +OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1 | bit)); + +SLJIT_ASSERT(tmp1_ind < 8 && tmp2_ind == 1); + +/* MOVD xmm, r/m32 */ +instruction[0] = 0x66; +instruction[1] = 0x0f; +instruction[2] = 0x6e; +instruction[3] = 0xc0 | (2 << 3) | tmp1_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +if (char1 != char2) + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(bit != 0 ? bit : char2)); + + /* MOVD xmm, r/m32 */ + instruction[3] = 0xc0 | (3 << 3) | tmp1_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + +/* PSHUFD xmm1, xmm2/m128, imm8 */ +instruction[2] = 0x70; +instruction[3] = 0xc0 | (2 << 3) | 2; +instruction[4] = 0; +sljit_emit_op_custom(compiler, instruction, 5); + +if (char1 != char2) + { + /* PSHUFD xmm1, xmm2/m128, imm8 */ + instruction[3] = 0xc0 | (3 << 3) | 3; + instruction[4] = 0; + sljit_emit_op_custom(compiler, instruction, 5); + } + +OP2(SLJIT_AND, TMP2, 0, STR_PTR, 0, SLJIT_IMM, 0xf); +OP2(SLJIT_AND, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, ~0xf); + +/* MOVDQA xmm1, xmm2/m128 */ +#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) + +if (str_ptr_ind < 8) + { + instruction[2] = 0x6f; + instruction[3] = (0 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 4); + + if (load_twice) + { + instruction[3] = (1 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + } +else + { + instruction[1] = 0x41; + instruction[2] = 0x0f; + instruction[3] = 0x6f; + instruction[4] = (0 << 3) | (str_ptr_ind & 0x7); + sljit_emit_op_custom(compiler, instruction, 5); + + if (load_twice) + { + instruction[4] = (1 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 5); + } + instruction[1] = 0x0f; + } + +#else + +instruction[2] = 0x6f; +instruction[3] = (0 << 3) | str_ptr_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +if (load_twice) + { + instruction[3] = (1 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + +#endif + +if (bit != 0) + { + /* POR xmm1, xmm2/m128 */ + instruction[2] = 0xeb; + instruction[3] = 0xc0 | (0 << 3) | 3; + sljit_emit_op_custom(compiler, instruction, 4); + } + +/* PCMPEQB/W/D xmm1, xmm2/m128 */ +instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; +instruction[3] = 0xc0 | (0 << 3) | 2; +sljit_emit_op_custom(compiler, instruction, 4); + +if (load_twice) + { + instruction[3] = 0xc0 | (1 << 3) | 3; + sljit_emit_op_custom(compiler, instruction, 4); + } + +/* PMOVMSKB reg, xmm */ +instruction[2] = 0xd7; +instruction[3] = 0xc0 | (tmp1_ind << 3) | 0; +sljit_emit_op_custom(compiler, instruction, 4); + +if (load_twice) + { + OP1(SLJIT_MOV, TMP3, 0, TMP2, 0); + instruction[3] = 0xc0 | (tmp2_ind << 3) | 1; + sljit_emit_op_custom(compiler, instruction, 4); + + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + OP1(SLJIT_MOV, TMP2, 0, TMP3, 0); + } + +OP2(SLJIT_ASHR, TMP1, 0, TMP1, 0, TMP2, 0); + +/* BSF r32, r/m32 */ +instruction[0] = 0x0f; +instruction[1] = 0xbc; +instruction[2] = 0xc0 | (tmp1_ind << 3) | tmp1_ind; +sljit_emit_op_custom(compiler, instruction, 3); + +nomatch = JUMP(SLJIT_ZERO); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +quit[1] = JUMP(SLJIT_JUMP); + +JUMPHERE(nomatch); + +start = LABEL(); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); +quit[2] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); + +/* Second part (aligned) */ + +instruction[0] = 0x66; +instruction[1] = 0x0f; + +/* MOVDQA xmm1, xmm2/m128 */ +#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) + +if (str_ptr_ind < 8) + { + instruction[2] = 0x6f; + instruction[3] = (0 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 4); + + if (load_twice) + { + instruction[3] = (1 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + } +else + { + instruction[1] = 0x41; + instruction[2] = 0x0f; + instruction[3] = 0x6f; + instruction[4] = (0 << 3) | (str_ptr_ind & 0x7); + sljit_emit_op_custom(compiler, instruction, 5); + + if (load_twice) + { + instruction[4] = (1 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 5); + } + instruction[1] = 0x0f; + } + +#else + +instruction[2] = 0x6f; +instruction[3] = (0 << 3) | str_ptr_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +if (load_twice) + { + instruction[3] = (1 << 3) | str_ptr_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + +#endif + +if (bit != 0) + { + /* POR xmm1, xmm2/m128 */ + instruction[2] = 0xeb; + instruction[3] = 0xc0 | (0 << 3) | 3; + sljit_emit_op_custom(compiler, instruction, 4); + } + +/* PCMPEQB/W/D xmm1, xmm2/m128 */ +instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; +instruction[3] = 0xc0 | (0 << 3) | 2; +sljit_emit_op_custom(compiler, instruction, 4); + +if (load_twice) + { + instruction[3] = 0xc0 | (1 << 3) | 3; + sljit_emit_op_custom(compiler, instruction, 4); + } + +/* PMOVMSKB reg, xmm */ +instruction[2] = 0xd7; +instruction[3] = 0xc0 | (tmp1_ind << 3) | 0; +sljit_emit_op_custom(compiler, instruction, 4); + +if (load_twice) + { + instruction[3] = 0xc0 | (tmp2_ind << 3) | 1; + sljit_emit_op_custom(compiler, instruction, 4); + + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + } + +/* BSF r32, r/m32 */ +instruction[0] = 0x0f; +instruction[1] = 0xbc; +instruction[2] = 0xc0 | (tmp1_ind << 3) | tmp1_ind; +sljit_emit_op_custom(compiler, instruction, 3); + +JUMPTO(SLJIT_ZERO, start); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); + +start = LABEL(); +SET_LABEL(quit[0], start); +SET_LABEL(quit[1], start); +SET_LABEL(quit[2], start); +} + +#undef SSE2_COMPARE_TYPE_INDEX + +#endif + +static void fast_forward_first_char2(compiler_common *common, pcre_uchar char1, pcre_uchar char2, sljit_s32 offset) { DEFINE_COMPILER; struct sljit_label *start; struct sljit_jump *quit; -pcre_uint32 chars[MAX_N_CHARS * 2]; -pcre_uint8 bytes[MAX_N_CHARS * MAX_N_BYTES]; -pcre_uint8 ones[MAX_N_CHARS]; -int offsets[3]; -pcre_uint32 mask; -pcre_uint8 *byte_set, *byte_set_end; -int i, max, from; -int range_right = -1, range_len = 3 - 1; -sljit_ub *update_table = NULL; -BOOL in_range; -pcre_uint32 rec_count; +struct sljit_jump *found; +pcre_uchar mask; +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +struct sljit_label *utf_start = NULL; +struct sljit_jump *utf_quit = NULL; +#endif +BOOL has_match_end = (common->match_end_ptr != 0); -for (i = 0; i < MAX_N_CHARS; i++) +if (offset > 0) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); + +if (has_match_end) { - chars[i << 1] = NOTACHAR; - chars[(i << 1) + 1] = 0; - bytes[i * MAX_N_BYTES] = 0; - } + OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); -rec_count = 10000; -max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS, &rec_count); - -if (max <= 1) - return FALSE; - -for (i = 0; i < max; i++) - { - mask = chars[(i << 1) + 1]; - ones[i] = ones_in_half_byte[mask & 0xf]; - mask >>= 4; - while (mask != 0) + OP2(SLJIT_ADD, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, SLJIT_IMM, IN_UCHARS(offset + 1)); +#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) + if (sljit_x86_is_cmov_available()) { - ones[i] += ones_in_half_byte[mask & 0xf]; - mask >>= 4; + OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_END, 0, TMP3, 0); + sljit_x86_emit_cmov(compiler, SLJIT_GREATER, STR_END, TMP3, 0); + } +#endif + { + quit = CMP(SLJIT_LESS_EQUAL, STR_END, 0, TMP3, 0); + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); + JUMPHERE(quit); } } +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +if (common->utf && offset > 0) + utf_start = LABEL(); +#endif + +#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) + +/* SSE2 accelerated first character search. */ + +if (sljit_x86_is_sse2_available()) + { + fast_forward_first_char2_sse2(common, char1, char2); + + SLJIT_ASSERT(common->mode == JIT_COMPILE || offset == 0); + if (common->mode == JIT_COMPILE) + { + /* In complete mode, we don't need to run a match when STR_PTR == STR_END. */ + SLJIT_ASSERT(common->forced_quit_label == NULL); + OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH); + add_jump(compiler, &common->forced_quit, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf && offset > 0) + { + SLJIT_ASSERT(common->mode == JIT_COMPILE); + + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offset)); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +#if defined COMPILE_PCRE8 + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, utf_start); +#elif defined COMPILE_PCRE16 + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0xdc00, utf_start); +#else +#error "Unknown code width" +#endif + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + } +#endif + + if (offset > 0) + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); + } + else if (sljit_x86_is_cmov_available()) + { + OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0); + sljit_x86_emit_cmov(compiler, SLJIT_GREATER_EQUAL, STR_PTR, has_match_end ? SLJIT_MEM1(SLJIT_SP) : STR_END, has_match_end ? common->match_end_ptr : 0); + } + else + { + quit = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); + OP1(SLJIT_MOV, STR_PTR, 0, has_match_end ? SLJIT_MEM1(SLJIT_SP) : STR_END, has_match_end ? common->match_end_ptr : 0); + JUMPHERE(quit); + } + + if (has_match_end) + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); + return; + } + +#endif + +quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); + +start = LABEL(); +OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); + +if (char1 == char2) + found = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, char1); +else + { + mask = char1 ^ char2; + if (is_powerof2(mask)) + { + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, mask); + found = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, char1 | mask); + } + else + { + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, char1); + OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, char2); + OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL); + found = JUMP(SLJIT_NOT_ZERO); + } + } + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, start); + +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +if (common->utf && offset > 0) + utf_quit = JUMP(SLJIT_JUMP); +#endif + +JUMPHERE(found); + +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +if (common->utf && offset > 0) + { + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offset)); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +#if defined COMPILE_PCRE8 + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, utf_start); +#elif defined COMPILE_PCRE16 + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0xdc00, utf_start); +#else +#error "Unknown code width" +#endif + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + JUMPHERE(utf_quit); + } +#endif + +JUMPHERE(quit); + +if (has_match_end) + { + quit = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); + if (offset > 0) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); + JUMPHERE(quit); + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); + } + +if (offset > 0) + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); +} + +static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common) +{ +DEFINE_COMPILER; +struct sljit_label *start; +struct sljit_jump *quit; +struct sljit_jump *match; +/* bytes[0] represent the number of characters between 0 +and MAX_N_BYTES - 1, 255 represents any character. */ +pcre_uchar chars[MAX_N_CHARS * MAX_DIFF_CHARS]; +sljit_s32 offset; +pcre_uchar mask; +pcre_uchar *char_set, *char_set_end; +int i, max, from; +int range_right = -1, range_len; +sljit_u8 *update_table = NULL; +BOOL in_range; +sljit_u32 rec_count; + +for (i = 0; i < MAX_N_CHARS; i++) + chars[i * MAX_DIFF_CHARS] = 0; + +rec_count = 10000; +max = scan_prefix(common, common->start, chars, MAX_N_CHARS, &rec_count); + +if (max < 1) + return FALSE; + in_range = FALSE; -from = 0; /* Prevent compiler "uninitialized" warning */ +/* Prevent compiler "uninitialized" warning */ +from = 0; +range_len = 4 /* minimum length */ - 1; for (i = 0; i <= max; i++) { - if (in_range && (i - from) > range_len && (bytes[(i - 1) * MAX_N_BYTES] <= 4)) + if (in_range && (i - from) > range_len && (chars[(i - 1) * MAX_DIFF_CHARS] < 255)) { range_len = i - from; range_right = i - 1; } - if (i < max && bytes[i * MAX_N_BYTES] < 255) + if (i < max && chars[i * MAX_DIFF_CHARS] < 255) { + SLJIT_ASSERT(chars[i * MAX_DIFF_CHARS] > 0); if (!in_range) { in_range = TRUE; from = i; } } - else if (in_range) + else in_range = FALSE; } if (range_right >= 0) { - update_table = (sljit_ub *)allocate_read_only_data(common, 256); + update_table = (sljit_u8 *)allocate_read_only_data(common, 256); if (update_table == NULL) return TRUE; memset(update_table, IN_UCHARS(range_len), 256); for (i = 0; i < range_len; i++) { - byte_set = bytes + ((range_right - i) * MAX_N_BYTES); - SLJIT_ASSERT(byte_set[0] > 0 && byte_set[0] < 255); - byte_set_end = byte_set + byte_set[0]; - byte_set++; - while (byte_set <= byte_set_end) + char_set = chars + ((range_right - i) * MAX_DIFF_CHARS); + SLJIT_ASSERT(char_set[0] > 0 && char_set[0] < 255); + char_set_end = char_set + char_set[0]; + char_set++; + while (char_set <= char_set_end) { - if (update_table[*byte_set] > IN_UCHARS(i)) - update_table[*byte_set] = IN_UCHARS(i); - byte_set++; + if (update_table[(*char_set) & 0xff] > IN_UCHARS(i)) + update_table[(*char_set) & 0xff] = IN_UCHARS(i); + char_set++; } } } -offsets[0] = -1; +offset = -1; /* Scan forward. */ for (i = 0; i < max; i++) - if (ones[i] <= 2) { - offsets[0] = i; - break; - } - -if (offsets[0] < 0 && range_right < 0) - return FALSE; - -if (offsets[0] >= 0) { - /* Scan backward. */ - offsets[1] = -1; - for (i = max - 1; i > offsets[0]; i--) - if (ones[i] <= 2 && i != range_right) - { - offsets[1] = i; - break; - } - - /* This case is handled better by fast_forward_first_char. */ - if (offsets[1] == -1 && offsets[0] == 0 && range_right < 0) - return FALSE; - - offsets[2] = -1; - /* We only search for a middle character if there is no range check. */ - if (offsets[1] >= 0 && range_right == -1) + if (offset == -1) { - /* Scan from middle. */ - for (i = (offsets[0] + offsets[1]) / 2 + 1; i < offsets[1]; i++) - if (ones[i] <= 2) + if (chars[i * MAX_DIFF_CHARS] <= 2) + offset = i; + } + else if (chars[offset * MAX_DIFF_CHARS] == 2 && chars[i * MAX_DIFF_CHARS] <= 2) + { + if (chars[i * MAX_DIFF_CHARS] == 1) + offset = i; + else + { + mask = chars[offset * MAX_DIFF_CHARS + 1] ^ chars[offset * MAX_DIFF_CHARS + 2]; + if (!is_powerof2(mask)) { - offsets[2] = i; - break; + mask = chars[i * MAX_DIFF_CHARS + 1] ^ chars[i * MAX_DIFF_CHARS + 2]; + if (is_powerof2(mask)) + offset = i; } - - if (offsets[2] == -1) - { - for (i = (offsets[0] + offsets[1]) / 2; i > offsets[0]; i--) - if (ones[i] <= 2) - { - offsets[2] = i; - break; - } } } - - SLJIT_ASSERT(offsets[1] == -1 || (offsets[0] < offsets[1])); - SLJIT_ASSERT(offsets[2] == -1 || (offsets[0] < offsets[2] && offsets[1] > offsets[2])); - - chars[0] = chars[offsets[0] << 1]; - chars[1] = chars[(offsets[0] << 1) + 1]; - if (offsets[2] >= 0) - { - chars[2] = chars[offsets[2] << 1]; - chars[3] = chars[(offsets[2] << 1) + 1]; - } - if (offsets[1] >= 0) - { - chars[4] = chars[offsets[1] << 1]; - chars[5] = chars[(offsets[1] << 1) + 1]; - } } +if (range_right < 0) + { + if (offset < 0) + return FALSE; + SLJIT_ASSERT(chars[offset * MAX_DIFF_CHARS] >= 1 && chars[offset * MAX_DIFF_CHARS] <= 2); + /* Works regardless the value is 1 or 2. */ + mask = chars[offset * MAX_DIFF_CHARS + chars[offset * MAX_DIFF_CHARS]]; + fast_forward_first_char2(common, chars[offset * MAX_DIFF_CHARS + 1], mask, offset); + return TRUE; + } + +if (range_right == offset) + offset = -1; + +SLJIT_ASSERT(offset == -1 || (chars[offset * MAX_DIFF_CHARS] >= 1 && chars[offset * MAX_DIFF_CHARS] <= 2)); + max -= 1; -if (firstline) +SLJIT_ASSERT(max > 0); +if (common->match_end_ptr != 0) { - SLJIT_ASSERT(common->first_line_end != 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); quit = CMP(SLJIT_LESS_EQUAL, STR_END, 0, TMP1, 0); @@ -3736,68 +4432,86 @@ if (firstline) else OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); +SLJIT_ASSERT(range_right >= 0); + #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) -if (range_right >= 0) - OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table); +OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table); #endif start = LABEL(); quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); -SLJIT_ASSERT(range_right >= 0 || offsets[0] >= 0); - -if (range_right >= 0) - { #if defined COMPILE_PCRE8 || (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN) - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right)); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right)); #else - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right + 1) - 1); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right + 1) - 1); #endif #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0); #else - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table); #endif - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, start); - } +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, start); -if (offsets[0] >= 0) +if (offset >= 0) { - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[0])); - if (offsets[1] >= 0) - OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[1])); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offset)); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - if (chars[1] != 0) - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[1]); - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[0], start); - if (offsets[2] >= 0) - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[2] - 1)); - - if (offsets[1] >= 0) + if (chars[offset * MAX_DIFF_CHARS] == 1) + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset * MAX_DIFF_CHARS + 1], start); + else { - if (chars[5] != 0) - OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, chars[5]); - CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, chars[4], start); + mask = chars[offset * MAX_DIFF_CHARS + 1] ^ chars[offset * MAX_DIFF_CHARS + 2]; + if (is_powerof2(mask)) + { + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, mask); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset * MAX_DIFF_CHARS + 1] | mask, start); + } + else + { + match = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset * MAX_DIFF_CHARS + 1]); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset * MAX_DIFF_CHARS + 2], start); + JUMPHERE(match); + } } - - if (offsets[2] >= 0) - { - if (chars[3] != 0) - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[3]); - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[2], start); - } - OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); } +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +if (common->utf && offset != 0) + { + if (offset < 0) + { + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + } + else + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1)); +#if defined COMPILE_PCRE8 + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, start); +#elif defined COMPILE_PCRE16 + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0xdc00, start); +#else +#error "Unknown code width" +#endif + if (offset < 0) + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + } +#endif + +if (offset >= 0) + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + JUMPHERE(quit); -if (firstline) +if (common->match_end_ptr != 0) { if (range_right >= 0) - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); if (range_right >= 0) { @@ -3812,66 +4526,26 @@ return TRUE; } #undef MAX_N_CHARS -#undef MAX_N_BYTES +#undef MAX_DIFF_CHARS -static SLJIT_INLINE void fast_forward_first_char(compiler_common *common, pcre_uchar first_char, BOOL caseless, BOOL firstline) +static SLJIT_INLINE void fast_forward_first_char(compiler_common *common, pcre_uchar first_char, BOOL caseless) { -DEFINE_COMPILER; -struct sljit_label *start; -struct sljit_jump *quit; -struct sljit_jump *found; -pcre_uchar oc, bit; - -if (firstline) - { - SLJIT_ASSERT(common->first_line_end != 0); - OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end); - } - -start = LABEL(); -quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); -OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); +pcre_uchar oc; oc = first_char; if (caseless) { oc = TABLE_GET(first_char, common->fcc, first_char); -#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8) +#if defined SUPPORT_UCP && !defined COMPILE_PCRE8 if (first_char > 127 && common->utf) oc = UCD_OTHERCASE(first_char); #endif } -if (first_char == oc) - found = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, first_char); -else - { - bit = first_char ^ oc; - if (is_powerof2(bit)) - { - OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit); - found = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, first_char | bit); - } - else - { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, first_char); - OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc); - OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL); - found = JUMP(SLJIT_NOT_ZERO); - } - } -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -JUMPTO(SLJIT_JUMP, start); -JUMPHERE(found); -JUMPHERE(quit); - -if (firstline) - OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); +fast_forward_first_char2(common, first_char, oc, 0); } -static SLJIT_INLINE void fast_forward_newline(compiler_common *common, BOOL firstline) +static SLJIT_INLINE void fast_forward_newline(compiler_common *common) { DEFINE_COMPILER; struct sljit_label *loop; @@ -3882,11 +4556,10 @@ struct sljit_jump *foundcr = NULL; struct sljit_jump *notfoundnl; jump_list *newline = NULL; -if (firstline) +if (common->match_end_ptr != 0) { - SLJIT_ASSERT(common->first_line_end != 0); OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end); + OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); } if (common->nltype == NLTYPE_FIXED && common->newline > 255) @@ -3917,7 +4590,7 @@ if (common->nltype == NLTYPE_FIXED && common->newline > 255) JUMPHERE(firstchar); JUMPHERE(lastchar); - if (firstline) + if (common->match_end_ptr != 0) OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); return; } @@ -3955,13 +4628,13 @@ if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF) JUMPHERE(lastchar); JUMPHERE(firstchar); -if (firstline) +if (common->match_end_ptr != 0) OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); } -static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks); +static BOOL check_class_ranges(compiler_common *common, const sljit_u8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks); -static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, pcre_uint8 *start_bits, BOOL firstline) +static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, const sljit_u8 *start_bits) { DEFINE_COMPILER; struct sljit_label *start; @@ -3972,11 +4645,10 @@ jump_list *matches = NULL; struct sljit_jump *jump; #endif -if (firstline) +if (common->match_end_ptr != 0) { - SLJIT_ASSERT(common->first_line_end != 0); OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0); - OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end); + OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); } start = LABEL(); @@ -3996,7 +4668,7 @@ if (!check_class_ranges(common, start_bits, (start_bits[31] & 0x80) != 0, TRUE, #endif OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); found = JUMP(SLJIT_NOT_ZERO); @@ -4012,7 +4684,7 @@ OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); if (common->utf) { CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); } #elif defined COMPILE_PCRE16 @@ -4034,7 +4706,7 @@ if (matches != NULL) set_jumps(matches, LABEL()); JUMPHERE(quit); -if (firstline) +if (common->match_end_ptr != 0) OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0); } @@ -4047,7 +4719,7 @@ struct sljit_jump *alreadyfound; struct sljit_jump *found; struct sljit_jump *foundoc = NULL; struct sljit_jump *notfound; -pcre_uint32 oc, bit; +sljit_u32 oc, bit; SLJIT_ASSERT(common->req_char_ptr != 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->req_char_ptr); @@ -4184,7 +4856,7 @@ else if (common->utf) jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255); #endif /* COMPILE_PCRE8 */ - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 4 /* ctype_word */); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP1, 0); @@ -4229,7 +4901,7 @@ else if (common->utf) jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255); #endif - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), common->ctypes); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP1), common->ctypes); OP2(SLJIT_LSHR, TMP2, 0, TMP2, 0, SLJIT_IMM, 4 /* ctype_word */); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 1); #ifndef COMPILE_PCRE8 @@ -4245,11 +4917,12 @@ OP2(SLJIT_XOR | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOC sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0); } -static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks) +static BOOL check_class_ranges(compiler_common *common, const sljit_u8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks) { +/* May destroy TMP1. */ DEFINE_COMPILER; int ranges[MAX_RANGE_SIZE]; -pcre_uint8 bit, cbit, all; +sljit_u8 bit, cbit, all; int i, byte, length = 0; bit = bits[0] & 0x1; @@ -4544,12 +5217,12 @@ OP1(MOVU_UCHAR, CHAR2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); #ifndef COMPILE_PCRE8 jump = CMP(SLJIT_GREATER, CHAR1, 0, SLJIT_IMM, 255); #endif -OP1(SLJIT_MOV_UB, CHAR1, 0, SLJIT_MEM2(LCC_TABLE, CHAR1), 0); +OP1(SLJIT_MOV_U8, CHAR1, 0, SLJIT_MEM2(LCC_TABLE, CHAR1), 0); #ifndef COMPILE_PCRE8 JUMPHERE(jump); jump = CMP(SLJIT_GREATER, CHAR2, 0, SLJIT_IMM, 255); #endif -OP1(SLJIT_MOV_UB, CHAR2, 0, SLJIT_MEM2(LCC_TABLE, CHAR2), 0); +OP1(SLJIT_MOV_U8, CHAR2, 0, SLJIT_MEM2(LCC_TABLE, CHAR2), 0); #ifndef COMPILE_PCRE8 JUMPHERE(jump); #endif @@ -4574,11 +5247,11 @@ sljit_emit_fast_return(compiler, RETURN_ADDR, 0); static const pcre_uchar * SLJIT_CALL do_utf_caselesscmp(pcre_uchar *src1, jit_arguments *args, pcre_uchar *end1) { /* This function would be ineffective to do in JIT level. */ -pcre_uint32 c1, c2; +sljit_u32 c1, c2; const pcre_uchar *src2 = args->uchar_ptr; const pcre_uchar *end2 = args->end; const ucd_record *ur; -const pcre_uint32 *pp; +const sljit_u32 *pp; while (src1 < end1) { @@ -4638,16 +5311,16 @@ if (context->sourcereg == -1) #if defined COMPILE_PCRE8 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED if (context->length >= 4) - OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_S32, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); else if (context->length >= 2) - OP1(SLJIT_MOV_UH, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); else #endif - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); #elif defined COMPILE_PCRE16 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED if (context->length >= 4) - OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_S32, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); else #endif OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length); @@ -4689,12 +5362,12 @@ do #endif { if (context->length >= 4) - OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_S32, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length); else if (context->length >= 2) - OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_U16, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length); #if defined COMPILE_PCRE8 else if (context->length >= 1) - OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length); + OP1(SLJIT_MOV_U8, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length); #endif /* COMPILE_PCRE8 */ context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1; @@ -4777,6 +5450,8 @@ return cc; } \ charoffset = (value); +static pcre_uchar *compile_char1_matchingpath(compiler_common *common, pcre_uchar type, pcre_uchar *cc, jump_list **backtracks, BOOL check_str_ptr); + static void compile_xclass_matchingpath(compiler_common *common, pcre_uchar *cc, jump_list **backtracks) { DEFINE_COMPILER; @@ -4793,8 +5468,8 @@ BOOL utf = common->utf; #ifdef SUPPORT_UCP BOOL needstype = FALSE, needsscript = FALSE, needschar = FALSE; BOOL charsaved = FALSE; -int typereg = TMP1, scriptreg = TMP1; -const pcre_uint32 *other_cases; +int typereg = TMP1; +const sljit_u32 *other_cases; sljit_uw typeoffset; #endif @@ -4856,6 +5531,14 @@ while (*cc != XCL_END) switch(*cc) { case PT_ANY: + /* Any either accepts everything or ignored. */ + if (cc[-1] == XCL_PROP) + { + compile_char1_matchingpath(common, OP_ALLANY, cc, backtracks, FALSE); + if (list == backtracks) + add_jump(compiler, backtracks, JUMP(SLJIT_JUMP)); + return; + } break; case PT_LAMP: @@ -4892,10 +5575,10 @@ while (*cc != XCL_END) } #endif } +SLJIT_ASSERT(compares > 0); /* We are not necessary in utf mode even in 8 bit mode. */ cc = ccbegin; -detect_partial_match(common, backtracks); read_char_range(common, min, max, (cc[-1] & XCL_NOT) != 0); if ((cc[-1] & XCL_HASPROP) == 0) @@ -4903,11 +5586,11 @@ if ((cc[-1] & XCL_HASPROP) == 0) if ((cc[-1] & XCL_MAP) != 0) { jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255); - if (!check_class_ranges(common, (const pcre_uint8 *)cc, (((const pcre_uint8 *)cc)[31] & 0x80) != 0, TRUE, &found)) + if (!check_class_ranges(common, (const sljit_u8 *)cc, (((const sljit_u8 *)cc)[31] & 0x80) != 0, TRUE, &found)) { OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); add_jump(compiler, &found, JUMP(SLJIT_NOT_ZERO)); @@ -4926,11 +5609,11 @@ if ((cc[-1] & XCL_HASPROP) == 0) } else if ((cc[-1] & XCL_MAP) != 0) { - OP1(SLJIT_MOV, TMP3, 0, TMP1, 0); + OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0); #ifdef SUPPORT_UCP charsaved = TRUE; #endif - if (!check_class_ranges(common, (const pcre_uint8 *)cc, FALSE, TRUE, list)) + if (!check_class_ranges(common, (const sljit_u8 *)cc, FALSE, TRUE, list)) { #ifdef COMPILE_PCRE8 jump = NULL; @@ -4940,7 +5623,7 @@ else if ((cc[-1] & XCL_MAP) != 0) OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO)); @@ -4951,45 +5634,82 @@ else if ((cc[-1] & XCL_MAP) != 0) JUMPHERE(jump); } - OP1(SLJIT_MOV, TMP1, 0, TMP3, 0); + OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0); cc += 32 / sizeof(pcre_uchar); } #ifdef SUPPORT_UCP -/* Simple register allocation. TMP1 is preferred if possible. */ if (needstype || needsscript) { if (needschar && !charsaved) - OP1(SLJIT_MOV, TMP3, 0, TMP1, 0); - add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL)); - if (needschar) - { - if (needstype) - { - OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0); - typereg = RETURN_ADDR; - } + OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0); - if (needsscript) - scriptreg = TMP3; - OP1(SLJIT_MOV, TMP1, 0, TMP3, 0); - } - else if (needstype && needsscript) - scriptreg = TMP3; - /* In all other cases only one of them was specified, and that can goes to TMP1. */ + OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1)); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK); + OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT); + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2)); + OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1); + /* Before anything else, we deal with scripts. */ if (needsscript) { - if (scriptreg == TMP1) + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script)); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3); + + ccbegin = cc; + + while (*cc != XCL_END) { - OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script)); - OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3); + if (*cc == XCL_SINGLE) + { + cc ++; + GETCHARINCTEST(c, cc); + } + else if (*cc == XCL_RANGE) + { + cc ++; + GETCHARINCTEST(c, cc); + GETCHARINCTEST(c, cc); + } + else + { + SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); + cc++; + if (*cc == PT_SC) + { + compares--; + invertcmp = (compares == 0 && list != backtracks); + if (cc[-1] == XCL_NOTPROP) + invertcmp ^= 0x1; + jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1]); + add_jump(compiler, compares > 0 ? list : backtracks, jump); + } + cc += 2; + } + } + + cc = ccbegin; + } + + if (needschar) + { + OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0); + } + + if (needstype) + { + if (!needschar) + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype)); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3); } else { OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3); - OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script)); - OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0); + OP1(SLJIT_MOV_U8, RETURN_ADDR, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype)); + typereg = RETURN_ADDR; } } } @@ -5061,20 +5781,15 @@ while (*cc != XCL_END) #ifdef SUPPORT_UCP else { + SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); if (*cc == XCL_NOTPROP) invertcmp ^= 0x1; cc++; switch(*cc) { case PT_ANY: - if (list != backtracks) - { - if ((cc[-1] == XCL_NOTPROP && compares > 0) || (cc[-1] == XCL_PROP && compares == 0)) - continue; - } - else if (cc[-1] == XCL_NOTPROP) - continue; - jump = JUMP(SLJIT_JUMP); + if (!invertcmp) + jump = JUMP(SLJIT_JUMP); break; case PT_LAMP: @@ -5098,7 +5813,8 @@ while (*cc != XCL_END) break; case PT_SC: - jump = CMP(SLJIT_EQUAL ^ invertcmp, scriptreg, 0, SLJIT_IMM, (int)cc[1]); + compares++; + /* Do nothing. */ break; case PT_SPACE: @@ -5264,6 +5980,10 @@ while (*cc != XCL_END) OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL); jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp); break; + + default: + SLJIT_ASSERT_STOP(); + break; } cc += 2; } @@ -5282,19 +6002,13 @@ if (found != NULL) #endif -static pcre_uchar *compile_char1_matchingpath(compiler_common *common, pcre_uchar type, pcre_uchar *cc, jump_list **backtracks) +static pcre_uchar *compile_simple_assertion_matchingpath(compiler_common *common, pcre_uchar type, pcre_uchar *cc, jump_list **backtracks) { DEFINE_COMPILER; int length; -unsigned int c, oc, bit; -compare_context context; struct sljit_jump *jump[4]; -jump_list *end_list; #ifdef SUPPORT_UTF struct sljit_label *label; -#ifdef SUPPORT_UCP -pcre_uchar propdata[5]; -#endif #endif /* SUPPORT_UTF */ switch(type) @@ -5317,191 +6031,6 @@ switch(type) add_jump(compiler, backtracks, JUMP(type == OP_NOT_WORD_BOUNDARY ? SLJIT_NOT_ZERO : SLJIT_ZERO)); return cc; - case OP_NOT_DIGIT: - case OP_DIGIT: - /* Digits are usually 0-9, so it is worth to optimize them. */ - detect_partial_match(common, backtracks); -#if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_digit, FALSE)) - read_char7_type(common, type == OP_NOT_DIGIT); - else -#endif - read_char8_type(common, type == OP_NOT_DIGIT); - /* Flip the starting bit in the negative case. */ - OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit); - add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_ZERO : SLJIT_NOT_ZERO)); - return cc; - - case OP_NOT_WHITESPACE: - case OP_WHITESPACE: - detect_partial_match(common, backtracks); -#if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_space, FALSE)) - read_char7_type(common, type == OP_NOT_WHITESPACE); - else -#endif - read_char8_type(common, type == OP_NOT_WHITESPACE); - OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_space); - add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_ZERO : SLJIT_NOT_ZERO)); - return cc; - - case OP_NOT_WORDCHAR: - case OP_WORDCHAR: - detect_partial_match(common, backtracks); -#if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_word, FALSE)) - read_char7_type(common, type == OP_NOT_WORDCHAR); - else -#endif - read_char8_type(common, type == OP_NOT_WORDCHAR); - OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_word); - add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_ZERO : SLJIT_NOT_ZERO)); - return cc; - - case OP_ANY: - detect_partial_match(common, backtracks); - read_char_range(common, common->nlmin, common->nlmax, TRUE); - if (common->nltype == NLTYPE_FIXED && common->newline > 255) - { - jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff); - end_list = NULL; - if (common->mode != JIT_PARTIAL_HARD_COMPILE) - add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - else - check_str_end(common, &end_list); - - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); - add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff)); - set_jumps(end_list, LABEL()); - JUMPHERE(jump[0]); - } - else - check_newlinechar(common, common->nltype, backtracks, TRUE); - return cc; - - case OP_ALLANY: - detect_partial_match(common, backtracks); -#ifdef SUPPORT_UTF - if (common->utf) - { - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16 -#if defined COMPILE_PCRE8 - jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); -#elif defined COMPILE_PCRE16 - jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800); - OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800); - OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL); - OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); -#endif - JUMPHERE(jump[0]); -#endif /* COMPILE_PCRE[8|16] */ - return cc; - } -#endif - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - return cc; - - case OP_ANYBYTE: - detect_partial_match(common, backtracks); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - return cc; - -#ifdef SUPPORT_UTF -#ifdef SUPPORT_UCP - case OP_NOTPROP: - case OP_PROP: - propdata[0] = XCL_HASPROP; - propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP; - propdata[2] = cc[0]; - propdata[3] = cc[1]; - propdata[4] = XCL_END; - compile_xclass_matchingpath(common, propdata, backtracks); - return cc + 2; -#endif -#endif - - case OP_ANYNL: - detect_partial_match(common, backtracks); - read_char_range(common, common->bsr_nlmin, common->bsr_nlmax, FALSE); - jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR); - /* We don't need to handle soft partial matching case. */ - end_list = NULL; - if (common->mode != JIT_PARTIAL_HARD_COMPILE) - add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - else - check_str_end(common, &end_list); - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); - jump[1] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - jump[2] = JUMP(SLJIT_JUMP); - JUMPHERE(jump[0]); - check_newlinechar(common, common->bsr_nltype, backtracks, FALSE); - set_jumps(end_list, LABEL()); - JUMPHERE(jump[1]); - JUMPHERE(jump[2]); - return cc; - - case OP_NOT_HSPACE: - case OP_HSPACE: - detect_partial_match(common, backtracks); - read_char_range(common, 0x9, 0x3000, type == OP_NOT_HSPACE); - add_jump(compiler, &common->hspace, JUMP(SLJIT_FAST_CALL)); - add_jump(compiler, backtracks, JUMP(type == OP_NOT_HSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO)); - return cc; - - case OP_NOT_VSPACE: - case OP_VSPACE: - detect_partial_match(common, backtracks); - read_char_range(common, 0xa, 0x2029, type == OP_NOT_VSPACE); - add_jump(compiler, &common->vspace, JUMP(SLJIT_FAST_CALL)); - add_jump(compiler, backtracks, JUMP(type == OP_NOT_VSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO)); - return cc; - -#ifdef SUPPORT_UCP - case OP_EXTUNI: - detect_partial_match(common, backtracks); - read_char(common); - add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL)); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop)); - /* Optimize register allocation: use a real register. */ - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0); - OP1(SLJIT_MOV_UB, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3); - - label = LABEL(); - jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); - OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0); - read_char(common); - add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL)); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop)); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3); - - OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2); - OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_sw)PRIV(ucp_gbtable)); - OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0); - OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); - OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); - JUMPTO(SLJIT_NOT_ZERO, label); - - OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0); - JUMPHERE(jump[0]); - OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); - - if (common->mode == JIT_PARTIAL_HARD_COMPILE) - { - jump[0] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); - /* Since we successfully read a char above, partial matching must occure. */ - check_partial(common, TRUE); - JUMPHERE(jump[0]); - } - return cc; -#endif - case OP_EODN: /* Requires rather complex checks. */ jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); @@ -5575,49 +6104,13 @@ switch(type) check_partial(common, FALSE); return cc; - case OP_CIRC: - OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); - add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol)); - add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); - return cc; - - case OP_CIRCM: - OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); - jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol)); - add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); - jump[0] = JUMP(SLJIT_JUMP); - JUMPHERE(jump[1]); - - add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - if (common->nltype == NLTYPE_FIXED && common->newline > 255) - { - OP2(SLJIT_SUB, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2)); - add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, TMP1, 0)); - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2)); - OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1)); - add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff)); - add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff)); - } - else - { - skip_char_back(common); - read_char_range(common, common->nlmin, common->nlmax, TRUE); - check_newlinechar(common, common->nltype, backtracks, FALSE); - } - JUMPHERE(jump[0]); - return cc; - case OP_DOLL: OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol)); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol)); add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); if (!common->endonly) - compile_char1_matchingpath(common, OP_EODN, cc, backtracks); + compile_simple_assertion_matchingpath(common, OP_EODN, cc, backtracks); else { add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0)); @@ -5628,7 +6121,7 @@ switch(type) case OP_DOLLM: jump[1] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol)); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol)); add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); check_partial(common, FALSE); jump[0] = JUMP(SLJIT_JUMP); @@ -5662,13 +6155,294 @@ switch(type) JUMPHERE(jump[0]); return cc; + case OP_CIRC: + OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); + add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol)); + add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); + return cc; + + case OP_CIRCM: + OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); + jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol)); + add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); + jump[0] = JUMP(SLJIT_JUMP); + JUMPHERE(jump[1]); + + add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + if (common->nltype == NLTYPE_FIXED && common->newline > 255) + { + OP2(SLJIT_SUB, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2)); + add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, TMP1, 0)); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2)); + OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1)); + add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff)); + add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff)); + } + else + { + skip_char_back(common); + read_char_range(common, common->nlmin, common->nlmax, TRUE); + check_newlinechar(common, common->nltype, backtracks, FALSE); + } + JUMPHERE(jump[0]); + return cc; + + case OP_REVERSE: + length = GET(cc, 0); + if (length == 0) + return cc + LINK_SIZE; + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); +#ifdef SUPPORT_UTF + if (common->utf) + { + OP1(SLJIT_MOV, TMP3, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, length); + label = LABEL(); + add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP3, 0)); + skip_char_back(common); + OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + } + else +#endif + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length)); + add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, TMP1, 0)); + } + check_start_used_ptr(common); + return cc + LINK_SIZE; + } +SLJIT_ASSERT_STOP(); +return cc; +} + +static pcre_uchar *compile_char1_matchingpath(compiler_common *common, pcre_uchar type, pcre_uchar *cc, jump_list **backtracks, BOOL check_str_ptr) +{ +DEFINE_COMPILER; +int length; +unsigned int c, oc, bit; +compare_context context; +struct sljit_jump *jump[3]; +jump_list *end_list; +#ifdef SUPPORT_UTF +struct sljit_label *label; +#ifdef SUPPORT_UCP +pcre_uchar propdata[5]; +#endif +#endif /* SUPPORT_UTF */ + +switch(type) + { + case OP_NOT_DIGIT: + case OP_DIGIT: + /* Digits are usually 0-9, so it is worth to optimize them. */ + if (check_str_ptr) + detect_partial_match(common, backtracks); +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && is_char7_bitset((const sljit_u8 *)common->ctypes - cbit_length + cbit_digit, FALSE)) + read_char7_type(common, type == OP_NOT_DIGIT); + else +#endif + read_char8_type(common, type == OP_NOT_DIGIT); + /* Flip the starting bit in the negative case. */ + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit); + add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_ZERO : SLJIT_NOT_ZERO)); + return cc; + + case OP_NOT_WHITESPACE: + case OP_WHITESPACE: + if (check_str_ptr) + detect_partial_match(common, backtracks); +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && is_char7_bitset((const sljit_u8 *)common->ctypes - cbit_length + cbit_space, FALSE)) + read_char7_type(common, type == OP_NOT_WHITESPACE); + else +#endif + read_char8_type(common, type == OP_NOT_WHITESPACE); + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_space); + add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_ZERO : SLJIT_NOT_ZERO)); + return cc; + + case OP_NOT_WORDCHAR: + case OP_WORDCHAR: + if (check_str_ptr) + detect_partial_match(common, backtracks); +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && is_char7_bitset((const sljit_u8 *)common->ctypes - cbit_length + cbit_word, FALSE)) + read_char7_type(common, type == OP_NOT_WORDCHAR); + else +#endif + read_char8_type(common, type == OP_NOT_WORDCHAR); + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_word); + add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_ZERO : SLJIT_NOT_ZERO)); + return cc; + + case OP_ANY: + if (check_str_ptr) + detect_partial_match(common, backtracks); + read_char_range(common, common->nlmin, common->nlmax, TRUE); + if (common->nltype == NLTYPE_FIXED && common->newline > 255) + { + jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff); + end_list = NULL; + if (common->mode != JIT_PARTIAL_HARD_COMPILE) + add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + else + check_str_end(common, &end_list); + + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); + add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff)); + set_jumps(end_list, LABEL()); + JUMPHERE(jump[0]); + } + else + check_newlinechar(common, common->nltype, backtracks, TRUE); + return cc; + + case OP_ALLANY: + if (check_str_ptr) + detect_partial_match(common, backtracks); +#ifdef SUPPORT_UTF + if (common->utf) + { + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16 +#if defined COMPILE_PCRE8 + jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +#elif defined COMPILE_PCRE16 + jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800); + OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL); + OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +#endif + JUMPHERE(jump[0]); +#endif /* COMPILE_PCRE[8|16] */ + return cc; + } +#endif + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + return cc; + + case OP_ANYBYTE: + if (check_str_ptr) + detect_partial_match(common, backtracks); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + return cc; + +#ifdef SUPPORT_UTF +#ifdef SUPPORT_UCP + case OP_NOTPROP: + case OP_PROP: + propdata[0] = XCL_HASPROP; + propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP; + propdata[2] = cc[0]; + propdata[3] = cc[1]; + propdata[4] = XCL_END; + if (check_str_ptr) + detect_partial_match(common, backtracks); + compile_xclass_matchingpath(common, propdata, backtracks); + return cc + 2; +#endif +#endif + + case OP_ANYNL: + if (check_str_ptr) + detect_partial_match(common, backtracks); + read_char_range(common, common->bsr_nlmin, common->bsr_nlmax, FALSE); + jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR); + /* We don't need to handle soft partial matching case. */ + end_list = NULL; + if (common->mode != JIT_PARTIAL_HARD_COMPILE) + add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + else + check_str_end(common, &end_list); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); + jump[1] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + jump[2] = JUMP(SLJIT_JUMP); + JUMPHERE(jump[0]); + check_newlinechar(common, common->bsr_nltype, backtracks, FALSE); + set_jumps(end_list, LABEL()); + JUMPHERE(jump[1]); + JUMPHERE(jump[2]); + return cc; + + case OP_NOT_HSPACE: + case OP_HSPACE: + if (check_str_ptr) + detect_partial_match(common, backtracks); + read_char_range(common, 0x9, 0x3000, type == OP_NOT_HSPACE); + add_jump(compiler, &common->hspace, JUMP(SLJIT_FAST_CALL)); + add_jump(compiler, backtracks, JUMP(type == OP_NOT_HSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO)); + return cc; + + case OP_NOT_VSPACE: + case OP_VSPACE: + if (check_str_ptr) + detect_partial_match(common, backtracks); + read_char_range(common, 0xa, 0x2029, type == OP_NOT_VSPACE); + add_jump(compiler, &common->vspace, JUMP(SLJIT_FAST_CALL)); + add_jump(compiler, backtracks, JUMP(type == OP_NOT_VSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO)); + return cc; + +#ifdef SUPPORT_UCP + case OP_EXTUNI: + if (check_str_ptr) + detect_partial_match(common, backtracks); + read_char(common); + add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL)); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop)); + /* Optimize register allocation: use a real register. */ + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0); + OP1(SLJIT_MOV_U8, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3); + + label = LABEL(); + jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); + OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0); + read_char(common); + add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL)); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop)); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3); + + OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2); + OP1(SLJIT_MOV_U32, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_sw)PRIV(ucp_gbtable)); + OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0); + OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); + JUMPTO(SLJIT_NOT_ZERO, label); + + OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0); + JUMPHERE(jump[0]); + OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + + if (common->mode == JIT_PARTIAL_HARD_COMPILE) + { + jump[0] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); + /* Since we successfully read a char above, partial matching must occure. */ + check_partial(common, TRUE); + JUMPHERE(jump[0]); + } + return cc; +#endif + case OP_CHAR: case OP_CHARI: length = 1; #ifdef SUPPORT_UTF if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc); #endif - if (common->mode == JIT_COMPILE && (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0)) + if (common->mode == JIT_COMPILE && check_str_ptr + && (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0)) { OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length)); add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0)); @@ -5681,7 +6455,8 @@ switch(type) return byte_sequence_compare(common, type == OP_CHARI, cc, &context, backtracks); } - detect_partial_match(common, backtracks); + if (check_str_ptr) + detect_partial_match(common, backtracks); #ifdef SUPPORT_UTF if (common->utf) { @@ -5713,7 +6488,8 @@ switch(type) case OP_NOT: case OP_NOTI: - detect_partial_match(common, backtracks); + if (check_str_ptr) + detect_partial_match(common, backtracks); length = 1; #ifdef SUPPORT_UTF if (common->utf) @@ -5722,7 +6498,7 @@ switch(type) c = *cc; if (c < 128) { - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); if (type == OP_NOT || !char_has_othercase(common, cc)) add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c)); else @@ -5774,16 +6550,17 @@ switch(type) case OP_CLASS: case OP_NCLASS: - detect_partial_match(common, backtracks); + if (check_str_ptr) + detect_partial_match(common, backtracks); #if defined SUPPORT_UTF && defined COMPILE_PCRE8 - bit = (common->utf && is_char7_bitset((const pcre_uint8 *)cc, type == OP_NCLASS)) ? 127 : 255; + bit = (common->utf && is_char7_bitset((const sljit_u8 *)cc, type == OP_NCLASS)) ? 127 : 255; read_char_range(common, 0, bit, type == OP_NCLASS); #else read_char_range(common, 0, 255, type == OP_NCLASS); #endif - if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, FALSE, backtracks)) + if (check_class_ranges(common, (const sljit_u8 *)cc, type == OP_NCLASS, FALSE, backtracks)) return cc + 32 / sizeof(pcre_uchar); #if defined SUPPORT_UTF && defined COMPILE_PCRE8 @@ -5808,7 +6585,7 @@ switch(type) OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); add_jump(compiler, backtracks, JUMP(SLJIT_ZERO)); @@ -5817,40 +6594,15 @@ switch(type) if (jump[0] != NULL) JUMPHERE(jump[0]); #endif - return cc + 32 / sizeof(pcre_uchar); #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32 case OP_XCLASS: + if (check_str_ptr) + detect_partial_match(common, backtracks); compile_xclass_matchingpath(common, cc + LINK_SIZE, backtracks); return cc + GET(cc, 0) - 1; #endif - - case OP_REVERSE: - length = GET(cc, 0); - if (length == 0) - return cc + LINK_SIZE; - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -#ifdef SUPPORT_UTF - if (common->utf) - { - OP1(SLJIT_MOV, TMP3, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, length); - label = LABEL(); - add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP3, 0)); - skip_char_back(common); - OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); - } - else -#endif - { - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); - OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length)); - add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, TMP1, 0)); - } - check_start_used_ptr(common); - return cc + LINK_SIZE; } SLJIT_ASSERT_STOP(); return cc; @@ -5919,7 +6671,7 @@ if (context.length > 0) } /* A non-fixed length character will be checked if length == 0. */ -return compile_char1_matchingpath(common, *cc, cc + 1, backtracks); +return compile_char1_matchingpath(common, *cc, cc + 1, backtracks, TRUE); } /* Forward definitions. */ @@ -6094,7 +6846,7 @@ pcre_uchar *ccbegin = cc; int min = 0, max = 0; BOOL minimize; -PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL); +PUSH_BACKTRACK(sizeof(ref_iterator_backtrack), cc, NULL); if (ref) offset = GET2(cc, 1) << 1; @@ -6214,7 +6966,7 @@ if (!minimize) } JUMPHERE(zerolength); - BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL(); + BACKTRACK_AS(ref_iterator_backtrack)->matchingpath = LABEL(); count_match(common); return cc; @@ -6260,7 +7012,7 @@ else } } -BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL(); +BACKTRACK_AS(ref_iterator_backtrack)->matchingpath = LABEL(); if (max > 0) add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, max)); @@ -6274,7 +7026,7 @@ if (min > 1) OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1)); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0); - CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min, BACKTRACK_AS(iterator_backtrack)->matchingpath); + CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min, BACKTRACK_AS(ref_iterator_backtrack)->matchingpath); } else if (max > 0) OP2(SLJIT_ADD, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 1); @@ -6419,8 +7171,8 @@ allocate_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw)); SLJIT_ASSERT(common->capture_last_ptr != 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr); OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_number), SLJIT_IMM, cc[1]); -OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(capture_last), TMP2, 0); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_number), SLJIT_IMM, cc[1]); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(capture_last), TMP2, 0); /* These pointer sized fields temporarly stores internal variables. */ OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0)); @@ -6429,8 +7181,8 @@ OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(subject), TMP2, 0); if (common->mark_ptr != 0) OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr)); -OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position), SLJIT_IMM, GET(cc, 2)); -OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(next_item_length), SLJIT_IMM, GET(cc, 2 + LINK_SIZE)); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position), SLJIT_IMM, GET(cc, 2)); +OP1(SLJIT_MOV_S32, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(next_item_length), SLJIT_IMM, GET(cc, 2 + LINK_SIZE)); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(mark), (common->mark_ptr != 0) ? TMP2 : SLJIT_IMM, 0); /* Needed to save important temporary registers. */ @@ -6438,7 +7190,7 @@ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0); OP2(SLJIT_SUB, SLJIT_R1, 0, STACK_TOP, 0, SLJIT_IMM, CALLOUT_ARG_SIZE); GET_LOCAL_BASE(SLJIT_R2, 0, OVECTOR_START); sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_callout)); -OP1(SLJIT_MOV_SI, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0); +OP1(SLJIT_MOV_S32, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); free_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw)); @@ -6455,6 +7207,32 @@ return cc + 2 + 2 * LINK_SIZE; #undef CALLOUT_ARG_SIZE #undef CALLOUT_ARG_OFFSET +static SLJIT_INLINE BOOL assert_needs_str_ptr_saving(pcre_uchar *cc) +{ +while (TRUE) + { + switch (*cc) + { + case OP_NOT_WORD_BOUNDARY: + case OP_WORD_BOUNDARY: + case OP_CIRC: + case OP_CIRCM: + case OP_DOLL: + case OP_DOLLM: + case OP_CALLOUT: + case OP_ALT: + cc += PRIV(OP_lengths)[*cc]; + break; + + case OP_KET: + return FALSE; + + default: + return TRUE; + } + } +} + static pcre_uchar *compile_assert_matchingpath(compiler_common *common, pcre_uchar *cc, assert_backtrack *backtrack, BOOL conditional) { DEFINE_COMPILER; @@ -6511,15 +7289,28 @@ if (bra == OP_BRAMINZERO) if (framesize < 0) { - extrasize = needs_control_head ? 2 : 1; + extrasize = 1; + if (bra == OP_BRA && !assert_needs_str_ptr_saving(ccbegin + 1 + LINK_SIZE)) + extrasize = 0; + + if (needs_control_head) + extrasize++; + if (framesize == no_frame) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0); - allocate_stack(common, extrasize); + + if (extrasize > 0) + allocate_stack(common, extrasize); + if (needs_control_head) OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr); - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0); + + if (extrasize > 0) + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0); + if (needs_control_head) { + SLJIT_ASSERT(extrasize == 2); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0); } @@ -6528,12 +7319,14 @@ else { extrasize = needs_control_head ? 3 : 2; allocate_stack(common, framesize + extrasize); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr); OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw)); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP2, 0); if (needs_control_head) OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0); + if (needs_control_head) { OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0); @@ -6542,6 +7335,7 @@ else } else OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0); + init_frame(common, ccbegin, NULL, framesize + extrasize - 1, extrasize, FALSE); } @@ -6565,7 +7359,7 @@ while (1) altbacktrack.top = NULL; altbacktrack.topbacktracks = NULL; - if (*ccbegin == OP_ALT) + if (*ccbegin == OP_ALT && extrasize > 0) OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); altbacktrack.cc = ccbegin; @@ -6594,8 +7388,9 @@ while (1) { if (framesize == no_frame) OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr); - else + else if (extrasize > 0) free_stack(common, extrasize); + if (needs_control_head) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0); } @@ -6621,7 +7416,10 @@ while (1) { /* We know that STR_PTR was stored on the top of the stack. */ if (conditional) - OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? sizeof(sljit_sw) : 0); + { + if (extrasize > 0) + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? sizeof(sljit_sw) : 0); + } else if (bra == OP_BRAZERO) { if (framesize < 0) @@ -6698,7 +7496,7 @@ if (needs_control_head) if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) { /* Assert is failed. */ - if (conditional || bra == OP_BRAZERO) + if ((conditional && extrasize > 0) || bra == OP_BRAZERO) OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); if (framesize < 0) @@ -6710,7 +7508,7 @@ if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) free_stack(common, 1); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0); } - else + else if (extrasize > 0) free_stack(common, extrasize); } else @@ -6735,7 +7533,9 @@ if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) if (framesize < 0) { /* We know that STR_PTR was stored on the top of the stack. */ - OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw)); + if (extrasize > 0) + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw)); + /* Keep the STR_PTR on the top of the stack. */ if (bra == OP_BRAZERO) { @@ -6798,14 +7598,16 @@ else /* AssertNot is successful. */ if (framesize < 0) { - OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); + if (extrasize > 0) + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); + if (bra != OP_BRA) { if (extrasize == 2) free_stack(common, 1); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0); } - else + else if (extrasize > 0) free_stack(common, extrasize); } else @@ -6867,7 +7669,9 @@ if (framesize < 0) stacksize = needs_control_head ? 1 : 0; if (ket != OP_KET || has_alternatives) stacksize++; - free_stack(common, stacksize); + + if (stacksize > 0) + free_stack(common, stacksize); } if (needs_control_head) @@ -7513,9 +8317,13 @@ while (*cc == OP_ALT) cc += GET(cc, 1); cc += 1 + LINK_SIZE; -/* Temporarily encoding the needs_control_head in framesize. */ if (opcode == OP_ONCE) + { + /* We temporarily encode the needs_control_head in the lowest bit. + Note: on the target architectures of SLJIT the ((x << 1) >> 1) returns + the same value for small signed numbers (including negative numbers). */ BACKTRACK_AS(bracket_backtrack)->u.framesize = (BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0); + } return cc + repeat_length; } @@ -7802,11 +8610,13 @@ count_match(common); return cc + 1 + LINK_SIZE; } -static SLJIT_INLINE pcre_uchar *get_iterator_parameters(compiler_common *common, pcre_uchar *cc, pcre_uchar *opcode, pcre_uchar *type, int *max, int *min, pcre_uchar **end) +static SLJIT_INLINE pcre_uchar *get_iterator_parameters(compiler_common *common, pcre_uchar *cc, pcre_uchar *opcode, pcre_uchar *type, sljit_u32 *max, sljit_u32 *exact, pcre_uchar **end) { int class_len; *opcode = *cc; +*exact = 0; + if (*opcode >= OP_STAR && *opcode <= OP_POSUPTO) { cc++; @@ -7834,7 +8644,7 @@ else if (*opcode >= OP_TYPESTAR && *opcode <= OP_TYPEPOSUPTO) { cc++; *opcode -= OP_TYPESTAR - OP_STAR; - *type = 0; + *type = OP_END; } else { @@ -7843,60 +8653,105 @@ else cc++; class_len = (*type < OP_XCLASS) ? (int)(1 + (32 / sizeof(pcre_uchar))) : GET(cc, 0); *opcode = cc[class_len - 1]; + if (*opcode >= OP_CRSTAR && *opcode <= OP_CRMINQUERY) { *opcode -= OP_CRSTAR - OP_STAR; - if (end != NULL) - *end = cc + class_len; + *end = cc + class_len; + + if (*opcode == OP_PLUS || *opcode == OP_MINPLUS) + { + *exact = 1; + *opcode -= OP_PLUS - OP_STAR; + } } else if (*opcode >= OP_CRPOSSTAR && *opcode <= OP_CRPOSQUERY) { *opcode -= OP_CRPOSSTAR - OP_POSSTAR; - if (end != NULL) - *end = cc + class_len; + *end = cc + class_len; + + if (*opcode == OP_POSPLUS) + { + *exact = 1; + *opcode = OP_POSSTAR; + } } else { SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE || *opcode == OP_CRPOSRANGE); *max = GET2(cc, (class_len + IMM2_SIZE)); - *min = GET2(cc, class_len); + *exact = GET2(cc, class_len); - if (*min == 0) + if (*max == 0) { - SLJIT_ASSERT(*max != 0); - *opcode = (*opcode == OP_CRRANGE) ? OP_UPTO : (*opcode == OP_CRMINRANGE ? OP_MINUPTO : OP_POSUPTO); + if (*opcode == OP_CRPOSRANGE) + *opcode = OP_POSSTAR; + else + *opcode -= OP_CRRANGE - OP_STAR; } - if (*max == *min) - *opcode = OP_EXACT; - - if (end != NULL) - *end = cc + class_len + 2 * IMM2_SIZE; + else + { + *max -= *exact; + if (*max == 0) + *opcode = OP_EXACT; + else if (*max == 1) + { + if (*opcode == OP_CRPOSRANGE) + *opcode = OP_POSQUERY; + else + *opcode -= OP_CRRANGE - OP_QUERY; + } + else + { + if (*opcode == OP_CRPOSRANGE) + *opcode = OP_POSUPTO; + else + *opcode -= OP_CRRANGE - OP_UPTO; + } + } + *end = cc + class_len + 2 * IMM2_SIZE; } return cc; } -if (*opcode == OP_UPTO || *opcode == OP_MINUPTO || *opcode == OP_EXACT || *opcode == OP_POSUPTO) +switch(*opcode) { + case OP_EXACT: + *exact = GET2(cc, 0); + cc += IMM2_SIZE; + break; + + case OP_PLUS: + case OP_MINPLUS: + *exact = 1; + *opcode -= OP_PLUS - OP_STAR; + break; + + case OP_POSPLUS: + *exact = 1; + *opcode = OP_POSSTAR; + break; + + case OP_UPTO: + case OP_MINUPTO: + case OP_POSUPTO: *max = GET2(cc, 0); cc += IMM2_SIZE; + break; } -if (*type == 0) +if (*type == OP_END) { *type = *cc; - if (end != NULL) - *end = next_opcode(common, cc); + *end = next_opcode(common, cc); cc++; return cc; } -if (end != NULL) - { - *end = cc + 1; +*end = cc + 1; #ifdef SUPPORT_UTF - if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc); +if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc); #endif - } return cc; } @@ -7906,9 +8761,15 @@ DEFINE_COMPILER; backtrack_common *backtrack; pcre_uchar opcode; pcre_uchar type; -int max = -1, min = -1; +sljit_u32 max = 0, exact; +BOOL fast_fail; +sljit_s32 fast_str_ptr; +BOOL charpos_enabled; +pcre_uchar charpos_char; +unsigned int charpos_othercasebit; pcre_uchar *end; -jump_list *nomatch = NULL; +jump_list *no_match = NULL; +jump_list *no_char1_match = NULL; struct sljit_jump *jump = NULL; struct sljit_label *label; int private_data_ptr = PRIVATE_DATA(cc); @@ -7917,83 +8778,92 @@ int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr; int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw); int tmp_base, tmp_offset; -PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL); +PUSH_BACKTRACK(sizeof(char_iterator_backtrack), cc, NULL); -cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &min, &end); +fast_str_ptr = PRIVATE_DATA(cc + 1); +fast_fail = TRUE; -switch(type) +SLJIT_ASSERT(common->fast_forward_bc_ptr == NULL || fast_str_ptr == 0 || cc == common->fast_forward_bc_ptr); + +if (cc == common->fast_forward_bc_ptr) + fast_fail = FALSE; +else if (common->fast_fail_start_ptr == 0) + fast_str_ptr = 0; + +SLJIT_ASSERT(common->fast_forward_bc_ptr != NULL || fast_str_ptr == 0 + || (fast_str_ptr >= common->fast_fail_start_ptr && fast_str_ptr <= common->fast_fail_end_ptr)); + +cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &exact, &end); + +if (type != OP_EXTUNI) { - case OP_NOT_DIGIT: - case OP_DIGIT: - case OP_NOT_WHITESPACE: - case OP_WHITESPACE: - case OP_NOT_WORDCHAR: - case OP_WORDCHAR: - case OP_ANY: - case OP_ALLANY: - case OP_ANYBYTE: - case OP_ANYNL: - case OP_NOT_HSPACE: - case OP_HSPACE: - case OP_NOT_VSPACE: - case OP_VSPACE: - case OP_CHAR: - case OP_CHARI: - case OP_NOT: - case OP_NOTI: - case OP_CLASS: - case OP_NCLASS: tmp_base = TMP3; tmp_offset = 0; - break; - - default: - SLJIT_ASSERT_STOP(); - /* Fall through. */ - - case OP_EXTUNI: - case OP_XCLASS: - case OP_NOTPROP: - case OP_PROP: + } +else + { tmp_base = SLJIT_MEM1(SLJIT_SP); tmp_offset = POSSESSIVE0; - break; } +if (fast_fail && fast_str_ptr != 0) + add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), fast_str_ptr)); + +/* Handle fixed part first. */ +if (exact > 1) + { + SLJIT_ASSERT(fast_str_ptr == 0); + if (common->mode == JIT_COMPILE +#ifdef SUPPORT_UTF + && !common->utf +#endif + ) + { + OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(exact)); + add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER, TMP1, 0, STR_END, 0)); + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, exact); + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, FALSE); + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + } + else + { + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, exact); + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, TRUE); + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + } + } +else if (exact == 1) + compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, TRUE); + switch(opcode) { case OP_STAR: - case OP_PLUS: case OP_UPTO: - case OP_CRRANGE: + SLJIT_ASSERT(fast_str_ptr == 0 || opcode == OP_STAR); + if (type == OP_ANYNL || type == OP_EXTUNI) { SLJIT_ASSERT(private_data_ptr == 0); - if (opcode == OP_STAR || opcode == OP_UPTO) - { - allocate_stack(common, 2); - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0); - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0); - } - else - { - allocate_stack(common, 1); - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0); - } + SLJIT_ASSERT(fast_str_ptr == 0); - if (opcode == OP_UPTO || opcode == OP_CRRANGE) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, SLJIT_IMM, 0); + allocate_stack(common, 2); + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0); + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0); + + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, SLJIT_IMM, max); label = LABEL(); - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); - if (opcode == OP_UPTO || opcode == OP_CRRANGE) + compile_char1_matchingpath(common, type, cc, &BACKTRACK_AS(char_iterator_backtrack)->u.backtracks, TRUE); + if (opcode == OP_UPTO) { OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0); - OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); - if (opcode == OP_CRRANGE && min > 0) - CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min, label); - if (opcode == OP_UPTO || (opcode == OP_CRRANGE && max > 0)) - jump = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, max); + OP2(SLJIT_SUB | SLJIT_SET_E, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); + jump = JUMP(SLJIT_ZERO); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, TMP1, 0); } @@ -8006,134 +8876,268 @@ switch(opcode) } else { - if (opcode == OP_PLUS) - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); - if (private_data_ptr == 0) - allocate_stack(common, 2); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - if (opcode <= OP_PLUS) + charpos_enabled = FALSE; + charpos_char = 0; + charpos_othercasebit = 0; + + if ((type != OP_CHAR && type != OP_CHARI) && (*end == OP_CHAR || *end == OP_CHARI)) + { + charpos_enabled = TRUE; +#ifdef SUPPORT_UTF + charpos_enabled = !common->utf || !HAS_EXTRALEN(end[1]); +#endif + if (charpos_enabled && *end == OP_CHARI && char_has_othercase(common, end + 1)) + { + charpos_othercasebit = char_get_othercase_bit(common, end + 1); + if (charpos_othercasebit == 0) + charpos_enabled = FALSE; + } + + if (charpos_enabled) + { + charpos_char = end[1]; + /* Consumpe the OP_CHAR opcode. */ + end += 2; +#if defined COMPILE_PCRE8 + SLJIT_ASSERT((charpos_othercasebit >> 8) == 0); +#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32 + SLJIT_ASSERT((charpos_othercasebit >> 9) == 0); + if ((charpos_othercasebit & 0x100) != 0) + charpos_othercasebit = (charpos_othercasebit & 0xff) << 8; +#endif + if (charpos_othercasebit != 0) + charpos_char |= charpos_othercasebit; + + BACKTRACK_AS(char_iterator_backtrack)->u.charpos.enabled = TRUE; + BACKTRACK_AS(char_iterator_backtrack)->u.charpos.chr = charpos_char; + BACKTRACK_AS(char_iterator_backtrack)->u.charpos.othercasebit = charpos_othercasebit; + } + } + + if (charpos_enabled) + { + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max + 1); + + /* Search the first instance of charpos_char. */ + jump = JUMP(SLJIT_JUMP); + label = LABEL(); + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_ZERO)); + } + compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, FALSE); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + JUMPHERE(jump); + + detect_partial_match(common, &backtrack->topbacktracks); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + if (charpos_othercasebit != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label); + + if (private_data_ptr == 0) + allocate_stack(common, 2); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); - else - OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1); - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &nomatch); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - if (opcode <= OP_PLUS) - JUMPTO(SLJIT_JUMP, label); - else if (opcode == OP_CRRANGE && max == 0) - { - OP2(SLJIT_ADD, base, offset1, base, offset1, SLJIT_IMM, 1); - JUMPTO(SLJIT_JUMP, label); + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); + } + + /* Search the last instance of charpos_char. */ + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_match, FALSE); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + detect_partial_match(common, &no_match); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + if (charpos_othercasebit != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit); + if (opcode == OP_STAR) + { + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + } + else + { + jump = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + JUMPHERE(jump); + } + + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + } + else + JUMPTO(SLJIT_JUMP, label); + + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); } +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + else if (common->utf) + { + if (private_data_ptr == 0) + allocate_stack(common, 2); + + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_match, TRUE); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + } + else + JUMPTO(SLJIT_JUMP, label); + + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + } +#endif else { - OP1(SLJIT_MOV, TMP1, 0, base, offset1); - OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); - OP1(SLJIT_MOV, base, offset1, TMP1, 0); - CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, max + 1, label); + if (private_data_ptr == 0) + allocate_stack(common, 2); + + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + + label = LABEL(); + detect_partial_match(common, &no_match); + compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + } + else + JUMPTO(SLJIT_JUMP, label); + + set_jumps(no_char1_match, LABEL()); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); } - set_jumps(nomatch, LABEL()); - if (opcode == OP_CRRANGE) - add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_LESS, base, offset1, SLJIT_IMM, min + 1)); - OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); } - BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL(); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); break; case OP_MINSTAR: - case OP_MINPLUS: - if (opcode == OP_MINPLUS) - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); if (private_data_ptr == 0) allocate_stack(common, 1); OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL(); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); break; case OP_MINUPTO: - case OP_CRMINRANGE: + SLJIT_ASSERT(fast_str_ptr == 0); if (private_data_ptr == 0) allocate_stack(common, 2); OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1); - if (opcode == OP_CRMINRANGE) - add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_JUMP)); - BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL(); + OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, max + 1); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); break; case OP_QUERY: case OP_MINQUERY: + SLJIT_ASSERT(fast_str_ptr == 0); if (private_data_ptr == 0) allocate_stack(common, 1); OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); if (opcode == OP_QUERY) - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); - BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL(); + compile_char1_matchingpath(common, type, cc, &BACKTRACK_AS(char_iterator_backtrack)->u.backtracks, TRUE); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); break; case OP_EXACT: - OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); - OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); break; case OP_POSSTAR: - case OP_POSPLUS: - case OP_POSUPTO: - if (opcode == OP_POSPLUS) - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); - if (opcode == OP_POSUPTO) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, max); - OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &nomatch); - OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - if (opcode != OP_POSUPTO) - JUMPTO(SLJIT_JUMP, label); - else +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); + OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_match, TRUE); + OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); + JUMPTO(SLJIT_JUMP, label); + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + break; } - set_jumps(nomatch, LABEL()); - OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset); +#endif + label = LABEL(); + detect_partial_match(common, &no_match); + compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); + JUMPTO(SLJIT_JUMP, label); + set_jumps(no_char1_match, LABEL()); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_match, LABEL()); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + break; + + case OP_POSUPTO: + SLJIT_ASSERT(fast_str_ptr == 0); +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) + { + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, STR_PTR, 0); + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_match, TRUE); + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, STR_PTR, 0); + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1); + break; + } +#endif + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + label = LABEL(); + detect_partial_match(common, &no_match); + compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); + OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_char1_match, LABEL()); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_match, LABEL()); break; case OP_POSQUERY: + SLJIT_ASSERT(fast_str_ptr == 0); OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - compile_char1_matchingpath(common, type, cc, &nomatch); + compile_char1_matchingpath(common, type, cc, &no_match, TRUE); OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - set_jumps(nomatch, LABEL()); - OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset); - break; - - case OP_CRPOSRANGE: - /* Combination of OP_EXACT and OP_POSSTAR or OP_POSUPTO */ - OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, min); - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks); - OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); - - if (max != 0) - { - SLJIT_ASSERT(max - min > 0); - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, max - min); - } - OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &nomatch); - OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - if (max == 0) - JUMPTO(SLJIT_JUMP, label); - else - { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); - } - set_jumps(nomatch, LABEL()); + set_jumps(no_match, LABEL()); OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset); break; @@ -8174,9 +9178,9 @@ if (common->accept_label == NULL) else CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), common->accept_label); OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); +OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); -OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); +OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); if (common->accept_label == NULL) add_jump(compiler, &common->accept, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); else @@ -8298,6 +9302,16 @@ while (cc < ccend) case OP_SOM: case OP_NOT_WORD_BOUNDARY: case OP_WORD_BOUNDARY: + case OP_EODN: + case OP_EOD: + case OP_DOLL: + case OP_DOLLM: + case OP_CIRC: + case OP_CIRCM: + case OP_REVERSE: + cc = compile_simple_assertion_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks); + break; + case OP_NOT_DIGIT: case OP_DIGIT: case OP_NOT_WHITESPACE: @@ -8315,16 +9329,9 @@ while (cc < ccend) case OP_NOT_VSPACE: case OP_VSPACE: case OP_EXTUNI: - case OP_EODN: - case OP_EOD: - case OP_CIRC: - case OP_CIRCM: - case OP_DOLL: - case OP_DOLLM: case OP_NOT: case OP_NOTI: - case OP_REVERSE: - cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks); + cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE); break; case OP_SET_SOM: @@ -8341,7 +9348,7 @@ while (cc < ccend) if (common->mode == JIT_COMPILE) cc = compile_charn_matchingpath(common, cc, ccend, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks); else - cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks); + cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE); break; case OP_STAR: @@ -8417,7 +9424,7 @@ while (cc < ccend) if (cc[1 + (32 / sizeof(pcre_uchar))] >= OP_CRSTAR && cc[1 + (32 / sizeof(pcre_uchar))] <= OP_CRPOSRANGE) cc = compile_iterator_matchingpath(common, cc, parent); else - cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks); + cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE); break; #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32 @@ -8425,7 +9432,7 @@ while (cc < ccend) if (*(cc + GET(cc, 1)) >= OP_CRSTAR && *(cc + GET(cc, 1)) <= OP_CRPOSRANGE) cc = compile_iterator_matchingpath(common, cc, parent); else - cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks); + cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE); break; #endif @@ -8601,95 +9608,82 @@ DEFINE_COMPILER; pcre_uchar *cc = current->cc; pcre_uchar opcode; pcre_uchar type; -int max = -1, min = -1; +sljit_u32 max = 0, exact; struct sljit_label *label = NULL; struct sljit_jump *jump = NULL; jump_list *jumplist = NULL; +pcre_uchar *end; int private_data_ptr = PRIVATE_DATA(cc); int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_SP); int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr; int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw); -cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &min, NULL); +cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &exact, &end); switch(opcode) { case OP_STAR: - case OP_PLUS: case OP_UPTO: - case OP_CRRANGE: if (type == OP_ANYNL || type == OP_EXTUNI) { SLJIT_ASSERT(private_data_ptr == 0); - set_jumps(current->topbacktracks, LABEL()); + set_jumps(CURRENT_AS(char_iterator_backtrack)->u.backtracks, LABEL()); OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); free_stack(common, 1); - CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath); + CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(char_iterator_backtrack)->matchingpath); } else { - if (opcode == OP_UPTO) - min = 0; - if (opcode <= OP_PLUS) + if (CURRENT_AS(char_iterator_backtrack)->u.charpos.enabled) { OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); - jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, base, offset1); + OP1(SLJIT_MOV, TMP2, 0, base, offset1); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + + jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0); + label = LABEL(); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1)); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + if (CURRENT_AS(char_iterator_backtrack)->u.charpos.othercasebit != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, CURRENT_AS(char_iterator_backtrack)->u.charpos.othercasebit); + CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CURRENT_AS(char_iterator_backtrack)->u.charpos.chr, CURRENT_AS(char_iterator_backtrack)->matchingpath); + skip_char_back(common); + CMPTO(SLJIT_GREATER, STR_PTR, 0, TMP2, 0, label); } else { - OP1(SLJIT_MOV, TMP1, 0, base, offset1); OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); - jump = CMP(SLJIT_LESS_EQUAL, TMP1, 0, SLJIT_IMM, min + 1); - OP2(SLJIT_SUB, base, offset1, TMP1, 0, SLJIT_IMM, 1); + jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, base, offset1); + skip_char_back(common); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + JUMPTO(SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath); } - skip_char_back(common); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath); - if (opcode == OP_CRRANGE) - set_jumps(current->topbacktracks, LABEL()); JUMPHERE(jump); if (private_data_ptr == 0) free_stack(common, 2); - if (opcode == OP_PLUS) - set_jumps(current->topbacktracks, LABEL()); } break; case OP_MINSTAR: - case OP_MINPLUS: OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); - compile_char1_matchingpath(common, type, cc, &jumplist); + compile_char1_matchingpath(common, type, cc, &jumplist, TRUE); OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath); + JUMPTO(SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath); set_jumps(jumplist, LABEL()); if (private_data_ptr == 0) free_stack(common, 1); - if (opcode == OP_MINPLUS) - set_jumps(current->topbacktracks, LABEL()); break; case OP_MINUPTO: - case OP_CRMINRANGE: - if (opcode == OP_CRMINRANGE) - { - label = LABEL(); - set_jumps(current->topbacktracks, label); - } - OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); - compile_char1_matchingpath(common, type, cc, &jumplist); - OP1(SLJIT_MOV, TMP1, 0, base, offset1); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); + OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); + OP2(SLJIT_SUB | SLJIT_SET_E, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); + add_jump(compiler, &jumplist, JUMP(SLJIT_ZERO)); + OP1(SLJIT_MOV, base, offset1, TMP1, 0); - - if (opcode == OP_CRMINRANGE) - CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min + 1, label); - - if (opcode == OP_CRMINRANGE && max == 0) - JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath); - else - CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, max + 2, CURRENT_AS(iterator_backtrack)->matchingpath); + compile_char1_matchingpath(common, type, cc, &jumplist, TRUE); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + JUMPTO(SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath); set_jumps(jumplist, LABEL()); if (private_data_ptr == 0) @@ -8699,12 +9693,12 @@ switch(opcode) case OP_QUERY: OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0); - CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath); + CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(char_iterator_backtrack)->matchingpath); jump = JUMP(SLJIT_JUMP); - set_jumps(current->topbacktracks, LABEL()); + set_jumps(CURRENT_AS(char_iterator_backtrack)->u.backtracks, LABEL()); OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0); - JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath); + JUMPTO(SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath); JUMPHERE(jump); if (private_data_ptr == 0) free_stack(common, 1); @@ -8714,8 +9708,8 @@ switch(opcode) OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0); jump = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0); - compile_char1_matchingpath(common, type, cc, &jumplist); - JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath); + compile_char1_matchingpath(common, type, cc, &jumplist, TRUE); + JUMPTO(SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath); set_jumps(jumplist, LABEL()); JUMPHERE(jump); if (private_data_ptr == 0) @@ -8723,11 +9717,6 @@ switch(opcode) break; case OP_EXACT: - case OP_POSPLUS: - case OP_CRPOSRANGE: - set_jumps(current->topbacktracks, LABEL()); - break; - case OP_POSSTAR: case OP_POSQUERY: case OP_POSUPTO: @@ -8737,6 +9726,8 @@ switch(opcode) SLJIT_ASSERT_STOP(); break; } + +set_jumps(current->topbacktracks, LABEL()); } static SLJIT_INLINE void compile_ref_iterator_backtrackingpath(compiler_common *common, struct backtrack_common *current) @@ -8754,12 +9745,12 @@ if ((type & 0x1) == 0) set_jumps(current->topbacktracks, LABEL()); OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); free_stack(common, 1); - CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath); + CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(ref_iterator_backtrack)->matchingpath); return; } OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); -CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath); +CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(ref_iterator_backtrack)->matchingpath); set_jumps(current->topbacktracks, LABEL()); free_stack(common, ref ? 2 : 3); } @@ -9258,7 +10249,9 @@ else if (opcode == OP_ONCE) /* The STR_PTR must be released. */ stacksize++; } - free_stack(common, stacksize); + + if (stacksize > 0) + free_stack(common, stacksize); JUMPHERE(once); /* Restore previous private_data_ptr */ @@ -9688,8 +10681,8 @@ common->currententry->entry = LABEL(); set_jumps(common->currententry->calls, common->currententry->entry); sljit_emit_fast_enter(compiler, TMP2, 0); -allocate_stack(common, private_data_size + framesize + alternativesize); count_match(common); +allocate_stack(common, private_data_size + framesize + alternativesize); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0); copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize, needs_control_head); if (needs_control_head) @@ -9795,7 +10788,7 @@ struct sljit_compiler *compiler; backtrack_common rootbacktrack; compiler_common common_data; compiler_common *common = &common_data; -const pcre_uint8 *tables = re->tables; +const sljit_u8 *tables = re->tables; pcre_study_data *study; int private_data_size; pcre_uchar *ccend; @@ -9907,7 +10900,7 @@ ccend = bracketend(common->start); /* Calculate the local space size on the stack. */ common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw); -common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1, compiler->allocator_data); +common->optimized_cbracket = (sljit_u8 *)SLJIT_MALLOC(re->top_bracket + 1, compiler->allocator_data); if (!common->optimized_cbracket) return; #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1 @@ -9942,15 +10935,10 @@ if (mode != JIT_COMPILE) common->hit_start = common->ovector_start; common->ovector_start += 2 * sizeof(sljit_sw); } - else - { - SLJIT_ASSERT(mode == JIT_PARTIAL_HARD_COMPILE); - common->needs_start_ptr = TRUE; - } } if ((re->options & PCRE_FIRSTLINE) != 0) { - common->first_line_end = common->ovector_start; + common->match_end_ptr = common->ovector_start; common->ovector_start += sizeof(sljit_sw); } #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD @@ -9961,14 +10949,12 @@ if (common->control_head_ptr != 0) common->control_head_ptr = common->ovector_start; common->ovector_start += sizeof(sljit_sw); } -if (common->needs_start_ptr && common->has_set_som) +if (common->has_set_som) { /* Saving the real start pointer is necessary. */ common->start_ptr = common->ovector_start; common->ovector_start += sizeof(sljit_sw); } -else - common->needs_start_ptr = FALSE; /* Aligning ovector to even number of sljit words. */ if ((common->ovector_start & sizeof(sljit_sw)) != 0) @@ -9985,16 +10971,24 @@ SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0)); common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw); total_length = ccend - common->start; -common->private_data_ptrs = (sljit_si *)SLJIT_MALLOC(total_length * (sizeof(sljit_si) + (common->has_then ? 1 : 0)), compiler->allocator_data); +common->private_data_ptrs = (sljit_s32 *)SLJIT_MALLOC(total_length * (sizeof(sljit_s32) + (common->has_then ? 1 : 0)), compiler->allocator_data); if (!common->private_data_ptrs) { SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data); return; } -memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_si)); +memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_s32)); private_data_size = common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw); set_private_data_ptrs(common, &private_data_size, ccend); +if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0) + { + if (!detect_fast_forward_skip(common, &private_data_size) && !common->has_skip_in_assert_back) + detect_fast_fail(common, common->start, &private_data_size, 4); + } + +SLJIT_ASSERT(common->fast_fail_start_ptr <= common->fast_fail_end_ptr); + if (private_data_size > SLJIT_MAX_LOCAL_SIZE) { SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data); @@ -10004,7 +10998,7 @@ if (private_data_size > SLJIT_MAX_LOCAL_SIZE) if (common->has_then) { - common->then_offsets = (pcre_uint8 *)(common->private_data_ptrs + total_length); + common->then_offsets = (sljit_u8 *)(common->private_data_ptrs + total_length); memset(common->then_offsets, 0, total_length); set_then_offsets(common, common->start, NULL); } @@ -10031,12 +11025,15 @@ OP1(SLJIT_MOV, TMP1, 0, SLJIT_S0, 0); OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack)); -OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match)); +OP1(SLJIT_MOV_U32, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match)); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base)); OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit)); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH, TMP1, 0); +if (common->fast_fail_start_ptr < common->fast_fail_end_ptr) + reset_fast_fail(common); + if (mode == JIT_PARTIAL_SOFT_COMPILE) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, -1); if (common->mark_ptr != 0) @@ -10047,19 +11044,19 @@ if (common->control_head_ptr != 0) /* Main part of the matching */ if ((re->options & PCRE_ANCHORED) == 0) { - mainloop_label = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0, (re->options & PCRE_FIRSTLINE) != 0); + mainloop_label = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0); continue_match_label = LABEL(); /* Forward search if possible. */ if ((re->options & PCRE_NO_START_OPTIMIZE) == 0) { - if (mode == JIT_COMPILE && fast_forward_first_n_chars(common, (re->options & PCRE_FIRSTLINE) != 0)) + if (mode == JIT_COMPILE && fast_forward_first_n_chars(common)) ; else if ((re->flags & PCRE_FIRSTSET) != 0) - fast_forward_first_char(common, (pcre_uchar)re->first_char, (re->flags & PCRE_FCH_CASELESS) != 0, (re->options & PCRE_FIRSTLINE) != 0); + fast_forward_first_char(common, (pcre_uchar)re->first_char, (re->flags & PCRE_FCH_CASELESS) != 0); else if ((re->flags & PCRE_STARTLINE) != 0) - fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0); + fast_forward_newline(common); else if (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0) - fast_forward_start_bits(common, study->start_bits, (re->options & PCRE_FIRSTLINE) != 0); + fast_forward_start_bits(common, study->start_bits); } } else @@ -10080,14 +11077,11 @@ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), STR_PTR, 0); OP1(SLJIT_MOV, COUNT_MATCH, 0, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH); if (common->capture_last_ptr != 0) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, -1); +if (common->fast_forward_bc_ptr != NULL) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), PRIVATE_DATA(common->fast_forward_bc_ptr + 1), STR_PTR, 0); -if (common->needs_start_ptr) - { - SLJIT_ASSERT(common->start_ptr != OVECTOR(0)); +if (common->start_ptr != OVECTOR(0)) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_ptr, STR_PTR, 0); - } -else - SLJIT_ASSERT(common->start_ptr == OVECTOR(0)); /* Copy the beginning of the string. */ if (mode == JIT_PARTIAL_SOFT_COMPILE) @@ -10166,11 +11160,12 @@ if (mode == JIT_PARTIAL_SOFT_COMPILE) /* Check we have remaining characters. */ if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_FIRSTLINE) != 0) { - SLJIT_ASSERT(common->first_line_end != 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end); + SLJIT_ASSERT(common->match_end_ptr != 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); } -OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr); +OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), + (common->fast_forward_bc_ptr != NULL) ? (PRIVATE_DATA(common->fast_forward_bc_ptr + 1)) : common->start_ptr); if ((re->options & PCRE_ANCHORED) == 0) { @@ -10181,12 +11176,7 @@ if ((re->options & PCRE_ANCHORED) == 0) /* There cannot be more newlines here. */ } else - { - if ((re->options & PCRE_FIRSTLINE) == 0) - CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop_label); - else - CMPTO(SLJIT_LESS, STR_PTR, 0, TMP1, 0, mainloop_label); - } + CMPTO(SLJIT_LESS, STR_PTR, 0, ((re->options & PCRE_FIRSTLINE) == 0) ? STR_END : TMP1, 0, mainloop_label); } /* No more remaining characters. */ @@ -10205,15 +11195,18 @@ if (common->might_be_empty) { JUMPHERE(empty_match); OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label); - OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); + OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label); JUMPTO(SLJIT_JUMP, empty_match_backtrack_label); } +common->fast_forward_bc_ptr = NULL; +common->fast_fail_start_ptr = 0; +common->fast_fail_end_ptr = 0; common->currententry = common->entries; common->local_exit = TRUE; quit_label = common->quit_label; @@ -10395,7 +11388,7 @@ union { void *executable_func; jit_function call_executable_func; } convert_executable_func; -pcre_uint8 local_space[MACHINE_STACK_SIZE]; +sljit_u8 local_space[MACHINE_STACK_SIZE]; struct sljit_stack local_stack; local_stack.top = (sljit_sw)&local_space; @@ -10435,7 +11428,7 @@ arguments.begin = subject; arguments.end = subject + length; arguments.mark_ptr = NULL; /* JIT decreases this value less frequently than the interpreter. */ -arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit); +arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (sljit_u32)(extra_data->match_limit); if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match) arguments.limit_match = functions->limit_match; arguments.notbol = (options & PCRE_NOTBOL) != 0; @@ -10528,7 +11521,7 @@ arguments.begin = subject_ptr; arguments.end = subject_ptr + length; arguments.mark_ptr = NULL; /* JIT decreases this value less frequently than the interpreter. */ -arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit); +arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (sljit_u32)(extra_data->match_limit); if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match) arguments.limit_match = functions->limit_match; arguments.notbol = (options & PCRE_NOTBOL) != 0; diff --git a/pcre/pcre_jit_test.c b/pcre/pcre_jit_test.c index 17378957d62..9b61ec000fa 100644 --- a/pcre/pcre_jit_test.c +++ b/pcre/pcre_jit_test.c @@ -242,13 +242,17 @@ static struct regression_test_case regression_test_cases[] = { { MA, 0, "a\\z", "aaa" }, { MA, 0 | F_NOMATCH, "a\\z", "aab" }, - /* Brackets. */ + /* Brackets and alternatives. */ { MUA, 0, "(ab|bb|cd)", "bacde" }, { MUA, 0, "(?:ab|a)(bc|c)", "ababc" }, { MUA, 0, "((ab|(cc))|(bb)|(?:cd|efg))", "abac" }, { CMUA, 0, "((aB|(Cc))|(bB)|(?:cd|EFg))", "AcCe" }, { MUA, 0, "((ab|(cc))|(bb)|(?:cd|ebg))", "acebebg" }, { MUA, 0, "(?:(a)|(?:b))(cc|(?:d|e))(a|b)k", "accabdbbccbk" }, + { MUA, 0, "\xc7\x82|\xc6\x82", "\xf1\x83\x82\x82\xc7\x82\xc7\x83" }, + { MUA, 0, "=\xc7\x82|#\xc6\x82", "\xf1\x83\x82\x82=\xc7\x82\xc7\x83" }, + { MUA, 0, "\xc7\x82\xc7\x83|\xc6\x82\xc6\x82", "\xf1\x83\x82\x82\xc7\x82\xc7\x83" }, + { MUA, 0, "\xc6\x82\xc6\x82|\xc7\x83\xc7\x83|\xc8\x84\xc8\x84", "\xf1\x83\x82\x82\xc8\x84\xc8\x84" }, /* Greedy and non-greedy ? operators. */ { MUA, 0, "(?:a)?a", "laab" }, @@ -318,6 +322,14 @@ static struct regression_test_case regression_test_cases[] = { { CMUA, 0, "[^\xe1\xbd\xb8][^\xc3\xa9]", "\xe1\xbd\xb8\xe1\xbf\xb8\xc3\xa9\xc3\x89#" }, { MUA, 0, "[^\xe1\xbd\xb8][^\xc3\xa9]", "\xe1\xbd\xb8\xe1\xbf\xb8\xc3\xa9\xc3\x89#" }, { MUA, 0, "[^\xe1\xbd\xb8]{3,}?", "##\xe1\xbd\xb8#\xe1\xbd\xb8#\xc3\x89#\xe1\xbd\xb8" }, + { MUA, 0, "\\d+123", "987654321,01234" }, + { MUA, 0, "abcd*|\\w+xy", "aaaaa,abxyz" }, + { MUA, 0, "(?:abc|((?:amc|\\b\\w*xy)))", "aaaaa,abxyz" }, + { MUA, 0, "a(?R)|([a-z]++)#", ".abcd.abcd#."}, + { MUA, 0, "a(?R)|([a-z]++)#", ".abcd.mbcd#."}, + { MUA, 0, ".[ab]*.", "xx" }, + { MUA, 0, ".[ab]*a", "xxa" }, + { MUA, 0, ".[ab]?.", "xx" }, /* Bracket repeats with limit. */ { MUA, 0, "(?:(ab){2}){5}M", "abababababababababababM" }, @@ -574,6 +586,16 @@ static struct regression_test_case regression_test_cases[] = { { MUA, 0, "(?:(?=.)??[a-c])+m", "abacdcbacacdcaccam" }, { MUA, 0, "((?!a)?(?!([^a]))?)+$", "acbab" }, { MUA, 0, "((?!a)?\?(?!([^a]))?\?)+$", "acbab" }, + { MUA, 0, "a(?=(?C)\\B)b", "ab" }, + { MUA, 0, "a(?!(?C)\\B)bb|ab", "abb" }, + { MUA, 0, "a(?=\\b|(?C)\\B)b", "ab" }, + { MUA, 0, "a(?!\\b|(?C)\\B)bb|ab", "abb" }, + { MUA, 0, "c(?(?=(?C)\\B)ab|a)", "cab" }, + { MUA, 0, "c(?(?!(?C)\\B)ab|a)", "cab" }, + { MUA, 0, "c(?(?=\\b|(?C)\\B)ab|a)", "cab" }, + { MUA, 0, "c(?(?!\\b|(?C)\\B)ab|a)", "cab" }, + { MUA, 0, "a(?=)b", "ab" }, + { MUA, 0 | F_NOMATCH, "a(?!)b", "ab" }, /* Not empty, ACCEPT, FAIL */ { MUA | PCRE_NOTEMPTY, 0 | F_NOMATCH, "a*", "bcx" }, @@ -664,6 +686,7 @@ static struct regression_test_case regression_test_cases[] = { { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" }, { PCRE_FIRSTLINE | PCRE_NEWLINE_LF | PCRE_DOTALL, 0 | F_NOMATCH, "ab.", "ab" }, { MUA | PCRE_FIRSTLINE, 1 | F_NOMATCH, "^[a-d0-9]", "\nxx\nd" }, + { PCRE_NEWLINE_ANY | PCRE_FIRSTLINE | PCRE_DOTALL, 0, "....a", "012\n0a" }, /* Recurse. */ { MUA, 0, "(a)(?1)", "aa" }, @@ -798,6 +821,9 @@ static struct regression_test_case regression_test_cases[] = { /* (*SKIP) verb. */ { MUA, 0 | F_NOMATCH, "(?=a(*SKIP)b)ab|ad", "ad" }, + { MUA, 0, "(\\w+(*SKIP)#)", "abcd,xyz#," }, + { MUA, 0, "\\w+(*SKIP)#|mm", "abcd,xyz#," }, + { MUA, 0 | F_NOMATCH, "b+(?<=(*SKIP)#c)|b+", "#bbb" }, /* (*THEN) verb. */ { MUA, 0, "((?:a(*THEN)|aab)(*THEN)c|a+)+m", "aabcaabcaabcaabcnacm" }, @@ -1534,10 +1560,10 @@ static int regression_tests(void) is_successful = 0; } #endif -#if defined SUPPORT_PCRE16 && defined SUPPORT_PCRE16 - if (ovector16_1[i] != ovector16_2[i] || ovector16_1[i] != ovector16_1[i] || ovector16_1[i] != ovector16_2[i]) { - printf("\n16 and 16 bit: Ovector[%d] value differs(J16:%d,I16:%d,J32:%d,I32:%d): [%d] '%s' @ '%s' \n", - i, ovector16_1[i], ovector16_2[i], ovector16_1[i], ovector16_2[i], +#if defined SUPPORT_PCRE16 && defined SUPPORT_PCRE32 + if (ovector16_1[i] != ovector16_2[i] || ovector16_1[i] != ovector32_1[i] || ovector16_1[i] != ovector32_2[i]) { + printf("\n16 and 32 bit: Ovector[%d] value differs(J16:%d,I16:%d,J32:%d,I32:%d): [%d] '%s' @ '%s' \n", + i, ovector16_1[i], ovector16_2[i], ovector32_1[i], ovector32_2[i], total, current->pattern, current->input); is_successful = 0; } diff --git a/pcre/pcre_study.c b/pcre/pcre_study.c index 7fd0ba0b3d8..d9d4960d84e 100644 --- a/pcre/pcre_study.c +++ b/pcre/pcre_study.c @@ -1371,7 +1371,7 @@ do for (c = 0; c < 16; c++) start_bits[c] |= map[c]; for (c = 128; c < 256; c++) { - if ((map[c/8] && (1 << (c&7))) != 0) + if ((map[c/8] & (1 << (c&7))) != 0) { int d = (c >> 6) | 0xc0; /* Set bit for this starter */ start_bits[d/8] |= (1 << (d&7)); /* and then skip on to the */ diff --git a/pcre/pcrecpp.cc b/pcre/pcrecpp.cc index c595cbcab5c..d09c9abc516 100644 --- a/pcre/pcrecpp.cc +++ b/pcre/pcrecpp.cc @@ -66,7 +66,7 @@ Arg RE::no_arg((void*)NULL); // inclusive test if we ever needed it. (Note that not only the // __attribute__ syntax, but also __USER_LABEL_PREFIX__, are // gnu-specific.) -#if defined(__GNUC__) && __GNUC__ >= 3 && defined(__ELF__) +#if defined(__GNUC__) && __GNUC__ >= 3 && defined(__ELF__) && !defined(__INTEL_COMPILER) # define ULP_AS_STRING(x) ULP_AS_STRING_INTERNAL(x) # define ULP_AS_STRING_INTERNAL(x) #x # define USER_LABEL_PREFIX_STR ULP_AS_STRING(__USER_LABEL_PREFIX__) @@ -168,22 +168,22 @@ bool RE::FullMatch(const StringPiece& text, const Arg& ptr16) const { const Arg* args[kMaxArgs]; int n = 0; - if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1; - if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2; - if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3; - if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4; - if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5; - if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6; - if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7; - if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8; - if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9; - if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10; - if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11; - if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12; - if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13; - if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14; - if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15; - if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16; + if (&ptr1 == &no_arg) { goto done; } args[n++] = &ptr1; + if (&ptr2 == &no_arg) { goto done; } args[n++] = &ptr2; + if (&ptr3 == &no_arg) { goto done; } args[n++] = &ptr3; + if (&ptr4 == &no_arg) { goto done; } args[n++] = &ptr4; + if (&ptr5 == &no_arg) { goto done; } args[n++] = &ptr5; + if (&ptr6 == &no_arg) { goto done; } args[n++] = &ptr6; + if (&ptr7 == &no_arg) { goto done; } args[n++] = &ptr7; + if (&ptr8 == &no_arg) { goto done; } args[n++] = &ptr8; + if (&ptr9 == &no_arg) { goto done; } args[n++] = &ptr9; + if (&ptr10 == &no_arg) { goto done; } args[n++] = &ptr10; + if (&ptr11 == &no_arg) { goto done; } args[n++] = &ptr11; + if (&ptr12 == &no_arg) { goto done; } args[n++] = &ptr12; + if (&ptr13 == &no_arg) { goto done; } args[n++] = &ptr13; + if (&ptr14 == &no_arg) { goto done; } args[n++] = &ptr14; + if (&ptr15 == &no_arg) { goto done; } args[n++] = &ptr15; + if (&ptr16 == &no_arg) { goto done; } args[n++] = &ptr16; done: int consumed; @@ -210,22 +210,22 @@ bool RE::PartialMatch(const StringPiece& text, const Arg& ptr16) const { const Arg* args[kMaxArgs]; int n = 0; - if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1; - if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2; - if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3; - if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4; - if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5; - if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6; - if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7; - if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8; - if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9; - if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10; - if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11; - if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12; - if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13; - if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14; - if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15; - if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16; + if (&ptr1 == &no_arg) { goto done; } args[n++] = &ptr1; + if (&ptr2 == &no_arg) { goto done; } args[n++] = &ptr2; + if (&ptr3 == &no_arg) { goto done; } args[n++] = &ptr3; + if (&ptr4 == &no_arg) { goto done; } args[n++] = &ptr4; + if (&ptr5 == &no_arg) { goto done; } args[n++] = &ptr5; + if (&ptr6 == &no_arg) { goto done; } args[n++] = &ptr6; + if (&ptr7 == &no_arg) { goto done; } args[n++] = &ptr7; + if (&ptr8 == &no_arg) { goto done; } args[n++] = &ptr8; + if (&ptr9 == &no_arg) { goto done; } args[n++] = &ptr9; + if (&ptr10 == &no_arg) { goto done; } args[n++] = &ptr10; + if (&ptr11 == &no_arg) { goto done; } args[n++] = &ptr11; + if (&ptr12 == &no_arg) { goto done; } args[n++] = &ptr12; + if (&ptr13 == &no_arg) { goto done; } args[n++] = &ptr13; + if (&ptr14 == &no_arg) { goto done; } args[n++] = &ptr14; + if (&ptr15 == &no_arg) { goto done; } args[n++] = &ptr15; + if (&ptr16 == &no_arg) { goto done; } args[n++] = &ptr16; done: int consumed; @@ -252,22 +252,22 @@ bool RE::Consume(StringPiece* input, const Arg& ptr16) const { const Arg* args[kMaxArgs]; int n = 0; - if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1; - if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2; - if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3; - if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4; - if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5; - if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6; - if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7; - if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8; - if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9; - if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10; - if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11; - if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12; - if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13; - if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14; - if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15; - if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16; + if (&ptr1 == &no_arg) { goto done; } args[n++] = &ptr1; + if (&ptr2 == &no_arg) { goto done; } args[n++] = &ptr2; + if (&ptr3 == &no_arg) { goto done; } args[n++] = &ptr3; + if (&ptr4 == &no_arg) { goto done; } args[n++] = &ptr4; + if (&ptr5 == &no_arg) { goto done; } args[n++] = &ptr5; + if (&ptr6 == &no_arg) { goto done; } args[n++] = &ptr6; + if (&ptr7 == &no_arg) { goto done; } args[n++] = &ptr7; + if (&ptr8 == &no_arg) { goto done; } args[n++] = &ptr8; + if (&ptr9 == &no_arg) { goto done; } args[n++] = &ptr9; + if (&ptr10 == &no_arg) { goto done; } args[n++] = &ptr10; + if (&ptr11 == &no_arg) { goto done; } args[n++] = &ptr11; + if (&ptr12 == &no_arg) { goto done; } args[n++] = &ptr12; + if (&ptr13 == &no_arg) { goto done; } args[n++] = &ptr13; + if (&ptr14 == &no_arg) { goto done; } args[n++] = &ptr14; + if (&ptr15 == &no_arg) { goto done; } args[n++] = &ptr15; + if (&ptr16 == &no_arg) { goto done; } args[n++] = &ptr16; done: int consumed; @@ -300,22 +300,22 @@ bool RE::FindAndConsume(StringPiece* input, const Arg& ptr16) const { const Arg* args[kMaxArgs]; int n = 0; - if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1; - if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2; - if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3; - if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4; - if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5; - if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6; - if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7; - if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8; - if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9; - if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10; - if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11; - if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12; - if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13; - if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14; - if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15; - if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16; + if (&ptr1 == &no_arg) { goto done; } args[n++] = &ptr1; + if (&ptr2 == &no_arg) { goto done; } args[n++] = &ptr2; + if (&ptr3 == &no_arg) { goto done; } args[n++] = &ptr3; + if (&ptr4 == &no_arg) { goto done; } args[n++] = &ptr4; + if (&ptr5 == &no_arg) { goto done; } args[n++] = &ptr5; + if (&ptr6 == &no_arg) { goto done; } args[n++] = &ptr6; + if (&ptr7 == &no_arg) { goto done; } args[n++] = &ptr7; + if (&ptr8 == &no_arg) { goto done; } args[n++] = &ptr8; + if (&ptr9 == &no_arg) { goto done; } args[n++] = &ptr9; + if (&ptr10 == &no_arg) { goto done; } args[n++] = &ptr10; + if (&ptr11 == &no_arg) { goto done; } args[n++] = &ptr11; + if (&ptr12 == &no_arg) { goto done; } args[n++] = &ptr12; + if (&ptr13 == &no_arg) { goto done; } args[n++] = &ptr13; + if (&ptr14 == &no_arg) { goto done; } args[n++] = &ptr14; + if (&ptr15 == &no_arg) { goto done; } args[n++] = &ptr15; + if (&ptr16 == &no_arg) { goto done; } args[n++] = &ptr16; done: int consumed; diff --git a/pcre/pcregrep.c b/pcre/pcregrep.c index 64986b016e6..cd53c648da2 100644 --- a/pcre/pcregrep.c +++ b/pcre/pcregrep.c @@ -2437,7 +2437,7 @@ return options; static char * ordin(int n) { -static char buffer[8]; +static char buffer[14]; char *p = buffer; sprintf(p, "%d", n); while (*p != 0) p++; diff --git a/pcre/pcreposix.c b/pcre/pcreposix.c index f024423b634..cf75588c40d 100644 --- a/pcre/pcreposix.c +++ b/pcre/pcreposix.c @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2014 University of Cambridge + Copyright (c) 1997-2016 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -173,7 +173,8 @@ static const int eint[] = { REG_BADPAT, /* group name must start with a non-digit */ /* 85 */ REG_BADPAT, /* parentheses too deeply nested (stack check) */ - REG_BADPAT /* missing digits in \x{} or \o{} */ + REG_BADPAT, /* missing digits in \x{} or \o{} */ + REG_BADPAT /* pattern too complicated */ }; /* Table of texts corresponding to POSIX error codes */ @@ -364,6 +365,7 @@ start location rather than being passed as a PCRE "starting offset". */ if ((eflags & REG_STARTEND) != 0) { + if (pmatch == NULL) return REG_INVARG; so = pmatch[0].rm_so; eo = pmatch[0].rm_eo; } diff --git a/pcre/pcretest.c b/pcre/pcretest.c index 488e419462e..78ef5177df7 100644 --- a/pcre/pcretest.c +++ b/pcre/pcretest.c @@ -2250,7 +2250,7 @@ data is not zero. */ static int callout(pcre_callout_block *cb) { FILE *f = (first_callout | callout_extra)? outfile : NULL; -int i, pre_start, post_start, subject_length; +int i, current_position, pre_start, post_start, subject_length; if (callout_extra) { @@ -2280,14 +2280,19 @@ printed lengths of the substrings. */ if (f != NULL) fprintf(f, "--->"); +/* If a lookbehind is involved, the current position may be earlier than the +match start. If so, use the match start instead. */ + +current_position = (cb->current_position >= cb->start_match)? + cb->current_position : cb->start_match; + PCHARS(pre_start, cb->subject, 0, cb->start_match, f); PCHARS(post_start, cb->subject, cb->start_match, - cb->current_position - cb->start_match, f); + current_position - cb->start_match, f); PCHARS(subject_length, cb->subject, 0, cb->subject_length, NULL); -PCHARSV(cb->subject, cb->current_position, - cb->subject_length - cb->current_position, f); +PCHARSV(cb->subject, current_position, cb->subject_length - current_position, f); if (f != NULL) fprintf(f, "\n"); @@ -5612,6 +5617,12 @@ while (!done) break; } + if (use_size_offsets < 2) + { + fprintf(outfile, "Cannot do global matching with an ovector size < 2\n"); + break; + } + /* If we have matched an empty string, first check to see if we are at the end of the subject. If so, the /g loop is over. Otherwise, mimic what Perl's /g options does. This turns out to be rather cunning. First we set @@ -5740,3 +5751,4 @@ return yield; } /* End of pcretest.c */ + diff --git a/pcre/testdata/testinput11 b/pcre/testdata/testinput11 index ac9d2289854..6f0989a14c2 100644 --- a/pcre/testdata/testinput11 +++ b/pcre/testdata/testinput11 @@ -138,4 +138,6 @@ is required for these tests. --/ /.((?2)(?R)\1)()/B +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/ + /-- End of testinput11 --/ diff --git a/pcre/testdata/testinput2 b/pcre/testdata/testinput2 index e2e520f7404..75e402ee9b3 100644 --- a/pcre/testdata/testinput2 +++ b/pcre/testdata/testinput2 @@ -4217,4 +4217,30 @@ backtracking verbs. --/ /a[[:punct:]b]/BZ +/L(?#(|++)(?J:(?)(?))(?)/ + \O\CC + +/(?=a\K)/ + ring bpattingbobnd $ 1,oern cou \rb\L + +/(?<=((?C)0))/ + 9010 + abcd + +/((?J)(?'R'(?'R'(?'R'(?'R'(?'R'(?|(\k'R'))))))))/ + +/\N(?(?C)0?!.)*/ + /-- End of testinput2 --/ diff --git a/pcre/testdata/testinput6 b/pcre/testdata/testinput6 index aeb62a073fa..a178d3d67b4 100644 --- a/pcre/testdata/testinput6 +++ b/pcre/testdata/testinput6 @@ -1553,4 +1553,13 @@ \x{200} \x{37e} +/[^[:^ascii:]\d]/8W + a + ~ + 0 + \a + \x{7f} + \x{389} + \x{20ac} + /-- End of testinput6 --/ diff --git a/pcre/testdata/testinput7 b/pcre/testdata/testinput7 index e411a4b842e..00b9738a371 100644 --- a/pcre/testdata/testinput7 +++ b/pcre/testdata/testinput7 @@ -853,4 +853,8 @@ of case for anything other than the ASCII letters. --/ /a[b[:punct:]]/8WBZ +/L(?#(|++a)...(?P=a)bbb(?P>a)d/BM -Memory allocation (code space): 77 +Memory allocation (code space): 93 ------------------------------------------------------------------ 0 24 Bra 2 5 CBra 1 @@ -765,4 +765,7 @@ Memory allocation (code space): 14 25 End ------------------------------------------------------------------ +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/ +Failed: regular expression is too complicated at offset 490 + /-- End of testinput11 --/ diff --git a/pcre/testdata/testoutput11-32 b/pcre/testdata/testoutput11-32 index 57e5da02795..e19518db594 100644 --- a/pcre/testdata/testoutput11-32 +++ b/pcre/testdata/testoutput11-32 @@ -231,7 +231,7 @@ Memory allocation (code space): 155 ------------------------------------------------------------------ /(?Pa)...(?P=a)bbb(?P>a)d/BM -Memory allocation (code space): 157 +Memory allocation (code space): 189 ------------------------------------------------------------------ 0 24 Bra 2 5 CBra 1 @@ -765,4 +765,7 @@ Memory allocation (code space): 28 25 End ------------------------------------------------------------------ +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/ +Failed: missing ) at offset 509 + /-- End of testinput11 --/ diff --git a/pcre/testdata/testoutput11-8 b/pcre/testdata/testoutput11-8 index 748548a5abb..5a4fbb23663 100644 --- a/pcre/testdata/testoutput11-8 +++ b/pcre/testdata/testoutput11-8 @@ -231,7 +231,7 @@ Memory allocation (code space): 45 ------------------------------------------------------------------ /(?Pa)...(?P=a)bbb(?P>a)d/BM -Memory allocation (code space): 50 +Memory allocation (code space): 62 ------------------------------------------------------------------ 0 30 Bra 3 7 CBra 1 @@ -765,4 +765,7 @@ Memory allocation (code space): 10 38 End ------------------------------------------------------------------ +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/ +Failed: missing ) at offset 509 + /-- End of testinput11 --/ diff --git a/pcre/testdata/testoutput2 b/pcre/testdata/testoutput2 index 85c565d1326..5e88d1a7091 100644 --- a/pcre/testdata/testoutput2 +++ b/pcre/testdata/testoutput2 @@ -419,7 +419,7 @@ Need char = '>' /(?U)<.*>/I Capturing subpattern count = 0 -Options: ungreedy +No options First char = '<' Need char = '>' abcghinop @@ -443,7 +443,7 @@ Need char = '=' /(?U)={3,}?/I Capturing subpattern count = 0 -Options: ungreedy +No options First char = '=' Need char = '=' abc========def @@ -477,7 +477,7 @@ Failed: lookbehind assertion is not fixed length at offset 12 /(?i)abc/I Capturing subpattern count = 0 -Options: caseless +No options First char = 'a' (caseless) Need char = 'c' (caseless) @@ -489,7 +489,7 @@ No need char /(?i)^1234/I Capturing subpattern count = 0 -Options: anchored caseless +Options: anchored No first char No need char @@ -502,7 +502,7 @@ No need char /(?s).*/I Capturing subpattern count = 0 May match empty string -Options: anchored dotall +Options: anchored No first char No need char @@ -516,7 +516,7 @@ Starting chars: a b c d /(?i)[abcd]/IS Capturing subpattern count = 0 -Options: caseless +No options No first char No need char Subject length lower bound = 1 @@ -524,7 +524,7 @@ Starting chars: A B C D a b c d /(?m)[xy]|(b|c)/IS Capturing subpattern count = 1 -Options: multiline +No options No first char No need char Subject length lower bound = 1 @@ -538,7 +538,7 @@ No need char /(?i)(^a|^b)/Im Capturing subpattern count = 1 -Options: caseless multiline +Options: multiline First char at start or follows newline No need char @@ -555,13 +555,13 @@ Failed: malformed number or name after (?( at offset 4 Failed: malformed number or name after (?( at offset 4 /(?(?i))/ -Failed: assertion expected after (?( at offset 3 +Failed: assertion expected after (?( or (?(?C) at offset 3 /(?(abc))/ Failed: reference to non-existent subpattern at offset 7 /(?(?.*!.*)?)" -Failed: assertion expected after (?( at offset 3 +Failed: assertion expected after (?( or (?(?C) at offset 3 "X((?2)()*+){2}+"BZ ------------------------------------------------------------------ @@ -14574,4 +14574,100 @@ No match End ------------------------------------------------------------------ +/L(?#(|++)(?J:(?)(?))(?)/ + \O\CC +Matched, but too many substrings +copy substring C failed -7 + +/(?=a\K)/ + ring bpattingbobnd $ 1,oern cou \rb\L +Start of matched string is beyond its end - displaying from end to start. + 0: a + 0L + +/(?<=((?C)0))/ + 9010 +--->9010 + 0 ^ 0 + 0 ^ 0 + 0: + 1: 0 + abcd +--->abcd + 0 ^ 0 + 0 ^ 0 + 0 ^ 0 + 0 ^ 0 +No match + +/((?J)(?'R'(?'R'(?'R'(?'R'(?'R'(?|(\k'R'))))))))/ + +/\N(?(?C)0?!.)*/ +Failed: assertion expected after (?( or (?(?C) at offset 4 + /-- End of testinput2 --/ diff --git a/pcre/testdata/testoutput6 b/pcre/testdata/testoutput6 index beb85aaa0b6..b64dc0dc366 100644 --- a/pcre/testdata/testoutput6 +++ b/pcre/testdata/testoutput6 @@ -2557,4 +2557,20 @@ No match \x{37e} 0: \x{37e} +/[^[:^ascii:]\d]/8W + a + 0: a + ~ + 0: ~ + 0 +No match + \a + 0: \x{07} + \x{7f} + 0: \x{7f} + \x{389} +No match + \x{20ac} +No match + /-- End of testinput6 --/ diff --git a/pcre/testdata/testoutput7 b/pcre/testdata/testoutput7 index cc9ebdd5588..fdfff646d3e 100644 --- a/pcre/testdata/testoutput7 +++ b/pcre/testdata/testoutput7 @@ -2348,4 +2348,24 @@ No match End ------------------------------------------------------------------ +/L(?#(|++ +#include #include #include #include @@ -44,6 +45,13 @@ char *strndup(const char *from, size_t length) } #endif +#ifndef DBUG_OFF +static char pam_debug = 0; +#define PAM_DEBUG(X) do { if (pam_debug) { fprintf X; } } while(0) +#else +#define PAM_DEBUG(X) /* no-op */ +#endif + static int conv(int n, const struct pam_message **msg, struct pam_response **resp, void *data) { @@ -91,12 +99,17 @@ static int conv(int n, const struct pam_message **msg, 4 means "password-like input, echo disabled" C'est la vie. */ param->buf[0] = msg[i]->msg_style == PAM_PROMPT_ECHO_ON ? 2 : 4; + PAM_DEBUG((stderr, "PAM: conv: send(%.*s)\n", (int)(param->ptr - param->buf - 1), param->buf)); if (param->vio->write_packet(param->vio, param->buf, param->ptr - param->buf - 1)) return PAM_CONV_ERR; pkt_len = param->vio->read_packet(param->vio, &pkt); if (pkt_len < 0) + { + PAM_DEBUG((stderr, "PAM: conv: recv() ERROR\n")); return PAM_CONV_ERR; + } + PAM_DEBUG((stderr, "PAM: conv: recv(%.*s)\n", pkt_len, pkt)); /* allocate and copy the reply to the response array */ if (!((*resp)[i].resp= strndup((char*) pkt, pkt_len))) return PAM_CONV_ERR; @@ -134,9 +147,16 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) param.ptr = param.buf + 1; param.vio = vio; + PAM_DEBUG((stderr, "PAM: pam_start(%s, %s)\n", service, info->user_name)); DO( pam_start(service, info->user_name, &pam_start_arg, &pamh) ); + + PAM_DEBUG((stderr, "PAM: pam_authenticate(0)\n")); DO( pam_authenticate (pamh, 0) ); + + PAM_DEBUG((stderr, "PAM: pam_acct_mgmt(0)\n")); DO( pam_acct_mgmt(pamh, 0) ); + + PAM_DEBUG((stderr, "PAM: pam_get_item(PAM_USER)\n")); DO( pam_get_item(pamh, PAM_USER, (pam_get_item_3_arg) &new_username) ); if (new_username && strcmp(new_username, info->user_name)) @@ -145,6 +165,7 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) end: pam_end(pamh, status); + PAM_DEBUG((stderr, "PAM: status = %d user = %s\n", status, new_username)); return status == PAM_SUCCESS ? CR_OK : CR_ERROR; } @@ -163,8 +184,17 @@ static MYSQL_SYSVAR_BOOL(use_cleartext_plugin, use_cleartext_plugin, "supports simple PAM policies that don't require anything besides " "a password", NULL, NULL, 0); +#ifndef DBUG_OFF +static MYSQL_SYSVAR_BOOL(debug, pam_debug, PLUGIN_VAR_OPCMDARG, + "Log all PAM activity", NULL, NULL, 0); +#endif + + static struct st_mysql_sys_var* vars[] = { MYSQL_SYSVAR(use_cleartext_plugin), +#ifndef DBUG_OFF + MYSQL_SYSVAR(debug), +#endif NULL }; diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c index fb149c5cc05..b4db8ece06e 100644 --- a/plugin/auth_pam/mapper/pam_user_map.c +++ b/plugin/auth_pam/mapper/pam_user_map.c @@ -71,6 +71,7 @@ static int populate_user_groups(const char *user, gid_t **groups) static int user_in_group(const gid_t *user_groups, int ng,const char *group) { gid_t group_id; + const gid_t *groups_end = user_groups + ng; { struct group *g= getgrnam(group); @@ -79,7 +80,7 @@ static int user_in_group(const gid_t *user_groups, int ng,const char *group) group_id= g->gr_gid; } - for (; user_groups < user_groups + ng; user_groups++) + for (; user_groups < groups_end; user_groups++) { if (*user_groups == group_id) return 1; @@ -146,7 +147,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, goto ret; } } - pam_err= PAM_SUCCESS; + pam_err= PAM_AUTH_ERR; goto ret; syntax_error: diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc index d04ff6fa9d5..cec3f60505c 100644 --- a/plugin/feedback/url_http.cc +++ b/plugin/feedback/url_http.cc @@ -190,6 +190,7 @@ int Url_http::send(const char* data, size_t data_length) break; closesocket(fd); + fd= INVALID_SOCKET; } freeaddrinfo(addrs); diff --git a/plugin/metadata_lock_info/metadata_lock_info.cc b/plugin/metadata_lock_info/metadata_lock_info.cc index addac713032..6a9f6ef3f6c 100644 --- a/plugin/metadata_lock_info/metadata_lock_info.cc +++ b/plugin/metadata_lock_info/metadata_lock_info.cc @@ -81,25 +81,17 @@ int i_s_metadata_lock_info_fill_row( THD *thd = param->thd; TABLE *table = param->table; DBUG_ENTER("i_s_metadata_lock_info_fill_row"); - MDL_request mdl_request; - enum_mdl_duration mdl_duration; MDL_context *mdl_ctx = mdl_ticket->get_ctx(); enum_mdl_type mdl_ticket_type = mdl_ticket->get_type(); MDL_key *mdl_key = mdl_ticket->get_key(); MDL_key::enum_mdl_namespace mdl_namespace = mdl_key->mdl_namespace(); - mdl_request.init(mdl_key, mdl_ticket_type, MDL_STATEMENT); - mdl_ctx->find_ticket(&mdl_request, &mdl_duration); table->field[0]->store((longlong) mdl_ctx->get_thread_id(), TRUE); table->field[1]->set_notnull(); table->field[1]->store( metadata_lock_info_lock_mode[(int) mdl_ticket_type].str, metadata_lock_info_lock_mode[(int) mdl_ticket_type].length, system_charset_info); - table->field[2]->set_notnull(); - table->field[2]->store( - metadata_lock_info_duration[(int) mdl_duration].str, - metadata_lock_info_duration[(int) mdl_duration].length, - system_charset_info); + table->field[2]->set_null(); table->field[3]->set_notnull(); table->field[3]->store( metadata_lock_info_lock_name[(int) mdl_namespace].str, diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result index 9840aeecf97..5803d7d1290 100644 --- a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result +++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/global_read_lock.result @@ -3,8 +3,8 @@ lock_mode lock_duration lock_type table_schema table_name FLUSH TABLES WITH READ LOCK; SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; lock_mode lock_duration lock_type table_schema table_name -MDL_SHARED MDL_EXPLICIT Global read lock -MDL_SHARED MDL_EXPLICIT Commit lock +MDL_SHARED NULL Commit lock +MDL_SHARED NULL Global read lock UNLOCK TABLES; SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; lock_mode lock_duration lock_type table_schema table_name diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result index 280c8284c54..1b76b9e8222 100644 --- a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result +++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/table_metadata_lock.result @@ -6,7 +6,7 @@ SELECT * FROM t1; a SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; lock_mode lock_duration lock_type table_schema table_name -MDL_SHARED_READ MDL_TRANSACTION Table metadata lock test t1 +MDL_SHARED_READ NULL Table metadata lock test t1 ROLLBACK; SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; lock_mode lock_duration lock_type table_schema table_name diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result index e1d690b566c..34d238cb43b 100644 --- a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result +++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/r/user_lock.result @@ -5,7 +5,7 @@ GET_LOCK('LOCK1',0) 1 SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; lock_mode lock_duration lock_type table_schema table_name -MDL_SHARED_NO_WRITE MDL_EXPLICIT User lock LOCK1 +MDL_SHARED_NO_WRITE NULL User lock LOCK1 SELECT RELEASE_LOCK('LOCK1'); RELEASE_LOCK('LOCK1') 1 diff --git a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test index f221191255e..103050e3fb8 100644 --- a/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test +++ b/plugin/metadata_lock_info/mysql-test/metadata_lock_info/t/global_read_lock.test @@ -1,5 +1,6 @@ SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; FLUSH TABLES WITH READ LOCK; +--sorted_result SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; UNLOCK TABLES; SELECT lock_mode, lock_duration, lock_type, table_schema, table_name FROM information_schema.metadata_lock_info; diff --git a/plugin/simple_password_check/simple_password_check.c b/plugin/simple_password_check/simple_password_check.c index 1b7668204b6..2d2a0ce0e37 100644 --- a/plugin/simple_password_check/simple_password_check.c +++ b/plugin/simple_password_check/simple_password_check.c @@ -14,6 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include #include #include #include @@ -50,12 +52,20 @@ static int validate(MYSQL_LEX_STRING *username, MYSQL_LEX_STRING *password) } static void fix_min_length(MYSQL_THD thd __attribute__((unused)), - struct st_mysql_sys_var *var, + struct st_mysql_sys_var *var __attribute__((unused)), void *var_ptr, const void *save) { + uint new_min_length; *((unsigned int *)var_ptr)= *((unsigned int *)save); - if (min_length < min_digits + 2 * min_letters + min_others) - min_length= min_digits + 2 * min_letters + min_others; + new_min_length= min_digits + 2 * min_letters + min_others; + if (min_length < new_min_length) + { + my_printf_error(ER_TRUNCATED_WRONG_VALUE, + "Adjusted the value of simple_password_check_minimal_length " + "from %u to %u", ME_JUST_WARNING, + min_length, new_min_length); + min_length= new_min_length; + } } static MYSQL_SYSVAR_UINT(minimal_length, min_length, PLUGIN_VAR_RQCMDARG, diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 759104c040a..d960f792a95 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -278,6 +278,15 @@ ELSE() wsrep_sst_xtrabackup-v2 ) ENDIF() + IF (NOT WITHOUT_SERVER) + SET(SERVER_SCRIPTS + mysql_fix_extensions + mysql_zap + mysqld_multi + mysqld_safe + mysqldumpslow + ) + ENDIF() # Configure this one, for testing, but do not install it. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_config.pl.in ${CMAKE_CURRENT_BINARY_DIR}/mysql_config.pl ESCAPE_QUOTES @ONLY) @@ -285,18 +294,14 @@ ELSE() SET(BIN_SCRIPTS msql2mysql mysql_config - mysql_fix_extensions mysql_setpermission mysql_secure_installation - mysql_zap mysqlaccess mysql_convert_table_format mysql_find_rows mytop mysqlhotcopy - mysqldumpslow - mysqld_multi - mysqld_safe + ${SERVER_SCRIPTS} ${WSREP_BINARIES} ${SYSTEMD_SCRIPTS} ) diff --git a/scripts/galera_recovery.sh b/scripts/galera_recovery.sh new file mode 100644 index 00000000000..d734ceb7ac7 --- /dev/null +++ b/scripts/galera_recovery.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +# Copyright (c) 2016 MariaDB Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + +# This script is intended to be executed by systemd. It starts mysqld with +# --wsrep-recover to recover from a non-graceful shutdown, determines the +# last stored global transaction ID and echoes it in --wsrep-start-position=XX +# format. The output is then captured and used by systemd to start mysqld. +# If the server was configured to start without wsrep, nothing is echoed. + +cmdline_args=$@ +user="@MYSQLD_USER@" +print_defaults="@bindir@/my_print_defaults" +log_file=$(mktemp /tmp/wsrep_recovery.XXXXXX) +euid=$(id -u) +recovered_pos="" +skipped="" +start_pos="" +start_pos_opt="" +ret=0 +wsrep_on=0 + +log () +{ + local msg="$1" + # Print all messages to stderr as we reserve stdout for printing + # --wsrep-start-position=XXXX. + echo "$msg" >&2 +} + +finish() +{ + rm -f "$log_file" +} + +trap finish EXIT + +parse_arguments() { + for arg do + val=`echo "$arg" | sed -e "s;--[^=]*=;;"` + case "$arg" in + --wsrep[-_]on) wsrep_on=1 ;; + --skip[-_]wsrep[-_]on) wsrep_on=0 ;; + --wsrep[-_]on=*) + if echo $val | grep -iq '\(ON\|1\)'; then + wsrep_on=1 + else + wsrep_on=0 + fi + ;; + esac + done +} + +wsrep_recover_position() { + # Redirect server's error log to the log file. + eval /usr/sbin/mysqld $cmdline_args --user=$user --wsrep_recover \ + --log-error="$log_file" + ret=$? + if [ $ret -ne 0 ]; then + # Something went wrong, let us also print the error log so that it + # shows up in systemctl status output as a hint to the user. + log "WSREP: Failed to start mysqld for wsrep recovery: '`cat $log_file`'" + exit 1 + fi + + # Parse server's error log for recovered position. The server prints + # "..skipping position recovery.." if started without wsrep. + + recovered_pos="$(grep 'WSREP: Recovered position:' $log_file)" + + if [ -z "$recovered_pos" ]; then + skipped="$(grep WSREP $log_file | grep 'skipping position recovery')" + if [ -z "$skipped" ]; then + log "WSREP: Failed to recover position: '`cat $log_file`'" + exit 1 + else + log "WSREP: Position recovery skipped." + fi + else + start_pos="$(echo $recovered_pos | sed 's/.*WSREP\:\ Recovered\ position://' \ + | sed 's/^[ \t]*//')" + log "WSREP: Recovered position $start_pos" + start_pos_opt="--wsrep_start_position=$start_pos" + fi +} + +# Safety checks +if [ -n "$log_file" -a -f "$log_file" ]; then + [ "$euid" = "0" ] && chown $user $log_file + chmod 600 $log_file +else + log "WSREP: mktemp failed" +fi + +parse_arguments `$print_defaults $cmdline_args --loose-verbose \ + mariadb mariadb_safe mysqld mysqld_safe safe_mysqld galera` + +# Perform wsrep position recovery if wsrep_on=1, skip otherwise. +if [ "$wsrep_on" -eq 1 ]; then + wsrep_recover_position +fi + +echo "$start_pos_opt" + diff --git a/scripts/maria_add_gis_sp.sql.in b/scripts/maria_add_gis_sp.sql.in index 1e2e513cd0a..3a5dd49b95b 100644 --- a/scripts/maria_add_gis_sp.sql.in +++ b/scripts/maria_add_gis_sp.sql.in @@ -23,12 +23,12 @@ SET sql_mode=''; DROP PROCEDURE IF EXISTS AddGeometryColumn; DROP PROCEDURE IF EXISTS DropGeometryColumn; -CREATE PROCEDURE AddGeometryColumn(catalog varchar(64), t_schema varchar(64), +CREATE DEFINER=`root`@`localhost` PROCEDURE AddGeometryColumn(catalog varchar(64), t_schema varchar(64), t_name varchar(64), geometry_column varchar(64), t_srid int) begin set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end @ADD_GIS_SP_EOL@ -CREATE PROCEDURE DropGeometryColumn(catalog varchar(64), t_schema varchar(64), +CREATE DEFINER=`root`@`localhost` PROCEDURE DropGeometryColumn(catalog varchar(64), t_schema varchar(64), t_name varchar(64), geometry_column varchar(64)) begin set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end @ADD_GIS_SP_EOL@ diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in index d1c4aaa1906..d1b299d9ef5 100644 --- a/scripts/mysql_install_db.pl.in +++ b/scripts/mysql_install_db.pl.in @@ -238,7 +238,7 @@ sub quote_options { ############################################################################## my $opt = {}; -parse_arguments($opt, 'PICK-ARGS-FROM-ARGV', @ARGV); +parse_arguments($opt, @ARGV); # ---------------------------------------------------------------------- # We can now find my_print_defaults. This script supports: diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index f8f36bfd28b..cd479d959c1 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -216,7 +216,7 @@ cannot_find_file() # Ok, let's go. We first need to parse arguments which are required by # my_print_defaults so that we can execute it first, then later re-parse # the command line to add any extra bits that we need. -parse_arguments PICK-ARGS-FROM-ARGV "$@" +parse_arguments "$@" # # We can now find my_print_defaults. This script supports: diff --git a/scripts/mysql_secure_installation.pl.in b/scripts/mysql_secure_installation.pl.in index 188a6bd7104..32331c3d601 100644 --- a/scripts/mysql_secure_installation.pl.in +++ b/scripts/mysql_secure_installation.pl.in @@ -217,7 +217,7 @@ sub remove_remote_root { sub remove_test_database { print " - Dropping test database...\n"; - if (do_query("DROP DATABASE test;")) { + if (do_query("DROP DATABASE IF EXISTS test;")) { print " ... Success!\n"; } else { print " ... Failed! Not critical, keep moving...\n"; diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index 82ea1b60a17..2c3b2f8dc8c 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -332,7 +332,7 @@ remove_remote_root() { remove_test_database() { echo " - Dropping test database..." - do_query "DROP DATABASE test;" + do_query "DROP DATABASE IF EXISTS test;" if [ $? -eq 0 ]; then echo " ... Success!" else diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index ca259e5396d..a0bc06e5e58 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -17,7 +17,7 @@ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301, USA -# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -54,6 +54,7 @@ $opt_user = "root"; $opt_version = 0; $opt_silent = 0; $opt_verbose = 0; +$opt_wsrep_new_cluster = 0; my $my_print_defaults_exists= 1; my $logdir= undef(); @@ -126,7 +127,7 @@ sub main # We've already handled --no-defaults, --defaults-file, etc. if (!GetOptions("help", "example", "version", "mysqld=s", "mysqladmin=s", "user=s", "password=s", "log=s", "no-log", - "tcp-ip", "silent", "verbose")) + "tcp-ip", "silent", "verbose", "wsrep-new-cluster")) { $flag_exit= 1; } @@ -378,6 +379,11 @@ sub start_mysqlds() $info_sent= 1; } $com.= $tmp; + + if ($opt_wsrep_new_cluster) { + $com.= " --wsrep-new-cluster"; + } + $com.= " >> $opt_log 2>&1" if (!$opt_no_log); $com.= " &"; if (!$mysqld_found) @@ -625,7 +631,11 @@ sub my_which my ($command) = @_; my (@paths, $path); - return $command if (-f $command && -x $command); + # If the argument is not 'my_print_defaults' then it would be of the format + # / + return $command if ($command ne 'my_print_defaults' && -f $command && + -x $command); + @paths = split(':', $ENV{'PATH'}); foreach $path (@paths) { @@ -848,6 +858,7 @@ Using: @{[join ' ', @defaults_options]} --user=... mysqladmin user. Using: $opt_user --verbose Be more verbose. --version Print the version number and exit. +--wsrep-new-cluster Bootstrap a cluster. EOF exit(0); } diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 13206ce0e56..07bca1c0318 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -332,14 +332,21 @@ parse_arguments() { --timezone=*) TZ="$val"; export TZ; ;; --flush[-_]caches) flush_caches=1 ;; --numa[-_]interleave) numa_interleave=1 ;; - --wsrep[-_]on) wsrep_on=1 ;; - --skip[-_]wsrep[-_]on) wsrep_on=0 ;; + --wsrep[-_]on) + wsrep_on=1 + append_arg_to_args "$arg" + ;; + --skip[-_]wsrep[-_]on) + wsrep_on=0 + append_arg_to_args "$arg" + ;; --wsrep[-_]on=*) if echo $val | grep -iq '\(ON\|1\)'; then wsrep_on=1 else wsrep_on=0 fi + append_arg_to_args "$arg" ;; --wsrep[-_]urls=*) wsrep_urls="$val"; ;; --wsrep[-_]provider=*) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 5f67507b577..f173a861e85 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -188,7 +188,7 @@ wsrep_log_info() wsrep_cleanup_progress_file() { - [ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null + [ -n "${SST_PROGRESS_FILE:-}" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null || true } wsrep_check_program() diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 7e895aa4eb2..10d6896accd 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -222,7 +222,8 @@ then [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo) [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu) - find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -I{} -0 -P $count \ + find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" -print0 | \ + xargs -I{} -0 -P $count \ rsync --owner --group --perms --links --specials \ --ignore-times --inplace --recursive --delete --quiet \ $WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \ diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 872589254d4..63febe556da 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -34,6 +34,7 @@ ssystag="" XTRABACKUP_PID="" SST_PORT="" REMOTEIP="" +REMOTEHOST="" tcert="" tpem="" tkey="" @@ -208,7 +209,7 @@ get_transfer() tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio" else wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}" - tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}" + tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}" fi elif [[ $encrypt -eq 3 ]];then wsrep_log_info "Using openssl based encryption with socat: with key and crt" @@ -231,7 +232,7 @@ get_transfer() tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}" else wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}" - tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}" + tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}" fi fi @@ -495,6 +496,10 @@ setup_ports() if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }') REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }') + REMOTEHOST=$(getent hosts $REMOTEIP | awk '{ print $2 }') + if [[ -z $REMOTEHOST ]];then + REMOTEHOST=$REMOTEIP + fi lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }') sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }') else @@ -684,6 +689,7 @@ then if [ $WSREP_SST_OPT_BYPASS -eq 0 ] then + usrst=0 if [[ -z $sst_ver ]];then wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support" wsrep_log_error "The joiner is not supported for this version of donor" @@ -699,13 +705,14 @@ then itmpdir=$(mktemp -d) wsrep_log_info "Using $itmpdir as innobackupex temporary directory" - if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then + if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then INNOEXTRA+=" --user=$WSREP_SST_OPT_USER" + usrst=1 fi if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" - else + elif [[ $usrst -eq 1 ]];then # Empty password, used for testing, debugging etc. INNOEXTRA+=" --password=" fi diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh index 2247edec7fd..22923ab3e88 100644 --- a/scripts/wsrep_sst_xtrabackup.sh +++ b/scripts/wsrep_sst_xtrabackup.sh @@ -436,15 +436,17 @@ then if [ $WSREP_SST_OPT_BYPASS -eq 0 ] then + usrst=0 TMPDIR="${TMPDIR:-/tmp}" - if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then + if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then INNOEXTRA+=" --user=$WSREP_SST_OPT_USER" + usrst=1 fi if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD" - else + elif [[ $usrst -eq 1 ]];then # Empty password, used for testing, debugging etc. INNOEXTRA+=" --password=" fi diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index 892d301c70d..7e83b7365e3 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -204,6 +204,11 @@ sub new $limits{'max_temporary_tables'}= $limits{"max_tables"}; $self->{'transactions'} = 1; # Transactions enabled } + if (defined($main::opt_create_options) && + $main::opt_create_options =~ /engine=tokudb/i) + { + $self->{'transactions'} = 1; # Transactions enabled + } return $self; } diff --git a/sql-bench/test-table-elimination.sh b/sql-bench/test-table-elimination.sh index 7772cab42b0..de440fc0633 100755 --- a/sql-bench/test-table-elimination.sh +++ b/sql-bench/test-table-elimination.sh @@ -305,6 +305,7 @@ if ($opt_lock_tables) if (!$opt_skip_delete) { do_query($dbh,"drop table elim_facts, elim_attr1, elim_attr2" . $server->{'drop_attr'}); + $dbh->do("drop view elim_current_facts"); } if ($opt_fast && defined($server->{vacuum})) diff --git a/sql-common/client.c b/sql-common/client.c index 9904719e616..756d1c1972c 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1045,28 +1045,44 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd) } while (0) -#define EXTENSION_SET_STRING(OPTS, X, STR) \ +#define EXTENSION_SET_STRING_X(OPTS, X, STR, dup) \ do { \ if ((OPTS)->extension) \ my_free((OPTS)->extension->X); \ else \ ALLOCATE_EXTENSIONS(OPTS); \ (OPTS)->extension->X= ((STR) != NULL) ? \ - my_strdup((STR), MYF(MY_WME)) : NULL; \ + dup((STR), MYF(MY_WME)) : NULL; \ } while (0) +#define EXTENSION_SET_STRING(OPTS, X, STR) \ + EXTENSION_SET_STRING_X(OPTS, X, STR, my_strdup) + #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) -#define SET_SSL_OPTION(OPTS, opt_var, arg) \ - my_free((OPTS)->opt_var); \ - (OPTS)->opt_var= arg ? my_strdup(arg, MYF(MY_WME)) : NULL; -#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) \ - EXTENSION_SET_STRING((OPTS), X, (STR)); +#define SET_SSL_OPTION_X(OPTS, opt_var, arg, dup) \ + my_free((OPTS)->opt_var); \ + (OPTS)->opt_var= arg ? dup(arg, MYF(MY_WME)) : NULL; +#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) \ + EXTENSION_SET_STRING_X((OPTS), X, (STR), dup); + +static char *set_ssl_option_unpack_path(const char *arg, myf flags) +{ + char buff[FN_REFLEN + 1]; + unpack_filename(buff, (char *)arg); + return my_strdup(buff, flags); +} + #else -#define SET_SSL_OPTION(OPTS, opt_var,arg) do { } while(0) -#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) do { } while(0) +#define SET_SSL_OPTION_X(OPTS, opt_var,arg, dup) do { } while(0) +#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) do { } while(0) #endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */ +#define SET_SSL_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, my_strdup) +#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, my_strdup) +#define SET_SSL_PATH_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, set_ssl_option_unpack_path) +#define EXTENSION_SET_SSL_PATH_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, set_ssl_option_unpack_path) + void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group) { @@ -3627,6 +3643,9 @@ error: /* Free alloced memory */ end_server(mysql); mysql_close_free(mysql); + if (!(client_flag & CLIENT_REMEMBER_OPTIONS) && + !mysql->options.extension->async_context) + mysql_close_free_options(mysql); } DBUG_RETURN(0); } @@ -3697,7 +3716,7 @@ my_bool mysql_reconnect(MYSQL *mysql) } if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, mysql->db, mysql->port, mysql->unix_socket, - mysql->client_flag)) + mysql->client_flag | CLIENT_REMEMBER_OPTIONS)) { if (ctxt) my_context_install_suspend_resume_hook(ctxt, NULL, NULL); @@ -4372,25 +4391,25 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg) mysql->net.vio->async_context= ctxt; break; case MYSQL_OPT_SSL_KEY: - SET_SSL_OPTION(&mysql->options,ssl_key, arg); + SET_SSL_PATH_OPTION(&mysql->options,ssl_key, arg); break; case MYSQL_OPT_SSL_CERT: - SET_SSL_OPTION(&mysql->options, ssl_cert, arg); + SET_SSL_PATH_OPTION(&mysql->options, ssl_cert, arg); break; case MYSQL_OPT_SSL_CA: - SET_SSL_OPTION(&mysql->options,ssl_ca, arg); + SET_SSL_PATH_OPTION(&mysql->options,ssl_ca, arg); break; case MYSQL_OPT_SSL_CAPATH: - SET_SSL_OPTION(&mysql->options,ssl_capath, arg); + SET_SSL_PATH_OPTION(&mysql->options,ssl_capath, arg); break; case MYSQL_OPT_SSL_CIPHER: SET_SSL_OPTION(&mysql->options,ssl_cipher, arg); break; case MYSQL_OPT_SSL_CRL: - EXTENSION_SET_SSL_STRING(&mysql->options, ssl_crl, arg); + EXTENSION_SET_SSL_PATH_STRING(&mysql->options, ssl_crl, arg); break; case MYSQL_OPT_SSL_CRLPATH: - EXTENSION_SET_SSL_STRING(&mysql->options, ssl_crlpath, arg); + EXTENSION_SET_SSL_PATH_STRING(&mysql->options, ssl_crlpath, arg); break; case MYSQL_OPT_CONNECT_ATTR_RESET: ENSURE_EXTENSIONS_PRESENT(&mysql->options); diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 28757a2c96c..7cf8692a3f6 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -224,7 +224,7 @@ my_bool check_datetime_range(const MYSQL_TIME *ltime) ltime->minute > 59 || ltime->second > 59 || ltime->second_part > TIME_MAX_SECOND_PART || (ltime->hour > - (ltime->time_type == MYSQL_TIMESTAMP_TIME ? TIME_MAX_HOUR : 23)); + (uint) (ltime->time_type == MYSQL_TIMESTAMP_TIME ? TIME_MAX_HOUR : 23)); } @@ -237,7 +237,7 @@ static void get_microseconds(ulong *val, MYSQL_TIME_STATUS *status, if (get_digits(&tmp, number_of_fields, str, end, 6)) status->warnings|= MYSQL_TIME_WARN_TRUNCATED; if ((status->precision= (*str - start)) < 6) - *val= tmp * log_10_int[6 - (*str - start)]; + *val= (ulong) (tmp * log_10_int[6 - (*str - start)]); else *val= tmp; if (skip_digits(str, end)) diff --git a/sql-common/mysql_async.c b/sql-common/mysql_async.c index 80b4f390641..decf48e0e69 100644 --- a/sql-common/mysql_async.c +++ b/sql-common/mysql_async.c @@ -455,7 +455,11 @@ MK_ASYNC_START_BODY( parms.db= db; parms.port= port; parms.unix_socket= unix_socket; - parms.client_flags= client_flags; + /* + async wrapper enforce the CLIENT_REMEMBER_OPTIONS flag to be + functional (otherwise it can't operate) + */ + parms.client_flags= client_flags | CLIENT_REMEMBER_OPTIONS; }, NULL, r_ptr, diff --git a/sql/contributors.h b/sql/contributors.h index 04f8b74aa65..f52d3243453 100644 --- a/sql/contributors.h +++ b/sql/contributors.h @@ -36,17 +36,16 @@ struct show_table_contributors_st { */ struct show_table_contributors_st show_table_contributors[]= { - /* MariaDB foundation members, in contribution, size , time order */ - {"Booking.com", "http://www.booking.com", "Founding member of the MariaDB Foundation"}, - {"MariaDB Corporation", "https://mariadb.com", "Founding member of the MariaDB Foundation"}, - {"Auttomattic", "http://automattic.com", "Member of the MariaDB Foundation"}, - {"Visma", "http://visma.com", "Member of the MariaDB Foundation"}, - {"Nexedi", "http://www.nexedi.com", "Member of the MariaDB Foundation"}, - {"Acronis", "http://www.acronis.com", "Member of the MariaDB Foundation"}, - - /* Smaller sponsors, newer per year */ - {"Verkkokauppa.com", "Finland", "Sponsor of the MariaDB Foundation"}, - {"Webyog", "Bangalore", "Sponsor of the MariaDB Foundation"}, + /* MariaDB foundation sponsors, in contribution, size , time order */ + {"Booking.com", "http://www.booking.com", "Founding member, Platinum Sponsor of the MariaDB Foundation"}, + {"MariaDB Corporation", "https://mariadb.com", "Founding member, Gold Sponsor of the MariaDB Foundation"}, + {"Visma", "http://visma.com", "Gold Sponsor of the MariaDB Foundation"}, + {"DBS", "http://dbs.com", "Gold Sponsor of the MariaDB Foundation"}, + {"Nexedi", "https://www.nexedi.com", "Silver Sponsor of the MariaDB Foundation"}, + {"Acronis", "http://www.acronis.com", "Silver Sponsor of the MariaDB Foundation"}, + {"Auttomattic", "https://automattic.com", "Bronze Sponsor of the MariaDB Foundation"}, + {"Verkkokauppa.com", "https://virtuozzo.com", "Bronze Sponsor of the MariaDB Foundation"}, + {"Virtuozzo", "https://virtuozzo.com/", "Bronze Sponsor of the MariaDB Foundation"}, /* Sponsors of important features */ {"Google", "USA", "Sponsoring encryption, parallel replication and GTID"}, diff --git a/sql/derror.cc b/sql/derror.cc index bc4b89493aa..5f0bc455caf 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -35,7 +35,7 @@ static void init_myfunc_errs(void); C_MODE_START -static const char **get_server_errmsgs() +static const char **get_server_errmsgs(void) { if (!current_thd) return DEFAULT_ERRMSGS; diff --git a/sql/field.cc b/sql/field.cc index ffa7beb275b..ae815187019 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1477,10 +1477,12 @@ Value_source::Converter_string_to_number::check_edom_and_truncation(THD *thd, */ -int Field_num::check_edom_and_truncation(const char *type, bool edom, - CHARSET_INFO *cs, - const char *str, uint length, - const char *end) +int Field_num::check_edom_and_important_data_truncation(const char *type, + bool edom, + CHARSET_INFO *cs, + const char *str, + uint length, + const char *end) { /* Test if we get an empty string or garbage */ if (edom) @@ -1495,12 +1497,23 @@ int Field_num::check_edom_and_truncation(const char *type, bool edom, set_warning(WARN_DATA_TRUNCATED, 1); return 2; } - if (end < str + length) - set_note(WARN_DATA_TRUNCATED, 1); return 0; } +int Field_num::check_edom_and_truncation(const char *type, bool edom, + CHARSET_INFO *cs, + const char *str, uint length, + const char *end) +{ + int rc= check_edom_and_important_data_truncation(type, edom, + cs, str, length, end); + if (!rc && end < str + length) + set_note(WARN_DATA_TRUNCATED, 1); + return rc; +} + + /* Conver a string to an integer then check bounds. @@ -2025,6 +2038,7 @@ Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, if (charset_arg->state & MY_CS_BINSORT) flags|=BINARY_FLAG; field_derivation= DERIVATION_IMPLICIT; + field_repertoire= my_charset_repertoire(charset_arg); } @@ -3005,7 +3019,8 @@ void Field_new_decimal::set_value_on_overflow(my_decimal *decimal_value, If it does, stores the decimal in the buffer using binary format. Otherwise sets maximal number that can be stored in the field. - @param decimal_value my_decimal + @param decimal_value my_decimal + @param [OUT] native_error the error returned by my_decimal2binary(). @retval 0 ok @@ -3013,7 +3028,8 @@ void Field_new_decimal::set_value_on_overflow(my_decimal *decimal_value, 1 error */ -bool Field_new_decimal::store_value(const my_decimal *decimal_value) +bool Field_new_decimal::store_value(const my_decimal *decimal_value, + int *native_error) { ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; int error= 0; @@ -3042,11 +3058,14 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value) } #endif - if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, - decimal_value, ptr, precision, dec))) + *native_error= my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, + decimal_value, ptr, precision, dec); + + if (*native_error == E_DEC_OVERFLOW) { my_decimal buff; DBUG_PRINT("info", ("overflow")); + set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); set_value_on_overflow(&buff, decimal_value->sign()); my_decimal2binary(E_DEC_FATAL_ERROR, &buff, ptr, precision, dec); error= 1; @@ -3057,6 +3076,16 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value) } +bool Field_new_decimal::store_value(const my_decimal *decimal_value) +{ + int native_error; + bool rc= store_value(decimal_value, &native_error); + if (!rc && native_error == E_DEC_TRUNCATED) + set_note(WARN_DATA_TRUNCATED, 1); + return rc; +} + + int Field_new_decimal::store(const char *from, uint length, CHARSET_INFO *charset_arg) { @@ -3084,9 +3113,10 @@ int Field_new_decimal::store(const char *from, uint length, if (thd->count_cuted_fields) { - if (check_edom_and_truncation("decimal", - err && err != E_DEC_TRUNCATED, - charset_arg, from, length, end)) + if (check_edom_and_important_data_truncation("decimal", + err && err != E_DEC_TRUNCATED, + charset_arg, + from, length, end)) { if (!thd->abort_on_warning) { @@ -3109,12 +3139,6 @@ int Field_new_decimal::store(const char *from, uint length, } DBUG_RETURN(1); } - /* - E_DEC_TRUNCATED means minor truncation '1e-1000000000000' -> 0.0 - A note should be enough. - */ - if (err == E_DEC_TRUNCATED) - set_note(WARN_DATA_TRUNCATED, 1); } #ifndef DBUG_OFF @@ -3122,7 +3146,21 @@ int Field_new_decimal::store(const char *from, uint length, DBUG_PRINT("enter", ("value: %s", dbug_decimal_as_string(dbug_buff, &decimal_value))); #endif - store_value(&decimal_value); + int err2; + if (store_value(&decimal_value, &err2)) + DBUG_RETURN(1); + + /* + E_DEC_TRUNCATED means minor truncation, a note should be enough: + - in err: str2my_decimal() truncated '1e-1000000000000' to 0.0 + - in err2: store_value() truncated 1.123 to 1.12, e.g. for DECIMAL(10,2) + Also, we send a note if a string had some trailing spaces: '1.12 ' + */ + if (thd->count_cuted_fields && + (err == E_DEC_TRUNCATED || + err2 == E_DEC_TRUNCATED || + end < from + length)) + set_note(WARN_DATA_TRUNCATED, 1); DBUG_RETURN(0); } diff --git a/sql/field.h b/sql/field.h index 08905f2c9e9..30f24ecc1bb 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1215,11 +1215,12 @@ public: { return binary() ? &my_charset_bin : charset(); } virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual bool has_charset(void) const { return FALSE; } - virtual void set_charset(CHARSET_INFO *charset_arg) { } virtual enum Derivation derivation(void) const { return DERIVATION_IMPLICIT; } virtual uint repertoire(void) const { return MY_REPERTOIRE_UNICODE30; } - virtual void set_derivation(enum Derivation derivation_arg) { } + virtual void set_derivation(enum Derivation derivation_arg, + uint repertoire_arg) + { } virtual int set_time() { return 1; } bool set_warning(Sql_condition::enum_warning_level, unsigned int code, int cuted_increment) const; @@ -1471,6 +1472,10 @@ protected: class Field_num :public Field { protected: + int check_edom_and_important_data_truncation(const char *type, bool edom, + CHARSET_INFO *cs, + const char *str, uint length, + const char *end_of_num); int check_edom_and_truncation(const char *type, bool edom, CHARSET_INFO *cs, const char *str, uint length, @@ -1533,8 +1538,10 @@ public: class Field_str :public Field { protected: + // TODO-10.2: Reuse DTCollation instead of these three members CHARSET_INFO *field_charset; enum Derivation field_derivation; + uint field_repertoire; public: bool can_be_substituted_to_equal_item(const Context &ctx, const Item_equal *item_equal); @@ -1547,15 +1554,15 @@ public: int store(longlong nr, bool unsigned_val)=0; int store_decimal(const my_decimal *); int store(const char *to,uint length,CHARSET_INFO *cs)=0; - uint repertoire(void) const - { - return my_charset_repertoire(field_charset); - } + uint repertoire(void) const { return field_repertoire; } CHARSET_INFO *charset(void) const { return field_charset; } - void set_charset(CHARSET_INFO *charset_arg) { field_charset= charset_arg; } enum Derivation derivation(void) const { return field_derivation; } - virtual void set_derivation(enum Derivation derivation_arg) - { field_derivation= derivation_arg; } + void set_derivation(enum Derivation derivation_arg, + uint repertoire_arg) + { + field_derivation= derivation_arg; + field_repertoire= repertoire_arg; + } bool binary() const { return field_charset == &my_charset_bin; } uint32 max_display_length() { return field_length; } friend class Create_field; @@ -1708,6 +1715,7 @@ public: Item_result result_type () const { return DECIMAL_RESULT; } int reset(void); bool store_value(const my_decimal *decimal_value); + bool store_value(const my_decimal *decimal_value, int *native_error); void set_value_on_overflow(my_decimal *decimal_value, bool sign); int store(const char *to, uint length, CHARSET_INFO *charset); int store(double nr); @@ -2987,10 +2995,9 @@ public: packlength= 4; if (set_packlength) { - uint32 l_char_length= len_arg/cs->mbmaxlen; - packlength= l_char_length <= 255 ? 1 : - l_char_length <= 65535 ? 2 : - l_char_length <= 16777215 ? 3 : 4; + packlength= len_arg <= 255 ? 1 : + len_arg <= 65535 ? 2 : + len_arg <= 16777215 ? 3 : 4; } } Field_blob(uint32 packlength_arg) diff --git a/sql/handler.cc b/sql/handler.cc index 49e451e3836..de456f703f1 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -296,7 +296,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(void) { return handler_errmsgs; } @@ -1360,7 +1360,8 @@ int ha_commit_trans(THD *thd, bool all) uint rw_ha_count= ha_check_and_coalesce_trx_read_only(thd, ha_info, all); /* rw_trans is TRUE when we in a transaction changing data */ - bool rw_trans= is_real_trans && (rw_ha_count > 0); + bool rw_trans= is_real_trans && + (rw_ha_count > !thd->is_current_stmt_binlog_disabled()); MDL_request mdl_request; DBUG_PRINT("info", ("is_real_trans: %d rw_trans: %d rw_ha_count: %d", is_real_trans, rw_trans, rw_ha_count)); @@ -2736,6 +2737,15 @@ int handler::ha_index_next_same(uchar *buf, const uchar *key, uint keylen) return result; } + +bool handler::ha_was_semi_consistent_read() +{ + bool result= was_semi_consistent_read(); + if (result) + increment_statistics(&SSV::ha_read_retry_count); + return result; +} + /* Initialize handler for random reading, with error handling */ int handler::ha_rnd_init_with_error(bool scan) @@ -5887,6 +5897,17 @@ int handler::ha_write_row(uchar *buf) rows_changed++; if (unlikely(error= binlog_log_row(table, 0, buf, log_func))) DBUG_RETURN(error); /* purecov: inspected */ +#ifdef WITH_WSREP + current_thd->wsrep_affected_rows++; + if (wsrep_max_ws_rows && + current_thd->wsrep_exec_mode != REPL_RECV && + current_thd->wsrep_affected_rows > wsrep_max_ws_rows) + { + trans_rollback_stmt(current_thd) || trans_rollback(current_thd); + my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); + DBUG_RETURN(ER_ERROR_DURING_COMMIT); + } +#endif /* WITH_WSREP */ DEBUG_SYNC_C("ha_write_row_end"); DBUG_RETURN(0); @@ -5920,6 +5941,17 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) rows_changed++; if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func))) return error; +#ifdef WITH_WSREP + current_thd->wsrep_affected_rows++; + if (wsrep_max_ws_rows && + current_thd->wsrep_exec_mode != REPL_RECV && + current_thd->wsrep_affected_rows > wsrep_max_ws_rows) + { + trans_rollback_stmt(current_thd) || trans_rollback(current_thd); + my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); + return ER_ERROR_DURING_COMMIT; + } +#endif /* WITH_WSREP */ return 0; } @@ -5947,6 +5979,17 @@ int handler::ha_delete_row(const uchar *buf) rows_changed++; if (unlikely(error= binlog_log_row(table, buf, 0, log_func))) return error; +#ifdef WITH_WSREP + current_thd->wsrep_affected_rows++; + if (wsrep_max_ws_rows && + current_thd->wsrep_exec_mode != REPL_RECV && + current_thd->wsrep_affected_rows > wsrep_max_ws_rows) + { + trans_rollback_stmt(current_thd) || trans_rollback(current_thd); + my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); + return ER_ERROR_DURING_COMMIT; + } +#endif /* WITH_WSREP */ return 0; } @@ -6078,7 +6121,10 @@ int ha_abort_transaction(THD *bf_thd, THD *victim_thd, my_bool signal) DBUG_RETURN(0); } - THD_TRANS *trans= &victim_thd->transaction.all; + /* Try statement transaction if standard one is not set. */ + THD_TRANS *trans= (victim_thd->transaction.all.ha_list) ? + &victim_thd->transaction.all : &victim_thd->transaction.stmt; + Ha_trx_info *ha_info= trans->ha_list, *ha_info_next; for (; ha_info; ha_info= ha_info_next) @@ -6086,8 +6132,8 @@ int ha_abort_transaction(THD *bf_thd, THD *victim_thd, my_bool signal) handlerton *hton= ha_info->ht(); if (!hton->abort_transaction) { - /* Skip warning for binlog SE */ - if (hton->db_type != DB_TYPE_BINLOG) + /* Skip warning for binlog & wsrep. */ + if (hton->db_type != DB_TYPE_BINLOG && hton != wsrep_hton) { WSREP_WARN("Cannot abort transaction."); } @@ -6104,25 +6150,42 @@ int ha_abort_transaction(THD *bf_thd, THD *victim_thd, my_bool signal) void ha_fake_trx_id(THD *thd) { DBUG_ENTER("ha_fake_trx_id"); + + bool no_fake_trx_id= true; + if (!WSREP(thd)) { DBUG_VOID_RETURN; } - THD_TRANS *trans= &thd->transaction.all; + /* Try statement transaction if standard one is not set. */ + THD_TRANS *trans= (thd->transaction.all.ha_list) ? &thd->transaction.all : + &thd->transaction.stmt; + Ha_trx_info *ha_info= trans->ha_list, *ha_info_next; for (; ha_info; ha_info= ha_info_next) { handlerton *hton= ha_info->ht(); - if (!hton->fake_trx_id) + if (hton->fake_trx_id) { - WSREP_WARN("cannot get fake InnoDB transaction ID"); - } - else hton->fake_trx_id(hton, thd); + + /* Got a fake trx id. */ + no_fake_trx_id= false; + + /* + We need transaction ID from just one storage engine providing + fake_trx_id (which will most likely be the case). + */ + break; + } ha_info_next= ha_info->next(); } + + if (unlikely(no_fake_trx_id)) + WSREP_WARN("Cannot get fake transaction ID from storage engine."); + DBUG_VOID_RETURN; } #endif /* WITH_WSREP */ @@ -6316,3 +6379,98 @@ bool HA_CREATE_INFO::check_conflicting_charset_declarations(CHARSET_INFO *cs) } return false; } + +/* Remove all indexes for a given table from global index statistics */ + +static +int del_global_index_stats_for_table(THD *thd, uchar* cache_key, uint cache_key_length) +{ + int res = 0; + DBUG_ENTER("del_global_index_stats_for_table"); + + mysql_mutex_lock(&LOCK_global_index_stats); + + for (uint i= 0; i < global_index_stats.records;) + { + INDEX_STATS *index_stats = + (INDEX_STATS*) my_hash_element(&global_index_stats, i); + + /* We search correct db\0table_name\0 string */ + if (index_stats && + index_stats->index_name_length >= cache_key_length && + !memcmp(index_stats->index, cache_key, cache_key_length)) + { + res= my_hash_delete(&global_index_stats, (uchar*)index_stats); + /* + In our HASH implementation on deletion one elements + is moved into a place where a deleted element was, + and the last element is moved into the empty space. + Thus we need to re-examine the current element, but + we don't have to restart the search from the beginning. + */ + } + else + i++; + } + + mysql_mutex_unlock(&LOCK_global_index_stats); + DBUG_RETURN(res); +} + +/* Remove a table from global table statistics */ + +int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table) +{ + TABLE_STATS *table_stats; + int res = 0; + uchar *cache_key; + uint cache_key_length; + DBUG_ENTER("del_global_table_stat"); + + cache_key_length= db->length + 1 + table->length + 1; + + if(!(cache_key= (uchar *)my_malloc(cache_key_length, + MYF(MY_WME | MY_ZEROFILL)))) + { + /* Out of memory error already given */ + res = 1; + goto end; + } + + memcpy(cache_key, db->str, db->length); + memcpy(cache_key + db->length + 1, table->str, table->length); + + res= del_global_index_stats_for_table(thd, cache_key, cache_key_length); + + mysql_mutex_lock(&LOCK_global_table_stats); + + if((table_stats= (TABLE_STATS*) my_hash_search(&global_table_stats, + cache_key, + cache_key_length))) + res= my_hash_delete(&global_table_stats, (uchar*)table_stats); + + my_free(cache_key); + mysql_mutex_unlock(&LOCK_global_table_stats); + +end: + DBUG_RETURN(res); +} + +/* Remove a index from global index statistics */ + +int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info) +{ + INDEX_STATS *index_stats; + uint key_length= table->s->table_cache_key.length + key_info->name_length + 1; + int res = 0; + DBUG_ENTER("del_global_index_stat"); + mysql_mutex_lock(&LOCK_global_index_stats); + + if((index_stats= (INDEX_STATS*) my_hash_search(&global_index_stats, + key_info->cache_name, + key_length))) + res= my_hash_delete(&global_index_stats, (uchar*)index_stats); + + mysql_mutex_unlock(&LOCK_global_index_stats); + DBUG_RETURN(res); +} diff --git a/sql/handler.h b/sql/handler.h index 3ffe4d03596..dad2b81b39c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3214,6 +3214,7 @@ public: If this method returns nonzero, it will also signal the storage engine that the next read will be a locking re-read of the row. */ + bool ha_was_semi_consistent_read(); virtual bool was_semi_consistent_read() { return 0; } /** Tell the engine whether it should avoid unnecessary lock waits. @@ -4286,4 +4287,7 @@ inline const char *table_case_name(HA_CREATE_INFO *info, const char *name) void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag); void print_keydup_error(TABLE *table, KEY *key, myf errflag); + +int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info); +int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table); #endif /* HANDLER_INCLUDED */ diff --git a/sql/item.cc b/sql/item.cc index adf70312b37..a9c17ef620c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -57,6 +57,17 @@ bool cmp_items(Item *a, Item *b) } +/** + Set max_sum_func_level if it is needed +*/ +inline void set_max_sum_func_level(THD *thd, SELECT_LEX *select) +{ + if (thd->lex->in_sum_func && + thd->lex->in_sum_func->nest_level >= select->nest_level) + set_if_bigger(thd->lex->in_sum_func->max_sum_func_level, + select->nest_level - 1); +} + /***************************************************************************** ** Item functions *****************************************************************************/ @@ -186,9 +197,6 @@ bool Item::get_time_with_conversion(THD *thd, MYSQL_TIME *ltime, */ String *Item::val_str_ascii(String *str) { - if (!(collation.collation->state & MY_CS_NONASCII)) - return val_str(str); - DBUG_ASSERT(str != &str_value); uint errors; @@ -196,11 +204,15 @@ String *Item::val_str_ascii(String *str) if (!res) return 0; - if ((null_value= str->copy(res->ptr(), res->length(), - collation.collation, &my_charset_latin1, - &errors))) - return 0; - + if (!(res->charset()->state & MY_CS_NONASCII)) + str= res; + else + { + if ((null_value= str->copy(res->ptr(), res->length(), collation.collation, + &my_charset_latin1, &errors))) + return 0; + } + return str; } @@ -4884,6 +4896,11 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) if (rf->fix_fields(thd, reference) || rf->check_cols(1)) return -1; + /* + We can not "move" aggregate function in the place where + its arguments are not defined. + */ + set_max_sum_func_level(thd, select); mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, rf, rf); @@ -4892,6 +4909,11 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) } else { + /* + We can not "move" aggregate function in the place where + its arguments are not defined. + */ + set_max_sum_func_level(thd, select); mark_as_dependent(thd, last_checked_context->select_lex, context->select_lex, this, (Item_ident*)*reference); @@ -5023,6 +5045,11 @@ bool Item_field::fix_fields(THD *thd, Item **reference) return(1); } + /* + We can not "move" aggregate function in the place where + its arguments are not defined. + */ + set_max_sum_func_level(thd, thd->lex->current_select); set_field(new_field); return 0; } @@ -5047,6 +5074,11 @@ bool Item_field::fix_fields(THD *thd, Item **reference) select->parsing_place == IN_GROUP_BY && alias_name_used ? *rf->ref : rf); + /* + We can not "move" aggregate function in the place where + its arguments are not defined. + */ + set_max_sum_func_level(thd, thd->lex->current_select); return FALSE; } } diff --git a/sql/item.h b/sql/item.h index bef57c4a967..1905e0f1216 100644 --- a/sql/item.h +++ b/sql/item.h @@ -657,6 +657,8 @@ protected: SEL_TREE *get_mm_tree_for_const(RANGE_OPT_PARAM *param); + Field *create_tmp_field(bool group, TABLE *table, uint convert_int_length); + public: /* Cache val_str() into the own buffer, e.g. to evaluate constant @@ -1021,9 +1023,7 @@ public: int save_str_value_in_field(Field *field, String *result); virtual Field *get_tmp_table_field() { return 0; } - /* This is also used to create fields in CREATE ... SELECT: */ - virtual Field *tmp_table_field(TABLE *t_arg) { return 0; } - virtual Field *create_field_for_create_select(THD *thd, TABLE *table); + virtual Field *create_field_for_create_select(TABLE *table); virtual Field *create_field_for_schema(THD *thd, TABLE *table); virtual const char *full_name() const { return name ? name : "???"; } const char *field_name_or_null() @@ -1630,6 +1630,15 @@ public: // used in row subselects to get value of elements virtual void bring_value() {} + virtual Field *create_tmp_field(bool group, TABLE *table) + { + /* + Values with MY_INT32_NUM_DECIMAL_DIGITS digits may or may not fit into + Field_long : make them Field_longlong. + */ + return create_tmp_field(false, table, MY_INT32_NUM_DECIMAL_DIGITS - 2); + } + Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length, bool set_blob_packlength); @@ -2224,7 +2233,6 @@ public: {} ~Item_result_field() {} /* Required with gcc 2.95 */ Field *get_tmp_table_field() { return result_field; } - Field *tmp_table_field(TABLE *t_arg) { return result_field; } /* This implementation of used_tables() used by Item_avg_field and Item_variance_field which work when only temporary table left, so theu @@ -3397,8 +3405,6 @@ public: { return val_real_from_date(); } my_decimal *val_decimal(my_decimal *decimal_value) { return val_decimal_from_date(decimal_value); } - Field *tmp_table_field(TABLE *table) - { return tmp_table_field_from_field_type(table, false, false); } int save_in_field(Field *field, bool no_conversions) { return save_date_in_field(field); } }; @@ -3903,7 +3909,6 @@ public: enum_field_types field_type() const { return (*ref)->field_type(); } Field *get_tmp_table_field() { return result_field ? result_field : (*ref)->get_tmp_table_field(); } - Field *tmp_table_field(TABLE *t_arg) { return 0; } Item *get_tmp_table_item(THD *thd); table_map used_tables() const; void update_used_tables(); @@ -5050,7 +5055,7 @@ public: bool basic_const_item() const { return MY_TEST(example && example->basic_const_item()); } virtual void clear() { null_value= TRUE; value_cached= FALSE; } - bool is_null() { return null_value; } + bool is_null() { return !has_value(); } virtual bool is_expensive() { if (value_cached) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f3196c55873..bd1e8b72157 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2263,11 +2263,6 @@ uint Item_func_case_abbreviation2::decimal_precision2(Item **args) const } -Field *Item_func_ifnull::tmp_table_field(TABLE *table) -{ - return tmp_table_field_from_field_type(table, false, false); -} - double Item_func_ifnull::real_op() { diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 2f66382941d..2e066b895e9 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -951,7 +951,9 @@ public: maybe_null= args[1]->maybe_null; } const char *func_name() const { return "ifnull"; } - Field *tmp_table_field(TABLE *table); + Field *create_field_for_create_select(TABLE *table) + { return tmp_table_field_from_field_type(table, false, false); } + table_map not_null_tables() const { return 0; } uint decimal_precision() const { diff --git a/sql/item_func.cc b/sql/item_func.cc index 6edb276ca20..a1c5835d525 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -509,43 +509,6 @@ bool Item_func::eq(const Item *item, bool binary_cmp) const } -Field *Item_func::tmp_table_field(TABLE *table) -{ - Field *field= NULL; - MEM_ROOT *mem_root= table->in_use->mem_root; - - switch (result_type()) { - case INT_RESULT: - if (max_char_length() > MY_INT32_NUM_DECIMAL_DIGITS) - field= new (mem_root) - Field_longlong(max_char_length(), maybe_null, name, - unsigned_flag); - else - field= new (mem_root) - Field_long(max_char_length(), maybe_null, name, - unsigned_flag); - break; - case REAL_RESULT: - field= new (mem_root) - Field_double(max_char_length(), maybe_null, name, decimals); - break; - case STRING_RESULT: - return make_string_field(table); - case DECIMAL_RESULT: - field= Field_new_decimal::create_from_item(mem_root, this); - break; - case ROW_RESULT: - case TIME_RESULT: - // This case should never be chosen - DBUG_ASSERT(0); - field= 0; - break; - } - if (field) - field->init(table); - return field; -} - /* bool Item_func::is_expensive_processor(uchar *arg) { @@ -2350,15 +2313,6 @@ longlong Item_func_bit_neg::val_int() // Conversion functions -void Item_func_integer::fix_length_and_dec() -{ - max_length=args[0]->max_length - args[0]->decimals+1; - uint tmp=float_length(decimals); - set_if_smaller(max_length,tmp); - decimals=0; -} - - void Item_func_int_val::fix_length_and_dec() { DBUG_ENTER("Item_func_int_val::fix_length_and_dec"); @@ -2910,10 +2864,10 @@ void Item_func_min_max::fix_length_and_dec() collation.set_numeric(); fix_char_length(float_length(decimals)); /* - Set type to DOUBLE, as Item_func::tmp_table_field() does not + Set type to DOUBLE, as Item_func::create_tmp_field() does not distinguish between DOUBLE and FLOAT and always creates Field_double. Perhaps we should eventually change this to use agg_field_type() here, - and fix Item_func::tmp_table_field() to create Field_float when possible. + and fix Item_func::create_tmp_field() to create Field_float when possible. */ set_handler_by_field_type(MYSQL_TYPE_DOUBLE); break; @@ -3962,7 +3916,7 @@ longlong Item_master_pos_wait::val_int() longlong timeout = (arg_count>=3) ? args[2]->val_int() : 0 ; String connection_name_buff; LEX_STRING connection_name; - Master_info *mi; + Master_info *mi= NULL; if (arg_count >= 4) { String *con; @@ -3982,8 +3936,9 @@ longlong Item_master_pos_wait::val_int() connection_name= thd->variables.default_master_connection; mysql_mutex_lock(&LOCK_active_mi); - mi= master_info_index->get_master_info(&connection_name, - Sql_condition::WARN_LEVEL_WARN); + if (master_info_index) // master_info_index is set to NULL on shutdown. + mi= master_info_index->get_master_info(&connection_name, + Sql_condition::WARN_LEVEL_WARN); mysql_mutex_unlock(&LOCK_active_mi); if (!mi) goto err; @@ -6805,16 +6760,6 @@ longlong Item_func_found_rows::val_int() } -Field * -Item_func_sp::tmp_table_field(TABLE *t_arg) -{ - DBUG_ENTER("Item_func_sp::tmp_table_field"); - - DBUG_ASSERT(sp_result_field); - DBUG_RETURN(sp_result_field); -} - - /** @brief Checks if requested access to function can be granted to user. If function isn't found yet, it searches function first. diff --git a/sql/item_func.h b/sql/item_func.h index 6a1494040c9..4a55bd68453 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -173,12 +173,10 @@ public: } void signal_divide_by_null(); friend class udf_handler; - Field *tmp_table_field() { return result_field; } - Field *tmp_table_field(TABLE *t_arg); - Field *create_field_for_create_select(THD *thd, TABLE *table) + Field *create_field_for_create_select(TABLE *table) { return result_type() != STRING_RESULT ? - tmp_table_field(table) : + create_tmp_field(false, table, MY_INT32_NUM_DECIMAL_DIGITS) : tmp_table_field_from_field_type(table, false, false); } Item *get_tmp_table_item(THD *thd); @@ -951,13 +949,6 @@ public: const char *func_name() const { return "cot"; } }; -class Item_func_integer :public Item_int_func -{ -public: - inline Item_func_integer(THD *thd, Item *a): Item_int_func(thd, a) {} - void fix_length_and_dec(); -}; - class Item_func_int_val :public Item_func_num1 { @@ -1762,10 +1753,10 @@ public: bool update(); bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec(); - Field *create_field_for_create_select(THD *thd, TABLE *table) + Field *create_field_for_create_select(TABLE *table) { return result_type() != STRING_RESULT ? - tmp_table_field(table) : + create_tmp_field(false, table, MY_INT32_NUM_DECIMAL_DIGITS) : tmp_table_field_from_field_type(table, false, true); } table_map used_tables() const @@ -2106,8 +2097,12 @@ public: enum enum_field_types field_type() const; - Field *tmp_table_field(TABLE *t_arg); - + Field *create_field_for_create_select(TABLE *table) + { + return result_type() != STRING_RESULT ? + sp_result_field : + tmp_table_field_from_field_type(table, false, false); + } void make_field(Send_field *tmp_field); Item_result result_type() const; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index a515f292975..c856aa985b3 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -1,6 +1,5 @@ -/* - Copyright (c) 2003-2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2003, 2016, Oracle and/or its affiliates. + Copyright (c) 2011, 2016, MariaDB 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 @@ -41,7 +40,7 @@ #include "opt_range.h" -Field *Item_geometry_func::tmp_table_field(TABLE *t_arg) +Field *Item_geometry_func::create_field_for_create_select(TABLE *t_arg) { Field *result; if ((result= new Field_geom(max_length, maybe_null, name, t_arg->s, diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 6b991a1b643..121e122d939 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -40,7 +40,7 @@ public: Item_geometry_func(THD *thd, List &list): Item_str_func(thd, list) {} void fix_length_and_dec(); enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } - Field *tmp_table_field(TABLE *t_arg); + Field *create_field_for_create_select(TABLE *table); }; class Item_func_geometry_from_text: public Item_geometry_func diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 1812110b1e6..42f17065cfe 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -84,7 +84,6 @@ void Item_subselect::init(st_select_lex *select_lex, DBUG_PRINT("enter", ("select_lex: 0x%lx this: 0x%lx", (ulong) select_lex, (ulong) this)); unit= select_lex->master_unit(); - thd= unit->thd; if (unit->item) { @@ -103,7 +102,7 @@ void Item_subselect::init(st_select_lex *select_lex, Item can be changed in JOIN::prepare while engine in JOIN::optimize => we do not copy old_engine here */ - thd->change_item_tree((Item**)&unit->item, this); + unit->thd->change_item_tree((Item**)&unit->item, this); engine->change_result(this, result, TRUE); } } @@ -118,9 +117,9 @@ void Item_subselect::init(st_select_lex *select_lex, NO_MATTER : outer_select->parsing_place); if (unit->is_union()) - engine= new subselect_union_engine(thd, unit, result, this); + engine= new subselect_union_engine(unit, result, this); else - engine= new subselect_single_select_engine(thd, select_lex, result, this); + engine= new subselect_single_select_engine(select_lex, result, this); } { SELECT_LEX *upper= unit->outer_select(); @@ -234,6 +233,10 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) uint8 uncacheable; bool res; + thd= thd_param; + + DBUG_ASSERT(unit->thd == thd); + status_var_increment(thd_param->status_var.feature_subquery); DBUG_ASSERT(fixed == 0); @@ -256,7 +259,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) return TRUE; - if (!(res= engine->prepare())) + if (!(res= engine->prepare(thd))) { // all transformation is done (used by prepared statements) changed= 1; @@ -557,6 +560,21 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent, bool Item_subselect::is_expensive() { double examined_rows= 0; + bool all_are_simple= true; + + /* check extremely simple select */ + if (!unit->first_select()->next_select()) // no union + { + /* + such single selects works even without optimization because + can not makes loops + */ + SELECT_LEX *sl= unit->first_select(); + JOIN *join = sl->join; + if (join && !join->tables_list && !sl->first_inner_unit()) + return false; + } + for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) { @@ -566,23 +584,27 @@ bool Item_subselect::is_expensive() if (!cur_join) return true; - /* very simple subquery */ - if (!cur_join->tables_list && !sl->first_inner_unit()) - return false; - /* If the subquery is not optimised or in the process of optimization it supposed to be expensive */ - if (!cur_join->optimized) + if (cur_join->optimization_state != JOIN::OPTIMIZATION_DONE) return true; + if (!cur_join->tables_list && !sl->first_inner_unit()) + continue; + /* Subqueries whose result is known after optimization are not expensive. Such subqueries have all tables optimized away, thus have no join plan. */ if ((cur_join->zero_result_cause || !cur_join->tables_list)) - return false; + continue; + + /* + This is not simple SELECT in union so we can not go by simple condition + */ + all_are_simple= false; /* If a subquery is not optimized we cannot estimate its cost. A subquery is @@ -603,7 +625,8 @@ bool Item_subselect::is_expensive() examined_rows+= cur_join->get_examined_rows(); } - return (examined_rows > thd->variables.expensive_subquery_limit); + return !all_are_simple && + (examined_rows > thd->variables.expensive_subquery_limit); } @@ -3168,9 +3191,12 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref) { uint outer_cols_num; List *inner_cols; - char const *save_where= thd->where; + char const *save_where= thd_arg->where; DBUG_ENTER("Item_in_subselect::fix_fields"); + thd= thd_arg; + DBUG_ASSERT(unit->thd == thd); + if (test_strategy(SUBS_SEMI_JOIN)) DBUG_RETURN( !( (*ref)= new (thd->mem_root) Item_int(thd, 1)) ); @@ -3287,7 +3313,8 @@ bool Item_in_subselect::setup_mat_engine() if (!(mat_engine= new subselect_hash_sj_engine(thd, this, select_engine))) DBUG_RETURN(TRUE); - if (mat_engine->init(&select_engine->join->fields_list, + if (mat_engine->prepare(thd) || + mat_engine->init(&select_engine->join->fields_list, engine->get_identifier())) DBUG_RETURN(TRUE); @@ -3404,10 +3431,10 @@ void subselect_engine::set_thd(THD *thd_arg) subselect_single_select_engine:: -subselect_single_select_engine(THD *thd_arg, st_select_lex *select, +subselect_single_select_engine(st_select_lex *select, select_result_interceptor *result_arg, Item_subselect *item_arg) - :subselect_engine(thd_arg, item_arg, result_arg), + :subselect_engine(item_arg, result_arg), prepared(0), executed(0), select_lex(select), join(0) { @@ -3488,10 +3515,10 @@ void subselect_uniquesubquery_engine::cleanup() } -subselect_union_engine::subselect_union_engine(THD *thd_arg, st_select_lex_unit *u, +subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, select_result_interceptor *result_arg, Item_subselect *item_arg) - :subselect_engine(thd_arg, item_arg, result_arg) + :subselect_engine(item_arg, result_arg) { unit= u; unit->item= item_arg; @@ -3524,10 +3551,11 @@ subselect_union_engine::subselect_union_engine(THD *thd_arg, st_select_lex_unit @retval 1 if error */ -int subselect_single_select_engine::prepare() +int subselect_single_select_engine::prepare(THD *thd) { if (prepared) return 0; + set_thd(thd); if (select_lex->join) { select_lex->cleanup(); @@ -3556,12 +3584,13 @@ int subselect_single_select_engine::prepare() return 0; } -int subselect_union_engine::prepare() +int subselect_union_engine::prepare(THD *thd_arg) { + set_thd(thd_arg); return unit->prepare(thd, result, SELECT_NO_UNLOCK); } -int subselect_uniquesubquery_engine::prepare() +int subselect_uniquesubquery_engine::prepare(THD *) { /* Should never be called. */ DBUG_ASSERT(FALSE); @@ -3663,7 +3692,7 @@ int subselect_single_select_engine::exec() SELECT_LEX *save_select= thd->lex->current_select; thd->lex->current_select= select_lex; - if (!join->optimized) + if (join->optimization_state == JOIN::NOT_OPTIMIZED) { SELECT_LEX_UNIT *unit= select_lex->master_unit(); @@ -3821,7 +3850,7 @@ int subselect_uniquesubquery_engine::scan_table() } table->file->extra_opt(HA_EXTRA_CACHE, - current_thd->variables.read_buff_size); + get_thd()->variables.read_buff_size); table->null_row= 0; for (;;) { @@ -4259,7 +4288,7 @@ table_map subselect_union_engine::upper_select_const_tables() void subselect_single_select_engine::print(String *str, enum_query_type query_type) { - select_lex->print(thd, str, query_type); + select_lex->print(get_thd(), str, query_type); } @@ -4790,6 +4819,7 @@ my_bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root) bool subselect_hash_sj_engine::init(List *tmp_columns, uint subquery_id) { + THD *thd= get_thd(); select_union *result_sink; /* Options to create_tmp_table. */ ulonglong tmp_create_options= thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS; @@ -5026,13 +5056,14 @@ subselect_hash_sj_engine::~subselect_hash_sj_engine() } -int subselect_hash_sj_engine::prepare() +int subselect_hash_sj_engine::prepare(THD *thd_arg) { /* Create and optimize the JOIN that will be used to materialize the subquery if not yet created. */ - return materialize_engine->prepare(); + set_thd(thd_arg); + return materialize_engine->prepare(thd); } @@ -5311,7 +5342,8 @@ int subselect_hash_sj_engine::exec() */ thd->lex->current_select= materialize_engine->select_lex; /* The subquery should be optimized, and materialized only once. */ - DBUG_ASSERT(materialize_join->optimized && !is_materialized); + DBUG_ASSERT(materialize_join->optimization_state == JOIN::OPTIMIZATION_DONE && + !is_materialized); materialize_join->exec(); if ((res= MY_TEST(materialize_join->error || thd->is_fatal_error || thd->is_error()))) @@ -5407,7 +5439,7 @@ int subselect_hash_sj_engine::exec() if (strategy == PARTIAL_MATCH_MERGE) { pm_engine= - new subselect_rowid_merge_engine(thd, (subselect_uniquesubquery_engine*) + new subselect_rowid_merge_engine((subselect_uniquesubquery_engine*) lookup_engine, tmp_table, count_pm_keys, has_covering_null_row, @@ -5416,6 +5448,7 @@ int subselect_hash_sj_engine::exec() item, result, semi_join_conds->argument_list()); if (!pm_engine || + pm_engine->prepare(thd) || ((subselect_rowid_merge_engine*) pm_engine)-> init(nn_key_parts, &partial_match_key_parts)) { @@ -5433,13 +5466,14 @@ int subselect_hash_sj_engine::exec() if (strategy == PARTIAL_MATCH_SCAN) { if (!(pm_engine= - new subselect_table_scan_engine(thd, (subselect_uniquesubquery_engine*) + new subselect_table_scan_engine((subselect_uniquesubquery_engine*) lookup_engine, tmp_table, item, result, semi_join_conds->argument_list(), has_covering_null_row, has_covering_null_columns, - count_columns_with_nulls))) + count_columns_with_nulls)) || + pm_engine->prepare(thd)) { /* This is an irrecoverable error. */ res= 1; @@ -5888,14 +5922,14 @@ void Ordered_key::print(String *str) subselect_partial_match_engine::subselect_partial_match_engine( - THD *thd_arg, subselect_uniquesubquery_engine *engine_arg, + subselect_uniquesubquery_engine *engine_arg, TABLE *tmp_table_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List *equi_join_conds_arg, bool has_covering_null_row_arg, bool has_covering_null_columns_arg, uint count_columns_with_nulls_arg) - :subselect_engine(thd_arg, item_arg, result_arg), + :subselect_engine(item_arg, result_arg), tmp_table(tmp_table_arg), lookup_engine(engine_arg), equi_join_conds(equi_join_conds_arg), has_covering_null_row(has_covering_null_row_arg), @@ -6020,6 +6054,7 @@ bool subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts, MY_BITMAP *partial_match_key_parts) { + THD *thd= get_thd(); /* The length in bytes of the rowids (positions) of tmp_table. */ uint rowid_length= tmp_table->file->ref_length; ha_rows row_count= tmp_table->file->stats.records; @@ -6508,7 +6543,7 @@ end: subselect_table_scan_engine::subselect_table_scan_engine( - THD *thd_arg, subselect_uniquesubquery_engine *engine_arg, + subselect_uniquesubquery_engine *engine_arg, TABLE *tmp_table_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, @@ -6516,7 +6551,7 @@ subselect_table_scan_engine::subselect_table_scan_engine( bool has_covering_null_row_arg, bool has_covering_null_columns_arg, uint count_columns_with_nulls_arg) - :subselect_partial_match_engine(thd_arg, engine_arg, tmp_table_arg, item_arg, + :subselect_partial_match_engine(engine_arg, tmp_table_arg, item_arg, result_arg, equi_join_conds_arg, has_covering_null_row_arg, has_covering_null_columns_arg, @@ -6558,7 +6593,7 @@ bool subselect_table_scan_engine::partial_match() } tmp_table->file->extra_opt(HA_EXTRA_CACHE, - current_thd->variables.read_buff_size); + get_thd()->variables.read_buff_size); for (;;) { error= tmp_table->file->ha_rnd_next(tmp_table->record[0]); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 670d0a66639..d18db4aab86 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -750,15 +750,15 @@ public: INDEXSUBQUERY_ENGINE, HASH_SJ_ENGINE, ROWID_MERGE_ENGINE, TABLE_SCAN_ENGINE}; - subselect_engine(THD *thd_arg, Item_subselect *si, - select_result_interceptor *res) + subselect_engine(Item_subselect *si, + select_result_interceptor *res): + thd(NULL) { result= res; item= si; cmp_type= res_type= STRING_RESULT; res_field_type= MYSQL_TYPE_VAR_STRING; maybe_null= 0; - set_thd(thd_arg); } virtual ~subselect_engine() {}; // to satisfy compiler virtual void cleanup()= 0; @@ -768,8 +768,8 @@ public: Should be called before prepare(). */ void set_thd(THD *thd_arg); - THD * get_thd() { return thd; } - virtual int prepare()= 0; + THD * get_thd() { return thd ? thd : current_thd; } + virtual int prepare(THD *)= 0; virtual void fix_length_and_dec(Item_cache** row)= 0; /* Execute the engine @@ -824,11 +824,11 @@ class subselect_single_select_engine: public subselect_engine st_select_lex *select_lex; /* corresponding select_lex */ JOIN * join; /* corresponding JOIN structure */ public: - subselect_single_select_engine(THD *thd_arg, st_select_lex *select, + subselect_single_select_engine(st_select_lex *select, select_result_interceptor *result, Item_subselect *item); void cleanup(); - int prepare(); + int prepare(THD *thd); void fix_length_and_dec(Item_cache** row); int exec(); uint cols(); @@ -858,11 +858,11 @@ class subselect_union_engine: public subselect_engine { st_select_lex_unit *unit; /* corresponding unit structure */ public: - subselect_union_engine(THD *thd_arg, st_select_lex_unit *u, + subselect_union_engine(st_select_lex_unit *u, select_result_interceptor *result, Item_subselect *item); void cleanup(); - int prepare(); + int prepare(THD *); void fix_length_and_dec(Item_cache** row); int exec(); uint cols(); @@ -915,11 +915,11 @@ public: // constructor can assign THD because it will be called after JOIN::prepare subselect_uniquesubquery_engine(THD *thd_arg, st_join_table *tab_arg, Item_subselect *subs, Item *where) - :subselect_engine(thd_arg, subs, 0), tab(tab_arg), cond(where) + :subselect_engine(subs, 0), tab(tab_arg), cond(where) {} ~subselect_uniquesubquery_engine(); void cleanup(); - int prepare(); + int prepare(THD *); void fix_length_and_dec(Item_cache** row); int exec(); uint cols() { return 1; } @@ -1047,7 +1047,7 @@ public: subselect_hash_sj_engine(THD *thd_arg, Item_subselect *in_predicate, subselect_single_select_engine *old_engine) - : subselect_engine(thd_arg, in_predicate, NULL), + : subselect_engine(in_predicate, NULL), tmp_table(NULL), is_materialized(FALSE), materialize_engine(old_engine), materialize_join(NULL), semi_join_conds(NULL), lookup_engine(NULL), count_partial_match_columns(0), count_null_only_columns(0), @@ -1057,7 +1057,7 @@ public: bool init(List *tmp_columns, uint subquery_id); void cleanup(); - int prepare(); + int prepare(THD *); int exec(); virtual void print(String *str, enum_query_type query_type); uint cols() @@ -1336,15 +1336,14 @@ protected: protected: virtual bool partial_match()= 0; public: - subselect_partial_match_engine(THD *thd_arg, - subselect_uniquesubquery_engine *engine_arg, + subselect_partial_match_engine(subselect_uniquesubquery_engine *engine_arg, TABLE *tmp_table_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List *equi_join_conds_arg, bool has_covering_null_row_arg, bool has_covering_null_columns_arg, uint count_columns_with_nulls_arg); - int prepare() { return 0; } + int prepare(THD *thd_arg) { set_thd(thd_arg); return 0; } int exec(); void fix_length_and_dec(Item_cache**) {} uint cols() { /* TODO: what is the correct value? */ return 1; } @@ -1431,8 +1430,7 @@ protected: bool exists_complementing_null_row(MY_BITMAP *keys_to_complement); bool partial_match(); public: - subselect_rowid_merge_engine(THD *thd_arg, - subselect_uniquesubquery_engine *engine_arg, + subselect_rowid_merge_engine(subselect_uniquesubquery_engine *engine_arg, TABLE *tmp_table_arg, uint merge_keys_count_arg, bool has_covering_null_row_arg, bool has_covering_null_columns_arg, @@ -1440,7 +1438,7 @@ public: Item_subselect *item_arg, select_result_interceptor *result_arg, List *equi_join_conds_arg) - :subselect_partial_match_engine(thd_arg, engine_arg, tmp_table_arg, + :subselect_partial_match_engine(engine_arg, tmp_table_arg, item_arg, result_arg, equi_join_conds_arg, has_covering_null_row_arg, has_covering_null_columns_arg, @@ -1459,8 +1457,7 @@ class subselect_table_scan_engine: public subselect_partial_match_engine protected: bool partial_match(); public: - subselect_table_scan_engine(THD *thd_arg, - subselect_uniquesubquery_engine *engine_arg, + subselect_table_scan_engine(subselect_uniquesubquery_engine *engine_arg, TABLE *tmp_table_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List *equi_join_conds_arg, diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 1cfee1a9241..540eefcc79a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -380,6 +380,16 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref) sl->master_unit()->item->with_sum_func= 1; } thd->lex->current_select->mark_as_dependent(thd, aggr_sel, NULL); + + if ((thd->lex->describe & DESCRIBE_EXTENDED) && aggr_sel) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_WARN_AGGFUNC_DEPENDENCE, + ER_THD(thd, ER_WARN_AGGFUNC_DEPENDENCE), + func_name(), + thd->lex->current_select->select_number, + aggr_sel->select_number); + } return FALSE; } @@ -1450,7 +1460,7 @@ my_decimal *Item_sum_sum::val_decimal(my_decimal *val) if (aggr) aggr->endup(); if (hybrid_type == DECIMAL_RESULT) - return (dec_buffs + curr_dec_buff); + return null_value ? NULL : (dec_buffs + curr_dec_buff); return val_decimal_from_real(val); } @@ -1753,6 +1763,8 @@ double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); double nr= Item_sum_variance::val_real(); + if (my_isinf(nr)) + return DBL_MAX; DBUG_ASSERT(nr >= 0.0); return sqrt(nr); } diff --git a/sql/item_sum.h b/sql/item_sum.h index 11d2f802af7..8568eaae907 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -481,7 +481,7 @@ public: } virtual void make_unique() { force_copy_fields= TRUE; } Item *get_tmp_table_item(THD *thd); - virtual Field *create_tmp_field(bool group, TABLE *table); + Field *create_tmp_field(bool group, TABLE *table); virtual bool collect_outer_ref_processor(uchar *param); bool init_sum_func_check(THD *thd); bool check_sum_func(THD *thd, Item **ref); @@ -1084,7 +1084,6 @@ public: fixed= true; } table_map used_tables() const { return (table_map) 1L; } - Field *tmp_table_field(TABLE *) { DBUG_ASSERT(0); return NULL; } void set_result_field(Field *) { DBUG_ASSERT(0); } void save_in_result_field(bool no_conversions) { DBUG_ASSERT(0); } }; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 991dde632e2..ff13e707ac4 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -939,9 +939,8 @@ void Item_func_monthname::fix_length_and_dec() { THD* thd= current_thd; CHARSET_INFO *cs= thd->variables.collation_connection; - uint32 repertoire= my_charset_repertoire(cs); locale= thd->variables.lc_time_names; - collation.set(cs, DERIVATION_COERCIBLE, repertoire); + collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire()); decimals=0; max_length= locale->max_month_name_length * collation.collation->mbmaxlen; maybe_null=1; @@ -1086,9 +1085,8 @@ void Item_func_dayname::fix_length_and_dec() { THD* thd= current_thd; CHARSET_INFO *cs= thd->variables.collation_connection; - uint32 repertoire= my_charset_repertoire(cs); locale= thd->variables.lc_time_names; - collation.set(cs, DERIVATION_COERCIBLE, repertoire); + collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire()); decimals=0; max_length= locale->max_day_name_length * collation.collation->mbmaxlen; maybe_null=1; @@ -2194,26 +2192,26 @@ void Item_extract::fix_length_and_dec() { maybe_null=1; // If wrong date switch (int_type) { - case INTERVAL_YEAR: max_length=4; date_value=1; break; - case INTERVAL_YEAR_MONTH: max_length=6; date_value=1; break; - case INTERVAL_QUARTER: max_length=2; date_value=1; break; - case INTERVAL_MONTH: max_length=2; date_value=1; break; - case INTERVAL_WEEK: max_length=2; date_value=1; break; - case INTERVAL_DAY: max_length=2; date_value=1; break; - case INTERVAL_DAY_HOUR: max_length=9; date_value=0; break; - case INTERVAL_DAY_MINUTE: max_length=11; date_value=0; break; - case INTERVAL_DAY_SECOND: max_length=13; date_value=0; break; - case INTERVAL_HOUR: max_length=2; date_value=0; break; - case INTERVAL_HOUR_MINUTE: max_length=4; date_value=0; break; - case INTERVAL_HOUR_SECOND: max_length=6; date_value=0; break; - case INTERVAL_MINUTE: max_length=2; date_value=0; break; - case INTERVAL_MINUTE_SECOND: max_length=4; date_value=0; break; - case INTERVAL_SECOND: max_length=2; date_value=0; break; - case INTERVAL_MICROSECOND: max_length=2; date_value=0; break; - case INTERVAL_DAY_MICROSECOND: max_length=20; date_value=0; break; - case INTERVAL_HOUR_MICROSECOND: max_length=13; date_value=0; break; - case INTERVAL_MINUTE_MICROSECOND: max_length=11; date_value=0; break; - case INTERVAL_SECOND_MICROSECOND: max_length=9; date_value=0; break; + case INTERVAL_YEAR: set_date_length(4); break; // YYYY + case INTERVAL_YEAR_MONTH: set_date_length(6); break; // YYYYMM + case INTERVAL_QUARTER: set_date_length(2); break; // 1..4 + case INTERVAL_MONTH: set_date_length(2); break; // MM + case INTERVAL_WEEK: set_date_length(2); break; // 0..52 + case INTERVAL_DAY: set_date_length(2); break; // DD + case INTERVAL_DAY_HOUR: set_time_length(4); break; // DDhh + case INTERVAL_DAY_MINUTE: set_time_length(6); break; // DDhhmm + case INTERVAL_DAY_SECOND: set_time_length(8); break; // DDhhmmss + case INTERVAL_HOUR: set_time_length(2); break; // hh + case INTERVAL_HOUR_MINUTE: set_time_length(4); break; // hhmm + case INTERVAL_HOUR_SECOND: set_time_length(6); break; // hhmmss + case INTERVAL_MINUTE: set_time_length(2); break; // mm + case INTERVAL_MINUTE_SECOND: set_time_length(4); break; // mmss + case INTERVAL_SECOND: set_time_length(2); break; // ss + case INTERVAL_MICROSECOND: set_time_length(6); break; // ffffff + case INTERVAL_DAY_MICROSECOND: set_time_length(14); break; // DDhhmmssffffff + case INTERVAL_HOUR_MICROSECOND: set_time_length(12); break; // hhmmssffffff + case INTERVAL_MINUTE_MICROSECOND: set_time_length(10); break; // mmssffffff + case INTERVAL_SECOND_MICROSECOND: set_time_length(8); break; // ssffffff case INTERVAL_LAST: DBUG_ASSERT(0); break; /* purecov: deadcode */ } } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index bb840987089..0e9329d501c 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -500,7 +500,7 @@ public: bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date) { DBUG_ASSERT(0); return 1; } my_decimal *val_decimal(my_decimal *decimal_value) { return val_decimal_from_date(decimal_value); } - Field *tmp_table_field(TABLE *table) + Field *create_field_for_create_select(TABLE *table) { return tmp_table_field_from_field_type(table, false, false); } int save_in_field(Field *field, bool no_conversions) { return save_date_in_field(field); } @@ -835,10 +835,57 @@ public: class Item_extract :public Item_int_func { bool date_value; + void set_date_length(uint32 length) + { + /* + Although DATE components (e.g. YEAR, YEAR_MONTH, QUARTER, MONTH, WEEK) + cannot have a sign, we should probably still add +1, + because all around the code we assume that max_length is sign inclusive. + Another options is to set unsigned_flag to "true". + */ + max_length= length; //QQ: see above + date_value= true; + } + void set_time_length(uint32 length) + { + max_length= length + 1/*sign*/; + date_value= false; + } public: const interval_type int_type; // keep it public Item_extract(THD *thd, interval_type type_arg, Item *a): Item_int_func(thd, a), int_type(type_arg) {} + enum_field_types field_type() const + { + switch (int_type) { + case INTERVAL_YEAR: + case INTERVAL_YEAR_MONTH: + case INTERVAL_QUARTER: + case INTERVAL_MONTH: + case INTERVAL_WEEK: + case INTERVAL_DAY: + case INTERVAL_DAY_HOUR: + case INTERVAL_DAY_MINUTE: + case INTERVAL_DAY_SECOND: + case INTERVAL_HOUR: + case INTERVAL_HOUR_MINUTE: + case INTERVAL_HOUR_SECOND: + case INTERVAL_MINUTE: + case INTERVAL_MINUTE_SECOND: + case INTERVAL_SECOND: + case INTERVAL_MICROSECOND: + case INTERVAL_SECOND_MICROSECOND: + return MYSQL_TYPE_LONG; + case INTERVAL_DAY_MICROSECOND: + case INTERVAL_HOUR_MICROSECOND: + case INTERVAL_MINUTE_MICROSECOND: + return MYSQL_TYPE_LONGLONG; + case INTERVAL_LAST: + break; + } + DBUG_ASSERT(0); + return MYSQL_TYPE_LONGLONG; + } longlong val_int(); enum Functype functype() const { return EXTRACT_FUNC; } const char *func_name() const { return "extract"; } @@ -883,6 +930,8 @@ class Item_extract :public Item_int_func } return true; } + Field *create_field_for_create_select(TABLE *table) + { return tmp_table_field_from_field_type(table, false, false); } }; diff --git a/sql/lex.h b/sql/lex.h index 22ff4e6d360..85bd20a5f37 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -47,12 +47,9 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"}; static SYMBOL symbols[] = { { "&&", SYM(AND_AND_SYM)}, - { "<", SYM(LT)}, { "<=", SYM(LE)}, { "<>", SYM(NE)}, { "!=", SYM(NE)}, - { "=", SYM(EQ)}, - { ">", SYM(GT_SYM)}, { ">=", SYM(GE)}, { "<<", SYM(SHIFT_LEFT)}, { ">>", SYM(SHIFT_RIGHT)}, diff --git a/sql/lock.cc b/sql/lock.cc index 2e44786d6fe..47db9ec6bfa 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1036,10 +1036,21 @@ void Global_read_lock::unlock_global_read_lock(THD *thd) thd->mdl_context.release_lock(m_mdl_blocks_commits_lock); m_mdl_blocks_commits_lock= NULL; #ifdef WITH_WSREP - if (WSREP_ON) + if (WSREP(thd) || wsrep_node_is_donor()) { wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; wsrep->resume(wsrep); + /* resync here only if we did implicit desync earlier */ + if (!wsrep_desync && wsrep_node_is_synced()) + { + int ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) + { + WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), thd->query()); + DBUG_VOID_RETURN; + } + } } #endif /* WITH_WSREP */ } @@ -1079,14 +1090,11 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) DBUG_RETURN(0); #ifdef WITH_WSREP - if (WSREP_ON && m_mdl_blocks_commits_lock) + if (WSREP(thd) && m_mdl_blocks_commits_lock) { WSREP_DEBUG("GRL was in block commit mode when entering " "make_global_read_lock_block_commit"); - thd->mdl_context.release_lock(m_mdl_blocks_commits_lock); - m_mdl_blocks_commits_lock= NULL; - wsrep_locked_seqno= WSREP_SEQNO_UNDEFINED; - wsrep->resume(wsrep); + DBUG_RETURN(FALSE); } #endif /* WITH_WSREP */ @@ -1100,7 +1108,43 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd) m_state= GRL_ACQUIRED_AND_BLOCKS_COMMIT; #ifdef WITH_WSREP - if (WSREP_ON) + /* Native threads should bail out before wsrep oprations to follow. + Donor servicing thread is an exception, it should pause provider but not desync, + as it is already desynced in donor state + */ + if (!WSREP(thd) && !wsrep_node_is_donor()) + { + DBUG_RETURN(FALSE); + } + + /* if already desynced or donor, avoid double desyncing + if not in PC and synced, desyncing is not possible either + */ + if (wsrep_desync || !wsrep_node_is_synced()) + { + WSREP_DEBUG("desync set upfont, skipping implicit desync for FTWRL: %d", + wsrep_desync); + } + else + { + int rcode; + WSREP_DEBUG("running implicit desync for node"); + rcode = wsrep->desync(wsrep); + if (rcode != WSREP_OK) + { + WSREP_WARN("FTWRL desync failed %d for schema: %s, query: %s", + rcode, (thd->db ? thd->db : "(null)"), thd->query()); + my_message(ER_LOCK_DEADLOCK, "wsrep desync failed for FTWRL", MYF(0)); + DBUG_RETURN(TRUE); + } + } + + long long ret = wsrep->pause(wsrep); + if (ret >= 0) + { + wsrep_locked_seqno= ret; + } + else if (ret != -ENOSYS) /* -ENOSYS - no provider */ { long long ret = wsrep->pause(wsrep); if (ret >= 0) diff --git a/sql/log.cc b/sql/log.cc index a938dcbc9f8..be24bcd718a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2009, 2016, MariaDB This program is free software; you can redistribute it and/or modify @@ -3138,6 +3138,22 @@ const char *MYSQL_LOG::generate_name(const char *log_name, } +/* + Print some additional information about addition/removal of + XID list entries. + TODO: Remove once MDEV-9510 is fixed. +*/ +#ifdef WITH_WSREP +#define WSREP_XID_LIST_ENTRY(X, Y) \ + if (wsrep_debug) \ + { \ + char buf[FN_REFLEN]; \ + strmake(buf, Y->binlog_name, Y->binlog_name_len); \ + WSREP_DEBUG(X, buf, Y->binlog_id); \ + } +#else +#define WSREP_XID_LIST_ENTRY(X, Y) do { } while(0) +#endif MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_period) :reset_master_pending(0), mark_xid_done_waiting(0), @@ -3200,6 +3216,8 @@ void MYSQL_BIN_LOG::cleanup() */ DBUG_ASSERT(b->xid_count == 0); DBUG_ASSERT(!binlog_xid_count_list.head()); + WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::cleanup(): Removing xid_list_entry " + "for %s (%lu)", b); my_free(b); } @@ -3690,7 +3708,14 @@ bool MYSQL_BIN_LOG::open(const char *log_name, new_xid_list_entry->binlog_id= current_binlog_id; /* Remove any initial entries with no pending XIDs. */ while ((b= binlog_xid_count_list.head()) && b->xid_count == 0) + { + WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::open(): Removing xid_list_entry for " + "%s (%lu)", b); my_free(binlog_xid_count_list.get()); + } + mysql_cond_broadcast(&COND_xid_list); + WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::open(): Adding new xid_list_entry for " + "%s (%lu)", new_xid_list_entry); binlog_xid_count_list.push_back(new_xid_list_entry); mysql_mutex_unlock(&LOCK_xid_list); @@ -4225,8 +4250,11 @@ err: if (b->binlog_id == current_binlog_id) break; DBUG_ASSERT(b->xid_count == 0); + WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::reset_logs(): Removing " + "xid_list_entry for %s (%lu)", b); my_free(binlog_xid_count_list.get()); } + mysql_cond_broadcast(&COND_xid_list); reset_master_pending--; mysql_mutex_unlock(&LOCK_xid_list); } @@ -4237,6 +4265,26 @@ err: } +void MYSQL_BIN_LOG::wait_for_last_checkpoint_event() +{ + mysql_mutex_lock(&LOCK_xid_list); + for (;;) + { + if (binlog_xid_count_list.is_last(binlog_xid_count_list.head())) + break; + mysql_cond_wait(&COND_xid_list, &LOCK_xid_list); + } + mysql_mutex_unlock(&LOCK_xid_list); + + /* + LOCK_xid_list and LOCK_log are chained, so the LOCK_log will only be + obtained after mark_xid_done() has written the last checkpoint event. + */ + mysql_mutex_lock(&LOCK_log); + mysql_mutex_unlock(&LOCK_log); +} + + /** Delete relay log files prior to rli->group_relay_log_name (i.e. all logs which are not involved in a non-finished group @@ -7688,7 +7736,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader) last= current->next == NULL; if (!current->error && RUN_HOOK(binlog_storage, after_sync, - (current->thd, log_file_name, + (current->thd, current->cache_mngr->last_commit_pos_file, current->cache_mngr->last_commit_pos_offset, first, last))) { @@ -9394,7 +9442,7 @@ TC_LOG_BINLOG::mark_xid_done(ulong binlog_id, bool write_checkpoint) */ if (unlikely(reset_master_pending)) { - mysql_cond_signal(&COND_xid_list); + mysql_cond_broadcast(&COND_xid_list); mysql_mutex_unlock(&LOCK_xid_list); DBUG_VOID_RETURN; } @@ -9432,8 +9480,7 @@ TC_LOG_BINLOG::mark_xid_done(ulong binlog_id, bool write_checkpoint) mysql_mutex_lock(&LOCK_log); mysql_mutex_lock(&LOCK_xid_list); --mark_xid_done_waiting; - if (unlikely(reset_master_pending)) - mysql_cond_signal(&COND_xid_list); + mysql_cond_broadcast(&COND_xid_list); /* We need to reload current_binlog_id due to release/re-take of lock. */ current= current_binlog_id; @@ -9448,6 +9495,8 @@ TC_LOG_BINLOG::mark_xid_done(ulong binlog_id, bool write_checkpoint) DBUG_ASSERT(b); if (b->binlog_id == current || b->xid_count > 0) break; + WSREP_XID_LIST_ENTRY("TC_LOG_BINLOG::mark_xid_done(): Removing " + "xid_list_entry for %s (%lu)", b); my_free(binlog_xid_count_list.get()); } diff --git a/sql/log.h b/sql/log.h index 9bf80d6e603..bf076fae31d 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2005, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2012, Monty Program Ab +/* Copyright (c) 2005, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -788,6 +788,7 @@ public: bool reset_logs(THD* thd, bool create_new_log, rpl_gtid *init_state, uint32 init_state_len, ulong next_log_number); + void wait_for_last_checkpoint_event(); void close(uint exiting); void clear_inuse_flag_when_closing(File file); diff --git a/sql/log_event.cc b/sql/log_event.cc index ea0afddafbe..de6528638f0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2009, 2016, MariaDB This program is free software; you can redistribute it and/or modify @@ -3743,10 +3743,25 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, if (time_zone_len) copy_str_and_move(&time_zone_str, &start, time_zone_len); - if (user.length > 0) + if (user.length) + { copy_str_and_move((const char **)&(user.str), &start, user.length); - if (host.length > 0) + } + else + { + user.str= (char *) start++; + user.str[0]= '\0'; + } + + if (host.length) + { copy_str_and_move((const char **)&(host.str), &start, host.length); + } + else + { + host.str= (char *) start++; + host.str[0]= '\0'; + } /** if time_zone_len or catalog_len are 0, then time_zone and catalog @@ -6007,7 +6022,6 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi, new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length); thd->set_db(new_db.str, new_db.length); DBUG_ASSERT(thd->query() == 0); - thd->reset_query_inner(); // Should not be needed thd->is_slave_error= 0; clear_all_errors(thd, const_cast(rli)); @@ -9824,9 +9838,6 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) /* When the open and locking succeeded, we check all tables to ensure that they still have the correct type. - - We can use a down cast here since we know that every table added - to the tables_to_lock is a RPL_TABLE_LIST. */ { @@ -9845,10 +9856,37 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) NOTE: The base tables are added here are removed when close_thread_tables is called. */ - RPL_TABLE_LIST *ptr= rgi->tables_to_lock; - for (uint i= 0 ; ptr && (i < rgi->tables_to_lock_count); - ptr= static_cast(ptr->next_global), i++) + TABLE_LIST *table_list_ptr= rgi->tables_to_lock; + for (uint i=0 ; table_list_ptr && (i < rgi->tables_to_lock_count); + table_list_ptr= table_list_ptr->next_global, i++) { + /* + Below if condition takes care of skipping base tables that + make up the MERGE table (which are added by open_tables() + call). They are added next to the merge table in the list. + For eg: If RPL_TABLE_LIST is t3->t1->t2 (where t1 and t2 + are base tables for merge table 't3'), open_tables will modify + the list by adding t1 and t2 again immediately after t3 in the + list (*not at the end of the list*). New table_to_lock list will + look like t3->t1'->t2'->t1->t2 (where t1' and t2' are TABLE_LIST + objects added by open_tables() call). There is no flag(or logic) in + open_tables() that can skip adding these base tables to the list. + So the logic here should take care of skipping them. + + tables_to_lock_count logic will take care of skipping base tables + that are added at the end of the list. + For eg: If RPL_TABLE_LIST is t1->t2->t3, open_tables will modify + the list into t1->t2->t3->t1'->t2'. t1' and t2' will be skipped + because tables_to_lock_count logic in this for loop. + */ + if (table_list_ptr->parent_l) + continue; + /* + We can use a down cast here since we know that every table added + to the tables_to_lock is a RPL_TABLE_LIST (or child table which is + skipped above). + */ + RPL_TABLE_LIST *ptr= static_cast(table_list_ptr); DBUG_ASSERT(ptr->m_tabledef_valid); TABLE *conv_table; if (!ptr->m_tabledef.compatible_with(thd, rgi, ptr->table, &conv_table)) @@ -9890,6 +9928,12 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) TABLE_LIST *ptr= rgi->tables_to_lock; for (uint i=0 ; ptr && (i < rgi->tables_to_lock_count); ptr= ptr->next_global, i++) { + /* + Please see comment in above 'for' loop to know the reason + for this if condition + */ + if (ptr->parent_l) + continue; rgi->m_table_map.set_table(ptr->table_id, ptr->table); /* Following is passing flag about triggers on the server. The problem was diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index ff2f7b156d5..0502f20d2b1 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. +/* Copyright (c) 2007, 2016, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -120,16 +120,25 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi) /* When the open and locking succeeded, we check all tables to ensure that they still have the correct type. - - We can use a down cast here since we know that every table added - to the tables_to_lock is a RPL_TABLE_LIST. */ { - RPL_TABLE_LIST *ptr= rgi->tables_to_lock; - for (uint i= 0 ; ptr&& (i< rgi->tables_to_lock_count); - ptr= static_cast(ptr->next_global), i++) + TABLE_LIST *table_list_ptr= rgi->tables_to_lock; + for (uint i=0 ; table_list_ptr&& (i< rgi->tables_to_lock_count); + table_list_ptr= table_list_ptr->next_global, i++) { + /* + Please see comment in log_event.cc-Rows_log_event::do_apply_event() + function for the explanation of the below if condition + */ + if (table_list_ptr->parent_l) + continue; + /* + We can use a down cast here since we know that every table added + to the tables_to_lock is a RPL_TABLE_LIST(or child table which is + skipped above). + */ + RPL_TABLE_LIST *ptr=static_cast(table_list_ptr); DBUG_ASSERT(ptr->m_tabledef_valid); TABLE *conv_table; if (!ptr->m_tabledef.compatible_with(thd, rgi, ptr->table, &conv_table)) @@ -162,7 +171,15 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi) */ TABLE_LIST *ptr= rgi->tables_to_lock; for (uint i=0; ptr && (i < rgi->tables_to_lock_count); ptr= ptr->next_global, i++) + { + /* + Please see comment in log_event.cc-Rows_log_event::do_apply_event() + function for the explanation of the below if condition + */ + if (ptr->parent_l) + continue; rgi->m_table_map.set_table(ptr->table_id, ptr->table); + } #ifdef HAVE_QUERY_CACHE query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock); #endif @@ -1420,16 +1437,25 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi) /* When the open and locking succeeded, we check all tables to ensure that they still have the correct type. - - We can use a down cast here since we know that every table added - to the tables_to_lock is a RPL_TABLE_LIST. */ { - RPL_TABLE_LIST *ptr= rgi->tables_to_lock; - for (uint i= 0 ; ptr&& (i< rgi->tables_to_lock_count); - ptr= static_cast(ptr->next_global), i++) + TABLE_LIST *table_list_ptr= rgi->tables_to_lock; + for (uint i=0; table_list_ptr&& (i< rgi->tables_to_lock_count); + table_list_ptr= static_cast(table_list_ptr->next_global), i++) { + /* + Please see comment in log_event.cc-Rows_log_event::do_apply_event() + function for the explanation of the below if condition + */ + if (table_list_ptr->parent_l) + continue; + /* + We can use a down cast here since we know that every table added + to the tables_to_lock is a RPL_TABLE_LIST (or child table which is + skipped above). + */ + RPL_TABLE_LIST *ptr=static_cast(table_list_ptr); TABLE *conv_table; if (ptr->m_tabledef.compatible_with(thd, rgi, ptr->table, &conv_table)) { diff --git a/sql/mdl.cc b/sql/mdl.cc index 61591ec9f57..d1f4cb7e5c7 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -17,6 +17,7 @@ #include "sql_class.h" #include "debug_sync.h" #include "sql_array.h" +#include "rpl_rli.h" #include #include #include @@ -506,6 +507,10 @@ public: bitmap_t hog_lock_types_bitmap() const { return m_strategy->hog_lock_types_bitmap(); } +#ifndef DBUG_OFF + bool check_if_conflicting_replication_locks(MDL_context *ctx); +#endif + /** List of granted tickets for this lock. */ Ticket_list m_granted; /** Tickets for contexts waiting to acquire a lock. */ @@ -1976,6 +1981,55 @@ MDL_context::clone_ticket(MDL_request *mdl_request) } +/** + Check if there is any conflicting lock that could cause this thread + to wait for another thread which is not ready to commit. + This is always an error, as the upper level of parallel replication + should not allow a scheduling of a conflicting DDL until all earlier + transactions has commited. + + This function is only called for a slave using parallel replication + and trying to get an exclusive lock for the table. +*/ + +#ifndef DBUG_OFF +bool MDL_lock::check_if_conflicting_replication_locks(MDL_context *ctx) +{ + Ticket_iterator it(m_granted); + MDL_ticket *conflicting_ticket; + rpl_group_info *rgi_slave= ctx->get_thd()->rgi_slave; + + if (!rgi_slave->gtid_sub_id) + return 0; + + while ((conflicting_ticket= it++)) + { + if (conflicting_ticket->get_ctx() != ctx) + { + MDL_context *conflicting_ctx= conflicting_ticket->get_ctx(); + rpl_group_info *conflicting_rgi_slave; + conflicting_rgi_slave= conflicting_ctx->get_thd()->rgi_slave; + + /* + If the conflicting thread is another parallel replication + thread for the same master and it's not in commit stage, then + the current transaction has started too early and something is + seriously wrong. + */ + if (conflicting_rgi_slave && + conflicting_rgi_slave->gtid_sub_id && + conflicting_rgi_slave->rli == rgi_slave->rli && + conflicting_rgi_slave->current_gtid.domain_id == + rgi_slave->current_gtid.domain_id && + !conflicting_rgi_slave->did_mark_start_commit) + return 1; // Fatal error + } + } + return 0; +} +#endif + + /** Acquire one lock with waiting for conflicting locks to go away if needed. @@ -2036,6 +2090,19 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) if (lock->needs_notification(ticket) && lock_wait_timeout) lock->notify_conflicting_locks(this); + /* + Ensure that if we are trying to get an exclusive lock for a slave + running parallel replication, then we are not blocked by another + parallel slave thread that is not committed. This should never happen as + the parallel replication scheduler should never schedule a DDL while + DML's are still running. + */ + DBUG_ASSERT((mdl_request->type != MDL_INTENTION_EXCLUSIVE && + mdl_request->type != MDL_EXCLUSIVE) || + !(get_thd()->rgi_slave && + get_thd()->rgi_slave->is_parallel_exec && + lock->check_if_conflicting_replication_locks(this))); + mysql_prlock_unlock(&lock->m_rwlock); will_wait_for(ticket); diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 6e8428f1aad..5de9b4a9eec 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -261,7 +261,7 @@ int handler::multi_range_read_next(range_id_t *range_info) } else { - if (was_semi_consistent_read()) + if (ha_was_semi_consistent_read()) { /* The following assignment is redundant, but for extra safety and to diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index e97db210da7..d36fdd1192a 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -330,6 +330,8 @@ void Single_line_formatting_helper::flush_on_one_line() ptr++; } owner->output.append(']'); + /* We've printed out the contents of the buffer, mark it as empty */ + buf_ptr= buffer; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ee40df945ed..8ff01a3c056 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2676,26 +2676,17 @@ static void network_init(void) saPipeSecurity.lpSecurityDescriptor = &sdPipeDescriptor; saPipeSecurity.bInheritHandle = FALSE; if ((hPipe= CreateNamedPipe(pipe_name, - PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | - PIPE_READMODE_BYTE | - PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, - (int) global_system_variables.net_buffer_length, - (int) global_system_variables.net_buffer_length, - NMPWAIT_USE_DEFAULT_WAIT, - &saPipeSecurity)) == INVALID_HANDLE_VALUE) - { - LPVOID lpMsgBuf; - int error=GetLastError(); - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, 0, NULL ); - sql_perror((char *)lpMsgBuf); - LocalFree(lpMsgBuf); - unireg_abort(1); - } + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + (int) global_system_variables.net_buffer_length, + (int) global_system_variables.net_buffer_length, + NMPWAIT_USE_DEFAULT_WAIT, + &saPipeSecurity)) == INVALID_HANDLE_VALUE) + { + sql_perror("Create named pipe failed"); + unireg_abort(1); + } } #endif @@ -4190,14 +4181,6 @@ static int init_common_variables() else opt_log_basename= glob_hostname; -#ifdef WITH_WSREP - if (wsrep_node_name == 0 || wsrep_node_name[0] == 0) - { - my_free((void *)wsrep_node_name); - wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME)); - } -#endif /* WITH_WSREP */ - strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5); strmov(fn_ext(pidfile_name),".pid"); // Add proper extension SYSVAR_AUTOSIZE(pidfile_name_ptr, pidfile_name); @@ -7736,7 +7719,10 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff) var->value= buff; mysql_mutex_lock(&LOCK_active_mi); - *((longlong *)buff)= master_info_index->any_slave_sql_running(); + if (master_info_index) + *((longlong *)buff)= master_info_index->any_slave_sql_running(); + else + *((longlong *)buff)= 0; mysql_mutex_unlock(&LOCK_active_mi); return 0; @@ -8370,6 +8356,7 @@ SHOW_VAR status_vars[]= { {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG}, {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH}, {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG}, + {"Delete_scan", (char*) offsetof(STATUS_VAR, delete_scan_count), SHOW_LONG_STATUS}, {"Empty_queries", (char*) offsetof(STATUS_VAR, empty_queries), SHOW_LONG_STATUS}, {"Executed_events", (char*) &executed_events, SHOW_LONG_NOFLUSH }, {"Executed_triggers", (char*) offsetof(STATUS_VAR, executed_triggers), SHOW_LONG_STATUS}, @@ -8398,6 +8385,7 @@ SHOW_VAR status_vars[]= { {"Handler_read_last", (char*) offsetof(STATUS_VAR, ha_read_last_count), SHOW_LONG_STATUS}, {"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS}, {"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS}, + {"Handler_read_retry", (char*) offsetof(STATUS_VAR, ha_read_retry_count), SHOW_LONG_STATUS}, {"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS}, {"Handler_read_rnd_deleted", (char*) offsetof(STATUS_VAR, ha_read_rnd_deleted_count), SHOW_LONG_STATUS}, {"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS}, @@ -8519,6 +8507,7 @@ SHOW_VAR status_vars[]= { {"Threads_connected", (char*) &connection_count, SHOW_INT}, {"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH}, {"Threads_running", (char*) &thread_running, SHOW_INT}, + {"Update_scan", (char*) offsetof(STATUS_VAR, update_scan_count), SHOW_LONG_STATUS}, {"Uptime", (char*) &show_starttime, SHOW_SIMPLE_FUNC}, #ifdef ENABLED_PROFILING {"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC}, @@ -9274,6 +9263,16 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) #endif break; } +#ifdef WITH_WSREP + case OPT_WSREP_CAUSAL_READS: + wsrep_causal_reads_update(&global_system_variables); + break; + case OPT_WSREP_SYNC_WAIT: + global_system_variables.wsrep_causal_reads= + MY_TEST(global_system_variables.wsrep_sync_wait & + WSREP_SYNC_WAIT_BEFORE_READ); + break; +#endif /* WITH_WSREP */ } return 0; } @@ -10118,11 +10117,6 @@ PSI_stage_info stage_waiting_for_the_next_event_in_relay_log= { 0, "Waiting for PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position= { 0, "Waiting for the slave SQL thread to advance position", 0}; PSI_stage_info stage_waiting_to_finalize_termination= { 0, "Waiting to finalize termination", 0}; PSI_stage_info stage_waiting_to_get_readlock= { 0, "Waiting to get readlock", 0}; -PSI_stage_info stage_slave_waiting_workers_to_exit= { 0, "Waiting for workers to exit", 0}; -PSI_stage_info stage_slave_waiting_worker_to_release_partition= { 0, "Waiting for Slave Worker to release partition", 0}; -PSI_stage_info stage_slave_waiting_worker_to_free_events= { 0, "Waiting for Slave Workers to free pending events", 0}; -PSI_stage_info stage_slave_waiting_worker_queue= { 0, "Waiting for Slave Worker queue", 0}; -PSI_stage_info stage_slave_waiting_event_from_coordinator= { 0, "Waiting for an event from Coordinator", 0}; PSI_stage_info stage_binlog_waiting_background_tasks= { 0, "Waiting for background binlog tasks", 0}; PSI_stage_info stage_binlog_processing_checkpoint_notify= { 0, "Processing binlog checkpoint notification", 0}; PSI_stage_info stage_binlog_stopping_background_thread= { 0, "Stopping binlog background thread", 0}; @@ -10218,11 +10212,6 @@ PSI_stage_info *all_server_stages[]= & stage_setup, & stage_show_explain, & stage_slave_has_read_all_relay_log, - & stage_slave_waiting_event_from_coordinator, - & stage_slave_waiting_worker_queue, - & stage_slave_waiting_worker_to_free_events, - & stage_slave_waiting_worker_to_release_partition, - & stage_slave_waiting_workers_to_exit, & stage_sorting, & stage_sorting_for_group, & stage_sorting_for_order, diff --git a/sql/mysqld.h b/sql/mysqld.h index 594afac521d..8c6c4ea1524 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -474,11 +474,6 @@ extern PSI_stage_info stage_waiting_for_the_next_event_in_relay_log; extern PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position; extern PSI_stage_info stage_waiting_to_finalize_termination; extern PSI_stage_info stage_waiting_to_get_readlock; -extern PSI_stage_info stage_slave_waiting_worker_to_release_partition; -extern PSI_stage_info stage_slave_waiting_worker_to_free_events; -extern PSI_stage_info stage_slave_waiting_worker_queue; -extern PSI_stage_info stage_slave_waiting_event_from_coordinator; -extern PSI_stage_info stage_slave_waiting_workers_to_exit; extern PSI_stage_info stage_binlog_waiting_background_tasks; extern PSI_stage_info stage_binlog_processing_checkpoint_notify; extern PSI_stage_info stage_binlog_stopping_background_thread; @@ -636,6 +631,10 @@ enum options_mysqld OPT_SSL_KEY, OPT_THREAD_CONCURRENCY, OPT_WANT_CORE, +#ifdef WITH_WSREP + OPT_WSREP_CAUSAL_READS, + OPT_WSREP_SYNC_WAIT, +#endif /* WITH_WSREP */ OPT_MYSQL_COMPATIBILITY, OPT_MYSQL_TO_BE_IMPLEMENTED, OPT_which_is_always_the_last diff --git a/sql/net_serv.cc b/sql/net_serv.cc index d81c89fe534..ef7a46a7109 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -541,7 +541,7 @@ net_write_buff(NET *net, const uchar *packet, ulong len) left_length= (ulong) (net->buff_end - net->write_pos); #ifdef DEBUG_DATA_PACKETS - DBUG_DUMP("data", packet, len); + DBUG_DUMP("data_written", packet, len); #endif if (len > left_length) { @@ -630,7 +630,8 @@ net_real_write(NET *net,const uchar *packet, size_t len) } memcpy(b+header_length,packet,len); - if (my_compress(b+header_length, &len, &complen)) + /* Don't compress error packets (compress == 2) */ + if (net->compress == 2 || my_compress(b+header_length, &len, &complen)) complen=0; int3store(&b[NET_HEADER_SIZE],complen); int3store(b,len); @@ -641,7 +642,7 @@ net_real_write(NET *net,const uchar *packet, size_t len) #endif /* HAVE_COMPRESS */ #ifdef DEBUG_DATA_PACKETS - DBUG_DUMP("data", packet, len); + DBUG_DUMP("data_written", packet, len); #endif #ifndef NO_ALARM @@ -831,6 +832,7 @@ my_real_read(NET *net, size_t *complen, size_t length; uint i,retry_count=0; ulong len=packet_error; + my_bool expect_error_packet __attribute__((unused))= 0; thr_alarm_t alarmed; #ifndef NO_ALARM ALARM alarm_buff; @@ -879,6 +881,7 @@ my_real_read(NET *net, size_t *complen, if (i== 0 && thd_net_is_killed()) { + DBUG_PRINT("info", ("thd is killed")); len= packet_error; net->error= 0; net->last_errno= ER_CONNECTION_KILLED; @@ -948,39 +951,34 @@ my_real_read(NET *net, size_t *complen, pos+= length; update_statistics(thd_increment_bytes_received(net->thd, length)); } + +#ifdef DEBUG_DATA_PACKETS + DBUG_DUMP("data_read", net->buff+net->where_b, length); +#endif if (i == 0) { /* First parts is packet length */ ulong helping; +#ifndef DEBUG_DATA_PACKETS DBUG_DUMP("packet_header", net->buff+net->where_b, NET_HEADER_SIZE); - if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr) - { - if (net->buff[net->where_b] != (uchar) 255) - { - DBUG_PRINT("error", - ("Packets out of order (Found: %d, expected %u)", - (int) net->buff[net->where_b + 3], - net->pkt_nr)); - /* - We don't make noise server side, since the client is expected - to break the protocol for e.g. --send LOAD DATA .. LOCAL where - the server expects the client to send a file, but the client - may reply with a new command instead. - */ -#ifndef MYSQL_SERVER - EXTRA_DEBUG_fflush(stdout); - EXTRA_DEBUG_fprintf(stderr,"Error: Packets out of order (Found: %d, expected %d)\n", - (int) net->buff[net->where_b + 3], - (uint) (uchar) net->pkt_nr); - EXTRA_DEBUG_fflush(stderr); #endif - } - len= packet_error; - /* Not a NET error on the client. XXX: why? */ - MYSQL_SERVER_my_error(ER_NET_PACKETS_OUT_OF_ORDER, MYF(0)); - goto end; - } - net->compress_pkt_nr= ++net->pkt_nr; + if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr) + { +#ifndef MYSQL_SERVER + if (net->buff[net->where_b + 3] == (uchar) (net->pkt_nr -1)) + { + /* + If the server was killed then the server may have missed the + last sent client packet and the packet numbering may be one off. + */ + DBUG_PRINT("warning", ("Found possible out of order packets")); + expect_error_packet= 1; + } + else +#endif + goto packets_out_of_order; + } + net->compress_pkt_nr= ++net->pkt_nr; #ifdef HAVE_COMPRESS if (net->compress) { @@ -1028,6 +1026,21 @@ my_real_read(NET *net, size_t *complen, } #endif } +#ifndef MYSQL_SERVER + else if (expect_error_packet) + { + /* + This check is safe both for compressed and not compressed protocol + as for the compressed protocol errors are not compressed anymore. + */ + if (net->buff[net->where_b] != (uchar) 255) + { + /* Restore pkt_nr to original value */ + net->pkt_nr--; + goto packets_out_of_order; + } + } +#endif } end: @@ -1041,7 +1054,7 @@ end: net->reading_or_writing=0; #ifdef DEBUG_DATA_PACKETS if (len != packet_error) - DBUG_DUMP("data", net->buff+net->where_b, len); + DBUG_DUMP("data_read", net->buff+net->where_b, len); #endif #ifdef MYSQL_SERVER if (server_extension != NULL) @@ -1052,9 +1065,35 @@ end: } #endif return(len); + +packets_out_of_order: + { + DBUG_PRINT("error", + ("Packets out of order (Found: %d, expected %u)", + (int) net->buff[net->where_b + 3], + net->pkt_nr)); + DBUG_ASSERT(0); + /* + We don't make noise server side, since the client is expected + to break the protocol for e.g. --send LOAD DATA .. LOCAL where + the server expects the client to send a file, but the client + may reply with a new command instead. + */ +#ifndef MYSQL_SERVER + EXTRA_DEBUG_fflush(stdout); + EXTRA_DEBUG_fprintf(stderr,"Error: Packets out of order (Found: %d, expected %d)\n", + (int) net->buff[net->where_b + 3], + (uint) (uchar) net->pkt_nr); + EXTRA_DEBUG_fflush(stderr); +#endif + len= packet_error; + MYSQL_SERVER_my_error(ER_NET_PACKETS_OUT_OF_ORDER, MYF(0)); + goto end; + } } + /* Old interface. See my_net_read_packet() for function description */ #undef my_net_read diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 3d059abd666..1a0d12a8dee 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2426,8 +2426,6 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, scan_time= read_time= DBL_MAX; if (limit < records) read_time= (double) records + scan_time + 1; // Force to use index - else if (read_time <= 2.0 && !force_quick_range) - DBUG_RETURN(0); /* No need for quick select */ possible_keys.clear_all(); @@ -2697,7 +2695,6 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, thd->no_errors=0; } - DBUG_EXECUTE("info", print_quick(quick, &needed_reg);); /* @@ -7114,7 +7111,7 @@ SEL_TREE *Item_func_in::get_func_mm_tree(RANGE_OPT_PARAM *param, DBUG_RETURN(NULL); } SEL_TREE *tree2; - for (; i < array->count; i++) + for (; i < array->used_count; i++) { if (array->compare_elems(i, i-1)) { @@ -8580,6 +8577,7 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) for e.g. "key IN (c1, ..., cN)" which produces a lot of ranges. */ result= tree1; + result->keys_map.clear_all(); } else { @@ -10375,8 +10373,10 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, KEY *table_key=quick->head->key_info+quick->index; flag=EQ_RANGE; if ((table_key->flags & HA_NOSAME) && + min_part == key_tree->part && key_tree->part == table_key->user_defined_key_parts-1) { + DBUG_ASSERT(min_part == max_part); if ((table_key->flags & HA_NULL_PART_KEY) && null_part_in_key(key, param->min_key, @@ -11901,8 +11901,6 @@ void QUICK_ROR_UNION_SELECT::add_used_key_part_to_set(MY_BITMAP *col_set) *******************************************************************************/ static inline uint get_field_keypart(KEY *index, Field *field); -static inline SEL_ARG * get_index_range_tree(uint index, SEL_TREE* range_tree, - PARAM *param, uint *param_idx); static bool get_sel_arg_for_keypart(Field *field, SEL_ARG *index_range_tree, SEL_ARG **cur_range); static bool get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, @@ -12179,8 +12177,6 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) (GA1,GA2) are all TRUE. If there is more than one such index, select the first one. Here we set the variables: group_prefix_len and index_info. */ - KEY *cur_index_info= table->key_info; - KEY *cur_index_info_end= cur_index_info + table->s->keys; /* Cost-related variables for the best index so far. */ double best_read_cost= DBL_MAX; ha_rows best_records= 0; @@ -12192,11 +12188,12 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) uint max_key_part; SEL_ARG *cur_index_tree= NULL; ha_rows cur_quick_prefix_records= 0; - uint cur_param_idx=MAX_KEY; - for (uint cur_index= 0 ; cur_index_info != cur_index_info_end ; - cur_index_info++, cur_index++) + // We go through allowed indexes + for (uint cur_param_idx= 0; cur_param_idx < param->keys ; ++cur_param_idx) { + const uint cur_index= param->real_keynr[cur_param_idx]; + KEY *const cur_index_info= &table->key_info[cur_index]; KEY_PART_INFO *cur_part; KEY_PART_INFO *end_part; /* Last part for loops. */ /* Last index part. */ @@ -12219,7 +12216,8 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) (was also: "Exclude UNIQUE indexes ..." but this was removed because there are cases Loose Scan over a multi-part index is useful). */ - if (!table->covering_keys.is_set(cur_index)) + if (!table->covering_keys.is_set(cur_index) || + !table->keys_in_use_for_group_by.is_set(cur_index)) continue; /* @@ -12398,9 +12396,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) { if (tree) { - uint dummy; - SEL_ARG *index_range_tree= get_index_range_tree(cur_index, tree, param, - &dummy); + SEL_ARG *index_range_tree= tree->keys[cur_param_idx]; if (!get_constant_key_infix(cur_index_info, index_range_tree, first_non_group_part, min_max_arg_part, last_part, thd, cur_key_infix, @@ -12464,9 +12460,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) */ if (tree && min_max_arg_item) { - uint dummy; - SEL_ARG *index_range_tree= get_index_range_tree(cur_index, tree, param, - &dummy); + SEL_ARG *index_range_tree= tree->keys[cur_param_idx]; SEL_ARG *cur_range= NULL; if (get_sel_arg_for_keypart(min_max_arg_part->field, index_range_tree, &cur_range) || @@ -12484,9 +12478,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) /* Compute the cost of using this index. */ if (tree) { - /* Find the SEL_ARG sub-tree that corresponds to the chosen index. */ - cur_index_tree= get_index_range_tree(cur_index, tree, param, - &cur_param_idx); + cur_index_tree= tree->keys[cur_param_idx]; /* Check if this range tree can be used for prefix retrieval. */ Cost_estimate dummy_cost; uint mrr_flags= HA_MRR_USE_DEFAULT_IMPL; @@ -13019,44 +13011,6 @@ get_field_keypart(KEY *index, Field *field) } -/* - Find the SEL_ARG sub-tree that corresponds to the chosen index. - - SYNOPSIS - get_index_range_tree() - index [in] The ID of the index being looked for - range_tree[in] Tree of ranges being searched - param [in] PARAM from SQL_SELECT::test_quick_select - param_idx [out] Index in the array PARAM::key that corresponds to 'index' - - DESCRIPTION - - A SEL_TREE contains range trees for all usable indexes. This procedure - finds the SEL_ARG sub-tree for 'index'. The members of a SEL_TREE are - ordered in the same way as the members of PARAM::key, thus we first find - the corresponding index in the array PARAM::key. This index is returned - through the variable param_idx, to be used later as argument of - check_quick_select(). - - RETURN - Pointer to the SEL_ARG subtree that corresponds to index. -*/ - -SEL_ARG * get_index_range_tree(uint index, SEL_TREE* range_tree, PARAM *param, - uint *param_idx) -{ - uint idx= 0; /* Index nr in param->key_parts */ - while (idx < param->keys) - { - if (index == param->real_keynr[idx]) - break; - idx++; - } - *param_idx= idx; - return(range_tree->keys[idx]); -} - - /* Compute the cost of a quick_group_min_max_select for a particular index. diff --git a/sql/opt_range_mrr.cc b/sql/opt_range_mrr.cc index 729c491a6f1..fbccb7c4e1d 100644 --- a/sql/opt_range_mrr.cc +++ b/sql/opt_range_mrr.cc @@ -278,14 +278,14 @@ walk_up_n_right: (1) - range analysis is used for estimating condition selectivity (2) - This is a unique key, and we have conditions for all its user-defined key parts. - (3) - The table uses extended keys, and we have conditions for - all key parts. + (3) - The table uses extended keys, this key covers all components, + and we have conditions for all key parts. */ if (!(cur->min_key_flag & ~NULL_RANGE) && !cur->max_key_flag && (!key_info || // (1) ((uint)key_tree->part+1 == key_info->user_defined_key_parts && // (2) key_info->flags & HA_NOSAME) || // (2) - (seq->param->table->s->use_ext_keys && // (3) + ((key_info->flags & HA_EXT_NOSAME) && // (3) (uint)key_tree->part+1 == key_info->ext_key_parts) // (3) ) && range->start_key.length == range->end_key.length && diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 537774aea2a..361da4e6279 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1558,7 +1558,12 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) { tl->set_tablenr(table_no); if (tl->is_jtbm()) + { tl->jtbm_table_no= table_no; + Item *dummy= tl->jtbm_subselect; + tl->jtbm_subselect->fix_after_pullout(parent_lex, &dummy); + DBUG_ASSERT(dummy == tl->jtbm_subselect); + } SELECT_LEX *old_sl= tl->select_lex; tl->select_lex= parent_join->select_lex; for (TABLE_LIST *emb= tl->embedding; diff --git a/sql/protocol.cc b/sql/protocol.cc index fa42915f5a9..4ae9497c039 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -373,7 +373,8 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, uint error; char converted_err[MYSQL_ERRMSG_SIZE]; char buff[2+1+SQLSTATE_LENGTH+MYSQL_ERRMSG_SIZE], *pos; - + my_bool ret; + uint8 save_compress; DBUG_ENTER("send_error_packet"); if (net->vio == 0) @@ -401,8 +402,16 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, /* Converted error message is always null-terminated. */ length= (uint) (strmake(pos, converted_err, MYSQL_ERRMSG_SIZE - 1) - buff); - DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) buff, - length)); + /* + Ensure that errors are not compressed. This is to ensure we can + detect out of bands error messages in the client + */ + if ((save_compress= net->compress)) + net->compress= 2; + ret= net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) buff, + length); + net->compress= save_compress; + DBUG_RETURN(ret); } #endif /* EMBEDDED_LIBRARY */ diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 02dbac46eb5..6048d26998b 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -1233,8 +1233,6 @@ Master_info_index::get_master_info(const LEX_STRING *connection_name, connection_name->str)); mysql_mutex_assert_owner(&LOCK_active_mi); - if (!this) // master_info_index is set to NULL on server shutdown - DBUG_RETURN(NULL); /* Make name lower case for comparison */ res= strmake(buff, connection_name->str, connection_name->length); @@ -1388,8 +1386,6 @@ bool Master_info_index::give_error_if_slave_running() { DBUG_ENTER("give_error_if_slave_running"); mysql_mutex_assert_owner(&LOCK_active_mi); - if (!this) // master_info_index is set to NULL on server shutdown - DBUG_RETURN(TRUE); for (uint i= 0; i< master_info_hash.records; ++i) { @@ -1420,8 +1416,7 @@ uint Master_info_index::any_slave_sql_running() { uint count= 0; DBUG_ENTER("any_slave_sql_running"); - if (!this) // master_info_index is set to NULL on server shutdown - DBUG_RETURN(count); + mysql_mutex_assert_owner(&LOCK_active_mi); for (uint i= 0; i< master_info_hash.records; ++i) { diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 2dd6f7d7afc..31dd24a038d 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1906,8 +1906,8 @@ rpl_group_info::mark_start_commit_no_lock() { if (did_mark_start_commit) return; - mark_start_commit_inner(parallel_entry, gco, this); did_mark_start_commit= true; + mark_start_commit_inner(parallel_entry, gco, this); } @@ -1918,12 +1918,12 @@ rpl_group_info::mark_start_commit() if (did_mark_start_commit) return; + did_mark_start_commit= true; e= this->parallel_entry; mysql_mutex_lock(&e->LOCK_parallel_entry); mark_start_commit_inner(e, gco, this); mysql_mutex_unlock(&e->LOCK_parallel_entry); - did_mark_start_commit= true; } @@ -1966,12 +1966,12 @@ rpl_group_info::unmark_start_commit() if (!did_mark_start_commit) return; + did_mark_start_commit= false; e= this->parallel_entry; mysql_mutex_lock(&e->LOCK_parallel_entry); --e->count_committing_event_groups; mysql_mutex_unlock(&e->LOCK_parallel_entry); - did_mark_start_commit= false; } diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 709ac55b28c..a6eaf2b27bd 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7139,3 +7139,6 @@ ER_KILL_QUERY_DENIED_ERROR ER_NO_EIS_FOR_FIELD eng "Engine-independent statistics are not collected for column '%s'" ukr "Незалежна від типу таблиці статистика не збирається для стовбця '%s'" +ER_WARN_AGGFUNC_DEPENDENCE + eng "Aggregate function '%-.192s)' of SELECT #%d belongs to SELECT #%d" + ukr "Агрегатна функція '%-.192s)' з SELECTу #%d належить до SELECTу #%d" diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 9077b24416b..9dd3e532d1e 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -65,6 +65,12 @@ extern "C" sig_handler handle_fatal_signal(int sig) #ifdef HAVE_STACKTRACE THD *thd; #endif + /* + This flag remembers if the query pointer was found invalid. + We will try and print the query at the end of the signal handler, in case + we're wrong. + */ + bool print_invalid_query_pointer= false; if (segfaulted) { @@ -201,7 +207,12 @@ extern "C" sig_handler handle_fatal_signal(int sig) "Some pointers may be invalid and cause the dump to abort.\n"); my_safe_printf_stderr("Query (%p): ", thd->query()); - my_safe_print_str(thd->query(), MY_MIN(65536U, thd->query_length())); + if (my_safe_print_str(thd->query(), MY_MIN(65536U, thd->query_length()))) + { + // Query was found invalid. We will try to print it at the end. + print_invalid_query_pointer= true; + } + my_safe_printf_stderr("\nConnection ID (thread ID): %lu\n", (ulong) thd->thread_id); my_safe_printf_stderr("Status: %s\n\n", kreason); @@ -265,6 +276,16 @@ extern "C" sig_handler handle_fatal_signal(int sig) "\"mlockall\" bugs.\n"); } + if (print_invalid_query_pointer) + { + my_safe_printf_stderr( + "\nWe think the query pointer is invalid, but we will try " + "to print it anyway. \n" + "Query: "); + my_write_stderr(thd->query(), MY_MIN(65536U, thd->query_length())); + my_safe_printf_stderr("\n\n"); + } + #ifdef HAVE_WRITE_CORE if (test_flags & TEST_CORE_ON_SIGNAL) { diff --git a/sql/slave.cc b/sql/slave.cc index 5410192a8dd..fc857d8c7c2 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2015, MariaDB +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB 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 @@ -651,6 +651,7 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) mysql_mutex_unlock(log_lock); } if (opt_slave_parallel_threads > 0 && + master_info_index &&// master_info_index is set to NULL on server shutdown !master_info_index->any_slave_sql_running()) rpl_parallel_inactivate_pool(&global_rpl_thread_pool); if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)) @@ -1362,6 +1363,10 @@ bool is_network_error(uint errorno) errorno == ER_NET_READ_INTERRUPTED || errorno == ER_SERVER_SHUTDOWN) return TRUE; +#ifdef WITH_WSREP + if (errorno == ER_UNKNOWN_COM_ERROR) + return TRUE; +#endif return FALSE; } @@ -4355,7 +4360,8 @@ int check_temp_dir(char* tmp_file) mysql_mutex_lock(&LOCK_thread_count); if (check_temp_dir_run) { - result= check_temp_dir_result; + if ((result= check_temp_dir_result)) + my_message(result, tmp_file, MYF(0)); goto end; } check_temp_dir_run= 1; @@ -4390,7 +4396,6 @@ int check_temp_dir(char* tmp_file) mysql_file_delete(key_file_misc, tmp_file, MYF(0)); end: - check_temp_dir_result= result; mysql_mutex_unlock(&LOCK_thread_count); DBUG_RETURN(result); } @@ -4672,11 +4677,14 @@ pthread_handler_t handle_slave_sql(void *arg) if (check_temp_dir(rli->slave_patternload_file)) { + check_temp_dir_result= thd->get_stmt_da()->sql_errno(); rli->report(ERROR_LEVEL, thd->get_stmt_da()->sql_errno(), NULL, "Unable to use slave's temporary directory %s - %s", slave_load_tmpdir, thd->get_stmt_da()->message()); goto err; } + else + check_temp_dir_result= 0; /* Load the set of seen GTIDs, if we did not already. */ if (rpl_load_gtid_slave_state(thd)) @@ -6211,9 +6219,9 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, #ifndef DBUG_OFF mi->events_till_disconnect = disconnect_slave_event_count; #endif - ulong client_flag= 0; + ulong client_flag= CLIENT_REMEMBER_OPTIONS; if (opt_slave_compressed_protocol) - client_flag=CLIENT_COMPRESS; /* We will use compression */ + client_flag|= CLIENT_COMPRESS; /* We will use compression */ mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout); mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout); diff --git a/sql/slave.h b/sql/slave.h index ca89064d773..7f412c1091c 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -1,5 +1,5 @@ -/* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sp_head.cc b/sql/sp_head.cc index cb598b367e7..29427c3834a 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2002, 2013, Oracle and/or its affiliates. - Copyright (c) 2011, 2013, Monty Program Ab + Copyright (c) 2002, 2016, Oracle and/or its affiliates. + Copyright (c) 2011, 2016, MariaDB 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 @@ -534,8 +534,10 @@ sp_name::init_qname(THD *thd) bool check_routine_name(LEX_STRING *ident) { - if (!ident || !ident->str || !ident->str[0] || - ident->str[ident->length-1] == ' ') + DBUG_ASSERT(ident); + DBUG_ASSERT(ident->str); + + if (!ident->str[0] || ident->str[ident->length-1] == ' ') { my_error(ER_SP_WRONG_NAME, MYF(0), ident->str); return TRUE; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 7db7d2cf3fb..48c57303805 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -31,7 +31,7 @@ #include "sql_base.h" // close_mysql_tables #include "key.h" // key_copy, key_cmp_if_same, key_restore #include "sql_show.h" // append_identifier -#include "sql_table.h" // build_table_filename +#include "sql_table.h" // write_bin_log #include "hash_filo.h" #include "sql_parse.h" // check_access #include "sql_view.h" // VIEW_ANY_ACL @@ -2797,7 +2797,7 @@ bool change_password(THD *thd, LEX_USER *user) if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)) { - thd->set_query_inner(buff, query_length, system_charset_info); + thd->set_query(buff, query_length, system_charset_info); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL); } @@ -2858,7 +2858,7 @@ error: // this label is used in WSREP_TO_ISOLATION_BEGIN { WSREP_TO_ISOLATION_END; - thd->set_query_inner(query_save); + thd->set_query(query_save); thd->wsrep_exec_mode = LOCAL_STATE; } #endif /* WITH_WSREP */ @@ -2913,7 +2913,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)) { - thd->set_query_inner(buff, query_length, system_charset_info); + thd->set_query(buff, query_length, system_charset_info); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL); } @@ -3009,7 +3009,7 @@ error: // this label is used in WSREP_TO_ISOLATION_END { WSREP_TO_ISOLATION_END; - thd->set_query_inner(query_save); + thd->set_query(query_save); thd->wsrep_exec_mode = LOCAL_STATE; } #endif /* WITH_WSREP */ @@ -7382,8 +7382,7 @@ bool check_grant_db(THD *thd, const char *db) len= (uint) (end - helping) + 1; /* - If a role is set, we need to check for privileges - here aswell + If a role is set, we need to check for privileges here as well. */ if (sctx->priv_role[0]) { @@ -7397,11 +7396,10 @@ bool check_grant_db(THD *thd, const char *db) for (uint idx=0 ; idx < column_priv_hash.records ; idx++) { - GRANT_TABLE *grant_table= (GRANT_TABLE*) - my_hash_element(&column_priv_hash, - idx); + GRANT_TABLE *grant_table= (GRANT_TABLE*) my_hash_element(&column_priv_hash, + idx); if (len < grant_table->key_length && - !memcmp(grant_table->hash_key,helping,len) && + !memcmp(grant_table->hash_key, helping, len) && compare_hostname(&grant_table->host, sctx->host, sctx->ip)) { error= FALSE; /* Found match. */ @@ -7409,7 +7407,7 @@ bool check_grant_db(THD *thd, const char *db) } if (sctx->priv_role[0] && len2 < grant_table->key_length && - !memcmp(grant_table->hash_key,helping2,len) && + !memcmp(grant_table->hash_key, helping2, len2) && (!grant_table->host.hostname || !grant_table->host.hostname[0])) { error= FALSE; /* Found role match */ @@ -12201,6 +12199,9 @@ static bool acl_check_ssl(THD *thd, const ACL_USER *acl_user) return 1; } } + if (!acl_user->x509_issuer && !acl_user->x509_subject) + return 0; // all done + /* Prepare certificate (if exists) */ if (!(cert= SSL_get_peer_certificate(ssl))) return 1; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e808fbafb50..9ea5b20dce6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2010, 2016, MariaDB This program is free software; you can redistribute it and/or modify @@ -691,7 +691,6 @@ bool close_cached_connection_tables(THD *thd, LEX_STRING *connection) static void mark_temp_tables_as_free_for_reuse(THD *thd) { - rpl_group_info *rgi_slave; DBUG_ENTER("mark_temp_tables_as_free_for_reuse"); if (thd->query_id == 0) @@ -700,9 +699,7 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd) DBUG_VOID_RETURN; } - rgi_slave=thd->rgi_slave; - if ((!rgi_slave && thd->temporary_tables) || - (rgi_slave && unlikely(rgi_slave->rli->save_temporary_tables))) + if (thd->have_temporary_tables()) { thd->lock_temporary_tables(); for (TABLE *table= thd->temporary_tables ; table ; table= table->next) @@ -710,15 +707,7 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd) if ((table->query_id == thd->query_id) && ! table->open_by_handler) mark_tmp_table_for_reuse(table); } - thd->unlock_temporary_tables(); - if (rgi_slave) - { - /* - Temporary tables are shared with other by sql execution threads. - As a safety messure, clear the pointer to the common area. - */ - thd->temporary_tables= 0; - } + thd->unlock_temporary_tables(1); } DBUG_VOID_RETURN; } @@ -1686,7 +1675,7 @@ TABLE *find_temporary_table(THD *thd, break; } } - thd->unlock_temporary_tables(); + thd->unlock_temporary_tables(0); return result; } @@ -1789,7 +1778,7 @@ void close_temporary_table(THD *thd, TABLE *table, thread_safe_decrement32(&slave_open_temp_tables); table->in_use= 0; // No statistics } - thd->unlock_temporary_tables(); + thd->unlock_temporary_tables(0); close_temporary(table, free_share, delete_table); DBUG_VOID_RETURN; } @@ -4888,6 +4877,15 @@ handle_view(THD *thd, Query_tables_list *prelocking_ctx, &table_list->view->sroutines_list, table_list->top_table()); } + + /* + If a trigger was defined on one of the associated tables then assign the + 'trg_event_map' value of the view to the next table in table_list. When a + Stored function is invoked, all the associated tables including the tables + associated with the trigger are prelocked. + */ + if (table_list->trg_event_map && table_list->next_global) + table_list->next_global->trg_event_map= table_list->trg_event_map; return FALSE; } @@ -5746,7 +5744,7 @@ TABLE *open_table_uncached(THD *thd, handlerton *hton, { thread_safe_increment32(&slave_open_temp_tables); } - thd->unlock_temporary_tables(); + thd->unlock_temporary_tables(0); } tmp_table->pos_in_table_list= 0; DBUG_PRINT("tmptable", ("opened table: '%s'.'%s' 0x%lx", tmp_table->s->db.str, @@ -8728,7 +8726,8 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, value=v++; Field *rfield= field->field; TABLE* table= rfield->table; - if (rfield == table->next_number_field) + if (table->next_number_field && + rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; if (rfield->vcol_info && value->type() != Item::DEFAULT_VALUE_ITEM && diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 16773ab3018..2821fcd6004 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1029,6 +1029,7 @@ THD::THD(bool is_wsrep_applier) wsrep_TOI_pre_query_len = 0; wsrep_info[sizeof(wsrep_info) - 1] = '\0'; /* make sure it is 0-terminated */ wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; + wsrep_affected_rows = 0; #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1444,6 +1445,7 @@ void THD::init(void) wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; + wsrep_affected_rows = 0; #endif /* WITH_WSREP */ if (variables.sql_log_bin) @@ -2233,6 +2235,8 @@ void THD::cleanup_after_query() #ifdef WITH_WSREP wsrep_sync_wait_gtid= WSREP_GTID_UNDEFINED; + if (!in_active_multi_stmt_transaction()) + wsrep_affected_rows= 0; #endif /* WITH_WSREP */ DBUG_VOID_RETURN; @@ -5196,7 +5200,11 @@ void THD::get_definer(LEX_USER *definer, bool role) { binlog_invoker(role); #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#ifdef WITH_WSREP + if ((wsrep_applier || slave_thread) && has_invoker()) +#else if (slave_thread && has_invoker()) +#endif { definer->user = invoker_user; definer->host= invoker_host; @@ -6942,10 +6950,18 @@ void THD::rgi_lock_temporary_tables() temporary_tables= rgi_slave->rli->save_temporary_tables; } -void THD::rgi_unlock_temporary_tables() +void THD::rgi_unlock_temporary_tables(bool clear) { rgi_slave->rli->save_temporary_tables= temporary_tables; mysql_mutex_unlock(&rgi_slave->rli->data_lock); + if (clear) + { + /* + Temporary tables are shared with other by sql execution threads. + As a safety messure, clear the pointer to the common area. + */ + temporary_tables= 0; + } } bool THD::rgi_have_temporary_tables() diff --git a/sql/sql_class.h b/sql/sql_class.h index 8bfc243977f..33c8ed2efe1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -713,9 +713,11 @@ typedef struct system_status_var ulong ha_read_key_count; ulong ha_read_next_count; ulong ha_read_prev_count; + ulong ha_read_retry_count; ulong ha_read_rnd_count; ulong ha_read_rnd_next_count; ulong ha_read_rnd_deleted_count; + /* This number doesn't include calls to the default implementation and calls made by range access. The intent is to count only calls made by @@ -749,6 +751,8 @@ typedef struct system_status_var ulong select_range_count_; ulong select_range_check_count_; ulong select_scan_count_; + ulong update_scan_count; + ulong delete_scan_count; ulong executed_triggers; ulong long_query_count; ulong filesort_merge_passes_; @@ -3082,12 +3086,12 @@ public: set_start_time(); start_utime= utime_after_lock= microsecond_interval_timer(); } - inline void set_time(my_hrtime_t t) + inline void set_time(my_hrtime_t t) { user_time= t; set_time(); } - inline void set_time(my_time_t t, ulong sec_part) + inline void set_time(my_time_t t, ulong sec_part) { my_hrtime_t hrtime= { hrtime_from_time(t) + sec_part }; set_time(hrtime); @@ -3940,7 +3944,7 @@ private: /* Protect against add/delete of temporary tables in parallel replication */ void rgi_lock_temporary_tables(); - void rgi_unlock_temporary_tables(); + void rgi_unlock_temporary_tables(bool clear); bool rgi_have_temporary_tables(); public: /* @@ -3964,15 +3968,15 @@ public: if (rgi_slave) rgi_lock_temporary_tables(); } - inline void unlock_temporary_tables() + inline void unlock_temporary_tables(bool clear) { if (rgi_slave) - rgi_unlock_temporary_tables(); + rgi_unlock_temporary_tables(clear); } inline bool have_temporary_tables() { return (temporary_tables || - (rgi_slave && rgi_have_temporary_tables())); + (rgi_slave && unlikely(rgi_have_temporary_tables()))); } LF_PINS *tdc_hash_pins; @@ -4025,6 +4029,7 @@ public: */ bool wsrep_ignore_table; wsrep_gtid_t wsrep_sync_wait_gtid; + ulong wsrep_affected_rows; #endif /* WITH_WSREP */ /* Handling of timeouts for commands */ diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index e077073c2df..5b8896aa37f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -27,7 +27,6 @@ #include "sql_delete.h" #include "sql_cache.h" // query_cache_* #include "sql_base.h" // open_temprary_table -#include "sql_table.h" // build_table_filename #include "lock.h" // unlock_table_name #include "sql_view.h" // check_key_in_view, mysql_frm_type #include "sql_parse.h" // mysql_init_select @@ -484,6 +483,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, DBUG_EXECUTE_IF("show_explain_probe_delete_exec_start", dbug_serve_apcs(thd, 1);); + if (!(select && select->quick)) + status_var_increment(thd->status_var.delete_scan_count); + if (query_plan.using_filesort) { ha_rows examined_rows; diff --git a/sql/sql_help.cc b/sql/sql_help.cc index a0e836da203..d71a6caf813 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -667,7 +667,7 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen, TRUE Error and send_error already commited */ -bool mysqld_help(THD *thd, const char *mask) +static bool mysqld_help_internal(THD *thd, const char *mask) { Protocol *protocol= thd->protocol; SQL_SELECT *select; @@ -849,3 +849,12 @@ error2: DBUG_RETURN(TRUE); } + +bool mysqld_help(THD *thd, const char *mask) +{ + ulonglong sql_mode_backup= thd->variables.sql_mode; + thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; + bool rc= mysqld_help_internal(thd, mask); + thd->variables.sql_mode= sql_mode_backup; + return rc; +} diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fcf8c143ec4..ac7fd93f0c0 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3338,6 +3338,7 @@ bool Delayed_insert::handle_inserts(void) max_rows= 0; // For DBUG output #endif /* Remove all not used rows */ + mysql_mutex_lock(&mutex); while ((row=rows.get())) { if (table->s->blob_fields) @@ -3354,7 +3355,6 @@ bool Delayed_insert::handle_inserts(void) } DBUG_PRINT("error", ("dropped %lu rows after an error", max_rows)); thread_safe_increment(delayed_insert_errors, &LOCK_delayed_status); - mysql_mutex_lock(&mutex); DBUG_RETURN(1); } #endif /* EMBEDDED_LIBRARY */ @@ -3924,11 +3924,11 @@ void select_insert::abort_result_set() { CREATE TABLE (SELECT) ... ***************************************************************************/ -Field *Item::create_field_for_create_select(THD *thd, TABLE *table) +Field *Item::create_field_for_create_select(TABLE *table) { Field *def_field, *tmp_field; - return create_tmp_field(thd, table, this, type(), - (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0); + return ::create_tmp_field(table->in_use, table, this, type(), + (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0); } @@ -4002,7 +4002,7 @@ static TABLE *create_table_from_items(THD *thd, while ((item=it++)) { - Field *tmp_field= item->create_field_for_create_select(thd, &tmp_table); + Field *tmp_field= item->create_field_for_create_select(&tmp_table); if (!tmp_field) DBUG_RETURN(NULL); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 31fc5f9712c..b62838f46f2 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1697,32 +1697,35 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd) return (BIN_NUM); case MY_LEX_CMP_OP: // Incomplete comparison operator + lip->next_state= MY_LEX_START; // Allow signed numbers if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP || state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP) - lip->yySkip(); - if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0))) { - lip->next_state= MY_LEX_START; // Allow signed numbers - return(tokval); + lip->yySkip(); + if ((tokval= find_keyword(lip, 2, 0))) + return(tokval); + lip->yyUnget(); } - state = MY_LEX_CHAR; // Something fishy found - break; + return(c); case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator + lip->next_state= MY_LEX_START; if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP || state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP) { lip->yySkip(); if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP) + { lip->yySkip(); + if ((tokval= find_keyword(lip, 3, 0))) + return(tokval); + lip->yyUnget(); + } + if ((tokval= find_keyword(lip, 2, 0))) + return(tokval); + lip->yyUnget(); } - if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0))) - { - lip->next_state= MY_LEX_START; // Found long op - return(tokval); - } - state = MY_LEX_CHAR; // Something fishy found - break; + return(c); case MY_LEX_BOOL: if (c != lip->yyPeek()) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 4e6d91b9c1f..c2c97a37633 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1387,7 +1387,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, set_if_bigger(length,line_start.length()); stack=stack_pos=(int*) sql_alloc(sizeof(int)*length); - if (!(buffer=(uchar*) my_malloc(buff_length+1,MYF(MY_THREAD_SPECIFIC)))) + if (!(buffer=(uchar*) my_malloc(buff_length+1,MYF(MY_WME | MY_THREAD_SPECIFIC)))) error=1; /* purecov: inspected */ else { @@ -1573,37 +1573,50 @@ int READ_INFO::read_field() } } #ifdef USE_MB - if (my_mbcharlen(read_charset, chr) > 1 && - to + my_mbcharlen(read_charset, chr) <= end_of_buff) - { - uchar* p= to; - int ml, i; - *to++ = chr; - - ml= my_mbcharlen(read_charset, chr); - - for (i= 1; i < ml; i++) + uint ml= my_mbcharlen(read_charset, chr); + if (ml == 0) { - chr= GET; - if (chr == my_b_EOF) - { - /* - Need to back up the bytes already ready from illformed - multi-byte char - */ - to-= i; - goto found_eof; - } - *to++ = chr; + *to= '\0'; + my_error(ER_INVALID_CHARACTER_STRING, MYF(0), + read_charset->csname, buffer); + error= true; + return 1; } - if (my_ismbchar(read_charset, + + if (ml > 1 && + to + ml <= end_of_buff) + { + uchar* p= to; + *to++ = chr; + + for (uint 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 + */ + to-= i; + goto found_eof; + } + *to++ = chr; + } + if (my_ismbchar(read_charset, (const char *)p, (const char *)to)) - continue; - for (i= 0; i < ml; i++) - PUSH(*--to); - chr= GET; - } + continue; + for (uint i= 0; i < ml; i++) + PUSH(*--to); + chr= GET; + } + else if (ml > 1) + { + // Buffer is too small, exit while loop, and reallocate. + PUSH(chr); + break; + } #endif *to++ = (uchar) chr; } @@ -1847,7 +1860,15 @@ int READ_INFO::read_value(int delim, String *val) for (chr= GET; my_tospace(chr) != delim && chr != my_b_EOF;) { #ifdef USE_MB - if (my_mbcharlen(read_charset, chr) > 1) + uint ml= my_mbcharlen(read_charset, chr); + if (ml == 0) + { + chr= my_b_EOF; + val->length(0); + return chr; + } + + if (ml > 1) { DBUG_PRINT("read_xml",("multi byte")); int i, ml= my_mbcharlen(read_charset, chr); diff --git a/sql/sql_locale.h b/sql/sql_locale.h index 8357a9ecba4..8559bb55cd9 100644 --- a/sql/sql_locale.h +++ b/sql/sql_locale.h @@ -61,6 +61,8 @@ public: grouping(grouping_par), errmsgs(errmsgs_par) {} + uint repertoire() const + { return is_ascii ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_EXTENDED; } }; /* Exported variables */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3c0bf523c2c..a15f3da8e12 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -529,6 +529,7 @@ void init_update_queries(void) sql_command_flags[SQLCOM_INSERT_SELECT]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_DELETE]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_DELETE_MULTI]|= CF_PREOPEN_TMP_TABLES; + sql_command_flags[SQLCOM_RENAME_TABLE]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_REPLACE_SELECT]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_SELECT]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_SET_OPTION]|= CF_PREOPEN_TMP_TABLES; @@ -6793,6 +6794,7 @@ bool check_stack_overrun(THD *thd, long margin, if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >= (long) (my_thread_stack_size - margin)) { + thd->is_fatal_error= 1; /* Do not use stack for the message buffer to ensure correct behaviour in cases we have close to no stack left. @@ -6881,10 +6883,13 @@ void THD::reset_for_next_command() /* Autoinc variables should be adjusted only for locally executed transactions. Appliers and replayers are either processing ROW - events or get autoinc variable values from Query_log_event. + events or get autoinc variable values from Query_log_event and + mysql slave may be processing STATEMENT format events, but he should + use autoinc values passed in binlog events, not the values forced by + the cluster. */ if (WSREP(thd) && thd->wsrep_exec_mode == LOCAL_STATE && - wsrep_auto_increment_control) + !thd->slave_thread && wsrep_auto_increment_control) { thd->variables.auto_increment_offset= global_system_variables.auto_increment_offset; @@ -7293,10 +7298,9 @@ void mysql_parse(THD *thd, char *rawbuf, uint length, Note that we don't need LOCK_thread_count to modify query_length. */ if (found_semicolon && (ulong) (found_semicolon - thd->query())) - thd->set_query_inner(thd->query(), - (uint32) (found_semicolon - - thd->query() - 1), - thd->charset()); + thd->set_query(thd->query(), + (uint32) (found_semicolon - thd->query() - 1), + thd->charset()); /* Actually execute the query */ if (found_semicolon) { diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 0158ab7d206..60248f3fef4 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -2955,6 +2955,70 @@ static st_bookmark *register_var(const char *plugin, const char *name, return result; } + +void sync_dynamic_session_variables(THD* thd, bool global_lock) +{ + uint idx; + + thd->variables.dynamic_variables_ptr= (char*) + my_realloc(thd->variables.dynamic_variables_ptr, + global_variables_dynamic_size, + MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); + + if (global_lock) + mysql_mutex_lock(&LOCK_global_system_variables); + + mysql_mutex_assert_owner(&LOCK_global_system_variables); + + memcpy(thd->variables.dynamic_variables_ptr + + thd->variables.dynamic_variables_size, + global_system_variables.dynamic_variables_ptr + + thd->variables.dynamic_variables_size, + global_system_variables.dynamic_variables_size - + thd->variables.dynamic_variables_size); + + /* + now we need to iterate through any newly copied 'defaults' + and if it is a string type with MEMALLOC flag, we need to strdup + */ + for (idx= 0; idx < bookmark_hash.records; idx++) + { + sys_var_pluginvar *pi; + sys_var *var; + st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx); + + if (v->version <= thd->variables.dynamic_variables_version) + continue; /* already in thd->variables */ + + if (!(var= intern_find_sys_var(v->key + 1, v->name_len)) || + !(pi= var->cast_pluginvar()) || + v->key[0] != plugin_var_bookmark_key(pi->plugin_var->flags)) + continue; + + /* Here we do anything special that may be required of the data types */ + + if ((pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && + pi->plugin_var->flags & PLUGIN_VAR_MEMALLOC) + { + int offset= ((thdvar_str_t *)(pi->plugin_var))->offset; + char **pp= (char**) (thd->variables.dynamic_variables_ptr + offset); + if (*pp) + *pp= my_strdup(*pp, MYF(MY_WME|MY_FAE)); + } + } + + if (global_lock) + mysql_mutex_unlock(&LOCK_global_system_variables); + + thd->variables.dynamic_variables_version= + global_system_variables.dynamic_variables_version; + thd->variables.dynamic_variables_head= + global_system_variables.dynamic_variables_head; + thd->variables.dynamic_variables_size= + global_system_variables.dynamic_variables_size; +} + + /* returns a pointer to the memory which holds the thd-local variable or a pointer to the global variable if thd==null. @@ -2976,67 +3040,8 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) if (!thd->variables.dynamic_variables_ptr || (uint)offset > thd->variables.dynamic_variables_head) { - uint idx; - mysql_rwlock_rdlock(&LOCK_system_variables_hash); - - thd->variables.dynamic_variables_ptr= (char*) - my_realloc(thd->variables.dynamic_variables_ptr, - global_variables_dynamic_size, - MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); - - if (global_lock) - mysql_mutex_lock(&LOCK_global_system_variables); - - mysql_mutex_assert_owner(&LOCK_global_system_variables); - - memcpy(thd->variables.dynamic_variables_ptr + - thd->variables.dynamic_variables_size, - global_system_variables.dynamic_variables_ptr + - thd->variables.dynamic_variables_size, - global_system_variables.dynamic_variables_size - - thd->variables.dynamic_variables_size); - - /* - now we need to iterate through any newly copied 'defaults' - and if it is a string type with MEMALLOC flag, we need to strdup - */ - for (idx= 0; idx < bookmark_hash.records; idx++) - { - sys_var_pluginvar *pi; - sys_var *var; - st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx); - - if (v->version <= thd->variables.dynamic_variables_version) - continue; /* already in thd->variables */ - - if (!(var= intern_find_sys_var(v->key + 1, v->name_len)) || - !(pi= var->cast_pluginvar()) || - v->key[0] != plugin_var_bookmark_key(pi->plugin_var->flags)) - continue; - - /* Here we do anything special that may be required of the data types */ - - if ((pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && - pi->plugin_var->flags & PLUGIN_VAR_MEMALLOC) - { - int offset= ((thdvar_str_t *)(pi->plugin_var))->offset; - char **pp= (char**) (thd->variables.dynamic_variables_ptr + offset); - if (*pp) - *pp= my_strdup(*pp, MYF(MY_WME|MY_FAE)); - } - } - - if (global_lock) - mysql_mutex_unlock(&LOCK_global_system_variables); - - thd->variables.dynamic_variables_version= - global_system_variables.dynamic_variables_version; - thd->variables.dynamic_variables_head= - global_system_variables.dynamic_variables_head; - thd->variables.dynamic_variables_size= - global_system_variables.dynamic_variables_size; - + sync_dynamic_session_variables(thd, global_lock); mysql_rwlock_unlock(&LOCK_system_variables_hash); } DBUG_RETURN((uchar*)thd->variables.dynamic_variables_ptr + offset); @@ -3570,6 +3575,7 @@ void plugin_opt_set_limits(struct my_option *options, case PLUGIN_VAR_BOOL: options->var_type= GET_BOOL; options->def_value= ((sysvar_bool_t*) opt)->def_val; + options->typelib= &bool_typelib; break; case PLUGIN_VAR_STR: options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ? @@ -3618,6 +3624,7 @@ void plugin_opt_set_limits(struct my_option *options, case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL: options->var_type= GET_BOOL; options->def_value= ((thdvar_bool_t*) opt)->def_val; + options->typelib= &bool_typelib; break; case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL: options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ? diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 2bfdcb29dfc..77ec24bbe9c 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -152,7 +152,7 @@ typedef int (*plugin_type_init)(struct st_plugin_int *); extern I_List *opt_plugin_load_list_ptr; extern char *opt_plugin_dir_ptr; -extern char opt_plugin_dir[FN_REFLEN]; +extern MYSQL_PLUGIN_IMPORT char opt_plugin_dir[FN_REFLEN]; extern const LEX_STRING plugin_type_names[]; extern ulong plugin_maturity; extern TYPELIB plugin_maturity_values; @@ -187,7 +187,10 @@ typedef my_bool (plugin_foreach_func)(THD *thd, #define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D) extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, int type, uint state_mask, void *arg); +extern void sync_dynamic_session_variables(THD* thd, bool global_lock); + extern bool plugin_dl_foreach(THD *thd, const LEX_STRING *dl, plugin_foreach_func *func, void *arg); +extern void sync_dynamic_session_variables(THD* thd, bool global_lock); #endif diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 089f60a2dd8..e361ed8b6e6 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. + Copyright (c) 2011, 2016, MariaDB 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 @@ -154,6 +155,12 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, { if (mysql_bin_log.rotate_and_purge(true)) *write_to_binlog= -1; + + if (WSREP_ON) + { + /* Wait for last binlog checkpoint event to be logged. */ + mysql_bin_log.wait_for_last_checkpoint_event(); + } } } if (options & REFRESH_RELAY_LOG) diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 17b297f63bd..35222bce949 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -24,7 +24,7 @@ #include "unireg.h" #include "sql_rename.h" #include "sql_cache.h" // query_cache_* -#include "sql_table.h" // build_table_filename +#include "sql_table.h" // write_bin_log #include "sql_view.h" // mysql_frm_type, mysql_rename_view #include "sql_trigger.h" #include "lock.h" // MYSQL_OPEN_SKIP_TEMPORARY @@ -212,6 +212,28 @@ static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list) } +static bool +do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table, + bool skip_error) +{ + const char *new_alias; + DBUG_ENTER("do_rename_temporary"); + + new_alias= (lower_case_table_names == 2) ? new_table->alias : + new_table->table_name; + + if (is_temporary_table(new_table)) + { + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); + DBUG_RETURN(1); // This can't be skipped + } + + + DBUG_RETURN(rename_temporary_table(thd, ren_table->table, + new_table->db, new_alias)); +} + + /* Rename a single table or a view @@ -317,6 +339,8 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, DBUG_RETURN(0); } + + /* Rename all tables in list; Return pointer to wrong entry if something goes wrong. Note that the table_list may be empty! @@ -351,8 +375,11 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) for (ren_table= table_list; ren_table; ren_table= new_table->next_local) { new_table= ren_table->next_local; - if (do_rename(thd, ren_table, new_table->db, new_table->table_name, - new_table->alias, skip_error)) + + if (is_temporary_table(ren_table) ? + do_rename_temporary(thd, ren_table, new_table, skip_error) : + do_rename(thd, ren_table, new_table->db, new_table->table_name, + new_table->alias, skip_error)) DBUG_RETURN(ren_table); } DBUG_RETURN(0); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 48257265a6a..5dc50c92104 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -694,7 +694,7 @@ JOIN::prepare(Item ***rref_pointer_array, DBUG_ENTER("JOIN::prepare"); // to prevent double initialization on EXPLAIN - if (optimized) + if (optimization_state != JOIN::NOT_OPTIMIZED) DBUG_RETURN(0); conds= conds_init; @@ -1032,24 +1032,13 @@ err: int JOIN::optimize() { - bool was_optimized= optimized; + // to prevent double initialization on EXPLAIN + if (optimization_state != JOIN::NOT_OPTIMIZED) + return FALSE; + optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS; + int res= optimize_inner(); - /* - If we're inside a non-correlated subquery, this function may be - called for the second time after the subquery has been executed - and deleted. The second call will not produce a valid query plan, it will - short-circuit because optimized==TRUE. - - "was_optimized != optimized" is here to handle this case: - - first optimization starts, gets an error (from a const. cheap - subquery), returns 1 - - another JOIN::optimize() call made, and now join->optimize() will - return 0, even though we never had a query plan. - - Can have QEP_NOT_PRESENT_YET for degenerate queries (for example, - SELECT * FROM tbl LIMIT 0) - */ - if (was_optimized != optimized && !res && have_query_plan != QEP_DELETED) + if (!res && have_query_plan != QEP_DELETED) { create_explain_query_if_not_exists(thd->lex, thd->mem_root); have_query_plan= QEP_AVAILABLE; @@ -1058,6 +1047,7 @@ int JOIN::optimize() !skip_sort_order && !no_order && (order || group_list), select_distinct); } + optimization_state= JOIN::OPTIMIZATION_DONE; return res; } @@ -1083,10 +1073,7 @@ JOIN::optimize_inner() DBUG_ENTER("JOIN::optimize"); do_send_rows = (unit->select_limit_cnt) ? 1 : 0; - // to prevent double initialization on EXPLAIN - if (optimized) - DBUG_RETURN(0); - optimized= 1; + DEBUG_SYNC(thd, "before_join_optimize"); THD_STAGE_INFO(thd, stage_optimizing); @@ -2060,7 +2047,7 @@ int JOIN::init_execution() { DBUG_ENTER("JOIN::init_execution"); - DBUG_ASSERT(optimized); + DBUG_ASSERT(optimization_state == JOIN::OPTIMIZATION_DONE); DBUG_ASSERT(!(select_options & SELECT_DESCRIBE)); initialized= true; @@ -15837,6 +15824,60 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field, return new_field; } + +Field *Item::create_tmp_field(bool group, TABLE *table, uint convert_int_length) +{ + Field *UNINIT_VAR(new_field); + MEM_ROOT *mem_root= table->in_use->mem_root; + + switch (cmp_type()) { + case REAL_RESULT: + new_field= new (mem_root) + Field_double(max_length, maybe_null, name, decimals, TRUE); + break; + case INT_RESULT: + /* + Select an integer type with the minimal fit precision. + convert_int_length is sign inclusive, don't consider the sign. + */ + if (max_char_length() > convert_int_length) + new_field= new (mem_root) + Field_longlong(max_char_length(), maybe_null, name, unsigned_flag); + else + new_field= new (mem_root) + Field_long(max_char_length(), maybe_null, name, unsigned_flag); + break; + case TIME_RESULT: + new_field= tmp_table_field_from_field_type(table, true, false); + break; + case STRING_RESULT: + DBUG_ASSERT(collation.collation); + /* + GEOMETRY fields have STRING_RESULT result type. + To preserve type they needed to be handled separately. + */ + if (field_type() == MYSQL_TYPE_GEOMETRY) + new_field= tmp_table_field_from_field_type(table, true, false); + else + new_field= make_string_field(table); + new_field->set_derivation(collation.derivation, collation.repertoire); + break; + case DECIMAL_RESULT: + new_field= Field_new_decimal::create_from_item(mem_root, this); + break; + case ROW_RESULT: + // This case should never be choosen + DBUG_ASSERT(0); + new_field= 0; + break; + } + if (new_field) + new_field->init(table); + return new_field; +} + + + /** Create field for temporary table using type of given item. @@ -15862,57 +15903,9 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field, static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, Item ***copy_func, bool modify_item) { - bool maybe_null= item->maybe_null; Field *UNINIT_VAR(new_field); - MEM_ROOT *mem_root= thd->mem_root; - - /* - To preserve type or DATE/TIME and GEOMETRY fields, - they need to be handled separately. - */ - if (item->cmp_type() == TIME_RESULT || - item->field_type() == MYSQL_TYPE_GEOMETRY) - new_field= item->tmp_table_field_from_field_type(table, true, false); - else - switch (item->result_type()) { - case REAL_RESULT: - new_field= new (mem_root) - Field_double(item->max_length, maybe_null, - item->name, item->decimals, TRUE); - break; - case INT_RESULT: - /* - Select an integer type with the minimal fit precision. - MY_INT32_NUM_DECIMAL_DIGITS is sign inclusive, don't consider the sign. - Values with MY_INT32_NUM_DECIMAL_DIGITS digits may or may not fit into - Field_long : make them Field_longlong. - */ - if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1)) - new_field=new (mem_root) - Field_longlong(item->max_length, maybe_null, - item->name, item->unsigned_flag); - else - new_field=new (mem_root) - Field_long(item->max_length, maybe_null, item->name, - item->unsigned_flag); - break; - case STRING_RESULT: - DBUG_ASSERT(item->collation.collation); - new_field= item->make_string_field(table); - new_field->set_derivation(item->collation.derivation); - break; - case DECIMAL_RESULT: - new_field= Field_new_decimal::create_from_item(mem_root, item); - break; - case ROW_RESULT: - default: - // This case should never be choosen - DBUG_ASSERT(0); - new_field= 0; - break; - } - if (new_field) - new_field->init(table); + DBUG_ASSERT(thd == table->in_use); + new_field= item->Item::create_tmp_field(false, table); if (copy_func && item->real_item()->is_result_field()) *((*copy_func)++) = item; // Save for copy_funcs @@ -16004,8 +15997,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, switch (type) { case Item::SUM_FUNC_ITEM: { - Item_sum *item_sum=(Item_sum*) item; - result= item_sum->create_tmp_field(group, table); + result= item->create_tmp_field(group, table); if (!result) my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR)); return result; @@ -16132,7 +16124,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, modify_item); case Item::TYPE_HOLDER: result= ((Item_type_holder *)item)->make_field_by_type(table); - result->set_derivation(item->collation.derivation); + result->set_derivation(item->collation.derivation, + item->collation.repertoire); return result; default: // Dosen't have to be stored return 0; diff --git a/sql/sql_select.h b/sql/sql_select.h index 89ee63e87b0..dfa96f1c81c 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1290,7 +1290,8 @@ public: enum join_optimization_state { NOT_OPTIMIZED=0, OPTIMIZATION_IN_PROGRESS=1, OPTIMIZATION_DONE=2}; - bool optimized; ///< flag to avoid double optimization in EXPLAIN + // state of JOIN optimization + enum join_optimization_state optimization_state; bool initialized; ///< flag to avoid double init_execution calls Explain_select *explain; @@ -1378,7 +1379,7 @@ public: ref_pointer_array= items0= items1= items2= items3= 0; ref_pointer_array_size= 0; zero_result_cause= 0; - optimized= 0; + optimization_state= JOIN::NOT_OPTIMIZED; have_query_plan= QEP_NOT_PRESENT_YET; initialized= 0; cleaned= 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1cbad7e9ea0..ae3874506dd 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -816,12 +816,24 @@ ignore_db_dirs_process_additions() for (i= 0; i < ignore_db_dirs_array.elements; i++) { get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i); - if (my_hash_insert(&ignore_db_dirs_hash, (uchar *) dir)) - return true; - ptr= strnmov(ptr, dir->str, dir->length); - if (i + 1 < ignore_db_dirs_array.elements) - ptr= strmov(ptr, ","); + if (my_hash_insert(&ignore_db_dirs_hash, (uchar *)dir)) + { + /* ignore duplicates from the config file */ + if (my_hash_search(&ignore_db_dirs_hash, (uchar *)dir->str, dir->length)) + { + sql_print_warning("Duplicate ignore-db-dir directory name '%.*s' " + "found in the config file(s). Ignoring the duplicate.", + (int) dir->length, dir->str); + my_free(dir); + goto continue_loop; + } + return true; + } + ptr= strnmov(ptr, dir->str, dir->length); + *(ptr++)= ','; + +continue_loop: /* Set the transferred array element to NULL to avoid double free in case of error. @@ -830,6 +842,12 @@ ignore_db_dirs_process_additions() set_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i); } + if (ptr > opt_ignore_db_dirs) + { + ptr--; + DBUG_ASSERT(*ptr == ','); + } + /* make sure the string is terminated */ DBUG_ASSERT(ptr - opt_ignore_db_dirs <= (ptrdiff_t) len); *ptr= 0; @@ -7191,6 +7209,17 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) COND *partial_cond= make_cond_for_info_schema(thd, cond, tables); mysql_rwlock_rdlock(&LOCK_system_variables_hash); + + /* + Avoid recursive LOCK_system_variables_hash acquisition in + intern_sys_var_ptr() by pre-syncing dynamic session variables. + */ + if (scope == OPT_SESSION && + (!thd->variables.dynamic_variables_ptr || + global_system_variables.dynamic_variables_head > + thd->variables.dynamic_variables_head)) + sync_dynamic_session_variables(thd, true); + res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars, scope), scope, NULL, "", tables->table, upper_case_names, partial_cond); diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 28e76ae43f1..4020cbc70c4 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -29,6 +29,7 @@ #include "sql_statistics.h" #include "opt_range.h" #include "my_atomic.h" +#include "sql_show.h" /* The system variable 'use_stat_tables' can take one of the @@ -3193,6 +3194,10 @@ int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab) rc= 1; } + err= del_global_table_stat(thd, db, tab); + if (err & !rc) + rc= 1; + thd->restore_stmt_binlog_format(save_binlog_format); close_system_tables(thd, &open_tables_backup); @@ -3339,6 +3344,10 @@ int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info, } } + err= del_global_index_stat(thd, tab, key_info); + if (err && !rc) + rc= 1; + thd->restore_stmt_binlog_format(save_binlog_format); close_system_tables(thd, &open_tables_backup); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dae3b7ad827..2e639f3d072 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2687,14 +2687,15 @@ bool log_drop_table(THD *thd, const char *db_name, size_t db_name_length, */ bool quick_rm_table(THD *thd, handlerton *base, const char *db, - const char *table_name, uint flags) + const char *table_name, uint flags, const char *table_path) { char path[FN_REFLEN + 1]; bool error= 0; DBUG_ENTER("quick_rm_table"); - uint path_length= build_table_filename(path, sizeof(path) - 1, - db, table_name, reg_ext, flags); + uint path_length= table_path ? + (strxnmov(path, sizeof(path) - 1, table_path, reg_ext, NullS) - path) : + build_table_filename(path, sizeof(path)-1, db, table_name, reg_ext, flags); if (mysql_file_delete(key_file_frm, path, MYF(0))) error= 1; /* purecov: inspected */ path[path_length - reg_ext_length]= '\0'; // Remove reg_ext @@ -9254,7 +9255,8 @@ err_new_table_cleanup: else (void) quick_rm_table(thd, new_db_type, alter_ctx.new_db, alter_ctx.tmp_name, - (FN_IS_TMP | (no_ha_table ? NO_HA_TABLE : 0))); + (FN_IS_TMP | (no_ha_table ? NO_HA_TABLE : 0)), + alter_ctx.get_tmp_path()); /* No default value was provided for a DATE/DATETIME field, the diff --git a/sql/sql_table.h b/sql/sql_table.h index a8124177840..474fe9cd90b 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -247,7 +247,8 @@ bool log_drop_table(THD *thd, const char *db_name, size_t db_name_length, const char *table_name, size_t table_name_length, bool temporary_table); bool quick_rm_table(THD *thd, handlerton *base, const char *db, - const char *table_name, uint flags); + const char *table_name, uint flags, + const char *table_path=0); void close_cached_table(THD *thd, TABLE *table); void sp_prepare_create_field(THD *thd, Create_field *sql_field); int prepare_create_field(Create_field *sql_field, diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 8145cec5f25..2086d1d6c03 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1043,6 +1043,12 @@ bool st_select_lex_unit::cleanup() join->tables_list= 0; join->table_count= 0; join->top_join_tab_count= 0; + if (join->tmp_join && join->tmp_join != join) + { + join->tmp_join->tables_list= 0; + join->tmp_join->table_count= 0; + join->tmp_join->top_join_tab_count= 0; + } } error|= fake_select_lex->cleanup(); /* diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4221025da28..04aea060543 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -534,6 +534,9 @@ int mysql_update(THD *thd, DBUG_EXECUTE_IF("show_explain_probe_update_exec_start", dbug_serve_apcs(thd, 1);); + if (!(select && select->quick)) + status_var_increment(thd->status_var.update_scan_count); + if (query_plan.using_filesort || query_plan.using_io_buffer) { /* @@ -604,6 +607,7 @@ int mysql_update(THD *thd, close_cached_file(&tempfile); goto err; } + table->file->try_semi_consistent_read(1); /* @@ -642,7 +646,7 @@ int mysql_update(THD *thd, thd->inc_examined_row_count(1); if (!select || (error= select->skip_record(thd)) > 0) { - if (table->file->was_semi_consistent_read()) + if (table->file->ha_was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ explain->buf_tracker.on_record_after_where(); @@ -760,7 +764,7 @@ int mysql_update(THD *thd, thd->inc_examined_row_count(1); if (!select || select->skip_record(thd) > 0) { - if (table->file->was_semi_consistent_read()) + if (table->file->ha_was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ explain->tracker.on_record_after_where(); @@ -1612,7 +1616,7 @@ bool mysql_multi_update(THD *thd, DBUG_RETURN(TRUE); } - thd->abort_on_warning= thd->is_strict_mode(); + thd->abort_on_warning= !ignore && thd->is_strict_mode(); List total_list; res= mysql_select(thd, &select_lex->ref_pointer_array, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e614692bd70..9131b99d95e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2016, MariaDB 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 @@ -1212,7 +1212,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ENGINES_SYM %token ENGINE_SYM %token ENUM -%token EQ /* OPERATOR */ %token EQUAL_SYM /* OPERATOR */ %token ERROR_SYM %token ERRORS @@ -1262,7 +1261,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token GRANTS %token GROUP_SYM /* SQL-2003-R */ %token GROUP_CONCAT_SYM -%token GT_SYM /* OPERATOR */ %token HANDLER_SYM %token HARD_SYM %token HASH_SYM @@ -1342,7 +1340,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token LONG_SYM %token LOOP_SYM %token LOW_PRIORITY -%token LT /* OPERATOR */ %token MASTER_CONNECT_RETRY_SYM %token MASTER_GTID_POS_SYM %token MASTER_HOST_SYM @@ -1702,7 +1699,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %left XOR %left AND_SYM AND_AND_SYM %left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE -%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM +%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM %left '|' %left '&' %left SHIFT_LEFT SHIFT_RIGHT @@ -2238,66 +2235,66 @@ master_defs: ; master_def: - MASTER_HOST_SYM EQ TEXT_STRING_sys + MASTER_HOST_SYM '=' TEXT_STRING_sys { Lex->mi.host = $3.str; } - | MASTER_USER_SYM EQ TEXT_STRING_sys + | MASTER_USER_SYM '=' TEXT_STRING_sys { Lex->mi.user = $3.str; } - | MASTER_PASSWORD_SYM EQ TEXT_STRING_sys + | MASTER_PASSWORD_SYM '=' TEXT_STRING_sys { Lex->mi.password = $3.str; } - | MASTER_PORT_SYM EQ ulong_num + | MASTER_PORT_SYM '=' ulong_num { Lex->mi.port = $3; } - | MASTER_CONNECT_RETRY_SYM EQ ulong_num + | MASTER_CONNECT_RETRY_SYM '=' ulong_num { Lex->mi.connect_retry = $3; } - | MASTER_SSL_SYM EQ ulong_num + | MASTER_SSL_SYM '=' ulong_num { Lex->mi.ssl= $3 ? LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE; } - | MASTER_SSL_CA_SYM EQ TEXT_STRING_sys + | MASTER_SSL_CA_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_ca= $3.str; } - | MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys + | MASTER_SSL_CAPATH_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_capath= $3.str; } - | MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys + | MASTER_SSL_CERT_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_cert= $3.str; } - | MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys + | MASTER_SSL_CIPHER_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_cipher= $3.str; } - | MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys + | MASTER_SSL_KEY_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_key= $3.str; } - | MASTER_SSL_VERIFY_SERVER_CERT_SYM EQ ulong_num + | MASTER_SSL_VERIFY_SERVER_CERT_SYM '=' ulong_num { Lex->mi.ssl_verify_server_cert= $3 ? LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE; } - | MASTER_SSL_CRL_SYM EQ TEXT_STRING_sys + | MASTER_SSL_CRL_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_crl= $3.str; } - | MASTER_SSL_CRLPATH_SYM EQ TEXT_STRING_sys + | MASTER_SSL_CRLPATH_SYM '=' TEXT_STRING_sys { Lex->mi.ssl_crlpath= $3.str; } - | MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal + | MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal { Lex->mi.heartbeat_period= (float) $3->val_real(); if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD || @@ -2324,15 +2321,15 @@ master_def: } Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE; } - | IGNORE_SERVER_IDS_SYM EQ '(' ignore_server_id_list ')' + | IGNORE_SERVER_IDS_SYM '=' '(' ignore_server_id_list ')' { Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE; } - | DO_DOMAIN_IDS_SYM EQ '(' do_domain_id_list ')' + | DO_DOMAIN_IDS_SYM '=' '(' do_domain_id_list ')' { Lex->mi.repl_do_domain_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE; } - | IGNORE_DOMAIN_IDS_SYM EQ '(' ignore_domain_id_list ')' + | IGNORE_DOMAIN_IDS_SYM '=' '(' ignore_domain_id_list ')' { Lex->mi.repl_ignore_domain_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE; } @@ -2380,11 +2377,11 @@ ignore_domain_id: ; master_file_def: - MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys + MASTER_LOG_FILE_SYM '=' TEXT_STRING_sys { Lex->mi.log_file_name = $3.str; } - | MASTER_LOG_POS_SYM EQ ulonglong_num + | MASTER_LOG_POS_SYM '=' ulonglong_num { /* If the user specified a value < BIN_LOG_HEADER_SIZE, adjust it @@ -2399,29 +2396,29 @@ master_file_def: */ Lex->mi.pos= MY_MAX(BIN_LOG_HEADER_SIZE, $3); } - | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys + | RELAY_LOG_FILE_SYM '=' TEXT_STRING_sys { Lex->mi.relay_log_name = $3.str; } - | RELAY_LOG_POS_SYM EQ ulong_num + | RELAY_LOG_POS_SYM '=' ulong_num { Lex->mi.relay_log_pos = $3; /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */ Lex->mi.relay_log_pos= MY_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos); } - | MASTER_USE_GTID_SYM EQ CURRENT_POS_SYM + | MASTER_USE_GTID_SYM '=' CURRENT_POS_SYM { if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid")); Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_CURRENT_POS; } - | MASTER_USE_GTID_SYM EQ SLAVE_POS_SYM + | MASTER_USE_GTID_SYM '=' SLAVE_POS_SYM { if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid")); Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_SLAVE_POS; } - | MASTER_USE_GTID_SYM EQ NO_SYM + | MASTER_USE_GTID_SYM '=' NO_SYM { if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid")); @@ -3325,7 +3322,7 @@ opt_set_signal_information: ; signal_information_item_list: - signal_condition_information_item_name EQ signal_allowed_expr + signal_condition_information_item_name '=' signal_allowed_expr { Set_signal_information *info; info= &thd->m_parser_state->m_yacc.m_set_signal_info; @@ -3334,7 +3331,7 @@ signal_information_item_list: info->m_item[index]= $3; } | signal_information_item_list ',' - signal_condition_information_item_name EQ signal_allowed_expr + signal_condition_information_item_name '=' signal_allowed_expr { Set_signal_information *info; info= &thd->m_parser_state->m_yacc.m_set_signal_info; @@ -3470,7 +3467,7 @@ statement_information: ; statement_information_item: - simple_target_specification EQ statement_information_item_name + simple_target_specification '=' statement_information_item_name { $$= new (thd->mem_root) Statement_information_item($3, $1); if ($$ == NULL) @@ -3527,7 +3524,7 @@ condition_information: ; condition_information_item: - simple_target_specification EQ condition_information_item_name + simple_target_specification '=' condition_information_item_name { $$= new (thd->mem_root) Condition_information_item($3, $1); if ($$ == NULL) @@ -4872,7 +4869,7 @@ opt_linear: opt_key_algo: /* empty */ { Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;} - | ALGORITHM_SYM EQ real_ulong_num + | ALGORITHM_SYM '=' real_ulong_num { switch ($3) { case 1: @@ -6332,7 +6329,7 @@ srid_option: /* empty */ { Lex->last_field->srid= 0; } | - REF_SYSTEM_ID_SYM EQ NUM + REF_SYSTEM_ID_SYM '=' NUM { Lex->last_field->srid=atoi($3.str); } @@ -7644,7 +7641,7 @@ opt_place: opt_to: /* empty */ {} | TO_SYM {} - | EQ {} + | '=' {} | AS {} ; @@ -7762,7 +7759,7 @@ slave_until: (lex->mi.relay_log_name && lex->mi.relay_log_pos))) my_yyabort_error((ER_BAD_SLAVE_UNTIL_COND, MYF(0))); } - | UNTIL_SYM MASTER_GTID_POS_SYM EQ TEXT_STRING_sys + | UNTIL_SYM MASTER_GTID_POS_SYM '=' TEXT_STRING_sys { Lex->mi.gtid_pos_str = $4; } @@ -8657,13 +8654,13 @@ bool_pri: if ($$ == NULL) MYSQL_YYABORT; } - | bool_pri comp_op predicate %prec EQ + | bool_pri comp_op predicate %prec '=' { $$= (*$2)(0)->create(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } - | bool_pri comp_op all_or_any '(' subselect ')' %prec EQ + | bool_pri comp_op all_or_any '(' subselect ')' %prec '=' { $$= all_any_subquery_creator(thd, $1, $2, $3, $5); if ($$ == NULL) @@ -8887,11 +8884,11 @@ not2: ; comp_op: - EQ { $$ = &comp_eq_creator; } + '=' { $$ = &comp_eq_creator; } | GE { $$ = &comp_ge_creator; } - | GT_SYM { $$ = &comp_gt_creator; } + | '>' { $$ = &comp_gt_creator; } | LE { $$ = &comp_le_creator; } - | LT { $$ = &comp_lt_creator; } + | '<' { $$ = &comp_lt_creator; } | NE { $$ = &comp_ne_creator; } ; @@ -10984,7 +10981,7 @@ date_time_type: table_alias: /* empty */ | AS - | EQ + | '=' ; opt_table_alias: @@ -11897,7 +11894,7 @@ ident_eq_value: ; equal: - EQ {} + '=' {} | SET_VAR {} ; @@ -12663,7 +12660,7 @@ opt_extended_describe: opt_format_json: /* empty */ {} - | FORMAT_SYM EQ ident_or_text + | FORMAT_SYM '=' ident_or_text { if (!my_strcasecmp(system_charset_info, $3.str, "JSON")) Lex->explain_json= true; @@ -14926,11 +14923,11 @@ handler_rkey_function: ; handler_rkey_mode: - EQ { $$=HA_READ_KEY_EXACT; } + '=' { $$=HA_READ_KEY_EXACT; } | GE { $$=HA_READ_KEY_OR_NEXT; } | LE { $$=HA_READ_KEY_OR_PREV; } - | GT_SYM { $$=HA_READ_AFTER_KEY; } - | LT { $$=HA_READ_BEFORE_KEY; } + | '>' { $$=HA_READ_AFTER_KEY; } + | '<' { $$=HA_READ_BEFORE_KEY; } ; /* GRANT / REVOKE */ @@ -15769,7 +15766,7 @@ no_definer: ; definer: - DEFINER_SYM EQ user_or_role + DEFINER_SYM '=' user_or_role { Lex->definer= $3; Lex->ssl_type= SSL_TYPE_NOT_SPECIFIED; @@ -15785,11 +15782,11 @@ definer: **************************************************************************/ view_algorithm: - ALGORITHM_SYM EQ UNDEFINED_SYM + ALGORITHM_SYM '=' UNDEFINED_SYM { Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; } - | ALGORITHM_SYM EQ MERGE_SYM + | ALGORITHM_SYM '=' MERGE_SYM { Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; } - | ALGORITHM_SYM EQ TEMPTABLE_SYM + | ALGORITHM_SYM '=' TEMPTABLE_SYM { Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; } ; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 3b043d92d75..306528c5c86 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1597,7 +1597,8 @@ Sys_var_gtid_slave_pos::do_check(THD *thd, set_var *var) } mysql_mutex_lock(&LOCK_active_mi); - running= master_info_index->give_error_if_slave_running(); + running= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); if (running) return true; @@ -1637,7 +1638,7 @@ Sys_var_gtid_slave_pos::global_update(THD *thd, set_var *var) mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_active_mi); - if (master_info_index->give_error_if_slave_running()) + if (!master_info_index || master_info_index->give_error_if_slave_running()) err= true; else err= rpl_gtid_pos_update(thd, var->save_result.string_value.str, @@ -1826,7 +1827,8 @@ check_slave_parallel_threads(sys_var *self, THD *thd, set_var *var) bool running; mysql_mutex_lock(&LOCK_active_mi); - running= master_info_index->give_error_if_slave_running(); + running= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); if (running) return true; @@ -1841,7 +1843,8 @@ fix_slave_parallel_threads(sys_var *self, THD *thd, enum_var_type type) mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_active_mi); - err= master_info_index->give_error_if_slave_running(); + err= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_global_system_variables); @@ -1868,7 +1871,8 @@ check_slave_domain_parallel_threads(sys_var *self, THD *thd, set_var *var) bool running; mysql_mutex_lock(&LOCK_active_mi); - running= master_info_index->give_error_if_slave_running(); + running= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); if (running) return true; @@ -1883,7 +1887,8 @@ fix_slave_domain_parallel_threads(sys_var *self, THD *thd, enum_var_type type) mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_active_mi); - running= master_info_index->give_error_if_slave_running(); + running= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_global_system_variables); @@ -2033,7 +2038,8 @@ check_gtid_ignore_duplicates(sys_var *self, THD *thd, set_var *var) bool running; mysql_mutex_lock(&LOCK_active_mi); - running= master_info_index->give_error_if_slave_running(); + running= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); if (running) return true; @@ -2048,7 +2054,8 @@ fix_gtid_ignore_duplicates(sys_var *self, THD *thd, enum_var_type type) mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_active_mi); - running= master_info_index->give_error_if_slave_running(); + running= (!master_info_index || + master_info_index->give_error_if_slave_running()); mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_global_system_variables); @@ -2962,7 +2969,7 @@ Sys_var_replicate_events_marked_for_skip::global_update(THD *thd, set_var *var) mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_active_mi); - if (!master_info_index->give_error_if_slave_running()) + if (master_info_index && !master_info_index->give_error_if_slave_running()) result= Sys_var_enum::global_update(thd, var); mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_global_system_variables); @@ -3987,14 +3994,16 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var) if (!var->save_result.string_value.str) return true; - if (var->save_result.string_value.length > FN_REFLEN) + LEX_STRING *val= &var->save_result.string_value; + + if (val->length > FN_REFLEN) { // path is too long my_error(ER_PATH_LENGTH, MYF(0), self->name.str); return true; } char path[FN_REFLEN]; - size_t path_length= unpack_filename(path, var->save_result.string_value.str); + size_t path_length= unpack_filename(path, val->str); if (!path_length) return true; @@ -4007,6 +4016,17 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var) return true; } + static const LEX_CSTRING my_cnf= { STRING_WITH_LEN("my.cnf") }; + static const LEX_CSTRING my_ini= { STRING_WITH_LEN("my.ini") }; + if (path_length >= my_cnf.length) + { + if (strcasecmp(path + path_length - my_cnf.length, my_cnf.str) == 0) + return true; // log file name ends with "my.cnf" + DBUG_ASSERT(my_cnf.length == my_ini.length); + if (strcasecmp(path + path_length - my_ini.length, my_ini.str) == 0) + return true; // log file name ends with "my.ini" + } + MY_STAT f_stat; if (my_stat(path, &f_stat, MYF(0))) @@ -4016,9 +4036,9 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var) return false; } - (void) dirname_part(path, var->save_result.string_value.str, &path_length); + (void) dirname_part(path, val->str, &path_length); - if (var->save_result.string_value.length - path_length >= FN_LEN) + if (val->length - path_length >= FN_LEN) { // filename is too long my_error(ER_PATH_LENGTH, MYF(0), self->name.str); return true; @@ -4730,7 +4750,7 @@ static Sys_var_charptr Sys_wsrep_cluster_address ( static Sys_var_charptr Sys_wsrep_node_name ( "wsrep_node_name", "Node name", PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG), - IN_SYSTEM_CHARSET, DEFAULT(""), NO_MUTEX_GUARD, NOT_IN_BINLOG, + IN_SYSTEM_CHARSET, DEFAULT(glob_hostname), NO_MUTEX_GUARD, NOT_IN_BINLOG, wsrep_node_name_check, wsrep_node_name_update); static Sys_var_charptr Sys_wsrep_node_address ( @@ -4782,9 +4802,10 @@ static Sys_var_mybool Sys_wsrep_auto_increment_control( CMD_LINE(OPT_ARG), DEFAULT(TRUE)); static Sys_var_mybool Sys_wsrep_drupal_282555_workaround( - "wsrep_drupal_282555_workaround", "To use a workaround for" - "bad autoincrement value", - GLOBAL_VAR(wsrep_drupal_282555_workaround), + "wsrep_drupal_282555_workaround", "Enable a workaround to handle the " + "cases where inserting a DEFAULT value into an auto-increment column " + "could fail with duplicate key error", + GLOBAL_VAR(wsrep_drupal_282555_workaround), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); static Sys_var_charptr sys_wsrep_sst_method( @@ -4843,13 +4864,14 @@ static Sys_var_charptr Sys_wsrep_start_position ( static Sys_var_ulong Sys_wsrep_max_ws_size ( "wsrep_max_ws_size", "Max write set size (bytes)", GLOBAL_VAR(wsrep_max_ws_size), CMD_LINE(REQUIRED_ARG), - /* Upper limit is 65K short of 4G to avoid overlows on 32-bit systems */ - VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(1073741824UL), BLOCK_SIZE(1)); + VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(WSREP_MAX_WS_SIZE), + BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(wsrep_max_ws_size_check), ON_UPDATE(wsrep_max_ws_size_update)); static Sys_var_ulong Sys_wsrep_max_ws_rows ( "wsrep_max_ws_rows", "Max number of rows in write set", GLOBAL_VAR(wsrep_max_ws_rows), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, 1048576), DEFAULT(131072), BLOCK_SIZE(1)); + VALID_RANGE(0, 1048576), DEFAULT(0), BLOCK_SIZE(1)); static Sys_var_charptr Sys_wsrep_notify_cmd( "wsrep_notify_cmd", "", @@ -4872,7 +4894,8 @@ static bool fix_wsrep_causal_reads(sys_var *self, THD* thd, enum_var_type var_ty static Sys_var_mybool Sys_wsrep_causal_reads( "wsrep_causal_reads", "Setting this variable is equivalent " "to setting wsrep_sync_wait READ flag", - SESSION_VAR(wsrep_causal_reads), CMD_LINE(OPT_ARG), DEFAULT(FALSE), + SESSION_VAR(wsrep_causal_reads), + CMD_LINE(OPT_ARG, OPT_WSREP_CAUSAL_READS), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_wsrep_causal_reads), DEPRECATED("'@@wsrep_sync_wait=1'")); @@ -4882,7 +4905,7 @@ static Sys_var_uint Sys_wsrep_sync_wait( "an operation of the type specified by bitmask: 1 - READ(includes " "SELECT, SHOW and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - " "INSERT and REPLACE", - SESSION_VAR(wsrep_sync_wait), CMD_LINE(OPT_ARG), + SESSION_VAR(wsrep_sync_wait), CMD_LINE(OPT_ARG, OPT_WSREP_SYNC_WAIT), VALID_RANGE(WSREP_SYNC_WAIT_NONE, WSREP_SYNC_WAIT_MAX), DEFAULT(WSREP_SYNC_WAIT_NONE), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic index 7c62516d52b..334dd318643 100644 --- a/sql/sys_vars.ic +++ b/sql/sys_vars.ic @@ -96,7 +96,6 @@ enum charset_enum {IN_SYSTEM_CHARSET, IN_FS_CHARSET}; static const char *bool_values[3]= {"OFF", "ON", 0}; TYPELIB bool_typelib={ array_elements(bool_values)-1, "", bool_values, 0 }; -extern const char *encrypt_algorithm_names[]; /** A small wrapper class to pass getopt arguments as a pair diff --git a/sql/table.cc b/sql/table.cc index a90eb2eee15..85ffd560992 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1804,6 +1804,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, { KEY_PART_INFO *new_key_part= (keyinfo-1)->key_part + (keyinfo-1)->ext_key_parts; + uint add_keyparts_for_this_key= add_first_key_parts; /* Do not extend the key that contains a component @@ -1815,19 +1816,20 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (share->field[fieldnr-1]->key_length() != keyinfo->key_part[i].length) { - add_first_key_parts= 0; + add_keyparts_for_this_key= 0; break; } } - if (add_first_key_parts < keyinfo->ext_key_parts-keyinfo->user_defined_key_parts) + if (add_keyparts_for_this_key < (keyinfo->ext_key_parts - + keyinfo->user_defined_key_parts)) { share->ext_key_parts-= keyinfo->ext_key_parts; key_part_map ext_key_part_map= keyinfo->ext_key_part_map; keyinfo->ext_key_parts= keyinfo->user_defined_key_parts; keyinfo->ext_key_flags= keyinfo->flags; keyinfo->ext_key_part_map= 0; - for (i= 0; i < add_first_key_parts; i++) + for (i= 0; i < add_keyparts_for_this_key; i++) { if (ext_key_part_map & 1<get_thd(); + ulonglong sql_mode_backup= thd->variables.sql_mode; + thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; field->val_str(&str); - if (!(length= str.length())) + if ((rc= !str.length() || + !(to= strmake_root(mem, str.ptr(), str.length())))) { res->length(0); - return 1; + goto ex; } - if (!(to= strmake_root(mem, str.ptr(), length))) - length= 0; // Safety fix - res->set(to, length, field->charset()); - return 0; + res->set(to, str.length(), field->charset()); + +ex: + thd->variables.sql_mode= sql_mode_backup; + return rc; } @@ -3472,17 +3479,10 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res) char *get_field(MEM_ROOT *mem, Field *field) { - char buff[MAX_FIELD_WIDTH], *to; - String str(buff,sizeof(buff),&my_charset_bin); - uint length; - - field->val_str(&str); - length= str.length(); - if (!length || !(to= (char*) alloc_root(mem,length+1))) - return NullS; - memcpy(to,str.ptr(),(uint) length); - to[length]=0; - return to; + String str; + bool rc= get_field(mem, field, &str); + DBUG_ASSERT(rc || str.ptr()[str.length()] == '\0'); + return rc ? NullS : (char *) str.ptr(); } /* diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 5bcea767aae..ae8a81b1bcd 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -148,9 +148,8 @@ int threadpool_add_connection(THD *thd) if (!setup_connection_thread_globals(thd)) { - if (!login_connection(thd)) + if (!thd_prepare_connection(thd)) { - prepare_new_connection_state(thd); /* Check if THD is ok, as prepare_new_connection_state() diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index 89a2036cb10..9e2ffc9aee0 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -169,6 +169,7 @@ struct pool_timer_t volatile uint64 next_timeout_check; int tick_interval; bool shutdown; + pthread_t timer_thread_id; }; static pool_timer_t pool_timer; @@ -606,12 +607,12 @@ void check_stall(thread_group_t *thread_group) static void start_timer(pool_timer_t* timer) { - pthread_t thread_id; DBUG_ENTER("start_timer"); mysql_mutex_init(key_timer_mutex,&timer->mutex, NULL); mysql_cond_init(key_timer_cond, &timer->cond, NULL); timer->shutdown = false; - mysql_thread_create(key_timer_thread,&thread_id, NULL, timer_thread, timer); + mysql_thread_create(key_timer_thread, &timer->timer_thread_id, NULL, + timer_thread, timer); DBUG_VOID_RETURN; } @@ -623,6 +624,7 @@ static void stop_timer(pool_timer_t *timer) timer->shutdown = true; mysql_cond_signal(&timer->cond); mysql_mutex_unlock(&timer->mutex); + pthread_join(timer->timer_thread_id, NULL); DBUG_VOID_RETURN; } diff --git a/sql/winservice.c b/sql/winservice.c index 1cf9f8d7823..74e9e56acc6 100644 --- a/sql/winservice.c +++ b/sql/winservice.c @@ -81,8 +81,10 @@ void normalize_path(char *path, size_t size) and services. We do not want to mess up with these installations. We will just ignore such services, pretending it is not MySQL. - ´@return - TRUE, if this service should be excluded from UI lists etc (OEM install) + We also exclude MySQL5.7+ since we cannot upgrade it (and it is not an upgrade anyway) + + @return + TRUE, if this service should be excluded from UI lists etc FALSE otherwise. */ BOOL exclude_service(mysqld_service_properties *props) @@ -104,7 +106,12 @@ BOOL exclude_service(mysqld_service_properties *props) if (strstr(buf, exclude_patterns[i])) return TRUE; } - + if ((props->version_major == 0) || + (props->version_major > 5 && props->version_major < 10) || + (props->version_major == 5 && props->version_minor > 6)) + { + return TRUE; + } return FALSE; } diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 477be1b55d1..426789b4d38 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -39,15 +39,9 @@ static Log_event* wsrep_read_log_event( const char *error= 0; Log_event *res= 0; - if (data_len > wsrep_max_ws_size) - { - error = "Event too big"; - goto err; - } + res= Log_event::read_log_event(buf, data_len, &error, description_event, + true); - res= Log_event::read_log_event(buf, data_len, &error, description_event, true); - -err: if (!res) { DBUG_ASSERT(error != 0); diff --git a/sql/wsrep_applier.h b/sql/wsrep_applier.h index b6497776e87..d58d3cdc54e 100644 --- a/sql/wsrep_applier.h +++ b/sql/wsrep_applier.h @@ -23,6 +23,7 @@ void wsrep_set_apply_format(THD* thd, Format_description_log_event* ev); Format_description_log_event* wsrep_get_apply_format(THD* thd); /* wsrep callback prototypes */ +extern "C" { wsrep_cb_status_t wsrep_apply_cb(void *ctx, const void* buf, size_t buf_len, @@ -39,4 +40,5 @@ wsrep_cb_status_t wsrep_unordered_cb(void* ctx, const void* data, size_t size); +} /* extern "C" */ #endif /* WSREP_APPLIER_H */ diff --git a/sql/wsrep_binlog.h b/sql/wsrep_binlog.h index d8a2eb51d4a..864813d5c98 100644 --- a/sql/wsrep_binlog.h +++ b/sql/wsrep_binlog.h @@ -19,7 +19,7 @@ #include "sql_class.h" // THD, IO_CACHE #define HEAP_PAGE_SIZE 65536 /* 64K */ -#define WSREP_MAX_WS_SIZE (0xFFFFFFFFUL - HEAP_PAGE_SIZE) +#define WSREP_MAX_WS_SIZE 2147483647 /* 2GB */ /* Write the contents of a cache to a memory buffer. @@ -38,10 +38,10 @@ int wsrep_write_cache_buf(IO_CACHE *cache, uchar **buf, size_t *buf_len); @param len total amount of data written @return wsrep error status */ -int wsrep_write_cache (wsrep_t* wsrep, - THD* thd, - IO_CACHE* cache, - size_t* len); +int wsrep_write_cache (wsrep_t* const wsrep, + THD* const thd, + IO_CACHE* const cache, + size_t* const len); /* Dump replication buffer to disk */ void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len); diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 3bce8ba7128..6e0fc11bfda 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -34,11 +34,14 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd); */ void wsrep_cleanup_transaction(THD *thd) { + if (!WSREP(thd)) return; + if (wsrep_emulate_bin_log) thd_binlog_trx_reset(thd); thd->wsrep_ws_handle.trx_id= WSREP_UNDEFINED_TRX_ID; thd->wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED; thd->wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED; thd->wsrep_exec_mode= LOCAL_STATE; + thd->wsrep_affected_rows= 0; return; } @@ -109,13 +112,7 @@ void wsrep_register_hton(THD* thd, bool all) */ void wsrep_post_commit(THD* thd, bool all) { - /* - TODO: It can perhaps be fixed in a more elegant fashion by turning off - wsrep_emulate_binlog if wsrep_on=0 on server start. - https://github.com/codership/mysql-wsrep/issues/112 - */ - if (!WSREP_ON) - return; + if (!WSREP(thd)) return; switch (thd->wsrep_exec_mode) { diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 1d96176a70d..776bf4a3ab2 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -169,7 +169,7 @@ static PSI_file_info wsrep_files[]= my_bool wsrep_inited = 0; // initialized ? -static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; +static wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED; static char cluster_uuid_str[40]= { 0, }; static const char* cluster_status_str[WSREP_VIEW_MAX] = { @@ -561,8 +561,6 @@ int wsrep_init() wsrep_sst_auth_init(wsrep_sst_auth); - wsrep_causal_reads_update(&global_system_variables); - wsrep_ready_set(FALSE); assert(wsrep_provider); @@ -575,8 +573,7 @@ int wsrep_init() WSREP_ERROR("wsrep_load(%s) failed: %s (%d). Reverting to no provider.", wsrep_provider, strerror(rcode), rcode); strcpy((char*)wsrep_provider, WSREP_NONE); // damn it's a dirty hack - (void) wsrep_init(); - return rcode; + return wsrep_init(); } else /* this is for recursive call above */ { @@ -785,6 +782,9 @@ void wsrep_init_startup (bool first) wsrep_debug, wsrep_convert_LOCK_to_trx, (wsrep_on_fun)wsrep_on); + /* Skip replication start if dummy wsrep provider is loaded */ + if (!strcmp(wsrep_provider, WSREP_NONE)) return; + /* Skip replication start if no cluster address */ if (!wsrep_cluster_address || strlen(wsrep_cluster_address) == 0) return; @@ -881,6 +881,9 @@ bool wsrep_start_replication() { wsrep_status_t rcode; + /* wsrep provider must be loaded. */ + DBUG_ASSERT(wsrep); + /* if provider is trivial, don't even try to connect, but resume local node operation @@ -1260,7 +1263,7 @@ wsrep_alter_query_string(THD *thd, String *buf) return 0; } -int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len) +static int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len) { String log_query; @@ -1356,6 +1359,10 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len) return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len); } +/* Forward declarations. */ +static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len); +static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); + /* returns: 0: statement was replicated as TOI @@ -1391,6 +1398,12 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, case SQLCOM_ALTER_EVENT: buf_err= wsrep_alter_event_query(thd, &buf, &buf_len); break; + case SQLCOM_CREATE_ROLE: + if (sp_process_definer(thd)) + { + WSREP_WARN("Failed to set CREATE ROLE definer for TOI."); + } + /* fallthrough */ default: buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf, &buf_len); @@ -1465,19 +1478,15 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_) WSREP_DEBUG("RSU BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd), thd->wsrep_exec_mode, thd->query() ); - if (!wsrep_desync) + ret = wsrep->desync(wsrep); + if (ret != WSREP_OK) { - ret = wsrep->desync(wsrep); - if (ret != WSREP_OK) - { - WSREP_WARN("RSU desync failed %d for schema: %s, query: %s", - ret, (thd->db ? thd->db : "(null)"), thd->query()); - my_error(ER_LOCK_DEADLOCK, MYF(0)); - return(ret); - } + WSREP_WARN("RSU desync failed %d for schema: %s, query: %s", + ret, (thd->db ? thd->db : "(null)"), thd->query()); + my_error(ER_LOCK_DEADLOCK, MYF(0)); + return(ret); } - else - WSREP_DEBUG("RSU desync skipped: %d", wsrep_desync); + mysql_mutex_lock(&LOCK_wsrep_replaying); wsrep_replaying++; mysql_mutex_unlock(&LOCK_wsrep_replaying); @@ -1492,15 +1501,13 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_) wsrep_replaying--; mysql_mutex_unlock(&LOCK_wsrep_replaying); - if (!wsrep_desync) + ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) { - ret = wsrep->resync(wsrep); - if (ret != WSREP_OK) - { - WSREP_WARN("resync failed %d for schema: %s, query: %s", - ret, (thd->db ? thd->db : "(null)"), thd->query()); - } + WSREP_WARN("resync failed %d for schema: %s, query: %s", + ret, (thd->db ? thd->db : "(null)"), thd->query()); } + my_error(ER_LOCK_DEADLOCK, MYF(0)); return(1); } @@ -1536,18 +1543,15 @@ static void wsrep_RSU_end(THD *thd) (thd->db ? thd->db : "(null)"), thd->query()); } - if (!wsrep_desync) + + ret = wsrep->resync(wsrep); + if (ret != WSREP_OK) { - ret = wsrep->resync(wsrep); - if (ret != WSREP_OK) - { - WSREP_WARN("resync failed %d for schema: %s, query: %s", ret, - (thd->db ? thd->db : "(null)"), thd->query()); - return; - } + WSREP_WARN("resync failed %d for schema: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), thd->query()); + return; } - else - WSREP_DEBUG("RSU resync skipped: %d", wsrep_desync); + thd->variables.wsrep_on = 1; } @@ -2167,7 +2171,7 @@ void wsrep_kill_mysql(THD *thd) } -int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len) +static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len) { String log_query; sp_head *sp = thd->lex->sphead; @@ -2494,7 +2498,7 @@ error: } -int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len) +static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len) { LEX *lex= thd->lex; String stmt_query; @@ -2622,3 +2626,13 @@ void wsrep_aborting_thd_enqueue(THD *thd) aborting->next = wsrep_aborting_thd; wsrep_aborting_thd = aborting; } + +bool wsrep_node_is_donor() +{ + return (WSREP_ON) ? (wsrep_config_state.get_status() == 2) : false; +} + +bool wsrep_node_is_synced() +{ + return (WSREP_ON) ? (wsrep_config_state.get_status() == 4) : false; +} diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index e91ed2302a2..04ccc1a7e45 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -50,6 +50,7 @@ struct wsrep_thd_shadow { ulong tx_isolation; char *db; size_t db_length; + my_hrtime_t user_time; }; // Global wsrep parameters @@ -168,9 +169,14 @@ extern void wsrep_prepend_PATH (const char* path); /* Other global variables */ extern wsrep_seqno_t wsrep_locked_seqno; -#define WSREP_ON \ +#define WSREP_ON \ (global_system_variables.wsrep_on) +#define WSREP_ON_NEW \ + ((global_system_variables.wsrep_on) && \ + wsrep_provider && \ + strcmp(wsrep_provider, WSREP_NONE)) + #define WSREP(thd) \ (WSREP_ON && wsrep && (thd && thd->variables.wsrep_on)) @@ -280,10 +286,7 @@ void wsrep_to_isolation_end(THD *thd); void wsrep_cleanup_transaction(THD *thd); int wsrep_to_buf_helper( THD* thd, const char *query, uint query_len, uchar** buf, size_t* buf_len); -int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len); -int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len); -int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len); extern bool wsrep_grant_mdl_exception(MDL_context *requestor_ctx, @@ -304,14 +307,14 @@ void wsrep_close_applier_threads(int count); void wsrep_wait_appliers_close(THD *thd); void wsrep_kill_mysql(THD *thd); void wsrep_close_threads(THD *thd); -int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len); void wsrep_copy_query(THD *thd); bool wsrep_is_show_query(enum enum_sql_command command); void wsrep_replay_transaction(THD *thd); bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, HA_CREATE_INFO *create_info); -int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); +bool wsrep_node_is_donor(); +bool wsrep_node_is_synced(); #else /* WITH_WSREP */ diff --git a/sql/wsrep_priv.h b/sql/wsrep_priv.h index 30dce78c1a4..1f3fdda2560 100644 --- a/sql/wsrep_priv.h +++ b/sql/wsrep_priv.h @@ -40,8 +40,11 @@ extern wsrep_uuid_t local_uuid; extern wsrep_seqno_t local_seqno; // a helper function -void wsrep_sst_received(wsrep_t*, const wsrep_uuid_t&, wsrep_seqno_t, - const void*, size_t); +void wsrep_sst_received (wsrep_t* const wsrep, + const wsrep_uuid_t& uuid, + wsrep_seqno_t const segno, + const void * const state, + size_t const state_len); /*! SST thread signals init thread about sst completion */ void wsrep_sst_complete(const wsrep_uuid_t*, wsrep_seqno_t, bool); diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 4f6cc51c3f8..d88263d75cb 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -340,6 +340,7 @@ static int sst_scan_uuid_seqno (const char* str, wsrep_uuid_t* uuid, wsrep_seqno_t* seqno) { int offt = wsrep_uuid_scan (str, strlen(str), uuid); + errno= 0; /* Reset the errno */ if (offt > 0 && strlen(str) > (unsigned int)offt && ':' == str[offt]) { *seqno = strtoll (str + offt + 1, NULL, 10); @@ -476,7 +477,7 @@ static void* sst_joiner_thread (void* a) } else { // Scan state ID first followed by wsrep_gtid_domain_id. char uuid[512]; - long int domain_id; + unsigned long int domain_id; size_t len= pos - out + 1; if (len > sizeof(uuid)) goto err; // safety check @@ -490,11 +491,11 @@ static void* sst_joiner_thread (void* a) else if (wsrep_gtid_mode) { errno= 0; /* Reset the errno */ - domain_id= strtol(pos + 1, NULL, 10); + domain_id= strtoul(pos + 1, NULL, 10); err= errno; /* Check if we received a valid gtid_domain_id. */ - if (err == EINVAL || err == ERANGE || domain_id < 0x0 || domain_id > 0xFFFF) + if (err == EINVAL || err == ERANGE) { WSREP_ERROR("Failed to get donor wsrep_gtid_domain_id."); err= EINVAL; @@ -1119,6 +1120,16 @@ wait_signal: if (!err) { sst_disallow_writes (thd.ptr, true); + /* + Lets also keep statements that modify binary logs (like RESET LOGS, + RESET MASTER) from proceeding until the files have been transferred + to the joiner node. + */ + if (mysql_bin_log.is_open()) + { + mysql_mutex_lock(mysql_bin_log.get_log_lock()); + } + locked= true; goto wait_signal; } @@ -1127,6 +1138,11 @@ wait_signal: { if (locked) { + if (mysql_bin_log.is_open()) + { + mysql_mutex_assert_owner(mysql_bin_log.get_log_lock()); + mysql_mutex_unlock(mysql_bin_log.get_log_lock()); + } sst_disallow_writes (thd.ptr, false); thd.ptr->global_read_lock.unlock_global_read_lock (thd.ptr); locked= false; @@ -1159,6 +1175,11 @@ wait_signal: if (locked) // don't forget to unlock server before return { + if (mysql_bin_log.is_open()) + { + mysql_mutex_assert_owner(mysql_bin_log.get_log_lock()); + mysql_mutex_unlock(mysql_bin_log.get_log_lock()); + } sst_disallow_writes (thd.ptr, false); thd.ptr->global_read_lock.unlock_global_read_lock (thd.ptr); } diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index fb48c1ad60e..cf69a4d2d12 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -140,6 +140,9 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) shadow->wsrep_exec_mode = thd->wsrep_exec_mode; shadow->vio = thd->net.vio; + // Disable general logging on applier threads + thd->variables.option_bits |= OPTION_LOG_OFF; + // Enable binlogging if opt_log_slave_updates is set if (opt_log_slave_updates) thd->variables.option_bits|= OPTION_BIN_LOG; else @@ -161,6 +164,7 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) shadow->db = thd->db; shadow->db_length = thd->db_length; + shadow->user_time = thd->user_time; thd->reset_db(NULL, 0); } @@ -171,6 +175,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) thd->wsrep_exec_mode = shadow->wsrep_exec_mode; thd->net.vio = shadow->vio; thd->variables.tx_isolation = shadow->tx_isolation; + thd->user_time = shadow->user_time; thd->reset_db(shadow->db, shadow->db_length); delete thd->system_thread_info.rpl_sql_info; @@ -184,6 +189,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) void wsrep_replay_transaction(THD *thd) { + DBUG_ENTER("wsrep_replay_transaction"); /* checking if BF trx must be replayed */ if (thd->wsrep_conflict_state== MUST_REPLAY) { DBUG_ASSERT(wsrep_thd_trx_seqno(thd)); @@ -192,6 +198,13 @@ void wsrep_replay_transaction(THD *thd) { WSREP_ERROR("replay issue, thd has reported status already"); } + + /* + PS reprepare observer should have been removed already. + open_table() will fail if we have dangling observer here. + */ + DBUG_ASSERT(thd->m_reprepare_observer == NULL); + thd->get_stmt_da()->reset_diagnostics_area(); thd->wsrep_conflict_state= REPLAYING; @@ -298,6 +311,7 @@ void wsrep_replay_transaction(THD *thd) mysql_mutex_unlock(&LOCK_wsrep_replaying); } } + DBUG_VOID_RETURN; } static void wsrep_replication_process(THD *thd) diff --git a/sql/wsrep_utils.h b/sql/wsrep_utils.h index ed699eabec9..f20e02d03a2 100644 --- a/sql/wsrep_utils.h +++ b/sql/wsrep_utils.h @@ -19,7 +19,7 @@ #include "wsrep_priv.h" #include "wsrep_mysqld.h" -unsigned int wsrep_check_ip (const char* addr, bool *is_ipv6); +unsigned int wsrep_check_ip (const char* const addr, bool *is_ipv6); size_t wsrep_guess_ip (char* buf, size_t buf_len); namespace wsp { @@ -155,6 +155,7 @@ private: } bool parse_port(const char *port) { + errno= 0; /* Reset the errno */ m_port= strtol(port, NULL, 10); if (errno == EINVAL || errno == ERANGE) { diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 9c01e54f48d..30c5bf900ff 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -167,16 +167,46 @@ void wsrep_start_position_init (const char* val) wsrep_set_local_position (val, false); } +static int get_provider_option_value(const char* opts, + const char* opt_name, + ulong* opt_value) +{ + int ret= 1; + ulong opt_value_tmp; + char *opt_value_str, *s, *opts_copy= my_strdup(opts, MYF(MY_WME)); + + if ((opt_value_str= strstr(opts_copy, opt_name)) == NULL) + goto end; + opt_value_str= strtok_r(opt_value_str, "=", &s); + if (opt_value_str == NULL) goto end; + opt_value_str= strtok_r(NULL, ";", &s); + if (opt_value_str == NULL) goto end; + + opt_value_tmp= strtoul(opt_value_str, NULL, 10); + if (errno == ERANGE) goto end; + + *opt_value= opt_value_tmp; + ret= 0; + +end: + my_free(opts_copy); + return ret; +} + static bool refresh_provider_options() { + DBUG_ASSERT(wsrep); + WSREP_DEBUG("refresh_provider_options: %s", (wsrep_provider_options) ? wsrep_provider_options : "null"); char* opts= wsrep->options_get(wsrep); if (opts) { - if (wsrep_provider_options) my_free((void *)wsrep_provider_options); - wsrep_provider_options = (char*)my_memdup(opts, strlen(opts) + 1, - MYF(MY_WME)); + wsrep_provider_options_init(opts); + get_provider_option_value(wsrep_provider_options, + (char*)"repl.max_ws_size", + &wsrep_max_ws_size); + free(opts); } else { @@ -290,18 +320,18 @@ void wsrep_provider_init (const char* value) } bool wsrep_provider_options_check(sys_var *self, THD* thd, set_var* var) -{ - return 0; -} - -bool wsrep_provider_options_update(sys_var *self, THD* thd, enum_var_type type) { if (wsrep == NULL) { my_message(ER_WRONG_ARGUMENTS, "WSREP (galera) not started", MYF(0)); return true; } + return false; +} +bool wsrep_provider_options_update(sys_var *self, THD* thd, enum_var_type type) +{ + DBUG_ASSERT(wsrep); wsrep_status_t ret= wsrep->options_set(wsrep, wsrep_provider_options); if (ret != WSREP_OK) { @@ -348,7 +378,16 @@ bool wsrep_cluster_address_check (sys_var *self, THD* thd, set_var* var) bool wsrep_cluster_address_update (sys_var *self, THD* thd, enum_var_type type) { - bool wsrep_on_saved= thd->variables.wsrep_on; + bool wsrep_on_saved; + + /* Do not proceed if wsrep provider is not loaded. */ + if (!wsrep) + { + WSREP_INFO("wsrep provider is not loaded, can't re(start) replication."); + return false; + } + + wsrep_on_saved= thd->variables.wsrep_on; thd->variables.wsrep_on= false; /* stop replication is heavy operation, and includes closing all client @@ -485,6 +524,12 @@ bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type) bool wsrep_desync_check (sys_var *self, THD* thd, set_var* var) { + if (wsrep == NULL) + { + my_message(ER_WRONG_ARGUMENTS, "WSREP (galera) not started", MYF(0)); + return true; + } + bool new_wsrep_desync= (bool) var->save_result.ulonglong_value; if (wsrep_desync == new_wsrep_desync) { if (new_wsrep_desync) { @@ -496,20 +541,10 @@ bool wsrep_desync_check (sys_var *self, THD* thd, set_var* var) ER_WRONG_VALUE_FOR_VAR, "'wsrep_desync' is already OFF."); } + return false; } - return 0; -} - -bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) -{ - if (wsrep == NULL) - { - my_message(ER_WRONG_ARGUMENTS, "WSREP (galera) not started", MYF(0)); - return true; - } - wsrep_status_t ret(WSREP_WARNING); - if (wsrep_desync) { + if (new_wsrep_desync) { ret = wsrep->desync (wsrep); if (ret != WSREP_OK) { WSREP_WARN ("SET desync failed %d for schema: %s, query: %s", ret, @@ -531,6 +566,39 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) return false; } +bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) +{ + DBUG_ASSERT(wsrep); + return false; +} + +bool wsrep_max_ws_size_check(sys_var *self, THD* thd, set_var* var) +{ + if (wsrep == NULL) + { + my_message(ER_WRONG_ARGUMENTS, "WSREP (galera) not started", MYF(0)); + return true; + } + return false; +} + +bool wsrep_max_ws_size_update (sys_var *self, THD *thd, enum_var_type) +{ + DBUG_ASSERT(wsrep); + + char max_ws_size_opt[128]; + my_snprintf(max_ws_size_opt, sizeof(max_ws_size_opt), + "repl.max_ws_size=%d", wsrep_max_ws_size); + wsrep_status_t ret= wsrep->options_set(wsrep, max_ws_size_opt); + if (ret != WSREP_OK) + { + WSREP_ERROR("Set options returned %d", ret); + refresh_provider_options(); + return true; + } + return refresh_provider_options(); +} + static SHOW_VAR wsrep_status_vars[]= { {"connected", (char*) &wsrep_connected, SHOW_BOOL}, diff --git a/sql/wsrep_var.h b/sql/wsrep_var.h index 377b54f2d18..ca77b5c0039 100644 --- a/sql/wsrep_var.h +++ b/sql/wsrep_var.h @@ -92,6 +92,9 @@ extern bool wsrep_slave_threads_update UPDATE_ARGS; extern bool wsrep_desync_check CHECK_ARGS; extern bool wsrep_desync_update UPDATE_ARGS; +extern bool wsrep_max_ws_size_check CHECK_ARGS; +extern bool wsrep_max_ws_size_update UPDATE_ARGS; + #else /* WITH_WSREP */ #define WSREP_NONE diff --git a/storage/connect/.gitignore b/storage/connect/.gitignore new file mode 100644 index 00000000000..e2fa07ee143 --- /dev/null +++ b/storage/connect/.gitignore @@ -0,0 +1,264 @@ +# Edited by Olivier Bertrand +*-t +*.a +*.ctest +*.o +*.reject +*.so +*.so.* +*.spec +*~ +*.bak +*.log +*.cmake +*.tgz +*.msg +.*.swp +*.ninja +.ninja_* +.gdb_history + +CMakeFiles/ +connect.dir/ +connect.dir-Copie/ +Debug/ +MinSizeRel/ +Release/ +RelWithDebInfo/ + +# C and C++ + +# Compiled Object files +*.slo +*.lo +*.o +*.ko +*.obj +*.elf +*.exp +*.manifest +*.dep +*.idb +*.res + +# Precompiled Headers +*.gch +*.pch + +# Compiled Static libraries +*.lib +*.a +*.la +*.lai +*.lo + +# Compiled Dynamic libraries +*.so +*.so.* +*.dylib +*.dll + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates +*.ncb +*.sln + +*.vcproj +*.vcproj.* +*.vcproj.*.* +*.vcproj.*.*.* +*.vcxproj +*.vcxproj.* +*.vcxproj.*.* +*.vcxproj.*.*.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# If using the old MSBuild-Integrated Package Restore, uncomment this: +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +# sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ diff --git a/storage/connect/JdbcInterface.class b/storage/connect/JdbcInterface.class deleted file mode 100644 index 51a0e69bad5..00000000000 Binary files a/storage/connect/JdbcInterface.class and /dev/null differ diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index da8be207237..b4b03e6ba4a 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -109,19 +109,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); /***********************************************************************/ char *GetPluginDir(void) { - char *plugin_dir; - -#if defined(_WIN64) - plugin_dir = (char *)GetProcAddress(GetModuleHandle(NULL), - "?opt_plugin_dir@@3PADEA"); -#elif defined(_WIN32) - plugin_dir = (char*)GetProcAddress(GetModuleHandle(NULL), - "?opt_plugin_dir@@3PADA"); -#else - plugin_dir = opt_plugin_dir; -#endif - - return plugin_dir; + return opt_plugin_dir; } // end of GetPluginDir /***********************************************************************/ diff --git a/storage/connect/mysql-test/connect/disabled.def b/storage/connect/mysql-test/connect/disabled.def index 9b4570915c7..4e07b5c0576 100644 --- a/storage/connect/mysql-test/connect/disabled.def +++ b/storage/connect/mysql-test/connect/disabled.def @@ -9,7 +9,6 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -#json_udf_bin : broken upstream in --ps (fixed) jdbc : Variable settings depend on machine configuration jdbc_new : Variable settings depend on machine configuration jdbc_oracle : Variable settings depend on machine configuration diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index be5b04787dd..33ca57c9654 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2014, 2015, MariaDB Corporation @@ -1126,7 +1126,7 @@ that the caller has made the reservation for free extents! @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) buf_block_t* btr_page_alloc_low( /*===============*/ @@ -2181,7 +2181,8 @@ btr_parse_page_reorganize( { ulint level = page_zip_level; - ut_ad(ptr && end_ptr); + ut_ad(ptr != NULL); + ut_ad(end_ptr != NULL); /* If dealing with a compressed page the record has the compression level used during original compression written in @@ -2653,7 +2654,7 @@ func_exit: Returns TRUE if the insert fits on the appropriate half-page with the chosen split_rec. @return true if fits */ -static __attribute__((nonnull(1,3,4,6), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,3,4,6), warn_unused_result)) bool btr_page_insert_fits( /*=================*/ @@ -2796,7 +2797,7 @@ btr_insert_on_non_leaf_level_func( /**************************************************************//** Attaches the halves of an index page on the appropriate level in an index tree. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void btr_attach_half_pages( /*==================*/ @@ -2932,7 +2933,7 @@ btr_attach_half_pages( /*************************************************************//** Determine if a tuple is smaller than any record on the page. @return TRUE if smaller */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool btr_page_tuple_smaller( /*===================*/ @@ -3524,7 +3525,8 @@ btr_level_list_remove_func( ulint prev_page_no; ulint next_page_no; - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(space == page_get_space_id(page)); /* Get the previous and next page numbers of page */ diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index a6bb258344f..eca232d81b4 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. Copyright (c) 2015, MariaDB Corporation. @@ -1139,7 +1139,7 @@ This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). @return pointer to inserted record if succeed, else NULL */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) rec_t* btr_cur_insert_if_possible( /*=======================*/ @@ -1182,7 +1182,7 @@ btr_cur_insert_if_possible( /*************************************************************//** For an insert, checks the locks and does the undo logging if desired. @return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */ -UNIV_INLINE __attribute__((warn_unused_result, nonnull(2,3,5,6))) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result, nonnull(2,3,5,6))) dberr_t btr_cur_ins_lock_and_undo( /*======================*/ @@ -1717,7 +1717,7 @@ btr_cur_pessimistic_insert( /*************************************************************//** For an update, checks the locks and does the undo logging. @return DB_SUCCESS, DB_WAIT_LOCK, or error number */ -UNIV_INLINE __attribute__((warn_unused_result, nonnull(2,3,6,7))) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result, nonnull(2,3,6,7))) dberr_t btr_cur_upd_lock_and_undo( /*======================*/ @@ -1736,7 +1736,7 @@ btr_cur_upd_lock_and_undo( const rec_t* rec; dberr_t err; - ut_ad(thr || (flags & BTR_NO_LOCKING_FLAG)); + ut_ad((thr != NULL) || (flags & BTR_NO_LOCKING_FLAG)); rec = btr_cur_get_rec(cursor); index = cursor->index; @@ -3035,7 +3035,7 @@ btr_cur_del_mark_set_clust_rec( ut_ad(page_is_leaf(page_align(rec))); #ifdef UNIV_DEBUG - if (btr_cur_print_record_ops && thr) { + if (btr_cur_print_record_ops && (thr != NULL)) { btr_cur_trx_report(thr_get_trx(thr)->id, index, "del mark "); rec_print_new(stderr, rec, offsets); } @@ -3183,7 +3183,7 @@ btr_cur_del_mark_set_sec_rec( rec = btr_cur_get_rec(cursor); #ifdef UNIV_DEBUG - if (btr_cur_print_record_ops && thr) { + if (btr_cur_print_record_ops && (thr != NULL)) { btr_cur_trx_report(thr_get_trx(thr)->id, cursor->index, "del mark "); rec_print(stderr, rec, cursor->index); @@ -5134,7 +5134,7 @@ btr_free_externally_stored_field( ulint i, /*!< in: field number of field_ref; ignored if rec == NULL */ enum trx_rb_ctx rb_ctx, /*!< in: rollback context */ - mtr_t* local_mtr __attribute__((unused))) /*!< in: mtr + mtr_t* local_mtr MY_ATTRIBUTE((unused))) /*!< in: mtr containing the latch to data an an X-latch to the index tree */ { diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index dcb508a7f29..712e15a8171 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -473,7 +473,7 @@ btr_search_update_block_hash_info( /*==============================*/ btr_search_t* info, /*!< in: search info */ buf_block_t* block, /*!< in: buffer block */ - btr_cur_t* cursor __attribute__((unused))) + btr_cur_t* cursor MY_ATTRIBUTE((unused))) /*!< in: cursor */ { #ifdef UNIV_SYNC_DEBUG diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index 958b3b5cfad..f2ab73217e0 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -112,7 +112,7 @@ buf_buddy_mem_invalid( /**********************************************************************//** Check if a buddy is stamped free. @return whether the buddy is free */ -UNIV_INLINE __attribute__((warn_unused_result)) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) bool buf_buddy_stamp_is_free( /*====================*/ @@ -225,7 +225,7 @@ Checks if a buf is free i.e.: in the zip_free[]. @retval BUF_BUDDY_STATE_FREE if fully free @retval BUF_BUDDY_STATE_USED if currently in use @retval BUF_BUDDY_STATE_PARTIALLY_USED if partially in use. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) buf_buddy_state_t buf_buddy_is_free( /*==============*/ diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index bd424b7b598..b3eaf4bf5a9 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. @@ -637,7 +637,7 @@ buf_page_is_corrupted( "InnoDB: " REFMAN "forcing-innodb-recovery.html\n" "InnoDB: for more information.\n", - (ulong) mach_read_from_4( + (ulint) mach_read_from_4( read_buf + FIL_PAGE_OFFSET), (lsn_t) mach_read_from_8( read_buf + FIL_PAGE_LSN), @@ -828,7 +828,7 @@ buf_page_print( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", - (ulong) size); + size); ut_print_buf(stderr, read_buf, size); fputs("\nInnoDB: End of page dump\n", stderr); } @@ -2472,9 +2472,9 @@ buf_zip_decompress( } fprintf(stderr, - "InnoDB: unable to decompress space %lu page %lu\n", - (ulong) block->page.space, - (ulong) block->page.offset); + "InnoDB: unable to decompress space %u page %u\n", + block->page.space, + block->page.offset); return(FALSE); case FIL_PAGE_TYPE_ALLOCATED: @@ -3740,7 +3740,7 @@ buf_page_init_low( /********************************************************************//** Inits a page to the buffer buf_pool. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void buf_page_init( /*==========*/ @@ -3806,8 +3806,8 @@ buf_page_init( fprintf(stderr, "InnoDB: Error: page %lu %lu already found" " in the hash table: %p, %p\n", - (ulong) space, - (ulong) offset, + space, + offset, (const void*) hash_page, (const void*) block); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(&block->mutex); @@ -4170,7 +4170,7 @@ buf_page_create( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, "Creating space %lu page %lu to buffer\n", - (ulong) space, (ulong) offset); + space, offset); } #endif /* UNIV_DEBUG */ @@ -4571,10 +4571,10 @@ buf_page_io_complete( ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Error: reading page %lu\n" + " InnoDB: Error: reading page %u\n" "InnoDB: which is in the" " doublewrite buffer!\n", - (ulong) bpage->offset); + bpage->offset); } else if (!read_space_id && !read_page_no) { /* This is likely an uninitialized page. */ } else if ((bpage->space @@ -4590,10 +4590,11 @@ buf_page_io_complete( " InnoDB: Error: space id and page n:o" " stored in the page\n" "InnoDB: read in are %lu:%lu," - " should be %lu:%lu!\n", - (ulong) read_space_id, (ulong) read_page_no, - (ulong) bpage->space, - (ulong) bpage->offset); + " should be %u:%u!\n", + read_space_id, + read_page_no, + bpage->space, + bpage->offset); } /* From version 3.23.38 up we store the page checksum @@ -4624,10 +4625,10 @@ corrupt: "Database page corruption on disk" " or a failed"); ib_logf(IB_LOG_LEVEL_ERROR, - "Space %lu file %s read of page %lu.", + "Space %lu file %s read of page %u.", (ulint)bpage->space, space ? space->name : "NULL", - (ulong) bpage->offset); + bpage->offset); ib_logf(IB_LOG_LEVEL_ERROR, "You may have to recover" " from a backup."); @@ -4803,8 +4804,8 @@ corrupt: if (buf_debug_prints) { fprintf(stderr, "Has %s page space %lu page no %lu\n", io_type == BUF_IO_READ ? "read" : "written", - (ulong) buf_page_get_space(bpage), - (ulong) buf_page_get_page_no(bpage)); + buf_page_get_space(bpage), + buf_page_get_page_no(bpage)); } #endif /* UNIV_DEBUG */ @@ -4836,11 +4837,21 @@ buf_all_freed_instance( const buf_block_t* block = buf_chunk_not_freed(chunk); if (UNIV_LIKELY_NULL(block)) { - if (block->page.key_version == 0) { - fprintf(stderr, - "Page %lu %lu still fixed or dirty\n", - (ulong) block->page.space, - (ulong) block->page.offset); + if (block->page.key_version == 0) { + fil_space_t* space = fil_space_get(block->page.space); + ib_logf(IB_LOG_LEVEL_ERROR, + "Page %u %u still fixed or dirty.", + block->page.space, + block->page.offset); + ib_logf(IB_LOG_LEVEL_ERROR, + "Page oldest_modification %lu fix_count %d io_fix %d.", + block->page.oldest_modification, + block->page.buf_fix_count, + buf_page_get_io_fix(&block->page)); + ib_logf(IB_LOG_LEVEL_ERROR, + "Page space_id %u name %s.", + block->page.space, + (space && space->name) ? space->name : "NULL"); ut_error; } } @@ -5141,16 +5152,16 @@ assert_s_latched: if (n_lru + n_free > buf_pool->curr_size + n_zip) { fprintf(stderr, "n LRU %lu, n free %lu, pool %lu zip %lu\n", - (ulong) n_lru, (ulong) n_free, - (ulong) buf_pool->curr_size, (ulong) n_zip); + n_lru, n_free, + buf_pool->curr_size, n_zip); ut_error; } ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { fprintf(stderr, "Free list len %lu, free blocks %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) n_free); + UT_LIST_GET_LEN(buf_pool->free), + n_free); ut_error; } @@ -5229,20 +5240,20 @@ buf_print_instance( "n pending flush LRU %lu list %lu single page %lu\n" "pages made young %lu, not young %lu\n" "pages read %lu, created %lu, written %lu\n", - (ulong) size, - (ulong) UT_LIST_GET_LEN(buf_pool->LRU), - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), - (ulong) buf_pool->n_pend_unzip, - (ulong) buf_pool->n_pend_reads, - (ulong) buf_pool->n_flush[BUF_FLUSH_LRU], - (ulong) buf_pool->n_flush[BUF_FLUSH_LIST], - (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], - (ulong) buf_pool->stat.n_pages_made_young, - (ulong) buf_pool->stat.n_pages_not_made_young, - (ulong) buf_pool->stat.n_pages_read, - (ulong) buf_pool->stat.n_pages_created, - (ulong) buf_pool->stat.n_pages_written); + (ulint) size, + (ulint) UT_LIST_GET_LEN(buf_pool->LRU), + (ulint) UT_LIST_GET_LEN(buf_pool->free), + (ulint) UT_LIST_GET_LEN(buf_pool->flush_list), + (ulint) buf_pool->n_pend_unzip, + (ulint) buf_pool->n_pend_reads, + (ulint) buf_pool->n_flush[BUF_FLUSH_LRU], + (ulint) buf_pool->n_flush[BUF_FLUSH_LIST], + (ulint) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], + (ulint) buf_pool->stat.n_pages_made_young, + (ulint) buf_pool->stat.n_pages_not_made_young, + (ulint) buf_pool->stat.n_pages_read, + (ulint) buf_pool->stat.n_pages_created, + (ulint) buf_pool->stat.n_pages_written); buf_flush_list_mutex_exit(buf_pool); @@ -5293,7 +5304,7 @@ buf_print_instance( fprintf(stderr, "Block count for index %llu in buffer is about %lu", (ullint) index_ids[i], - (ulong) counts[i]); + (ulint) counts[i]); if (index) { putc(' ', stderr); @@ -5741,10 +5752,10 @@ buf_print_io_instance( fprintf(file, "Buffer pool hit rate %lu / 1000," " young-making rate %lu / 1000 not %lu / 1000\n", - (ulong) hit_rate, - (ulong) (1000 * pool_info->young_making_delta + (ulint) hit_rate, + (ulint) (1000 * pool_info->young_making_delta / pool_info->n_page_get_delta), - (ulong) (1000 * pool_info->not_young_making_delta + (ulint) (1000 * pool_info->not_young_making_delta / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n", diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 6f3aca0e1fb..0abf7118b4f 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -105,7 +105,7 @@ SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; or by: SHOW STATUS LIKE 'innodb_buffer_pool_dump_status'; */ -static __attribute__((nonnull, format(printf, 2, 3))) +static MY_ATTRIBUTE((nonnull, format(printf, 2, 3))) void buf_dump_status( /*============*/ @@ -137,7 +137,7 @@ SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_LOAD_STATUS'; or by: SHOW STATUS LIKE 'innodb_buffer_pool_load_status'; */ -static __attribute__((nonnull, format(printf, 2, 3))) +static MY_ATTRIBUTE((nonnull, format(printf, 2, 3))) void buf_load_status( /*============*/ @@ -684,7 +684,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(buf_dump_thread)( /*============================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { ut_ad(!srv_read_only_mode); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 780230b38ba..2f84ebae301 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates -Copyright (c) 2013, 2015, MariaDB Corporation +Copyright (c) 1995, 2016, Oracle and/or its affiliates +Copyright (c) 2013, 2016, MariaDB Corporation Copyright (c) 2013, 2014, Fusion-io This program is free software; you can redistribute it and/or modify it under @@ -2285,7 +2285,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner_thread)( /*==========================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 7591e4476d6..30b991d24cf 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -146,7 +146,7 @@ If a compressed page is freed other compressed pages may be relocated. caller needs to free the page to the free list @retval false if BUF_BLOCK_ZIP_PAGE was removed from page_hash. In this case the block is already returned to the buddy allocator. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool buf_LRU_block_remove_hashed( /*========================*/ @@ -370,7 +370,7 @@ want to hog the CPU and resources. Release the buffer pool and block mutex and try to force a context switch. Then reacquire the same mutexes. The current page is "fixed" before the release of the mutexes and then "unfixed" again once we have reacquired the mutexes. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void buf_flush_yield( /*============*/ @@ -411,7 +411,7 @@ If we have hogged the resources for too long then release the buffer pool and flush list mutex and do a thread yield. Set the current page to "sticky" so that it is not relocated during the yield. @return true if yielded */ -static __attribute__((nonnull(1), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1), warn_unused_result)) bool buf_flush_try_yield( /*================*/ @@ -454,7 +454,7 @@ buf_flush_try_yield( Removes a single page from a given tablespace inside a specific buffer pool instance. @return true if page was removed. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool buf_flush_or_remove_page( /*=====================*/ @@ -535,7 +535,7 @@ the list as they age towards the tail of the LRU. @retval DB_SUCCESS if all freed @retval DB_FAIL if not all freed @retval DB_INTERRUPTED if the transaction was interrupted */ -static __attribute__((nonnull(1), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1), warn_unused_result)) dberr_t buf_flush_or_remove_pages( /*======================*/ @@ -641,7 +641,7 @@ Remove or flush all the dirty pages that belong to a given tablespace inside a specific buffer pool instance. The pages will remain in the LRU list and will be evicted from the LRU list as they age and move towards the tail of the LRU list. */ -static __attribute__((nonnull(1))) +static MY_ATTRIBUTE((nonnull(1))) void buf_flush_dirty_pages( /*==================*/ @@ -681,7 +681,7 @@ buf_flush_dirty_pages( /******************************************************************//** Remove all pages that belong to a given tablespace inside a specific buffer pool instance when we are DISCARDing the tablespace. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void buf_LRU_remove_all_pages( /*=====================*/ @@ -829,7 +829,7 @@ buffer pool instance when we are deleting the data file(s) of that tablespace. The pages still remain a part of LRU and are evicted from the list as they age towards the tail of the LRU only if buf_remove is BUF_REMOVE_FLUSH_NO_WRITE. */ -static __attribute__((nonnull(1))) +static MY_ATTRIBUTE((nonnull(1))) void buf_LRU_remove_pages( /*=================*/ diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc index 179de79b69f..593af089b00 100644 --- a/storage/innobase/data/data0data.cc +++ b/storage/innobase/data/data0data.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -67,7 +67,8 @@ dtuple_coll_cmp( ulint n_fields; ulint i; - ut_ad(tuple1 && tuple2); + ut_ad(tuple1 != NULL); + ut_ad(tuple2 != NULL); ut_ad(tuple1->magic_n == DATA_TUPLE_MAGIC_N); ut_ad(tuple2->magic_n == DATA_TUPLE_MAGIC_N); ut_ad(dtuple_check_typed(tuple1)); @@ -715,7 +716,7 @@ UNIV_INTERN void dtuple_convert_back_big_rec( /*========================*/ - dict_index_t* index __attribute__((unused)), /*!< in: index */ + dict_index_t* index MY_ATTRIBUTE((unused)), /*!< in: index */ dtuple_t* entry, /*!< in: entry whose data was put to vector */ big_rec_t* vector) /*!< in, own: big rec vector; it is freed in this function */ diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index a5af8208135..d423f16f61c 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -246,7 +246,7 @@ dict_create_sys_columns_tuple( /***************************************************************//** Builds a table definition to insert. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_build_table_def_step( /*======================*/ @@ -574,7 +574,7 @@ dict_create_search_tuple( /***************************************************************//** Builds an index definition row to insert. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_build_index_def_step( /*======================*/ @@ -649,7 +649,7 @@ dict_build_field_def_step( /***************************************************************//** Creates an index tree for the index if it is not a member of a cluster. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_create_index_tree_step( /*========================*/ @@ -1369,7 +1369,7 @@ dict_create_or_check_foreign_constraint_tables(void) ib_logf(IB_LOG_LEVEL_WARN, "Dropping incompletely created " "SYS_FOREIGN table."); - row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE); } if (sys_foreign_cols_err == DB_CORRUPTION) { @@ -1377,7 +1377,7 @@ dict_create_or_check_foreign_constraint_tables(void) "Dropping incompletely created " "SYS_FOREIGN_COLS table."); - row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE); } ib_logf(IB_LOG_LEVEL_WARN, @@ -1431,8 +1431,8 @@ dict_create_or_check_foreign_constraint_tables(void) ut_ad(err == DB_OUT_OF_FILE_SPACE || err == DB_TOO_MANY_CONCURRENT_TRXS); - row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); - row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE); if (err == DB_OUT_OF_FILE_SPACE) { err = DB_MUST_GET_MORE_FILE_SPACE; @@ -1468,7 +1468,7 @@ dict_create_or_check_foreign_constraint_tables(void) /****************************************************************//** Evaluate the given foreign key SQL statement. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_foreign_eval_sql( /*==================*/ @@ -1534,7 +1534,7 @@ dict_foreign_eval_sql( Add a single foreign key field definition to the data dictionary tables in the database. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_create_add_foreign_field_to_dictionary( /*========================================*/ @@ -1857,7 +1857,7 @@ dict_create_or_check_sys_tablespace(void) ib_logf(IB_LOG_LEVEL_WARN, "Dropping incompletely created " "SYS_TABLESPACES table."); - row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE); + row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE); } if (sys_datafiles_err == DB_CORRUPTION) { @@ -1865,7 +1865,7 @@ dict_create_or_check_sys_tablespace(void) "Dropping incompletely created " "SYS_DATAFILES table."); - row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE); + row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE); } ib_logf(IB_LOG_LEVEL_INFO, @@ -1901,8 +1901,8 @@ dict_create_or_check_sys_tablespace(void) ut_a(err == DB_OUT_OF_FILE_SPACE || err == DB_TOO_MANY_CONCURRENT_TRXS); - row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE); - row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE); + row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE); + row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE); if (err == DB_OUT_OF_FILE_SPACE) { err = DB_MUST_GET_MORE_FILE_SPACE; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index c51deb0a048..0310e5e1d66 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -6309,7 +6309,7 @@ dict_set_corrupted_index_cache_only( dict_index_t* index, /*!< in/out: index */ dict_table_t* table) /*!< in/out: table */ { - ut_ad(index); + ut_ad(index != NULL); ut_ad(mutex_own(&dict_sys->mutex)); ut_ad(!dict_table_is_comp(dict_sys->sys_tables)); ut_ad(!dict_table_is_comp(dict_sys->sys_indexes)); @@ -6319,8 +6319,9 @@ dict_set_corrupted_index_cache_only( if (dict_index_is_clust(index)) { dict_table_t* corrupt_table; - corrupt_table = table ? table : index->table; - ut_ad(!index->table || !table || index->table == table); + corrupt_table = (table != NULL) ? table : index->table; + ut_ad((index->table != NULL) || (table != NULL) + || index->table == table); if (corrupt_table) { corrupt_table->corrupted = TRUE; @@ -6400,11 +6401,6 @@ dict_table_get_index_on_name( { dict_index_t* index; - /* If name is NULL, just return */ - if (!name) { - return(NULL); - } - index = dict_table_get_first_index(table); while (index != NULL) { diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index ce5b10a623c..3c72efdb6f3 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -1751,7 +1751,7 @@ err_len: goto err_len; } type = mach_read_from_4(field); - if (type & (~0 << DICT_IT_BITS)) { + if (type & (~0U << DICT_IT_BITS)) { return("unknown SYS_INDEXES.TYPE bits"); } @@ -1790,7 +1790,7 @@ Loads definitions for table indexes. Adds them to the data dictionary cache. @return DB_SUCCESS if ok, DB_CORRUPTION if corruption of dictionary table or DB_UNSUPPORTED if table has unknown index type */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t dict_load_indexes( /*==============*/ @@ -2538,6 +2538,7 @@ func_exit: /* the table->fts could be created in dict_load_column when a user defined FTS_DOC_ID is present, but no FTS */ + fts_optimize_remove_table(table); fts_free(table); } else { fts_optimize_add_table(table); @@ -2603,14 +2604,13 @@ dict_load_table_on_id( btr_pcur_open_on_user_rec(sys_table_ids, tuple, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr); -check_rec: rec = btr_pcur_get_rec(&pcur); if (page_rec_is_user_rec(rec)) { /*---------------------------------------------------*/ /* Now we have the record in the secondary index containing the table ID and NAME */ - +check_rec: field = rec_get_nth_field_old( rec, DICT_FLD__SYS_TABLE_IDS__ID, &len); ut_ad(len == 8); @@ -2620,12 +2620,14 @@ check_rec: if (rec_get_deleted_flag(rec, 0)) { /* Until purge has completed, there may be delete-marked duplicate records - for the same SYS_TABLES.ID. - Due to Bug #60049, some delete-marked - records may survive the purge forever. */ - if (btr_pcur_move_to_next(&pcur, &mtr)) { + for the same SYS_TABLES.ID, but different + SYS_TABLES.NAME. */ + while (btr_pcur_move_to_next(&pcur, &mtr)) { + rec = btr_pcur_get_rec(&pcur); - goto check_rec; + if (page_rec_is_user_rec(rec)) { + goto check_rec; + } } } else { /* Now we get the table name from the record */ @@ -2887,7 +2889,7 @@ dict_load_foreign_cols( /***********************************************************************//** Loads a foreign key constraint to the dictionary cache. @return DB_SUCCESS or error code */ -static __attribute__((nonnull(1), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1), warn_unused_result)) dberr_t dict_load_foreign( /*==============*/ diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index 1724ac024fa..f8ea0005665 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -303,7 +303,7 @@ dict_mem_table_add_col( /**********************************************************************//** Renames a column of a table in the data dictionary cache. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void dict_mem_table_col_rename_low( /*==========================*/ diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 076ceb79613..7aefa6a1d4d 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -527,7 +527,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(dict_stats_thread)( /*==============================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { ut_a(!srv_read_only_mode); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 1bf15e7b639..b92ac02da10 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1395,6 +1395,28 @@ fil_space_free( return(TRUE); } +/*******************************************************************//** +Returns a pointer to the file_space_t that is in the memory cache +associated with a space id. +@return file_space_t pointer, NULL if space not found */ +fil_space_t* +fil_space_get( +/*==========*/ + ulint id) /*!< in: space id */ +{ + fil_space_t* space; + + ut_ad(fil_system); + + mutex_enter(&fil_system->mutex); + + space = fil_space_get_by_id(id); + + mutex_exit(&fil_system->mutex); + + return (space); +} + /*******************************************************************//** Returns a pointer to the file_space_t that is in the memory cache associated with a space id. The caller must lock fil_system->mutex. @@ -1809,7 +1831,7 @@ fil_set_max_space_id_if_bigger( Writes the flushed lsn and the latest archived log number to the page header of the first page of a data file of the system tablespace (space 0), which is uncompressed. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) dberr_t fil_write_lsn_and_arch_no_to_file( /*==============================*/ @@ -1817,7 +1839,7 @@ fil_write_lsn_and_arch_no_to_file( ulint sum_of_sizes, /*!< in: combined size of previous files in space, in database pages */ lsn_t lsn, /*!< in: lsn to write */ - ulint arch_log_no __attribute__((unused))) + ulint arch_log_no MY_ATTRIBUTE((unused))) /*!< in: archived log number to write */ { byte* buf1; @@ -1905,7 +1927,7 @@ Checks the consistency of the first data page of a tablespace at database startup. @retval NULL on success, or if innodb_force_recovery is set @return pointer to an error message string */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) const char* fil_check_first_page( /*=================*/ diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index bbd7ee1b650..87aa5f7db5c 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -94,7 +94,7 @@ fseg_n_reserved_pages_low( /********************************************************************//** Marks a page used. The page must reside within the extents of the given segment. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fseg_mark_page_used( /*================*/ @@ -133,7 +133,7 @@ fsp_fill_free_list( ulint space, /*!< in: space */ fsp_header_t* header, /*!< in/out: space header */ mtr_t* mtr) /*!< in/out: mini-transaction */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space @@ -162,7 +162,7 @@ fseg_alloc_free_page_low( in which the page should be initialized. If init_mtr!=mtr, but the page is already latched in mtr, do not initialize the page. */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -426,7 +426,7 @@ descriptor resides is x-locked. This function no longer extends the data file. @return pointer to the extent descriptor, NULL if the page does not exist in the space or if the offset is >= the free limit */ -UNIV_INLINE __attribute__((nonnull, warn_unused_result)) +UNIV_INLINE MY_ATTRIBUTE((nonnull, warn_unused_result)) xdes_t* xdes_get_descriptor_with_space_hdr( /*===============================*/ @@ -488,7 +488,7 @@ is necessary to make the descriptor defined, as they are uninitialized above the free limit. @return pointer to the extent descriptor, NULL if the page does not exist in the space or if the offset exceeds the free limit */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) xdes_t* xdes_get_descriptor( /*================*/ @@ -615,7 +615,7 @@ byte* fsp_parse_init_file_page( /*=====================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ buf_block_t* block) /*!< in: block or NULL */ { ut_ad(ptr && end_ptr); @@ -856,7 +856,7 @@ fsp_header_get_tablespace_size(void) Tries to extend a single-table tablespace so that a page would fit in the data file. @return TRUE if success */ -static UNIV_COLD __attribute__((nonnull, warn_unused_result)) +static UNIV_COLD MY_ATTRIBUTE((nonnull, warn_unused_result)) ibool fsp_try_extend_data_file_with_pages( /*================================*/ @@ -888,7 +888,7 @@ fsp_try_extend_data_file_with_pages( /***********************************************************************//** Tries to extend the last data file of a tablespace if it is auto-extending. @return FALSE if not auto-extending */ -static UNIV_COLD __attribute__((nonnull)) +static UNIV_COLD MY_ATTRIBUTE((nonnull)) ibool fsp_try_extend_data_file( /*=====================*/ @@ -1070,7 +1070,8 @@ fsp_fill_free_list( ulint i; mtr_t ibuf_mtr; - ut_ad(header && mtr); + ut_ad(header != NULL); + ut_ad(mtr != NULL); ut_ad(page_offset(header) == FSP_HEADER_OFFSET); /* Check if we can fill free list from above the free list limit */ @@ -1242,7 +1243,7 @@ fsp_alloc_free_extent( /**********************************************************************//** Allocates a single free page from a space. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fsp_alloc_from_free_frag( /*=====================*/ @@ -1333,7 +1334,7 @@ Allocates a single free page from a space. The page is marked as used. @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) buf_block_t* fsp_alloc_free_page( /*================*/ @@ -1582,9 +1583,9 @@ fsp_seg_inode_page_get_nth_inode( /*=============================*/ page_t* page, /*!< in: segment inode page */ ulint i, /*!< in: inode index on page */ - ulint zip_size __attribute__((unused)), + ulint zip_size MY_ATTRIBUTE((unused)), /*!< in: compressed page size, or 0 */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in/out: mini-transaction */ { ut_ad(i < FSP_SEG_INODES_PER_PAGE(zip_size)); @@ -1883,7 +1884,7 @@ fseg_get_nth_frag_page_no( /*======================*/ fseg_inode_t* inode, /*!< in: segment inode */ ulint n, /*!< in: slot index */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in/out: mini-transaction */ { ut_ad(inode && mtr); @@ -2978,7 +2979,7 @@ fsp_get_available_space_in_free_extents( /********************************************************************//** Marks a page used. The page must reside within the extents of the given segment. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fseg_mark_page_used( /*================*/ @@ -3050,7 +3051,8 @@ fseg_free_page_low( ib_id_t seg_id; ulint i; - ut_ad(seg_inode && mtr); + ut_ad(seg_inode != NULL); + ut_ad(mtr != NULL); ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); @@ -3259,7 +3261,8 @@ fseg_free_extent( ulint descr_n_used; ulint i; - ut_ad(seg_inode && mtr); + ut_ad(seg_inode != NULL); + ut_ad(mtr != NULL); descr = xdes_get_descriptor(space, zip_size, page, mtr); diff --git a/storage/innobase/fts/fts0blex.cc b/storage/innobase/fts/fts0blex.cc index 7d0acb00a3b..2d71934fa0e 100644 --- a/storage/innobase/fts/fts0blex.cc +++ b/storage/innobase/fts/fts0blex.cc @@ -305,9 +305,9 @@ YY_BUFFER_STATE fts0b_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner YY_BUFFER_STATE fts0b_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE fts0b_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -void *fts0balloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void *fts0brealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void fts0bfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0balloc (yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void *fts0brealloc (void *,yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void fts0bfree (void * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); #define yy_new_buffer fts0b_create_buffer @@ -347,7 +347,7 @@ typedef int yy_state_type; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -451,7 +451,7 @@ static yyconst flex_int16_t yy_chk[32] = #line 1 "fts0blex.l" /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -579,11 +579,11 @@ extern int fts0bwrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifndef YY_NO_INPUT @@ -1609,7 +1609,7 @@ YY_BUFFER_STATE fts0b_scan_bytes (yyconst char * yybytes, int _yybytes_len , y #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -1910,7 +1910,7 @@ int fts0blex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int i; for ( i = 0; i < n; ++i ) @@ -1919,7 +1919,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yys #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int n; for ( n = 0; s[n]; ++n ) @@ -1929,12 +1929,12 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __at } #endif -void *fts0balloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0balloc (yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { return (void *) malloc( size ); } -void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -1946,7 +1946,7 @@ void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner return (void *) realloc( (char *) ptr, size ); } -void fts0bfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void fts0bfree (void * ptr , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { free( (char *) ptr ); /* see fts0brealloc() for (char *) cast */ } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 95740da78d5..1457417d5dc 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end. @param[in,out] sync sync state @param[in] unlock_cache whether unlock cache lock when write node @param[in] wait whether wait when a sync is in progress +@param[in] has_dict whether has dict operation lock @return DB_SUCCESS if all OK */ static dberr_t fts_sync( fts_sync_t* sync, bool unlock_cache, - bool wait); + bool wait, + bool has_dict); /****************************************************************//** Release all resources help by the words rb tree e.g., the node ilist. */ @@ -280,7 +282,7 @@ void fts_words_free( /*===========*/ ib_rbt_t* words) /*!< in: rb tree of words */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef FTS_CACHE_SIZE_DEBUG /****************************************************************//** Read the max cache size parameter from the config table. */ @@ -302,7 +304,7 @@ fts_add_doc_by_id( /*==============*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ doc_id_t doc_id, /*!< in: doc id */ - ib_vector_t* fts_indexes __attribute__((unused))); + ib_vector_t* fts_indexes MY_ATTRIBUTE((unused))); /*!< in: affected fts indexes */ #ifdef FTS_DOC_STATS_DEBUG /****************************************************************//** @@ -317,7 +319,7 @@ fts_is_word_in_index( fts_table_t* fts_table, /*!< in: table instance */ const fts_string_t* word, /*!< in: the word to check */ ibool* found) /*!< out: TRUE if exists */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* FTS_DOC_STATS_DEBUG */ /******************************************************************//** @@ -332,7 +334,7 @@ fts_update_sync_doc_id( const char* table_name, /*!< in: table name, or NULL */ doc_id_t doc_id, /*!< in: last document id */ trx_t* trx) /*!< in: update trx, or NULL */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /****************************************************************//** This function loads the default InnoDB stopword list */ @@ -1075,13 +1077,12 @@ fts_words_free( } } -/*********************************************************************//** -Clear cache. */ +/** Clear cache. +@param[in,out] cache fts cache */ UNIV_INTERN void fts_cache_clear( -/*============*/ - fts_cache_t* cache) /*!< in: cache */ + fts_cache_t* cache) { ulint i; @@ -1477,7 +1478,7 @@ fts_cache_add_doc( /****************************************************************//** Drops a table. If the table can't be found we return a SUCCESS code. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_drop_table( /*===========*/ @@ -1519,7 +1520,7 @@ fts_drop_table( /****************************************************************//** Rename a single auxiliary table due to database name change. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_rename_one_aux_table( /*=====================*/ @@ -1628,7 +1629,7 @@ Drops the common ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have been called before this. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_drop_common_tables( /*===================*/ @@ -1755,7 +1756,7 @@ Drops FTS ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have been called before this. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_drop_all_index_tables( /*======================*/ @@ -1919,7 +1920,7 @@ func_exit: trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(table->name, trx, FALSE); + row_drop_table_for_mysql(table->name, trx, FALSE, TRUE); trx->error_state = DB_SUCCESS; } @@ -2071,7 +2072,7 @@ fts_create_index_tables_low( trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE, TRUE); trx->error_state = DB_SUCCESS; } @@ -2663,7 +2664,7 @@ fts_get_next_doc_id( This function fetch the Doc ID from CONFIG table, and compare with the Doc ID supplied. And store the larger one to the CONFIG table. @return DB_SUCCESS if OK */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_cmp_set_sync_doc_id( /*====================*/ @@ -2917,7 +2918,7 @@ fts_add( /*********************************************************************//** Do commit-phase steps necessary for the deletion of a row. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_delete( /*=======*/ @@ -3008,7 +3009,7 @@ fts_delete( /*********************************************************************//** Do commit-phase steps necessary for the modification of a row. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_modify( /*=======*/ @@ -3079,7 +3080,7 @@ fts_create_doc_id( The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_commit_table( /*=============*/ @@ -3413,7 +3414,7 @@ fts_add_doc_by_id( /*==============*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ doc_id_t doc_id, /*!< in: doc id */ - ib_vector_t* fts_indexes __attribute__((unused))) + ib_vector_t* fts_indexes MY_ATTRIBUTE((unused))) /*!< in: affected fts indexes */ { mtr_t mtr; @@ -3533,7 +3534,7 @@ fts_add_doc_by_id( get_doc, clust_index, doc_pcur, offsets, &doc); if (doc.found) { - ibool success __attribute__((unused)); + ibool success MY_ATTRIBUTE((unused)); btr_pcur_store_position(doc_pcur, &mtr); mtr_commit(&mtr); @@ -3568,7 +3569,7 @@ fts_add_doc_by_id( DBUG_EXECUTE_IF( "fts_instrument_sync_debug", - fts_sync(cache->sync, true, true); + fts_sync(cache->sync, true, true, false); ); DEBUG_SYNC_C("fts_instrument_sync_request"); @@ -3642,7 +3643,7 @@ fts_get_max_doc_id( dict_table_t* table) /*!< in: user table */ { dict_index_t* index; - dict_field_t* dfield __attribute__((unused)) = NULL; + dict_field_t* dfield MY_ATTRIBUTE((unused)) = NULL; doc_id_t doc_id = 0; mtr_t mtr; btr_pcur_t pcur; @@ -3900,7 +3901,7 @@ fts_write_node( /*********************************************************************//** Add rows to the DELETED_CACHE table. @return DB_SUCCESS if all went well else error code*/ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_add_deleted_cache( /*=======================*/ @@ -3954,7 +3955,7 @@ fts_sync_add_deleted_cache( @param[in] index_cache index cache @param[in] unlock_cache whether unlock cache when write node @return DB_SUCCESS if all went well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_write_words( trx_t* trx, @@ -4090,7 +4091,7 @@ fts_sync_write_words( /*********************************************************************//** Write a single documents statistics to disk. @return DB_SUCCESS if all went well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_write_doc_stat( /*====================*/ @@ -4344,7 +4345,7 @@ fts_sync_begin( Run SYNC on the table, i.e., write out data from the index specific cache to the FTS aux INDEX table and FTS aux doc id stats table. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_index( /*===========*/ @@ -4380,13 +4381,11 @@ fts_sync_index( } /** Check if index cache has been synced completely -@param[in,out] sync sync state @param[in,out] index_cache index cache @return true if index is synced, otherwise false. */ static bool fts_sync_index_check( - fts_sync_t* sync, fts_index_cache_t* index_cache) { const ib_rbt_node_t* rbt_node; @@ -4409,14 +4408,36 @@ fts_sync_index_check( return(true); } -/*********************************************************************//** -Commit the SYNC, change state of processed doc ids etc. +/** Reset synced flag in index cache when rollback +@param[in,out] index_cache index cache */ +static +void +fts_sync_index_reset( + fts_index_cache_t* index_cache) +{ + const ib_rbt_node_t* rbt_node; + + for (rbt_node = rbt_first(index_cache->words); + rbt_node != NULL; + rbt_node = rbt_next(index_cache->words, rbt_node)) { + + fts_tokenizer_word_t* word; + word = rbt_value(fts_tokenizer_word_t, rbt_node); + + fts_node_t* fts_node; + fts_node = static_cast(ib_vector_last(word->nodes)); + + fts_node->synced = false; + } +} + +/** Commit the SYNC, change state of processed doc ids etc. +@param[in,out] sync sync state @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_commit( -/*============*/ - fts_sync_t* sync) /*!< in: sync state */ + fts_sync_t* sync) { dberr_t error; trx_t* trx = sync->trx; @@ -4469,18 +4490,19 @@ fts_sync_commit( (double) n_nodes/ (double) elapsed_time); } + /* Avoid assertion in trx_free(). */ + trx->dict_operation_lock_mode = 0; trx_free_for_background(trx); return(error); } -/*********************************************************************//** -Rollback a sync operation */ +/** Rollback a sync operation +@param[in,out] sync sync state */ static void fts_sync_rollback( -/*==============*/ - fts_sync_t* sync) /*!< in: sync state */ + fts_sync_t* sync) { trx_t* trx = sync->trx; fts_cache_t* cache = sync->table->fts->cache; @@ -4492,6 +4514,10 @@ fts_sync_rollback( index_cache = static_cast( ib_vector_get(cache->indexes, i)); + /* Reset synced flag so nodes will not be skipped + in the next sync, see fts_sync_write_words(). */ + fts_sync_index_reset(index_cache); + for (j = 0; fts_index_selector[j].value; ++j) { if (index_cache->ins_graph[j] != NULL) { @@ -4517,6 +4543,9 @@ fts_sync_rollback( rw_lock_x_unlock(&cache->lock); fts_sql_rollback(trx); + + /* Avoid assertion in trx_free(). */ + trx->dict_operation_lock_mode = 0; trx_free_for_background(trx); } @@ -4525,13 +4554,15 @@ FTS auxiliary INDEX table and clear the cache at the end. @param[in,out] sync sync state @param[in] unlock_cache whether unlock cache lock when write node @param[in] wait whether wait when a sync is in progress +@param[in] has_dict whether has dict operation lock @return DB_SUCCESS if all OK */ static dberr_t fts_sync( fts_sync_t* sync, bool unlock_cache, - bool wait) + bool wait, + bool has_dict) { ulint i; dberr_t error = DB_SUCCESS; @@ -4560,6 +4591,12 @@ fts_sync( DEBUG_SYNC_C("fts_sync_begin"); fts_sync_begin(sync); + /* When sync in background, we hold dict operation lock + to prevent DDL like DROP INDEX, etc. */ + if (has_dict) { + sync->trx->dict_operation_lock_mode = RW_S_LATCH; + } + begin_sync: if (cache->total_size > fts_max_cache_size) { /* Avoid the case: sync never finish when @@ -4600,7 +4637,7 @@ begin_sync: ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped - || fts_sync_index_check(sync, index_cache)) { + || fts_sync_index_check(index_cache)) { continue; } @@ -4615,6 +4652,7 @@ end_sync: } rw_lock_x_lock(&cache->lock); + sync->interrupted = false; sync->in_progress = false; os_event_set(sync->event); rw_lock_x_unlock(&cache->lock); @@ -4638,20 +4676,23 @@ FTS auxiliary INDEX table and clear the cache at the end. @param[in,out] table fts table @param[in] unlock_cache whether unlock cache when write node @param[in] wait whether wait for existing sync to finish +@param[in] has_dict whether has dict operation lock @return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( dict_table_t* table, bool unlock_cache, - bool wait) + bool wait, + bool has_dict) { dberr_t err = DB_SUCCESS; ut_ad(table->fts); if (!dict_table_is_discarded(table) && table->fts->cache) { - err = fts_sync(table->fts->cache->sync, unlock_cache, wait); + err = fts_sync(table->fts->cache->sync, + unlock_cache, wait, has_dict); } return(err); @@ -6170,7 +6211,7 @@ fts_update_hex_format_flag( /*********************************************************************//** Rename an aux table to HEX format. It's called when "%016llu" is used to format an object id in table name, which only happens in Windows. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_rename_one_aux_table_to_hex_format( /*===================================*/ @@ -6261,7 +6302,7 @@ Note the ids in tables are correct but the names are old ambiguous ones. This function should make sure that either all the parent table and aux tables are set DICT_TF2_FTS_AUX_HEX_NAME with flags2 or none of them are set */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_rename_aux_tables_to_hex_format_low( /*====================================*/ @@ -6415,7 +6456,7 @@ fts_fake_hex_to_dec( { ib_id_t dec_id = 0; char tmp_id[FTS_AUX_MIN_TABLE_ID_LENGTH]; - int ret __attribute__((unused)); + int ret MY_ATTRIBUTE((unused)); ret = sprintf(tmp_id, UINT64PFx, id); ut_ad(ret == 16); @@ -6737,7 +6778,7 @@ fts_drop_aux_table_from_vector( Check and drop all orphaned FTS auxiliary tables, those that don't have a parent table or FTS index defined on them. @return DB_SUCCESS or error code */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fts_check_and_drop_orphaned_tables( /*===============================*/ diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index ccb7090c61d..ea937c20752 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -797,7 +797,7 @@ fts_zip_deflate_end( Read the words from the FTS INDEX. @return DB_SUCCESS if all OK, DB_TABLE_NOT_FOUND if no more indexes to search else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_index_fetch_words( /*==================*/ @@ -1131,7 +1131,7 @@ fts_optimize_lookup( /**********************************************************************//** Encode the word pos list into the node @return DB_SUCCESS or error code*/ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_optimize_encode_node( /*=====================*/ @@ -1220,7 +1220,7 @@ fts_optimize_encode_node( /**********************************************************************//** Optimize the data contained in a node. @return DB_SUCCESS or error code*/ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_optimize_node( /*==============*/ @@ -1318,7 +1318,7 @@ test_again: /**********************************************************************//** Determine the starting pos within the deleted doc id vector for a word. @return delete position */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int fts_optimize_deleted_pos( /*=====================*/ @@ -1447,7 +1447,7 @@ fts_optimize_word( /**********************************************************************//** Update the FTS index table. This is a delete followed by an insert. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_write_word( /*====================*/ @@ -1550,7 +1550,7 @@ fts_word_free( /**********************************************************************//** Optimize the word ilist and rewrite data to the FTS index. @return status one of RESTART, EXIT, ERROR */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_compact( /*=================*/ @@ -1645,7 +1645,7 @@ fts_optimize_create( /**********************************************************************//** Get optimize start time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_get_index_start_time( /*==============================*/ @@ -1661,7 +1661,7 @@ fts_optimize_get_index_start_time( /**********************************************************************//** Set the optimize start time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_set_index_start_time( /*==============================*/ @@ -1677,7 +1677,7 @@ fts_optimize_set_index_start_time( /**********************************************************************//** Get optimize end time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_get_index_end_time( /*============================*/ @@ -1692,7 +1692,7 @@ fts_optimize_get_index_end_time( /**********************************************************************//** Set the optimize end time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_set_index_end_time( /*============================*/ @@ -1912,7 +1912,7 @@ fts_optimize_set_next_word( Optimize is complete. Set the completion time, and reset the optimize start string for this FTS index to "". @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_index_completed( /*=========================*/ @@ -1952,7 +1952,7 @@ fts_optimize_index_completed( Read the list of words from the FTS auxiliary index that will be optimized in this pass. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_index_read_words( /*==========================*/ @@ -2009,7 +2009,7 @@ fts_optimize_index_read_words( Run OPTIMIZE on the given FTS index. Note: this can take a very long time (hours). @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_index( /*===============*/ @@ -2080,7 +2080,7 @@ fts_optimize_index( /**********************************************************************//** Delete the document ids in the delete, and delete cache tables. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_purge_deleted_doc_ids( /*===============================*/ @@ -2149,7 +2149,7 @@ fts_optimize_purge_deleted_doc_ids( /**********************************************************************//** Delete the document ids in the pending delete, and delete tables. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_purge_deleted_doc_id_snapshot( /*=======================================*/ @@ -2199,7 +2199,7 @@ Copy the deleted doc ids that will be purged during this optimize run to the being deleted FTS auxiliary tables. The transaction is committed upon successfull copy and rolled back on DB_DUPLICATE_KEY error. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_create_deleted_doc_id_snapshot( /*========================================*/ @@ -2237,7 +2237,7 @@ fts_optimize_create_deleted_doc_id_snapshot( Read in the document ids that are to be purged during optimize. The transaction is committed upon successfully read. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_read_deleted_doc_id_snapshot( /*======================================*/ @@ -2274,7 +2274,7 @@ Optimze all the FTS indexes, skipping those that have already been optimized, since the FTS auxiliary indexes are not guaranteed to be of the same cardinality. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_indexes( /*=================*/ @@ -2344,7 +2344,7 @@ fts_optimize_indexes( /*********************************************************************//** Cleanup the snapshot tables and the master deleted table. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_purge_snapshot( /*========================*/ @@ -2373,7 +2373,7 @@ fts_optimize_purge_snapshot( /*********************************************************************//** Reset the start time to 0 so that a new optimize can be started. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_reset_start_time( /*==========================*/ @@ -2412,7 +2412,7 @@ fts_optimize_reset_start_time( /*********************************************************************//** Run OPTIMIZE on the given table by a background thread. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_optimize_table_bk( /*==================*/ @@ -2757,6 +2757,7 @@ fts_optimize_new_table( empty_slot = i; } else if (slot->table->id == table->id) { /* Already exists in our optimize queue. */ + ut_ad(slot->table_id = table->id); return(FALSE); } } @@ -2974,15 +2975,24 @@ fts_optimize_sync_table( { dict_table_t* table = NULL; + /* Prevent DROP INDEX etc. from running when we are syncing + cache in background. */ + if (!rw_lock_s_lock_nowait(&dict_operation_lock, __FILE__, __LINE__)) { + /* Exit when fail to get dict operation lock. */ + return; + } + table = dict_table_open_on_id(table_id, FALSE, DICT_TABLE_OP_NORMAL); if (table) { if (dict_table_has_fts_index(table) && table->fts->cache) { - fts_sync_table(table, true, false); + fts_sync_table(table, true, false, true); } dict_table_close(table, FALSE, FALSE); } + + rw_lock_s_unlock(&dict_operation_lock); } /**********************************************************************//** diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 9fa38cde561..26bd0378aed 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -287,7 +287,7 @@ fts_expand_query( dict_index_t* index, /*!< in: FTS index to search */ fts_query_t* query) /*!< in: query result, to be freed by the client */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** This function finds documents that contain all words in a phrase or proximity search. And if proximity search, verify @@ -1128,7 +1128,7 @@ cont_search: /*****************************************************************//** Set difference. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_difference( /*=================*/ @@ -1220,7 +1220,7 @@ fts_query_difference( /*****************************************************************//** Intersect the token doc ids with the current set. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_intersect( /*================*/ @@ -1398,7 +1398,7 @@ fts_query_cache( /*****************************************************************//** Set union. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_union( /*============*/ @@ -2015,7 +2015,7 @@ fts_query_select( Read the rows from the FTS index, that match word and where the doc id is between first and last doc id. @return DB_SUCCESS if all go well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_find_term( /*================*/ @@ -2155,7 +2155,7 @@ fts_query_sum( /******************************************************************** Calculate the total documents that contain a particular word (term). @return DB_SUCCESS if all go well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_total_docs_containing_term( /*=================================*/ @@ -2234,7 +2234,7 @@ fts_query_total_docs_containing_term( /******************************************************************** Get the total number of words in a documents. @return DB_SUCCESS if all go well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_terms_in_document( /*========================*/ @@ -2315,7 +2315,7 @@ fts_query_terms_in_document( /*****************************************************************//** Retrieve the document and match the phrase tokens. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_match_document( /*=====================*/ @@ -2361,7 +2361,7 @@ fts_query_match_document( This function fetches the original documents and count the words in between matching words to see that is in specified distance @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool fts_query_is_in_proximity_range( /*============================*/ @@ -2416,7 +2416,7 @@ fts_query_is_in_proximity_range( Iterate over the matched document ids and search the for the actual phrase in the text. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_search_phrase( /*====================*/ @@ -2504,7 +2504,7 @@ func_exit: /*****************************************************************//** Text/Phrase search. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_phrase_search( /*====================*/ @@ -2755,7 +2755,7 @@ func_exit: /*****************************************************************//** Find the word and evaluate. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_execute( /*==============*/ @@ -4126,7 +4126,7 @@ words in documents found in the first search pass will be used as search arguments to search the document again, thus "expand" the search result set. @return DB_SUCCESS if success, otherwise the error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_expand_query( /*=============*/ diff --git a/storage/innobase/fts/fts0tlex.cc b/storage/innobase/fts/fts0tlex.cc index b744fbf0763..d4d9b4c48d1 100644 --- a/storage/innobase/fts/fts0tlex.cc +++ b/storage/innobase/fts/fts0tlex.cc @@ -305,9 +305,9 @@ YY_BUFFER_STATE fts0t_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner YY_BUFFER_STATE fts0t_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE fts0t_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -void *fts0talloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void *fts0trealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void fts0tfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0talloc (yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void *fts0trealloc (void *,yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void fts0tfree (void * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); #define yy_new_buffer fts0t_create_buffer @@ -347,7 +347,7 @@ typedef int yy_state_type; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -447,7 +447,7 @@ static yyconst flex_int16_t yy_chk[29] = #line 1 "fts0tlex.l" /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -575,11 +575,11 @@ extern int fts0twrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifndef YY_NO_INPUT @@ -1602,7 +1602,7 @@ YY_BUFFER_STATE fts0t_scan_bytes (yyconst char * yybytes, int _yybytes_len , y #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -1903,7 +1903,7 @@ int fts0tlex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int i; for ( i = 0; i < n; ++i ) @@ -1912,7 +1912,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yys #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int n; for ( n = 0; s[n]; ++n ) @@ -1922,12 +1922,12 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __at } #endif -void *fts0talloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0talloc (yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { return (void *) malloc( size ); } -void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -1939,7 +1939,7 @@ void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner return (void *) realloc( (char *) ptr, size ); } -void fts0tfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void fts0tfree (void * ptr , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { free( (char *) ptr ); /* see fts0trealloc() for (char *) cast */ } diff --git a/storage/innobase/fts/make_parser.sh b/storage/innobase/fts/make_parser.sh index 2c072914c8b..52b63eff674 100755 --- a/storage/innobase/fts/make_parser.sh +++ b/storage/innobase/fts/make_parser.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -22,15 +22,15 @@ make -f Makefile.query echo '#include "univ.i"' > $TMPF # This is to avoid compiler warning about unused parameters. -# FIXME: gcc extension "__attribute__" causing compilation errors on windows +# FIXME: gcc extension "MY_ATTRIBUTE" causing compilation errors on windows # platform. Quote them out for now. sed -e ' -s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; +s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; ' < fts0blex.cc >> $TMPF mv $TMPF fts0blex.cc @@ -38,12 +38,12 @@ mv $TMPF fts0blex.cc echo '#include "univ.i"' > $TMPF sed -e ' -s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; +s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; ' < fts0tlex.cc >> $TMPF mv $TMPF fts0tlex.cc diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a60462bc9d6..debda3bfea8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1762,7 +1762,7 @@ thd_set_lock_wait_time( /********************************************************************//** Obtain the InnoDB transaction of a MySQL thread. @return reference to transaction pointer */ -__attribute__((warn_unused_result, nonnull)) +MY_ATTRIBUTE((warn_unused_result, nonnull)) static inline trx_t*& thd_to_trx( @@ -3993,7 +3993,7 @@ int innobase_end( /*=========*/ handlerton* hton, /*!< in/out: InnoDB handlerton */ - ha_panic_function type __attribute__((unused))) + ha_panic_function type MY_ATTRIBUTE((unused))) /*!< in: ha_panic() parameter */ { int err= 0; @@ -7831,6 +7831,7 @@ dberr_t ha_innobase::innobase_lock_autoinc(void) /*====================================*/ { + DBUG_ENTER("ha_innobase::innobase_lock_autoinc"); dberr_t error = DB_SUCCESS; ut_ad(!srv_read_only_mode); @@ -7870,6 +7871,8 @@ ha_innobase::innobase_lock_autoinc(void) /* Fall through to old style locking. */ case AUTOINC_OLD_STYLE_LOCKING: + DBUG_EXECUTE_IF("die_if_autoinc_old_lock_style_used", + ut_ad(0);); error = row_lock_table_autoinc_for_mysql(prebuilt); if (error == DB_SUCCESS) { @@ -7883,7 +7886,7 @@ ha_innobase::innobase_lock_autoinc(void) ut_error; } - return(error); + DBUG_RETURN(error); } /********************************************************************//** @@ -10603,7 +10606,7 @@ create_table_check_doc_id_col( /*****************************************************************//** Creates a table definition to an InnoDB database. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int create_table_def( /*=============*/ @@ -12277,6 +12280,25 @@ ha_innobase::discard_or_import_tablespace( /* Commit the transaction in order to release the table lock. */ trx_commit_for_mysql(prebuilt->trx); + if (err == DB_SUCCESS && !discard + && dict_stats_is_persistent_enabled(dict_table)) { + dberr_t ret; + + /* Adjust the persistent statistics. */ + ret = dict_stats_update(dict_table, + DICT_STATS_RECALC_PERSISTENT); + + if (ret != DB_SUCCESS) { + push_warning_printf( + ha_thd(), + Sql_condition::WARN_LEVEL_WARN, + ER_ALTER_INFO, + "Error updating stats for table '%s'" + " after table rebuild: %s", + dict_table->name, ut_strerr(ret)); + } + } + DBUG_RETURN(convert_error_code_to_mysql(err, dict_table->flags, NULL)); } @@ -12398,7 +12420,8 @@ ha_innobase::delete_table( /* Drop the table in InnoDB */ err = row_drop_table_for_mysql( - norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB); + norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB, + FALSE); if (err == DB_TABLE_NOT_FOUND @@ -12429,7 +12452,8 @@ ha_innobase::delete_table( #endif err = row_drop_table_for_mysql( par_case_name, trx, - thd_sql_command(thd) == SQLCOM_DROP_DB); + thd_sql_command(thd) == SQLCOM_DROP_DB, + FALSE); } } @@ -12621,7 +12645,7 @@ innobase_drop_database( /*********************************************************************//** Renames an InnoDB table. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t innobase_rename_table( /*==================*/ @@ -13721,7 +13745,7 @@ ha_innobase::optimize( if (innodb_optimize_fulltext_only) { if (prebuilt->table->fts && prebuilt->table->fts->cache && !dict_table_is_discarded(prebuilt->table)) { - fts_sync_table(prebuilt->table, false, true); + fts_sync_table(prebuilt->table, false, true, false); fts_optimize_table(prebuilt->table); } return(HA_ADMIN_OK); @@ -13783,6 +13807,35 @@ ha_innobase::check( DBUG_RETURN(HA_ADMIN_CORRUPT); } + if (prebuilt->table->corrupted) { + char index_name[MAX_FULL_NAME_LEN + 1]; + /* If some previous operation has marked the table as + corrupted in memory, and has not propagated such to + clustered index, we will do so here */ + index = dict_table_get_first_index(prebuilt->table); + + if (!dict_index_is_corrupted(index)) { + row_mysql_lock_data_dictionary(prebuilt->trx); + dict_set_corrupted(index, prebuilt->trx, "CHECK TABLE"); + row_mysql_unlock_data_dictionary(prebuilt->trx); + } + + innobase_format_name(index_name, sizeof index_name, + index->name, TRUE); + + push_warning_printf(thd, + Sql_condition::WARN_LEVEL_WARN, + HA_ERR_INDEX_CORRUPT, + "InnoDB: Index %s is marked as" + " corrupted", index_name); + + /* Now that the table is already marked as corrupted, + there is no need to check any index of this table */ + prebuilt->trx->op_info = ""; + + DBUG_RETURN(HA_ADMIN_CORRUPT); + } + prebuilt->trx->op_info = "checking table"; old_isolation_level = prebuilt->trx->isolation_level; @@ -13866,6 +13919,15 @@ ha_innobase::check( prebuilt->index_usable = row_merge_is_index_usable( prebuilt->trx, prebuilt->index); + DBUG_EXECUTE_IF( + "dict_set_index_corrupted", + if (!dict_index_is_clust(index)) { + prebuilt->index_usable = FALSE; + row_mysql_lock_data_dictionary(prebuilt->trx); + dict_set_corrupted(index, prebuilt->trx, "dict_set_index_corrupted");; + row_mysql_unlock_data_dictionary(prebuilt->trx); + }); + if (UNIV_UNLIKELY(!prebuilt->index_usable)) { innobase_format_name( index_name, sizeof index_name, @@ -17585,7 +17647,7 @@ static char* srv_buffer_pool_evict; Evict all uncompressed pages of compressed tables from the buffer pool. Keep the compressed pages in the buffer pool. @return whether all uncompressed pages were evicted */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) bool innodb_buffer_pool_evict_uncompressed(void) /*=======================================*/ @@ -17930,13 +17992,13 @@ void purge_run_now_set( /*==============*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -17953,13 +18015,13 @@ void purge_stop_now_set( /*===============*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -17975,13 +18037,13 @@ void checkpoint_now_set( /*===============*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -18002,13 +18064,13 @@ void buf_flush_list_now_set( /*===================*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -18105,13 +18167,13 @@ void buffer_pool_dump_now( /*=================*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 107e90b1080..478187e0b23 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -462,7 +462,7 @@ enum durability_properties thd_get_durability_property(const MYSQL_THD thd); @return True if sql_mode has strict mode (all or trans), false otherwise. */ bool thd_is_strict_mode(const MYSQL_THD thd) -__attribute__((nonnull)); +MY_ATTRIBUTE((nonnull)); } /* extern "C" */ /** Get the file name and position of the MySQL binlog corresponding to the @@ -507,7 +507,7 @@ innobase_index_name_is_reserved( const KEY* key_info, /*!< in: Indexes to be created */ ulint num_of_keys) /*!< in: Number of indexes to be created. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** #ifdef WITH_WSREP @@ -527,7 +527,7 @@ innobase_table_flags( outside system tablespace */ ulint* flags, /*!< out: DICT_TF flags */ ulint* flags2) /*!< out: DICT_TF2 flags */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Validates the create options. We may build on this function @@ -544,7 +544,7 @@ create_options_are_invalid( columns and indexes */ HA_CREATE_INFO* create_info, /*!< in: create info. */ bool use_tablespace) /*!< in: srv_file_per_table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Retrieve the FTS Relevance Ranking result for doc with doc_id @@ -574,7 +574,7 @@ void innobase_fts_close_ranking( /*=======================*/ FT_INFO* fts_hdl) /*!< in: FTS handler */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*****************************************************************//** Initialize the table FTS stopword list @return TRUE if success */ @@ -585,7 +585,7 @@ innobase_fts_load_stopword( dict_table_t* table, /*!< in: Table has the FTS */ trx_t* trx, /*!< in: transaction */ THD* thd) /*!< in: current thread */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /** Some defines for innobase_fts_check_doc_id_index() return value */ enum fts_doc_id_index_enum { @@ -607,7 +607,7 @@ innobase_fts_check_doc_id_index( that is being altered */ ulint* fts_doc_col_no) /*!< out: The column number for Doc ID */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME @@ -620,7 +620,7 @@ innobase_fts_check_doc_id_index_in_def( /*===================================*/ ulint n_key, /*!< in: Number of keys */ const KEY* key_info) /*!< in: Key definitions */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************** @return version of the extended FTS API */ diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index f5db3775909..5385c7ab920 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates -Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates +Copyright (c) 2013, 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 @@ -101,7 +101,7 @@ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ALTER_NOREBUILD | Alter_inplace_info::ALTER_COLUMN_NAME; /* Report an InnoDB error to the client by invoking my_error(). */ -static UNIV_COLD __attribute__((nonnull)) +static UNIV_COLD MY_ATTRIBUTE((nonnull)) void my_error_innodb( /*============*/ @@ -203,7 +203,7 @@ Determine if ALTER TABLE needs to rebuild the table. @param ha_alter_info the DDL operation @param altered_table MySQL original table @return whether it is necessary to rebuild the table */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_need_rebuild( /*==================*/ @@ -230,7 +230,7 @@ innobase_need_rebuild( & Alter_inplace_info::ADD_INDEX) || (ha_alter_info->handler_flags & Alter_inplace_info::ADD_FOREIGN_KEY))) { - for (ulint i = 0; i < ha_alter_info->key_count; i++) { + for (ulint i = 0; i < ha_alter_info->index_add_count; i++) { const KEY* key = &ha_alter_info->key_info_buffer[ ha_alter_info->index_add_buffer[i]]; @@ -241,13 +241,13 @@ innobase_need_rebuild( /* Field used on added index is renamed on this same alter table. We need table rebuild. */ - if (field->flags & FIELD_IS_RENAMED) { + if (field && field->flags & FIELD_IS_RENAMED) { return (true); } } } } - + return(!!(ha_alter_info->handler_flags & INNOBASE_ALTER_REBUILD)); } @@ -646,7 +646,7 @@ ha_innobase::check_if_supported_inplace_alter( /*************************************************************//** Initialize the dict_foreign_t structure with supplied info @return true if added, false if duplicate foreign->id */ -static __attribute__((nonnull(1,3,5,7))) +static MY_ATTRIBUTE((nonnull(1,3,5,7))) bool innobase_init_foreign( /*==================*/ @@ -735,7 +735,7 @@ innobase_init_foreign( /*************************************************************//** Check whether the foreign key options is legit @return true if it is */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_check_fk_option( /*=====================*/ @@ -767,7 +767,7 @@ innobase_check_fk_option( /*************************************************************//** Set foreign key options @return true if successfully set */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_set_foreign_key_option( /*============================*/ @@ -812,7 +812,7 @@ innobase_set_foreign_key_option( Check if a foreign key constraint can make use of an index that is being created. @return useable index, or NULL if none found */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const KEY* innobase_find_equiv_index( /*======================*/ @@ -868,7 +868,7 @@ no_match: Find an index whose first fields are the columns in the array in the same order and is not marked for deletion @return matching index, NULL if not found */ -static __attribute__((nonnull(1,2,6), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,6), warn_unused_result)) dict_index_t* innobase_find_fk_index( /*===================*/ @@ -916,7 +916,7 @@ next_rec: Create InnoDB foreign key structure from MySQL alter_info @retval true if successful @retval false on error (will call my_error()) */ -static __attribute__((nonnull(1,2,3,7,8), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,7,8), warn_unused_result)) bool innobase_get_foreign_key_info( /*==========================*/ @@ -1416,7 +1416,7 @@ innobase_rec_reset( /*******************************************************************//** This function checks that index keys are sensible. @return 0 or error number */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int innobase_check_index_keys( /*======================*/ @@ -1537,7 +1537,7 @@ name_ok: /*******************************************************************//** Create index field definition for key part */ -static __attribute__((nonnull(2,3))) +static MY_ATTRIBUTE((nonnull(2,3))) void innobase_create_index_field_def( /*============================*/ @@ -1586,7 +1586,7 @@ innobase_create_index_field_def( /*******************************************************************//** Create index definition for key */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_create_index_def( /*======================*/ @@ -1876,7 +1876,7 @@ ELSE ENDIF @return key definitions */ -static __attribute__((nonnull, warn_unused_result, malloc)) +static MY_ATTRIBUTE((nonnull, warn_unused_result, malloc)) index_def_t* innobase_create_key_defs( /*=====================*/ @@ -2100,7 +2100,7 @@ created_clustered: /*******************************************************************//** Check each index column size, make sure they do not exceed the max limit @return true if index column size exceeds limit */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_check_column_length( /*=========================*/ @@ -2250,7 +2250,7 @@ online_retry_drop_indexes_low( /********************************************************************//** Drop any indexes that we were not able to free previously due to open table handles. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void online_retry_drop_indexes( /*======================*/ @@ -2280,7 +2280,7 @@ online_retry_drop_indexes( /********************************************************************//** Commit a dictionary transaction and drop any indexes that we were not able to free previously due to open table handles. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void online_retry_drop_indexes_with_trx( /*===============================*/ @@ -2309,7 +2309,7 @@ online_retry_drop_indexes_with_trx( @param drop_fk constraints being dropped @param n_drop_fk number of constraints that are being dropped @return whether the constraint is being dropped */ -inline __attribute__((pure, nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) bool innobase_dropping_foreign( /*======================*/ @@ -2336,7 +2336,7 @@ column that is being dropped or modified to NOT NULL. @retval true Not allowed (will call my_error()) @retval false Allowed */ -static __attribute__((pure, nonnull, warn_unused_result)) +static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) bool innobase_check_foreigns_low( /*========================*/ @@ -2436,7 +2436,7 @@ column that is being dropped or modified to NOT NULL. @retval true Not allowed (will call my_error()) @retval false Allowed */ -static __attribute__((pure, nonnull, warn_unused_result)) +static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) bool innobase_check_foreigns( /*====================*/ @@ -2481,7 +2481,7 @@ innobase_check_foreigns( @param dfield InnoDB data field to copy to @param field MySQL value for the column @param comp nonzero if in compact format */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_build_col_map_add( /*=======================*/ @@ -2515,7 +2515,7 @@ adding columns. @param heap Memory heap where allocated @return array of integers, mapping column numbers in the table to column numbers in altered_table */ -static __attribute__((nonnull(1,2,3,4,5,7), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,4,5,7), warn_unused_result)) const ulint* innobase_build_col_map( /*===================*/ @@ -2665,7 +2665,7 @@ innobase_drop_fts_index_table( @param user_table InnoDB table as it is before the ALTER operation @param heap Memory heap for the allocation @return array of new column names in rebuilt_table, or NULL if not renamed */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const char** innobase_get_col_names( Alter_inplace_info* ha_alter_info, @@ -2728,7 +2728,7 @@ while preparing ALTER TABLE. @retval true Failure @retval false Success */ -static __attribute__((warn_unused_result, nonnull(1,2,3,4))) +static MY_ATTRIBUTE((warn_unused_result, nonnull(1,2,3,4))) bool prepare_inplace_alter_table_dict( /*=============================*/ @@ -3382,7 +3382,7 @@ err_exit: /* Check whether an index is needed for the foreign key constraint. If so, if it is dropped, is there an equivalent index can play its role. @return true if the index is needed and can't be dropped */ -static __attribute__((nonnull(1,2,3,5), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,5), warn_unused_result)) bool innobase_check_foreign_key_index( /*=============================*/ @@ -3926,6 +3926,24 @@ check_if_can_drop_indexes: drop_index = NULL; } + /* Check if any of the existing indexes are marked as corruption + and if they are, refuse adding more indexes. */ + if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) { + for (dict_index_t* index = dict_table_get_first_index(indexed_table); + index != NULL; index = dict_table_get_next_index(index)) { + + if (!index->to_be_dropped && dict_index_is_corrupted(index)) { + char index_name[MAX_FULL_NAME_LEN + 1]; + + innobase_format_name(index_name, sizeof index_name, + index->name, TRUE); + + my_error(ER_INDEX_CORRUPT, MYF(0), index_name); + DBUG_RETURN(true); + } + } + } + n_add_fk = 0; if (ha_alter_info->handler_flags @@ -4296,7 +4314,7 @@ temparary index prefix @param locked TRUE=table locked, FALSE=may need to do a lazy drop @param trx the transaction */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_rollback_sec_index( /*========================*/ @@ -4330,7 +4348,7 @@ during prepare, but might not be during commit). @retval true Failure @retval false Success */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool rollback_inplace_alter_table( /*=========================*/ @@ -4462,7 +4480,7 @@ func_exit: @param foreign_id Foreign key constraint identifier @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_drop_foreign_try( /*======================*/ @@ -4519,7 +4537,7 @@ innobase_drop_foreign_try( @param new_clustered whether the table has been rebuilt @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_rename_column_try( /*=======================*/ @@ -4728,7 +4746,7 @@ rename_foreign: @param table_name Table name in MySQL @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_rename_columns_try( /*========================*/ @@ -4778,7 +4796,7 @@ as part of commit_cache_norebuild(). @param ha_alter_info Data used during in-place alter. @param table the TABLE @param user_table InnoDB table that was being altered */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_rename_columns_cache( /*==========================*/ @@ -4822,7 +4840,7 @@ processed_field: @param altered_table MySQL table that is being altered @param old_table MySQL table as it is before the ALTER operation @return the next auto-increment value (0 if not present) */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulonglong commit_get_autoinc( /*===============*/ @@ -4906,7 +4924,7 @@ but do not touch the data dictionary cache. @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_update_foreign_try( /*========================*/ @@ -4990,7 +5008,7 @@ after the changes to data dictionary tables were committed. @param ctx In-place ALTER TABLE context @param user_thd MySQL connection @return InnoDB error code (should always be DB_SUCCESS) */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t innobase_update_foreign_cache( /*==========================*/ @@ -5075,7 +5093,7 @@ when rebuilding the table. @retval true Failure @retval false Success */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool commit_try_rebuild( /*===============*/ @@ -5237,7 +5255,7 @@ commit_try_rebuild( /** Apply the changes made during commit_try_rebuild(), to the data dictionary cache and the file system. @param ctx In-place ALTER TABLE context */ -inline __attribute__((nonnull)) +inline MY_ATTRIBUTE((nonnull)) void commit_cache_rebuild( /*=================*/ @@ -5332,7 +5350,7 @@ when not rebuilding the table. @retval true Failure @retval false Success */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool commit_try_norebuild( /*=================*/ @@ -5442,7 +5460,7 @@ after a successful commit_try_norebuild() call. @param trx Data dictionary transaction object (will be started and committed) @return whether all replacements were found for dropped indexes */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool commit_cache_norebuild( /*===================*/ diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 0bb10f435af..17b35f88188 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2015, Oracle and/or its affiliates. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. Copyrigth (c) 2014, 2016, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under @@ -2941,15 +2941,26 @@ i_s_fts_deleted_generic_fill( DBUG_RETURN(0); } - deleted = fts_doc_ids_create(); + /* Prevent DDL to drop fts aux tables. */ + rw_lock_s_lock(&dict_operation_lock); user_table = dict_table_open_on_name( fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); if (!user_table) { + rw_lock_s_unlock(&dict_operation_lock); + + DBUG_RETURN(0); + } else if (!dict_table_has_fts_index(user_table)) { + dict_table_close(user_table, FALSE, FALSE); + + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } + deleted = fts_doc_ids_create(); + trx = trx_allocate_for_background(); trx->op_info = "Select for FTS DELETE TABLE"; @@ -2977,6 +2988,8 @@ i_s_fts_deleted_generic_fill( dict_table_close(user_table, FALSE, FALSE); + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } @@ -3350,6 +3363,12 @@ i_s_fts_index_cache_fill( DBUG_RETURN(0); } + if (user_table->fts == NULL || user_table->fts->cache == NULL) { + dict_table_close(user_table, FALSE, FALSE); + + DBUG_RETURN(0); + } + cache = user_table->fts->cache; ut_a(cache); @@ -3784,10 +3803,15 @@ i_s_fts_index_table_fill( DBUG_RETURN(0); } + /* Prevent DDL to drop fts aux tables. */ + rw_lock_s_lock(&dict_operation_lock); + user_table = dict_table_open_on_name( fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); if (!user_table) { + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } @@ -3800,6 +3824,8 @@ i_s_fts_index_table_fill( dict_table_close(user_table, FALSE, FALSE); + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } @@ -3935,14 +3961,21 @@ i_s_fts_config_fill( fields = table->field; + /* Prevent DDL to drop fts aux tables. */ + rw_lock_s_lock(&dict_operation_lock); + user_table = dict_table_open_on_name( fts_internal_tbl_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); if (!user_table) { + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } else if (!dict_table_has_fts_index(user_table)) { dict_table_close(user_table, FALSE, FALSE); + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } @@ -3998,6 +4031,8 @@ i_s_fts_config_fill( dict_table_close(user_table, FALSE, FALSE); + rw_lock_s_unlock(&dict_operation_lock); + DBUG_RETURN(0); } diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 9e8d8659739..0a2140c4a29 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -670,7 +670,7 @@ byte* ibuf_parse_bitmap_init( /*===================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ buf_block_t* block, /*!< in: block or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ { @@ -2513,7 +2513,7 @@ ibuf_get_merge_page_nos_func( /*******************************************************************//** Get the matching records for space id. @return current rec or NULL */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const rec_t* ibuf_get_user_rec( /*===============*/ @@ -2535,7 +2535,7 @@ ibuf_get_user_rec( Reads page numbers for a space id from an ibuf tree. @return a lower limit for the combined volume of records which will be merged */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint ibuf_get_merge_pages( /*=================*/ @@ -2643,40 +2643,22 @@ ibuf_merge_pages( } /*********************************************************************//** -Get the table instance from the table id. -@return table instance */ -static __attribute__((warn_unused_result)) -dict_table_t* -ibuf_get_table( -/*===========*/ - table_id_t table_id) /*!< in: valid table id */ -{ - rw_lock_s_lock_func(&dict_operation_lock, 0, __FILE__, __LINE__); - - dict_table_t* table = dict_table_open_on_id( - table_id, FALSE, DICT_TABLE_OP_NORMAL); - - rw_lock_s_unlock_gen(&dict_operation_lock, 0); - - return(table); -} - -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. -@return a lower limit for the combined size in bytes of entries which -will be merged from ibuf trees to the pages read, 0 if ibuf is -empty */ -static +Contracts insert buffer trees by reading pages referring to space_id +to the buffer pool. +@returns number of pages merged.*/ +UNIV_INTERN ulint ibuf_merge_space( /*=============*/ - ulint space, /*!< in: tablespace id to merge */ - ulint* n_pages)/*!< out: number of pages to which merged */ + ulint space) /*!< in: tablespace id to merge */ { mtr_t mtr; btr_pcur_t pcur; mem_heap_t* heap = mem_heap_create(512); dtuple_t* tuple = ibuf_search_tuple_build(space, 0, heap); + ulint n_pages = 0; + + ut_ad(space < SRV_LOG_SPACE_FIRST_ID); ibuf_mtr_start(&mtr); @@ -2708,50 +2690,47 @@ ibuf_merge_space( } else { sum_sizes = ibuf_get_merge_pages( - &pcur, space, IBUF_MAX_N_PAGES_MERGED, - &pages[0], &spaces[0], &versions[0], n_pages, - &mtr); + &pcur, space, IBUF_MAX_N_PAGES_MERGED, + &pages[0], &spaces[0], &versions[0], &n_pages, + &mtr); + ib_logf(IB_LOG_LEVEL_INFO,"\n Size of pages merged %lu" + ,sum_sizes); - ++sum_sizes; } ibuf_mtr_commit(&mtr); btr_pcur_close(&pcur); - if (sum_sizes > 0) { - - ut_a(*n_pages > 0 || sum_sizes == 1); + if (n_pages > 0) { #ifdef UNIV_DEBUG - ut_ad(*n_pages <= UT_ARR_SIZE(pages)); + ut_ad(n_pages <= UT_ARR_SIZE(pages)); - for (ulint i = 0; i < *n_pages; ++i) { + for (ulint i = 0; i < n_pages; ++i) { ut_ad(spaces[i] == space); ut_ad(i == 0 || versions[i] == versions[i - 1]); } #endif /* UNIV_DEBUG */ buf_read_ibuf_merge_pages( - true, spaces, versions, pages, *n_pages); + true, spaces, versions, pages, n_pages); } - return(sum_sizes); + return(n_pages); } -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[out] n_pages number of pages merged +@param[in] sync whether the caller waits for +the issued reads to complete @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint ibuf_merge( /*=======*/ - table_id_t table_id, /*!< in: if merge should be - done only for a specific - table, for all tables this - should be 0 */ ulint* n_pages, /*!< out: number of pages to which merged */ bool sync) /*!< in: TRUE if the caller @@ -2759,8 +2738,6 @@ ibuf_merge( read with the highest tablespace address to complete */ { - dict_table_t* table; - *n_pages = 0; /* We perform a dirty read of ibuf->empty, without latching @@ -2774,55 +2751,45 @@ ibuf_merge( } else if (ibuf_debug) { return(0); #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - } else if (table_id == 0) { + } else { return(ibuf_merge_pages(n_pages, sync)); - } else if ((table = ibuf_get_table(table_id)) == 0) { - /* Table has been dropped. */ - return(0); } - - ulint volume = ibuf_merge_space(table->space, n_pages); - - dict_table_close(table, FALSE, FALSE); - - return(volume); } -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[in] sync whether the caller waits for +the issued reads to complete @return a lower limit for the combined size in bytes of entries which -will be merged from ibuf trees to the pages read, 0 if ibuf is -empty */ +will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ static ulint ibuf_contract( /*==========*/ - ibool sync) /*!< in: TRUE if the caller wants to wait for the + bool sync) /*!< in: TRUE if the caller wants to wait for the issued read with the highest tablespace address to complete */ { ulint n_pages; - return(ibuf_merge(0, &n_pages, sync)); + return(ibuf_merge_pages(&n_pages, sync)); } -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[in] full If true, do a full contraction based +on PCT_IO(100). If false, the size of contract batch is determined +based on the current size of the change buffer. @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ UNIV_INTERN ulint -ibuf_contract_in_background( -/*========================*/ - table_id_t table_id, /*!< in: if merge should be done only - for a specific table, for all tables - this should be 0 */ - ibool full) /*!< in: TRUE if the caller wants to - do a full contract based on PCT_IO(100). - If FALSE then the size of contract - batch is determined based on the - current size of the ibuf tree. */ +ibuf_merge_in_background( +/*=====================*/ + bool full) /*!< in: TRUE if the caller wants to + do a full contract based on PCT_IO(100). + If FALSE then the size of contract + batch is determined based on the + current size of the ibuf tree. */ { ulint sum_bytes = 0; ulint sum_pages = 0; @@ -2830,7 +2797,7 @@ ibuf_contract_in_background( ulint n_pages; #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - if (srv_ibuf_disable_background_merge && table_id == 0) { + if (srv_ibuf_disable_background_merge) { return(0); } #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ @@ -2867,7 +2834,7 @@ ibuf_contract_in_background( while (sum_pages < n_pages) { ulint n_bytes; - n_bytes = ibuf_merge(table_id, &n_pag2, FALSE); + n_bytes = ibuf_merge(&n_pag2, false); if (n_bytes == 0) { return(sum_bytes); @@ -3471,7 +3438,7 @@ ibuf_get_entry_counter_func( Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible. @return DB_SUCCESS, DB_STRONG_FAIL or other error */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t ibuf_insert_low( /*============*/ @@ -3538,8 +3505,7 @@ ibuf_insert_low( #ifdef UNIV_IBUF_DEBUG fputs("Ibuf too big\n", stderr); #endif - /* Use synchronous contract (== TRUE) */ - ibuf_contract(TRUE); + ibuf_contract(true); return(DB_STRONG_FAIL); } @@ -3962,7 +3928,7 @@ skip_watch: During merge, inserts to an index page a secondary index entry extracted from the insert buffer. @return newly inserted record */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) rec_t* ibuf_insert_to_index_page_low( /*==========================*/ @@ -4393,7 +4359,7 @@ ibuf_delete( /*********************************************************************//** Restores insert buffer tree cursor position @return TRUE if the position was restored; FALSE if not */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) ibool ibuf_restore_pos( /*=============*/ @@ -4448,7 +4414,7 @@ Deletes from ibuf the record on which pcur is positioned. If we have to resort to a pessimistic delete, this function commits mtr and closes the cursor. @return TRUE if mtr was committed and pcur closed in this operation */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool ibuf_delete_rec( /*============*/ diff --git a/storage/innobase/include/api0api.h b/storage/innobase/include/api0api.h index e4c9c941de5..500bf4fe3b2 100644 --- a/storage/innobase/include/api0api.h +++ b/storage/innobase/include/api0api.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -36,7 +36,7 @@ InnoDB Native API #endif #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER) -#define UNIV_NO_IGNORE __attribute__ ((warn_unused_result)) +#define UNIV_NO_IGNORE MY_ATTRIBUTE ((warn_unused_result)) #else #define UNIV_NO_IGNORE #endif /* __GNUC__ && __GNUC__ > 2 && !__INTEL_COMPILER */ diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 95ce104e7ea..bf3f4a76301 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2014, 2015, MariaDB Corporation. All Rights Reserved. @@ -115,7 +115,7 @@ btr_corruption_report( /*==================*/ const buf_block_t* block, /*!< in: corrupted block */ const dict_index_t* index) /*!< in: index tree */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /** Assert that a B-tree page is not corrupted. @param block buffer block containing a B-tree page @@ -157,7 +157,7 @@ btr_blob_dbg_add_blob( ulint page_no, /*!< in: start page of the column */ dict_index_t* index, /*!< in/out: index tree */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Display the references to off-page columns. This function is to be called from a debugger, @@ -167,7 +167,7 @@ void btr_blob_dbg_print( /*===============*/ const dict_index_t* index) /*!< in: index tree */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Check that there are no references to off-page columns from or to the given page. Invoked when freeing or clearing a page. @@ -178,7 +178,7 @@ btr_blob_dbg_is_empty( /*==================*/ dict_index_t* index, /*!< in: index */ ulint page_no) /*!< in: page number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Modify the 'deleted' flag of a record. */ @@ -190,7 +190,7 @@ btr_blob_dbg_set_deleted_flag( dict_index_t* index, /*!< in/out: index */ const ulint* offsets,/*!< in: rec_get_offs(rec, index) */ ibool del) /*!< in: TRUE=deleted, FALSE=exists */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Change the ownership of an off-page column. */ UNIV_INTERN @@ -202,7 +202,7 @@ btr_blob_dbg_owner( const ulint* offsets,/*!< in: rec_get_offs(rec, index) */ ulint i, /*!< in: ith field in rec */ ibool own) /*!< in: TRUE=owned, FALSE=disowned */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Assert that there are no BLOB references to or from the given page. */ # define btr_blob_dbg_assert_empty(index, page_no) \ ut_a(btr_blob_dbg_is_empty(index, page_no)) @@ -222,7 +222,7 @@ btr_root_get( /*=========*/ const dict_index_t* index, /*!< in: index tree */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Checks and adjusts the root node of a tree during IMPORT TABLESPACE. @@ -232,7 +232,7 @@ dberr_t btr_root_adjust_on_import( /*======================*/ const dict_index_t* index) /*!< in: index tree */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Gets the height of the B-tree (the level of the root, when the leaf @@ -245,7 +245,7 @@ btr_height_get( /*===========*/ dict_index_t* index, /*!< in: index tree */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Gets a buffer page and declares its latching order level. */ UNIV_INLINE @@ -307,7 +307,7 @@ index_id_t btr_page_get_index_id( /*==================*/ const page_t* page) /*!< in: index page */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #ifndef UNIV_HOTBACKUP /********************************************************//** Gets the node level field in an index page. @@ -317,7 +317,7 @@ ulint btr_page_get_level_low( /*===================*/ const page_t* page) /*!< in: index page */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #define btr_page_get_level(page, mtr) btr_page_get_level_low(page) /********************************************************//** Gets the next index page number. @@ -328,7 +328,7 @@ btr_page_get_next( /*==============*/ const page_t* page, /*!< in: index page */ mtr_t* mtr) /*!< in: mini-transaction handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************//** Gets the previous index page number. @return prev page number */ @@ -338,7 +338,7 @@ btr_page_get_prev( /*==============*/ const page_t* page, /*!< in: index page */ mtr_t* mtr) /*!< in: mini-transaction handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Gets pointer to the previous user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor. @@ -350,7 +350,7 @@ btr_get_prev_user_rec( rec_t* rec, /*!< in: record on leaf level */ mtr_t* mtr) /*!< in: mtr holding a latch on the page, and if needed, also to the previous page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Gets pointer to the next user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor. @@ -362,7 +362,7 @@ btr_get_next_user_rec( rec_t* rec, /*!< in: record on leaf level */ mtr_t* mtr) /*!< in: mtr holding a latch on the page, and if needed, also to the next page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Releases the latch on a leaf page and bufferunfixes it. */ UNIV_INLINE @@ -373,7 +373,7 @@ btr_leaf_page_release( ulint latch_mode, /*!< in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Gets the child node file address in a node pointer. NOTE: the offsets array must contain all offsets for the record since @@ -387,7 +387,7 @@ btr_node_ptr_get_child_page_no( /*===========================*/ const rec_t* rec, /*!< in: node pointer record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /************************************************************//** Creates the root node for a new index tree. @return page number of the created root, FIL_NULL if did not succeed */ @@ -402,7 +402,7 @@ btr_create( index_id_t index_id,/*!< in: index id */ dict_index_t* index, /*!< in: index */ mtr_t* mtr) /*!< in: mini-transaction handle */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Frees a B-tree except the root page, which MUST be freed after this by calling btr_free_root. */ @@ -425,7 +425,7 @@ btr_free_root( or 0 for uncompressed pages */ ulint root_page_no, /*!< in: root page number */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. @@ -474,7 +474,7 @@ btr_page_reorganize_low( page_cur_t* cursor, /*!< in/out: page cursor */ dict_index_t* index, /*!< in: the index tree of the page */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Reorganizes an index page. @@ -493,7 +493,7 @@ btr_page_reorganize( page_cur_t* cursor, /*!< in/out: page cursor */ dict_index_t* index, /*!< in: the index tree of the page */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Decides if the page should be split at the convergence point of inserts converging to left. @@ -506,7 +506,7 @@ btr_page_get_split_rec_to_left( rec_t** split_rec)/*!< out: if split recommended, the first record on upper half page, or NULL if tuple should be first */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Decides if the page should be split at the convergence point of inserts converging to right. @@ -519,7 +519,7 @@ btr_page_get_split_rec_to_right( rec_t** split_rec)/*!< out: if split recommended, the first record on upper half page, or NULL if tuple should be first */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is @@ -558,7 +558,7 @@ btr_insert_on_non_leaf_level_func( const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); # define btr_insert_on_non_leaf_level(f,i,l,t,m) \ btr_insert_on_non_leaf_level_func(f,i,l,t,__FILE__,__LINE__,m) #endif /* !UNIV_HOTBACKUP */ @@ -570,7 +570,7 @@ btr_set_min_rec_mark( /*=================*/ rec_t* rec, /*!< in/out: record */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /*************************************************************//** Deletes on the upper level the node pointer to a page. */ @@ -581,7 +581,7 @@ btr_node_ptr_delete( dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: page whose node pointer is deleted */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /************************************************************//** Checks that the node pointer to a page is appropriate. @@ -593,7 +593,7 @@ btr_check_node_ptr( dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: index page */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /*************************************************************//** Tries to merge the page first to the left immediate brother if such a @@ -616,7 +616,7 @@ btr_compress( ibool adjust, /*!< in: TRUE if should adjust the cursor position even if compression occurs */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Discards a page from a B-tree. This is used to remove the last record from a B-tree page: the whole page must be removed at the same time. This cannot @@ -628,7 +628,7 @@ btr_discard_page( btr_cur_t* cursor, /*!< in: cursor on the page to discard: not on the root page */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /****************************************************************//** Parses the redo log record for setting an index record as the predefined @@ -643,7 +643,7 @@ btr_parse_set_min_rec_mark( ulint comp, /*!< in: nonzero=compact page format */ page_t* page, /*!< in: page or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ - __attribute__((nonnull(1,2), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2), warn_unused_result)); /***********************************************************//** Parses a redo log record of reorganizing a page. @return end of log record or NULL */ @@ -657,7 +657,7 @@ btr_parse_page_reorganize( bool compressed,/*!< in: true if compressed page */ buf_block_t* block, /*!< in: page to be reorganized, or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ - __attribute__((nonnull(1,2,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3), warn_unused_result)); #ifndef UNIV_HOTBACKUP /**************************************************************//** Gets the number of pages in a B-tree. @@ -670,7 +670,7 @@ btr_get_size( ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ mtr_t* mtr) /*!< in/out: mini-transaction where index is s-latched */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Gets the number of reserved and used pages in a B-tree. @return number of pages reserved, or ULINT_UNDEFINED if the index @@ -708,7 +708,7 @@ btr_page_alloc( mtr_t* init_mtr) /*!< in/out: mini-transaction for x-latching and initializing the page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Frees a file page used in an index tree. NOTE: cannot free field external storage pages because the page must contain info on its level. */ @@ -719,7 +719,7 @@ btr_page_free( dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: block to be freed, x-latched */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Frees a file page used in an index tree. Can be used also to BLOB external storage pages, because the page level 0 can be given as an @@ -769,7 +769,7 @@ void btr_print_size( /*===========*/ dict_index_t* index) /*!< in: index tree */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Prints directories and other info of all nodes in the index. */ UNIV_INTERN @@ -779,7 +779,7 @@ btr_print_index( dict_index_t* index, /*!< in: index */ ulint width) /*!< in: print this many entries from start and end */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* UNIV_BTR_PRINT */ /************************************************************//** Checks the size and number of fields in a record based on the definition of @@ -794,7 +794,7 @@ btr_index_rec_validate( ibool dump_on_error) /*!< in: TRUE if the function should print hex dump of record and page on error */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Checks the consistency of an index tree. @return DB_SUCCESS if ok, error code if not */ @@ -804,7 +804,7 @@ btr_validate_index( /*===============*/ dict_index_t* index, /*!< in: index */ const trx_t* trx) /*!< in: transaction or 0 */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); #ifdef UNIV_SYNC_DEBUG /*************************************************************//** diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index 5fc621f469d..64b3d5a0975 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2016, MariaDB Corporation. 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 @@ -165,10 +165,11 @@ ulint btr_page_get_next( /*==============*/ const page_t* page, /*!< in: index page */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); #ifndef UNIV_INNOCHECKSUM ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX) || mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX)); @@ -188,7 +189,8 @@ btr_page_set_next( ulint next, /*!< in: next page number */ mtr_t* mtr) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); if (page_zip) { mach_write_to_4(page + FIL_PAGE_NEXT, next); @@ -206,9 +208,10 @@ ulint btr_page_get_prev( /*==============*/ const page_t* page, /*!< in: index page */ - mtr_t* mtr __attribute__((unused))) /*!< in: mini-transaction handle */ + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); return(mach_read_from_4(page + FIL_PAGE_PREV)); } @@ -225,7 +228,8 @@ btr_page_set_prev( ulint prev, /*!< in: previous page number */ mtr_t* mtr) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); if (page_zip) { mach_write_to_4(page + FIL_PAGE_PREV, prev); diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 88e3b84e04b..aa799e0fc00 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -186,7 +186,7 @@ btr_cur_open_at_index_side_func( const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define btr_cur_open_at_index_side(f,i,l,c,lv,m) \ btr_cur_open_at_index_side_func(f,i,l,c,lv,__FILE__,__LINE__,m) /**********************************************************************//** @@ -235,7 +235,7 @@ btr_cur_optimistic_insert( compressed tablespace, the caller must mtr_commit(mtr) before latching any further pages */ - __attribute__((nonnull(2,3,4,5,6,7,10), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3,4,5,6,7,10), warn_unused_result)); /*************************************************************//** Performs an insert on a page of an index tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the insert is @@ -266,7 +266,7 @@ btr_cur_pessimistic_insert( ulint n_ext, /*!< in: number of externally stored columns */ que_thr_t* thr, /*!< in: query thread or NULL */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull(2,3,4,5,6,7,10), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3,4,5,6,7,10), warn_unused_result)); /*************************************************************//** See if there is enough place in the page modification log to log an update-in-place. @@ -293,7 +293,7 @@ btr_cur_update_alloc_zip_func( bool create, /*!< in: true=delete-and-insert, false=update-in-place */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG # define btr_cur_update_alloc_zip(page_zip,cursor,index,offsets,len,cr,mtr) \ btr_cur_update_alloc_zip_func(page_zip,cursor,index,offsets,len,cr,mtr) @@ -325,7 +325,7 @@ btr_cur_update_in_place( is a secondary index, the caller must mtr_commit(mtr) before latching any further pages */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /***********************************************************//** Writes a redo log record of updating a record in-place. */ UNIV_INTERN @@ -339,7 +339,7 @@ btr_cur_update_in_place_log( trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr, /*!< in: roll ptr */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Tries to update a record on a page in an index tree. It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too @@ -371,7 +371,7 @@ btr_cur_optimistic_update( is a secondary index, the caller must mtr_commit(mtr) before latching any further pages */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /*************************************************************//** Performs an update of a record on a page of a tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the @@ -405,7 +405,7 @@ btr_cur_pessimistic_update( trx_id_t trx_id, /*!< in: transaction id */ mtr_t* mtr) /*!< in/out: mini-transaction; must be committed before latching any further pages */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /***********************************************************//** Marks a clustered index record deleted. Writes an undo log record to undo log on this delete marking. Writes in the trx id field the id @@ -422,7 +422,7 @@ btr_cur_del_mark_set_clust_rec( const ulint* offsets,/*!< in: rec_get_offsets(rec) */ que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************//** Sets a secondary index record delete mark to TRUE or FALSE. @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ @@ -435,7 +435,7 @@ btr_cur_del_mark_set_sec_rec( ibool val, /*!< in: value to set */ que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Tries to compress a page of the tree if it seems useful. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid @@ -453,7 +453,7 @@ btr_cur_compress_if_useful( ibool adjust, /*!< in: TRUE if should adjust the cursor position even if compression occurs */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************//** Removes the record on which the tree cursor is positioned. It is assumed that the mtr has an x-latch on the page where the cursor is positioned, @@ -474,7 +474,7 @@ btr_cur_optimistic_delete_func( TRUE on a leaf page of a secondary index, the mtr must be committed before latching any further pages */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # ifdef UNIV_DEBUG # define btr_cur_optimistic_delete(cursor, flags, mtr) \ btr_cur_optimistic_delete_func(cursor, flags, mtr) @@ -510,7 +510,7 @@ btr_cur_pessimistic_delete( ulint flags, /*!< in: BTR_CREATE_FLAG or 0 */ enum trx_rb_ctx rb_ctx, /*!< in: rollback context */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Parses a redo log record of updating a record in-place. @@ -604,7 +604,7 @@ btr_cur_disown_inherited_fields( const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ const upd_t* update, /*!< in: update vector */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull(2,3,4,5,6))); + MY_ATTRIBUTE((nonnull(2,3,4,5,6))); /** Operation code for btr_store_big_rec_extern_fields(). */ enum blob_op { @@ -624,7 +624,7 @@ ibool btr_blob_op_is_update( /*==================*/ enum blob_op op) /*!< in: operation */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** Stores the fields in big_rec_vec to the tablespace and puts pointers to @@ -649,7 +649,7 @@ btr_store_big_rec_extern_fields( mtr_t* btr_mtr, /*!< in: mtr containing the latches to the clustered index */ enum blob_op op) /*! in: operation code */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Frees the space in an externally stored field to the file space @@ -746,7 +746,7 @@ btr_push_update_extern_fields( dtuple_t* tuple, /*!< in/out: data tuple */ const upd_t* update, /*!< in: update vector */ mem_heap_t* heap) /*!< in: memory heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Sets a secondary index record's delete mark to the given value. This function is only used by the insert buffer merge mechanism. */ diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index d8e7cf6b283..dafe14ce556 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -155,7 +155,7 @@ btr_pcur_open_at_index_side( ulint level, /*!< in: level to search for (0=leaf) */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Gets the up_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index 848bde451a0..c95ca28057a 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -69,7 +69,7 @@ btr_search_t* btr_search_get_info( /*================*/ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*****************************************************************//** Creates and initializes a search info struct. @return own: search info struct */ diff --git a/storage/innobase/include/btr0types.h b/storage/innobase/include/btr0types.h index c1a4531f861..04b69d8145c 100644 --- a/storage/innobase/include/btr0types.h +++ b/storage/innobase/include/btr0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -81,7 +81,7 @@ btr_blob_dbg_rbt_insert( dict_index_t* index, /*!< in/out: index tree */ const btr_blob_dbg_t* b, /*!< in: the reference */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Remove from index->blobs a reference to an off-page column. @param index the index tree @@ -94,7 +94,7 @@ btr_blob_dbg_rbt_delete( dict_index_t* index, /*!< in/out: index tree */ const btr_blob_dbg_t* b, /*!< in: the reference */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Add to index->blobs any references to off-page columns from a record. @@ -107,7 +107,7 @@ btr_blob_dbg_add_rec( dict_index_t* index, /*!< in/out: index */ const ulint* offsets,/*!< in: offsets */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Remove from index->blobs any references to off-page columns from a record. @return number of references removed */ @@ -119,7 +119,7 @@ btr_blob_dbg_remove_rec( dict_index_t* index, /*!< in/out: index */ const ulint* offsets,/*!< in: offsets */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Count and add to index->blobs any references to off-page columns from records on a page. @@ -131,7 +131,7 @@ btr_blob_dbg_add( const page_t* page, /*!< in: rewritten page */ dict_index_t* index, /*!< in/out: index */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Count and remove from index->blobs any references to off-page columns from records on a page. @@ -144,7 +144,7 @@ btr_blob_dbg_remove( const page_t* page, /*!< in: b-tree page */ dict_index_t* index, /*!< in/out: index */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Restore in index->blobs any references to off-page columns Used when page reorganize fails due to compressed page overflow. */ @@ -156,7 +156,7 @@ btr_blob_dbg_restore( const page_t* page, /*!< in: copy of original page */ dict_index_t* index, /*!< in/out: index */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Operation that processes the BLOB references of an index record @param[in] rec record on index page @@ -180,7 +180,7 @@ btr_blob_dbg_op( dict_index_t* index, /*!< in/out: index */ const char* ctx, /*!< in: context (for logging) */ const btr_blob_dbg_op_f op) /*!< in: operation on records */ - __attribute__((nonnull(1,3,4,5))); + MY_ATTRIBUTE((nonnull(1,3,4,5))); #else /* UNIV_BLOB_DEBUG */ # define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0) # define btr_blob_dbg_add(page, index, ctx) ((void) 0) diff --git a/storage/innobase/include/buf0buddy.h b/storage/innobase/include/buf0buddy.h index fab9a4b828b..7fc4408505d 100644 --- a/storage/innobase/include/buf0buddy.h +++ b/storage/innobase/include/buf0buddy.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -54,7 +54,7 @@ buf_buddy_alloc( storage was allocated from the LRU list and buf_pool->mutex was temporarily released */ - __attribute__((malloc, nonnull)); + MY_ATTRIBUTE((malloc, nonnull)); /**********************************************************************//** Deallocate a block. */ @@ -68,7 +68,7 @@ buf_buddy_free( be pointed to by the buffer pool */ ulint size) /*!< in: block size, up to UNIV_PAGE_SIZE */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_NONINL # include "buf0buddy.ic" diff --git a/storage/innobase/include/buf0buddy.ic b/storage/innobase/include/buf0buddy.ic index be2f950162d..4352ebe8945 100644 --- a/storage/innobase/include/buf0buddy.ic +++ b/storage/innobase/include/buf0buddy.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -50,7 +50,7 @@ buf_buddy_alloc_low( allocated from the LRU list and buf_pool->mutex was temporarily released */ - __attribute__((malloc, nonnull)); + MY_ATTRIBUTE((malloc, nonnull)); /**********************************************************************//** Deallocate a block. */ @@ -63,7 +63,7 @@ buf_buddy_free_low( pointed to by the buffer pool */ ulint i) /*!< in: index of buf_pool->zip_free[], or BUF_BUDDY_SIZES */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Get the index of buf_pool->zip_free[] for a given block size. diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 985bddd1317..c737f3a6f1d 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2015, MariaDB Corporation. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation. 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 @@ -256,7 +256,7 @@ buf_relocate( buf_page_get_state(bpage) must be BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */ buf_page_t* dpage) /*!< in/out: destination control block */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the current size of buffer buf_pool in bytes. @return size in bytes */ @@ -287,7 +287,7 @@ UNIV_INLINE buf_page_t* buf_page_alloc_descriptor(void) /*===========================*/ - __attribute__((malloc)); + MY_ATTRIBUTE((malloc)); /********************************************************************//** Free a buf_page_t descriptor. */ UNIV_INLINE @@ -295,7 +295,7 @@ void buf_page_free_descriptor( /*=====================*/ buf_page_t* bpage) /*!< in: bpage descriptor to free. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Allocates a buffer block. @@ -536,7 +536,7 @@ ulint buf_page_get_freed_page_clock( /*==========================*/ const buf_page_t* bpage) /*!< in: block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /********************************************************************//** Reads the freed_page_clock of a buffer block. @return freed_page_clock */ @@ -545,7 +545,7 @@ ulint buf_block_get_freed_page_clock( /*===========================*/ const buf_block_t* block) /*!< in: block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /********************************************************************//** Tells if a block is still close enough to the MRU end of the LRU list @@ -608,7 +608,7 @@ buf_block_buf_fix_inc_func( ulint line, /*!< in: line */ # endif /* UNIV_SYNC_DEBUG */ buf_block_t* block) /*!< in/out: block to bufferfix */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Increments the bufferfix count. */ @@ -654,7 +654,7 @@ buf_page_is_corrupted( const byte* read_buf, /*!< in: a database page */ ulint zip_size) /*!< in: size of compressed page; 0 for uncompressed pages */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Checks if a page is all zeroes. @return TRUE if the page is all zeroes */ @@ -684,7 +684,7 @@ ulint buf_block_get_lock_hash_val( /*========================*/ const buf_block_t* block) /*!< in: block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #ifdef UNIV_DEBUG /*********************************************************************//** Finds a block in the buffer pool that points to a @@ -745,7 +745,7 @@ buf_page_print( ulint flags) /*!< in: 0 or BUF_PAGE_PRINT_NO_CRASH or BUF_PAGE_PRINT_NO_FULL */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /********************************************************************//** Decompress a block. @return TRUE if successful */ @@ -882,7 +882,7 @@ enum buf_page_state buf_block_get_state( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Sets the state of a block. */ UNIV_INLINE @@ -907,7 +907,7 @@ ibool buf_page_in_file( /*=============*/ const buf_page_t* bpage) /*!< in: pointer to control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** Determines if a block should be on unzip_LRU list. @@ -917,7 +917,7 @@ ibool buf_page_belongs_to_unzip_LRU( /*==========================*/ const buf_page_t* bpage) /*!< in: pointer to control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the mutex of a block. @@ -927,7 +927,7 @@ ib_mutex_t* buf_page_get_mutex( /*===============*/ const buf_page_t* bpage) /*!< in: pointer to control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Get the flush type of a page. @@ -937,7 +937,7 @@ buf_flush_t buf_page_get_flush_type( /*====================*/ const buf_page_t* bpage) /*!< in: buffer page */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Set the flush type of a page. */ UNIV_INLINE @@ -963,7 +963,7 @@ enum buf_io_fix buf_page_get_io_fix( /*================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the io_fix state of a block. @return io_fix state */ @@ -972,7 +972,7 @@ enum buf_io_fix buf_block_get_io_fix( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Sets the io_fix state of a block. */ UNIV_INLINE @@ -1018,7 +1018,7 @@ ibool buf_page_can_relocate( /*==================*/ const buf_page_t* bpage) /*!< control block being relocated */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Determine if a block has been flagged old. @@ -1028,7 +1028,7 @@ ibool buf_page_is_old( /*============*/ const buf_page_t* bpage) /*!< in: control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Flag a block old. */ UNIV_INLINE @@ -1045,7 +1045,7 @@ unsigned buf_page_is_accessed( /*=================*/ const buf_page_t* bpage) /*!< in: control block */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************************//** Flag a block accessed. */ UNIV_INLINE @@ -1053,7 +1053,7 @@ void buf_page_set_accessed( /*==================*/ buf_page_t* bpage) /*!< in/out: control block */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the buf_block_t handle of a buffered file block if an uncompressed page frame exists, or NULL. Note: even though bpage is not declared a @@ -1064,7 +1064,7 @@ buf_block_t* buf_page_get_block( /*===============*/ buf_page_t* bpage) /*!< in: control block, or NULL */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG /*********************************************************************//** @@ -1075,7 +1075,7 @@ buf_frame_t* buf_block_get_frame( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #else /* UNIV_DEBUG */ # define buf_block_get_frame(block) (block)->frame #endif /* UNIV_DEBUG */ @@ -1087,7 +1087,7 @@ ulint buf_page_get_space( /*===============*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the space id of a block. @return space id */ @@ -1096,7 +1096,7 @@ ulint buf_block_get_space( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the page number of a block. @return page number */ @@ -1105,7 +1105,7 @@ ulint buf_page_get_page_no( /*=================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the page number of a block. @return page number */ @@ -1114,7 +1114,7 @@ ulint buf_block_get_page_no( /*==================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the compressed page size of a block. @return compressed page size, or 0 */ @@ -1123,7 +1123,7 @@ ulint buf_page_get_zip_size( /*==================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the compressed page size of a block. @return compressed page size, or 0 */ @@ -1132,7 +1132,7 @@ ulint buf_block_get_zip_size( /*===================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ @@ -1223,7 +1223,7 @@ buf_page_address_fold( /*==================*/ ulint space, /*!< in: space id */ ulint offset) /*!< in: offset of the page within space */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************************//** Calculates the index of a buffer pool to the buf_pool[] array. @return the position of the buffer pool in buf_pool[] */ @@ -1232,7 +1232,7 @@ ulint buf_pool_index( /*===========*/ const buf_pool_t* buf_pool) /*!< in: buffer pool */ - __attribute__((nonnull, const)); + MY_ATTRIBUTE((nonnull, const)); /******************************************************************//** Returns the buffer pool instance given a page instance @return buf_pool */ @@ -1372,7 +1372,7 @@ buf_pool_watch_is_sentinel( /*=======================*/ buf_pool_t* buf_pool, /*!< buffer pool instance */ const buf_page_t* bpage) /*!< in: block */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** Add watch for the given page to be read in. Caller must have the buffer pool @return NULL if watch set, block if the page is in the buffer pool */ @@ -1383,7 +1383,7 @@ buf_pool_watch_set( ulint space, /*!< in: space id */ ulint offset, /*!< in: page number */ ulint fold) /*!< in: buf_page_address_fold(space, offset) */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /****************************************************************//** Stop watching if the page has been read in. buf_pool_watch_set(space,offset) must have returned NULL before. */ @@ -1404,7 +1404,7 @@ buf_pool_watch_occurred( /*====================*/ ulint space, /*!< in: space id */ ulint offset) /*!< in: page number */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Get total buffer pool statistics. */ UNIV_INTERN diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index 5b66d65dcba..e77c5a84202 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -302,6 +302,20 @@ buf_page_set_state( ut_a(state == BUF_BLOCK_NOT_USED); break; case BUF_BLOCK_FILE_PAGE: + if (!(state == BUF_BLOCK_NOT_USED + || state == BUF_BLOCK_REMOVE_HASH)) { + const char *old_state_name = buf_get_state_name((buf_block_t*)bpage); + bpage->state = state; + + fprintf(stderr, + "InnoDB: Error: block old state %d (%s) " + " new state %d (%s) not correct\n", + old_state, + old_state_name, + state, + buf_get_state_name((buf_block_t*)bpage)); + } + ut_a(state == BUF_BLOCK_NOT_USED || state == BUF_BLOCK_REMOVE_HASH); break; diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index 3ab3f7c308a..f1ca1039ccb 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2014, SkySQL Ab. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2016, MariaDB Corporation 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 @@ -97,7 +97,7 @@ buf_flush_page_try( /*===============*/ buf_pool_t* buf_pool, /*!< in/out: buffer pool instance */ buf_block_t* block) /*!< in/out: buffer control block */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ /*******************************************************************//** This utility flushes dirty blocks from the end of the flush list of @@ -266,7 +266,7 @@ buf_flush_ready_for_flush( buf_page_t* bpage, /*!< in: buffer control block, must be buf_page_in_file(bpage) */ buf_flush_t flush_type)/*!< in: type of flush */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG /******************************************************************//** diff --git a/storage/innobase/include/buf0lru.h b/storage/innobase/include/buf0lru.h index f1f6abd2d68..a7a65df33aa 100644 --- a/storage/innobase/include/buf0lru.h +++ b/storage/innobase/include/buf0lru.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -93,7 +93,7 @@ buf_LRU_free_page( buf_page_t* bpage, /*!< in: block to be freed */ bool zip) /*!< in: true if should remove also the compressed page of an uncompressed page */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Try to free a replaceable block. @return TRUE if found and freed */ @@ -105,7 +105,7 @@ buf_LRU_scan_and_free_block( ibool scan_all) /*!< in: scan whole LRU list if TRUE, otherwise scan only 'old' blocks. */ - __attribute__((nonnull,warn_unused_result)); + MY_ATTRIBUTE((nonnull,warn_unused_result)); /******************************************************************//** Returns a free block from the buf_pool. The block is taken off the free list. If it is empty, returns NULL. @@ -144,7 +144,7 @@ buf_block_t* buf_LRU_get_free_block( /*===================*/ buf_pool_t* buf_pool) /*!< in/out: buffer pool instance */ - __attribute__((nonnull,warn_unused_result)); + MY_ATTRIBUTE((nonnull,warn_unused_result)); /******************************************************************//** Determines if the unzip_LRU list should be used for evicting a victim instead of the general LRU list. @@ -227,7 +227,7 @@ buf_LRU_free_one_page( buf_page_t* bpage) /*!< in/out: block, must contain a file page and be in a state where it can be freed; there may or may not be a hash index to the page */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Adjust LRU hazard pointers if needed. */ diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index a548c7b89b3..1d954bfc07c 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -46,7 +46,7 @@ dtype_t* dfield_get_type( /*============*/ const dfield_t* field) /*!< in: SQL data field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets pointer to the data in a field. @return pointer to data */ @@ -55,7 +55,7 @@ void* dfield_get_data( /*============*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ # define dfield_get_type(field) (&(field)->type) # define dfield_get_data(field) ((field)->data) @@ -68,7 +68,7 @@ dfield_set_type( /*============*/ dfield_t* field, /*!< in: SQL data field */ const dtype_t* type) /*!< in: pointer to data type struct */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets length of field data. @return length of data; UNIV_SQL_NULL if SQL null data */ @@ -77,7 +77,7 @@ ulint dfield_get_len( /*===========*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets length in a field. */ UNIV_INLINE @@ -86,7 +86,7 @@ dfield_set_len( /*===========*/ dfield_t* field, /*!< in: field */ ulint len) /*!< in: length or UNIV_SQL_NULL */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Determines if a field is SQL NULL @return nonzero if SQL null data */ @@ -95,7 +95,7 @@ ulint dfield_is_null( /*===========*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Determines if a field is externally stored @return nonzero if externally stored */ @@ -104,7 +104,7 @@ ulint dfield_is_ext( /*==========*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets the "external storage" flag */ UNIV_INLINE @@ -112,7 +112,7 @@ void dfield_set_ext( /*===========*/ dfield_t* field) /*!< in/out: field */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Sets pointer to the data and length in a field. */ UNIV_INLINE @@ -122,7 +122,7 @@ dfield_set_data( dfield_t* field, /*!< in: field */ const void* data, /*!< in: data */ ulint len) /*!< in: length or UNIV_SQL_NULL */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*********************************************************************//** Sets a data field to SQL NULL. */ UNIV_INLINE @@ -130,7 +130,7 @@ void dfield_set_null( /*============*/ dfield_t* field) /*!< in/out: field */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Writes an SQL null field full of zeros. */ UNIV_INLINE @@ -139,7 +139,7 @@ data_write_sql_null( /*================*/ byte* data, /*!< in: pointer to a buffer of size len */ ulint len) /*!< in: SQL null size in bytes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies the data and len fields. */ UNIV_INLINE @@ -148,7 +148,7 @@ dfield_copy_data( /*=============*/ dfield_t* field1, /*!< out: field to copy to */ const dfield_t* field2) /*!< in: field to copy from */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies a data field to another. */ UNIV_INLINE @@ -157,7 +157,7 @@ dfield_copy( /*========*/ dfield_t* field1, /*!< out: field to copy to */ const dfield_t* field2) /*!< in: field to copy from */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies the data pointed to by a data field. */ UNIV_INLINE @@ -166,7 +166,7 @@ dfield_dup( /*=======*/ dfield_t* field, /*!< in/out: data field */ mem_heap_t* heap) /*!< in: memory heap where allocated */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** Tests if two data fields are equal. @@ -181,7 +181,7 @@ dfield_datas_are_binary_equal( const dfield_t* field2, /*!< in: field */ ulint len) /*!< in: maximum prefix to compare, or 0 to compare the whole field length */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Tests if dfield data length and content is equal to the given. @return TRUE if equal */ @@ -192,7 +192,7 @@ dfield_data_is_binary_equal( const dfield_t* field, /*!< in: field */ ulint len, /*!< in: data length or UNIV_SQL_NULL */ const byte* data) /*!< in: data */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************************//** Gets number of fields in a data tuple. @@ -202,7 +202,7 @@ ulint dtuple_get_n_fields( /*================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG /*********************************************************************//** Gets nth field of a tuple. @@ -224,7 +224,7 @@ ulint dtuple_get_info_bits( /*=================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets info bits in a data tuple. */ UNIV_INLINE @@ -233,7 +233,7 @@ dtuple_set_info_bits( /*=================*/ dtuple_t* tuple, /*!< in: tuple */ ulint info_bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets number of fields used in record comparisons. @return number of fields used in comparisons in rem0cmp.* */ @@ -242,7 +242,7 @@ ulint dtuple_get_n_fields_cmp( /*====================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets number of fields used in record comparisons. */ UNIV_INLINE @@ -252,7 +252,7 @@ dtuple_set_n_fields_cmp( dtuple_t* tuple, /*!< in: tuple */ ulint n_fields_cmp) /*!< in: number of fields used in comparisons in rem0cmp.* */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /* Estimate the number of bytes that are going to be allocated when creating a new dtuple_t object */ @@ -272,7 +272,7 @@ dtuple_create_from_mem( void* buf, /*!< in, out: buffer to use */ ulint buf_size, /*!< in: buffer size */ ulint n_fields) /*!< in: number of fields */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Creates a data tuple to a memory heap. The default value for number @@ -286,7 +286,7 @@ dtuple_create( is created, DTUPLE_EST_ALLOC(n_fields) bytes will be allocated from this heap */ ulint n_fields)/*!< in: number of fields */ - __attribute__((nonnull, malloc)); + MY_ATTRIBUTE((nonnull, malloc)); /*********************************************************************//** Sets number of fields used in a tuple. Normally this is set in @@ -297,7 +297,7 @@ dtuple_set_n_fields( /*================*/ dtuple_t* tuple, /*!< in: tuple */ ulint n_fields) /*!< in: number of fields */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies a data tuple to another. This is a shallow copy; if a deep copy is desired, dfield_dup() will have to be invoked on each field. @@ -309,7 +309,7 @@ dtuple_copy( const dtuple_t* tuple, /*!< in: tuple to copy from */ mem_heap_t* heap) /*!< in: memory heap where the tuple is created */ - __attribute__((nonnull, malloc)); + MY_ATTRIBUTE((nonnull, malloc)); /**********************************************************//** The following function returns the sum of data lengths of a tuple. The space occupied by the field structs or the tuple struct is not counted. @@ -320,7 +320,7 @@ dtuple_get_data_size( /*=================*/ const dtuple_t* tuple, /*!< in: typed data tuple */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Computes the number of externally stored fields in a data tuple. @return number of fields */ @@ -329,7 +329,7 @@ ulint dtuple_get_n_ext( /*=============*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Compare two data tuples, respecting the collation of character fields. @return 1, 0 , -1 if tuple1 is greater, equal, less, respectively, @@ -340,7 +340,7 @@ dtuple_coll_cmp( /*============*/ const dtuple_t* tuple1, /*!< in: tuple 1 */ const dtuple_t* tuple2) /*!< in: tuple 2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Folds a prefix given as the number of fields of a tuple. @return the folded value */ @@ -353,7 +353,7 @@ dtuple_fold( ulint n_bytes,/*!< in: number of bytes to fold in an incomplete last field */ index_id_t tree_id)/*!< in: index tree id */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /*******************************************************************//** Sets types of fields binary in a tuple. */ UNIV_INLINE @@ -362,7 +362,7 @@ dtuple_set_types_binary( /*====================*/ dtuple_t* tuple, /*!< in: data tuple */ ulint n) /*!< in: number of fields to set */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Checks if a dtuple contains an SQL null value. @return TRUE if some field is SQL null */ @@ -371,7 +371,7 @@ ibool dtuple_contains_null( /*=================*/ const dtuple_t* tuple) /*!< in: dtuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Checks that a data field is typed. Asserts an error if not. @return TRUE if ok */ @@ -380,7 +380,7 @@ ibool dfield_check_typed( /*===============*/ const dfield_t* field) /*!< in: data field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Checks that a data tuple is typed. Asserts an error if not. @return TRUE if ok */ @@ -389,7 +389,7 @@ ibool dtuple_check_typed( /*===============*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Checks that a data tuple is typed. @return TRUE if ok */ @@ -398,7 +398,7 @@ ibool dtuple_check_typed_no_assert( /*=========================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG /**********************************************************//** Validates the consistency of a tuple which must be complete, i.e, @@ -409,7 +409,7 @@ ibool dtuple_validate( /*============*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /*************************************************************//** Pretty prints a dfield value according to its data type. */ @@ -418,7 +418,7 @@ void dfield_print( /*=========*/ const dfield_t* dfield) /*!< in: dfield */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Pretty prints a dfield value according to its data type. Also the hex string is printed if a string contains non-printable characters. */ @@ -427,7 +427,7 @@ void dfield_print_also_hex( /*==================*/ const dfield_t* dfield) /*!< in: dfield */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************//** The following function prints the contents of a tuple. */ UNIV_INTERN @@ -436,7 +436,7 @@ dtuple_print( /*=========*/ FILE* f, /*!< in: output stream */ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Moves parts of long fields in entry to the big record vector so that the size of tuple drops below the maximum record size allowed in the @@ -453,7 +453,7 @@ dtuple_convert_big_rec( dtuple_t* entry, /*!< in/out: index entry */ ulint* n_ext) /*!< in/out: number of externally stored columns */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /**************************************************************//** Puts back to entry the data stored in vector. Note that to ensure the fields in entry can accommodate the data, vector must have been created @@ -466,7 +466,7 @@ dtuple_convert_back_big_rec( dtuple_t* entry, /*!< in: entry whose data was put to vector */ big_rec_t* vector) /*!< in, own: big rec vector; it is freed in this function */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Frees the memory in a big rec vector. */ UNIV_INLINE @@ -475,7 +475,7 @@ dtuple_big_rec_free( /*================*/ big_rec_t* vector) /*!< in, own: big rec vector; it is freed in this function */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*######################################################################*/ diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic index 6937d55d211..11499ab928c 100644 --- a/storage/innobase/include/data0data.ic +++ b/storage/innobase/include/data0data.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -56,7 +56,8 @@ dfield_set_type( dfield_t* field, /*!< in: SQL data field */ const dtype_t* type) /*!< in: pointer to data type struct */ { - ut_ad(field && type); + ut_ad(field != NULL); + ut_ad(type != NULL); field->type = *type; } @@ -194,7 +195,8 @@ dfield_copy_data( dfield_t* field1, /*!< out: field to copy to */ const dfield_t* field2) /*!< in: field to copy from */ { - ut_ad(field1 && field2); + ut_ad(field1 != NULL); + ut_ad(field2 != NULL); field1->data = field2->data; field1->len = field2->len; diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h index a994c9d8ff1..477e1150f43 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -95,7 +95,7 @@ UNIV_INTERN dberr_t dict_boot(void) /*===========*/ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*****************************************************************//** Creates and initializes the data dictionary at the server bootstrap. @@ -104,7 +104,7 @@ UNIV_INTERN dberr_t dict_create(void) /*=============*/ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Check if a table id belongs to system table. @@ -114,7 +114,7 @@ bool dict_is_sys_table( /*==============*/ table_id_t id) /*!< in: table id to check */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /* Space id and page no where the dictionary header resides */ #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */ diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 564fad35748..150c76b2e65 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -137,7 +137,7 @@ dict_create_add_foreign_id( incremented if used */ const char* name, /*!< in: table name */ dict_foreign_t* foreign)/*!< in/out: foreign key */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Adds the given set of foreign key objects to the dictionary tables in the database. This function does not modify the dictionary cache. The @@ -156,7 +156,7 @@ dict_create_add_foreigns_to_dictionary( const dict_foreign_set& local_fk_set, const dict_table_t* table, trx_t* trx) - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** Creates the tablespaces and datafiles system tables inside InnoDB at server bootstrap or server start if they are not found or are @@ -192,7 +192,7 @@ dict_create_add_foreign_to_dictionary( const char* name, /*!< in: table name */ const dict_foreign_t* foreign,/*!< in: foreign key */ trx_t* trx) /*!< in/out: dictionary transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Construct foreign key constraint defintion from data dictionary information. diff --git a/storage/innobase/include/dict0crea.ic b/storage/innobase/include/dict0crea.ic index 2d0d9dcb858..1cbaa47032b 100644 --- a/storage/innobase/include/dict0crea.ic +++ b/storage/innobase/include/dict0crea.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -33,7 +33,7 @@ UNIV_INTERN bool row_is_mysql_tmp_table_name( /*========================*/ - const char* name) __attribute__((warn_unused_result)); + const char* name) MY_ATTRIBUTE((warn_unused_result)); /*!< in: table name in the form 'database/tablename' */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index b15d364948c..42f93b5a889 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -59,7 +59,7 @@ void dict_casedn_str( /*============*/ char* a) /*!< in/out: string to put in lower case */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Get the database name length in a table name. @return database name length */ @@ -69,7 +69,7 @@ dict_get_db_name_len( /*=================*/ const char* name) /*!< in: table name in the form dbname '/' tablename */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table. @@ -113,7 +113,7 @@ dict_remove_db_name( /*================*/ const char* name) /*!< in: table name in the form dbname '/' tablename */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Operation to perform when opening a table */ enum dict_table_op_t { @@ -161,7 +161,7 @@ dict_table_close( ibool try_drop) /*!< in: TRUE=try to drop any orphan indexes after an aborted online index creation */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Inits the data dictionary module. */ UNIV_INTERN @@ -186,7 +186,7 @@ ulint dict_col_get_mbminlen( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the maximum number of bytes per character. @return maximum multi-byte char size, in bytes */ @@ -195,7 +195,7 @@ ulint dict_col_get_mbmaxlen( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets the minimum and maximum number of bytes per character. */ UNIV_INLINE @@ -207,7 +207,7 @@ dict_col_set_mbminmaxlen( character size, in bytes */ ulint mbmaxlen) /*!< in: minimum multi-byte character size, in bytes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the column data type. */ UNIV_INLINE @@ -216,7 +216,7 @@ dict_col_copy_type( /*===============*/ const dict_col_t* col, /*!< in: column */ dtype_t* type) /*!< out: data type */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Determine bytes of column prefix to be stored in the undo log. Please note if the table format is UNIV_FORMAT_A (< UNIV_FORMAT_B), no prefix @@ -229,7 +229,7 @@ dict_max_field_len_store_undo( dict_table_t* table, /*!< in: table */ const dict_col_t* col) /*!< in: column which index prefix is based on */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG /*********************************************************************//** @@ -241,7 +241,7 @@ dict_col_type_assert_equal( /*=======================*/ const dict_col_t* col, /*!< in: column */ const dtype_t* type) /*!< in: data type */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ #ifndef UNIV_HOTBACKUP /***********************************************************************//** @@ -252,7 +252,7 @@ ulint dict_col_get_min_size( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Returns the maximum size of the column. @return maximum size */ @@ -261,7 +261,7 @@ ulint dict_col_get_max_size( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Returns the size of a fixed size column, 0 if not a fixed size column. @return fixed size, or 0 */ @@ -271,7 +271,7 @@ dict_col_get_fixed_size( /*====================*/ const dict_col_t* col, /*!< in: column */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column. For fixed length types it is the fixed length of the type, otherwise 0. @@ -282,7 +282,7 @@ dict_col_get_sql_null_size( /*=======================*/ const dict_col_t* col, /*!< in: column */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the column number. @return col->ind, table column position (starting from 0) */ @@ -291,7 +291,7 @@ ulint dict_col_get_no( /*============*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the column position in the clustered index. */ UNIV_INLINE @@ -300,7 +300,7 @@ dict_col_get_clust_pos( /*===================*/ const dict_col_t* col, /*!< in: table column */ const dict_index_t* clust_index) /*!< in: clustered index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** If the given column name is reserved for InnoDB system columns, return TRUE. @@ -310,7 +310,7 @@ ibool dict_col_name_is_reserved( /*======================*/ const char* name) /*!< in: column name */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Acquire the autoinc lock. */ UNIV_INTERN @@ -318,7 +318,7 @@ void dict_table_autoinc_lock( /*====================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Unconditionally set the autoinc counter. */ UNIV_INTERN @@ -327,7 +327,7 @@ dict_table_autoinc_initialize( /*==========================*/ dict_table_t* table, /*!< in/out: table */ ib_uint64_t value) /*!< in: next value to assign to a row */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Store autoinc value when the table is evicted. @param[in] table table evicted */ @@ -352,7 +352,7 @@ ib_uint64_t dict_table_autoinc_read( /*====================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Updates the autoinc counter if the value supplied is greater than the current value. */ @@ -363,7 +363,7 @@ dict_table_autoinc_update_if_greater( dict_table_t* table, /*!< in/out: table */ ib_uint64_t value) /*!< in: value which was assigned to a row */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Release the autoinc lock. */ UNIV_INTERN @@ -371,7 +371,7 @@ void dict_table_autoinc_unlock( /*======================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** Adds system columns to a table object. */ @@ -381,7 +381,7 @@ dict_table_add_system_columns( /*==========================*/ dict_table_t* table, /*!< in/out: table */ mem_heap_t* heap) /*!< in: temporary heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Adds a table object to the dictionary cache. */ @@ -392,7 +392,7 @@ dict_table_add_to_cache( dict_table_t* table, /*!< in: table */ ibool can_be_evicted, /*!< in: TRUE if can be evicted*/ mem_heap_t* heap) /*!< in: temporary heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Removes a table object from the dictionary cache. */ UNIV_INTERN @@ -400,7 +400,7 @@ void dict_table_remove_from_cache( /*=========================*/ dict_table_t* table) /*!< in, own: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Removes a table object from the dictionary cache. */ UNIV_INTERN @@ -423,7 +423,7 @@ dict_table_rename_in_cache( /*!< in: in ALTER TABLE we want to preserve the original table name in constraints which reference it */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Removes an index from the dictionary cache. */ UNIV_INTERN @@ -432,7 +432,7 @@ dict_index_remove_from_cache( /*=========================*/ dict_table_t* table, /*!< in/out: table */ dict_index_t* index) /*!< in, own: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Change the id of a table object in the dictionary cache. This is used in DISCARD TABLESPACE. */ @@ -442,7 +442,7 @@ dict_table_change_id_in_cache( /*==========================*/ dict_table_t* table, /*!< in/out: table object already in cache */ table_id_t new_id) /*!< in: new id to set */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Removes a foreign constraint struct from the dictionary cache. */ UNIV_INTERN @@ -450,7 +450,7 @@ void dict_foreign_remove_from_cache( /*===========================*/ dict_foreign_t* foreign) /*!< in, own: foreign constraint */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. @@ -471,7 +471,7 @@ dict_foreign_add_to_cache( compatibility */ dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); /*********************************************************************//** Checks if a table is referenced by foreign keys. @return TRUE if table is referenced by a foreign key */ @@ -480,7 +480,7 @@ ibool dict_table_is_referenced_by_foreign_key( /*====================================*/ const dict_table_t* table) /*!< in: InnoDB table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Replace the index passed in with another equivalent index in the foreign key lists of the table. @@ -494,7 +494,7 @@ dict_foreign_replace_index( /*!< in: column names, or NULL to use table->col_names */ const dict_index_t* index) /*!< in: index to be replaced */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /**********************************************************************//** Determines whether a string starts with the specified keyword. @return TRUE if str starts with keyword */ @@ -505,7 +505,7 @@ dict_str_starts_with_keyword( THD* thd, /*!< in: MySQL thread handle */ const char* str, /*!< in: string to scan for keyword */ const char* keyword) /*!< in: keyword to look for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function @@ -534,7 +534,7 @@ dict_create_foreign_constraints( ibool reject_fks) /*!< in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. @return DB_SUCCESS or DB_CANNOT_DROP_CONSTRAINT if syntax error or the @@ -551,7 +551,7 @@ dict_foreign_parse_drop_constraints( to drop */ const char*** constraints_to_drop) /*!< out: id's of the constraints to drop */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Returns a table object and increments its open handle count. NOTE! This is a high-level function to be used mainly from outside the @@ -570,7 +570,7 @@ dict_table_open_on_name( dict_err_ignore_t ignore_err) /*!< in: error to be ignored when loading the table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Tries to find an index whose first fields are the columns in the array, @@ -607,7 +607,7 @@ dict_foreign_find_index( /*!< out: index where error happened */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /**********************************************************************//** Returns a column's name. @return column name. NOTE: not guaranteed to stay valid if table is @@ -618,7 +618,7 @@ dict_table_get_col_name( /*====================*/ const dict_table_t* table, /*!< in: table */ ulint col_nr) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Returns a column's name. @return column name. NOTE: not guaranteed to stay valid if table is @@ -629,7 +629,7 @@ dict_table_get_col_name_for_mysql( /*==============================*/ const dict_table_t* table, /*!< in: table */ const char* col_name)/*!< in: MySQL table column name */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Prints a table data. */ UNIV_INTERN @@ -637,7 +637,7 @@ void dict_table_print( /*=============*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Outputs info on foreign keys of a table. */ UNIV_INTERN @@ -669,7 +669,7 @@ dict_index_name_print( FILE* file, /*!< in: output stream */ const trx_t* trx, /*!< in: transaction */ const dict_index_t* index) /*!< in: index to print */ - __attribute__((nonnull(1,3))); + MY_ATTRIBUTE((nonnull(1,3))); /*********************************************************************//** Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same @@ -705,7 +705,7 @@ dict_foreign_qualify_index( dict_index_t** err_index) /*!< out: index where error happened */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the first index on the table (the clustered index). @@ -715,7 +715,7 @@ dict_index_t* dict_table_get_first_index( /*=======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the last index on the table. @return index, NULL if none exists */ @@ -724,7 +724,7 @@ dict_index_t* dict_table_get_last_index( /*=======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the next index on the table. @return index, NULL if none left */ @@ -733,7 +733,7 @@ dict_index_t* dict_table_get_next_index( /*======================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ # define dict_table_get_first_index(table) UT_LIST_GET_FIRST((table)->indexes) # define dict_table_get_last_index(table) UT_LIST_GET_LAST((table)->indexes) @@ -762,7 +762,7 @@ ulint dict_index_is_clust( /*================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is unique. @return nonzero for unique index, zero for other indexes */ @@ -771,7 +771,7 @@ ulint dict_index_is_unique( /*=================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ @@ -780,7 +780,7 @@ ulint dict_index_is_ibuf( /*===============*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is a secondary index or the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ @@ -789,7 +789,7 @@ ulint dict_index_is_sec_or_ibuf( /*======================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /************************************************************************ Gets the all the FTS indexes for the table. NOTE: must not be called for @@ -801,7 +801,7 @@ dict_table_get_all_fts_indexes( /* out: number of indexes collected */ dict_table_t* table, /* in: table */ ib_vector_t* indexes)/* out: vector for collecting FTS indexes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Gets the number of user-defined columns in a table in the dictionary cache. @@ -811,7 +811,7 @@ ulint dict_table_get_n_user_cols( /*=======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of system columns in a table in the dictionary cache. @return number of system (e.g., ROW_ID) columns of a table */ @@ -820,7 +820,7 @@ ulint dict_table_get_n_sys_cols( /*======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of all columns (also system) in a table in the dictionary cache. @@ -830,7 +830,7 @@ ulint dict_table_get_n_cols( /*==================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the approximately estimated number of rows in the table. @return estimated number of rows */ @@ -839,7 +839,7 @@ ib_uint64_t dict_table_get_n_rows( /*==================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Increment the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is @@ -849,7 +849,7 @@ void dict_table_n_rows_inc( /*==================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Decrement the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is @@ -859,7 +859,7 @@ void dict_table_n_rows_dec( /*==================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the nth column of a table. @@ -870,7 +870,7 @@ dict_table_get_nth_col( /*===================*/ const dict_table_t* table, /*!< in: table */ ulint pos) /*!< in: position of column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the given system column of a table. @return pointer to column object */ @@ -880,7 +880,7 @@ dict_table_get_sys_col( /*===================*/ const dict_table_t* table, /*!< in: table */ ulint sys) /*!< in: DATA_ROW_ID, ... */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ #define dict_table_get_nth_col(table, pos) \ ((table)->cols + (pos)) @@ -896,7 +896,7 @@ dict_table_get_sys_col_no( /*======================*/ const dict_table_t* table, /*!< in: table */ ulint sys) /*!< in: DATA_ROW_ID, ... */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /********************************************************************//** Returns the minimum data size of an index record. @@ -906,7 +906,7 @@ ulint dict_index_get_min_size( /*====================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /********************************************************************//** Check whether the table uses the compact page format. @@ -916,7 +916,7 @@ ibool dict_table_is_comp( /*===============*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Determine the file format of a table. @return file format version */ @@ -925,7 +925,7 @@ ulint dict_table_get_format( /*==================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Determine the file format from a dict_table_t::flags. @return file format version */ @@ -934,7 +934,7 @@ ulint dict_tf_get_format( /*===============*/ ulint flags) /*!< in: dict_table_t::flags */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Set the various values in a dict_table_t::flags pointer. */ UNIV_INLINE @@ -969,7 +969,7 @@ ulint dict_tf_to_fsp_flags( /*=================*/ ulint flags) /*!< in: dict_table_t::flags */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************************//** Extract the compressed page size from table flags. @return compressed page size, or 0 if not compressed */ @@ -988,7 +988,7 @@ ulint dict_table_zip_size( /*================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** Obtain exclusive locks on all index trees of the table. This is to prevent @@ -999,7 +999,7 @@ void dict_table_x_lock_indexes( /*======================*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Release the exclusive locks on all index tree. */ UNIV_INLINE @@ -1007,7 +1007,7 @@ void dict_table_x_unlock_indexes( /*========================*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. @@ -1018,7 +1018,7 @@ dict_table_col_in_clustered_key( /*============================*/ const dict_table_t* table, /*!< in: table */ ulint n) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Check if the table has an FTS index. @return TRUE if table has an FTS index */ @@ -1027,7 +1027,7 @@ ibool dict_table_has_fts_index( /*=====================*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should @@ -1038,7 +1038,7 @@ dict_table_copy_types( /*==================*/ dtuple_t* tuple, /*!< in/out: data tuple */ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************** Wait until all the background threads of the given table have exited, i.e., bg_threads == 0. Note: bg_threads_mutex must be reserved when @@ -1050,7 +1050,7 @@ dict_table_wait_for_bg_threads_to_exit( dict_table_t* table, /* in: table */ ulint delay) /* in: time in microseconds to wait between checks of bg_threads. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like @@ -1061,7 +1061,7 @@ dict_index_t* dict_index_find_on_id_low( /*======================*/ index_id_t id) /*!< in: index id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /**********************************************************************//** Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user @@ -1087,7 +1087,7 @@ dict_index_add_to_cache( ibool strict) /*!< in: TRUE=refuse to create the index if records could be too big to fit in an B-tree page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Removes an index from the dictionary cache. */ UNIV_INTERN @@ -1096,7 +1096,7 @@ dict_index_remove_from_cache( /*=========================*/ dict_table_t* table, /*!< in/out: table */ dict_index_t* index) /*!< in, own: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /********************************************************************//** Gets the number of fields in the internal representation of an index, @@ -1109,7 +1109,7 @@ dict_index_get_n_fields( const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of fields in the internal representation of an index that uniquely determine the position of an index entry in the index, if @@ -1122,7 +1122,7 @@ dict_index_get_n_unique( /*====================*/ const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of fields in the internal representation of an index which uniquely determine the position of an index entry in the index, if @@ -1134,7 +1134,7 @@ dict_index_get_n_unique_in_tree( /*============================*/ const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of user-defined ordering fields in the index. In the internal representation we add the row id to the ordering fields to make all indexes @@ -1147,7 +1147,7 @@ dict_index_get_n_ordering_defined_by_user( /*======================================*/ const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the nth field of an index. @@ -1158,7 +1158,7 @@ dict_index_get_nth_field( /*=====================*/ const dict_index_t* index, /*!< in: index */ ulint pos) /*!< in: position of field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ # define dict_index_get_nth_field(index, pos) ((index)->fields + (pos)) #endif /* UNIV_DEBUG */ @@ -1171,7 +1171,7 @@ dict_index_get_nth_col( /*===================*/ const dict_index_t* index, /*!< in: index */ ulint pos) /*!< in: position of the field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the column number of the nth field in an index. @return column number */ @@ -1181,7 +1181,7 @@ dict_index_get_nth_col_no( /*======================*/ const dict_index_t* index, /*!< in: index */ ulint pos) /*!< in: position of the field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Looks for column n in an index. @return position in internal representation of the index; @@ -1218,7 +1218,7 @@ dict_index_contains_col_or_prefix( /*==============================*/ const dict_index_t* index, /*!< in: index */ ulint n) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Looks for a matching field in an index. The column has to be the same. The column in index must be complete, or must contain a prefix longer than the @@ -1233,7 +1233,7 @@ dict_index_get_nth_field_pos( const dict_index_t* index, /*!< in: index from which to search */ const dict_index_t* index2, /*!< in: index */ ulint n) /*!< in: field number in index2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Looks for column n position in the clustered index. @return position in internal representation of the clustered index */ @@ -1243,7 +1243,7 @@ dict_table_get_nth_col_pos( /*=======================*/ const dict_table_t* table, /*!< in: table */ ulint n) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Returns the position of a system column in an index. @return position, ULINT_UNDEFINED if not contained */ @@ -1253,7 +1253,7 @@ dict_index_get_sys_col_pos( /*=======================*/ const dict_index_t* index, /*!< in: index */ ulint type) /*!< in: DATA_ROW_ID, ... */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Adds a column to index. */ UNIV_INTERN @@ -1264,7 +1264,7 @@ dict_index_add_col( const dict_table_t* table, /*!< in: table */ dict_col_t* col, /*!< in: column */ ulint prefix_len) /*!< in: column prefix length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /*******************************************************************//** Copies types of fields contained in index to tuple. */ @@ -1276,7 +1276,7 @@ dict_index_copy_types( const dict_index_t* index, /*!< in: index */ ulint n_fields) /*!< in: number of field types to copy */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************************//** Gets the field column. @@ -1286,7 +1286,7 @@ const dict_col_t* dict_field_get_col( /*===============*/ const dict_field_t* field) /*!< in: index field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Returns an index object if it is found in the dictionary cache. @@ -1297,7 +1297,7 @@ dict_index_t* dict_index_get_if_in_cache_low( /*===========================*/ index_id_t index_id) /*!< in: index id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** Returns an index object if it is found in the dictionary cache. @@ -1307,7 +1307,7 @@ dict_index_t* dict_index_get_if_in_cache( /*=======================*/ index_id_t index_id) /*!< in: index id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #ifdef UNIV_DEBUG /**********************************************************************//** @@ -1320,7 +1320,7 @@ dict_index_check_search_tuple( /*==========================*/ const dict_index_t* index, /*!< in: index tree */ const dtuple_t* tuple) /*!< in: tuple used in a search */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Whether and when to allow temporary index names */ enum check_name { /** Require all indexes to be complete. */ @@ -1340,7 +1340,7 @@ dict_table_check_for_dup_indexes( in this table */ enum check_name check) /*!< in: whether and when to allow temporary index names */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* UNIV_DEBUG */ /**********************************************************************//** Builds a node pointer out of a physical record and a page number. @@ -1358,7 +1358,7 @@ dict_index_build_node_ptr( created */ ulint level) /*!< in: level of rec in tree: 0 means leaf level */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Copies an initial segment of a physical record, long enough to specify an index entry uniquely. @@ -1374,7 +1374,7 @@ dict_index_copy_rec_order_prefix( byte** buf, /*!< in/out: memory buffer for the copied prefix, or NULL */ ulint* buf_size)/*!< in/out: buffer size */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Builds a typed data tuple out of a physical record. @return own: data tuple */ @@ -1386,7 +1386,7 @@ dict_index_build_data_tuple( rec_t* rec, /*!< in: record for which to build data tuple */ ulint n_fields,/*!< in: number of data fields */ mem_heap_t* heap) /*!< in: memory heap where tuple created */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the space id of the root of the index tree. @return space id */ @@ -1395,7 +1395,7 @@ ulint dict_index_get_space( /*=================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets the space id of the root of the index tree. */ UNIV_INLINE @@ -1404,7 +1404,7 @@ dict_index_set_space( /*=================*/ dict_index_t* index, /*!< in/out: index */ ulint space) /*!< in: space id */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the page number of the root of the index tree. @return page number */ @@ -1413,7 +1413,7 @@ ulint dict_index_get_page( /*================*/ const dict_index_t* tree) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the read-write lock of the index tree. @return read-write lock */ @@ -1422,7 +1422,7 @@ rw_lock_t* dict_index_get_lock( /*================*/ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Returns free space reserved for future updates of records. This is relevant only in the case of many consecutive inserts, as updates @@ -1442,7 +1442,7 @@ enum online_index_status dict_index_get_online_status( /*=========================*/ const dict_index_t* index) /*!< in: secondary index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Sets the status of online index creation. */ UNIV_INLINE @@ -1451,7 +1451,7 @@ dict_index_set_online_status( /*=========================*/ dict_index_t* index, /*!< in/out: index */ enum online_index_status status) /*!< in: status */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications @@ -1465,7 +1465,7 @@ bool dict_index_is_online_ddl( /*=====================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Calculates the minimum record length in an index. */ UNIV_INTERN @@ -1473,7 +1473,7 @@ ulint dict_index_calc_min_rec_len( /*========================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Reserves the dictionary system mutex for MySQL. */ UNIV_INTERN @@ -1541,7 +1541,7 @@ dict_tables_have_same_db( dbname '/' tablename */ const char* name2) /*!< in: table name in the form dbname '/' tablename */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Removes an index from the cache */ UNIV_INTERN @@ -1550,7 +1550,7 @@ dict_index_remove_from_cache( /*=========================*/ dict_table_t* table, /*!< in/out: table */ dict_index_t* index) /*!< in, own: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Get index by name @return index, NULL if does not exist */ @@ -1560,7 +1560,7 @@ dict_table_get_index_on_name( /*=========================*/ dict_table_t* table, /*!< in: table */ const char* name) /*!< in: name of the index to find */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Looks for an index with the given id given a table instance. @return index or NULL */ @@ -1581,7 +1581,7 @@ dict_table_get_index_on_name_and_min_id( /*====================================*/ dict_table_t* table, /*!< in: table */ const char* name) /*!< in: name of the index to find */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************** Check whether a column exists in an FTS index. */ UNIV_INLINE @@ -1592,7 +1592,7 @@ dict_table_is_fts_column( the offset within the vector */ ib_vector_t* indexes,/* in: vector containing only FTS indexes */ ulint col_no) /* in: col number to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Move a table to the non LRU end of the LRU list. */ UNIV_INTERN @@ -1600,7 +1600,7 @@ void dict_table_move_from_lru_to_non_lru( /*================================*/ dict_table_t* table) /*!< in: table to move from LRU to non-LRU */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Move a table to the LRU list from the non-LRU list. */ UNIV_INTERN @@ -1608,7 +1608,7 @@ void dict_table_move_from_non_lru_to_lru( /*================================*/ dict_table_t* table) /*!< in: table to move from non-LRU to LRU */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Move to the most recently used segment of the LRU list. */ UNIV_INTERN @@ -1616,7 +1616,7 @@ void dict_move_to_mru( /*=============*/ dict_table_t* table) /*!< in: table to move to MRU */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Maximum number of columns in a foreign key constraint. Please Note MySQL has a much lower limit on the number of columns allowed in a foreign key @@ -1740,7 +1740,7 @@ dict_table_schema_check( != DB_TABLE_NOT_FOUND is returned */ size_t errstr_sz) /*!< in: errstr size */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /* @} */ /*********************************************************************//** @@ -1758,7 +1758,7 @@ dict_fs2utf8( size_t db_utf8_size, /*!< in: dbname_utf8 size */ char* table_utf8, /*!< out: table name, e.g. aюbØc */ size_t table_utf8_size)/*!< in: table_utf8 size */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Closes the data dictionary module. */ @@ -1775,7 +1775,7 @@ ulint dict_table_is_corrupted( /*====================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Check whether the index is corrupted. @@ -1785,7 +1785,7 @@ ulint dict_index_is_corrupted( /*====================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -1798,7 +1798,7 @@ dict_set_corrupted( dict_index_t* index, /*!< in/out: index */ trx_t* trx, /*!< in/out: transaction */ const char* ctx) /*!< in: context */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Flags an index corrupted in the data dictionary cache only. This @@ -1810,7 +1810,7 @@ dict_set_corrupted_index_cache_only( /*================================*/ dict_index_t* index, /*!< in/out: index */ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Flags a table with specified space_id corrupted in the table dictionary @@ -1830,7 +1830,7 @@ bool dict_tf_is_valid( /*=============*/ ulint flags) /*!< in: table flags */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Check if the tablespace for the table has been discarded. @@ -1840,7 +1840,7 @@ bool dict_table_is_discarded( /*====================*/ const dict_table_t* table) /*!< in: table to check */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check if it is a temporary table. @@ -1850,7 +1850,7 @@ bool dict_table_is_temporary( /*====================*/ const dict_table_t* table) /*!< in: table to check */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** @@ -1861,7 +1861,7 @@ void dict_index_zip_success( /*===================*/ dict_index_t* index) /*!< in/out: index to be updated. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** This function should be called whenever a page compression attempt fails. Updates the compression padding information. */ @@ -1870,7 +1870,7 @@ void dict_index_zip_failure( /*===================*/ dict_index_t* index) /*!< in/out: index to be updated. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Return the optimal page size, for which page will likely compress. @return page size beyond which page may not compress*/ @@ -1880,7 +1880,7 @@ dict_index_zip_pad_optimal_page_size( /*=================================*/ dict_index_t* index) /*!< in: index for which page size is requested */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Convert table flag to row format string. @return row format name */ diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index a3a3446d507..3d2f0dff0da 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates -Copyright (c) 2013, 2015, SkySQL Ab +Copyright (c) 1996, 2016, Oracle and/or its affiliates +Copyright (c) 2013, 2016, MariaDB Corporation 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 @@ -81,7 +81,8 @@ dict_col_copy_type( const dict_col_t* col, /*!< in: column */ dtype_t* type) /*!< out: data type */ { - ut_ad(col && type); + ut_ad(col != NULL); + ut_ad(type != NULL); type->mtype = col->mtype; type->prtype = col->prtype; @@ -358,7 +359,7 @@ UNIV_INLINE ulint dict_table_get_n_sys_cols( /*======================*/ - const dict_table_t* table __attribute__((unused))) /*!< in: table */ + const dict_table_t* table MY_ATTRIBUTE((unused))) /*!< in: table */ { ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 030190b1a8e..dcbc3de8e94 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -243,7 +243,7 @@ dict_load_foreigns( bool check_charsets, /*!< in: whether to check charset compatibility */ dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); /********************************************************************//** Prints to the standard output information on all tables found in the data dictionary system table. */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index eb2a7968bc4..f964447fb8f 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2016, MariaDB Corporation. @@ -192,19 +192,19 @@ DEFAULT=0, ON = 1, OFF = 2 /** Bit mask of the COMPACT field */ #define DICT_TF_MASK_COMPACT \ - ((~(~0 << DICT_TF_WIDTH_COMPACT)) \ + ((~(~0U << DICT_TF_WIDTH_COMPACT)) \ << DICT_TF_POS_COMPACT) /** Bit mask of the ZIP_SSIZE field */ #define DICT_TF_MASK_ZIP_SSIZE \ - ((~(~0 << DICT_TF_WIDTH_ZIP_SSIZE)) \ + ((~(~0U << DICT_TF_WIDTH_ZIP_SSIZE)) \ << DICT_TF_POS_ZIP_SSIZE) /** Bit mask of the ATOMIC_BLOBS field */ #define DICT_TF_MASK_ATOMIC_BLOBS \ - ((~(~0 << DICT_TF_WIDTH_ATOMIC_BLOBS)) \ + ((~(~0U << DICT_TF_WIDTH_ATOMIC_BLOBS)) \ << DICT_TF_POS_ATOMIC_BLOBS) /** Bit mask of the DATA_DIR field */ #define DICT_TF_MASK_DATA_DIR \ - ((~(~0 << DICT_TF_WIDTH_DATA_DIR)) \ + ((~(~0U << DICT_TF_WIDTH_DATA_DIR)) \ << DICT_TF_POS_DATA_DIR) /** Bit mask of the PAGE_COMPRESSION field */ #define DICT_TF_MASK_PAGE_COMPRESSION \ @@ -279,7 +279,7 @@ for unknown bits in order to protect backward incompatibility. */ /* @{ */ /** Total number of bits in table->flags2. */ #define DICT_TF2_BITS 7 -#define DICT_TF2_BIT_MASK ~(~0 << DICT_TF2_BITS) +#define DICT_TF2_BIT_MASK ~(~0U << DICT_TF2_BITS) /** TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE. */ #define DICT_TF2_TEMPORARY 1 @@ -367,7 +367,7 @@ dict_mem_table_add_col( ulint mtype, /*!< in: main datatype */ ulint prtype, /*!< in: precise type */ ulint len) /*!< in: precision */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /**********************************************************************//** Renames a column of a table in the data dictionary cache. */ UNIV_INTERN @@ -378,7 +378,7 @@ dict_mem_table_col_rename( unsigned nth_col,/*!< in: column index */ const char* from, /*!< in: old column name */ const char* to) /*!< in: new column name */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** This function populates a dict_col_t memory structure with supplied information. */ diff --git a/storage/innobase/include/dict0stats.h b/storage/innobase/include/dict0stats.h index abf56b2f0c7..72501bf9429 100644 --- a/storage/innobase/include/dict0stats.h +++ b/storage/innobase/include/dict0stats.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2009, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2009, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -77,7 +77,7 @@ dict_stats_set_persistent( dict_table_t* table, /*!< in/out: table */ ibool ps_on, /*!< in: persistent stats explicitly enabled */ ibool ps_off) /*!< in: persistent stats explicitly disabled */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Check whether persistent statistics is enabled for a given table. @@ -87,7 +87,7 @@ ibool dict_stats_is_persistent_enabled( /*=============================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Set the auto recalc flag for a given table (only honored for a persistent @@ -127,7 +127,7 @@ void dict_stats_deinit( /*==============*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Calculates new estimates for table and index statistics. The statistics @@ -179,7 +179,7 @@ void dict_stats_update_for_index( /*========================*/ dict_index_t* index) /*!< in/out: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Renames a table in InnoDB persistent stats storage. diff --git a/storage/innobase/include/dict0stats_bg.h b/storage/innobase/include/dict0stats_bg.h index 32fac3015e8..34dc4657829 100644 --- a/storage/innobase/include/dict0stats_bg.h +++ b/storage/innobase/include/dict0stats_bg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,7 +96,7 @@ bool dict_stats_stop_bg( /*===============*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*****************************************************************//** Wait until background stats thread has stopped using the specified table. diff --git a/storage/innobase/include/dyn0dyn.h b/storage/innobase/include/dyn0dyn.h index 7f23302d1ff..1bd10b6bf58 100644 --- a/storage/innobase/include/dyn0dyn.h +++ b/storage/innobase/include/dyn0dyn.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -48,7 +48,7 @@ dyn_array_create( /*=============*/ dyn_array_t* arr) /*!< in/out memory buffer of size sizeof(dyn_array_t) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Frees a dynamic array. */ UNIV_INLINE @@ -56,7 +56,7 @@ void dyn_array_free( /*===========*/ dyn_array_t* arr) /*!< in,own: dyn array */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Makes room on top of a dyn array and returns a pointer to a buffer in it. After copying the elements, the caller must close the buffer using @@ -69,7 +69,7 @@ dyn_array_open( dyn_array_t* arr, /*!< in: dynamic array */ ulint size) /*!< in: size in bytes of the buffer; MUST be smaller than DYN_ARRAY_DATA_SIZE! */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Closes the buffer returned by dyn_array_open. */ UNIV_INLINE @@ -78,7 +78,7 @@ dyn_array_close( /*============*/ dyn_array_t* arr, /*!< in: dynamic array */ const byte* ptr) /*!< in: end of used space */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Makes room on top of a dyn array and returns a pointer to the added element. The caller must copy the element to @@ -90,7 +90,7 @@ dyn_array_push( /*===========*/ dyn_array_t* arr, /*!< in/out: dynamic array */ ulint size) /*!< in: size in bytes of the element */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Returns pointer to an element in dyn array. @return pointer to element */ @@ -101,7 +101,7 @@ dyn_array_get_element( const dyn_array_t* arr, /*!< in: dyn array */ ulint pos) /*!< in: position of element in bytes from array start */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Returns the size of stored data in a dyn array. @return data size in bytes */ @@ -110,7 +110,7 @@ ulint dyn_array_get_data_size( /*====================*/ const dyn_array_t* arr) /*!< in: dyn array */ - __attribute__((nonnull, warn_unused_result, pure)); + MY_ATTRIBUTE((nonnull, warn_unused_result, pure)); /************************************************************//** Gets the first block in a dyn array. @param arr dyn array @@ -144,7 +144,7 @@ ulint dyn_block_get_used( /*===============*/ const dyn_block_t* block) /*!< in: dyn array block */ - __attribute__((nonnull, warn_unused_result, pure)); + MY_ATTRIBUTE((nonnull, warn_unused_result, pure)); /********************************************************************//** Gets pointer to the start of data in a dyn array block. @return pointer to data */ @@ -153,7 +153,7 @@ byte* dyn_block_get_data( /*===============*/ const dyn_block_t* block) /*!< in: dyn array block */ - __attribute__((nonnull, warn_unused_result, pure)); + MY_ATTRIBUTE((nonnull, warn_unused_result, pure)); /********************************************************//** Pushes n bytes to a dyn array. */ UNIV_INLINE @@ -163,7 +163,7 @@ dyn_push_string( dyn_array_t* arr, /*!< in/out: dyn array */ const byte* str, /*!< in: string to write */ ulint len) /*!< in: string length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*#################################################################*/ diff --git a/storage/innobase/include/dyn0dyn.ic b/storage/innobase/include/dyn0dyn.ic index 0296554e2ee..f18f2e6dff9 100644 --- a/storage/innobase/include/dyn0dyn.ic +++ b/storage/innobase/include/dyn0dyn.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -36,7 +36,7 @@ dyn_block_t* dyn_array_add_block( /*================*/ dyn_array_t* arr) /*!< in/out: dyn array */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of used bytes in a dyn array block. diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 7fe0cc88618..c97143235bc 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. -Copyright (c) 2013, 2015, MariaDB Corporation. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. +Copyright (c) 2013, 2016, MariaDB Corporation. 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 @@ -443,7 +443,7 @@ fil_node_create( ulint id, /*!< in: space id where to append */ ibool is_raw) /*!< in: TRUE if a raw device or a raw disk partition */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_LOG_ARCHIVE /****************************************************************//** Drops files from the start of a file space, so that its size is cut by @@ -702,7 +702,7 @@ dberr_t fil_discard_tablespace( /*===================*/ ulint id) /*!< in: space id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /** Test if a tablespace file can be renamed to a new filepath by checking @@ -1200,7 +1200,7 @@ fil_tablespace_iterate( dict_table_t* table, ulint n_io_buffers, PageCallback& callback) - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Checks if a single-table tablespace for a given table name exists in the @@ -1224,7 +1224,7 @@ fil_get_space_names( /*================*/ space_name_list_t& space_name_list) /*!< in/out: Vector for collecting the names. */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /** Generate redo log for swapping two .ibd files @param[in] old_table old table @@ -1239,7 +1239,7 @@ fil_mtr_rename_log( const dict_table_t* new_table, const char* tmp_name, mtr_t* mtr) - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Finds the given page_no of the given space id from the double write buffer, @@ -1261,6 +1261,14 @@ fil_space_flags( /*===========*/ fil_space_t* space); /*!< in: space */ +/*******************************************************************//** +Returns a pointer to the file_space_t that is in the memory cache +associated with a space id. +@return file_space_t pointer, NULL if space not found */ +fil_space_t* +fil_space_get( +/*==========*/ + ulint id); /*!< in: space id */ #endif /* !UNIV_INNOCHECKSUM */ /****************************************************************//** diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index 296dfd8d841..b9ff05b4bd4 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under @@ -109,23 +109,23 @@ dictionary */ /** Bit mask of the POST_ANTELOPE field */ #define FSP_FLAGS_MASK_POST_ANTELOPE \ - ((~(~0 << FSP_FLAGS_WIDTH_POST_ANTELOPE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_POST_ANTELOPE)) \ << FSP_FLAGS_POS_POST_ANTELOPE) /** Bit mask of the ZIP_SSIZE field */ #define FSP_FLAGS_MASK_ZIP_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_ZIP_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_ZIP_SSIZE)) \ << FSP_FLAGS_POS_ZIP_SSIZE) /** Bit mask of the ATOMIC_BLOBS field */ #define FSP_FLAGS_MASK_ATOMIC_BLOBS \ - ((~(~0 << FSP_FLAGS_WIDTH_ATOMIC_BLOBS)) \ + ((~(~0U << FSP_FLAGS_WIDTH_ATOMIC_BLOBS)) \ << FSP_FLAGS_POS_ATOMIC_BLOBS) /** Bit mask of the PAGE_SSIZE field */ #define FSP_FLAGS_MASK_PAGE_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ << FSP_FLAGS_POS_PAGE_SSIZE) /** Bit mask of the DATA_DIR field */ #define FSP_FLAGS_MASK_DATA_DIR \ - ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \ + ((~(~0U << FSP_FLAGS_WIDTH_DATA_DIR)) \ << FSP_FLAGS_POS_DATA_DIR) /** Bit mask of the DATA_DIR field */ #define FSP_FLAGS_MASK_DATA_DIR_ORACLE \ @@ -582,7 +582,7 @@ fseg_alloc_free_page_general( in which the page should be initialized. If init_mtr!=mtr, but the page is already latched in mtr, do not initialize the page. */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /**********************************************************************//** Reserves free pages from a tablespace. All mini-transactions which may use several pages from the tablespace should call this function beforehand @@ -651,7 +651,7 @@ fseg_page_is_free( fseg_header_t* seg_header, /*!< in: segment header */ ulint space, /*!< in: space id */ ulint page) /*!< in: page offset */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Frees part of a segment. This function can be used to free a segment by repeatedly calling this function in different mini-transactions. @@ -747,7 +747,7 @@ bool fsp_flags_is_valid( /*===============*/ ulint flags) /*!< in: tablespace flags */ - __attribute__((warn_unused_result, const)); + MY_ATTRIBUTE((warn_unused_result, const)); /********************************************************************//** Determine if the tablespace is compressed from dict_table_t::flags. @return TRUE if compressed, FALSE if not compressed */ diff --git a/storage/innobase/include/fts0ast.h b/storage/innobase/include/fts0ast.h index b2380f78b39..50f62063893 100644 --- a/storage/innobase/include/fts0ast.h +++ b/storage/innobase/include/fts0ast.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -200,7 +200,7 @@ fts_ast_visit( and ignored processing an operator, currently we only ignore FTS_IGNORE operator */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Process (nested) sub-expression, create a new result set to store the sub-expression result by processing nodes under current sub-expression @@ -213,7 +213,7 @@ fts_ast_visit_sub_exp( fts_ast_node_t* node, /*!< in: instance to traverse*/ fts_ast_callback visitor, /*!< in: callback */ void* arg) /*!< in: callback arg */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************** Create a lex instance.*/ UNIV_INTERN @@ -223,7 +223,7 @@ fts_lexer_create( ibool boolean_mode, /*!< in: query type */ const byte* query, /*!< in: query string */ ulint query_len) /*!< in: query string len */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /******************************************************************** Free an fts_lexer_t instance.*/ UNIV_INTERN @@ -232,7 +232,7 @@ fts_lexer_free( /*===========*/ fts_lexer_t* fts_lexer) /*!< in: lexer instance to free */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Create an ast string object, with NUL-terminator, so the string diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 9f7b0216d9b..87b5787d416 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -94,7 +94,10 @@ those defined in mysql file ft_global.h */ /** Threshold where our optimize thread automatically kicks in */ #define FTS_OPTIMIZE_THRESHOLD 10000000 -#define FTS_DOC_ID_MAX_STEP 10000 +/** Threshold to avoid exhausting of doc ids. Consecutive doc id difference +should not exceed FTS_DOC_ID_MAX_STEP */ +#define FTS_DOC_ID_MAX_STEP 65535 + /** Variable specifying the FTS parallel sort degree */ extern ulong fts_sort_pll_degree; @@ -408,7 +411,7 @@ fts_get_next_doc_id( /*================*/ const dict_table_t* table, /*!< in: table */ doc_id_t* doc_id) /*!< out: new document id */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Update the next and last Doc ID in the CONFIG table to be the input "doc_id" value (+ 1). We would do so after each FTS index build or @@ -421,7 +424,7 @@ fts_update_next_doc_id( const dict_table_t* table, /*!< in: table */ const char* table_name, /*!< in: table name, or NULL */ doc_id_t doc_id) /*!< in: DOC ID to set */ - __attribute__((nonnull(2))); + MY_ATTRIBUTE((nonnull(2))); /******************************************************************//** Create a new document id . @@ -437,7 +440,7 @@ fts_create_doc_id( current row that is being inserted. */ mem_heap_t* heap) /*!< in: heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Create a new fts_doc_ids_t. @return new fts_doc_ids_t. */ @@ -466,7 +469,7 @@ fts_trx_add_op( fts_row_state state, /*!< in: state of the row */ ib_vector_t* fts_indexes) /*!< in: FTS indexes affected (NULL=all) */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /******************************************************************//** Free an FTS trx. */ @@ -491,7 +494,7 @@ fts_create_common_tables( index */ const char* name, /*!< in: table name */ bool skip_doc_id_index) /*!< in: Skip index on doc id */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Wrapper function of fts_create_index_tables_low(), create auxiliary tables for an FTS index @@ -503,7 +506,7 @@ fts_create_index_tables( trx_t* trx, /*!< in: transaction handle */ const dict_index_t* index) /*!< in: the FTS index instance */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Creates the column specific ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have @@ -519,7 +522,7 @@ fts_create_index_tables_low( instance */ const char* table_name, /*!< in: the table name */ table_id_t table_id) /*!< in: the table id */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Add the FTS document id hidden column. */ UNIV_INTERN @@ -528,7 +531,7 @@ fts_add_doc_id_column( /*==================*/ dict_table_t* table, /*!< in/out: Table with FTS index */ mem_heap_t* heap) /*!< in: temporary memory heap, or NULL */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*********************************************************************//** Drops the ancillary tables needed for supporting an FTS index on the @@ -542,7 +545,7 @@ fts_drop_tables( trx_t* trx, /*!< in: transaction */ dict_table_t* table) /*!< in: table has the FTS index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @@ -552,7 +555,7 @@ dberr_t fts_commit( /*=======*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** FTS Query entry point. @@ -569,7 +572,7 @@ fts_query( in bytes */ fts_result_t** result) /*!< out: query result, to be freed by the caller.*/ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Retrieve the FTS Relevance Ranking result for doc with doc_id @@ -687,7 +690,7 @@ dberr_t fts_optimize_table( /*===============*/ dict_table_t* table) /*!< in: table to optimiza */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Startup the optimize thread and create the work queue. */ @@ -713,7 +716,7 @@ fts_drop_index_tables( /*==================*/ trx_t* trx, /*!< in: transaction */ dict_index_t* index) /*!< in: Index to drop */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Remove the table from the OPTIMIZER's list. We do wait for @@ -754,7 +757,7 @@ fts_savepoint_take( trx_t* trx, /*!< in: transaction */ fts_trx_t* fts_trx, /*!< in: fts transaction */ const char* name) /*!< in: savepoint name */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Refresh last statement savepoint. */ UNIV_INTERN @@ -762,7 +765,7 @@ void fts_savepoint_laststmt_refresh( /*===========================*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Release the savepoint data identified by name. */ UNIV_INTERN @@ -780,13 +783,12 @@ fts_cache_destroy( /*==============*/ fts_cache_t* cache); /*!< in: cache*/ -/*********************************************************************//** -Clear cache. */ +/** Clear cache. +@param[in,out] cache fts cache */ UNIV_INTERN void fts_cache_clear( -/*============*/ - fts_cache_t* cache); /*!< in: cache */ + fts_cache_t* cache); /*********************************************************************//** Initialize things in cache. */ @@ -831,20 +833,22 @@ fts_drop_index_split_tables( /*========================*/ trx_t* trx, /*!< in: transaction */ dict_index_t* index) /*!< in: fts instance */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. @param[in,out] table fts table @param[in] unlock_cache whether unlock cache when write node @param[in] wait whether wait for existing sync to finish +@param[in] has_dict whether has dict operation lock @return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( dict_table_t* table, bool unlock_cache, - bool wait); + bool wait, + bool has_dict); /****************************************************************//** Free the query graph but check whether dict_sys->mutex is already @@ -1023,7 +1027,7 @@ fts_drop_index( dict_table_t* table, /*!< in: Table where indexes are dropped */ dict_index_t* index, /*!< in: Index to be dropped */ trx_t* trx) /*!< in: Transaction for the drop */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Rename auxiliary tables for all fts index for a table diff --git a/storage/innobase/include/fts0priv.h b/storage/innobase/include/fts0priv.h index b4d9e1d41ec..2d4e9d88fd1 100644 --- a/storage/innobase/include/fts0priv.h +++ b/storage/innobase/include/fts0priv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -121,7 +121,7 @@ fts_parse_sql( fts_table_t* fts_table, /*!< in: FTS aux table */ pars_info_t* info, /*!< in: info struct, or NULL */ const char* sql) /*!< in: SQL string to evaluate */ - __attribute__((nonnull(3), malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull(3), malloc, warn_unused_result)); /******************************************************************//** Evaluate a parsed SQL statement @return DB_SUCCESS or error code */ @@ -131,7 +131,7 @@ fts_eval_sql( /*=========*/ trx_t* trx, /*!< in: transaction */ que_t* graph) /*!< in: Parsed statement */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Construct the name of an ancillary FTS table for the given table. @return own: table name, must be freed with mem_free() */ @@ -141,7 +141,7 @@ fts_get_table_name( /*===============*/ const fts_table_t* fts_table) /*!< in: FTS aux table info */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /******************************************************************//** Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table. Adds the necessary bound @@ -164,7 +164,7 @@ fts_get_select_columns_str( dict_index_t* index, /*!< in: FTS index */ pars_info_t* info, /*!< in/out: parser info */ mem_heap_t* heap) /*!< in: memory heap */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** define for fts_doc_fetch_by_doc_id() "option" value, defines whether we want to get Doc whose ID is equal to or greater or smaller than supplied @@ -191,7 +191,7 @@ fts_doc_fetch_by_doc_id( callback, /*!< in: callback to read records */ void* arg) /*!< in: callback arg */ - __attribute__((nonnull(6))); + MY_ATTRIBUTE((nonnull(6))); /*******************************************************************//** Callback function for fetch that stores the text of an FTS document, @@ -203,7 +203,7 @@ fts_query_expansion_fetch_doc( /*==========================*/ void* row, /*!< in: sel_node_t* */ void* user_arg) /*!< in: fts_doc_t* */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************** Write out a single word's data as new entry/entries in the INDEX table. @return DB_SUCCESS if all OK. */ @@ -216,7 +216,7 @@ fts_write_node( fts_table_t* fts_table, /*!< in: the FTS aux index */ fts_string_t* word, /*!< in: word in UTF-8 */ fts_node_t* node) /*!< in: node columns */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Tokenize a document. */ UNIV_INTERN @@ -227,7 +227,7 @@ fts_tokenize_document( tokenize */ fts_doc_t* result) /*!< out: if provided, save result tokens here */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*******************************************************************//** Continue to tokenize a document. */ @@ -241,7 +241,7 @@ fts_tokenize_document_next( tokens from this tokenization */ fts_doc_t* result) /*!< out: if provided, save result tokens here */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /******************************************************************//** Initialize a document. */ UNIV_INTERN @@ -249,7 +249,7 @@ void fts_doc_init( /*=========*/ fts_doc_t* doc) /*!< in: doc to initialize */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Do a binary search for a doc id in the array @@ -263,7 +263,7 @@ fts_bsearch( int lower, /*!< in: lower bound of array*/ int upper, /*!< in: upper bound of array*/ doc_id_t doc_id) /*!< in: doc id to lookup */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Free document. */ UNIV_INTERN @@ -271,7 +271,7 @@ void fts_doc_free( /*=========*/ fts_doc_t* doc) /*!< in: document */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Free fts_optimizer_word_t instanace.*/ UNIV_INTERN @@ -279,7 +279,7 @@ void fts_word_free( /*==========*/ fts_word_t* word) /*!< in: instance to free.*/ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Read the rows from the FTS inde @return DB_SUCCESS or error code */ @@ -293,7 +293,7 @@ fts_index_fetch_nodes( const fts_string_t* word, /*!< in: the word to fetch */ fts_fetch_t* fetch) /*!< in: fetch callback.*/ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Create a fts_optimizer_word_t instance. @return new instance */ @@ -304,7 +304,7 @@ fts_word_init( fts_word_t* word, /*!< in: word to initialize */ byte* utf8, /*!< in: UTF-8 string */ ulint len) /*!< in: length of string in bytes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Compare two fts_trx_table_t instances, we actually compare the table id's here. @@ -315,7 +315,7 @@ fts_trx_table_cmp( /*==============*/ const void* v1, /*!< in: id1 */ const void* v2) /*!< in: id2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Compare a table id with a trx_table_t table id. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ @@ -325,7 +325,7 @@ fts_trx_table_id_cmp( /*=================*/ const void* p1, /*!< in: id1 */ const void* p2) /*!< in: id2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Commit a transaction. @return DB_SUCCESS if all OK */ @@ -334,7 +334,7 @@ dberr_t fts_sql_commit( /*===========*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Rollback a transaction. @return DB_SUCCESS if all OK */ @@ -343,7 +343,7 @@ dberr_t fts_sql_rollback( /*=============*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Parse an SQL string. %s is replaced with the table's id. Don't acquire the dict mutex @@ -355,7 +355,7 @@ fts_parse_sql_no_dict_lock( fts_table_t* fts_table, /*!< in: table with FTS index */ pars_info_t* info, /*!< in: parser info */ const char* sql) /*!< in: SQL string to evaluate */ - __attribute__((nonnull(3), malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull(3), malloc, warn_unused_result)); /******************************************************************//** Get value from config table. The caller must ensure that enough space is allocated for value to hold the column contents @@ -370,7 +370,7 @@ fts_config_get_value( this parameter name */ fts_string_t* value) /*!< out: value read from config table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Get value specific to an FTS index from the config table. The caller must ensure that enough space is allocated for value to hold the @@ -386,7 +386,7 @@ fts_config_get_index_value( this parameter name */ fts_string_t* value) /*!< out: value read from config table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Set the value in the config table for name. @return DB_SUCCESS or error code */ @@ -400,7 +400,7 @@ fts_config_set_value( this parameter name */ const fts_string_t* value) /*!< in: value to update */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Set an ulint value in the config table. @return DB_SUCCESS if all OK else error code */ @@ -412,7 +412,7 @@ fts_config_set_ulint( fts_table_t* fts_table, /*!< in: the indexed FTS table */ const char* name, /*!< in: param name */ ulint int_value) /*!< in: value */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Set the value specific to an FTS index in the config table. @return DB_SUCCESS or error code */ @@ -426,7 +426,7 @@ fts_config_set_index_value( this parameter name */ fts_string_t* value) /*!< out: value read from config table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Increment the value in the config table for column name. @return DB_SUCCESS or error code */ @@ -439,7 +439,7 @@ fts_config_increment_value( const char* name, /*!< in: increment config value for this parameter name */ ulint delta) /*!< in: increment by this much */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Increment the per index value in the config table for column name. @return DB_SUCCESS or error code */ @@ -452,7 +452,7 @@ fts_config_increment_index_value( const char* name, /*!< in: increment config value for this parameter name */ ulint delta) /*!< in: increment by this much */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Get an ulint value from the config table. @return DB_SUCCESS or error code */ @@ -464,7 +464,7 @@ fts_config_get_index_ulint( dict_index_t* index, /*!< in: FTS index */ const char* name, /*!< in: param name */ ulint* int_value) /*!< out: value */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Set an ulint value int the config table. @return DB_SUCCESS or error code */ @@ -476,7 +476,7 @@ fts_config_set_index_ulint( dict_index_t* index, /*!< in: FTS index */ const char* name, /*!< in: param name */ ulint int_value) /*!< in: value */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Get an ulint value from the config table. @return DB_SUCCESS or error code */ @@ -488,7 +488,7 @@ fts_config_get_ulint( fts_table_t* fts_table, /*!< in: the indexed FTS table */ const char* name, /*!< in: param name */ ulint* int_value) /*!< out: value */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Search cache for word. @return the word node vector if found else NULL */ @@ -500,7 +500,7 @@ fts_cache_find_word( index_cache, /*!< in: cache to search */ const fts_string_t* text) /*!< in: word to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Check cache for deleted doc id. @return TRUE if deleted */ @@ -511,7 +511,7 @@ fts_cache_is_deleted_doc_id( const fts_cache_t* cache, /*!< in: cache ito search */ doc_id_t doc_id) /*!< in: doc id to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Append deleted doc ids to vector and sort the vector. */ UNIV_INTERN @@ -546,7 +546,7 @@ fts_get_total_word_count( trx_t* trx, /*!< in: transaction */ dict_index_t* index, /*!< in: for this index */ ulint* total) /*!< out: total words */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /******************************************************************//** Search the index specific cache for a particular FTS index. @@ -559,7 +559,7 @@ fts_find_index_cache( cache, /*!< in: cache to search */ const dict_index_t* index) /*!< in: index to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Write the table id to the given buffer (including final NUL). Buffer must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long. @@ -570,10 +570,10 @@ fts_write_object_id( /*================*/ ib_id_t id, /*!< in: a table/index id */ char* str, /*!< in: buffer to write the id to */ - bool hex_format __attribute__((unused))) + bool hex_format MY_ATTRIBUTE((unused))) /*!< in: true for fixed hex format, false for old ambiguous format */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Read the table id from the string generated by fts_write_object_id(). @return TRUE if parse successful */ @@ -583,7 +583,7 @@ fts_read_object_id( /*===============*/ ib_id_t* id, /*!< out: a table id */ const char* str) /*!< in: buffer to read from */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Get the table id. @return number of bytes written */ @@ -596,7 +596,7 @@ fts_get_table_id( char* table_id) /*!< out: table id, must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Add the table to add to the OPTIMIZER's list. */ UNIV_INTERN @@ -604,7 +604,7 @@ void fts_optimize_add_table( /*===================*/ dict_table_t* table) /*!< in: table to add */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Optimize a table. */ UNIV_INTERN @@ -612,7 +612,7 @@ void fts_optimize_do_table( /*==================*/ dict_table_t* table) /*!< in: table to optimize */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Construct the prefix name of an FTS table. @return own: table name, must be freed with mem_free() */ @@ -622,7 +622,7 @@ fts_get_table_name_prefix( /*======================*/ const fts_table_t* fts_table) /*!< in: Auxiliary table type */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /******************************************************************//** Add node positions. */ UNIV_INTERN @@ -633,7 +633,7 @@ fts_cache_node_add_positions( fts_node_t* node, /*!< in: word node */ doc_id_t doc_id, /*!< in: doc id */ ib_vector_t* positions) /*!< in: fts_token_t::positions */ - __attribute__((nonnull(2,4))); + MY_ATTRIBUTE((nonnull(2,4))); /******************************************************************//** Create the config table name for retrieving index specific value. @@ -644,7 +644,7 @@ fts_config_create_index_param_name( /*===============================*/ const char* param, /*!< in: base name of param */ const dict_index_t* index) /*!< in: index for config */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); #ifndef UNIV_NONINL #include "fts0priv.ic" diff --git a/storage/innobase/include/fts0priv.ic b/storage/innobase/include/fts0priv.ic index ec61691870b..88f2d67c7b8 100644 --- a/storage/innobase/include/fts0priv.ic +++ b/storage/innobase/include/fts0priv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -33,7 +33,7 @@ fts_write_object_id( /*================*/ ib_id_t id, /* in: a table/index id */ char* str, /* in: buffer to write the id to */ - bool hex_format __attribute__((unused))) + bool hex_format MY_ATTRIBUTE((unused))) /* in: true for fixed hex format, false for old ambiguous format */ { diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 427bfaf2c05..12453099ef7 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -136,7 +136,7 @@ enum durability_properties thd_requested_durability( /*=====================*/ const THD* thd) /*!< in: thread handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Returns true if the transaction this thread is processing has edited @@ -177,7 +177,7 @@ innobase_mysql_cmp( const unsigned char* b, /*!< in: data field */ unsigned int b_length) /*!< in: data field length, not UNIV_SQL_NULL */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Log code calls this whenever log has been written and/or flushed up @@ -205,7 +205,7 @@ get_innobase_type_from_mysql_type( and unsigned integer types are 'unsigned types' */ const void* field) /*!< in: MySQL Field */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Get the variable length bounds of the given character set. */ @@ -289,8 +289,10 @@ innobase_casedn_str( #ifdef WITH_WSREP UNIV_INTERN int -wsrep_innobase_kill_one_trx(void *thd_ptr, - const trx_t *bf_trx, trx_t *victim_trx, ibool signal); +wsrep_innobase_kill_one_trx(void * const thd_ptr, + const trx_t * const bf_trx, + trx_t *victim_trx, + ibool signal); int wsrep_innobase_mysql_sort(int mysql_type, uint charset_number, unsigned char* str, unsigned int str_length, unsigned int buf_length); @@ -313,7 +315,7 @@ innobase_get_stmt( /*==============*/ THD* thd, /*!< in: MySQL thread handle */ size_t* length) /*!< out: length of the SQL statement */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** This function is used to find the storage length in bytes of the first n characters for prefix indexes using a multibyte character set. The function @@ -339,7 +341,7 @@ enum icp_result innobase_index_cond( /*================*/ void* file) /*!< in/out: pointer to ha_innobase */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Returns true if the thread supports XA, global value of innodb_supports_xa if thd is NULL. @@ -475,7 +477,7 @@ innobase_format_name( const char* name, /*!< in: index or table name to format */ ibool is_index_name) /*!< in: index name */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Corresponds to Sql_condition:enum_warning_level. */ enum ib_log_level_t { @@ -505,7 +507,7 @@ ib_errf( ib_uint32_t code, /*!< MySQL error code */ const char* format, /*!< printf format */ ...) /*!< Args */ - __attribute__((format(printf, 4, 5))); + MY_ATTRIBUTE((format(printf, 4, 5))); /******************************************************************//** Use this when the args are passed to the format string from @@ -536,7 +538,7 @@ ib_logf( ib_log_level_t level, /*!< in: warning level */ const char* format, /*!< printf format */ ...) /*!< Args */ - __attribute__((format(printf, 2, 3))); + MY_ATTRIBUTE((format(printf, 2, 3))); /******************************************************************//** Returns the NUL terminated value of glob_hostname. @@ -582,7 +584,7 @@ innobase_next_autoinc( ulonglong step, /*!< in: AUTOINC increment step */ ulonglong offset, /*!< in: AUTOINC offset */ ulonglong max_value) /*!< in: max value for type */ - __attribute__((pure, warn_unused_result)); + MY_ATTRIBUTE((pure, warn_unused_result)); /********************************************************************//** Get the upper limit of the MySQL integral and floating-point type. @@ -592,7 +594,7 @@ ulonglong innobase_get_int_col_max_value( /*===========================*/ const Field* field) /*!< in: MySQL field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************** Converts an identifier from my_charset_filename to UTF-8 charset. */ diff --git a/storage/innobase/include/handler0alter.h b/storage/innobase/include/handler0alter.h index 66b963ae39a..3dd6c99eb6d 100644 --- a/storage/innobase/include/handler0alter.h +++ b/storage/innobase/include/handler0alter.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -32,7 +32,7 @@ innobase_rec_to_mysql( const dict_index_t* index, /*!< in: index */ const ulint* offsets)/*!< in: rec_get_offsets( rec, index, ...) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Copies an InnoDB index entry to table->record[0]. */ @@ -43,7 +43,7 @@ innobase_fields_to_mysql( struct TABLE* table, /*!< in/out: MySQL table */ const dict_index_t* index, /*!< in: InnoDB index */ const dfield_t* fields) /*!< in: InnoDB index fields */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Copies an InnoDB row to table->record[0]. */ @@ -54,7 +54,7 @@ innobase_row_to_mysql( struct TABLE* table, /*!< in/out: MySQL table */ const dict_table_t* itab, /*!< in: InnoDB table */ const dtuple_t* row) /*!< in: InnoDB row */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Resets table->record[0]. */ @@ -63,7 +63,7 @@ void innobase_rec_reset( /*===============*/ struct TABLE* table) /*!< in/out: MySQL table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Generate the next autoinc based on a snapshot of the session auto_increment_increment and auto_increment_offset variables. */ diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h index badafe6befd..09c48822b9f 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -120,7 +120,7 @@ void ibuf_mtr_start( /*===========*/ mtr_t* mtr) /*!< out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Commits an insert buffer mini-transaction. */ UNIV_INLINE @@ -128,7 +128,7 @@ void ibuf_mtr_commit( /*============*/ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Initializes an ibuf bitmap page. */ UNIV_INTERN @@ -254,7 +254,7 @@ ibool ibuf_inside( /*========*/ const mtr_t* mtr) /*!< in: mini-transaction */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /***********************************************************************//** Checks if a page address is an ibuf bitmap page (level 3 page) address. @return TRUE if a bitmap page */ @@ -287,7 +287,7 @@ ibuf_page_low( is not one of the fixed address ibuf pages, or NULL, in which case a new transaction is created. */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG /** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. Must not be called when recv_no_ibuf_operations==TRUE. @@ -366,23 +366,31 @@ void ibuf_delete_for_discarded_space( /*============================*/ ulint space); /*!< in: space id */ -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[in] full If true, do a full contraction based +on PCT_IO(100). If false, the size of contract batch is determined +based on the current size of the change buffer. @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ UNIV_INTERN ulint -ibuf_contract_in_background( -/*========================*/ - table_id_t table_id, /*!< in: if merge should be done only - for a specific table, for all tables - this should be 0 */ - ibool full); /*!< in: TRUE if the caller wants to - do a full contract based on PCT_IO(100). - If FALSE then the size of contract - batch is determined based on the - current size of the ibuf tree. */ +ibuf_merge_in_background( + bool full); /*!< in: TRUE if the caller wants to + do a full contract based on PCT_IO(100). + If FALSE then the size of contract + batch is determined based on the + current size of the ibuf tree. */ + +/** Contracts insert buffer trees by reading pages referring to space_id +to the buffer pool. +@returns number of pages merged.*/ +UNIV_INTERN +ulint +ibuf_merge_space( +/*=============*/ + ulint space); /*!< in: space id */ + #endif /* !UNIV_HOTBACKUP */ /*********************************************************************//** Parses a redo log record of an ibuf bitmap page init. @@ -447,7 +455,7 @@ ibuf_check_bitmap_on_import( /*========================*/ const trx_t* trx, /*!< in: transaction */ ulint space_id) /*!< in: tablespace identifier */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO #define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index acfb8ef19c6..a6fafd95754 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -276,7 +276,7 @@ lock_rec_expl_exist_on_page( /*========================*/ ulint space, /*!< in: space id */ ulint page_no)/*!< in: page number */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Checks if locks of other transactions prevent an immediate insert of a record. If they do, first tests if the query thread should anyway @@ -299,7 +299,7 @@ lock_rec_insert_check_and_lock( inserted record maybe should inherit LOCK_GAP type locks from the successor record */ - __attribute__((nonnull(2,3,4,6,7), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3,4,6,7), warn_unused_result)); /*********************************************************************//** Checks if locks of other transactions prevent an immediate modify (update, delete mark, or delete unmark) of a clustered index record. If they do, @@ -320,7 +320,7 @@ lock_clust_rec_modify_check_and_lock( dict_index_t* index, /*!< in: clustered index */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /*********************************************************************//** Checks if locks of other transactions prevent an immediate modify (delete mark or delete unmark) of a secondary index record. @@ -341,7 +341,7 @@ lock_sec_rec_modify_check_and_lock( que_thr_t* thr, /*!< in: query thread (can be NULL if BTR_NO_LOCKING_FLAG) */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((warn_unused_result, nonnull(2,3,4,6))); + MY_ATTRIBUTE((warn_unused_result, nonnull(2,3,4,6))); /*********************************************************************//** Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record. @@ -428,7 +428,7 @@ lock_clust_rec_read_check_and_lock_alt( ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Checks that a record is seen in a consistent read. @return true if sees, or false if an earlier version of the record @@ -460,7 +460,7 @@ lock_sec_rec_cons_read_sees( should be read or passed over by a read cursor */ const read_view_t* view) /*!< in: consistent read view */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Locks the specified database table in the mode given. If the lock cannot be granted immediately, the query thread is put to wait. @@ -475,7 +475,7 @@ lock_table( in dictionary cache */ enum lock_mode mode, /*!< in: lock mode */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Creates a table IX lock object for a resurrected transaction. */ UNIV_INTERN @@ -530,7 +530,7 @@ lock_rec_fold( /*==========*/ ulint space, /*!< in: space */ ulint page_no)/*!< in: page number */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*********************************************************************//** Calculates the hash value of a page file address: used in inserting or searching for a lock in the hash table. @@ -580,7 +580,7 @@ lock_is_table_exclusive( /*====================*/ const dict_table_t* table, /*!< in: table */ const trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Checks if a lock request lock1 has to wait for request lock2. @return TRUE if lock1 has to wait for lock2 to be removed */ @@ -604,7 +604,7 @@ lock_report_trx_id_insanity( dict_index_t* index, /*!< in: index */ const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */ trx_id_t max_trx_id) /*!< in: trx_sys_get_max_trx_id() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Prints info of a table lock. */ UNIV_INTERN @@ -631,7 +631,7 @@ lock_print_info_summary( /*====================*/ FILE* file, /*!< in: file where to print */ ibool nowait) /*!< in: whether to wait for the lock mutex */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock @@ -651,7 +651,7 @@ ulint lock_number_of_rows_locked( /*=======================*/ const trx_lock_t* trx_lock) /*!< in: transaction locks */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Gets the type of a lock. Non-inline version for using outside of the @@ -819,7 +819,7 @@ dberr_t lock_trx_handle_wait( /*=================*/ trx_t* trx) /*!< in/out: trx lock state */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Get the number of locks on a table. @return number of locks */ @@ -828,7 +828,7 @@ ulint lock_table_get_n_locks( /*===================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /*********************************************************************//** Checks that a transaction id is sensible, i.e., not in the future. @@ -841,7 +841,7 @@ lock_check_trx_id_sanity( const rec_t* rec, /*!< in: user record */ dict_index_t* index, /*!< in: index */ const ulint* offsets) /*!< in: rec_get_offsets(rec, index) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Check if the transaction holds any locks on the sys tables or its records. @@ -851,7 +851,7 @@ const lock_t* lock_trx_has_sys_table_locks( /*=========================*/ const trx_t* trx) /*!< in: transaction to check */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** Check if the transaction holds an exclusive lock on a record. @@ -864,7 +864,7 @@ lock_trx_has_rec_x_lock( const dict_table_t* table, /*!< in: table to check */ const buf_block_t* block, /*!< in: buffer block of the record */ ulint heap_no)/*!< in: record heap number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /** Lock modes and types */ diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h index 16423e6a282..b60dd0d92c8 100644 --- a/storage/innobase/include/lock0priv.h +++ b/storage/innobase/include/lock0priv.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2016, MariaDB Corporation 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 @@ -124,7 +124,7 @@ lock_clust_rec_some_has_impl( const rec_t* rec, /*!< in: user record */ const dict_index_t* index, /*!< in: clustered index */ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_NONINL #include "lock0priv.ic" diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 292953854f7..b6c977bdc74 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -51,7 +51,7 @@ recv_read_checkpoint_info_for_backup( lsn_t* first_header_lsn) /*!< out: lsn of of the start of the first log file */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Scans the log segment and n_bytes_scanned is set to the length of valid log scanned. */ diff --git a/storage/innobase/include/mach0data.h b/storage/innobase/include/mach0data.h index d0087f56aaa..9859def0adc 100644 --- a/storage/innobase/include/mach0data.h +++ b/storage/innobase/include/mach0data.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -53,7 +53,7 @@ ulint mach_read_from_1( /*=============*/ const byte* b) /*!< in: pointer to byte */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*******************************************************//** The following function is used to store data in two consecutive bytes. We store the most significant byte to the lower address. */ @@ -72,7 +72,7 @@ ulint mach_read_from_2( /*=============*/ const byte* b) /*!< in: pointer to two bytes */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /********************************************************//** The following function is used to convert a 16-bit data item @@ -84,7 +84,7 @@ uint16 mach_encode_2( /*==========*/ ulint n) /*!< in: integer in machine-dependent format */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************//** The following function is used to convert a 16-bit data item from the canonical format, for fast bytewise equality test @@ -95,7 +95,7 @@ ulint mach_decode_2( /*==========*/ uint16 n) /*!< in: 16-bit integer in canonical format */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*******************************************************//** The following function is used to store data in 3 consecutive bytes. We store the most significant byte to the lowest address. */ @@ -114,7 +114,7 @@ ulint mach_read_from_3( /*=============*/ const byte* b) /*!< in: pointer to 3 bytes */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*******************************************************//** The following function is used to store data in four consecutive bytes. We store the most significant byte to the lowest address. */ @@ -133,7 +133,7 @@ ulint mach_read_from_4( /*=============*/ const byte* b) /*!< in: pointer to four bytes */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a ulint in a compressed form (1..5 bytes). @return stored size in bytes */ @@ -151,7 +151,7 @@ ulint mach_get_compressed_size( /*=====================*/ ulint n) /*!< in: ulint integer to be stored */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*********************************************************//** Reads a ulint in a compressed form. @return read integer */ @@ -160,7 +160,7 @@ ulint mach_read_compressed( /*=================*/ const byte* b) /*!< in: pointer to memory from where to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*******************************************************//** The following function is used to store data in 6 consecutive bytes. We store the most significant byte to the lowest address. */ @@ -179,7 +179,7 @@ ib_uint64_t mach_read_from_6( /*=============*/ const byte* b) /*!< in: pointer to 6 bytes */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*******************************************************//** The following function is used to store data in 7 consecutive bytes. We store the most significant byte to the lowest address. */ @@ -198,7 +198,7 @@ ib_uint64_t mach_read_from_7( /*=============*/ const byte* b) /*!< in: pointer to 7 bytes */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*******************************************************//** The following function is used to store data in 8 consecutive bytes. We store the most significant byte to the lowest address. */ @@ -217,7 +217,7 @@ ib_uint64_t mach_read_from_8( /*=============*/ const byte* b) /*!< in: pointer to 8 bytes */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a 64-bit integer in a compressed form (5..9 bytes). @return size in bytes */ @@ -243,7 +243,7 @@ ib_uint64_t mach_ull_read_compressed( /*=====================*/ const byte* b) /*!< in: pointer to memory from where to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a 64-bit integer in a compressed form (1..11 bytes). @return size in bytes */ @@ -261,7 +261,7 @@ ulint mach_ull_get_much_compressed_size( /*==============================*/ ib_uint64_t n) /*!< in: 64-bit integer to be stored */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*********************************************************//** Reads a 64-bit integer in a compressed form. @return the value read */ @@ -270,7 +270,7 @@ ib_uint64_t mach_ull_read_much_compressed( /*==========================*/ const byte* b) /*!< in: pointer to memory from where to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Reads a ulint in a compressed form if the log record fully contains it. @return pointer to end of the stored field, NULL if not complete */ @@ -301,7 +301,7 @@ double mach_double_read( /*=============*/ const byte* b) /*!< in: pointer to memory from where to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a double. It is stored in a little-endian format. */ UNIV_INLINE @@ -318,7 +318,7 @@ float mach_float_read( /*============*/ const byte* b) /*!< in: pointer to memory from where to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a float. It is stored in a little-endian format. */ UNIV_INLINE @@ -336,7 +336,7 @@ mach_read_from_n_little_endian( /*===========================*/ const byte* buf, /*!< in: from where to read */ ulint buf_size) /*!< in: from how many bytes to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a ulint in the little-endian format. */ UNIV_INLINE @@ -354,7 +354,7 @@ ulint mach_read_from_2_little_endian( /*===========================*/ const byte* buf) /*!< in: from where to read */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************//** Writes a ulint in the little-endian format. */ UNIV_INLINE diff --git a/storage/innobase/include/mem0mem.h b/storage/innobase/include/mem0mem.h index f30034f3074..de9b8b29fd9 100644 --- a/storage/innobase/include/mem0mem.h +++ b/storage/innobase/include/mem0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2010, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -353,7 +353,7 @@ mem_heap_printf( /*============*/ mem_heap_t* heap, /*!< in: memory heap */ const char* format, /*!< in: format string */ - ...) __attribute__ ((format (printf, 2, 3))); + ...) MY_ATTRIBUTE ((format (printf, 2, 3))); #ifdef MEM_PERIODIC_CHECK /******************************************************************//** diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index 0d983d69e1a..63e68150b61 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2010, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -476,9 +476,9 @@ void mem_heap_free_func( /*===============*/ mem_heap_t* heap, /*!< in, own: heap to be freed */ - const char* file_name __attribute__((unused)), + const char* file_name MY_ATTRIBUTE((unused)), /*!< in: file name where freed */ - ulint line __attribute__((unused))) + ulint line MY_ATTRIBUTE((unused))) { mem_block_t* block; mem_block_t* prev_block; diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index eae981f2fbb..c3307985532 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -1,7 +1,8 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2013, 2016, MariaDB Corporation 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 @@ -217,7 +218,7 @@ mtr_start_trx( /*======*/ mtr_t* mtr, /*!< out: mini-transaction */ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull (1))); + MY_ATTRIBUTE((nonnull (1))); /***************************************************************//** Starts a mini-transaction. */ UNIV_INLINE @@ -228,7 +229,7 @@ mtr_start( { mtr_start_trx(mtr, NULL); } - __attribute__((nonnull)) + MY_ATTRIBUTE((nonnull)) /***************************************************************//** Commits a mini-transaction. */ UNIV_INTERN @@ -236,7 +237,7 @@ void mtr_commit( /*=======*/ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************//** Sets and returns a savepoint in mtr. @return savepoint */ @@ -341,7 +342,7 @@ mtr_memo_release( mtr_t* mtr, /*!< in/out: mini-transaction */ void* object, /*!< in: object */ ulint type) /*!< in: object type: MTR_MEMO_S_LOCK, ... */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG # ifndef UNIV_HOTBACKUP /**********************************************************//** @@ -354,7 +355,7 @@ mtr_memo_contains( mtr_t* mtr, /*!< in: mtr */ const void* object, /*!< in: object to search */ ulint type) /*!< in: type of object */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /**********************************************************//** Checks if memo contains the given page. diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic index 44d548e9b64..37cea34d4eb 100644 --- a/storage/innobase/include/mtr0mtr.ic +++ b/storage/innobase/include/mtr0mtr.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -37,7 +37,7 @@ ibool mtr_block_dirtied( /*==============*/ const buf_block_t* block) /*!< in: block being x-fixed */ - __attribute__((nonnull,warn_unused_result)); + MY_ATTRIBUTE((nonnull,warn_unused_result)); /***************************************************************//** Starts a mini-transaction. */ diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index dd6fd8f9940..2425a682e22 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -637,7 +637,7 @@ pfs_os_file_create_simple_func( ibool* success,/*!< out: TRUE if succeed, FALSE if error */ const char* src_file,/*!< in: file name where func invoked */ ulint src_line)/*!< in: line where the func invoked */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** NOTE! Please use the corresponding macro @@ -664,7 +664,7 @@ pfs_os_file_create_simple_no_error_handling_func( value */ const char* src_file,/*!< in: file name where func invoked */ ulint src_line)/*!< in: line where the func invoked */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** NOTE! Please use the corresponding macro os_file_create(), not directly @@ -694,7 +694,7 @@ pfs_os_file_create_func( value*/ const char* src_file,/*!< in: file name where func invoked */ ulint src_line)/*!< in: line where the func invoked */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** NOTE! Please use the corresponding macro os_file_close(), not directly @@ -880,7 +880,7 @@ os_offset_t os_file_get_size( /*=============*/ os_file_t file) /*!< in: handle to a file */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /***********************************************************************//** Write the specified number of zeros to a newly created file. @return TRUE if success */ @@ -892,7 +892,7 @@ os_file_set_size( null-terminated string */ os_file_t file, /*!< in: handle to a file */ os_offset_t size) /*!< in: file size */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Truncates a file at its current position. @return TRUE if success */ diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h index 95e724ec48e..0754210c47a 100644 --- a/storage/innobase/include/os0sync.h +++ b/storage/innobase/include/os0sync.h @@ -466,7 +466,7 @@ amount to decrement. */ # define os_atomic_decrement_uint64(ptr, amount) \ os_atomic_decrement(ptr, amount) -# if defined(IB_STRONG_MEMORY_MODEL) +# if defined(HAVE_ATOMIC_BUILTINS) /** Do an atomic test and set. @param[in,out] ptr Memory location to set to non-zero @@ -479,20 +479,13 @@ os_atomic_test_and_set(volatile lock_word_t* ptr) } /** Do an atomic release. - -In theory __sync_lock_release should be used to release the lock. -Unfortunately, it does not work properly alone. The workaround is -that more conservative __sync_lock_test_and_set is used instead. - -Performance regression was observed at some conditions for Intel -architecture. Disable release barrier on Intel architecture for now. @param[in,out] ptr Memory location to write to @return the previous value */ inline -lock_word_t +void os_atomic_clear(volatile lock_word_t* ptr) { - return(__sync_lock_test_and_set(ptr, 0)); + __sync_lock_release(ptr); } # elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) @@ -856,15 +849,7 @@ for synchronization */ } while (0); /** barrier definitions for memory ordering */ -#ifdef IB_STRONG_MEMORY_MODEL -/* Performance regression was observed at some conditions for Intel -architecture. Disable memory barrier for Intel architecture for now. */ -# define os_rmb do { } while(0) -# define os_wmb do { } while(0) -# define os_isync do { } while(0) -# define IB_MEMORY_BARRIER_STARTUP_MSG \ - "Memory barrier is not used" -#elif defined(HAVE_IB_GCC_ATOMIC_THREAD_FENCE) +#if defined(HAVE_IB_GCC_ATOMIC_THREAD_FENCE) # define HAVE_MEMORY_BARRIER # define os_rmb __atomic_thread_fence(__ATOMIC_ACQUIRE) # define os_wmb __atomic_thread_fence(__ATOMIC_RELEASE) diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index 37c54afae80..9a1ada8fa0d 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -125,7 +125,7 @@ os_thread_exit( /*===========*/ void* exit_value) /*!< in: exit value; in Windows this void* is cast as a DWORD */ - UNIV_COLD __attribute__((noreturn)); + UNIV_COLD MY_ATTRIBUTE((noreturn)); /*****************************************************************//** Returns the thread identifier of current thread. @return current thread identifier */ diff --git a/storage/innobase/include/page0cur.h b/storage/innobase/include/page0cur.h index b1ad49b4915..f04667ff29c 100644 --- a/storage/innobase/include/page0cur.h +++ b/storage/innobase/include/page0cur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -180,7 +180,7 @@ page_cur_tuple_insert( mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ ulint n_ext, /*!< in: number of externally stored columns */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ - __attribute__((nonnull(1,2,3,4,5), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4,5), warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Inserts a record next to page cursor. Returns pointer to inserted record if @@ -218,7 +218,7 @@ page_cur_insert_rec_low( const rec_t* rec, /*!< in: pointer to a physical record */ ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ - __attribute__((nonnull(1,2,3,4), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /***********************************************************//** Inserts a record next to page cursor on a compressed and uncompressed page. Returns pointer to inserted record if succeed, i.e., @@ -240,7 +240,7 @@ page_cur_insert_rec_zip( const rec_t* rec, /*!< in: pointer to a physical record */ ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ - __attribute__((nonnull(1,2,3,4), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /*************************************************************//** Copies records from page to a newly created page, from a given record onward, including that record. Infimum and supremum records are not copied. diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index d83b6e1985d..e8b4265bc68 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,6 +1,7 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation 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 @@ -172,7 +173,7 @@ page_t* page_align( /*=======*/ const void* ptr) /*!< in: pointer to page frame */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** Gets the offset within a page. @return offset from the start of the page */ @@ -181,7 +182,7 @@ ulint page_offset( /*========*/ const void* ptr) /*!< in: pointer to page frame */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*************************************************************//** Returns the max trx id field value. */ UNIV_INLINE @@ -239,7 +240,7 @@ page_header_get_offs( /*=================*/ const page_t* page, /*!< in: page */ ulint field) /*!< in: PAGE_FREE, ... */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*************************************************************//** Returns the pointer stored in the given header field, or NULL. */ @@ -299,7 +300,7 @@ page_rec_get_nth_const( /*===================*/ const page_t* page, /*!< in: page */ ulint nth) /*!< in: nth record */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Returns the nth record of the record list. This is the inverse function of page_rec_get_n_recs_before(). @@ -310,7 +311,7 @@ page_rec_get_nth( /*=============*/ page_t* page, /*< in: page */ ulint nth) /*!< in: nth record */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /************************************************************//** @@ -323,7 +324,7 @@ rec_t* page_get_middle_rec( /*================*/ page_t* page) /*!< in: page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Compares a data tuple to a physical record. Differs from the function cmp_dtuple_rec_with_match in the way that the record must reside on an @@ -536,7 +537,7 @@ bool page_is_leaf( /*=========*/ const page_t* page) /*!< in: page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); #ifndef UNIV_INNOCHECKSUM /************************************************************//** Determine whether the page is empty. @@ -546,7 +547,7 @@ bool page_is_empty( /*==========*/ const page_t* page) /*!< in: page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /************************************************************//** Determine whether the page contains garbage. @return true if the page contains garbage (PAGE_GARBAGE is not 0) */ @@ -555,7 +556,7 @@ bool page_has_garbage( /*=============*/ const page_t* page) /*!< in: page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /************************************************************//** Gets the pointer to the next record on the page. @return pointer to next record */ @@ -627,7 +628,7 @@ ibool page_rec_is_user_rec_low( /*=====================*/ ulint offset) /*!< in: record offset on page */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the supremum record on a page. @return TRUE if the supremum record */ @@ -636,7 +637,7 @@ ibool page_rec_is_supremum_low( /*=====================*/ ulint offset) /*!< in: record offset on page */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the infimum record on a page. @return TRUE if the infimum record */ @@ -645,7 +646,7 @@ ibool page_rec_is_infimum_low( /*====================*/ ulint offset) /*!< in: record offset on page */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is a user record on the page. @@ -655,7 +656,7 @@ ibool page_rec_is_user_rec( /*=================*/ const rec_t* rec) /*!< in: record */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the supremum record on a page. @return TRUE if the supremum record */ @@ -664,7 +665,7 @@ ibool page_rec_is_supremum( /*=================*/ const rec_t* rec) /*!< in: record */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the infimum record on a page. @@ -674,7 +675,7 @@ ibool page_rec_is_infimum( /*================*/ const rec_t* rec) /*!< in: record */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /***************************************************************//** Looks for the record which owns the given record. @return the owner record */ @@ -694,7 +695,7 @@ page_rec_write_field( ulint i, /*!< in: index of the field to update */ ulint val, /*!< in: value to write */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /************************************************************//** Returns the maximum combined size of records which can be inserted on top @@ -724,7 +725,7 @@ ulint page_get_free_space_of_empty( /*=========================*/ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************//** Returns the base extra size of a physical record. This is the size of the fixed header, independent of the record size. @@ -810,7 +811,7 @@ page_create_zip( ulint level, /*!< in: the B-tree level of the page */ trx_id_t max_trx_id, /*!< in: PAGE_MAX_TRX_ID */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************//** Empty a previously created B-tree index page. */ UNIV_INTERN @@ -820,7 +821,7 @@ page_create_empty( buf_block_t* block, /*!< in/out: B-tree block */ dict_index_t* index, /*!< in: the index of the page */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /*************************************************************//** Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. @@ -859,7 +860,7 @@ page_copy_rec_list_end( rec_t* rec, /*!< in: record on page */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Copies records from page to new_page, up to the given record, NOT including that record. Infimum and supremum records are not copied. @@ -881,7 +882,7 @@ page_copy_rec_list_start( rec_t* rec, /*!< in: record on page */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Deletes records from a page from a given record onward, including that record. The infimum and supremum records are not deleted. */ @@ -898,7 +899,7 @@ page_delete_rec_list_end( records in the end of the chain to delete, or ULINT_UNDEFINED if not known */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Deletes records from page, up to the given record, NOT including that record. Infimum and supremum records are not deleted. */ @@ -910,7 +911,7 @@ page_delete_rec_list_start( buf_block_t* block, /*!< in: buffer block of the page */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Moves record list end to another page. Moved records include split_rec. @@ -931,7 +932,7 @@ page_move_rec_list_end( rec_t* split_rec, /*!< in: first record to move */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull(1, 2, 4, 5))); + MY_ATTRIBUTE((nonnull(1, 2, 4, 5))); /*************************************************************//** Moves record list start to another page. Moved records do not include split_rec. @@ -951,7 +952,7 @@ page_move_rec_list_start( rec_t* split_rec, /*!< in: first record not to move */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull(1, 2, 4, 5))); + MY_ATTRIBUTE((nonnull(1, 2, 4, 5))); /****************************************************************//** Splits a directory slot which owns too many records. */ UNIV_INTERN @@ -962,7 +963,7 @@ page_dir_split_slot( page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed part will be written, or NULL */ ulint slot_no)/*!< in: the directory slot */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*************************************************************//** Tries to balance the given directory slot with too few records with the upper neighbor, so that there are at least the minimum number @@ -975,7 +976,7 @@ page_dir_balance_slot( page_t* page, /*!< in/out: index page */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ ulint slot_no)/*!< in: the directory slot */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /**********************************************************//** Parses a log record of a record list end or start deletion. @return end of log record or NULL */ diff --git a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h index fb9250a5a3b..2892e860875 100644 --- a/storage/innobase/include/page0types.h +++ b/storage/innobase/include/page0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -131,7 +131,7 @@ page_zip_rec_set_deleted( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Write the "owned" flag of a record on a compressed page. The n_owned field @@ -143,7 +143,7 @@ page_zip_rec_set_owned( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the owned flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Shift the dense page directory when a record is deleted. */ @@ -156,7 +156,7 @@ page_zip_dir_delete( dict_index_t* index, /*!< in: index of rec */ const ulint* offsets,/*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ - __attribute__((nonnull(1,2,3,4))); + MY_ATTRIBUTE((nonnull(1,2,3,4))); /**********************************************************************//** Add a slot to the dense page directory. */ @@ -167,5 +167,5 @@ page_zip_dir_add_slot( page_zip_des_t* page_zip, /*!< in/out: compressed page */ ulint is_clustered) /*!< in: nonzero for clustered index, zero for others */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 0c2abef4b09..4e362cec641 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -1,8 +1,9 @@ /***************************************************************************** -Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2013, 2016, MariaDB Corporation 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 @@ -62,7 +63,7 @@ ulint page_zip_get_size( /*==============*/ const page_zip_des_t* page_zip) /*!< in: compressed page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /**********************************************************************//** Set the size of a compressed page in bytes. */ UNIV_INLINE @@ -85,7 +86,7 @@ page_zip_rec_needs_ext( ulint n_fields, /*!< in: number of fields in the record; ignored if zip_size == 0 */ ulint zip_size) /*!< in: compressed page size in bytes, or 0 */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************************//** Determine the guaranteed free space on an empty page. @@ -96,7 +97,7 @@ page_zip_empty_size( /*================*/ ulint n_fields, /*!< in: number of columns in the index */ ulint zip_size) /*!< in: compressed page size in bytes */ - __attribute__((const)); + MY_ATTRIBUTE((const)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -132,7 +133,7 @@ page_zip_compress( dict_index_t* index, /*!< in: index of the B-tree node */ ulint level, /*!< in: compression level */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2,3))); + MY_ATTRIBUTE((nonnull(1,2,3))); /**********************************************************************//** Decompress a page. This function should tolerate errors on the compressed @@ -150,7 +151,7 @@ page_zip_decompress( FALSE=verify but do not copy some page header fields that should not change after page creation */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); #ifndef UNIV_INNOCHECKSUM #ifdef UNIV_DEBUG @@ -179,7 +180,7 @@ page_zip_validate_low( const dict_index_t* index, /*!< in: index of the page, if known */ ibool sloppy) /*!< in: FALSE=strict, TRUE=ignore the MIN_REC_FLAG */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Check that the compressed and decompressed pages match. */ UNIV_INTERN @@ -189,7 +190,7 @@ page_zip_validate( const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_t* page, /*!< in: uncompressed page */ const dict_index_t* index) /*!< in: index of the page, if known */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); #endif /* UNIV_ZIP_DEBUG */ #ifndef UNIV_INNOCHECKSUM @@ -203,7 +204,7 @@ page_zip_max_ins_size( /*==================*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ ibool is_clust)/*!< in: TRUE if clustered index */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /**********************************************************************//** Determine if enough space is available in the modification log. @@ -217,7 +218,7 @@ page_zip_available( ulint length, /*!< in: combined size of the record */ ulint create) /*!< in: nonzero=add the record to the heap */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /**********************************************************************//** Write data to the uncompressed header portion of a page. The data must @@ -230,7 +231,7 @@ page_zip_write_header( const byte* str, /*!< in: address on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Write an entire record on the compressed page. The data must already @@ -244,7 +245,7 @@ page_zip_write_rec( dict_index_t* index, /*!< in: the index the record belongs to */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint create) /*!< in: nonzero=insert, zero=update */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Parses a log record of writing a BLOB pointer of a record. @@ -273,7 +274,7 @@ page_zip_write_blob_ptr( ulint n, /*!< in: column index */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL if no logging is needed */ - __attribute__((nonnull(1,2,3,4))); + MY_ATTRIBUTE((nonnull(1,2,3,4))); /***********************************************************//** Parses a log record of writing the node pointer of a record. @@ -298,7 +299,7 @@ page_zip_write_node_ptr( ulint size, /*!< in: data size of rec */ ulint ptr, /*!< in: node pointer */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ @@ -312,7 +313,7 @@ page_zip_write_trx_id_and_roll_ptr( ulint trx_id_col,/*!< in: column number of TRX_ID in rec */ trx_id_t trx_id, /*!< in: transaction identifier */ roll_ptr_t roll_ptr)/*!< in: roll_ptr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Write the "deleted" flag of a record on a compressed page. The flag must @@ -324,7 +325,7 @@ page_zip_rec_set_deleted( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Write the "owned" flag of a record on a compressed page. The n_owned field @@ -336,7 +337,7 @@ page_zip_rec_set_owned( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the owned flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Insert a record to the dense page directory. */ @@ -363,7 +364,7 @@ page_zip_dir_delete( const ulint* offsets, /*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ - __attribute__((nonnull(1,2,3,4))); + MY_ATTRIBUTE((nonnull(1,2,3,4))); /**********************************************************************//** Add a slot to the dense page directory. */ @@ -374,7 +375,7 @@ page_zip_dir_add_slot( page_zip_des_t* page_zip, /*!< in/out: compressed page */ ulint is_clustered) /*!< in: nonzero for clustered index, zero for others */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Parses a log record of writing to the header of a page. @@ -402,7 +403,7 @@ page_zip_write_header( const byte* str, /*!< in: address on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Reorganize and compress a page. This is a low-level operation for @@ -425,7 +426,7 @@ page_zip_reorganize( m_start, m_end, m_nonempty */ dict_index_t* index, /*!< in: index of the B-tree node */ mtr_t* mtr) /*!< in: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_INNOCHECKSUM */ #ifndef UNIV_HOTBACKUP @@ -446,7 +447,7 @@ page_zip_copy_recs( const page_t* src, /*!< in: page */ dict_index_t* index, /*!< in: index of the B-tree */ mtr_t* mtr) /*!< in: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -460,7 +461,7 @@ page_zip_parse_compress( byte* end_ptr,/*!< in: buffer end */ page_t* page, /*!< out: uncompressed page */ page_zip_des_t* page_zip)/*!< out: compressed page */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Calculate the compressed page checksum. @@ -472,7 +473,7 @@ page_zip_calc_checksum( const void* data, /*!< in: compressed page */ ulint size, /*!< in: size of compressed page */ srv_checksum_algorithm_t algo) /*!< in: algorithm to use */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Verify a compressed page's checksum. @@ -508,7 +509,7 @@ page_zip_parse_compress_no_data( page_t* page, /*!< in: uncompressed page */ page_zip_des_t* page_zip, /*!< out: compressed page */ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Reset the counters used for filling diff --git a/storage/innobase/include/pars0pars.h b/storage/innobase/include/pars0pars.h index 65ff7533828..73585c78a6a 100644 --- a/storage/innobase/include/pars0pars.h +++ b/storage/innobase/include/pars0pars.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -472,7 +472,7 @@ pars_complete_graph_for_exec( query graph, or NULL for dummy graph */ trx_t* trx, /*!< in: transaction handle */ mem_heap_t* heap) /*!< in: memory heap from which allocated */ - __attribute__((nonnull(2,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3), warn_unused_result)); /****************************************************************//** Create parser info struct. @@ -628,7 +628,7 @@ pars_info_bind_ull_literal( pars_info_t* info, /*!< in: info struct */ const char* name, /*!< in: name */ const ib_uint64_t* val) /*!< in: value */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Add bound id. */ diff --git a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h index 980faddf98e..ae75cfac6f5 100644 --- a/storage/innobase/include/read0read.h +++ b/storage/innobase/include/read0read.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -82,7 +82,7 @@ read_view_sees_trx_id( /*==================*/ const read_view_t* view, /*!< in: read view */ trx_id_t trx_id) /*!< in: trx id */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Prints a read view to stderr. */ UNIV_INTERN diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h index cb3c85ac2c8..65116229fdc 100644 --- a/storage/innobase/include/rem0cmp.h +++ b/storage/innobase/include/rem0cmp.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -174,7 +174,7 @@ cmp_dtuple_rec_with_match_low( bytes within the first field not completely matched; when function returns, contains the value for current comparison */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define cmp_dtuple_rec_with_match(tuple,rec,offsets,fields,bytes) \ cmp_dtuple_rec_with_match_low( \ tuple,rec,offsets,dtuple_get_n_fields_cmp(tuple),fields,bytes) @@ -218,7 +218,7 @@ cmp_rec_rec_simple( struct TABLE* table) /*!< in: MySQL table, for reporting duplicate key value if applicable, or NULL */ - __attribute__((nonnull(1,2,3,4), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /*************************************************************//** This function is used to compare two physical records. Only the common first fields are compared, and if an externally stored field is diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 22899c2a815..83286a98f8e 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -101,7 +101,7 @@ rec_get_next_ptr_const( /*===================*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the pointer of the next chained record on the same page. @@ -112,7 +112,7 @@ rec_get_next_ptr( /*=============*/ rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the offset of the next chained record on the same page. @@ -123,7 +123,7 @@ rec_get_next_offs( /*==============*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the next record offset field of an old-style record. */ @@ -133,7 +133,7 @@ rec_set_next_offs_old( /*==================*/ rec_t* rec, /*!< in: old-style physical record */ ulint next) /*!< in: offset of the next record */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to set the next record offset field of a new-style record. */ @@ -143,7 +143,7 @@ rec_set_next_offs_new( /*==================*/ rec_t* rec, /*!< in/out: new-style physical record */ ulint next) /*!< in: offset of the next record */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to get the number of fields in an old-style record. @@ -153,7 +153,7 @@ ulint rec_get_n_fields_old( /*=================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the number of fields in a record. @@ -164,7 +164,7 @@ rec_get_n_fields( /*=============*/ const rec_t* rec, /*!< in: physical record */ const dict_index_t* index) /*!< in: record descriptor */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the number of records owned by the previous directory record. @@ -174,7 +174,7 @@ ulint rec_get_n_owned_old( /*================*/ const rec_t* rec) /*!< in: old-style physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the number of owned records. */ UNIV_INLINE @@ -183,7 +183,7 @@ rec_set_n_owned_old( /*================*/ rec_t* rec, /*!< in: old-style physical record */ ulint n_owned) /*!< in: the number of owned */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to get the number of records owned by the previous directory record. @@ -193,7 +193,7 @@ ulint rec_get_n_owned_new( /*================*/ const rec_t* rec) /*!< in: new-style physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the number of owned records. */ UNIV_INLINE @@ -203,7 +203,7 @@ rec_set_n_owned_new( rec_t* rec, /*!< in/out: new-style physical record */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ ulint n_owned)/*!< in: the number of owned */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /******************************************************//** The following function is used to retrieve the info bits of a record. @@ -214,7 +214,7 @@ rec_get_info_bits( /*==============*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the info bits of a record. */ UNIV_INLINE @@ -223,7 +223,7 @@ rec_set_info_bits_old( /*==================*/ rec_t* rec, /*!< in: old-style physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to set the info bits of a record. */ UNIV_INLINE @@ -232,7 +232,7 @@ rec_set_info_bits_new( /*==================*/ rec_t* rec, /*!< in/out: new-style physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function retrieves the status bits of a new-style record. @return status bits */ @@ -241,7 +241,7 @@ ulint rec_get_status( /*===========*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the status bits of a new-style record. */ @@ -251,7 +251,7 @@ rec_set_status( /*===========*/ rec_t* rec, /*!< in/out: physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to retrieve the info and status @@ -263,7 +263,7 @@ rec_get_info_and_status_bits( /*=========================*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the info and status bits of a record. (Only compact records have status bits.) */ @@ -273,7 +273,7 @@ rec_set_info_and_status_bits( /*=========================*/ rec_t* rec, /*!< in/out: compact physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function tells if record is delete marked. @@ -284,7 +284,7 @@ rec_get_deleted_flag( /*=================*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the deleted bit. */ UNIV_INLINE @@ -293,7 +293,7 @@ rec_set_deleted_flag_old( /*=====================*/ rec_t* rec, /*!< in: old-style physical record */ ulint flag) /*!< in: nonzero if delete marked */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to set the deleted bit. */ UNIV_INLINE @@ -303,7 +303,7 @@ rec_set_deleted_flag_new( rec_t* rec, /*!< in/out: new-style physical record */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ ulint flag) /*!< in: nonzero if delete marked */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /******************************************************//** The following function tells if a new-style record is a node pointer. @return TRUE if node pointer */ @@ -312,7 +312,7 @@ ibool rec_get_node_ptr_flag( /*==================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the order number of an old-style record in the heap of the index page. @@ -322,7 +322,7 @@ ulint rec_get_heap_no_old( /*================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the heap number field in an old-style record. */ @@ -332,7 +332,7 @@ rec_set_heap_no_old( /*================*/ rec_t* rec, /*!< in: physical record */ ulint heap_no)/*!< in: the heap number */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to get the order number of a new-style record in the heap of the index page. @@ -342,7 +342,7 @@ ulint rec_get_heap_no_new( /*================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the heap number field in a new-style record. */ @@ -352,7 +352,7 @@ rec_set_heap_no_new( /*================*/ rec_t* rec, /*!< in/out: physical record */ ulint heap_no)/*!< in: the heap number */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to test whether the data offsets in the record are stored in one-byte or two-byte format. @@ -362,7 +362,7 @@ ibool rec_get_1byte_offs_flag( /*====================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the 1-byte offsets flag. */ @@ -372,7 +372,7 @@ rec_set_1byte_offs_flag( /*====================*/ rec_t* rec, /*!< in: physical record */ ibool flag) /*!< in: TRUE if 1byte form */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** Returns the offset of nth field end if the record is stored in the 1-byte @@ -385,7 +385,7 @@ rec_1_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: field index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns the offset of nth field end if the record is stored in the 2-byte @@ -399,7 +399,7 @@ rec_2_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: field index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns nonzero if the field is stored off-page. @@ -411,7 +411,7 @@ rec_2_is_field_extern( /*==================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: field index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Determine how many of the first n columns in a compact @@ -424,7 +424,7 @@ rec_get_n_extern_new( const rec_t* rec, /*!< in: compact physical record */ const dict_index_t* index, /*!< in: record descriptor */ ulint n) /*!< in: number of columns to scan */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** The following function determines the offsets to each field @@ -449,9 +449,9 @@ rec_get_offsets_func( #endif /* UNIV_DEBUG */ mem_heap_t** heap) /*!< in/out: memory heap */ #ifdef UNIV_DEBUG - __attribute__((nonnull(1,2,5,7),warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,5,7),warn_unused_result)); #else /* UNIV_DEBUG */ - __attribute__((nonnull(1,2,5),warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,5),warn_unused_result)); #endif /* UNIV_DEBUG */ #ifdef UNIV_DEBUG @@ -478,7 +478,7 @@ rec_get_offsets_reverse( 0=leaf node */ ulint* offsets)/*!< in/out: array consisting of offsets[0] allocated elements */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /************************************************************//** Validates offsets returned by rec_get_offsets(). @@ -491,7 +491,7 @@ rec_offs_validate( const dict_index_t* index, /*!< in: record descriptor or NULL */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull(3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(3), warn_unused_result)); /************************************************************//** Updates debug data in offsets, in order to avoid bogus rec_offs_validate() failures. */ @@ -503,7 +503,7 @@ rec_offs_make_valid( const dict_index_t* index, /*!< in: record descriptor */ ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #else # define rec_offs_make_valid(rec, index, offsets) ((void) 0) #endif /* UNIV_DEBUG */ @@ -520,7 +520,7 @@ rec_get_nth_field_offs_old( ulint n, /*!< in: index of the field */ ulint* len) /*!< out: length of the field; UNIV_SQL_NULL if SQL null */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define rec_get_nth_field_old(rec, n, len) \ ((rec) + rec_get_nth_field_offs_old(rec, n, len)) /************************************************************//** @@ -534,7 +534,7 @@ rec_get_nth_field_size( /*===================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: index of the field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /************************************************************//** The following function is used to get an offset to the nth data field in a record. @@ -547,7 +547,7 @@ rec_get_nth_field_offs( ulint n, /*!< in: index of the field */ ulint* len) /*!< out: length of the field; UNIV_SQL_NULL if SQL null */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define rec_get_nth_field(rec, offsets, n, len) \ ((rec) + rec_get_nth_field_offs(offsets, n, len)) /******************************************************//** @@ -559,7 +559,7 @@ ulint rec_offs_comp( /*==========*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Determine if the offsets are for a record containing externally stored columns. @@ -569,7 +569,7 @@ ulint rec_offs_any_extern( /*================*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Determine if the offsets are for a record containing null BLOB pointers. @return first field containing a null BLOB pointer, or NULL if none found */ @@ -579,7 +579,7 @@ rec_offs_any_null_extern( /*=====================*/ const rec_t* rec, /*!< in: record */ const ulint* offsets) /*!< in: rec_get_offsets(rec) */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns nonzero if the extern bit is set in nth field of rec. @return nonzero if externally stored */ @@ -589,7 +589,7 @@ rec_offs_nth_extern( /*================*/ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns nonzero if the SQL NULL bit is set in nth field of rec. @return nonzero if SQL NULL */ @@ -599,7 +599,7 @@ rec_offs_nth_sql_null( /*==================*/ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Gets the physical size of a field. @return length of field */ @@ -609,7 +609,7 @@ rec_offs_nth_size( /*==============*/ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns the number of extern bits set in a record. @@ -619,7 +619,7 @@ ulint rec_offs_n_extern( /*==============*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /***********************************************************//** This is used to modify the value of an already existing field in a record. The previous value must have exactly the same size as the new value. If len @@ -639,7 +639,7 @@ rec_set_nth_field( length as the previous value. If SQL null, previous value must be SQL null. */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************//** The following function returns the data size of an old-style physical record, that is the sum of field lengths. SQL null fields @@ -651,7 +651,7 @@ ulint rec_get_data_size_old( /*==================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** The following function returns the number of allocated elements for an array of offsets. @@ -661,7 +661,7 @@ ulint rec_offs_get_n_alloc( /*=================*/ const ulint* offsets)/*!< in: array for rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** The following function sets the number of allocated elements for an array of offsets. */ @@ -672,7 +672,7 @@ rec_offs_set_n_alloc( ulint* offsets, /*!< out: array for rec_get_offsets(), must be allocated */ ulint n_alloc) /*!< in: number of elements */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define rec_offs_init(offsets) \ rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets) /**********************************************************//** @@ -683,7 +683,7 @@ ulint rec_offs_n_fields( /*==============*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** The following function returns the data size of a physical record, that is the sum of field lengths. SQL null fields @@ -695,7 +695,7 @@ ulint rec_offs_data_size( /*===============*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** Returns the total size of record minus data size of record. The value returned by the function is the distance from record @@ -706,7 +706,7 @@ ulint rec_offs_extra_size( /*================*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** Returns the total size of a physical record. @return size */ @@ -715,7 +715,7 @@ ulint rec_offs_size( /*==========*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #ifdef UNIV_DEBUG /**********************************************************//** Returns a pointer to the start of the record. @@ -726,7 +726,7 @@ rec_get_start( /*==========*/ const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** Returns a pointer to the end of the record. @return pointer to end */ @@ -736,7 +736,7 @@ rec_get_end( /*========*/ const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #else /* UNIV_DEBUG */ # define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets)) # define rec_get_end(rec, offsets) ((rec) + rec_offs_data_size(offsets)) @@ -751,7 +751,7 @@ rec_copy( void* buf, /*!< in: buffer */ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /**********************************************************//** Determines the size of a data tuple prefix in a temporary file. @@ -764,7 +764,7 @@ rec_get_converted_size_temp( const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields,/*!< in: number of data fields */ ulint* extra) /*!< out: extra size */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /******************************************************//** Determine the offset to each field in temporary file. @@ -777,7 +777,7 @@ rec_init_offsets_temp( const dict_index_t* index, /*!< in: record descriptor */ ulint* offsets)/*!< in/out: array of offsets; in: n=rec_offs_n_fields(offsets) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************//** Builds a temporary file record out of a data tuple. @@ -790,7 +790,7 @@ rec_convert_dtuple_to_temp( const dict_index_t* index, /*!< in: record descriptor */ const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields) /*!< in: number of fields */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Copies the first n fields of a physical record to a new physical record in @@ -808,7 +808,7 @@ rec_copy_prefix_to_buf( for the copied prefix, or NULL */ ulint* buf_size) /*!< in/out: buffer size */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Folds a prefix of a physical record to a ulint. @return the folded value */ @@ -824,7 +824,7 @@ rec_fold( ulint n_bytes, /*!< in: number of bytes to fold in an incomplete last field */ index_id_t tree_id) /*!< in: index tree id */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************//** Builds a physical record out of a data tuple and @@ -840,7 +840,7 @@ rec_convert_dtuple_to_rec( const dtuple_t* dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Returns the extra size of an old-style physical record if we know its data size and number of fields. @@ -852,7 +852,7 @@ rec_get_converted_extra_size( ulint data_size, /*!< in: data size */ ulint n_fields, /*!< in: number of fields */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************//** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ @@ -864,7 +864,7 @@ rec_get_converted_size_comp_prefix( const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields,/*!< in: number of data fields */ ulint* extra) /*!< out: extra size */ - __attribute__((warn_unused_result, nonnull(1,2))); + MY_ATTRIBUTE((warn_unused_result, nonnull(1,2))); /**********************************************************//** Determines the size of a data tuple in ROW_FORMAT=COMPACT. @return total size */ @@ -880,7 +880,7 @@ rec_get_converted_size_comp( const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields,/*!< in: number of data fields */ ulint* extra) /*!< out: extra size */ - __attribute__((nonnull(1,3))); + MY_ATTRIBUTE((nonnull(1,3))); /**********************************************************//** The following function returns the size of a data tuple when converted to a physical record. @@ -892,7 +892,7 @@ rec_get_converted_size( dict_index_t* index, /*!< in: record descriptor */ const dtuple_t* dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); #ifndef UNIV_HOTBACKUP /**************************************************************//** Copies the first n fields of a physical record to a data tuple. @@ -907,7 +907,7 @@ rec_copy_prefix_to_dtuple( ulint n_fields, /*!< in: number of fields to copy */ mem_heap_t* heap) /*!< in: memory heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***************************************************************//** Validates the consistency of a physical record. @@ -918,7 +918,7 @@ rec_validate( /*=========*/ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints an old-style physical record. */ UNIV_INTERN @@ -927,7 +927,7 @@ rec_print_old( /*==========*/ FILE* file, /*!< in: file where to print */ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /***************************************************************//** Prints a physical record in ROW_FORMAT=COMPACT. Ignores the @@ -939,7 +939,7 @@ rec_print_comp( FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints a physical record. */ UNIV_INTERN @@ -949,7 +949,7 @@ rec_print_new( FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints a physical record. */ UNIV_INTERN @@ -959,7 +959,7 @@ rec_print( FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ const dict_index_t* index) /*!< in: record descriptor */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); # ifdef UNIV_DEBUG /************************************************************//** @@ -971,7 +971,7 @@ rec_get_trx_id( /*===========*/ const rec_t* rec, /*!< in: record */ const dict_index_t* index) /*!< in: clustered index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # endif /* UNIV_DEBUG */ #endif /* UNIV_HOTBACKUP */ diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index a539320dd2a..5811a77a48b 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1540,7 +1540,8 @@ rec_copy( ulint extra_len; ulint data_len; - ut_ad(rec && buf); + ut_ad(rec != NULL); + ut_ad(buf != NULL); ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(rec_validate(rec, offsets)); diff --git a/storage/innobase/include/row0ftsort.h b/storage/innobase/include/row0ftsort.h index eeef10f3397..00bd3317de3 100644 --- a/storage/innobase/include/row0ftsort.h +++ b/storage/innobase/include/row0ftsort.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2010, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2016, MariaDB Corporation. 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 @@ -193,7 +193,7 @@ row_fts_psort_info_init( instantiated */ fts_psort_t** merge) /*!< out: parallel merge info to be instantiated */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Clean up and deallocate FTS parallel sort structures, and close temparary merge sort files */ @@ -281,5 +281,5 @@ row_fts_merge_insert( fts_psort_t* psort_info, /*!< parallel sort info */ ulint id) /* !< in: which auxiliary table's data to insert to */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* row0ftsort_h */ diff --git a/storage/innobase/include/row0import.h b/storage/innobase/include/row0import.h index aa46fdb7c27..a821c230a3b 100644 --- a/storage/innobase/include/row0import.h +++ b/storage/innobase/include/row0import.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -46,7 +46,7 @@ row_import_for_mysql( dict_table_t* table, /*!< in/out: table */ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Update the DICT_TF2_DISCARDED flag in SYS_TABLES. @@ -64,7 +64,7 @@ row_import_update_discarded_flag( bool dict_locked) /*!< in: Set to true if the caller already owns the dict_sys_t:: mutex. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Update the (space, root page) of a table's indexes from the values @@ -83,7 +83,7 @@ row_import_update_index_root( bool dict_locked) /*!< in: Set to true if the caller already owns the dict_sys_t:: mutex. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_NONINL #include "row0import.ic" #endif diff --git a/storage/innobase/include/row0ins.h b/storage/innobase/include/row0ins.h index 2a892d2f5df..71ee39070ef 100644 --- a/storage/innobase/include/row0ins.h +++ b/storage/innobase/include/row0ins.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -53,7 +53,7 @@ row_ins_check_foreign_constraint( table, else the referenced table */ dtuple_t* entry, /*!< in: index entry for index */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Creates an insert node struct. @return own: insert node struct */ @@ -98,7 +98,7 @@ row_ins_clust_index_entry_low( dtuple_t* entry, /*!< in/out: index entry to insert */ ulint n_ext, /*!< in: number of externally stored columns */ que_thr_t* thr) /*!< in: query thread or NULL */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***************************************************************//** Tries to insert an entry into a secondary index. If a record with exactly the same fields is found, the other record is necessarily marked deleted. @@ -123,7 +123,7 @@ row_ins_sec_index_entry_low( trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during row_log_table_apply(), or 0 */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***************************************************************//** Tries to insert the externally stored fields (off-page columns) of a clustered index entry. @@ -142,7 +142,7 @@ row_ins_index_entry_big_rec_func( const void* thd, /*!< in: connection, or NULL */ #endif /* DBUG_OFF */ ulint line) /*!< in: line number of caller */ - __attribute__((nonnull(1,2,3,4,5,6), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4,5,6), warn_unused_result)); #ifdef DBUG_OFF # define row_ins_index_entry_big_rec(e,big,ofs,heap,index,thd,file,line) \ row_ins_index_entry_big_rec_func(e,big,ofs,heap,index,file,line) @@ -164,7 +164,7 @@ row_ins_clust_index_entry( dtuple_t* entry, /*!< in/out: index entry to insert */ que_thr_t* thr, /*!< in: query thread */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***************************************************************//** Inserts an entry into a secondary index. Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough @@ -178,7 +178,7 @@ row_ins_sec_index_entry( dict_index_t* index, /*!< in: secondary index */ dtuple_t* entry, /*!< in/out: index entry to insert */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************//** Inserts a row to a table. This is a high-level function used in SQL execution graphs. diff --git a/storage/innobase/include/row0log.h b/storage/innobase/include/row0log.h index e127504c484..5ff148ff045 100644 --- a/storage/innobase/include/row0log.h +++ b/storage/innobase/include/row0log.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -58,7 +58,7 @@ row_log_allocate( const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ const char* path) /*!< in: where to create temporary file */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); /******************************************************//** Free the row log for an index that was being created online. */ @@ -67,7 +67,7 @@ void row_log_free( /*=========*/ row_log_t*& log) /*!< in,own: row log */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** Free the row log for an index on which online creation was aborted. */ @@ -76,7 +76,7 @@ void row_log_abort_sec( /*==============*/ dict_index_t* index) /*!< in/out: index (x-latched) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** Try to log an operation to a secondary index that is @@ -91,7 +91,7 @@ row_log_online_op_try( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Logs an operation to a secondary index that is (or was) being created. */ UNIV_INTERN @@ -102,7 +102,7 @@ row_log_online_op( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Gets the error status of the online index rebuild log. @@ -113,7 +113,7 @@ row_log_table_get_error( /*====================*/ const dict_index_t* index) /*!< in: clustered index of a table that is being rebuilt online */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Logs a delete operation to a table that is being rebuilt. @@ -129,7 +129,7 @@ row_log_table_delete( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const byte* sys) /*!< in: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec */ - UNIV_COLD __attribute__((nonnull(1,2,3))); + UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); /******************************************************//** Logs an update operation to a table that is being rebuilt. @@ -145,7 +145,7 @@ row_log_table_update( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const dtuple_t* old_pk) /*!< in: row_log_table_get_pk() before the update */ - UNIV_COLD __attribute__((nonnull(1,2,3))); + UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); /******************************************************//** Constructs the old PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR @@ -165,7 +165,7 @@ row_log_table_get_pk( byte* sys, /*!< out: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL */ mem_heap_t** heap) /*!< in/out: memory heap where allocated */ - UNIV_COLD __attribute__((nonnull(1,2,5), warn_unused_result)); + UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,5), warn_unused_result)); /******************************************************//** Logs an insert to a table that is being rebuilt. @@ -179,7 +179,7 @@ row_log_table_insert( dict_index_t* index, /*!< in/out: clustered index, S-latched or X-latched */ const ulint* offsets)/*!< in: rec_get_offsets(rec,index) */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Notes that a BLOB is being freed during online ALTER TABLE. */ UNIV_INTERN @@ -188,7 +188,7 @@ row_log_table_blob_free( /*====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Notes that a BLOB is being allocated during online ALTER TABLE. */ UNIV_INTERN @@ -197,7 +197,7 @@ row_log_table_blob_alloc( /*=====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Apply the row_log_table log to a table upon completing rebuild. @return DB_SUCCESS, or error code on failure */ @@ -210,7 +210,7 @@ row_log_table_apply( /*!< in: old table */ struct TABLE* table) /*!< in/out: MySQL table (for reporting duplicates) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Get the latest transaction ID that has invoked row_log_online_op() @@ -221,7 +221,7 @@ trx_id_t row_log_get_max_trx( /*================*/ dict_index_t* index) /*!< in: index, must be locked */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Merge the row log to the index upon completing index creation. @@ -235,7 +235,7 @@ row_log_apply( dict_index_t* index, /*!< in/out: secondary index */ struct TABLE* table) /*!< in/out: MySQL table (for reporting duplicates) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_NONINL #include "row0log.ic" diff --git a/storage/innobase/include/row0merge.h b/storage/innobase/include/row0merge.h index 53164b5197f..04d4010ad48 100644 --- a/storage/innobase/include/row0merge.h +++ b/storage/innobase/include/row0merge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -144,7 +144,7 @@ row_merge_dup_report( /*=================*/ row_merge_dup_t* dup, /*!< in/out: for reporting duplicates */ const dfield_t* entry) /*!< in: duplicate index entry */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Sets an exclusive lock on a table, for the duration of creating indexes. @return error code or DB_SUCCESS */ @@ -155,7 +155,7 @@ row_merge_lock_table( trx_t* trx, /*!< in/out: transaction */ dict_table_t* table, /*!< in: table to lock */ enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Drop indexes that were created before an error occurred. The data dictionary must have been locked exclusively by the caller, @@ -166,7 +166,7 @@ row_merge_drop_indexes_dict( /*========================*/ trx_t* trx, /*!< in/out: dictionary transaction */ table_id_t table_id)/*!< in: table identifier */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Drop those indexes which were created before an error occurred. The data dictionary must have been locked exclusively by the caller, @@ -179,7 +179,7 @@ row_merge_drop_indexes( dict_table_t* table, /*!< in/out: table containing the indexes */ ibool locked) /*!< in: TRUE=table locked, FALSE=may need to do a lazy drop */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Drop all partially created indexes during crash recovery. */ UNIV_INTERN @@ -195,7 +195,7 @@ UNIV_INTERN int row_merge_file_create_low( const char* path) - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Destroy a merge file. And de-register the file from Performance Schema if UNIV_PFS_IO is defined. */ @@ -231,7 +231,7 @@ row_merge_rename_tables_dict( old_table->name */ const char* tmp_name, /*!< in: new name for old_table */ trx_t* trx) /*!< in/out: dictionary transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Rename an index in the dictionary that was created. The data @@ -245,7 +245,7 @@ row_merge_rename_index_to_add( trx_t* trx, /*!< in/out: transaction */ table_id_t table_id, /*!< in: table identifier */ index_id_t index_id) /*!< in: index identifier */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Rename an index in the dictionary that is to be dropped. The data dictionary must have been locked exclusively by the caller, because @@ -258,7 +258,7 @@ row_merge_rename_index_to_drop( trx_t* trx, /*!< in/out: transaction */ table_id_t table_id, /*!< in: table identifier */ index_id_t index_id) /*!< in: index identifier */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Create the index and load in to the dictionary. @return index, or NULL on error */ @@ -294,7 +294,7 @@ row_merge_drop_table( /*=================*/ trx_t* trx, /*!< in: transaction */ dict_table_t* table) /*!< in: table instance to drop */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Build indexes on a table by reading a clustered index, creating a temporary file containing index entries, merge sorting @@ -327,7 +327,7 @@ row_merge_build_indexes( AUTO_INCREMENT column, or ULINT_UNDEFINED if none is added */ ib_sequence_t& sequence) /*!< in/out: autoinc sequence */ - __attribute__((nonnull(1,2,3,5,6,8), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,5,6,8), warn_unused_result)); /********************************************************************//** Write a buffer to a block. */ UNIV_INTERN @@ -337,7 +337,7 @@ row_merge_buf_write( const row_merge_buf_t* buf, /*!< in: sorted buffer */ const merge_file_t* of, /*!< in: output file */ row_merge_block_t* block) /*!< out: buffer for writing to file */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Sort a buffer. */ UNIV_INTERN @@ -347,7 +347,7 @@ row_merge_buf_sort( row_merge_buf_t* buf, /*!< in/out: sort buffer */ row_merge_dup_t* dup) /*!< in/out: reporter of duplicates (NULL if non-unique index) */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /********************************************************************//** Write a merge block to the file system. @return TRUE if request was successful, FALSE if fail */ @@ -371,7 +371,7 @@ row_merge_buf_t* row_merge_buf_empty( /*================*/ row_merge_buf_t* buf) /*!< in,own: sort buffer */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /** Create a merge file in the given location. @param[out] merge_file merge file structure @@ -412,7 +412,7 @@ row_merge_buf_t* row_merge_buf_create( /*=================*/ dict_index_t* index) /*!< in: secondary index */ - __attribute__((warn_unused_result, nonnull, malloc)); + MY_ATTRIBUTE((warn_unused_result, nonnull, malloc)); /*********************************************************************//** Deallocate a sort buffer. */ UNIV_INTERN @@ -420,7 +420,7 @@ void row_merge_buf_free( /*===============*/ row_merge_buf_t* buf) /*!< in,own: sort buffer to be freed */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Destroy a merge file. */ UNIV_INTERN @@ -428,7 +428,7 @@ void row_merge_file_destroy( /*===================*/ merge_file_t* merge_file) /*!< in/out: merge file structure */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Read a merge block from the file system. @return TRUE if request was successful, FALSE if fail */ diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 7fda64e21b7..71e3b9bb19e 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -168,7 +168,7 @@ row_mysql_handle_errors( trx_t* trx, /*!< in: transaction */ que_thr_t* thr, /*!< in: query thread, or NULL */ trx_savept_t* savept) /*!< in: savepoint, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /********************************************************************//** Create a prebuilt struct for a MySQL table handle. @return own: a prebuilt struct */ @@ -210,7 +210,7 @@ row_lock_table_autoinc_for_mysql( /*=============================*/ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in the MySQL table handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets a table lock on the table mentioned in prebuilt. @return error code or DB_SUCCESS */ @@ -226,7 +226,7 @@ row_lock_table_for_mysql( prebuilt->select_lock_type */ ulint mode) /*!< in: lock mode of table (ignored if table==NULL) */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*********************************************************************//** Does an insert for MySQL. @return error code or DB_SUCCESS */ @@ -237,7 +237,7 @@ row_insert_for_mysql( byte* mysql_rec, /*!< in: row in the MySQL format */ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Builds a dummy query graph used in selects. */ UNIV_INTERN @@ -277,7 +277,7 @@ row_update_for_mysql( the MySQL format */ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** This can only be used when srv_locks_unsafe_for_binlog is TRUE or this session is using a READ COMMITTED or READ UNCOMMITTED isolation level. @@ -298,7 +298,7 @@ row_unlock_for_mysql( the records under pcur and clust_pcur, and we do not need to reposition the cursors. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @@ -307,7 +307,7 @@ UNIV_INTERN bool row_is_mysql_tmp_table_name( /*========================*/ - const char* name) __attribute__((warn_unused_result)); + const char* name) MY_ATTRIBUTE((warn_unused_result)); /*!< in: table name in the form 'database/tablename' */ @@ -332,7 +332,7 @@ row_update_cascade_for_mysql( upd_node_t* node, /*!< in: update node used in the cascade or set null operation */ dict_table_t* table) /*!< in: table where we do the operation */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation. */ @@ -409,7 +409,7 @@ row_create_index_for_mysql( index columns, which are then checked for not being too large. */ - __attribute__((nonnull(1,2), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2), warn_unused_result)); /*********************************************************************//** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function @@ -435,7 +435,7 @@ row_table_add_foreign_constraints( ibool reject_fks) /*!< in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended. Such lazy @@ -464,7 +464,7 @@ row_mysql_lock_table( dict_table_t* table, /*!< in: table to lock */ enum lock_mode mode, /*!< in: LOCK_X or LOCK_S */ const char* op_info) /*!< in: string for trx->op_info */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Truncates a table for MySQL. @@ -475,7 +475,7 @@ row_truncate_table_for_mysql( /*=========================*/ dict_table_t* table, /*!< in: table handle */ trx_t* trx) /*!< in: transaction handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Drops a table for MySQL. If the name of the dropped table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", @@ -491,10 +491,13 @@ row_drop_table_for_mysql( const char* name, /*!< in: table name */ trx_t* trx, /*!< in: dictionary transaction handle */ bool drop_db,/*!< in: true=dropping whole database */ + ibool create_failed,/*!lock.trx_locks */ ulint heap_size) /*!< in: mem_heap_get_size(trx->lock.lock_heap) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Prints info about a transaction. @@ -331,7 +331,7 @@ trx_print_latched( const trx_t* trx, /*!< in: transaction */ ulint max_query_len) /*!< in: max query length to print, or 0 to use the default max length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Prints info about a transaction. @@ -344,7 +344,7 @@ trx_print( const trx_t* trx, /*!< in: transaction */ ulint max_query_len) /*!< in: max query length to print, or 0 to use the default max length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Determine if a transaction is a dictionary operation. @@ -354,7 +354,7 @@ enum trx_dict_op_t trx_get_dict_operation( /*===================*/ const trx_t* trx) /*!< in: transaction */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /**********************************************************************//** Flag a transaction a dictionary operation. */ UNIV_INLINE @@ -383,7 +383,7 @@ trx_state_eq( if state != TRX_STATE_NOT_STARTED asserts that trx->state != TRX_STATE_NOT_STARTED */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # ifdef UNIV_DEBUG /**********************************************************************//** Asserts that a transaction has been started. @@ -394,7 +394,7 @@ ibool trx_assert_started( /*===============*/ const trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # endif /* UNIV_DEBUG */ /**********************************************************************//** diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index 45733921212..42ac62916e0 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -1,6 +1,7 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation 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 @@ -75,7 +76,7 @@ bool trx_undo_trx_id_is_insert( /*======================*/ const byte* trx_id) /*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /*****************************************************************//** Writes a roll ptr to an index page. In case that the size changes in @@ -216,7 +217,7 @@ trx_undo_add_page( mtr_t* mtr) /*!< in: mtr which does not have a latch to any undo log page; the caller must have reserved the rollback segment mutex */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Frees the last undo log page. The caller must hold the rollback segment mutex. */ @@ -231,7 +232,7 @@ trx_undo_free_last_page_func( mtr_t* mtr) /*!< in/out: mini-transaction which does not have a latch to any undo log page or which has allocated the undo log page */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG # define trx_undo_free_last_page(trx,undo,mtr) \ trx_undo_free_last_page_func(trx,undo,mtr) @@ -251,7 +252,7 @@ trx_undo_truncate_end( trx_undo_t* undo, /*!< in/out: undo log */ undo_no_t limit) /*!< in: all undo records with undo number >= this value should be truncated */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************************//** Truncates an undo log from the start. This function is used during a purge @@ -293,7 +294,7 @@ trx_undo_assign_undo( /*=================*/ trx_t* trx, /*!< in: transaction */ ulint type) /*!< in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Sets the state of the undo log segment at a transaction finish. @return undo log segment header page, x-latched */ @@ -343,7 +344,7 @@ void trx_undo_free_prepared( /*===================*/ trx_t* trx) /*!< in/out: PREPARED transaction */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Parses the redo log entry of an undo log page initialization. diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 56a257241d9..8557f74f756 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 30 +#define INNODB_VERSION_BUGFIX 32 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; @@ -249,8 +249,9 @@ operations (very slow); also UNIV_DEBUG must be defined */ that are only referenced from within InnoDB, not from MySQL. We disable the GCC visibility directive on all Sun operating systems because there is no easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ +#define MY_ATTRIBUTE __attribute__ #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(sun) || defined(__INTEL_COMPILER) -# define UNIV_INTERN __attribute__((visibility ("hidden"))) +# define UNIV_INTERN MY_ATTRIBUTE((visibility ("hidden"))) #else # define UNIV_INTERN #endif @@ -265,7 +266,7 @@ appears close together improving code locality of non-cold parts of program. The paths leading to call of cold functions within code are marked as unlikely by the branch prediction mechanism. optimize a rarely invoked function for size instead for speed. */ -# define UNIV_COLD __attribute__((cold)) +# define UNIV_COLD MY_ATTRIBUTE((cold)) #else # define UNIV_COLD /* empty */ #endif @@ -562,7 +563,7 @@ contains the sum of the following flag and the locally stored len. */ #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER) #define HAVE_GCC_GT_2 /* Tell the compiler that variable/function is unused. */ -# define UNIV_UNUSED __attribute__ ((unused)) +# define UNIV_UNUSED MY_ATTRIBUTE ((unused)) #else # define UNIV_UNUSED #endif /* CHECK FOR GCC VER_GT_2 */ diff --git a/storage/innobase/include/ut0byte.h b/storage/innobase/include/ut0byte.h index 5bdd553ca80..4893ab9f9af 100644 --- a/storage/innobase/include/ut0byte.h +++ b/storage/innobase/include/ut0byte.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -39,7 +39,7 @@ ut_ull_create( /*==========*/ ulint high, /*!< in: high-order 32 bits */ ulint low) /*!< in: low-order 32 bits */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************//** Rounds a 64-bit integer downward to a multiple of a power of 2. @@ -80,7 +80,7 @@ ut_align_down( /*==========*/ const void* ptr, /*!< in: pointer */ ulint align_no) /*!< in: align by this number */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*********************************************************//** The following function computes the offset of a pointer from the nearest aligned address. @@ -91,7 +91,7 @@ ut_align_offset( /*============*/ const void* ptr, /*!< in: pointer */ ulint align_no) /*!< in: align by this number */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*****************************************************************//** Gets the nth bit of a ulint. @return TRUE if nth bit is 1; 0th bit is defined to be the least significant */ diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index 6a4afe99597..3f5baef0a3c 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -59,7 +59,7 @@ ut_dbg_assertion_failed( const char* expr, /*!< in: the failed assertion */ const char* file, /*!< in: source file containing the assertion */ ulint line) /*!< in: line number of the assertion */ - UNIV_COLD __attribute__((nonnull(2))); + UNIV_COLD MY_ATTRIBUTE((nonnull(2))); /** Abort the execution. */ # define UT_DBG_PANIC abort() diff --git a/storage/innobase/include/ut0mem.h b/storage/innobase/include/ut0mem.h index af7eb4e9b1d..81470358f2f 100644 --- a/storage/innobase/include/ut0mem.h +++ b/storage/innobase/include/ut0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -87,7 +87,7 @@ ut_malloc_low( ulint n, /*!< in: number of bytes to allocate */ ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if the memory cannot be allocated */ - __attribute__((malloc)); + MY_ATTRIBUTE((malloc)); /**********************************************************************//** Allocates memory. */ #define ut_malloc(n) ut_malloc_low(n, TRUE) diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index 53b769849a5..6ed3ee3b2e5 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,7 +96,7 @@ ulint ut_fold_ull( /*========*/ ib_uint64_t d) /*!< in: 64-bit integer */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*************************************************************//** Folds a character string ending in the null character. @return folded value */ @@ -105,7 +105,7 @@ ulint ut_fold_string( /*===========*/ const char* str) /*!< in: null-terminated string */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /***********************************************************//** Looks for a prime number slightly greater than the given argument. The prime is chosen so that it is not near any power of 2. @@ -115,7 +115,7 @@ ulint ut_find_prime( /*==========*/ ulint n) /*!< in: positive number > 100 */ - __attribute__((const)); + MY_ATTRIBUTE((const)); #endif /* !UNIV_INNOCHECKSUM */ @@ -128,7 +128,7 @@ ut_fold_ulint_pair( /*===============*/ ulint n1, /*!< in: ulint */ ulint n2) /*!< in: ulint */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*************************************************************//** Folds a binary string. @return folded value */ @@ -138,7 +138,7 @@ ut_fold_binary( /*===========*/ const byte* str, /*!< in: string of bytes */ ulint len) /*!< in: length */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #ifndef UNIV_NONINL diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 176f132704a..6786ad166e8 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -241,7 +241,7 @@ ulint ut_2_power_up( /*==========*/ ulint n) /*!< in: number != 0 */ - __attribute__((const)); + MY_ATTRIBUTE((const)); #endif /* !UNIV_INNOCHECKSUM */ @@ -324,7 +324,7 @@ void ut_print_timestamp( /*===============*/ FILE* file) /*!< in: file where to print */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); #ifndef UNIV_INNOCHECKSUM @@ -524,7 +524,7 @@ ut_ulint_sort( ulint* aux_arr, /*!< in/out: aux array to use in sort */ ulint low, /*!< in: lower bound */ ulint high) /*!< in: upper bound */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_NONINL #include "ut0ut.ic" diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 165db2d33ed..b4834c05b81 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2015, MariaDB Corporation +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2016, MariaDB Corporation 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 @@ -429,7 +429,7 @@ ibool lock_rec_validate_page( /*===================*/ const buf_block_t* block) /*!< in: buffer block */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /* The lock system */ @@ -513,7 +513,7 @@ Checks that a transaction id is sensible, i.e., not in the future. #ifdef UNIV_DEBUG UNIV_INTERN #else -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) #endif bool lock_check_trx_id_sanity( @@ -1681,6 +1681,10 @@ wsrep_kill_victim( { ut_ad(lock_mutex_own()); ut_ad(trx_mutex_own(lock->trx)); + + /* quit for native mysql */ + if (!wsrep_on(trx->mysql_thd)) return; + my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); @@ -1767,9 +1771,11 @@ lock_rec_other_has_conflicting( #ifdef WITH_WSREP if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { - trx_mutex_enter(lock->trx); - wsrep_kill_victim(trx, lock); - trx_mutex_exit(lock->trx); + if (wsrep_on(trx->mysql_thd)) { + trx_mutex_enter(lock->trx); + wsrep_kill_victim(trx, lock); + trx_mutex_exit(lock->trx); + } #else if (lock_rec_has_to_wait(trx, mode, lock, is_supremum)) { #endif /* WITH_WSREP */ @@ -2063,7 +2069,9 @@ lock_rec_create( ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); #ifdef WITH_WSREP - if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + if (c_lock && + wsrep_on(trx->mysql_thd) && + wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; @@ -4017,7 +4025,7 @@ lock_get_next_lock( ut_ad(heap_no == ULINT_UNDEFINED); ut_ad(lock_get_type_low(lock) == LOCK_TABLE); - lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock); + lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock); } } while (lock != NULL && lock->trx->lock.deadlock_mark > ctx->mark_start); @@ -4067,7 +4075,8 @@ lock_get_first_lock( } else { *heap_no = ULINT_UNDEFINED; ut_ad(lock_get_type_low(lock) == LOCK_TABLE); - lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock); + dict_table_t* table = lock->un_member.tab_lock.table; + lock = UT_LIST_GET_FIRST(table->locks); } ut_a(lock != NULL); @@ -4670,10 +4679,10 @@ lock_table_create( trx_mutex_exit(c_lock->trx); } } else { - UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); - } -#else +#endif /* WITH_WSREP */ UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); +#ifdef WITH_WSREP + } #endif /* WITH_WSREP */ if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) { @@ -4999,7 +5008,8 @@ lock_table( dberr_t err; const lock_t* wait_for; - ut_ad(table && thr); + ut_ad(table != NULL); + ut_ad(thr != NULL); if (flags & BTR_NO_LOCKING_FLAG) { @@ -6431,7 +6441,7 @@ lock_validate_table_locks( /*********************************************************************//** Validate record locks up to a limit. @return lock at limit or NULL if no more locks in the hash bucket */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const lock_t* lock_rec_validate( /*==============*/ diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index a87adcf94c0..c7bd223c491 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -512,7 +512,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(lock_wait_timeout_thread)( /*=====================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /* in: a dummy parameter required by os_thread_create */ { diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 31104b395c1..89b616aba01 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved. @@ -981,7 +981,7 @@ log_group_init( ulint space_id, /*!< in: space id of the file space which contains the log files of this group */ - ulint archive_space_id __attribute__((unused))) + ulint archive_space_id MY_ATTRIBUTE((unused))) /*!< in: space id of the file space which contains some archived log files for this group; currently, only @@ -2396,7 +2396,7 @@ void log_archived_file_name_gen( /*=======================*/ char* buf, /*!< in: buffer where to write */ - ulint id __attribute__((unused)), + ulint id MY_ATTRIBUTE((unused)), /*!< in: group id; currently we only archive the first group */ ulint file_no)/*!< in: file number */ diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index d574cd55397..9fde18757c5 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. @@ -334,7 +334,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(recv_writer_thread)( /*===============================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -755,7 +755,7 @@ recv_check_cp_is_consistent( /********************************************************//** Looks for the maximum consistent checkpoint from the log groups. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t recv_find_max_checkpoint( /*=====================*/ diff --git a/storage/innobase/mem/mem0dbg.cc b/storage/innobase/mem/mem0dbg.cc index 308c2979551..a77785a369a 100644 --- a/storage/innobase/mem/mem0dbg.cc +++ b/storage/innobase/mem/mem0dbg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -248,7 +248,7 @@ void mem_field_erase( /*============*/ byte* buf, /*!< in: memory field */ - ulint n __attribute__((unused))) + ulint n MY_ATTRIBUTE((unused))) /*!< in: how many bytes the user requested */ { byte* usr_buf; @@ -450,7 +450,7 @@ void mem_heap_validate_or_print( /*=======================*/ mem_heap_t* heap, /*!< in: memory heap */ - byte* top __attribute__((unused)), + byte* top MY_ATTRIBUTE((unused)), /*!< in: calculate and validate only until this top pointer in the heap is reached, if this pointer is NULL, ignored */ diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 400aa9bff57..5843dd80524 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -58,7 +58,7 @@ mtr_block_dirtied( /*****************************************************************//** Releases the item in the slot given. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void mtr_memo_slot_release_func( /*=======================*/ @@ -105,7 +105,7 @@ mtr_memo_slot_release_func( Releases the mlocks and other objects stored in an mtr memo. They are released in the order opposite to which they were pushed to the memo. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void mtr_memo_pop_all( /*=============*/ @@ -395,7 +395,7 @@ mtr_read_ulint( /*===========*/ const byte* ptr, /*!< in: pointer from where to read */ ulint type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { ut_ad(mtr->state == MTR_ACTIVE); diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index f71a4cf125c..2db53c25b04 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2016, MariaDB Corporation. @@ -1681,8 +1681,8 @@ os_file_set_nocache( __attribute__((unused)), const char* file_name /*!< in: used in the diagnostic message */ - __attribute__((unused)), - const char* operation_name __attribute__((unused))) + MY_ATTRIBUTE((unused)), + const char* operation_name MY_ATTRIBUTE((unused))) /*!< in: "open" or "create"; used in the diagnostic message */ { @@ -2615,7 +2615,7 @@ os_file_flush_func( /*******************************************************************//** Does a synchronous read operation in Posix. @return number of bytes read, -1 if error */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ssize_t os_file_pread( /*==========*/ @@ -2726,7 +2726,7 @@ os_file_pread( /*******************************************************************//** Does a synchronous write operation in Posix. @return number of bytes written, -1 if error */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ssize_t os_file_pwrite( /*===========*/ diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 97405261392..76e4c2aed9b 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1055,6 +1055,26 @@ use_heap: insert_rec = rec_copy(insert_buf, rec, offsets); rec_offs_make_valid(insert_rec, index, offsets); + /* This is because assertion below is debug assertion */ +#ifdef UNIV_DEBUG + if (UNIV_UNLIKELY(current_rec == insert_rec)) { + ulint extra_len, data_len; + extra_len = rec_offs_extra_size(offsets); + data_len = rec_offs_data_size(offsets); + + fprintf(stderr, "InnoDB: Error: current_rec == insert_rec " + " extra_len %lu data_len %lu insert_buf %p rec %p\n", + extra_len, data_len, insert_buf, rec); + fprintf(stderr, "InnoDB; Physical record: \n"); + rec_print(stderr, rec, index); + fprintf(stderr, "InnoDB: Inserted record: \n"); + rec_print(stderr, insert_rec, index); + fprintf(stderr, "InnoDB: Current record: \n"); + rec_print(stderr, current_rec, index); + ut_a(current_rec != insert_rec); + } +#endif /* UNIV_DEBUG */ + /* 4. Insert the record in the linked list of records */ ut_ad(current_rec != insert_rec); diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index fca8641342c..a09f270a54f 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -304,7 +304,7 @@ byte* page_parse_create( /*==============*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ ulint comp, /*!< in: nonzero=compact page format */ buf_block_t* block, /*!< in: block or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 0842971c8d0..2bf1f324784 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -131,7 +131,7 @@ independently of any UNIV_ debugging conditions. */ #ifndef UNIV_INNOCHECKSUM #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG # include -__attribute__((format (printf, 1, 2))) +MY_ATTRIBUTE((format (printf, 1, 2))) /**********************************************************************//** Report a failure to decompress or compress. @return number of characters printed */ @@ -752,8 +752,8 @@ static void page_zip_free( /*==========*/ - void* opaque __attribute__((unused)), /*!< in: memory heap */ - void* address __attribute__((unused)))/*!< in: object to free */ + void* opaque MY_ATTRIBUTE((unused)), /*!< in: memory heap */ + void* address MY_ATTRIBUTE((unused)))/*!< in: object to free */ { } @@ -4807,7 +4807,8 @@ page_zip_parse_compress( ulint size; ulint trailer_size; - ut_ad(ptr && end_ptr); + ut_ad(ptr != NULL); + ut_ad(end_ptr != NULL); ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) { @@ -4928,10 +4929,10 @@ page_zip_verify_checksum( stored = static_cast(mach_read_from_4( static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - ulint page_no __attribute__((unused)) = + ulint page_no MY_ATTRIBUTE((unused)) = mach_read_from_4(static_cast (data) + FIL_PAGE_OFFSET); - ulint space_id __attribute__((unused)) = + ulint space_id MY_ATTRIBUTE((unused)) = mach_read_from_4(static_cast (data) + FIL_PAGE_SPACE_ID); diff --git a/storage/innobase/pars/lexyy.cc b/storage/innobase/pars/lexyy.cc index 1c01becd9ed..bfa8e2ea950 100644 --- a/storage/innobase/pars/lexyy.cc +++ b/storage/innobase/pars/lexyy.cc @@ -295,7 +295,7 @@ static int yy_start = 0; /* start state number */ static int yy_did_buffer_switch_on_eof; void yyrestart (FILE *input_file ); -__attribute__((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +MY_ATTRIBUTE((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); static YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); void yy_delete_buffer (YY_BUFFER_STATE b ); void yy_flush_buffer (YY_BUFFER_STATE b ); @@ -916,7 +916,7 @@ char *yytext; #line 1 "pars0lex.l" /***************************************************************************** -Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1027,7 +1027,7 @@ static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -__attribute__((unused)) static int yylex_destroy (void ); +MY_ATTRIBUTE((unused)) static int yylex_destroy (void ); int yyget_debug (void ); @@ -2664,7 +2664,7 @@ static int yy_get_next_buffer (void) * @param new_buffer The new input buffer. * */ - __attribute__((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + MY_ATTRIBUTE((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body @@ -3042,7 +3042,7 @@ static int yy_init_globals (void) } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -__attribute__((unused)) static int yylex_destroy (void) +MY_ATTRIBUTE((unused)) static int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ diff --git a/storage/innobase/pars/make_flex.sh b/storage/innobase/pars/make_flex.sh index 581fc2342aa..c3db8aea298 100755 --- a/storage/innobase/pars/make_flex.sh +++ b/storage/innobase/pars/make_flex.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -33,15 +33,15 @@ sed -e ' s/'"$TMPFILE"'/'"$OUTFILE"'/; s/\(int offset = \)\((yy_c_buf_p) - (yytext_ptr)\);/\1(int)(\2);/; s/\(void yy\(restart\|_\(delete\|flush\)_buffer\)\)/static \1/; -s/\(void yy_switch_to_buffer\)/__attribute__((unused)) static \1/; -s/\(void yy\(push\|pop\)_buffer_state\)/__attribute__((unused)) static \1/; +s/\(void yy_switch_to_buffer\)/MY_ATTRIBUTE((unused)) static \1/; +s/\(void yy\(push\|pop\)_buffer_state\)/MY_ATTRIBUTE((unused)) static \1/; s/\(YY_BUFFER_STATE yy_create_buffer\)/static \1/; -s/\(\(int\|void\) yy[gs]et_\)/__attribute__((unused)) static \1/; +s/\(\(int\|void\) yy[gs]et_\)/MY_ATTRIBUTE((unused)) static \1/; s/\(void \*\?yy\(\(re\)\?alloc\|free\)\)/static \1/; s/\(extern \)\?\(int yy\(leng\|lineno\|_flex_debug\)\)/static \2/; -s/\(int yylex_destroy\)/__attribute__((unused)) static \1/; +s/\(int yylex_destroy\)/MY_ATTRIBUTE((unused)) static \1/; s/\(extern \)\?\(int yylex \)/UNIV_INTERN \2/; -s/^\(\(FILE\|char\) *\* *yyget\)/__attribute__((unused)) static \1/; +s/^\(\(FILE\|char\) *\* *yyget\)/MY_ATTRIBUTE((unused)) static \1/; s/^\(extern \)\?\(\(FILE\|char\) *\* *yy\)/static \2/; ' < $TMPFILE >> $OUTFILE diff --git a/storage/innobase/pars/pars0pars.cc b/storage/innobase/pars/pars0pars.cc index da08939d78a..e6af3d25e86 100644 --- a/storage/innobase/pars/pars0pars.cc +++ b/storage/innobase/pars/pars0pars.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1926,7 +1926,7 @@ pars_create_table( sym_node_t* column_defs, /*!< in: list of column names */ sym_node_t* compact, /* in: non-NULL if COMPACT table. */ sym_node_t* block_size, /* in: block size (can be NULL) */ - void* not_fit_in_memory __attribute__((unused))) + void* not_fit_in_memory MY_ATTRIBUTE((unused))) /*!< in: a non-NULL pointer means that this is a table which in simulations should be simulated as not fitting @@ -2143,7 +2143,7 @@ UNIV_INTERN que_fork_t* pars_stored_procedure_call( /*=======================*/ - sym_node_t* sym_node __attribute__((unused))) + sym_node_t* sym_node MY_ATTRIBUTE((unused))) /*!< in: stored procedure name */ { ut_error; @@ -2203,7 +2203,7 @@ UNIV_INTERN void yyerror( /*====*/ - const char* s __attribute__((unused))) + const char* s MY_ATTRIBUTE((unused))) /*!< in: error message string */ { ut_ad(s); diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index 426cf9e3ac5..616ef322fb5 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -75,7 +75,7 @@ cmp_debug_dtuple_rec_with_match( completely matched fields; when function returns, contains the value for current comparison */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /*************************************************************//** This function is used to compare two data fields for which the data type @@ -659,7 +659,10 @@ cmp_dtuple_rec_with_match_low( in current field */ int ret; /* return value */ - ut_ad(dtuple && rec && matched_fields && matched_bytes); + ut_ad(dtuple != NULL); + ut_ad(rec != NULL); + ut_ad(matched_fields != NULL); + ut_ad(matched_bytes != NULL); ut_ad(dtuple_check_typed(dtuple)); ut_ad(rec_offs_validate(rec, NULL, offsets)); @@ -920,7 +923,7 @@ Compare two physical record fields. @retval 1 if rec1 field is greater than rec2 @retval -1 if rec1 field is less than rec2 @retval 0 if rec1 field equals to rec2 */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int cmp_rec_rec_simple_field( /*=====================*/ @@ -1139,7 +1142,9 @@ cmp_rec_rec_with_match( int ret = 0; /* return value */ ulint comp; - ut_ad(rec1 && rec2 && index); + ut_ad(rec1 != NULL); + ut_ad(rec2 != NULL); + ut_ad(index != NULL); ut_ad(rec_offs_validate(rec1, index, offsets1)); ut_ad(rec_offs_validate(rec2, index, offsets2)); ut_ad(rec_offs_comp(offsets1) == rec_offs_comp(offsets2)); @@ -1375,7 +1380,9 @@ cmp_debug_dtuple_rec_with_match( int ret; /* return value */ ulint cur_field; /* current field number */ - ut_ad(dtuple && rec && matched_fields); + ut_ad(dtuple != NULL); + ut_ad(rec != NULL); + ut_ad(matched_fields != NULL); ut_ad(dtuple_check_typed(dtuple)); ut_ad(rec_offs_validate(rec, NULL, offsets)); diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc index 3ff71d5c59e..9218e757f6a 100644 --- a/storage/innobase/rem/rem0rec.cc +++ b/storage/innobase/rem/rem0rec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -244,7 +244,7 @@ rec_get_n_extern_new( Determine the offset to each field in a leaf-page record in ROW_FORMAT=COMPACT. This is a special case of rec_init_offsets() and rec_get_offsets_func(). */ -UNIV_INLINE __attribute__((nonnull)) +UNIV_INLINE MY_ATTRIBUTE((nonnull)) void rec_init_offsets_comp_ordinary( /*===========================*/ @@ -788,7 +788,7 @@ rec_get_nth_field_offs_old( /**********************************************************//** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ -UNIV_INLINE __attribute__((warn_unused_result, nonnull(1,2))) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result, nonnull(1,2))) ulint rec_get_converted_size_comp_prefix_low( /*===================================*/ @@ -1133,7 +1133,7 @@ rec_convert_dtuple_to_rec_old( /*********************************************************//** Builds a ROW_FORMAT=COMPACT record out of a data tuple. */ -UNIV_INLINE __attribute__((nonnull)) +UNIV_INLINE MY_ATTRIBUTE((nonnull)) void rec_convert_dtuple_to_rec_comp( /*===========================*/ @@ -1341,7 +1341,9 @@ rec_convert_dtuple_to_rec( { rec_t* rec; - ut_ad(buf && index && dtuple); + ut_ad(buf != NULL); + ut_ad(index != NULL); + ut_ad(dtuple != NULL); ut_ad(dtuple_validate(dtuple)); ut_ad(dtuple_check_typed(dtuple)); diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 9e340f24213..bdd0e63c0a6 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -557,8 +557,18 @@ row_merge_fts_doc_tokenize( dfield_dup(field, buf->heap); /* One variable length column, word with its lenght less than - fts_max_token_size, add one extra size and one extra byte */ - cur_len += 2; + fts_max_token_size, add one extra size and one extra byte. + + Since the max length for FTS token now is larger than 255, + so we will need to signify length byte itself, so only 1 to 128 + bytes can be used for 1 bytes, larger than that 2 bytes. */ + if (t_str.f_len < 128) { + /* Extra size is one byte. */ + cur_len += 2; + } else { + /* Extra size is two bytes. */ + cur_len += 3; + } /* Reserve one byte for the end marker of row_merge_block_t and we have reserved ROW_MERGE_RESERVE_SIZE (= 4) for @@ -1042,7 +1052,7 @@ row_fts_start_parallel_merge( /********************************************************************//** Insert processed FTS data to auxillary index tables. @return DB_SUCCESS if insertion runs fine */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t row_merge_write_fts_word( /*=====================*/ diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 893ffcab3da..6dd3c4eea94 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2016, MariaDB Corporation. 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 @@ -2181,7 +2181,7 @@ PageConverter::operator() ( Clean up after import tablespace failure, this function will acquire the dictionary latches on behalf of the transaction if the transaction hasn't already acquired them. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_import_discard_changes( /*=======================*/ @@ -2232,7 +2232,7 @@ row_import_discard_changes( /*****************************************************************//** Clean up after import tablespace. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_cleanup( /*===============*/ @@ -2267,7 +2267,7 @@ row_import_cleanup( /*****************************************************************//** Report error during tablespace import. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_error( /*=============*/ @@ -2295,7 +2295,7 @@ row_import_error( Adjust the root page index node and leaf node segment headers, update with the new space id. For all the table's secondary indexes. @return error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_adjust_root_pages_of_secondary_indexes( /*==============================================*/ @@ -2411,7 +2411,7 @@ row_import_adjust_root_pages_of_secondary_indexes( /*****************************************************************//** Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). @return error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_set_sys_max_row_id( /*==========================*/ @@ -2561,7 +2561,7 @@ row_import_cfg_read_string( /*********************************************************************//** Write the meta data (index user fields) config file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_cfg_read_index_fields( /*=============================*/ @@ -2644,7 +2644,7 @@ row_import_cfg_read_index_fields( Read the index names and root page numbers of the indexes and set the values. Row format [root_page_no, len of str, str ... ] @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_index_data( /*=======================*/ @@ -2839,7 +2839,7 @@ row_import_read_indexes( /*********************************************************************//** Read the meta data (table columns) config file. Deserialise the contents of dict_col_t structure, along with the column name. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_columns( /*====================*/ @@ -2964,7 +2964,7 @@ row_import_read_columns( /*****************************************************************//** Read the contents of the .cfg file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_v1( /*===============*/ @@ -3130,7 +3130,7 @@ row_import_read_v1( /** Read the contents of the .cfg file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_meta_data( /*======================*/ @@ -3173,7 +3173,7 @@ row_import_read_meta_data( /** Read the contents of the .cfg file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_cfg( /*================*/ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index d3670bcfddd..e3817ea4de7 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -224,7 +224,7 @@ Does an insert operation by updating a delete-marked existing record in the index. This situation can occur if the delete-marked record is kept in the index for consistent reads. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_sec_index_entry_by_modify( /*==============================*/ @@ -319,7 +319,7 @@ Does an insert operation by delete unmarking and updating a delete marked existing record in the index. This situation can occur if the delete marked record is kept in the index for consistent reads. @return DB_SUCCESS, DB_FAIL, or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_clust_index_entry_by_modify( /*================================*/ @@ -427,7 +427,7 @@ row_ins_cascade_ancestor_updates_table( Returns the number of ancestor UPDATE or DELETE nodes of a cascaded update/delete node. @return number of ancestors */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint row_ins_cascade_n_ancestors( /*========================*/ @@ -453,7 +453,7 @@ a cascaded update. can also be 0 if no foreign key fields changed; the returned value is ULINT_UNDEFINED if the column type in the child table is too short to fit the new value in the parent table: that means the update fails */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint row_ins_cascade_calc_update_vec( /*============================*/ @@ -942,7 +942,7 @@ Perform referential actions or checks when a parent row is deleted or updated and the constraint had an ON DELETE or ON UPDATE condition which was not RESTRICT. @return DB_SUCCESS, DB_LOCK_WAIT, or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_foreign_check_on_constraint( /*================================*/ @@ -1784,7 +1784,7 @@ Otherwise does searches to the indexes of referenced tables and sets shared locks which lock either the success or the failure of a constraint. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_check_foreign_constraints( /*==============================*/ @@ -1925,7 +1925,7 @@ Scans a unique non-clustered index at a given index entry to determine whether a uniqueness violation has occurred for the key value of the entry. Set shared locks on possible duplicate records. @return DB_SUCCESS, DB_DUPLICATE_KEY, or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_scan_sec_index_for_duplicate( /*=================================*/ @@ -2067,7 +2067,7 @@ end_scan: @retval DB_SUCCESS_LOCKED_REC when rec is an exact match of entry or a newer version of entry (the entry should not be inserted) @retval DB_DUPLICATE_KEY when entry is a duplicate of rec */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_duplicate_online( /*=====================*/ @@ -2108,7 +2108,7 @@ row_ins_duplicate_online( @retval DB_SUCCESS_LOCKED_REC when rec is an exact match of entry or a newer version of entry (the entry should not be inserted) @retval DB_DUPLICATE_KEY when entry is a duplicate of rec */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_duplicate_error_in_clust_online( /*====================================*/ @@ -2151,7 +2151,7 @@ for a clustered index! record @retval DB_SUCCESS_LOCKED_REC if an exact match of the record was found in online table rebuild (flags & (BTR_KEEP_SYS_FLAG | BTR_NO_LOCKING_FLAG)) */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_duplicate_error_in_clust( /*=============================*/ @@ -2576,7 +2576,7 @@ func_exit: /***************************************************************//** Starts a mini-transaction and checks if the index will be dropped. @return true if the index is to be dropped */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_ins_sec_mtr_start_trx_and_check_if_aborted( /*=======================================*/ @@ -3032,7 +3032,7 @@ row_ins_index_entry( /***********************************************************//** Sets the values of the dtuple fields in entry from the values of appropriate columns in row. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_ins_index_entry_set_vals( /*=========================*/ @@ -3085,7 +3085,7 @@ row_ins_index_entry_set_vals( Inserts a single index entry to the table. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_index_entry_step( /*=====================*/ @@ -3208,7 +3208,7 @@ row_ins_get_row_from_select( Inserts a row to a table. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins( /*====*/ diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index bddc81d9fb3..5e32663ad32 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -205,7 +205,7 @@ struct row_log_t { /** Create the file or online log if it does not exist. @param[in,out] log online rebuild log @return file descriptor. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_log_tmpfile( row_log_t* log) @@ -221,7 +221,7 @@ row_log_tmpfile( /** Allocate the memory for the log buffer. @param[in,out] log_buf Buffer used for log operation @return TRUE if success, false if not */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) bool row_log_block_allocate( row_log_buf_t& log_buf) @@ -411,7 +411,7 @@ row_log_table_get_error( /******************************************************//** Starts logging an operation to a table that is being rebuilt. @return pointer to log, or NULL if no logging is necessary */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) byte* row_log_table_open( /*===============*/ @@ -446,7 +446,7 @@ err_exit: /******************************************************//** Stops logging an operation to a table that is being rebuilt. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_log_table_close_func( /*=====================*/ @@ -820,7 +820,7 @@ row_log_table_low_redundant( /******************************************************//** Logs an insert or update to a table that is being rebuilt. */ -static __attribute__((nonnull(1,2,3))) +static MY_ATTRIBUTE((nonnull(1,2,3))) void row_log_table_low( /*==============*/ @@ -1320,7 +1320,7 @@ row_log_table_blob_alloc( /******************************************************//** Converts a log record to a table row. @return converted row, or NULL if the conversion fails */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const dtuple_t* row_log_table_apply_convert_mrec( /*=============================*/ @@ -1474,7 +1474,7 @@ blob_done: /******************************************************//** Replays an insert operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_insert_low( /*===========================*/ @@ -1556,7 +1556,7 @@ row_log_table_apply_insert_low( /******************************************************//** Replays an insert operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_insert( /*=======================*/ @@ -1608,7 +1608,7 @@ row_log_table_apply_insert( /******************************************************//** Deletes a record from a table that is being rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull(1, 2, 4, 5), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1, 2, 4, 5), warn_unused_result)) dberr_t row_log_table_apply_delete_low( /*===========================*/ @@ -1706,7 +1706,7 @@ flag_ok: /******************************************************//** Replays a delete operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull(1, 3, 4, 5, 6, 7), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1, 3, 4, 5, 6, 7), warn_unused_result)) dberr_t row_log_table_apply_delete( /*=======================*/ @@ -1828,7 +1828,7 @@ all_done: /******************************************************//** Replays an update operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_update( /*=======================*/ @@ -2191,7 +2191,7 @@ func_exit_committed: Applies an operation to a table that was rebuilt. @return NULL on failure (mrec corruption) or when out of data; pointer to next record on success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const mrec_t* row_log_table_apply_op( /*===================*/ @@ -2482,7 +2482,7 @@ row_log_table_apply_op( /******************************************************//** Applies operations to a table was rebuilt. @return DB_SUCCESS, or error code on failure */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_ops( /*====================*/ @@ -2982,7 +2982,7 @@ row_log_get_max_trx( /******************************************************//** Applies an operation to a secondary index that was being created. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_log_apply_op_low( /*=================*/ @@ -3209,7 +3209,7 @@ func_exit: Applies an operation to a secondary index that was being created. @return NULL on failure (mrec corruption) or when out of data; pointer to next record on success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const mrec_t* row_log_apply_op( /*=============*/ @@ -3334,7 +3334,7 @@ corrupted: /******************************************************//** Applies operations to a secondary index that was being created. @return DB_SUCCESS, or error code on failure */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t row_log_apply_ops( /*==============*/ diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 9b5b1574280..bdedd0da85c 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -164,7 +164,7 @@ row_merge_decrypt_buf( #ifdef UNIV_DEBUG /******************************************************//** Display a merge tuple. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_merge_tuple_print( /*==================*/ @@ -199,7 +199,7 @@ row_merge_tuple_print( /******************************************************//** Encode an index record. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_merge_buf_encode( /*=================*/ @@ -236,7 +236,7 @@ row_merge_buf_encode( /******************************************************//** Allocate a sort buffer. @return own: sort buffer */ -static __attribute__((malloc, nonnull)) +static MY_ATTRIBUTE((malloc, nonnull)) row_merge_buf_t* row_merge_buf_create_low( /*=====================*/ @@ -736,7 +736,7 @@ row_merge_dup_report( /*************************************************************//** Compare two tuples. @return 1, 0, -1 if a is greater, equal, less, respectively, than b */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_merge_tuple_cmp( /*================*/ @@ -815,7 +815,7 @@ UT_SORT_FUNCTION_BODY(). /**********************************************************************//** Merge sort the tuple buffer in main memory. */ -static __attribute__((nonnull(4,5))) +static MY_ATTRIBUTE((nonnull(4,5))) void row_merge_tuple_sort( /*=================*/ @@ -1391,7 +1391,7 @@ row_merge_write_eof( @param[in,out] tmpfd temporary file handle @param[in] path path to create temporary file @return file descriptor, or -1 on failure */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_merge_tmpfile_if_needed( int* tmpfd, @@ -1410,7 +1410,7 @@ row_merge_tmpfile_if_needed( @param[in] nrec number of records in the file @param[in] path path to create temporary files @return file descriptor, or -1 on failure */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_merge_file_create_if_needed( merge_file_t* file, @@ -1459,7 +1459,7 @@ containing the index entries for the indexes to be built. @param[in] crypt_data crypt data or NULL @param[in,out] crypt_block crypted file buffer return DB_SUCCESS or error */ -static __attribute__((nonnull(1,2,3,4,6,9,10,16), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,4,6,9,10,16), warn_unused_result)) dberr_t row_merge_read_clustered_index( trx_t* trx, @@ -2170,7 +2170,7 @@ wait_again: /* Sync fts cache for other fts indexes to keep all fts indexes consistent in sync_doc_id. */ err = fts_sync_table(const_cast(new_table), - false, true); + false, true, false); if (err == DB_SUCCESS) { fts_update_next_doc_id( @@ -2625,10 +2625,16 @@ row_merge_sort( of file marker). Thus, it must be at least one block. */ ut_ad(file->offset > 0); + /* These thd_progress* calls will crash on sol10-64 when innodb_plugin + is used. MDEV-9356: innodb.innodb_bug53290 fails (crashes) on + sol10-64 in buildbot. + */ +#ifndef UNIV_SOLARIS /* Progress report only for "normal" indexes. */ if (!(dup->index->type & DICT_FTS)) { thd_progress_init(trx->mysql_thd, 1); } +#endif /* UNIV_SOLARIS */ sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs); @@ -2637,9 +2643,11 @@ row_merge_sort( /* Report progress of merge sort to MySQL for show processlist progress field */ /* Progress report only for "normal" indexes. */ +#ifndef UNIV_SOLARIS if (!(dup->index->type & DICT_FTS)) { thd_progress_report(trx->mysql_thd, file->offset - num_runs, file->offset); } +#endif /* UNIV_SOLARIS */ error = row_merge(trx, dup, file, block, tmpfd, &num_runs, run_offset, @@ -2664,16 +2672,18 @@ row_merge_sort( mem_free(run_offset); /* Progress report only for "normal" indexes. */ +#ifndef UNIV_SOLARIS if (!(dup->index->type & DICT_FTS)) { thd_progress_end(trx->mysql_thd); } +#endif /* UNIV_SOLARIS */ DBUG_RETURN(error); } /*************************************************************//** Copy externally stored columns to the data tuple. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_merge_copy_blobs( /*=================*/ @@ -3755,7 +3765,7 @@ row_merge_rename_tables_dict( /*********************************************************************//** Create and execute a query graph for creating an index. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_merge_create_index_graph( /*=========================*/ @@ -3907,7 +3917,7 @@ row_merge_drop_table( /* There must be no open transactions on the table. */ ut_a(table->n_ref_count == 0); - return(row_drop_table_for_mysql(table->name, trx, false, false)); + return(row_drop_table_for_mysql(table->name, trx, false, false, false)); } /*********************************************************************//** diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 24d25a0b2c8..a5ab4f4911e 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1432,9 +1432,12 @@ error_exit: } /* Difference between Doc IDs are restricted within - 4 bytes integer. See fts_get_encoded_len() */ + 4 bytes integer. See fts_get_encoded_len(). Consecutive + doc_ids difference should not exceed + FTS_DOC_ID_MAX_STEP value. */ - if (doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { + if (next_doc_id > 1 + && doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { fprintf(stderr, "InnoDB: Doc ID " UINT64PF " is too" " big. Its difference with largest" @@ -1700,7 +1703,8 @@ row_update_for_mysql( trx_t* trx = prebuilt->trx; ulint fk_depth = 0; - ut_ad(prebuilt && trx); + ut_ad(prebuilt != NULL); + ut_ad(trx != NULL); UT_NOT_USED(mysql_rec); if (prebuilt->table->ibd_file_missing) { @@ -1917,7 +1921,8 @@ row_unlock_for_mysql( btr_pcur_t* clust_pcur = &prebuilt->clust_pcur; trx_t* trx = prebuilt->trx; - ut_ad(prebuilt && trx); + ut_ad(prebuilt != NULL); + ut_ad(trx != NULL); if (UNIV_UNLIKELY (!srv_locks_unsafe_for_binlog @@ -2405,7 +2410,7 @@ err_exit: dict_table_close(table, TRUE, FALSE); - row_drop_table_for_mysql(table->name, trx, FALSE); + row_drop_table_for_mysql(table->name, trx, FALSE, TRUE); if (commit) { trx_commit_for_mysql(trx); @@ -2565,7 +2570,7 @@ error_handling: trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE, TRUE); trx_commit_for_mysql(trx); @@ -2642,7 +2647,7 @@ row_table_add_foreign_constraints( trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(name, trx, FALSE); + row_drop_table_for_mysql(name, trx, FALSE, TRUE); trx_commit_for_mysql(trx); @@ -2683,7 +2688,7 @@ row_drop_table_for_mysql_in_background( /* Try to drop the table in InnoDB */ - error = row_drop_table_for_mysql(name, trx, FALSE); + error = row_drop_table_for_mysql(name, trx, FALSE, FALSE); /* Flush the log to reduce probability that the .frm files and the InnoDB data dictionary get out-of-sync if the user runs @@ -3830,6 +3835,9 @@ row_drop_table_for_mysql( const char* name, /*!< in: table name */ trx_t* trx, /*!< in: transaction handle */ bool drop_db,/*!< in: true=dropping whole database */ + ibool create_failed,/*!foreign_table_name_lookup); - if (foreign->foreign_table != table && !ref_ok) { + /* We should allow dropping a referenced table if creating + that referenced table has failed for some reason. For example + if referenced table is created but it column types that are + referenced do not match. */ + if (foreign->foreign_table != table && + !create_failed && !ref_ok) { FILE* ef = dict_foreign_err_file; @@ -4578,7 +4591,7 @@ row_mysql_drop_temp_tables(void) table = dict_load_table(table_name, TRUE, DICT_ERR_IGNORE_NONE); if (table) { - row_drop_table_for_mysql(table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE, FALSE); trx_commit_for_mysql(trx); } @@ -4598,7 +4611,7 @@ row_mysql_drop_temp_tables(void) Drop all foreign keys in a database, see Bug#18942. Called at the end of row_drop_database_for_mysql(). @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t drop_all_foreign_keys_in_db( /*========================*/ @@ -4747,7 +4760,7 @@ loop: goto loop; } - err = row_drop_table_for_mysql(table_name, trx, TRUE); + err = row_drop_table_for_mysql(table_name, trx, TRUE, FALSE); trx_commit_for_mysql(trx); if (err != DB_SUCCESS) { @@ -4790,7 +4803,7 @@ loop: Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @return true if temporary table */ -UNIV_INTERN __attribute__((warn_unused_result)) +UNIV_INTERN MY_ATTRIBUTE((warn_unused_result)) bool row_is_mysql_tmp_table_name( /*========================*/ @@ -4804,7 +4817,7 @@ row_is_mysql_tmp_table_name( /****************************************************************//** Delete a single constraint. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_delete_constraint_low( /*======================*/ @@ -4827,7 +4840,7 @@ row_delete_constraint_low( /****************************************************************//** Delete a single constraint. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_delete_constraint( /*==================*/ diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index b26ba971a95..bc2e0b0e1cb 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -69,7 +69,8 @@ row_purge_node_create( { purge_node_t* node; - ut_ad(parent && heap); + ut_ad(parent != NULL); + ut_ad(heap != NULL); node = static_cast( mem_heap_zalloc(heap, sizeof(*node))); @@ -120,7 +121,7 @@ row_purge_reposition_pcur( Removes a delete marked clustered index record if possible. @retval true if the row was not found, or it was successfully removed @retval false if the row was modified after the delete marking */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_remove_clust_if_poss_low( /*===============================*/ @@ -202,7 +203,7 @@ marking. @retval true if the row was not found, or it was successfully removed @retval false the purge needs to be suspended because of running out of file space. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_remove_clust_if_poss( /*===========================*/ @@ -274,7 +275,7 @@ row_purge_poss_sec( Removes a secondary index entry if possible, by modifying the index tree. Does not try to buffer the delete. @return TRUE if success or if not found */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ibool row_purge_remove_sec_if_poss_tree( /*==============================*/ @@ -396,7 +397,7 @@ Removes a secondary index entry without modifying the index tree, if possible. @retval true if success or if not found @retval false if row_purge_remove_sec_if_poss_tree() should be invoked */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_remove_sec_if_poss_leaf( /*==============================*/ @@ -507,7 +508,7 @@ row_purge_remove_sec_if_poss_leaf( /***********************************************************//** Removes a secondary index entry if possible. */ -UNIV_INLINE __attribute__((nonnull(1,2))) +UNIV_INLINE MY_ATTRIBUTE((nonnull(1,2))) void row_purge_remove_sec_if_poss( /*=========================*/ @@ -554,7 +555,7 @@ Purges a delete marking of a record. @retval true if the row was not found, or it was successfully removed @retval false the purge needs to be suspended because of running out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_del_mark( /*===============*/ @@ -745,7 +746,8 @@ row_purge_parse_undo_rec( ulint info_bits; ulint type; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); ptr = trx_undo_rec_get_pars( undo_rec, &type, &node->cmpl_info, @@ -830,7 +832,7 @@ err_exit: /***********************************************************//** Purges the parsed record. @return true if purged, false if skipped */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_record_func( /*==================*/ @@ -895,7 +897,7 @@ row_purge_record_func( Fetches an undo log record and does the purge for the recorded operation. If none left, or the current purge completed, returns the control to the parent node, which is always a query thread node. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_purge( /*======*/ diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index ecd6f47947b..583fbe60fb3 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -37,7 +37,7 @@ Created 2012-02-08 by Sunny Bains. /*********************************************************************//** Write the meta data (index user fields) config file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_index_fields( /*===========================*/ @@ -97,7 +97,7 @@ row_quiesce_write_index_fields( /*********************************************************************//** Write the meta data config file index information. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_indexes( /*======================*/ @@ -210,7 +210,7 @@ Write the meta data (table columns) config file. Serialise the contents of dict_col_t structure, along with the column name. All fields are serialized as ib_uint32_t. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_table( /*====================*/ @@ -293,7 +293,7 @@ row_quiesce_write_table( /*********************************************************************//** Write the meta data config file header. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_header( /*=====================*/ @@ -415,7 +415,7 @@ row_quiesce_write_header( /*********************************************************************//** Write the table meta data after quiesce. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_cfg( /*==================*/ @@ -530,10 +530,8 @@ row_quiesce_table_start( trx_purge_stop(); } - ut_a(table->id > 0); - for (ulint count = 0; - ibuf_contract_in_background(table->id, TRUE) != 0 + ibuf_merge_space(table->space) != 0 && !trx_is_interrupted(trx); ++count) { if (!(count % 20)) { diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index be786f954fb..96d25e15777 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -240,7 +240,9 @@ row_build( ulint offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs_init(offsets_); - ut_ad(index && rec && heap); + ut_ad(index != NULL); + ut_ad(rec != NULL); + ut_ad(heap != NULL); ut_ad(dict_index_is_clust(index)); ut_ad(!mutex_own(&trx_sys->mutex)); ut_ad(!col_map || col_table); @@ -409,7 +411,9 @@ row_rec_to_index_entry_low( ulint len; ulint rec_len; - ut_ad(rec && heap && index); + ut_ad(rec != NULL); + ut_ad(heap != NULL); + ut_ad(index != NULL); /* Because this function may be invoked by row0merge.cc on a record whose header is in different format, the check rec_offs_validate(rec, index, offsets) must be avoided here. */ @@ -464,7 +468,9 @@ row_rec_to_index_entry( byte* buf; const rec_t* copy_rec; - ut_ad(rec && heap && index); + ut_ad(rec != NULL); + ut_ad(heap != NULL); + ut_ad(index != NULL); ut_ad(rec_offs_validate(rec, index, offsets)); /* Take a copy of rec to heap */ @@ -523,7 +529,9 @@ row_build_row_ref( ulint* offsets = offsets_; rec_offs_init(offsets_); - ut_ad(index && rec && heap); + ut_ad(index != NULL); + ut_ad(rec != NULL); + ut_ad(heap != NULL); ut_ad(!dict_index_is_clust(index)); offsets = rec_get_offsets(rec, index, offsets, diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index ea2f93dd788..dab1bc58db5 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2015, MariaDB Corporation. @@ -678,7 +678,7 @@ sel_enqueue_prefetched_row( /*********************************************************************//** Builds a previous version of a clustered index record for a consistent read @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_build_prev_vers( /*====================*/ @@ -713,7 +713,7 @@ row_sel_build_prev_vers( /*********************************************************************//** Builds the last committed version of a clustered index record for a semi-consistent read. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_sel_build_committed_vers_for_mysql( /*===================================*/ @@ -811,7 +811,7 @@ row_sel_test_other_conds( Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_get_clust_rec( /*==================*/ @@ -1314,7 +1314,7 @@ func_exit: /*********************************************************************//** Performs a select step. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel( /*====*/ @@ -2561,7 +2561,7 @@ row_sel_store_row_id_to_prebuilt( /**************************************************************//** Stores a non-SQL-NULL field in the MySQL format. The counterpart of this function is row_mysql_store_col_in_innobase_format() in row0mysql.cc. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_sel_field_store_in_mysql_format_func( /*=====================================*/ @@ -2750,7 +2750,7 @@ row_sel_field_store_in_mysql_format_func( #endif /* UNIV_DEBUG */ /**************************************************************//** Convert a field in the Innobase format to a field in the MySQL format. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool row_sel_store_mysql_field_func( /*===========================*/ @@ -2900,7 +2900,7 @@ Note that the template in prebuilt may advise us to copy only a few columns to mysql_rec, other columns are left blank. All columns may not be needed in the query. @return TRUE on success, FALSE if not all columns could be retrieved */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool row_sel_store_mysql_rec( /*====================*/ @@ -2967,7 +2967,7 @@ row_sel_store_mysql_rec( /*********************************************************************//** Builds a previous version of a clustered index record for a consistent read @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_build_prev_vers_for_mysql( /*==============================*/ @@ -3004,7 +3004,7 @@ Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. Used in the MySQL interface. @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_get_clust_rec_for_mysql( /*============================*/ diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 849bf096492..651042fb820 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -61,7 +61,7 @@ introduced where a call to log_free_check() is bypassed. */ Removes a clustered index record. The pcur in node was positioned on the record, now it is detached. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_clust_rec( /*==========================*/ @@ -176,7 +176,7 @@ func_exit: /***************************************************************//** Removes a secondary index entry if found. @return DB_SUCCESS, DB_FAIL, or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_sec_low( /*========================*/ @@ -251,7 +251,7 @@ func_exit_no_pcur: Removes a secondary index entry from the index if found. Tries first optimistic, then pessimistic descent down the tree. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_sec( /*====================*/ @@ -350,7 +350,7 @@ close_table: /***************************************************************//** Removes secondary index records. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_sec_rec( /*========================*/ diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index 7649add4b33..a64e41786d6 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -72,7 +72,7 @@ introduced where a call to log_free_check() is bypassed. */ /***********************************************************//** Undoes a modify in a clustered index record. @return DB_SUCCESS, DB_FAIL, or error code: we may run out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_clust_low( /*===================*/ @@ -154,7 +154,7 @@ This is attempted when the record was inserted by updating a delete-marked record and there no longer exist transactions that would see the delete-marked record. @return DB_SUCCESS, DB_FAIL, or error code: we may run out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_remove_clust_low( /*==========================*/ @@ -273,7 +273,7 @@ row_undo_mod_remove_clust_low( Undoes a modify in a clustered index record. Sets also the node state for the next round of undo. @return DB_SUCCESS or error code: we may run out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_clust( /*===============*/ @@ -417,7 +417,7 @@ row_undo_mod_clust( /***********************************************************//** Delete marks or removes a secondary index entry if found. @return DB_SUCCESS, DB_FAIL, or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_mark_or_remove_sec_low( /*====================================*/ @@ -553,7 +553,7 @@ not cause problems because in row0sel.cc, in queries we always retrieve the clustered index record or an earlier version of it, if the secondary index record through which we do the search is delete-marked. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_mark_or_remove_sec( /*================================*/ @@ -586,7 +586,7 @@ fields but alphabetically they stayed the same, e.g., 'abc' -> 'aBc'. @retval DB_OUT_OF_FILE_SPACE when running out of tablespace @retval DB_DUPLICATE_KEY if the value was missing and an insert would lead to a duplicate exists */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_unmark_sec_and_undo_update( /*========================================*/ @@ -782,7 +782,7 @@ func_exit_no_pcur: /***********************************************************//** Flags a secondary index corrupted. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_undo_mod_sec_flag_corrupted( /*============================*/ @@ -814,7 +814,7 @@ row_undo_mod_sec_flag_corrupted( /***********************************************************//** Undoes a modify in secondary indexes when undo record type is UPD_DEL. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_upd_del_sec( /*=====================*/ @@ -881,7 +881,7 @@ row_undo_mod_upd_del_sec( /***********************************************************//** Undoes a modify in secondary indexes when undo record type is DEL_MARK. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_mark_sec( /*======================*/ @@ -949,7 +949,7 @@ row_undo_mod_del_mark_sec( /***********************************************************//** Undoes a modify in secondary indexes when undo record type is UPD_EXIST. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_upd_exist_sec( /*=======================*/ @@ -1065,7 +1065,7 @@ row_undo_mod_upd_exist_sec( /***********************************************************//** Parses the row reference and other info in a modify undo log record. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_undo_mod_parse_undo_rec( /*========================*/ @@ -1142,7 +1142,8 @@ row_undo_mod( dberr_t err; ibool dict_locked; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); ut_ad(node->state == UNDO_NODE_MODIFY); dict_locked = thr_get_trx(thr)->dict_operation_lock_mode == RW_X_LATCH; diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc index 9977a1e8f04..149dc671930 100644 --- a/storage/innobase/row/row0undo.cc +++ b/storage/innobase/row/row0undo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -245,7 +245,7 @@ Fetches an undo log record and does the undo for the recorded operation. If none left, or a partial rollback completed, returns control to the parent node, which is always a query thread node. @return DB_SUCCESS if operation successfully completed, else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo( /*=====*/ @@ -257,7 +257,8 @@ row_undo( roll_ptr_t roll_ptr; ibool locked_data_dict; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); trx = node->trx; diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 0ea4865d15f..60b490228b1 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -219,7 +219,7 @@ NOTE that this function will temporarily commit mtr and lose the pcur position! @return DB_SUCCESS or an error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_check_references_constraints( /*=================================*/ @@ -412,7 +412,7 @@ wsrep_row_upd_check_foreign_constraints( dict_table_open_on_name( foreign->referenced_table_name_lookup, FALSE, FALSE, DICT_ERR_IGNORE_NONE); - opened = TRUE; + opened = (foreign->referenced_table) ? TRUE : FALSE; } if (foreign->referenced_table) { @@ -435,7 +435,7 @@ wsrep_row_upd_check_foreign_constraints( ->n_foreign_key_checks_running); if (opened == TRUE) { - dict_table_close(foreign->referenced_table, TRUE, FALSE); + dict_table_close(foreign->referenced_table, FALSE, FALSE); opened = FALSE; } } @@ -775,7 +775,7 @@ row_upd_write_sys_vals_to_log( roll_ptr_t roll_ptr,/*!< in: roll ptr of the undo log record */ byte* log_ptr,/*!< pointer to a buffer of size > 20 opened in mlog */ - mtr_t* mtr __attribute__((unused))) /*!< in: mtr */ + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mtr */ { ut_ad(dict_index_is_clust(index)); ut_ad(mtr); @@ -1810,7 +1810,7 @@ row_upd_store_row( Updates a secondary index entry of a row. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_sec_index_entry( /*====================*/ @@ -2049,7 +2049,7 @@ Updates the secondary index record if it is changed in the row update or deletes it if this is a delete. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_sec_step( /*=============*/ @@ -2082,7 +2082,7 @@ updated. We must mark them as inherited in entry, so that they are not freed in a rollback. A limited version of this function used to be called btr_cur_mark_dtuple_inherited_extern(). @return TRUE if any columns were inherited */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool row_upd_clust_rec_by_insert_inherit_func( /*=====================================*/ @@ -2161,7 +2161,7 @@ fields of the clustered index record change. This should be quite rare in database applications. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_clust_rec_by_insert( /*========================*/ @@ -2320,7 +2320,7 @@ Updates a clustered index record of a row when the ordering fields do not change. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_clust_rec( /*==============*/ @@ -2479,7 +2479,7 @@ func_exit: /***********************************************************//** Delete marks a clustered index record. @return DB_SUCCESS if operation successfully completed, else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_del_mark_clust_rec( /*=======================*/ @@ -2572,7 +2572,7 @@ row_upd_del_mark_clust_rec( Updates the clustered index record. @return DB_SUCCESS if operation successfully completed, DB_LOCK_WAIT in case of a lock wait, else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_clust_step( /*===============*/ @@ -2780,7 +2780,7 @@ to this node, we assume that we have a persistent cursor which was on a record, and the position of the cursor is stored in the cursor. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd( /*====*/ @@ -2789,7 +2789,8 @@ row_upd( { dberr_t err = DB_SUCCESS; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); if (UNIV_LIKELY(node->in_mysql_interface)) { diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 1d6a4c008e8..3375ea40658 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2016, MariaDB Corporation @@ -1493,7 +1493,10 @@ srv_mon_set_module_control( module */ set_current_module = FALSE; } else if (module_id == MONITOR_ALL_COUNTER) { - continue; + if (!(innodb_counter_info[ix].monitor_type + & MONITOR_GROUP_MODULE)) { + continue; + } } else { /* Hitting the next module, stop */ break; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index c28f889dfcc..e17b27b44fc 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1686,7 +1686,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_monitor_thread)( /*===============================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -1863,7 +1863,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_error_monitor_thread)( /*=====================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -2309,7 +2309,7 @@ srv_master_do_active_tasks(void) /* Do an ibuf merge */ srv_main_thread_op_info = "doing insert buffer merge"; counter_time = ut_time_us(NULL); - ibuf_contract_in_background(0, FALSE); + ibuf_merge_in_background(false); MONITOR_INC_TIME_IN_MICRO_SECS( MONITOR_SRV_IBUF_MERGE_MICROSECOND, counter_time); @@ -2404,7 +2404,7 @@ srv_master_do_idle_tasks(void) /* Do an ibuf merge */ counter_time = ut_time_us(NULL); srv_main_thread_op_info = "doing insert buffer merge"; - ibuf_contract_in_background(0, TRUE); + ibuf_merge_in_background(true); MONITOR_INC_TIME_IN_MICRO_SECS( MONITOR_SRV_IBUF_MERGE_MICROSECOND, counter_time); @@ -2482,7 +2482,7 @@ srv_master_do_shutdown_tasks( /* Do an ibuf merge */ srv_main_thread_op_info = "doing insert buffer merge"; - n_bytes_merged = ibuf_contract_in_background(0, TRUE); + n_bytes_merged = ibuf_merge_in_background(true); /* Flush logs if needed */ srv_sync_log_buffer_in_background(); @@ -2522,7 +2522,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_master_thread)( /*==============================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -2666,7 +2666,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_worker_thread)( /*==============================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { srv_slot_t* slot; @@ -2924,7 +2924,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_purge_coordinator_thread)( /*=========================================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { srv_slot_t* slot; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 4a457ae6f00..0b81ad86f1c 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2015, MariaDB Corporation @@ -532,7 +532,7 @@ UNIV_INTERN void srv_normalize_path_for_win( /*=======================*/ - char* str __attribute__((unused))) /*!< in/out: null-terminated + char* str MY_ATTRIBUTE((unused))) /*!< in/out: null-terminated character string */ { #ifdef __WIN__ @@ -549,7 +549,7 @@ srv_normalize_path_for_win( /*********************************************************************//** Creates a log file. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t create_log_file( /*============*/ @@ -757,7 +757,7 @@ create_log_files_rename( /*********************************************************************//** Opens a log file. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t open_log_file( /*==========*/ @@ -785,7 +785,7 @@ open_log_file( /*********************************************************************//** Creates or opens database data files and closes them. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t open_or_create_data_files( /*======================*/ diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc index 7eb3d0bd6f2..3e3ce353724 100644 --- a/storage/innobase/sync/sync0sync.cc +++ b/storage/innobase/sync/sync0sync.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -386,10 +386,10 @@ ulint mutex_enter_nowait_func( /*====================*/ ib_mutex_t* mutex, /*!< in: pointer to mutex */ - const char* file_name __attribute__((unused)), + const char* file_name MY_ATTRIBUTE((unused)), /*!< in: file name where mutex requested */ - ulint line __attribute__((unused))) + ulint line MY_ATTRIBUTE((unused))) /*!< in: line where requested */ { ut_ad(mutex_validate(mutex)); diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 56d46311f62..efc600d16b1 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -913,7 +913,7 @@ Fetches the next undo log record from the history list to purge. It must be released with the corresponding release function. @return copy of an undo log record or pointer to trx_purge_dummy_rec, if the whole undo log can skipped in purge; NULL if none left */ -static __attribute__((warn_unused_result, nonnull)) +static MY_ATTRIBUTE((warn_unused_result, nonnull)) trx_undo_rec_t* trx_purge_fetch_next_rec( /*=====================*/ diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index fa3fe0904b8..74a63b60286 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1133,7 +1133,7 @@ trx_undo_rec_get_partial_row( /***********************************************************************//** Erases the unused undo log page end. @return TRUE if the page contained something, FALSE if it was empty */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) ibool trx_undo_erase_page_end( /*====================*/ @@ -1159,7 +1159,7 @@ byte* trx_undo_parse_erase_page_end( /*==========================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ page_t* page, /*!< in: page or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ { @@ -1442,7 +1442,7 @@ NOTE: the caller must have latches on the clustered index page. @retval true if the undo log has been truncated and we cannot fetch the old version @retval false if the undo log record is available */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool trx_undo_get_undo_rec( /*==================*/ @@ -1470,7 +1470,7 @@ trx_undo_get_undo_rec( #ifdef UNIV_DEBUG #define ATTRIB_USED_ONLY_IN_DEBUG #else /* UNIV_DEBUG */ -#define ATTRIB_USED_ONLY_IN_DEBUG __attribute__((unused)) +#define ATTRIB_USED_ONLY_IN_DEBUG MY_ATTRIBUTE((unused)) #endif /* UNIV_DEBUG */ /*******************************************************************//** diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index e2c3c0b949c..c65d95a9817 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -336,7 +336,7 @@ the row, these locks are naturally released in the rollback. Savepoints which were set after this savepoint are deleted. @return if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t trx_rollback_to_savepoint_for_mysql_low( /*====================================*/ @@ -641,7 +641,7 @@ trx_rollback_active( "in recovery", table->name, trx->table_id); - err = row_drop_table_for_mysql(table->name, trx, TRUE); + err = row_drop_table_for_mysql(table->name, trx, TRUE, FALSE); trx_commit_for_mysql(trx); ut_a(err == DB_SUCCESS); @@ -796,7 +796,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(trx_rollback_or_clean_all_recovered)( /*================================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 7f3cfa22255..1a99e159d41 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -973,7 +973,7 @@ trx_serialisation_number_get( /****************************************************************//** Assign the transaction its history serialisation number and write the update UNDO log record to the assigned rollback segment. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_write_serialisation_history( /*============================*/ @@ -1060,7 +1060,7 @@ trx_write_serialisation_history( /******************************************************************** Finalize a transaction containing updates for a FTS table. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_finalize_for_fts_table( /*=======================*/ @@ -1093,7 +1093,7 @@ trx_finalize_for_fts_table( /******************************************************************//** Finalize a transaction containing updates to FTS tables. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_finalize_for_fts( /*=================*/ @@ -1161,7 +1161,7 @@ trx_flush_log_if_needed_low( /**********************************************************************//** If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_flush_log_if_needed( /*====================*/ @@ -1176,7 +1176,7 @@ trx_flush_log_if_needed( /****************************************************************//** Commits a transaction in memory. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_commit_in_memory( /*=================*/ @@ -2165,7 +2165,7 @@ which is in the prepared state @return trx on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) trx_t* trx_get_trx_by_xid_low( /*===================*/ diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index edb85a89c17..cdd23726f2e 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -419,11 +419,11 @@ trx_undo_page_init( Creates a new undo log segment in file. @return DB_SUCCESS if page creation OK possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t trx_undo_seg_create( /*================*/ - trx_rseg_t* rseg __attribute__((unused)),/*!< in: rollback segment */ + trx_rseg_t* rseg MY_ATTRIBUTE((unused)),/*!< in: rollback segment */ trx_rsegf_t* rseg_hdr,/*!< in: rollback segment header, page x-latched */ ulint type, /*!< in: type of the segment: TRX_UNDO_INSERT or @@ -443,7 +443,9 @@ trx_undo_seg_create( ibool success; dberr_t err = DB_SUCCESS; - ut_ad(mtr && id && rseg_hdr); + ut_ad(mtr != NULL); + ut_ad(id != NULL); + ut_ad(rseg_hdr != NULL); ut_ad(mutex_own(&(rseg->mutex))); /* fputs(type == TRX_UNDO_INSERT @@ -827,7 +829,7 @@ byte* trx_undo_parse_discard_latest( /*==========================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ page_t* page, /*!< in: page or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ { @@ -1555,7 +1557,7 @@ Creates a new undo log. @return DB_SUCCESS if successful in creating the new undo lob object, possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_OUT_OF_MEMORY */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t trx_undo_create( /*============*/ diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c index 36b729e6053..21b4758a720 100644 --- a/storage/maria/ma_checkpoint.c +++ b/storage/maria/ma_checkpoint.c @@ -46,7 +46,7 @@ static mysql_mutex_t LOCK_checkpoint; static mysql_cond_t COND_checkpoint; /** @brief control structure for checkpoint background thread */ static MA_SERVICE_THREAD_CONTROL checkpoint_control= - {THREAD_DEAD, FALSE, &LOCK_checkpoint, &COND_checkpoint}; + {0, FALSE, FALSE, &LOCK_checkpoint, &COND_checkpoint}; /* is ulong like pagecache->blocks_changed */ static ulong pages_to_flush_before_next_checkpoint; static PAGECACHE_FILE *dfiles, /**< data files to flush in background */ @@ -326,7 +326,6 @@ end: int ma_checkpoint_init(ulong interval) { - pthread_t th; int res= 0; DBUG_ENTER("ma_checkpoint_init"); if (ma_service_thread_control_init(&checkpoint_control)) @@ -334,14 +333,14 @@ int ma_checkpoint_init(ulong interval) else if (interval > 0) { compile_time_assert(sizeof(void *) >= sizeof(ulong)); - if (!(res= mysql_thread_create(key_thread_checkpoint, - &th, NULL, ma_checkpoint_background, - (void *)interval))) - { - /* thread lives, will have to be killed */ - checkpoint_control.status= THREAD_RUNNING; - } + if ((res= mysql_thread_create(key_thread_checkpoint, + &checkpoint_control.thread, NULL, + ma_checkpoint_background, + (void*) interval))) + checkpoint_control.killed= TRUE; } + else + checkpoint_control.killed= TRUE; DBUG_RETURN(res); } @@ -573,8 +572,6 @@ pthread_handler_t ma_checkpoint_background(void *arg) sleeps= 1; pages_to_flush_before_next_checkpoint= 0; - pthread_detach_this_thread(); - for(;;) /* iterations of checkpoints and dirty page flushing */ { #if 0 /* good for testing, to do a lot of checkpoints, finds a lot of bugs */ @@ -723,7 +720,6 @@ pthread_handler_t ma_checkpoint_background(void *arg) DBUG_EXECUTE_IF("maria_checkpoint_indirect", level= CHECKPOINT_INDIRECT;); ma_checkpoint_execute(level, FALSE); } - my_service_thread_signal_end(&checkpoint_control); my_thread_end(); return 0; } diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 1e7cc9483a2..8bcb84c2a20 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -54,7 +54,7 @@ static mysql_mutex_t LOCK_soft_sync; static mysql_cond_t COND_soft_sync; /** @brief control structure for checkpoint background thread */ static MA_SERVICE_THREAD_CONTROL soft_sync_control= - {THREAD_DEAD, FALSE, &LOCK_soft_sync, &COND_soft_sync}; + {0, FALSE, FALSE, &LOCK_soft_sync, &COND_soft_sync}; /* transaction log file descriptor */ @@ -8790,7 +8790,6 @@ ma_soft_sync_background( void *arg __attribute__((unused))) if (my_service_thread_sleep(&soft_sync_control, sleep)) break; } - my_service_thread_signal_end(&soft_sync_control); my_thread_end(); DBUG_RETURN(0); } @@ -8803,7 +8802,6 @@ ma_soft_sync_background( void *arg __attribute__((unused))) int translog_soft_sync_start(void) { - pthread_t th; int res= 0; uint32 min, max; DBUG_ENTER("translog_soft_sync_start"); @@ -8818,9 +8816,10 @@ int translog_soft_sync_start(void) soft_need_sync= 1; if (!(res= ma_service_thread_control_init(&soft_sync_control))) - if (!(res= mysql_thread_create(key_thread_soft_sync, - &th, NULL, ma_soft_sync_background, NULL))) - soft_sync_control.status= THREAD_RUNNING; + if ((res= mysql_thread_create(key_thread_soft_sync, + &soft_sync_control.thread, NULL, + ma_soft_sync_background, NULL))) + soft_sync_control.killed= TRUE; DBUG_RETURN(res); } diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index bba99703119..4630a84334b 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -500,8 +500,8 @@ static void test_key_cache(PAGECACHE *pagecache, const char *where, my_bool lock); #endif -#define PAGECACHE_HASH(p, f, pos) (((ulong) (pos) + \ - (ulong) (f).file) & (p->hash_entries-1)) +#define PAGECACHE_HASH(p, f, pos) (((size_t) (pos) + \ + (size_t) (f).file) & (p->hash_entries-1)) #define FILE_HASH(f,cache) ((uint) (f).file & (cache->changed_blocks_hash_size-1)) #define DEFAULT_PAGECACHE_DEBUG_LOG "pagecache_debug.log" @@ -641,10 +641,10 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache, { char buff[80]; uint len= my_sprintf(buff, - (buff, "fwrite: fd: %d id: %u page: %lu", + (buff, "fwrite: fd: %d id: %u page: %llu", filedesc->file, _ma_file_callback_to_id(filedesc->callback_data), - (ulong) pageno)); + pageno)); (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY, (uchar*) buff, len); } @@ -745,12 +745,12 @@ static inline uint next_power(uint value) */ -ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, +size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem, uint division_limit, uint age_threshold, uint block_size, uint changed_blocks_hash_size, myf my_readwrite_flags) { - ulong blocks, hash_links, length; + size_t blocks, hash_links, length; int error; DBUG_ENTER("init_pagecache"); DBUG_ASSERT(block_size >= 512); @@ -787,10 +787,10 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, DBUG_PRINT("info", ("block_size: %u", block_size)); DBUG_ASSERT(((uint)(1 << pagecache->shift)) == block_size); - blocks= (ulong) (use_mem / (sizeof(PAGECACHE_BLOCK_LINK) + + blocks= use_mem / (sizeof(PAGECACHE_BLOCK_LINK) + 2 * sizeof(PAGECACHE_HASH_LINK) + sizeof(PAGECACHE_HASH_LINK*) * - 5/4 + block_size)); + 5/4 + block_size); /* Changed blocks hash needs to be a power of 2 */ changed_blocks_hash_size= my_round_up_to_next_power(MY_MAX(changed_blocks_hash_size, MIN_PAGECACHE_CHANGED_BLOCKS_HASH_SIZE)); @@ -826,7 +826,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, blocks--; /* Allocate memory for cache page buffers */ if ((pagecache->block_mem= - my_large_malloc((ulong) blocks * pagecache->block_size, + my_large_malloc(blocks * pagecache->block_size, MYF(MY_WME)))) { /* @@ -857,7 +857,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, blocks= blocks / 4*3; } pagecache->blocks_unused= blocks; - pagecache->disk_blocks= (long) blocks; + pagecache->disk_blocks= blocks; pagecache->hash_links= hash_links; pagecache->hash_links_used= 0; pagecache->free_hash_list= NULL; @@ -894,7 +894,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, pagecache->hash_links, (long) pagecache->hash_link_root)); pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0; - DBUG_RETURN((ulong) pagecache->disk_blocks); + DBUG_RETURN((size_t)pagecache->disk_blocks); err: error= my_errno; @@ -985,11 +985,11 @@ static int flush_all_key_blocks(PAGECACHE *pagecache) So we disable it for now. */ #if NOT_USED /* keep disabled until code is fixed see above !! */ -ulong resize_pagecache(PAGECACHE *pagecache, +size_t resize_pagecache(PAGECACHE *pagecache, size_t use_mem, uint division_limit, uint age_threshold, uint changed_blocks_hash_size) { - ulong blocks; + size_t blocks; struct st_my_thread_var *thread; WQUEUE *wqueue; DBUG_ENTER("resize_pagecache"); @@ -1385,7 +1385,7 @@ static void link_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block, ("linked block: %u:%1u status: %x #requests: %u #available: %u", PCBLOCK_NUMBER(pagecache, block), at_end, block->status, block->requests, pagecache->blocks_available)); - KEYCACHE_DBUG_ASSERT((ulong) pagecache->blocks_available <= + KEYCACHE_DBUG_ASSERT(pagecache->blocks_available <= pagecache->blocks_used); #endif DBUG_VOID_RETURN; @@ -2024,7 +2024,7 @@ restart: /* There are some never used blocks, take first of them */ block= &pagecache->block_root[pagecache->blocks_used]; block->buffer= ADD_TO_PTR(pagecache->block_mem, - ((ulong) pagecache->blocks_used* + (pagecache->blocks_used* pagecache->block_size), uchar*); pagecache->blocks_used++; @@ -4875,7 +4875,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, LSN *min_rec_lsn) { my_bool error= 0; - ulong stored_list_size= 0; + size_t stored_list_size= 0; uint file_hash; char *ptr; LSN minimum_rec_lsn= LSN_MAX; diff --git a/storage/maria/ma_pagecache.h b/storage/maria/ma_pagecache.h index e212a7b7029..207ad69711f 100644 --- a/storage/maria/ma_pagecache.h +++ b/storage/maria/ma_pagecache.h @@ -131,21 +131,21 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK; typedef struct st_pagecache { size_t mem_size; /* specified size of the cache memory */ - ulong min_warm_blocks; /* min number of warm blocks; */ - ulong age_threshold; /* age threshold for hot blocks */ + size_t min_warm_blocks; /* min number of warm blocks; */ + size_t age_threshold; /* age threshold for hot blocks */ ulonglong time; /* total number of block link operations */ - ulong hash_entries; /* max number of entries in the hash table */ - ulong changed_blocks_hash_size; /* Number of hash buckets for file blocks */ - long hash_links; /* max number of hash links */ - long hash_links_used; /* number of hash links taken from free links pool */ - long disk_blocks; /* max number of blocks in the cache */ - ulong blocks_used; /* maximum number of concurrently used blocks */ - ulong blocks_unused; /* number of currently unused blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong warm_blocks; /* number of blocks in warm sub-chain */ - ulong cnt_for_resize_op; /* counter to block resize operation */ - ulong blocks_available; /* number of blocks available in the LRU chain */ - long blocks; /* max number of blocks in the cache */ + size_t hash_entries; /* max number of entries in the hash table */ + size_t changed_blocks_hash_size;/* Number of hash buckets for file blocks */ + ssize_t hash_links; /* max number of hash links */ + ssize_t hash_links_used; /* number of hash links taken from free links pool */ + ssize_t disk_blocks; /* max number of blocks in the cache */ + size_t blocks_used; /* maximum number of concurrently used blocks */ + size_t blocks_unused; /* number of currently unused blocks */ + size_t blocks_changed; /* number of currently dirty blocks */ + size_t warm_blocks; /* number of blocks in warm sub-chain */ + size_t cnt_for_resize_op; /* counter to block resize operation */ + size_t blocks_available; /* number of blocks available in the LRU chain */ + ssize_t blocks; /* max number of blocks in the cache */ uint32 block_size; /* size of the page buffer of a cache block */ PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */ PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */ @@ -170,12 +170,12 @@ typedef struct st_pagecache */ ulonglong param_buff_size; /* size the memory allocated for the cache */ - ulong param_block_size; /* size of the blocks in the key cache */ - ulong param_division_limit; /* min. percentage of warm blocks */ - ulong param_age_threshold; /* determines when hot block is downgraded */ + size_t param_block_size; /* size of the blocks in the key cache */ + size_t param_division_limit; /* min. percentage of warm blocks */ + size_t param_age_threshold; /* determines when hot block is downgraded */ /* Statistics variables. These are reset in reset_pagecache_counters(). */ - ulong global_blocks_changed; /* number of currently dirty blocks */ + size_t global_blocks_changed; /* number of currently dirty blocks */ ulonglong global_cache_w_requests;/* number of write requests (write hits) */ ulonglong global_cache_write; /* number of writes from cache to files */ ulonglong global_cache_r_requests;/* number of read requests (read hits) */ @@ -208,11 +208,11 @@ typedef enum pagecache_flush_filter_result /* The default key cache */ extern PAGECACHE dflt_pagecache_var, *dflt_pagecache; -extern ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, +extern size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem, uint division_limit, uint age_threshold, uint block_size, uint changed_blocks_hash_size, myf my_read_flags); -extern ulong resize_pagecache(PAGECACHE *pagecache, +extern size_t resize_pagecache(PAGECACHE *pagecache, size_t use_mem, uint division_limit, uint age_threshold, uint changed_blocks_hash_size); extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit, diff --git a/storage/maria/ma_servicethread.c b/storage/maria/ma_servicethread.c index e5c949a7571..d92c5315933 100644 --- a/storage/maria/ma_servicethread.c +++ b/storage/maria/ma_servicethread.c @@ -33,7 +33,7 @@ int ma_service_thread_control_init(MA_SERVICE_THREAD_CONTROL *control) DBUG_ENTER("ma_service_thread_control_init"); DBUG_PRINT("init", ("control 0x%lx", (ulong) control)); control->inited= TRUE; - control->status= THREAD_DEAD; /* not yet born == dead */ + control->killed= FALSE; res= (mysql_mutex_init(key_SERVICE_THREAD_CONTROL_lock, control->LOCK_control, MY_MUTEX_INIT_SLOW) || mysql_cond_init(key_SERVICE_THREAD_CONTROL_cond, @@ -60,20 +60,17 @@ void ma_service_thread_control_end(MA_SERVICE_THREAD_CONTROL *control) DBUG_PRINT("init", ("control 0x%lx", (ulong) control)); DBUG_ASSERT(control->inited); mysql_mutex_lock(control->LOCK_control); - if (control->status != THREAD_DEAD) /* thread was started OK */ + if (!control->killed) { DBUG_PRINT("info",("killing Maria background thread")); - control->status= THREAD_DYING; /* kill it */ - do /* and wait for it to be dead */ - { - /* wake it up if it was in a sleep */ - mysql_cond_broadcast(control->COND_control); - DBUG_PRINT("info",("waiting for Maria background thread to die")); - mysql_cond_wait(control->COND_control, control->LOCK_control); - } - while (control->status != THREAD_DEAD); + control->killed= TRUE; /* kill it */ + mysql_cond_broadcast(control->COND_control); + mysql_mutex_unlock(control->LOCK_control); + DBUG_PRINT("info", ("waiting for Maria background thread to die")); + pthread_join(control->thread, NULL); } - mysql_mutex_unlock(control->LOCK_control); + else + mysql_mutex_unlock(control->LOCK_control); mysql_mutex_destroy(control->LOCK_control); mysql_cond_destroy(control->COND_control); control->inited= FALSE; @@ -100,7 +97,7 @@ my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control, DBUG_ENTER("my_service_thread_sleep"); DBUG_PRINT("init", ("control 0x%lx", (ulong) control)); mysql_mutex_lock(control->LOCK_control); - if (control->status == THREAD_DYING) + if (control->killed) { mysql_mutex_unlock(control->LOCK_control); DBUG_RETURN(TRUE); @@ -119,34 +116,8 @@ my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control, control->LOCK_control, &abstime); } #endif - if (control->status == THREAD_DYING) + if (control->killed) res= TRUE; mysql_mutex_unlock(control->LOCK_control); DBUG_RETURN(res); } - - -/** - inform about thread exiting - - @param control control block -*/ - -void my_service_thread_signal_end(MA_SERVICE_THREAD_CONTROL *control) -{ - DBUG_ENTER("my_service_thread_signal_end"); - DBUG_PRINT("init", ("control 0x%lx", (ulong) control)); - mysql_mutex_lock(control->LOCK_control); - control->status = THREAD_DEAD; /* indicate that we are dead */ - /* - wake up ma_service_thread_control_end which may be waiting for - our death - */ - mysql_cond_broadcast(control->COND_control); - /* - broadcast was inside unlock because ma_service_thread_control_end - destroys mutex - */ - mysql_mutex_unlock(control->LOCK_control); - DBUG_VOID_RETURN; -} diff --git a/storage/maria/ma_servicethread.h b/storage/maria/ma_servicethread.h index ed578d93c24..254225bd608 100644 --- a/storage/maria/ma_servicethread.h +++ b/storage/maria/ma_servicethread.h @@ -16,12 +16,10 @@ #include -enum ma_service_thread_state {THREAD_RUNNING, THREAD_DYING, THREAD_DEAD}; - typedef struct st_ma_service_thread_control { - /** 'kill' flag for the background thread */ - enum ma_service_thread_state status; + pthread_t thread; + my_bool killed; /** if thread module was inited or not */ my_bool inited; /** for killing the background thread */ @@ -35,4 +33,3 @@ int ma_service_thread_control_init(MA_SERVICE_THREAD_CONTROL *control); void ma_service_thread_control_end(MA_SERVICE_THREAD_CONTROL *control); my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control, ulonglong sleep_time); -void my_service_thread_signal_end(MA_SERVICE_THREAD_CONTROL *control); diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c index ef6e8506ac6..ac166cf4084 100644 --- a/storage/maria/ma_sort.c +++ b/storage/maria/ma_sort.c @@ -364,192 +364,196 @@ err: } /* find_all_keys */ +static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param) +{ + int error= 0; + ulonglong memavl, old_memavl; + longlong sortbuff_size; + ha_keys UNINIT_VAR(keys), idx; + uint sort_length; + uint maxbuffer; + uchar **sort_keys= NULL; + DBUG_ENTER("_ma_thr_find_all_keys_exec"); + DBUG_PRINT("enter", ("master: %d", sort_param->master)); + + if (sort_param->sort_info->got_error) + DBUG_RETURN(TRUE); + + set_sort_param_read_write(sort_param); + + my_b_clear(&sort_param->tempfile); + my_b_clear(&sort_param->tempfile_for_exceptions); + bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek)); + bzero((char*) &sort_param->unique, sizeof(sort_param->unique)); + + sortbuff_size= sort_param->sortbuff_size; + memavl= MY_MAX(sortbuff_size, MIN_SORT_MEMORY); + idx= (ha_keys) sort_param->sort_info->max_records; + sort_length= sort_param->key_length; + maxbuffer= 1; + + while (memavl >= MIN_SORT_MEMORY) + { + if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl) + keys= idx+1; + else if ((sort_param->sort_info->param->testflag & + (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) == + T_FORCE_SORT_MEMORY) + { + /* + Use all of the given sort buffer for key data. + Allocate 1000 buffers at a start for new data. More buffers + will be allocated when needed. + */ + keys= memavl / (sort_length+sizeof(char*)); + maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1); + } + else + { + uint maxbuffer_org; + do + { + maxbuffer_org= maxbuffer; + if (memavl < sizeof(BUFFPEK)*maxbuffer || + (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/ + (sort_length+sizeof(char*))) <= 1 || + keys < maxbuffer) + { + _ma_check_print_error(sort_param->sort_info->param, + "aria_sort_buffer_size is too small. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u", + sortbuff_size, (ulonglong) idx, sort_length); + goto err; + } + } + while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); + } + if ((sort_keys= (uchar **) + my_malloc(keys*(sort_length+sizeof(char*))+ + ((sort_param->keyinfo->flag & HA_FULLTEXT) ? + HA_FT_MAXBYTELEN : 0), MYF(0)))) + { + if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), + maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0))) + { + my_free(sort_keys); + sort_keys= NULL; /* Safety against double free on error. */ + } + else + break; + } + old_memavl= memavl; + if ((memavl= memavl/4*3) < MIN_SORT_MEMORY && + old_memavl > MIN_SORT_MEMORY) + memavl= MIN_SORT_MEMORY; + } + if (memavl < MIN_SORT_MEMORY) + { + /* purecov: begin inspected */ + _ma_check_print_error(sort_param->sort_info->param, + "aria_sort_buffer_size is too small. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u", + sortbuff_size, (ulonglong) idx, sort_length); + my_errno= ENOMEM; + goto err; + /* purecov: end inspected */ + } + + if (sort_param->sort_info->param->testflag & T_VERBOSE) + my_fprintf(stdout, + "Key %d - Allocating buffer for %llu keys\n", + sort_param->key + 1, (ulonglong) keys); + sort_param->sort_keys= sort_keys; + + idx= error= 0; + sort_keys[0]= (uchar*) (sort_keys+keys); + + DBUG_PRINT("info", ("reading keys")); + while (!(error= sort_param->sort_info->got_error) && + !(error= (*sort_param->key_read)(sort_param, sort_keys[idx]))) + { + if (sort_param->real_key_length > sort_param->key_length) + { + if (write_key(sort_param, sort_keys[idx], + &sort_param->tempfile_for_exceptions)) + goto err; + continue; + } + + if (++idx == keys) + { + if (sort_param->write_keys(sort_param, sort_keys, idx - 1, + (BUFFPEK *)alloc_dynamic(&sort_param->buffpek), + &sort_param->tempfile)) + goto err; + sort_keys[0]= (uchar*) (sort_keys+keys); + memcpy(sort_keys[0], sort_keys[idx - 1], (size_t) sort_param->key_length); + idx= 1; + } + sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length; + } + if (error > 0) + goto err; + if (sort_param->buffpek.elements) + { + if (sort_param->write_keys(sort_param,sort_keys, idx, + (BUFFPEK *) alloc_dynamic(&sort_param->buffpek), + &sort_param->tempfile)) + goto err; + sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx; + } + else + sort_param->keys= idx; + + DBUG_RETURN(FALSE); + +err: + DBUG_PRINT("error", ("got some error")); + my_free(sort_keys); + sort_param->sort_keys= 0; + delete_dynamic(& sort_param->buffpek); + close_cached_file(&sort_param->tempfile); + close_cached_file(&sort_param->tempfile_for_exceptions); + + DBUG_RETURN(TRUE); +} + /* Search after all keys and place them in a temp. file */ pthread_handler_t _ma_thr_find_all_keys(void *arg) { MARIA_SORT_PARAM *sort_param= (MARIA_SORT_PARAM*) arg; - int error; - size_t memavl, old_memavl; - longlong sortbuff_size; - ha_keys UNINIT_VAR(keys), idx; - uint sort_length; - uint maxbuffer; - uchar **sort_keys=0; + my_bool error= FALSE; + /* If my_thread_init fails */ + if (my_thread_init() || _ma_thr_find_all_keys_exec(sort_param)) + error= TRUE; - error=1; + /* + Thread must clean up after itself. + */ + free_root(&sort_param->wordroot, MYF(0)); + /* + Detach from the share if the writer is involved. Avoid others to + be blocked. This includes a flush of the write buffer. This will + also indicate EOF to the readers. + That means that a writer always gets here first and readers - + only when they see EOF. But if a reader finishes prematurely + because of an error it may reach this earlier - don't allow it + to detach the writer thread. + */ + if (sort_param->master && sort_param->sort_info->info->rec_cache.share) + remove_io_thread(&sort_param->sort_info->info->rec_cache); - if (my_thread_init()) - goto err; + /* Readers detach from the share if any. Avoid others to be blocked. */ + if (sort_param->read_cache.share) + remove_io_thread(&sort_param->read_cache); - { /* Add extra block since DBUG_ENTER declare variables */ - DBUG_ENTER("_ma_thr_find_all_keys"); - DBUG_PRINT("enter", ("master: %d", sort_param->master)); - if (sort_param->sort_info->got_error) - goto err; + mysql_mutex_lock(&sort_param->sort_info->mutex); + if (error) + sort_param->sort_info->got_error= 1; - set_sort_param_read_write(sort_param); + if (!--sort_param->sort_info->threads_running) + mysql_cond_signal(&sort_param->sort_info->cond); + mysql_mutex_unlock(&sort_param->sort_info->mutex); - my_b_clear(&sort_param->tempfile); - my_b_clear(&sort_param->tempfile_for_exceptions); - bzero((char*) &sort_param->buffpek,sizeof(sort_param->buffpek)); - bzero((char*) &sort_param->unique, sizeof(sort_param->unique)); - - sortbuff_size= sort_param->sortbuff_size; - memavl= MY_MAX(sortbuff_size, MIN_SORT_MEMORY); - idx= (ha_keys) sort_param->sort_info->max_records; - sort_length= sort_param->key_length; - maxbuffer= 1; - - while (memavl >= MIN_SORT_MEMORY) - { - if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= (my_off_t) memavl) - keys= idx+1; - else if ((sort_param->sort_info->param->testflag & - (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) == - T_FORCE_SORT_MEMORY) - { - /* - Use all of the given sort buffer for key data. - Allocate 1000 buffers at a start for new data. More buffers - will be allocated when needed. - */ - keys= memavl / (sort_length+sizeof(char*)); - maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1); - } - else - { - uint maxbuffer_org; - do - { - maxbuffer_org= maxbuffer; - if (memavl < sizeof(BUFFPEK)*maxbuffer || - (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/ - (sort_length+sizeof(char*))) <= 1 || - keys < maxbuffer) - { - _ma_check_print_error(sort_param->sort_info->param, - "aria_sort_buffer_size is too small. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u", - sortbuff_size, (ulonglong) idx, sort_length); - goto err; - } - } - while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); - } - if ((sort_keys= (uchar **) - my_malloc(keys*(sort_length+sizeof(char*))+ - ((sort_param->keyinfo->flag & HA_FULLTEXT) ? - HA_FT_MAXBYTELEN : 0), MYF(0)))) - { - if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), - maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0))) - { - my_free(sort_keys); - sort_keys= (uchar **) NULL; /* for err: label */ - } - else - break; - } - old_memavl= memavl; - if ((memavl= memavl/4*3) < MIN_SORT_MEMORY && - old_memavl > MIN_SORT_MEMORY) - memavl= MIN_SORT_MEMORY; - } - if (memavl < MIN_SORT_MEMORY) - { - /* purecov: begin inspected */ - _ma_check_print_error(sort_param->sort_info->param, - "aria_sort_buffer_size is too small. Current aria_sort_buffer_size: %llu rows: %llu sort_length: %u", - sortbuff_size, (ulonglong) idx, sort_length); - my_errno= ENOMEM; - goto err; - /* purecov: end inspected */ - } - - if (sort_param->sort_info->param->testflag & T_VERBOSE) - my_fprintf(stdout, - "Key %d - Allocating buffer for %llu keys\n", - sort_param->key + 1, (ulonglong) keys); - sort_param->sort_keys= sort_keys; - - idx= error= 0; - sort_keys[0]= (uchar*) (sort_keys+keys); - - DBUG_PRINT("info", ("reading keys")); - while (!(error= sort_param->sort_info->got_error) && - !(error= (*sort_param->key_read)(sort_param, sort_keys[idx]))) - { - if (sort_param->real_key_length > sort_param->key_length) - { - if (write_key(sort_param, sort_keys[idx], - &sort_param->tempfile_for_exceptions)) - goto err; - continue; - } - - if (++idx == keys) - { - if (sort_param->write_keys(sort_param, sort_keys, idx - 1, - (BUFFPEK *)alloc_dynamic(&sort_param-> - buffpek), - &sort_param->tempfile)) - goto err; - sort_keys[0]= (uchar*) (sort_keys+keys); - memcpy(sort_keys[0], sort_keys[idx - 1], - (size_t) sort_param->key_length); - idx= 1; - } - sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length; - } - if (error > 0) - goto err; - if (sort_param->buffpek.elements) - { - if (sort_param->write_keys(sort_param,sort_keys, idx, - (BUFFPEK *) alloc_dynamic(&sort_param-> - buffpek), - &sort_param->tempfile)) - goto err; - sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx; - } - else - sort_param->keys= idx; - - goto ok; - -err: - DBUG_PRINT("error", ("got some error")); - sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */ - my_free(sort_keys); - sort_param->sort_keys= 0; - delete_dynamic(& sort_param->buffpek); - close_cached_file(&sort_param->tempfile); - close_cached_file(&sort_param->tempfile_for_exceptions); - -ok: - free_root(&sort_param->wordroot, MYF(0)); - /* - Detach from the share if the writer is involved. Avoid others to - be blocked. This includes a flush of the write buffer. This will - also indicate EOF to the readers. - That means that a writer always gets here first and readers - - only when they see EOF. But if a reader finishes prematurely - because of an error it may reach this earlier - don't allow it - to detach the writer thread. - */ - if (sort_param->master && sort_param->sort_info->info->rec_cache.share) - remove_io_thread(&sort_param->sort_info->info->rec_cache); - - /* Readers detach from the share if any. Avoid others to be blocked. */ - if (sort_param->read_cache.share) - remove_io_thread(&sort_param->read_cache); - - mysql_mutex_lock(&sort_param->sort_info->mutex); - if (!--sort_param->sort_info->threads_running) - mysql_cond_signal(&sort_param->sort_info->cond); - mysql_mutex_unlock(&sort_param->sort_info->mutex); - DBUG_PRINT("exit", ("======== ending thread ========")); - } my_thread_end(); return NULL; } @@ -559,7 +563,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param) { MARIA_SORT_INFO *sort_info=sort_param->sort_info; HA_CHECK *param=sort_info->param; - ulong UNINIT_VAR(length), keys; + size_t UNINIT_VAR(length), keys; double *rec_per_key_part= param->new_rec_per_key_part; int got_error=sort_info->got_error; uint i; diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 7337b01a981..a4fac8c088a 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -67,7 +67,8 @@ typedef struct st_maria_sort_info pgcache_page_no_t page; ha_rows max_records; uint current_key, total_keys; - uint got_error, threads_running; + volatile uint got_error; + uint threads_running; myf myf_rw; enum data_file_type new_data_file_type, org_data_file_type; } MARIA_SORT_INFO; diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 947a019827c..597ec4690cf 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -4218,9 +4218,12 @@ int ha_mroonga::storage_open(const char *name, int mode, uint test_if_locked) if (!(ha_thd()->open_options & HA_OPEN_FOR_REPAIR)) { error = storage_open_indexes(name); if (error) { - // TODO: free grn_columns and set NULL; grn_obj_unlink(ctx, grn_table); grn_table = NULL; + // TODO: unlink elements + free(grn_columns); + // TODO: unlink elements + free(grn_column_ranges); DBUG_RETURN(error); } diff --git a/storage/mroonga/mysql-test/mroonga/include/mroonga/skip_solaris10.inc b/storage/mroonga/mysql-test/mroonga/include/mroonga/skip_solaris10.inc new file mode 100644 index 00000000000..7cee5c38c53 --- /dev/null +++ b/storage/mroonga/mysql-test/mroonga/include/mroonga/skip_solaris10.inc @@ -0,0 +1,3 @@ +if (`SELECT @@version_compile_os='solaris10'`) { + skip This test is not for Solaris 10; +} diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/column_datetime_64bit_before_unix_epoch.test b/storage/mroonga/mysql-test/mroonga/storage/t/column_datetime_64bit_before_unix_epoch.test index 246500b4498..433e239c301 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/column_datetime_64bit_before_unix_epoch.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/column_datetime_64bit_before_unix_epoch.test @@ -17,6 +17,7 @@ --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/have_mroonga.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_64bit_equal.test b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_64bit_equal.test index e84147d6041..010611ee3ec 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_64bit_equal.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_64bit_equal.test @@ -18,6 +18,7 @@ --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/have_mroonga.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_asc.test b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_asc.test index 7a0ec41f07a..ef7066164fd 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_asc.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_asc.test @@ -18,6 +18,7 @@ --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/have_mroonga.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_desc.test b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_desc.test index db434bca061..d34d29a224b 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_desc.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_date_order_64bit_desc.test @@ -18,6 +18,7 @@ --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/have_mroonga.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_index_read.test b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_index_read.test index 2b7ea97133e..66e0a4d6a9f 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_index_read.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_index_read.test @@ -19,6 +19,7 @@ --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_mroonga.inc --disable_warnings diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_asc.test b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_asc.test index c2ebff516d0..c28fcd86a2a 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_asc.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_asc.test @@ -18,6 +18,7 @@ --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/have_mroonga.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_desc.test b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_desc.test index 6a60b00087e..b5b3545cc9d 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_desc.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/index_multiple_column_unique_datetime_order_desc.test @@ -18,6 +18,7 @@ --source ../../include/mroonga/skip_freebsd.inc --source ../../include/mroonga/skip_osx.inc +--source ../../include/mroonga/skip_solaris10.inc --source ../../include/mroonga/have_64bit.inc --source ../../include/mroonga/have_mroonga.inc diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 72bc4c0c7fe..40a27de5cf9 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1455,6 +1455,7 @@ int ha_myisam::enable_indexes(uint mode) else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) { THD *thd= table->in_use; + int was_error= thd->is_error(); HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); const char *save_proc_info=thd->proc_info; @@ -1500,7 +1501,7 @@ int ha_myisam::enable_indexes(uint mode) might have been set by the first repair. They can still be seen with SHOW WARNINGS then. */ - if (! error) + if (! error && ! was_error) thd->clear_error(); } info(HA_STATUS_CONST); diff --git a/storage/myisam/mysql-test/storage_engine/alter_table_online.rdiff b/storage/myisam/mysql-test/storage_engine/alter_table_online.rdiff index 3a7fef61d3b..5ae99e2035c 100644 --- a/storage/myisam/mysql-test/storage_engine/alter_table_online.rdiff +++ b/storage/myisam/mysql-test/storage_engine/alter_table_online.rdiff @@ -1,41 +1,5 @@ --- suite/storage_engine/alter_table_online.result 2013-11-08 20:01:16.000000000 +0400 +++ suite/storage_engine/alter_table_online.reject 2013-11-08 20:02:03.000000000 +0400 -@@ -2,8 +2,35 @@ - CREATE TABLE t1 (a , b , c ) ENGINE= ; - INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c'); - ALTER ONLINE TABLE t1 MODIFY b DEFAULT 5; -+ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. -+# ERROR: Statement ended with errno 1845, errname ER_ALTER_OPERATION_NOT_SUPPORTED (expected to succeed) -+# ------------ UNEXPECTED RESULT ------------ -+# The statement|command finished with ER_ALTER_OPERATION_NOT_SUPPORTED. -+# Functionality or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. -+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. -+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. -+# Also, this problem may cause a chain effect (more errors of different kinds in the test). -+# ------------------------------------------- - ALTER ONLINE TABLE t1 CHANGE b new_name ; -+ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. -+# ERROR: Statement ended with errno 1845, errname ER_ALTER_OPERATION_NOT_SUPPORTED (expected to succeed) -+# ------------ UNEXPECTED RESULT ------------ -+# The statement|command finished with ER_ALTER_OPERATION_NOT_SUPPORTED. -+# Functionality or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. -+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. -+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. -+# Also, this problem may cause a chain effect (more errors of different kinds in the test). -+# ------------------------------------------- - ALTER ONLINE TABLE t1 COMMENT 'new comment'; -+ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. -+# ERROR: Statement ended with errno 1845, errname ER_ALTER_OPERATION_NOT_SUPPORTED (expected to succeed) -+# ------------ UNEXPECTED RESULT ------------ -+# The statement|command finished with ER_ALTER_OPERATION_NOT_SUPPORTED. -+# Functionality or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. -+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. -+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. -+# Also, this problem may cause a chain effect (more errors of different kinds in the test). -+# ------------------------------------------- - ALTER ONLINE TABLE t1 RENAME TO t2; - ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. - DROP TABLE IF EXISTS t2; @@ -23,12 +50,30 @@ CREATE TABLE t1 (a , b , c ) ENGINE= ; INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c'); diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index f490e5f0b44..f9838d4dcb5 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -344,192 +344,197 @@ static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_rows keys, DBUG_RETURN((*maxbuffer)*(keys-1)+idx); } /* find_all_keys */ +static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param) +{ + ulonglong memavl, old_memavl, sortbuff_size; + ha_keys UNINIT_VAR(keys), idx; + uint sort_length; + uint maxbuffer; + uchar **sort_keys= NULL; + int error= 0; + DBUG_ENTER("thr_find_all_keys"); + DBUG_PRINT("enter", ("master: %d", sort_param->master)); + + if (sort_param->sort_info->got_error) + DBUG_RETURN(TRUE); + + set_sort_param_read_write(sort_param); + + my_b_clear(&sort_param->tempfile); + my_b_clear(&sort_param->tempfile_for_exceptions); + bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek)); + bzero((char*) &sort_param->unique, sizeof(sort_param->unique)); + + sortbuff_size= sort_param->sortbuff_size; + memavl= MY_MAX(sortbuff_size, MIN_SORT_BUFFER); + idx= (ha_keys) sort_param->sort_info->max_records; + sort_length= sort_param->key_length; + maxbuffer= 1; + + while (memavl >= MIN_SORT_BUFFER) + { + if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= + (my_off_t) memavl) + keys= idx+1; + else if ((sort_param->sort_info->param->testflag & + (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) == + T_FORCE_SORT_MEMORY) + { + /* + Use all of the given sort buffer for key data. + Allocate 1000 buffers at a start for new data. More buffers + will be allocated when needed. + */ + keys= memavl / (sort_length+sizeof(char*)); + maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1); + } + else + { + uint maxbuffer_org; + do + { + maxbuffer_org= maxbuffer; + if (memavl < sizeof(BUFFPEK)*maxbuffer || + (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/ + (sort_length+sizeof(char*))) <= 1 || + keys < (uint) maxbuffer) + { + mi_check_print_error(sort_param->sort_info->param, + "myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u", + sortbuff_size, (ulonglong) idx, sort_length); + DBUG_RETURN(TRUE); + } + } + while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); + } + if ((sort_keys= (uchar**) my_malloc(keys * (sort_length + sizeof(char*)) + + ((sort_param->keyinfo->flag & HA_FULLTEXT) ? + HA_FT_MAXBYTELEN : 0), MYF(0)))) + { + if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), + maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0))) + { + my_free(sort_keys); + sort_keys= NULL; /* Safety against double free on error. */ + } + else + break; + } + old_memavl= memavl; + if ((memavl= memavl / 4 * 3) < MIN_SORT_BUFFER && + old_memavl > MIN_SORT_BUFFER) + memavl= MIN_SORT_BUFFER; + } + if (memavl < MIN_SORT_BUFFER) + { + /* purecov: begin inspected */ + mi_check_print_error(sort_param->sort_info->param, + "myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u", + sortbuff_size, (ulonglong) idx, sort_length); + my_errno= ENOMEM; + goto err; + /* purecov: end inspected */ + } + + if (sort_param->sort_info->param->testflag & T_VERBOSE) + my_fprintf(stdout, + "Key %d - Allocating buffer for %llu keys\n", + sort_param->key + 1, (ulonglong) keys); + sort_param->sort_keys= sort_keys; + + idx= error= 0; + sort_keys[0]= (uchar*) (sort_keys+keys); + + DBUG_PRINT("info", ("reading keys")); + while (!(error= sort_param->sort_info->got_error) && + !(error= (*sort_param->key_read)(sort_param, sort_keys[idx]))) + { + if (sort_param->real_key_length > sort_param->key_length) + { + if (write_key(sort_param, sort_keys[idx], + &sort_param->tempfile_for_exceptions)) + goto err; + continue; + } + + if (++idx == keys) + { + if (sort_param->write_keys(sort_param, sort_keys, idx - 1, + (BUFFPEK*) alloc_dynamic(&sort_param->buffpek), + &sort_param->tempfile)) + goto err; + sort_keys[0]= (uchar*) (sort_keys+keys); + memcpy(sort_keys[0], sort_keys[idx - 1], (size_t) sort_param->key_length); + idx= 1; + } + sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length; + } + + if (error > 0) + goto err; + + if (sort_param->buffpek.elements) + { + if (sort_param->write_keys(sort_param, sort_keys, idx, + (BUFFPEK*) alloc_dynamic(&sort_param->buffpek), + &sort_param->tempfile)) + goto err; + sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx; + } + else + sort_param->keys= idx; + + DBUG_RETURN(FALSE); + +err: + DBUG_PRINT("error", ("got some error")); + sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */ + my_free(sort_keys); + sort_param->sort_keys= 0; + delete_dynamic(& sort_param->buffpek); + close_cached_file(&sort_param->tempfile); + close_cached_file(&sort_param->tempfile_for_exceptions); + + DBUG_RETURN(TRUE); +} + /* Search after all keys and place them in a temp. file */ pthread_handler_t thr_find_all_keys(void *arg) { MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg; - int error; - ulonglong memavl, old_memavl, sortbuff_size; - ha_keys UNINIT_VAR(keys), idx; - uint sort_length; - uint maxbuffer; - uchar **sort_keys=0; + my_bool error= FALSE; + /* If my_thread_init fails */ + if (my_thread_init() || thr_find_all_keys_exec(sort_param)) + error= TRUE; - error=1; + /* + Thread must clean up after itself. + */ + free_root(&sort_param->wordroot, MYF(0)); + /* + Detach from the share if the writer is involved. Avoid others to + be blocked. This includes a flush of the write buffer. This will + also indicate EOF to the readers. + That means that a writer always gets here first and readers - + only when they see EOF. But if a reader finishes prematurely + because of an error it may reach this earlier - don't allow it + to detach the writer thread. + */ + if (sort_param->master && sort_param->sort_info->info->rec_cache.share) + remove_io_thread(&sort_param->sort_info->info->rec_cache); - if (my_thread_init()) - goto err; + /* Readers detach from the share if any. Avoid others to be blocked. */ + if (sort_param->read_cache.share) + remove_io_thread(&sort_param->read_cache); - { /* Add extra block since DBUG_ENTER declare variables */ - DBUG_ENTER("thr_find_all_keys"); - DBUG_PRINT("enter", ("master: %d", sort_param->master)); - if (sort_param->sort_info->got_error) - goto err; + mysql_mutex_lock(&sort_param->sort_info->mutex); + if (error) + sort_param->sort_info->got_error= 1; - set_sort_param_read_write(sort_param); - - my_b_clear(&sort_param->tempfile); - my_b_clear(&sort_param->tempfile_for_exceptions); - bzero((char*) &sort_param->buffpek, sizeof(sort_param->buffpek)); - bzero((char*) &sort_param->unique, sizeof(sort_param->unique)); - sort_keys= (uchar **) NULL; - - sortbuff_size= sort_param->sortbuff_size; - memavl= MY_MAX(sortbuff_size, MIN_SORT_BUFFER); - idx= (ha_keys) sort_param->sort_info->max_records; - sort_length= sort_param->key_length; - maxbuffer= 1; - - while (memavl >= MIN_SORT_BUFFER) - { - if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= - (my_off_t) memavl) - keys= idx+1; - else if ((sort_param->sort_info->param->testflag & - (T_FORCE_SORT_MEMORY | T_CREATE_MISSING_KEYS)) == - T_FORCE_SORT_MEMORY) - { - /* - Use all of the given sort buffer for key data. - Allocate 1000 buffers at a start for new data. More buffers - will be allocated when needed. - */ - keys= memavl / (sort_length+sizeof(char*)); - maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1); - } - else - { - uint maxbuffer_org; - do - { - maxbuffer_org= maxbuffer; - if (memavl < sizeof(BUFFPEK)*maxbuffer || - (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/ - (sort_length+sizeof(char*))) <= 1 || - keys < (uint) maxbuffer) - { - mi_check_print_error(sort_param->sort_info->param, - "myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u", - sortbuff_size, (ulonglong) idx, sort_length); - goto err; - } - } - while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); - } - if ((sort_keys= (uchar**) - my_malloc(keys*(sort_length+sizeof(char*))+ - ((sort_param->keyinfo->flag & HA_FULLTEXT) ? - HA_FT_MAXBYTELEN : 0), MYF(0)))) - { - if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), - maxbuffer, MY_MIN(maxbuffer/2, 1000), MYF(0))) - { - my_free(sort_keys); - sort_keys= (uchar **) NULL; /* for err: label */ - } - else - break; - } - old_memavl= memavl; - if ((memavl= memavl / 4 * 3) < MIN_SORT_BUFFER && - old_memavl > MIN_SORT_BUFFER) - memavl= MIN_SORT_BUFFER; - } - if (memavl < MIN_SORT_BUFFER) - { - /* purecov: begin inspected */ - mi_check_print_error(sort_param->sort_info->param, - "myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u", - sortbuff_size, (ulonglong) idx, sort_length); - my_errno= ENOMEM; - goto err; - /* purecov: end inspected */ - } - - if (sort_param->sort_info->param->testflag & T_VERBOSE) - my_fprintf(stdout, - "Key %d - Allocating buffer for %llu keys\n", - sort_param->key + 1, (ulonglong) keys); - sort_param->sort_keys= sort_keys; - - idx= error= 0; - sort_keys[0]= (uchar*) (sort_keys+keys); - - DBUG_PRINT("info", ("reading keys")); - while (!(error= sort_param->sort_info->got_error) && - !(error= (*sort_param->key_read)(sort_param, sort_keys[idx]))) - { - if (sort_param->real_key_length > sort_param->key_length) - { - if (write_key(sort_param, sort_keys[idx], - &sort_param->tempfile_for_exceptions)) - goto err; - continue; - } - - if (++idx == keys) - { - if (sort_param->write_keys(sort_param, sort_keys, idx - 1, - (BUFFPEK*) alloc_dynamic(&sort_param->buffpek), - &sort_param->tempfile)) - goto err; - sort_keys[0]= (uchar*) (sort_keys+keys); - memcpy(sort_keys[0], sort_keys[idx - 1], - (size_t) sort_param->key_length); - idx= 1; - } - sort_keys[idx]= sort_keys[idx - 1] + sort_param->key_length; - } - if (error > 0) - goto err; - if (sort_param->buffpek.elements) - { - if (sort_param->write_keys(sort_param, sort_keys, idx, - (BUFFPEK*) alloc_dynamic(&sort_param->buffpek), - &sort_param->tempfile)) - goto err; - sort_param->keys= (sort_param->buffpek.elements - 1) * (keys - 1) + idx; - } - else - sort_param->keys= idx; - - goto ok; - -err: - DBUG_PRINT("error", ("got some error")); - sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */ - my_free(sort_keys); - sort_param->sort_keys= 0; - delete_dynamic(& sort_param->buffpek); - close_cached_file(&sort_param->tempfile); - close_cached_file(&sort_param->tempfile_for_exceptions); - -ok: - free_root(&sort_param->wordroot, MYF(0)); - /* - Detach from the share if the writer is involved. Avoid others to - be blocked. This includes a flush of the write buffer. This will - also indicate EOF to the readers. - That means that a writer always gets here first and readers - - only when they see EOF. But if a reader finishes prematurely - because of an error it may reach this earlier - don't allow it - to detach the writer thread. - */ - if (sort_param->master && sort_param->sort_info->info->rec_cache.share) - remove_io_thread(&sort_param->sort_info->info->rec_cache); - - /* Readers detach from the share if any. Avoid others to be blocked. */ - if (sort_param->read_cache.share) - remove_io_thread(&sort_param->read_cache); - - mysql_mutex_lock(&sort_param->sort_info->mutex); - if (!--sort_param->sort_info->threads_running) - mysql_cond_signal(&sort_param->sort_info->cond); - mysql_mutex_unlock(&sort_param->sort_info->mutex); - DBUG_PRINT("exit", ("======== ending thread ========")); - DBUG_LEAVE; - } + if (!--sort_param->sort_info->threads_running) + mysql_cond_signal(&sort_param->sort_info->cond); + mysql_mutex_unlock(&sort_param->sort_info->mutex); my_thread_end(); return NULL; } diff --git a/storage/oqgraph/oqgraph_shim.h b/storage/oqgraph/oqgraph_shim.h index 6ea9d10631f..af240b88ebd 100644 --- a/storage/oqgraph/oqgraph_shim.h +++ b/storage/oqgraph/oqgraph_shim.h @@ -254,7 +254,7 @@ namespace boost typedef no_property type; }; -#if BOOST_VERSION >= 104601 +#if BOOST_VERSION < 106000 && BOOST_VERSION >= 104601 template <> struct graph_bundle_type { diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 2a87ffba999..7c85431c57c 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -225,7 +225,7 @@ maria_declare_plugin(perfschema) 0x0001, pfs_status_vars, NULL, - "5.6.29", + "5.6.32", MariaDB_PLUGIN_MATURITY_STABLE } maria_declare_plugin_end; diff --git a/storage/perfschema/table_events_statements.cc b/storage/perfschema/table_events_statements.cc index fc912cfdc9b..0d0ea02974d 100644 --- a/storage/perfschema/table_events_statements.cc +++ b/storage/perfschema/table_events_statements.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -249,11 +249,17 @@ void table_events_statements_common::make_row_part_1(PFS_events_statements *stat CHARSET_INFO *cs= get_charset(statement->m_sqltext_cs_number, MYF(0)); size_t valid_length= statement->m_sqltext_length; - if (cs->mbmaxlen > 1) + if (cs != NULL) { - int well_formed_error; - valid_length= cs->cset->well_formed_len(cs, statement->m_sqltext, statement->m_sqltext + valid_length, - valid_length, &well_formed_error); + if (cs->mbmaxlen > 1) + { + int well_formed_error; + valid_length= cs->cset->well_formed_len(cs, + statement->m_sqltext, + statement->m_sqltext + valid_length, + valid_length, + &well_formed_error); + } } m_row.m_sqltext.set_charset(cs); diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index a64974d7330..765e6733a98 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -1,4 +1,4 @@ -SET(TOKUDB_VERSION 5.6.26-74.0) +SET(TOKUDB_VERSION 5.6.31-77.0) # PerconaFT only supports x86-64 and cmake-2.8.9+ IF(CMAKE_VERSION VERSION_LESS "2.8.9") MESSAGE(STATUS "CMake 2.8.9 or higher is required by TokuDB") @@ -16,7 +16,12 @@ IF(NOT TOKUDB_OK) RETURN() ENDIF() -SET(TOKUDB_SOURCES ha_tokudb.cc) +SET(TOKUDB_SOURCES + ha_tokudb.cc + tokudb_background.cc + tokudb_information_schema.cc + tokudb_sysvars.cc + tokudb_thread.cc) MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY) IF(NOT TARGET tokudb) @@ -27,7 +32,6 @@ IF(NOT LIBJEMALLOC) MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported") ENDIF() -MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG) ############################################ @@ -47,10 +51,16 @@ MARK_AS_ADVANCED(gcc_ar) MARK_AS_ADVANCED(gcc_ranlib) ############################################ +# pick language dialect +MY_CHECK_AND_SET_COMPILER_FLAG(-std=c++11) + SET(BUILD_TESTING OFF CACHE BOOL "") SET(USE_VALGRIND OFF CACHE BOOL "") SET(TOKU_DEBUG_PARANOID OFF CACHE BOOL "") +# Enable TokuDB's TOKUDB_DEBUG in debug builds +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTOKUDB_DEBUG") + IF(NOT DEFINED TOKUDB_VERSION) IF(DEFINED ENV{TOKUDB_VERSION}) SET(TOKUDB_VERSION $ENV{TOKUDB_VERSION}) @@ -69,14 +79,6 @@ IF(DEFINED TOKUDB_NOPATCH_CONFIG) ADD_DEFINITIONS("-DTOKUDB_NOPATCH_CONFIG=${TOKUDB_NOPATCH_CONFIG}") ENDIF() -IF(DEFINED TOKUDB_CHECK_JEMALLOC) - ADD_DEFINITIONS("-DTOKUDB_CHECK_JEMALLOC=${TOKUDB_CHECK_JEMALLOC}") -ENDIF() - -## adds a compiler flag if the compiler supports it -include(CheckCCompilerFlag) -include(CheckCXXCompilerFlag) - MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-missing-field-initializers) IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/PerconaFT/") diff --git a/storage/tokudb/PerconaFT/CMakeLists.txt b/storage/tokudb/PerconaFT/CMakeLists.txt index 843b4c9d0e8..0e283c13c61 100644 --- a/storage/tokudb/PerconaFT/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/CMakeLists.txt @@ -1,3 +1,6 @@ +if (CMAKE_PROJECT_NAME STREQUAL TokuDB) + cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR) +endif() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") project(TokuDB) diff --git a/storage/tokudb/PerconaFT/CTestCustom.cmake b/storage/tokudb/PerconaFT/CTestCustom.cmake.in similarity index 100% rename from storage/tokudb/PerconaFT/CTestCustom.cmake rename to storage/tokudb/PerconaFT/CTestCustom.cmake.in diff --git a/storage/tokudb/PerconaFT/README.md b/storage/tokudb/PerconaFT/README.md index 7e30a558bc7..d53caf00190 100644 --- a/storage/tokudb/PerconaFT/README.md +++ b/storage/tokudb/PerconaFT/README.md @@ -113,11 +113,11 @@ All source code and test contributions must be provided under a [BSD 2-Clause][b License ------- -PerconaFT is available under the GPL version 2, and AGPL version 3, with slight modifications. +PerconaFT is available under the GPL version 2, and AGPL version 3. See [COPYING.AGPLv3][agpllicense], [COPYING.GPLv2][gpllicense], and [PATENTS][patents]. -[agpllicense]: http://github.com/Perona/PerconaFT/blob/master/COPYING.AGPLv3 -[gpllicense]: http://github.com/Perona/PerconaFT/blob/master/COPYING.GPLv2 -[patents]: http://github.com/Perona/PerconaFT/blob/master/PATENTS +[agpllicense]: http://github.com/Percona/PerconaFT/blob/master/COPYING.AGPLv3 +[gpllicense]: http://github.com/Percona/PerconaFT/blob/master/COPYING.GPLv2 +[patents]: http://github.com/Percona/PerconaFT/blob/master/PATENTS diff --git a/storage/tokudb/PerconaFT/buildheader/make_tdb.cc b/storage/tokudb/PerconaFT/buildheader/make_tdb.cc index 958f00a8706..4b62703480f 100644 --- a/storage/tokudb/PerconaFT/buildheader/make_tdb.cc +++ b/storage/tokudb/PerconaFT/buildheader/make_tdb.cc @@ -420,6 +420,8 @@ static void print_db_env_struct (void) { "int (*set_client_pool_threads)(DB_ENV *, uint32_t)", "int (*set_cachetable_pool_threads)(DB_ENV *, uint32_t)", "int (*set_checkpoint_pool_threads)(DB_ENV *, uint32_t)", + "void (*set_check_thp)(DB_ENV *, bool new_val)", + "bool (*get_check_thp)(DB_ENV *)", NULL}; sort_and_dump_fields("db_env", true, extra); @@ -510,8 +512,9 @@ static void print_db_struct (void) { "int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, uint32_t flags)", "int (*get_fractal_tree_info64)(DB*,uint64_t*,uint64_t*,uint64_t*,uint64_t*)", "int (*iterate_fractal_tree_block_map)(DB*,int(*)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*),void*)", - "const char *(*get_dname)(DB *db)", - "int (*get_last_key)(DB *db, YDB_CALLBACK_FUNCTION func, void* extra)", + "const char *(*get_dname)(DB *db)", + "int (*get_last_key)(DB *db, YDB_CALLBACK_FUNCTION func, void* extra)", + "int (*recount_rows)(DB* db, int (*progress_callback)(uint64_t count, uint64_t deleted, void* progress_extra), void* progress_extra)", NULL}; sort_and_dump_fields("db", true, extra); } diff --git a/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake b/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake index 15066906831..e1da095fc00 100644 --- a/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake +++ b/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake @@ -48,7 +48,8 @@ MACRO(TOKU_MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) ENDIF() ENDFOREACH() IF(OSLIBS) - #LIST(REMOVE_DUPLICATES OSLIBS) + # REMOVE_DUPLICATES destroys the order of the libs so disabled + # LIST(REMOVE_DUPLICATES OSLIBS) TARGET_LINK_LIBRARIES(${TARGET} LINK_PUBLIC ${OSLIBS}) ENDIF() diff --git a/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake b/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake index 40ccbcc0aed..77f6d8f67b7 100644 --- a/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake +++ b/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake @@ -24,12 +24,12 @@ endif () ## add TOKU_PTHREAD_DEBUG for debug builds if (CMAKE_VERSION VERSION_LESS 3.0) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG TOKU_PTHREAD_DEBUG=1) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DRD TOKU_PTHREAD_DEBUG=1) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG TOKU_PTHREAD_DEBUG=1 TOKU_DEBUG_TXN_SYNC=1) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DRD TOKU_PTHREAD_DEBUG=1 TOKU_DEBUG_TXN_SYNC=1) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DRD _FORTIFY_SOURCE=2) else () set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS - $<$,$>:TOKU_PTHREAD_DEBUG=1> + $<$,$>:TOKU_PTHREAD_DEBUG=1 TOKU_DEBUG_TXN_SYNC=1> $<$:_FORTIFY_SOURCE=2> ) endif () @@ -65,8 +65,10 @@ set_cflags_if_supported( -Wno-error=missing-format-attribute -Wno-error=address-of-array-temporary -Wno-error=tautological-constant-out-of-range-compare + -Wno-error=maybe-uninitialized -Wno-ignored-attributes -Wno-error=extern-c-compat + -Wno-pointer-bool-conversion -fno-rtti -fno-exceptions ) @@ -119,13 +121,18 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(CMAKE_C_FLAGS_RELEASE "-g -O3 ${CMAKE_C_FLAGS_RELEASE} -UNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 ${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG") else () + if (APPLE) + set(FLTO_OPTS "-fwhole-program") + else () + set(FLTO_OPTS "-fuse-linker-plugin") + endif() # we overwrite this because the default passes -DNDEBUG and we don't want that - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-flto -fuse-linker-plugin ${CMAKE_C_FLAGS_RELWITHDEBINFO} -g -O3 -UNDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-flto -fuse-linker-plugin ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -O3 -UNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-g -O3 -flto -fuse-linker-plugin ${CMAKE_C_FLAGS_RELEASE} -UNDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 -flto -fuse-linker-plugin ${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG") - set(CMAKE_EXE_LINKER_FLAGS "-g -fuse-linker-plugin ${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_SHARED_LINKER_FLAGS "-g -fuse-linker-plugin ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-flto ${FLTO_OPTS} ${CMAKE_C_FLAGS_RELWITHDEBINFO} -g -O3 -UNDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-flto ${FLTO_OPTS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -O3 -UNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "-g -O3 -flto ${FLTO_OPTS} ${CMAKE_C_FLAGS_RELEASE} -UNDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 -flto ${FLTO_OPTS} ${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG") + set(CMAKE_EXE_LINKER_FLAGS "-g ${FLTO_OPTS} ${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "-g ${FLTO_OPTS} ${CMAKE_SHARED_LINKER_FLAGS}") endif () ## set warnings @@ -159,15 +166,6 @@ endif () set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}") -## need to set -stdlib=libc++ to get real c++11 support on darwin -if (APPLE) - if (CMAKE_GENERATOR STREQUAL Xcode) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - else () - add_definitions(-stdlib=libc++) - endif () -endif () - # pick language dialect set(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}") check_cxx_compiler_flag(-std=c++11 HAVE_STDCXX11) diff --git a/storage/tokudb/PerconaFT/ft/CMakeLists.txt b/storage/tokudb/PerconaFT/ft/CMakeLists.txt index 744b9c9a9e1..11091073ac2 100644 --- a/storage/tokudb/PerconaFT/ft/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/ft/CMakeLists.txt @@ -36,6 +36,7 @@ set(FT_SOURCES ft-flusher ft-hot-flusher ft-ops + ft-recount-rows ft-status ft-test-helpers ft-verify diff --git a/storage/tokudb/PerconaFT/ft/ft-flusher.cc b/storage/tokudb/PerconaFT/ft/ft-flusher.cc index 530947fe868..fb456ea6a18 100644 --- a/storage/tokudb/PerconaFT/ft/ft-flusher.cc +++ b/storage/tokudb/PerconaFT/ft/ft-flusher.cc @@ -1572,6 +1572,7 @@ void toku_bnc_flush_to_child(FT ft, NONLEAF_CHILDINFO bnc, FTNODE child, TXNID p txn_gc_info *gc_info; STAT64INFO_S stats_delta; + int64_t logical_rows_delta = 0; size_t remaining_memsize = bnc->msg_buffer.buffer_size_in_use(); flush_msg_fn(FT t, FTNODE n, NONLEAF_CHILDINFO nl, txn_gc_info *g) : @@ -1599,8 +1600,8 @@ void toku_bnc_flush_to_child(FT ft, NONLEAF_CHILDINFO bnc, FTNODE child, TXNID p is_fresh, gc_info, flow_deltas, - &stats_delta - ); + &stats_delta, + &logical_rows_delta); remaining_memsize -= memsize_in_buffer; return 0; } @@ -1613,6 +1614,7 @@ void toku_bnc_flush_to_child(FT ft, NONLEAF_CHILDINFO bnc, FTNODE child, TXNID p if (flush_fn.stats_delta.numbytes || flush_fn.stats_delta.numrows) { toku_ft_update_stats(&ft->in_memory_stats, flush_fn.stats_delta); } + toku_ft_adjust_logical_row_count(ft, flush_fn.logical_rows_delta); if (do_garbage_collection) { size_t buffsize = bnc->msg_buffer.buffer_size_in_use(); // may be misleading if there's a broadcast message in there diff --git a/storage/tokudb/PerconaFT/ft/ft-internal.h b/storage/tokudb/PerconaFT/ft/ft-internal.h index 6bf7029245b..eec591d1744 100644 --- a/storage/tokudb/PerconaFT/ft/ft-internal.h +++ b/storage/tokudb/PerconaFT/ft/ft-internal.h @@ -143,6 +143,10 @@ struct ft_header { MSN msn_at_start_of_last_completed_optimize; STAT64INFO_S on_disk_stats; + + // This represents the balance of inserts - deletes and should be + // closer to a logical representation of the number of records in an index + uint64_t on_disk_logical_rows; }; typedef struct ft_header *FT_HEADER; @@ -176,6 +180,7 @@ struct ft { // protected by atomic builtins STAT64INFO_S in_memory_stats; + uint64_t in_memory_logical_rows; // transient, not serialized to disk. updated when we do write to // disk. tells us whether we can do partial eviction (we can't if diff --git a/storage/tokudb/PerconaFT/ft/ft-ops.cc b/storage/tokudb/PerconaFT/ft/ft-ops.cc index f5da82ee000..8f61bc67339 100644 --- a/storage/tokudb/PerconaFT/ft/ft-ops.cc +++ b/storage/tokudb/PerconaFT/ft/ft-ops.cc @@ -1371,7 +1371,8 @@ static void inject_message_in_locked_node( ft_msg msg_with_msn(msg.kdbt(), msg.vdbt(), msg.type(), msg_msn, msg.xids()); paranoid_invariant(msg_with_msn.msn().msn > node->max_msn_applied_to_node_on_disk.msn); - STAT64INFO_S stats_delta = {0,0}; + STAT64INFO_S stats_delta = { 0,0 }; + int64_t logical_rows_delta = 0; toku_ftnode_put_msg( ft->cmp, ft->update_fun, @@ -1381,11 +1382,12 @@ static void inject_message_in_locked_node( true, gc_info, flow_deltas, - &stats_delta - ); + &stats_delta, + &logical_rows_delta); if (stats_delta.numbytes || stats_delta.numrows) { toku_ft_update_stats(&ft->in_memory_stats, stats_delta); } + toku_ft_adjust_logical_row_count(ft, logical_rows_delta); // // assumption is that toku_ftnode_put_msg will // mark the node as dirty. @@ -2169,6 +2171,7 @@ int toku_ft_insert_unique(FT_HANDLE ft_h, DBT *key, DBT *val, TOKUTXN txn, bool if (r == 0) { ft_txn_log_insert(ft_h->ft, key, val, txn, do_logging, FT_INSERT); + toku_ft_adjust_logical_row_count(ft_h->ft, 1); } return r; } @@ -2344,6 +2347,7 @@ void toku_ft_maybe_insert (FT_HANDLE ft_h, DBT *key, DBT *val, TOKUTXN txn, bool if (r != 0) { toku_ft_send_insert(ft_h, key, val, message_xids, type, &gc_info); } + toku_ft_adjust_logical_row_count(ft_h->ft, 1); } } @@ -2513,6 +2517,7 @@ void toku_ft_maybe_delete(FT_HANDLE ft_h, DBT *key, TOKUTXN txn, bool oplsn_vali oldest_referenced_xid_estimate, txn != nullptr ? !txn->for_recovery : false); toku_ft_send_delete(ft_h, key, message_xids, &gc_info); + toku_ft_adjust_logical_row_count(ft_h->ft, -1); } } diff --git a/storage/tokudb/PerconaFT/ft/ft-ops.h b/storage/tokudb/PerconaFT/ft/ft-ops.h index 7d0b165b70c..313a74628ea 100644 --- a/storage/tokudb/PerconaFT/ft/ft-ops.h +++ b/storage/tokudb/PerconaFT/ft/ft-ops.h @@ -207,6 +207,15 @@ extern int toku_ft_debug_mode; int toku_verify_ft (FT_HANDLE ft_h) __attribute__ ((warn_unused_result)); int toku_verify_ft_with_progress (FT_HANDLE ft_h, int (*progress_callback)(void *extra, float progress), void *extra, int verbose, int keep_going) __attribute__ ((warn_unused_result)); +int toku_ft_recount_rows( + FT_HANDLE ft, + int (*progress_callback)( + uint64_t count, + uint64_t deleted, + void* progress_extra), + void* progress_extra); + + DICTIONARY_ID toku_ft_get_dictionary_id(FT_HANDLE); enum ft_flags { diff --git a/storage/tokudb/PerconaFT/ft/ft-recount-rows.cc b/storage/tokudb/PerconaFT/ft/ft-recount-rows.cc new file mode 100644 index 00000000000..adac96f4882 --- /dev/null +++ b/storage/tokudb/PerconaFT/ft/ft-recount-rows.cc @@ -0,0 +1,115 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/*====== +This file is part of PerconaFT. + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PerconaFT. If not, see . + +---------------------------------------- + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with PerconaFT. If not, see . +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "ft/serialize/block_table.h" +#include "ft/ft.h" +#include "ft/ft-internal.h" +#include "ft/cursor.h" + +struct recount_rows_extra_t { + int (*_progress_callback)( + uint64_t count, + uint64_t deleted, + void* progress_extra); + void* _progress_extra; + uint64_t _keys; + bool _cancelled; +}; + +static int recount_rows_found( + uint32_t UU(keylen), + const void* key, + uint32_t UU(vallen), + const void* UU(val), + void* extra, + bool UU(lock_only)) { + + recount_rows_extra_t* rre = (recount_rows_extra_t*)extra; + + if (FT_LIKELY(key != nullptr)) { + rre->_keys++; + } + return rre->_cancelled + = rre->_progress_callback(rre->_keys, 0, rre->_progress_extra); +} +static bool recount_rows_interrupt(void* extra, uint64_t deleted_rows) { + recount_rows_extra_t* rre = (recount_rows_extra_t*)extra; + + return rre->_cancelled = + rre->_progress_callback(rre->_keys, deleted_rows, rre->_progress_extra); +} +int toku_ft_recount_rows( + FT_HANDLE ft, + int (*progress_callback)( + uint64_t count, + uint64_t deleted, + void* progress_extra), + void* progress_extra) { + + int ret = 0; + recount_rows_extra_t rre = { + progress_callback, + progress_extra, + 0, + false + }; + + ft_cursor c; + ret = toku_ft_cursor_create(ft, &c, nullptr, C_READ_ANY, false, false); + if (ret) return ret; + + toku_ft_cursor_set_check_interrupt_cb( + &c, + recount_rows_interrupt, + &rre); + + ret = toku_ft_cursor_first(&c, recount_rows_found, &rre); + while (FT_LIKELY(ret == 0)) { + ret = toku_ft_cursor_next(&c, recount_rows_found, &rre); + } + + toku_ft_cursor_destroy(&c); + + if (rre._cancelled == false) { + // update ft count + toku_unsafe_set(&ft->ft->in_memory_logical_rows, rre._keys); + ret = 0; + } + + return ret; +} diff --git a/storage/tokudb/PerconaFT/ft/ft-status.cc b/storage/tokudb/PerconaFT/ft/ft-status.cc index 982df1822c4..19a378c22bf 100644 --- a/storage/tokudb/PerconaFT/ft/ft-status.cc +++ b/storage/tokudb/PerconaFT/ft/ft-status.cc @@ -128,24 +128,24 @@ void CACHETABLE_STATUS_S::init() { CT_STATUS_INIT(CT_LONG_WAIT_PRESSURE_COUNT, CACHETABLE_LONG_WAIT_PRESSURE_COUNT, UINT64, "number of long waits on cache pressure"); CT_STATUS_INIT(CT_LONG_WAIT_PRESSURE_TIME, CACHETABLE_LONG_WAIT_PRESSURE_TIME, UINT64, "long time waiting on cache pressure"); - CT_STATUS_INIT(CT_POOL_CLIENT_NUM_THREADS, CACHETABLE_POOL_CLIENT_NUM_THREADS, UINT64, "number of threads in pool"); - CT_STATUS_INIT(CT_POOL_CLIENT_NUM_THREADS_ACTIVE, CACHETABLE_POOL_CLIENT_NUM_THREADS_ACTIVE, UINT64, "number of currently active threads in pool"); - CT_STATUS_INIT(CT_POOL_CLIENT_QUEUE_SIZE, CACHETABLE_POOL_CLIENT_QUEUE_SIZE, UINT64, "number of currently queued work items"); - CT_STATUS_INIT(CT_POOL_CLIENT_MAX_QUEUE_SIZE, CACHETABLE_POOL_CLIENT_MAX_QUEUE_SIZE, UINT64, "largest number of queued work items"); - CT_STATUS_INIT(CT_POOL_CLIENT_TOTAL_ITEMS_PROCESSED, CACHETABLE_POOL_CLIENT_TOTAL_ITEMS_PROCESSED, UINT64, "total number of work items processed"); - CT_STATUS_INIT(CT_POOL_CLIENT_TOTAL_EXECUTION_TIME, CACHETABLE_POOL_CLIENT_TOTAL_EXECUTION_TIME, UINT64, "total execution time of processing work items"); - CT_STATUS_INIT(CT_POOL_CACHETABLE_NUM_THREADS, CACHETABLE_POOL_CACHETABLE_NUM_THREADS, UINT64, "number of threads in pool"); - CT_STATUS_INIT(CT_POOL_CACHETABLE_NUM_THREADS_ACTIVE, CACHETABLE_POOL_CACHETABLE_NUM_THREADS_ACTIVE, UINT64, "number of currently active threads in pool"); - CT_STATUS_INIT(CT_POOL_CACHETABLE_QUEUE_SIZE, CACHETABLE_POOL_CACHETABLE_QUEUE_SIZE, UINT64, "number of currently queued work items"); - CT_STATUS_INIT(CT_POOL_CACHETABLE_MAX_QUEUE_SIZE, CACHETABLE_POOL_CACHETABLE_MAX_QUEUE_SIZE, UINT64, "largest number of queued work items"); - CT_STATUS_INIT(CT_POOL_CACHETABLE_TOTAL_ITEMS_PROCESSED, CACHETABLE_POOL_CACHETABLE_TOTAL_ITEMS_PROCESSED, UINT64, "total number of work items processed"); - CT_STATUS_INIT(CT_POOL_CACHETABLE_TOTAL_EXECUTION_TIME, CACHETABLE_POOL_CACHETABLE_TOTAL_EXECUTION_TIME, UINT64, "total execution time of processing work items"); - CT_STATUS_INIT(CT_POOL_CHECKPOINT_NUM_THREADS, CACHETABLE_POOL_CHECKPOINT_NUM_THREADS, UINT64, "number of threads in pool"); - CT_STATUS_INIT(CT_POOL_CHECKPOINT_NUM_THREADS_ACTIVE, CACHETABLE_POOL_CHECKPOINT_NUM_THREADS_ACTIVE, UINT64, "number of currently active threads in pool"); - CT_STATUS_INIT(CT_POOL_CHECKPOINT_QUEUE_SIZE, CACHETABLE_POOL_CHECKPOINT_QUEUE_SIZE, UINT64, "number of currently queued work items"); - CT_STATUS_INIT(CT_POOL_CHECKPOINT_MAX_QUEUE_SIZE, CACHETABLE_POOL_CHECKPOINT_MAX_QUEUE_SIZE, UINT64, "largest number of queued work items"); - CT_STATUS_INIT(CT_POOL_CHECKPOINT_TOTAL_ITEMS_PROCESSED, CACHETABLE_POOL_CHECKPOINT_TOTAL_ITEMS_PROCESSED, UINT64, "total number of work items processed"); - CT_STATUS_INIT(CT_POOL_CHECKPOINT_TOTAL_EXECUTION_TIME, CACHETABLE_POOL_CHECKPOINT_TOTAL_EXECUTION_TIME, UINT64, "total execution time of processing work items"); + CT_STATUS_INIT(CT_POOL_CLIENT_NUM_THREADS, CACHETABLE_POOL_CLIENT_NUM_THREADS, UINT64, "client pool: number of threads in pool"); + CT_STATUS_INIT(CT_POOL_CLIENT_NUM_THREADS_ACTIVE, CACHETABLE_POOL_CLIENT_NUM_THREADS_ACTIVE, UINT64, "client pool: number of currently active threads in pool"); + CT_STATUS_INIT(CT_POOL_CLIENT_QUEUE_SIZE, CACHETABLE_POOL_CLIENT_QUEUE_SIZE, UINT64, "client pool: number of currently queued work items"); + CT_STATUS_INIT(CT_POOL_CLIENT_MAX_QUEUE_SIZE, CACHETABLE_POOL_CLIENT_MAX_QUEUE_SIZE, UINT64, "client pool: largest number of queued work items"); + CT_STATUS_INIT(CT_POOL_CLIENT_TOTAL_ITEMS_PROCESSED, CACHETABLE_POOL_CLIENT_TOTAL_ITEMS_PROCESSED, UINT64, "client pool: total number of work items processed"); + CT_STATUS_INIT(CT_POOL_CLIENT_TOTAL_EXECUTION_TIME, CACHETABLE_POOL_CLIENT_TOTAL_EXECUTION_TIME, UINT64, "client pool: total execution time of processing work items"); + CT_STATUS_INIT(CT_POOL_CACHETABLE_NUM_THREADS, CACHETABLE_POOL_CACHETABLE_NUM_THREADS, UINT64, "cachetable pool: number of threads in pool"); + CT_STATUS_INIT(CT_POOL_CACHETABLE_NUM_THREADS_ACTIVE, CACHETABLE_POOL_CACHETABLE_NUM_THREADS_ACTIVE, UINT64, "cachetable pool: number of currently active threads in pool"); + CT_STATUS_INIT(CT_POOL_CACHETABLE_QUEUE_SIZE, CACHETABLE_POOL_CACHETABLE_QUEUE_SIZE, UINT64, "cachetable pool: number of currently queued work items"); + CT_STATUS_INIT(CT_POOL_CACHETABLE_MAX_QUEUE_SIZE, CACHETABLE_POOL_CACHETABLE_MAX_QUEUE_SIZE, UINT64, "cachetable pool: largest number of queued work items"); + CT_STATUS_INIT(CT_POOL_CACHETABLE_TOTAL_ITEMS_PROCESSED, CACHETABLE_POOL_CACHETABLE_TOTAL_ITEMS_PROCESSED, UINT64, "cachetable pool: total number of work items processed"); + CT_STATUS_INIT(CT_POOL_CACHETABLE_TOTAL_EXECUTION_TIME, CACHETABLE_POOL_CACHETABLE_TOTAL_EXECUTION_TIME, UINT64, "cachetable pool: total execution time of processing work items"); + CT_STATUS_INIT(CT_POOL_CHECKPOINT_NUM_THREADS, CACHETABLE_POOL_CHECKPOINT_NUM_THREADS, UINT64, "checkpoint pool: number of threads in pool"); + CT_STATUS_INIT(CT_POOL_CHECKPOINT_NUM_THREADS_ACTIVE, CACHETABLE_POOL_CHECKPOINT_NUM_THREADS_ACTIVE, UINT64, "checkpoint pool: number of currently active threads in pool"); + CT_STATUS_INIT(CT_POOL_CHECKPOINT_QUEUE_SIZE, CACHETABLE_POOL_CHECKPOINT_QUEUE_SIZE, UINT64, "checkpoint pool: number of currently queued work items"); + CT_STATUS_INIT(CT_POOL_CHECKPOINT_MAX_QUEUE_SIZE, CACHETABLE_POOL_CHECKPOINT_MAX_QUEUE_SIZE, UINT64, "checkpoint pool: largest number of queued work items"); + CT_STATUS_INIT(CT_POOL_CHECKPOINT_TOTAL_ITEMS_PROCESSED, CACHETABLE_POOL_CHECKPOINT_TOTAL_ITEMS_PROCESSED, UINT64, "checkpoint pool: total number of work items processed"); + CT_STATUS_INIT(CT_POOL_CHECKPOINT_TOTAL_EXECUTION_TIME, CACHETABLE_POOL_CHECKPOINT_TOTAL_EXECUTION_TIME, UINT64, "checkpoint pool: total execution time of processing work items"); m_initialized = true; #undef CT_STATUS_INIT diff --git a/storage/tokudb/PerconaFT/ft/ft-test-helpers.cc b/storage/tokudb/PerconaFT/ft/ft-test-helpers.cc index 7ca36c23780..6fcdbbdc9e3 100644 --- a/storage/tokudb/PerconaFT/ft/ft-test-helpers.cc +++ b/storage/tokudb/PerconaFT/ft/ft-test-helpers.cc @@ -172,21 +172,26 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, const assert(node->height==0); DBT kdbt, vdbt; - ft_msg msg(toku_fill_dbt(&kdbt, key, keylen), toku_fill_dbt(&vdbt, val, vallen), - FT_INSERT, next_dummymsn(), toku_xids_get_root_xids()); + ft_msg msg( + toku_fill_dbt(&kdbt, key, keylen), + toku_fill_dbt(&vdbt, val, vallen), + FT_INSERT, + next_dummymsn(), + toku_xids_get_root_xids()); static size_t zero_flow_deltas[] = { 0, 0 }; txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, true); - toku_ftnode_put_msg(ft_handle->ft->cmp, - ft_handle->ft->update_fun, - node, - -1, - msg, - true, - &gc_info, - zero_flow_deltas, - NULL - ); + toku_ftnode_put_msg( + ft_handle->ft->cmp, + ft_handle->ft->update_fun, + node, + -1, + msg, + true, + &gc_info, + zero_flow_deltas, + NULL, + NULL); toku_verify_or_set_counts(node); diff --git a/storage/tokudb/PerconaFT/ft/ft.cc b/storage/tokudb/PerconaFT/ft/ft.cc index 2a0fb6f6800..93d21233bf7 100644 --- a/storage/tokudb/PerconaFT/ft/ft.cc +++ b/storage/tokudb/PerconaFT/ft/ft.cc @@ -198,6 +198,8 @@ static void ft_checkpoint (CACHEFILE cf, int fd, void *header_v) { ch->time_of_last_modification = now; ch->checkpoint_count++; ft_hack_highest_unused_msn_for_upgrade_for_checkpoint(ft); + ch->on_disk_logical_rows = + ft->h->on_disk_logical_rows = ft->in_memory_logical_rows; // write translation and header to disk (or at least to OS internal buffer) toku_serialize_ft_to(fd, ch, &ft->blocktable, ft->cf); @@ -383,7 +385,8 @@ ft_header_create(FT_OPTIONS options, BLOCKNUM root_blocknum, TXNID root_xid_that .count_of_optimize_in_progress = 0, .count_of_optimize_in_progress_read_from_disk = 0, .msn_at_start_of_last_completed_optimize = ZERO_MSN, - .on_disk_stats = ZEROSTATS + .on_disk_stats = ZEROSTATS, + .on_disk_logical_rows = 0 }; return (FT_HEADER) toku_xmemdup(&h, sizeof h); } @@ -802,7 +805,14 @@ toku_ft_stat64 (FT ft, struct ftstat64_s *s) { s->fsize = toku_cachefile_size(ft->cf); // just use the in memory stats from the header // prevent appearance of negative numbers for numrows, numbytes - int64_t n = ft->in_memory_stats.numrows; + // if the logical count was never properly re-counted on an upgrade, + // return the existing physical count instead. + int64_t n; + if (ft->in_memory_logical_rows == (uint64_t)-1) { + n = ft->in_memory_stats.numrows; + } else { + n = ft->in_memory_logical_rows; + } if (n < 0) { n = 0; } @@ -871,20 +881,38 @@ DESCRIPTOR toku_ft_get_cmp_descriptor(FT_HANDLE ft_handle) { return &ft_handle->ft->cmp_descriptor; } -void -toku_ft_update_stats(STAT64INFO headerstats, STAT64INFO_S delta) { +void toku_ft_update_stats(STAT64INFO headerstats, STAT64INFO_S delta) { (void) toku_sync_fetch_and_add(&(headerstats->numrows), delta.numrows); (void) toku_sync_fetch_and_add(&(headerstats->numbytes), delta.numbytes); } -void -toku_ft_decrease_stats(STAT64INFO headerstats, STAT64INFO_S delta) { +void toku_ft_decrease_stats(STAT64INFO headerstats, STAT64INFO_S delta) { (void) toku_sync_fetch_and_sub(&(headerstats->numrows), delta.numrows); (void) toku_sync_fetch_and_sub(&(headerstats->numbytes), delta.numbytes); } -void -toku_ft_remove_reference(FT ft, bool oplsn_valid, LSN oplsn, remove_ft_ref_callback remove_ref, void *extra) { +void toku_ft_adjust_logical_row_count(FT ft, int64_t delta) { + // In order to make sure that the correct count is returned from + // toku_ft_stat64, the ft->(in_memory|on_disk)_logical_rows _MUST_NOT_ be + // modified from anywhere else from here with the exceptions of + // serializing in a header, initializing a new header and analyzing + // an index for a logical_row count. + // The gist is that on an index upgrade, all logical_rows values + // in the ft header are set to -1 until an analyze can reset it to an + // accurate value. Until then, the physical count from in_memory_stats + // must be returned in toku_ft_stat64. + if (delta != 0 && ft->in_memory_logical_rows != (uint64_t)-1) { + toku_sync_fetch_and_add(&(ft->in_memory_logical_rows), delta); + } +} + +void toku_ft_remove_reference( + FT ft, + bool oplsn_valid, + LSN oplsn, + remove_ft_ref_callback remove_ref, + void *extra) { + toku_ft_grab_reflock(ft); if (toku_ft_has_one_reference_unlocked(ft)) { toku_ft_release_reflock(ft); diff --git a/storage/tokudb/PerconaFT/ft/ft.h b/storage/tokudb/PerconaFT/ft/ft.h index cc64bdfc6d3..d600e093bdc 100644 --- a/storage/tokudb/PerconaFT/ft/ft.h +++ b/storage/tokudb/PerconaFT/ft/ft.h @@ -127,13 +127,17 @@ DESCRIPTOR toku_ft_get_cmp_descriptor(FT_HANDLE ft_handle); typedef struct { // delta versions in basements could be negative + // These represent the physical leaf entries and do not account + // for pending deletes or other in-flight messages that have not been + // applied to a leaf entry. int64_t numrows; int64_t numbytes; } STAT64INFO_S, *STAT64INFO; -static const STAT64INFO_S ZEROSTATS = { .numrows = 0, .numbytes = 0}; +static const STAT64INFO_S ZEROSTATS = { .numrows = 0, .numbytes = 0 }; void toku_ft_update_stats(STAT64INFO headerstats, STAT64INFO_S delta); void toku_ft_decrease_stats(STAT64INFO headerstats, STAT64INFO_S delta); +void toku_ft_adjust_logical_row_count(FT ft, int64_t delta); typedef void (*remove_ft_ref_callback)(FT ft, void *extra); void toku_ft_remove_reference(FT ft, diff --git a/storage/tokudb/PerconaFT/ft/leafentry.h b/storage/tokudb/PerconaFT/ft/leafentry.h index 9cb81ef7cd6..7274a1480e2 100644 --- a/storage/tokudb/PerconaFT/ft/leafentry.h +++ b/storage/tokudb/PerconaFT/ft/leafentry.h @@ -180,43 +180,57 @@ uint64_t le_outermost_uncommitted_xid (LEAFENTRY le); // r|r!=0&&r!=TOKUDB_ACCEPT: Quit early, return r, because something unexpected went wrong (error case) typedef int(*LE_ITERATE_CALLBACK)(TXNID id, TOKUTXN context, bool is_provisional); -int le_iterate_val(LEAFENTRY le, LE_ITERATE_CALLBACK f, void** valpp, uint32_t *vallenp, TOKUTXN context); +int le_iterate_val( + LEAFENTRY le, + LE_ITERATE_CALLBACK f, + void** valpp, + uint32_t* vallenp, + TOKUTXN context); -void le_extract_val(LEAFENTRY le, - // should we return the entire leafentry as the val? - bool is_leaf_mode, enum cursor_read_type read_type, - TOKUTXN ttxn, uint32_t *vallen, void **val); +void le_extract_val( + LEAFENTRY le, + // should we return the entire leafentry as the val? + bool is_leaf_mode, + enum cursor_read_type read_type, + TOKUTXN ttxn, + uint32_t* vallen, + void** val); -size_t -leafentry_disksize_13(LEAFENTRY_13 le); +size_t leafentry_disksize_13(LEAFENTRY_13 le); -int -toku_le_upgrade_13_14(LEAFENTRY_13 old_leafentry, // NULL if there was no stored data. - void** keyp, - uint32_t* keylen, - size_t *new_leafentry_memorysize, - LEAFENTRY *new_leafentry_p); +int toku_le_upgrade_13_14( + // NULL if there was no stored data. + LEAFENTRY_13 old_leafentry, + void** keyp, + uint32_t* keylen, + size_t* new_leafentry_memorysize, + LEAFENTRY *new_leafentry_p); class bn_data; -void -toku_le_apply_msg(const ft_msg &msg, - LEAFENTRY old_leafentry, // NULL if there was no stored data. - bn_data* data_buffer, // bn_data storing leafentry, if NULL, means there is no bn_data - uint32_t idx, // index in data_buffer where leafentry is stored (and should be replaced - uint32_t old_keylen, - txn_gc_info *gc_info, - LEAFENTRY *new_leafentry_p, - int64_t * numbytes_delta_p); +int64_t toku_le_apply_msg( + const ft_msg &msg, + // NULL if there was no stored data. + LEAFENTRY old_leafentry, + // bn_data storing leafentry, if NULL, means there is no bn_data + bn_data* data_buffer, + // index in data_buffer where leafentry is stored (and should be replaced + uint32_t idx, + uint32_t old_keylen, + txn_gc_info* gc_info, + LEAFENTRY *new_leafentry_p, + int64_t* numbytes_delta_p); -bool toku_le_worth_running_garbage_collection(LEAFENTRY le, txn_gc_info *gc_info); +bool toku_le_worth_running_garbage_collection( + LEAFENTRY le, + txn_gc_info* gc_info); -void -toku_le_garbage_collect(LEAFENTRY old_leaf_entry, - bn_data* data_buffer, - uint32_t idx, - void* keyp, - uint32_t keylen, - txn_gc_info *gc_info, - LEAFENTRY *new_leaf_entry, - int64_t * numbytes_delta_p); +void toku_le_garbage_collect( + LEAFENTRY old_leaf_entry, + bn_data* data_buffer, + uint32_t idx, + void* keyp, + uint32_t keylen, + txn_gc_info* gc_info, + LEAFENTRY* new_leaf_entry, + int64_t* numbytes_delta_p); diff --git a/storage/tokudb/PerconaFT/ft/loader/loader.cc b/storage/tokudb/PerconaFT/ft/loader/loader.cc index 5ff0d69af46..20f9363da1e 100644 --- a/storage/tokudb/PerconaFT/ft/loader/loader.cc +++ b/storage/tokudb/PerconaFT/ft/loader/loader.cc @@ -2312,11 +2312,42 @@ static struct leaf_buf *start_leaf (struct dbout *out, const DESCRIPTOR UU(desc) return lbuf; } -static void finish_leafnode (struct dbout *out, struct leaf_buf *lbuf, int progress_allocation, FTLOADER bl, uint32_t target_basementnodesize, enum toku_compression_method target_compression_method); -static int write_nonleaves (FTLOADER bl, FIDX pivots_fidx, struct dbout *out, struct subtrees_info *sts, const DESCRIPTOR descriptor, uint32_t target_nodesize, uint32_t target_basementnodesize, enum toku_compression_method target_compression_method); -static void add_pair_to_leafnode (struct leaf_buf *lbuf, unsigned char *key, int keylen, unsigned char *val, int vallen, int this_leafentry_size, STAT64INFO stats_to_update); -static int write_translation_table (struct dbout *out, long long *off_of_translation_p); -static int write_header (struct dbout *out, long long translation_location_on_disk, long long translation_size_on_disk); +static void finish_leafnode( + struct dbout* out, + struct leaf_buf* lbuf, + int progress_allocation, + FTLOADER bl, + uint32_t target_basementnodesize, + enum toku_compression_method target_compression_method); + +static int write_nonleaves( + FTLOADER bl, + FIDX pivots_fidx, + struct dbout* out, + struct subtrees_info* sts, + const DESCRIPTOR descriptor, + uint32_t target_nodesize, + uint32_t target_basementnodesize, + enum toku_compression_method target_compression_method); + +static void add_pair_to_leafnode( + struct leaf_buf* lbuf, + unsigned char* key, + int keylen, + unsigned char* val, + int vallen, + int this_leafentry_size, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta); + +static int write_translation_table( + struct dbout* out, + long long* off_of_translation_p); + +static int write_header( + struct dbout* out, + long long translation_location_on_disk, + long long translation_size_on_disk); static void drain_writer_q(QUEUE q) { void *item; @@ -2448,6 +2479,12 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, DBT maxkey = make_dbt(0, 0); // keep track of the max key of the current node STAT64INFO_S deltas = ZEROSTATS; + // This is just a placeholder and not used in the loader, the real/accurate + // stats will come out of 'deltas' because this loader is not pushing + // messages down into the top of a fractal tree where the logical row count + // is done, it is directly creating leaf entries so it must also take on + // performing the logical row counting on its own + int64_t logical_rows_delta = 0; while (result == 0) { void *item; { @@ -2506,7 +2543,15 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, lbuf = start_leaf(&out, descriptor, lblock, le_xid, target_nodesize); } - add_pair_to_leafnode(lbuf, (unsigned char *) key.data, key.size, (unsigned char *) val.data, val.size, this_leafentry_size, &deltas); + add_pair_to_leafnode( + lbuf, + (unsigned char*)key.data, + key.size, + (unsigned char*)val.data, + val.size, + this_leafentry_size, + &deltas, + &logical_rows_delta); n_rows_remaining--; update_maxkey(&maxkey, &key); // set the new maxkey to the current key @@ -2526,6 +2571,13 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, toku_ft_update_stats(&ft.in_memory_stats, deltas); } + // As noted above, the loader directly creates a tree structure without + // going through the higher level ft API and tus bypasses the logical row + // counting performed at that level. So, we must manually update the logical + // row count with the info we have from the physical delta that comes out of + // add_pair_to_leafnode. + toku_ft_adjust_logical_row_count(&ft, deltas.numrows); + cleanup_maxkey(&maxkey); if (lbuf) { @@ -2878,7 +2930,16 @@ int toku_ft_loader_get_error(FTLOADER bl, int *error) { return 0; } -static void add_pair_to_leafnode (struct leaf_buf *lbuf, unsigned char *key, int keylen, unsigned char *val, int vallen, int this_leafentry_size, STAT64INFO stats_to_update) { +static void add_pair_to_leafnode( + struct leaf_buf* lbuf, + unsigned char* key, + int keylen, + unsigned char* val, + int vallen, + int this_leafentry_size, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta) { + lbuf->nkeys++; lbuf->ndata++; lbuf->dsize += keylen + vallen; @@ -2890,11 +2951,25 @@ static void add_pair_to_leafnode (struct leaf_buf *lbuf, unsigned char *key, int FTNODE leafnode = lbuf->node; uint32_t idx = BLB_DATA(leafnode, 0)->num_klpairs(); DBT kdbt, vdbt; - ft_msg msg(toku_fill_dbt(&kdbt, key, keylen), toku_fill_dbt(&vdbt, val, vallen), FT_INSERT, ZERO_MSN, lbuf->xids); + ft_msg msg( + toku_fill_dbt(&kdbt, key, keylen), + toku_fill_dbt(&vdbt, val, vallen), + FT_INSERT, + ZERO_MSN, + lbuf->xids); uint64_t workdone = 0; // there's no mvcc garbage in a bulk-loaded FT, so there's no need to pass useful gc info txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, true); - toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, &workdone, stats_to_update); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + &workdone, + stats_to_update, + logical_rows_delta); } static int write_literal(struct dbout *out, void*data, size_t len) { @@ -2905,7 +2980,14 @@ static int write_literal(struct dbout *out, void*data, size_t len) { return result; } -static void finish_leafnode (struct dbout *out, struct leaf_buf *lbuf, int progress_allocation, FTLOADER bl, uint32_t target_basementnodesize, enum toku_compression_method target_compression_method) { +static void finish_leafnode( + struct dbout* out, + struct leaf_buf* lbuf, + int progress_allocation, + FTLOADER bl, + uint32_t target_basementnodesize, + enum toku_compression_method target_compression_method) { + int result = 0; // serialize leaf to buffer @@ -2913,7 +2995,16 @@ static void finish_leafnode (struct dbout *out, struct leaf_buf *lbuf, int progr size_t uncompressed_serialized_leaf_size = 0; char *serialized_leaf = NULL; FTNODE_DISK_DATA ndd = NULL; - result = toku_serialize_ftnode_to_memory(lbuf->node, &ndd, target_basementnodesize, target_compression_method, true, true, &serialized_leaf_size, &uncompressed_serialized_leaf_size, &serialized_leaf); + result = toku_serialize_ftnode_to_memory( + lbuf->node, + &ndd, + target_basementnodesize, + target_compression_method, + true, + true, + &serialized_leaf_size, + &uncompressed_serialized_leaf_size, + &serialized_leaf); // write it out if (result == 0) { @@ -2979,8 +3070,11 @@ static int write_translation_table (struct dbout *out, long long *off_of_transla return result; } -static int -write_header (struct dbout *out, long long translation_location_on_disk, long long translation_size_on_disk) { +static int write_header( + struct dbout* out, + long long translation_location_on_disk, + long long translation_size_on_disk) { + int result = 0; size_t size = toku_serialize_ft_size(out->ft->h); size_t alloced_size = roundup_to_multiple(512, size); @@ -2991,6 +3085,7 @@ write_header (struct dbout *out, long long translation_location_on_disk, long lo } else { wbuf_init(&wbuf, buf, size); out->ft->h->on_disk_stats = out->ft->in_memory_stats; + out->ft->h->on_disk_logical_rows = out->ft->in_memory_logical_rows; toku_serialize_ft_to_wbuf(&wbuf, out->ft->h, translation_location_on_disk, translation_size_on_disk); for (size_t i=size; i= TOKU_LOG_VERSION_25 && + version_of_logs_on_disk <= TOKU_LOG_VERSION_29 && + TOKU_LOG_VERSION_29 == TOKU_LOG_VERSION) { r = 0; // can do recovery on dirty shutdown } else { fprintf(stderr, "Cannot upgrade PerconaFT version %d database.", version_of_logs_on_disk); diff --git a/storage/tokudb/PerconaFT/ft/logger/logger.h b/storage/tokudb/PerconaFT/ft/logger/logger.h index 1f15f59fb3f..d9595d71065 100644 --- a/storage/tokudb/PerconaFT/ft/logger/logger.h +++ b/storage/tokudb/PerconaFT/ft/logger/logger.h @@ -54,6 +54,7 @@ enum { TOKU_LOG_VERSION_26 = 26, // no change from 25 TOKU_LOG_VERSION_27 = 27, // no change from 26 TOKU_LOG_VERSION_28 = 28, // no change from 27 + TOKU_LOG_VERSION_29 = 29, // no change from 28 TOKU_LOG_VERSION = FT_LAYOUT_VERSION, TOKU_LOG_MIN_SUPPORTED_VERSION = FT_LAYOUT_MIN_SUPPORTED_VERSION, }; diff --git a/storage/tokudb/PerconaFT/ft/logger/recover.h b/storage/tokudb/PerconaFT/ft/logger/recover.h index 0d216c11a8b..bdd44d562cd 100644 --- a/storage/tokudb/PerconaFT/ft/logger/recover.h +++ b/storage/tokudb/PerconaFT/ft/logger/recover.h @@ -67,7 +67,7 @@ int tokuft_recover(DB_ENV *env, // Effect: Check the tokuft logs to determine whether or not we need to run recovery. // If the log is empty or if there is a clean shutdown at the end of the log, then we -// dont need to run recovery. +// don't need to run recovery. // Returns: true if we need recovery, otherwise false. int tokuft_needs_recovery(const char *logdir, bool ignore_empty_log); diff --git a/storage/tokudb/PerconaFT/ft/node.cc b/storage/tokudb/PerconaFT/ft/node.cc index 44dbc73ba2b..58ba675eb7c 100644 --- a/storage/tokudb/PerconaFT/ft/node.cc +++ b/storage/tokudb/PerconaFT/ft/node.cc @@ -206,12 +206,20 @@ int msg_buffer_offset_msn_cmp(message_buffer &msg_buffer, const int32_t &ao, con } /** - * Given a message buffer and and offset, apply the message with toku_ft_bn_apply_msg, or discard it, + * Given a message buffer and and offset, apply the message with + * toku_ft_bn_apply_msg, or discard it, * based on its MSN and the MSN of the basement node. */ -static void -do_bn_apply_msg(FT_HANDLE ft_handle, BASEMENTNODE bn, message_buffer *msg_buffer, int32_t offset, - txn_gc_info *gc_info, uint64_t *workdone, STAT64INFO stats_to_update) { +static void do_bn_apply_msg( + FT_HANDLE ft_handle, + BASEMENTNODE bn, + message_buffer* msg_buffer, + int32_t offset, + txn_gc_info* gc_info, + uint64_t* workdone, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta) { + DBT k, v; ft_msg msg = msg_buffer->get_message(offset, &k, &v); @@ -227,16 +235,17 @@ do_bn_apply_msg(FT_HANDLE ft_handle, BASEMENTNODE bn, message_buffer *msg_buffer msg, gc_info, workdone, - stats_to_update - ); + stats_to_update, + logical_rows_delta); } else { toku_ft_status_note_msn_discard(); } // We must always mark message as stale since it has been marked // (using omt::iterate_and_mark_range) - // It is possible to call do_bn_apply_msg even when it won't apply the message because - // the node containing it could have been evicted and brought back in. + // It is possible to call do_bn_apply_msg even when it won't apply the + // message because the node containing it could have been evicted and + // brought back in. msg_buffer->set_freshness(offset, false); } @@ -248,12 +257,29 @@ struct iterate_do_bn_apply_msg_extra { txn_gc_info *gc_info; uint64_t *workdone; STAT64INFO stats_to_update; + int64_t *logical_rows_delta; }; -int iterate_do_bn_apply_msg(const int32_t &offset, const uint32_t UU(idx), struct iterate_do_bn_apply_msg_extra *const e) __attribute__((nonnull(3))); -int iterate_do_bn_apply_msg(const int32_t &offset, const uint32_t UU(idx), struct iterate_do_bn_apply_msg_extra *const e) +int iterate_do_bn_apply_msg( + const int32_t &offset, + const uint32_t UU(idx), + struct iterate_do_bn_apply_msg_extra* const e) + __attribute__((nonnull(3))); + +int iterate_do_bn_apply_msg( + const int32_t &offset, + const uint32_t UU(idx), + struct iterate_do_bn_apply_msg_extra* const e) { - do_bn_apply_msg(e->t, e->bn, &e->bnc->msg_buffer, offset, e->gc_info, e->workdone, e->stats_to_update); + do_bn_apply_msg( + e->t, + e->bn, + &e->bnc->msg_buffer, + offset, + e->gc_info, + e->workdone, + e->stats_to_update, + e->logical_rows_delta); return 0; } @@ -354,17 +380,15 @@ find_bounds_within_message_tree( * or plus infinity respectively if they are NULL. Do not mark the node * as dirty (preserve previous state of 'dirty' bit). */ -static void -bnc_apply_messages_to_basement_node( +static void bnc_apply_messages_to_basement_node( FT_HANDLE t, // used for comparison function BASEMENTNODE bn, // where to apply messages FTNODE ancestor, // the ancestor node where we can find messages to apply int childnum, // which child buffer of ancestor contains messages we want const pivot_bounds &bounds, // contains pivot key bounds of this basement node - txn_gc_info *gc_info, - bool* msgs_applied - ) -{ + txn_gc_info* gc_info, + bool* msgs_applied) { + int r; NONLEAF_CHILDINFO bnc = BNC(ancestor, childnum); @@ -372,16 +396,29 @@ bnc_apply_messages_to_basement_node( // apply messages from this buffer STAT64INFO_S stats_delta = {0,0}; uint64_t workdone_this_ancestor = 0; + int64_t logical_rows_delta = 0; uint32_t stale_lbi, stale_ube; if (!bn->stale_ancestor_messages_applied) { - find_bounds_within_message_tree(t->ft->cmp, bnc->stale_message_tree, &bnc->msg_buffer, bounds, &stale_lbi, &stale_ube); + find_bounds_within_message_tree( + t->ft->cmp, + bnc->stale_message_tree, + &bnc->msg_buffer, + bounds, + &stale_lbi, + &stale_ube); } else { stale_lbi = 0; stale_ube = 0; } uint32_t fresh_lbi, fresh_ube; - find_bounds_within_message_tree(t->ft->cmp, bnc->fresh_message_tree, &bnc->msg_buffer, bounds, &fresh_lbi, &fresh_ube); + find_bounds_within_message_tree( + t->ft->cmp, + bnc->fresh_message_tree, + &bnc->msg_buffer, + bounds, + &fresh_lbi, + &fresh_ube); // We now know where all the messages we must apply are, so one of the // following 4 cases will do the application, depending on which of @@ -395,7 +432,9 @@ bnc_apply_messages_to_basement_node( // We have messages in multiple trees, so we grab all // the relevant messages' offsets and sort them by MSN, then apply // them in MSN order. - const int buffer_size = ((stale_ube - stale_lbi) + (fresh_ube - fresh_lbi) + bnc->broadcast_list.size()); + const int buffer_size = ((stale_ube - stale_lbi) + + (fresh_ube - fresh_lbi) + + bnc->broadcast_list.size()); toku::scoped_malloc offsets_buf(buffer_size * sizeof(int32_t)); int32_t *offsets = reinterpret_cast(offsets_buf.get()); struct store_msg_buffer_offset_extra sfo_extra = { .offsets = offsets, .i = 0 }; @@ -419,11 +458,27 @@ bnc_apply_messages_to_basement_node( // Apply the messages in MSN order. for (int i = 0; i < buffer_size; ++i) { *msgs_applied = true; - do_bn_apply_msg(t, bn, &bnc->msg_buffer, offsets[i], gc_info, &workdone_this_ancestor, &stats_delta); + do_bn_apply_msg( + t, + bn, + &bnc->msg_buffer, + offsets[i], + gc_info, + &workdone_this_ancestor, + &stats_delta, + &logical_rows_delta); } } else if (stale_lbi == stale_ube) { // No stale messages to apply, we just apply fresh messages, and mark them to be moved to stale later. - struct iterate_do_bn_apply_msg_extra iter_extra = { .t = t, .bn = bn, .bnc = bnc, .gc_info = gc_info, .workdone = &workdone_this_ancestor, .stats_to_update = &stats_delta }; + struct iterate_do_bn_apply_msg_extra iter_extra = { + .t = t, + .bn = bn, + .bnc = bnc, + .gc_info = gc_info, + .workdone = &workdone_this_ancestor, + .stats_to_update = &stats_delta, + .logical_rows_delta = &logical_rows_delta + }; if (fresh_ube - fresh_lbi > 0) *msgs_applied = true; r = bnc->fresh_message_tree.iterate_and_mark_range(fresh_lbi, fresh_ube, &iter_extra); assert_zero(r); @@ -432,7 +487,15 @@ bnc_apply_messages_to_basement_node( // No fresh messages to apply, we just apply stale messages. if (stale_ube - stale_lbi > 0) *msgs_applied = true; - struct iterate_do_bn_apply_msg_extra iter_extra = { .t = t, .bn = bn, .bnc = bnc, .gc_info = gc_info, .workdone = &workdone_this_ancestor, .stats_to_update = &stats_delta }; + struct iterate_do_bn_apply_msg_extra iter_extra = { + .t = t, + .bn = bn, + .bnc = bnc, + .gc_info = gc_info, + .workdone = &workdone_this_ancestor, + .stats_to_update = &stats_delta, + .logical_rows_delta = &logical_rows_delta + }; r = bnc->stale_message_tree.iterate_on_range(stale_lbi, stale_ube, &iter_extra); assert_zero(r); @@ -446,6 +509,7 @@ bnc_apply_messages_to_basement_node( if (stats_delta.numbytes || stats_delta.numrows) { toku_ft_update_stats(&t->ft->in_memory_stats, stats_delta); } + toku_ft_adjust_logical_row_count(t->ft, logical_rows_delta); } static void @@ -1073,7 +1137,8 @@ toku_ft_bn_apply_msg_once ( LEAFENTRY le, txn_gc_info *gc_info, uint64_t *workdone, - STAT64INFO stats_to_update + STAT64INFO stats_to_update, + int64_t *logical_rows_delta ) // Effect: Apply msg to leafentry (msn is ignored) // Calculate work done by message on leafentry and add it to caller's workdone counter. @@ -1082,26 +1147,34 @@ toku_ft_bn_apply_msg_once ( { size_t newsize=0, oldsize=0, workdone_this_le=0; LEAFENTRY new_le=0; - int64_t numbytes_delta = 0; // how many bytes of user data (not including overhead) were added or deleted from this row - int64_t numrows_delta = 0; // will be +1 or -1 or 0 (if row was added or deleted or not) + // how many bytes of user data (not including overhead) were added or + // deleted from this row + int64_t numbytes_delta = 0; + // will be +1 or -1 or 0 (if row was added or deleted or not) + int64_t numrows_delta = 0; + // will be +1, -1 or 0 if a message that was accounted for logically has + // changed in meaning such as an insert changed to an update or a delete + // changed to a noop + int64_t logical_rows_delta_le = 0; uint32_t key_storage_size = msg.kdbt()->size + sizeof(uint32_t); if (le) { oldsize = leafentry_memsize(le) + key_storage_size; } - // toku_le_apply_msg() may call bn_data::mempool_malloc_and_update_dmt() to allocate more space. - // That means le is guaranteed to not cause a sigsegv but it may point to a mempool that is - // no longer in use. We'll have to release the old mempool later. - toku_le_apply_msg( - msg, + // toku_le_apply_msg() may call bn_data::mempool_malloc_and_update_dmt() + // to allocate more space. That means le is guaranteed to not cause a + // sigsegv but it may point to a mempool that is no longer in use. + // We'll have to release the old mempool later. + logical_rows_delta_le = toku_le_apply_msg( + msg, le, &bn->data_buffer, idx, le_keylen, - gc_info, - &new_le, - &numbytes_delta - ); + gc_info, + &new_le, + &numbytes_delta); + // at this point, we cannot trust cmd->u.id.key to be valid. // The dmt may have realloced its mempool and freed the one containing key. @@ -1121,37 +1194,42 @@ toku_ft_bn_apply_msg_once ( numrows_delta = 1; } } - if (workdone) { // test programs may call with NULL + if (FT_LIKELY(workdone != NULL)) { // test programs may call with NULL *workdone += workdone_this_le; } + if (FT_LIKELY(logical_rows_delta != NULL)) { + *logical_rows_delta += logical_rows_delta_le; + } // now update stat64 statistics bn->stat64_delta.numrows += numrows_delta; bn->stat64_delta.numbytes += numbytes_delta; // the only reason stats_to_update may be null is for tests - if (stats_to_update) { + if (FT_LIKELY(stats_to_update != NULL)) { stats_to_update->numrows += numrows_delta; stats_to_update->numbytes += numbytes_delta; } - } static const uint32_t setval_tag = 0xee0ccb99; // this was gotten by doing "cat /dev/random|head -c4|od -x" to get a random number. We want to make sure that the user actually passes us the setval_extra_s that we passed in. struct setval_extra_s { uint32_t tag; bool did_set_val; - int setval_r; // any error code that setval_fun wants to return goes here. + // any error code that setval_fun wants to return goes here. + int setval_r; // need arguments for toku_ft_bn_apply_msg_once BASEMENTNODE bn; - MSN msn; // captured from original message, not currently used + // captured from original message, not currently used + MSN msn; XIDS xids; - const DBT *key; + const DBT* key; uint32_t idx; uint32_t le_keylen; LEAFENTRY le; - txn_gc_info *gc_info; - uint64_t * workdone; // set by toku_ft_bn_apply_msg_once() + txn_gc_info* gc_info; + uint64_t* workdone; // set by toku_ft_bn_apply_msg_once() STAT64INFO stats_to_update; + int64_t* logical_rows_delta; }; /* @@ -1170,29 +1248,45 @@ static void setval_fun (const DBT *new_val, void *svextra_v) { // can't leave scope until toku_ft_bn_apply_msg_once if // this is a delete DBT val; - ft_msg msg(svextra->key, - new_val ? new_val : toku_init_dbt(&val), - new_val ? FT_INSERT : FT_DELETE_ANY, - svextra->msn, svextra->xids); - toku_ft_bn_apply_msg_once(svextra->bn, msg, - svextra->idx, svextra->le_keylen, svextra->le, - svextra->gc_info, - svextra->workdone, svextra->stats_to_update); + ft_msg msg( + svextra->key, + new_val ? new_val : toku_init_dbt(&val), + new_val ? FT_INSERT : FT_DELETE_ANY, + svextra->msn, + svextra->xids); + toku_ft_bn_apply_msg_once( + svextra->bn, + msg, + svextra->idx, + svextra->le_keylen, + svextra->le, + svextra->gc_info, + svextra->workdone, + svextra->stats_to_update, + svextra->logical_rows_delta); svextra->setval_r = 0; } } -// We are already past the msn filter (in toku_ft_bn_apply_msg(), which calls do_update()), -// so capturing the msn in the setval_extra_s is not strictly required. The alternative -// would be to put a dummy msn in the messages created by setval_fun(), but preserving -// the original msn seems cleaner and it preserves accountability at a lower layer. -static int do_update(ft_update_func update_fun, const DESCRIPTOR_S *desc, BASEMENTNODE bn, const ft_msg &msg, uint32_t idx, - LEAFENTRY le, - void* keydata, - uint32_t keylen, - txn_gc_info *gc_info, - uint64_t * workdone, - STAT64INFO stats_to_update) { +// We are already past the msn filter (in toku_ft_bn_apply_msg(), which calls +// do_update()), so capturing the msn in the setval_extra_s is not strictly +// required. The alternative would be to put a dummy msn in the messages +// created by setval_fun(), but preserving the original msn seems cleaner and +// it preserves accountability at a lower layer. +static int do_update( + ft_update_func update_fun, + const DESCRIPTOR_S* desc, + BASEMENTNODE bn, + const ft_msg &msg, + uint32_t idx, + LEAFENTRY le, + void* keydata, + uint32_t keylen, + txn_gc_info* gc_info, + uint64_t* workdone, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta) { + LEAFENTRY le_for_update; DBT key; const DBT *keyp; @@ -1232,39 +1326,52 @@ static int do_update(ft_update_func update_fun, const DESCRIPTOR_S *desc, BASEME } le_for_update = le; - struct setval_extra_s setval_extra = {setval_tag, false, 0, bn, msg.msn(), msg.xids(), - keyp, idx, keylen, le_for_update, gc_info, - workdone, stats_to_update}; - // call handlerton's ft->update_fun(), which passes setval_extra to setval_fun() + struct setval_extra_s setval_extra = { + setval_tag, + false, + 0, + bn, + msg.msn(), + msg.xids(), + keyp, + idx, + keylen, + le_for_update, + gc_info, + workdone, + stats_to_update, + logical_rows_delta + }; + // call handlerton's ft->update_fun(), which passes setval_extra + // to setval_fun() FAKE_DB(db, desc); int r = update_fun( &db, keyp, vdbtp, update_function_extra, - setval_fun, &setval_extra - ); + setval_fun, + &setval_extra); if (r == 0) { r = setval_extra.setval_r; } return r; } // Should be renamed as something like "apply_msg_to_basement()." -void -toku_ft_bn_apply_msg ( - const toku::comparator &cmp, +void toku_ft_bn_apply_msg( + const toku::comparator& cmp, ft_update_func update_fun, BASEMENTNODE bn, - const ft_msg &msg, - txn_gc_info *gc_info, - uint64_t *workdone, - STAT64INFO stats_to_update - ) + const ft_msg& msg, + txn_gc_info* gc_info, + uint64_t* workdone, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta) { // Effect: // Put a msg into a leaf. -// Calculate work done by message on leafnode and add it to caller's workdone counter. +// Calculate work done by message on leafnode and add it to caller's +// workdone counter. // The leaf could end up "too big" or "too small". The caller must fix that up. -{ LEAFENTRY storeddata; void* key = NULL; uint32_t keylen = 0; @@ -1303,7 +1410,16 @@ toku_ft_bn_apply_msg ( } else { assert_zero(r); } - toku_ft_bn_apply_msg_once(bn, msg, idx, keylen, storeddata, gc_info, workdone, stats_to_update); + toku_ft_bn_apply_msg_once( + bn, + msg, + idx, + keylen, + storeddata, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); // if the insertion point is within a window of the right edge of // the leaf then it is sequential @@ -1331,12 +1447,19 @@ toku_ft_bn_apply_msg ( &storeddata, &key, &keylen, - &idx - ); + &idx); if (r == DB_NOTFOUND) break; assert_zero(r); - toku_ft_bn_apply_msg_once(bn, msg, idx, keylen, storeddata, gc_info, workdone, stats_to_update); - + toku_ft_bn_apply_msg_once( + bn, + msg, + idx, + keylen, + storeddata, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); break; } case FT_OPTIMIZE_FOR_UPGRADE: @@ -1352,13 +1475,27 @@ toku_ft_bn_apply_msg ( assert_zero(r); int deleted = 0; if (!le_is_clean(storeddata)) { //If already clean, nothing to do. - // message application code needs a key in order to determine how much - // work was done by this message. since this is a broadcast message, - // we have to create a new message whose key is the current le's key. + // message application code needs a key in order to determine + // how much work was done by this message. since this is a + // broadcast message, we have to create a new message whose + // key is the current le's key. DBT curr_keydbt; - ft_msg curr_msg(toku_fill_dbt(&curr_keydbt, curr_keyp, curr_keylen), - msg.vdbt(), msg.type(), msg.msn(), msg.xids()); - toku_ft_bn_apply_msg_once(bn, curr_msg, idx, curr_keylen, storeddata, gc_info, workdone, stats_to_update); + ft_msg curr_msg( + toku_fill_dbt(&curr_keydbt, curr_keyp, curr_keylen), + msg.vdbt(), + msg.type(), + msg.msn(), + msg.xids()); + toku_ft_bn_apply_msg_once( + bn, + curr_msg, + idx, + curr_keylen, + storeddata, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); // at this point, we cannot trust msg.kdbt to be valid. uint32_t new_dmt_size = bn->data_buffer.num_klpairs(); if (new_dmt_size != num_klpairs) { @@ -1386,13 +1523,27 @@ toku_ft_bn_apply_msg ( assert_zero(r); int deleted = 0; if (le_has_xids(storeddata, msg.xids())) { - // message application code needs a key in order to determine how much - // work was done by this message. since this is a broadcast message, - // we have to create a new message whose key is the current le's key. + // message application code needs a key in order to determine + // how much work was done by this message. since this is a + // broadcast message, we have to create a new message whose key + // is the current le's key. DBT curr_keydbt; - ft_msg curr_msg(toku_fill_dbt(&curr_keydbt, curr_keyp, curr_keylen), - msg.vdbt(), msg.type(), msg.msn(), msg.xids()); - toku_ft_bn_apply_msg_once(bn, curr_msg, idx, curr_keylen, storeddata, gc_info, workdone, stats_to_update); + ft_msg curr_msg( + toku_fill_dbt(&curr_keydbt, curr_keyp, curr_keylen), + msg.vdbt(), + msg.type(), + msg.msn(), + msg.xids()); + toku_ft_bn_apply_msg_once( + bn, + curr_msg, + idx, + curr_keylen, + storeddata, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); uint32_t new_dmt_size = bn->data_buffer.num_klpairs(); if (new_dmt_size != num_klpairs) { paranoid_invariant(new_dmt_size + 1 == num_klpairs); @@ -1424,9 +1575,33 @@ toku_ft_bn_apply_msg ( key = msg.kdbt()->data; keylen = msg.kdbt()->size; } - r = do_update(update_fun, cmp.get_descriptor(), bn, msg, idx, NULL, NULL, 0, gc_info, workdone, stats_to_update); + r = do_update( + update_fun, + cmp.get_descriptor(), + bn, + msg, + idx, + NULL, + NULL, + 0, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); } else if (r==0) { - r = do_update(update_fun, cmp.get_descriptor(), bn, msg, idx, storeddata, key, keylen, gc_info, workdone, stats_to_update); + r = do_update( + update_fun, + cmp.get_descriptor(), + bn, + msg, + idx, + storeddata, + key, + keylen, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); } // otherwise, a worse error, just return it break; } @@ -1434,6 +1609,12 @@ toku_ft_bn_apply_msg ( // apply to all leafentries. uint32_t idx = 0; uint32_t num_leafentries_before; + // This is used to avoid having the logical row count changed on apply + // of this message since it will return a negative number of the number + // of leaf entries visited and cause the ft header value to go to 0; + // This message will not change the number of rows, so just use the + // bogus value. + int64_t temp_logical_rows_delta = 0; while (idx < (num_leafentries_before = bn->data_buffer.num_klpairs())) { void* curr_key = nullptr; uint32_t curr_keylen = 0; @@ -1449,7 +1630,19 @@ toku_ft_bn_apply_msg ( // This is broken below. Have a compilation error checked // in as a reminder - r = do_update(update_fun, cmp.get_descriptor(), bn, msg, idx, storeddata, curr_key, curr_keylen, gc_info, workdone, stats_to_update); + r = do_update( + update_fun, + cmp.get_descriptor(), + bn, + msg, + idx, + storeddata, + curr_key, + curr_keylen, + gc_info, + workdone, + stats_to_update, + &temp_logical_rows_delta); assert_zero(r); if (num_leafentries_before == bn->data_buffer.num_klpairs()) { @@ -1810,24 +2003,22 @@ void toku_ftnode_leaf_run_gc(FT ft, FTNODE node) { } } -void -toku_ftnode_put_msg ( +void toku_ftnode_put_msg( const toku::comparator &cmp, ft_update_func update_fun, FTNODE node, int target_childnum, const ft_msg &msg, bool is_fresh, - txn_gc_info *gc_info, + txn_gc_info* gc_info, size_t flow_deltas[], - STAT64INFO stats_to_update - ) + STAT64INFO stats_to_update, + int64_t* logical_rows_delta) { // Effect: Push message into the subtree rooted at NODE. // If NODE is a leaf, then // put message into leaf, applying it to the leafentries // If NODE is a nonleaf, then push the message into the message buffer(s) of the relevent child(ren). // The node may become overfull. That's not our problem. -{ toku_ftnode_assert_fully_in_memory(node); // // see comments in toku_ft_leaf_apply_msg @@ -1836,26 +2027,40 @@ toku_ftnode_put_msg ( // and instead defer to these functions // if (node->height==0) { - toku_ft_leaf_apply_msg(cmp, update_fun, node, target_childnum, msg, gc_info, nullptr, stats_to_update); + toku_ft_leaf_apply_msg( + cmp, + update_fun, + node, + target_childnum, msg, + gc_info, + nullptr, + stats_to_update, + logical_rows_delta); } else { - ft_nonleaf_put_msg(cmp, node, target_childnum, msg, is_fresh, flow_deltas); + ft_nonleaf_put_msg( + cmp, + node, + target_childnum, + msg, + is_fresh, + flow_deltas); } } -// Effect: applies the message to the leaf if the appropriate basement node is in memory. -// This function is called during message injection and/or flushing, so the entire -// node MUST be in memory. +// Effect: applies the message to the leaf if the appropriate basement node is +// in memory. This function is called during message injection and/or +// flushing, so the entire node MUST be in memory. void toku_ft_leaf_apply_msg( - const toku::comparator &cmp, + const toku::comparator& cmp, ft_update_func update_fun, FTNODE node, int target_childnum, // which child to inject to, or -1 if unknown - const ft_msg &msg, - txn_gc_info *gc_info, - uint64_t *workdone, - STAT64INFO stats_to_update - ) -{ + const ft_msg& msg, + txn_gc_info* gc_info, + uint64_t* workdone, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta) { + VERIFY_NODE(t, node); toku_ftnode_assert_fully_in_memory(node); @@ -1891,34 +2096,36 @@ void toku_ft_leaf_apply_msg( BASEMENTNODE bn = BLB(node, childnum); if (msg.msn().msn > bn->max_msn_applied.msn) { bn->max_msn_applied = msg.msn(); - toku_ft_bn_apply_msg(cmp, - update_fun, - bn, - msg, - gc_info, - workdone, - stats_to_update); + toku_ft_bn_apply_msg( + cmp, + update_fun, + bn, + msg, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); } else { toku_ft_status_note_msn_discard(); } - } - else if (ft_msg_type_applies_all(msg.type())) { + } else if (ft_msg_type_applies_all(msg.type())) { for (int childnum=0; childnumn_children; childnum++) { if (msg.msn().msn > BLB(node, childnum)->max_msn_applied.msn) { BLB(node, childnum)->max_msn_applied = msg.msn(); - toku_ft_bn_apply_msg(cmp, - update_fun, - BLB(node, childnum), - msg, - gc_info, - workdone, - stats_to_update); + toku_ft_bn_apply_msg( + cmp, + update_fun, + BLB(node, childnum), + msg, + gc_info, + workdone, + stats_to_update, + logical_rows_delta); } else { toku_ft_status_note_msn_discard(); } } - } - else if (!ft_msg_type_does_nothing(msg.type())) { + } else if (!ft_msg_type_does_nothing(msg.type())) { invariant(ft_msg_type_does_nothing(msg.type())); } VERIFY_NODE(t, node); diff --git a/storage/tokudb/PerconaFT/ft/node.h b/storage/tokudb/PerconaFT/ft/node.h index 9d910491682..ad0298e81c5 100644 --- a/storage/tokudb/PerconaFT/ft/node.h +++ b/storage/tokudb/PerconaFT/ft/node.h @@ -382,25 +382,54 @@ enum reactivity toku_ftnode_get_leaf_reactivity(FTNODE node, uint32_t nodesize); * If k is equal to some pivot, then we return the next (to the right) * childnum. */ -int toku_ftnode_hot_next_child(FTNODE node, const DBT *k, const toku::comparator &cmp); +int toku_ftnode_hot_next_child( + FTNODE node, + const DBT* k, + const toku::comparator &cmp); -void toku_ftnode_put_msg(const toku::comparator &cmp, ft_update_func update_fun, - FTNODE node, int target_childnum, - const ft_msg &msg, bool is_fresh, txn_gc_info *gc_info, - size_t flow_deltas[], STAT64INFO stats_to_update); +void toku_ftnode_put_msg( + const toku::comparator& cmp, + ft_update_func update_fun, + FTNODE node, + int target_childnum, + const ft_msg& msg, + bool is_fresh, + txn_gc_info* gc_info, + size_t flow_deltas[], + STAT64INFO stats_to_update, + int64_t* logical_rows_delta); -void toku_ft_bn_apply_msg_once(BASEMENTNODE bn, const ft_msg &msg, uint32_t idx, - uint32_t le_keylen, LEAFENTRY le, txn_gc_info *gc_info, - uint64_t *workdonep, STAT64INFO stats_to_update); +void toku_ft_bn_apply_msg_once( + BASEMENTNODE bn, + const ft_msg& msg, + uint32_t idx, + uint32_t le_keylen, + LEAFENTRY le, + txn_gc_info* gc_info, + uint64_t* workdonep, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta); -void toku_ft_bn_apply_msg(const toku::comparator &cmp, ft_update_func update_fun, - BASEMENTNODE bn, const ft_msg &msg, txn_gc_info *gc_info, - uint64_t *workdone, STAT64INFO stats_to_update); +void toku_ft_bn_apply_msg( + const toku::comparator& cmp, + ft_update_func update_fun, + BASEMENTNODE bn, + const ft_msg& msg, + txn_gc_info* gc_info, + uint64_t* workdone, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta); -void toku_ft_leaf_apply_msg(const toku::comparator &cmp, ft_update_func update_fun, - FTNODE node, int target_childnum, - const ft_msg &msg, txn_gc_info *gc_info, - uint64_t *workdone, STAT64INFO stats_to_update); +void toku_ft_leaf_apply_msg( + const toku::comparator& cmp, + ft_update_func update_fun, + FTNODE node, + int target_childnum, + const ft_msg& msg, + txn_gc_info* gc_info, + uint64_t* workdone, + STAT64INFO stats_to_update, + int64_t* logical_rows_delta); // // Message management for orthopush diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc index a7bc2949276..49d4368a3ab 100644 --- a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc +++ b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc @@ -323,6 +323,13 @@ int deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ftp, uint32_t version) fanout = rbuf_int(rb); } + uint64_t on_disk_logical_rows; + on_disk_logical_rows = (uint64_t)-1; + if (ft->layout_version_read_from_disk >= FT_LAYOUT_VERSION_29) { + on_disk_logical_rows = rbuf_ulonglong(rb); + } + ft->in_memory_logical_rows = on_disk_logical_rows; + (void) rbuf_int(rb); //Read in checksum and ignore (already verified). if (rb->ndone != rb->size) { fprintf(stderr, "Header size did not match contents.\n"); @@ -357,7 +364,8 @@ int deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ftp, uint32_t version) .count_of_optimize_in_progress = count_of_optimize_in_progress, .count_of_optimize_in_progress_read_from_disk = count_of_optimize_in_progress, .msn_at_start_of_last_completed_optimize = msn_at_start_of_last_completed_optimize, - .on_disk_stats = on_disk_stats + .on_disk_stats = on_disk_stats, + .on_disk_logical_rows = on_disk_logical_rows }; XMEMDUP(ft->h, &h); } @@ -408,6 +416,8 @@ serialize_ft_min_size (uint32_t version) { size_t size = 0; switch(version) { + case FT_LAYOUT_VERSION_29: + size += sizeof(uint64_t); // logrows in ft case FT_LAYOUT_VERSION_28: size += sizeof(uint32_t); // fanout in ft case FT_LAYOUT_VERSION_27: @@ -754,6 +764,7 @@ void toku_serialize_ft_to_wbuf ( wbuf_MSN(wbuf, h->highest_unused_msn_for_upgrade); wbuf_MSN(wbuf, h->max_msn_in_ft); wbuf_int(wbuf, h->fanout); + wbuf_ulonglong(wbuf, h->on_disk_logical_rows); uint32_t checksum = toku_x1764_finish(&wbuf->checksum); wbuf_int(wbuf, checksum); lazy_assert(wbuf->ndone == wbuf->size); diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft_layout_version.h b/storage/tokudb/PerconaFT/ft/serialize/ft_layout_version.h index 72b6882bc06..9407a568337 100644 --- a/storage/tokudb/PerconaFT/ft/serialize/ft_layout_version.h +++ b/storage/tokudb/PerconaFT/ft/serialize/ft_layout_version.h @@ -68,6 +68,7 @@ enum ft_layout_version_e { FT_LAYOUT_VERSION_26 = 26, // Hojo: basements store key/vals separately on disk for fixed klpair length BNs FT_LAYOUT_VERSION_27 = 27, // serialize message trees with nonleaf buffers to avoid key, msn sort on deserialize FT_LAYOUT_VERSION_28 = 28, // Add fanout to ft_header + FT_LAYOUT_VERSION_29 = 29, // Add logrows to ft_header FT_NEXT_VERSION, // the version after the current version FT_LAYOUT_VERSION = FT_NEXT_VERSION-1, // A hack so I don't have to change this line. FT_LAYOUT_MIN_SUPPORTED_VERSION = FT_LAYOUT_VERSION_13, // Minimum version supported diff --git a/storage/tokudb/PerconaFT/ft/tests/CMakeLists.txt b/storage/tokudb/PerconaFT/ft/tests/CMakeLists.txt index 0098b6091be..270ec97660a 100644 --- a/storage/tokudb/PerconaFT/ft/tests/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/ft/tests/CMakeLists.txt @@ -112,11 +112,13 @@ if(BUILD_TESTING OR BUILD_FT_TESTS) declare_custom_tests(test-upgrade-recovery-logs) file(GLOB upgrade_tests "${TOKUDB_DATA}/upgrade-recovery-logs-??-clean") + file(GLOB upgrade_tests "${CMAKE_CURRENT_SOURCE_DIR}/upgrade.data/upgrade-recovery-logs-??-clean") foreach(test ${upgrade_tests}) get_filename_component(test_basename "${test}" NAME) add_ft_test_aux(test-${test_basename} test-upgrade-recovery-logs ${test}) endforeach(test) file(GLOB upgrade_tests "${TOKUDB_DATA}/upgrade-recovery-logs-??-dirty") + file(GLOB upgrade_tests "${CMAKE_CURRENT_SOURCE_DIR}/upgrade.data/upgrade-recovery-logs-??-dirty") foreach(test ${upgrade_tests}) get_filename_component(test_basename "${test}" NAME) add_ft_test_aux(test-${test_basename} test-upgrade-recovery-logs ${test}) diff --git a/storage/tokudb/PerconaFT/ft/tests/make-tree.cc b/storage/tokudb/PerconaFT/ft/tests/make-tree.cc index 663bbf3beb2..761d672539b 100644 --- a/storage/tokudb/PerconaFT/ft/tests/make-tree.cc +++ b/storage/tokudb/PerconaFT/ft/tests/make-tree.cc @@ -74,11 +74,20 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) // apply an insert to the leaf node txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); - toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); leafnode->max_msn_applied_to_node_on_disk = msn; - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/msnfilter.cc b/storage/tokudb/PerconaFT/ft/tests/msnfilter.cc index 737c3556ad6..c37dcd089f8 100644 --- a/storage/tokudb/PerconaFT/ft/tests/msnfilter.cc +++ b/storage/tokudb/PerconaFT/ft/tests/msnfilter.cc @@ -82,49 +82,85 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg, &gc_info, nullptr, nullptr); + toku_ft_leaf_apply_msg( + ft->ft->cmp, + ft->ft->update_fun, + leafnode, + -1, + msg, + &gc_info, + nullptr, + nullptr, + nullptr); { - int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair); - assert(r==0); - assert(pair.call_count==1); + int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair); + assert(r==0); + assert(pair.call_count==1); } ft_msg badmsg(&thekey, &badval, FT_INSERT, msn, toku_xids_get_root_xids()); - toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, badmsg, &gc_info, nullptr, nullptr); + toku_ft_leaf_apply_msg( + ft->ft->cmp, + ft->ft->update_fun, + leafnode, + -1, + badmsg, + &gc_info, + nullptr, + nullptr, + nullptr); // message should be rejected for duplicate msn, row should still have original val { - int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair); - assert(r==0); - assert(pair.call_count==2); + int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair); + assert(r==0); + assert(pair.call_count==2); } // now verify that message with proper msn gets through msn = next_dummymsn(); ft->ft->h->max_msn_in_ft = msn; ft_msg msg2(&thekey, &val2, FT_INSERT, msn, toku_xids_get_root_xids()); - toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg2, &gc_info, nullptr, nullptr); + toku_ft_leaf_apply_msg( + ft->ft->cmp, + ft->ft->update_fun, + leafnode, + -1, + msg2, + &gc_info, + nullptr, + nullptr, + nullptr); // message should be accepted, val should have new value { - int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair2); - assert(r==0); - assert(pair2.call_count==1); + int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair2); + assert(r==0); + assert(pair2.call_count==1); } // now verify that message with lesser (older) msn is rejected msn.msn = msn.msn - 10; ft_msg msg3(&thekey, &badval, FT_INSERT, msn, toku_xids_get_root_xids()); - toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg3, &gc_info, nullptr, nullptr); + toku_ft_leaf_apply_msg( + ft->ft->cmp, + ft->ft->update_fun, + leafnode, + -1, + msg3, + &gc_info, + nullptr, + nullptr, + nullptr); // message should be rejected, val should still have value in pair2 { - int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair2); - assert(r==0); - assert(pair2.call_count==2); + int r = toku_ft_lookup(ft, &thekey, lookup_checkf, &pair2); + assert(r==0); + assert(pair2.call_count==2); } - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/orthopush-flush.cc b/storage/tokudb/PerconaFT/ft/tests/orthopush-flush.cc index 055a38e5f6d..393fb88ac2e 100644 --- a/storage/tokudb/PerconaFT/ft/tests/orthopush-flush.cc +++ b/storage/tokudb/PerconaFT/ft/tests/orthopush-flush.cc @@ -137,8 +137,24 @@ insert_random_message_to_bn( *keyp = toku_xmemdup(keydbt->data, keydbt->size); ft_msg msg(keydbt, valdbt, FT_INSERT, msn, xids); int64_t numbytes; - toku_le_apply_msg(msg, NULL, NULL, 0, keydbt->size, &non_mvcc_gc_info, save, &numbytes); - toku_ft_bn_apply_msg(t->ft->cmp, t->ft->update_fun, blb, msg, &non_mvcc_gc_info, NULL, NULL); + toku_le_apply_msg( + msg, + NULL, + NULL, + 0, + keydbt->size, + &non_mvcc_gc_info, + save, + &numbytes); + toku_ft_bn_apply_msg( + t->ft->cmp, + t->ft->update_fun, + blb, + msg, + &non_mvcc_gc_info, + NULL, + NULL, + NULL); if (msn.msn > blb->max_msn_applied.msn) { blb->max_msn_applied = msn; } @@ -182,12 +198,36 @@ insert_same_message_to_bns( *keyp = toku_xmemdup(keydbt->data, keydbt->size); ft_msg msg(keydbt, valdbt, FT_INSERT, msn, xids); int64_t numbytes; - toku_le_apply_msg(msg, NULL, NULL, 0, keydbt->size, &non_mvcc_gc_info, save, &numbytes); - toku_ft_bn_apply_msg(t->ft->cmp, t->ft->update_fun, blb1, msg, &non_mvcc_gc_info, NULL, NULL); + toku_le_apply_msg( + msg, + NULL, + NULL, + 0, + keydbt->size, + &non_mvcc_gc_info, + save, + &numbytes); + toku_ft_bn_apply_msg( + t->ft->cmp, + t->ft->update_fun, + blb1, + msg, + &non_mvcc_gc_info, + NULL, + NULL, + NULL); if (msn.msn > blb1->max_msn_applied.msn) { blb1->max_msn_applied = msn; } - toku_ft_bn_apply_msg(t->ft->cmp, t->ft->update_fun, blb2, msg, &non_mvcc_gc_info, NULL, NULL); + toku_ft_bn_apply_msg( + t->ft->cmp, + t->ft->update_fun, + blb2, + msg, + &non_mvcc_gc_info, + NULL, + NULL, + NULL); if (msn.msn > blb2->max_msn_applied.msn) { blb2->max_msn_applied = msn; } @@ -619,7 +659,16 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) { if (make_leaf_up_to_date) { for (i = 0; i < num_parent_messages; ++i) { if (!parent_messages_is_fresh[i]) { - toku_ft_leaf_apply_msg(t->ft->cmp, t->ft->update_fun, child, -1, *parent_messages[i], &non_mvcc_gc_info, NULL, NULL); + toku_ft_leaf_apply_msg( + t->ft->cmp, + t->ft->update_fun, + child, + -1, + *parent_messages[i], + &non_mvcc_gc_info, + NULL, + NULL, + NULL); } } for (i = 0; i < 8; ++i) { @@ -842,7 +891,16 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) { for (i = 0; i < num_parent_messages; ++i) { if (dummy_cmp(parent_messages[i]->kdbt(), &childkeys[7]) <= 0 && !parent_messages_is_fresh[i]) { - toku_ft_leaf_apply_msg(t->ft->cmp, t->ft->update_fun, child, -1, *parent_messages[i], &non_mvcc_gc_info, NULL, NULL); + toku_ft_leaf_apply_msg( + t->ft->cmp, + t->ft->update_fun, + child, + -1, + *parent_messages[i], + &non_mvcc_gc_info, + NULL, + NULL, + NULL); } } for (i = 0; i < 8; ++i) { @@ -1045,8 +1103,26 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) { if (make_leaf_up_to_date) { for (i = 0; i < num_parent_messages; ++i) { if (!parent_messages_is_fresh[i]) { - toku_ft_leaf_apply_msg(t->ft->cmp, t->ft->update_fun, child1, -1, *parent_messages[i], &non_mvcc_gc_info, NULL, NULL); - toku_ft_leaf_apply_msg(t->ft->cmp, t->ft->update_fun, child2, -1, *parent_messages[i], &non_mvcc_gc_info, NULL, NULL); + toku_ft_leaf_apply_msg( + t->ft->cmp, + t->ft->update_fun, + child1, + -1, + *parent_messages[i], + &non_mvcc_gc_info, + NULL, + NULL, + NULL); + toku_ft_leaf_apply_msg( + t->ft->cmp, + t->ft->update_fun, + child2, + -1, + *parent_messages[i], + &non_mvcc_gc_info, + NULL, + NULL, + NULL); } } for (i = 0; i < 8; ++i) { diff --git a/storage/tokudb/PerconaFT/ft/tests/test-upgrade-recovery-logs.cc b/storage/tokudb/PerconaFT/ft/tests/test-upgrade-recovery-logs.cc index 8e006498d77..7691ffaac2b 100644 --- a/storage/tokudb/PerconaFT/ft/tests/test-upgrade-recovery-logs.cc +++ b/storage/tokudb/PerconaFT/ft/tests/test-upgrade-recovery-logs.cc @@ -81,7 +81,7 @@ static void run_recovery(const char *testdir) { bool upgrade_in_progress; r = toku_maybe_upgrade_log(testdir, testdir, &lsn_of_clean_shutdown, &upgrade_in_progress); if (strcmp(shutdown, "dirty") == 0 && log_version <= 24) { - CKERR2(r, TOKUDB_UPGRADE_FAILURE); // we dont support dirty upgrade from versions <= 24 + CKERR2(r, TOKUDB_UPGRADE_FAILURE); // we don't support dirty upgrade from versions <= 24 return; } else { CKERR(r); diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-24-clean/log000000000000.tokulog24 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-24-clean/log000000000000.tokulog24 new file mode 100755 index 00000000000..9a56e83e627 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-24-clean/log000000000000.tokulog24 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-24-dirty/log000000000000.tokulog24 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-24-dirty/log000000000000.tokulog24 new file mode 100755 index 00000000000..c552cda6673 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-24-dirty/log000000000000.tokulog24 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-25-clean/log000000000000.tokulog25 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-25-clean/log000000000000.tokulog25 new file mode 100755 index 00000000000..26b8bcfbdcc Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-25-clean/log000000000000.tokulog25 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-25-dirty/log000000000000.tokulog25 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-25-dirty/log000000000000.tokulog25 new file mode 100755 index 00000000000..04d3190c818 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-25-dirty/log000000000000.tokulog25 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-26-clean/log000000000000.tokulog26 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-26-clean/log000000000000.tokulog26 new file mode 100755 index 00000000000..02047325aa6 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-26-clean/log000000000000.tokulog26 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-26-dirty/log000000000000.tokulog26 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-26-dirty/log000000000000.tokulog26 new file mode 100755 index 00000000000..ce826b5608b Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-26-dirty/log000000000000.tokulog26 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-27-clean/log000000000000.tokulog27 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-27-clean/log000000000000.tokulog27 new file mode 100755 index 00000000000..9849b977d73 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-27-clean/log000000000000.tokulog27 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-27-dirty/log000000000000.tokulog27 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-27-dirty/log000000000000.tokulog27 new file mode 100755 index 00000000000..8b658ea4c0a Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-27-dirty/log000000000000.tokulog27 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-28-clean/log000000000000.tokulog28 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-28-clean/log000000000000.tokulog28 new file mode 100644 index 00000000000..11fecfb94b2 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-28-clean/log000000000000.tokulog28 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-28-dirty/log000000000000.tokulog28 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-28-dirty/log000000000000.tokulog28 new file mode 100644 index 00000000000..b7a9b03b583 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-28-dirty/log000000000000.tokulog28 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-29-clean/log000000000000.tokulog29 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-29-clean/log000000000000.tokulog29 new file mode 100644 index 00000000000..a1f306f4a96 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-29-clean/log000000000000.tokulog29 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-29-dirty/log000000000000.tokulog29 b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-29-dirty/log000000000000.tokulog29 new file mode 100644 index 00000000000..b9e79eeb1c4 Binary files /dev/null and b/storage/tokudb/PerconaFT/ft/tests/upgrade.data/upgrade-recovery-logs-29-dirty/log000000000000.tokulog29 differ diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-bad-msn.cc b/storage/tokudb/PerconaFT/ft/tests/verify-bad-msn.cc index 68fac0e6a9c..b10885c2e62 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-bad-msn.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-bad-msn.cc @@ -78,12 +78,21 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) // apply an insert to the leaf node ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); // Create bad tree (don't do following): // leafnode->max_msn_applied_to_node = msn; - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-bad-pivots.cc b/storage/tokudb/PerconaFT/ft/tests/verify-bad-pivots.cc index 49b2b8a6c21..c1d08ce41a6 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-bad-pivots.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-bad-pivots.cc @@ -65,9 +65,18 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) MSN msn = next_dummymsn(); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-dup-in-leaf.cc b/storage/tokudb/PerconaFT/ft/tests/verify-dup-in-leaf.cc index 72c4063f51f..22a29c0ff69 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-dup-in-leaf.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-dup-in-leaf.cc @@ -66,9 +66,18 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) MSN msn = next_dummymsn(); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-dup-pivots.cc b/storage/tokudb/PerconaFT/ft/tests/verify-dup-pivots.cc index f569f502dc8..80189dd9804 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-dup-pivots.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-dup-pivots.cc @@ -65,9 +65,18 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) MSN msn = next_dummymsn(); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-misrouted-msgs.cc b/storage/tokudb/PerconaFT/ft/tests/verify-misrouted-msgs.cc index 3a6db8ee4de..a84aac1f063 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-misrouted-msgs.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-misrouted-msgs.cc @@ -66,9 +66,18 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) MSN msn = next_dummymsn(); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-leaf.cc b/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-leaf.cc index 4392887718f..ca413f52567 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-leaf.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-leaf.cc @@ -68,9 +68,18 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) MSN msn = next_dummymsn(); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-pivots.cc b/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-pivots.cc index e3167bd3dc1..6efa06913c2 100644 --- a/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-pivots.cc +++ b/storage/tokudb/PerconaFT/ft/tests/verify-unsorted-pivots.cc @@ -65,9 +65,18 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) MSN msn = next_dummymsn(); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids()); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); - toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); + toku_ft_bn_apply_msg_once( + BLB(leafnode, 0), + msg, + idx, + keylen, + NULL, + &gc_info, + NULL, + NULL, + NULL); - // dont forget to dirty the node + // don't forget to dirty the node leafnode->dirty = 1; } diff --git a/storage/tokudb/PerconaFT/ft/txn/rollback-apply.cc b/storage/tokudb/PerconaFT/ft/txn/rollback-apply.cc index 6a8c0d45b45..df830afd0df 100644 --- a/storage/tokudb/PerconaFT/ft/txn/rollback-apply.cc +++ b/storage/tokudb/PerconaFT/ft/txn/rollback-apply.cc @@ -186,6 +186,7 @@ int toku_rollback_commit(TOKUTXN txn, LSN lsn) { // Append the list to the front of the parent. if (child_log->oldest_logentry) { // There are some entries, so link them in. + parent_log->dirty = true; child_log->oldest_logentry->prev = parent_log->newest_logentry; if (!parent_log->oldest_logentry) { parent_log->oldest_logentry = child_log->oldest_logentry; diff --git a/storage/tokudb/PerconaFT/ft/txn/txn.cc b/storage/tokudb/PerconaFT/ft/txn/txn.cc index cd0585dbf6c..dd03073a3ec 100644 --- a/storage/tokudb/PerconaFT/ft/txn/txn.cc +++ b/storage/tokudb/PerconaFT/ft/txn/txn.cc @@ -248,11 +248,24 @@ static txn_child_manager tcm; .xa_xid = {0, 0, 0, ""}, .progress_poll_fun = NULL, .progress_poll_fun_extra = NULL, - .txn_lock = ZERO_MUTEX_INITIALIZER, + + // You cannot initialize txn_lock a TOKU_MUTEX_INITIALIZER, because we + // will initialize it in the code below, and it cannot already + // be initialized at that point. Also, in general, you don't + // get to use PTHREAD_MUTEX_INITALIZER (which is what is inside + // TOKU_MUTEX_INITIALIZER) except in static variables, and this + // is initializing an auto variable. + // + // And we cannot simply avoid initializing these fields + // because, although it avoids -Wmissing-field-initializer + // errors under gcc, it gets other errors about non-trivial + // designated initializers not being supported. + + .txn_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER .open_fts = open_fts, .roll_info = roll_info, - .state_lock = ZERO_MUTEX_INITIALIZER, - .state_cond = TOKU_COND_INITIALIZER, + .state_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER + .state_cond = ZERO_COND_INITIALIZER, // Not TOKU_COND_INITIALIZER .state = TOKUTXN_LIVE, .num_pin = 0, .client_id = 0, diff --git a/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc b/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc index 551fd32b8d5..88eca36a261 100644 --- a/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc +++ b/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc @@ -45,7 +45,15 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #include "ft/txn/txn_manager.h" #include "ft/txn/rollback.h" #include "util/omt.h" +//this is only for testing +static void (* test_txn_sync_callback) (pthread_t, void *) = NULL; +static void * test_txn_sync_callback_extra = NULL; + +void set_test_txn_sync_callback(void (*cb) (pthread_t, void *), void *extra) { + test_txn_sync_callback = cb; + test_txn_sync_callback_extra = extra; +} bool garbage_collection_debug = false; static bool txn_records_snapshot(TXN_SNAPSHOT_TYPE snapshot_type, struct tokutxn *parent) { @@ -525,14 +533,19 @@ void toku_txn_manager_handle_snapshot_create_for_child_txn( XMALLOC(txn->live_root_txn_list); txn_manager_lock(txn_manager); txn_manager_create_snapshot_unlocked(txn_manager, txn); - txn_manager_unlock(txn_manager); } else { inherit_snapshot_from_parent(txn); } - if (copies_snapshot) { - setup_live_root_txn_list(&txn_manager->live_root_ids, txn->live_root_txn_list); - } + + toku_debug_txn_sync(pthread_self()); + + if (copies_snapshot) { + if(!records_snapshot) + txn_manager_lock(txn_manager); + setup_live_root_txn_list(&txn_manager->live_root_ids, txn->live_root_txn_list); + txn_manager_unlock(txn_manager); + } } void toku_txn_manager_handle_snapshot_destroy_for_child_txn( diff --git a/storage/tokudb/PerconaFT/ft/txn/txn_manager.h b/storage/tokudb/PerconaFT/ft/txn/txn_manager.h index 658c6f9aecd..7cdc52c4f43 100644 --- a/storage/tokudb/PerconaFT/ft/txn/txn_manager.h +++ b/storage/tokudb/PerconaFT/ft/txn/txn_manager.h @@ -43,6 +43,15 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #include "ft/txn/txn.h" +void set_test_txn_sync_callback(void (*) (pthread_t, void*), void*); +#define toku_test_txn_sync_callback(a) ((test_txn_sync_callback)? test_txn_sync_callback( a,test_txn_sync_callback_extra) : (void) 0) + +#if TOKU_DEBUG_TXN_SYNC +#define toku_debug_txn_sync(a) toku_test_txn_sync_callback(a) +#else +#define toku_debug_txn_sync(a) ((void) 0) +#endif + typedef struct txn_manager *TXN_MANAGER; struct referenced_xid_tuple { diff --git a/storage/tokudb/PerconaFT/ft/ule.cc b/storage/tokudb/PerconaFT/ft/ule.cc index 573c4488f70..ac393fbf179 100644 --- a/storage/tokudb/PerconaFT/ft/ule.cc +++ b/storage/tokudb/PerconaFT/ft/ule.cc @@ -73,12 +73,11 @@ void toku_le_get_status(LE_STATUS statp) { *statp = le_status; } -/////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Accessor functions used by outside world (e.g. indexer) // -ULEHANDLE -toku_ule_create(LEAFENTRY le) { +ULEHANDLE toku_ule_create(LEAFENTRY le) { ULE XMALLOC(ule_p); le_unpack(ule_p, le); return (ULEHANDLE) ule_p; @@ -89,7 +88,7 @@ void toku_ule_free(ULEHANDLE ule_p) { toku_free(ule_p); } -/////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // // Question: Can any software outside this file modify or read a leafentry? // If so, is it worthwhile to put it all here? @@ -117,27 +116,43 @@ const UXR_S committed_delete = { // Local functions: -static void msg_init_empty_ule(ULE ule); -static void msg_modify_ule(ULE ule, const ft_msg &msg); -static void ule_init_empty_ule(ULE ule); +static inline void msg_init_empty_ule(ULE ule); +static int64_t msg_modify_ule(ULE ule, const ft_msg &msg); +static inline void ule_init_empty_ule(ULE ule); static void ule_do_implicit_promotions(ULE ule, XIDS xids); -static void ule_try_promote_provisional_outermost(ULE ule, TXNID oldest_possible_live_xid); +static void ule_try_promote_provisional_outermost( + ULE ule, + TXNID oldest_possible_live_xid); static void ule_promote_provisional_innermost_to_index(ULE ule, uint32_t index); static void ule_promote_provisional_innermost_to_committed(ULE ule); -static void ule_apply_insert(ULE ule, XIDS xids, uint32_t vallen, void * valp); -static void ule_apply_delete(ULE ule, XIDS xids); -static void ule_prepare_for_new_uxr(ULE ule, XIDS xids); -static void ule_apply_abort(ULE ule, XIDS xids); +static inline int64_t ule_apply_insert_no_overwrite( + ULE ule, + XIDS xids, + uint32_t vallen, + void* valp); +static inline int64_t ule_apply_insert( + ULE ule, + XIDS xids, + uint32_t vallen, + void* valp); +static inline int64_t ule_apply_delete(ULE ule, XIDS xids); +static inline void ule_prepare_for_new_uxr(ULE ule, XIDS xids); +static inline int64_t ule_apply_abort(ULE ule, XIDS xids); static void ule_apply_broadcast_commit_all (ULE ule); static void ule_apply_commit(ULE ule, XIDS xids); -static void ule_push_insert_uxr(ULE ule, bool is_committed, TXNID xid, uint32_t vallen, void * valp); -static void ule_push_delete_uxr(ULE ule, bool is_committed, TXNID xid); -static void ule_push_placeholder_uxr(ULE ule, TXNID xid); -static UXR ule_get_innermost_uxr(ULE ule); -static UXR ule_get_first_empty_uxr(ULE ule); -static void ule_remove_innermost_uxr(ULE ule); -static TXNID ule_get_innermost_xid(ULE ule); -static TXNID ule_get_xid(ULE ule, uint32_t index); +static inline void ule_push_insert_uxr( + ULE ule, + bool is_committed, + TXNID xid, + uint32_t vallen, + void* valp); +static inline void ule_push_delete_uxr(ULE ule, bool is_committed, TXNID xid); +static inline void ule_push_placeholder_uxr(ULE ule, TXNID xid); +static inline UXR ule_get_innermost_uxr(ULE ule); +static inline UXR ule_get_first_empty_uxr(ULE ule); +static inline void ule_remove_innermost_uxr(ULE ule); +static inline TXNID ule_get_innermost_xid(ULE ule); +static inline TXNID ule_get_xid(ULE ule, uint32_t index); static void ule_remove_innermost_placeholders(ULE ule); static void ule_add_placeholders(ULE ule, XIDS xids); static void ule_optimize(ULE ule, XIDS xids); @@ -153,6 +168,30 @@ static inline size_t uxr_unpack_type_and_length(UXR uxr, uint8_t *p); static inline size_t uxr_unpack_length_and_bit(UXR uxr, uint8_t *p); static inline size_t uxr_unpack_data(UXR uxr, uint8_t *p); +#if 0 +static void ule_print(ULE ule, const char* note) { + fprintf(stderr, "%s : ULE[0x%p]\n", note, ule); + fprintf(stderr, " num_puxrs[%u]\n", ule->num_puxrs); + fprintf(stderr, " num_cuxrs[%u]\n", ule->num_cuxrs); + fprintf(stderr, " innermost[%u]\n", ule->num_cuxrs + ule->num_puxrs - 1); + fprintf(stderr, " first_empty[%u]\n", ule->num_cuxrs + ule->num_puxrs); + + uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs - 1; + for (uint32_t uxr_num = 0; uxr_num <= num_uxrs; uxr_num++) { + UXR uxr = &(ule->uxrs[uxr_num]); + fprintf(stderr, " uxr[%u]\n", uxr_num); + switch (uxr->type) { + case 0: fprintf(stderr, " type[NONE]\n"); break; + case 1: fprintf(stderr, " type[INSERT]\n"); break; + case 2: fprintf(stderr, " type[DELETE]\n"); break; + case 3: fprintf(stderr, " type[PLACEHOLDER]\n"); break; + default: fprintf(stderr, " type[WHAT??]\n"); break; + } + fprintf(stderr, " xid[%lu]\n", uxr->xid); + } +} +#endif + static void get_space_for_le( bn_data* data_buffer, uint32_t idx, @@ -162,21 +201,30 @@ static void get_space_for_le( uint32_t old_le_size, size_t size, LEAFENTRY* new_le_space, - void **const maybe_free - ) -{ + void** const maybe_free) { + if (data_buffer == nullptr) { CAST_FROM_VOIDP(*new_le_space, toku_xmalloc(size)); - } - else { + } else if (old_le_size > 0) { // this means we are overwriting something - if (old_le_size > 0) { - data_buffer->get_space_for_overwrite(idx, keyp, keylen, old_keylen, old_le_size, size, new_le_space, maybe_free); - } + data_buffer->get_space_for_overwrite( + idx, + keyp, + keylen, + old_keylen, + old_le_size, + size, + new_le_space, + maybe_free); + } else { // this means we are inserting something new - else { - data_buffer->get_space_for_insert(idx, keyp, keylen, size, new_le_space, maybe_free); - } + data_buffer->get_space_for_insert( + idx, + keyp, + keylen, + size, + new_le_space, + maybe_free); } } @@ -185,15 +233,13 @@ static void get_space_for_le( // Garbage collection related functions // -static TXNID -get_next_older_txnid(TXNID xc, const xid_omt_t &omt) { +static TXNID get_next_older_txnid(TXNID xc, const xid_omt_t &omt) { int r; TXNID xid; r = omt.find(xc, -1, &xid, nullptr); if (r==0) { invariant(xid < xc); //sanity check - } - else { + } else { invariant(r==DB_NOTFOUND); xid = TXNID_NONE; } @@ -201,17 +247,32 @@ get_next_older_txnid(TXNID xc, const xid_omt_t &omt) { } // -// This function returns true if live transaction TL1 is allowed to read a value committed by -// transaction xc, false otherwise. +// This function returns true if live transaction TL1 is allowed to read a +// value committed by transaction xc, false otherwise. // -static bool -xid_reads_committed_xid(TXNID tl1, TXNID xc, const xid_omt_t &snapshot_txnids, const rx_omt_t &referenced_xids) { +static bool xid_reads_committed_xid( + TXNID tl1, + TXNID xc, + const xid_omt_t& snapshot_txnids, + const rx_omt_t& referenced_xids) { + bool rval; - if (tl1 < xc) rval = false; //cannot read a newer txn - else { - TXNID x = toku_get_youngest_live_list_txnid_for(xc, snapshot_txnids, referenced_xids); - if (x == TXNID_NONE) rval = true; //Not in ANY live list, tl1 can read it. - else rval = tl1 > x; //Newer than the 'newest one that has it in live list' + if (tl1 < xc) { + rval = false; //cannot read a newer txn + } else { + TXNID x = + toku_get_youngest_live_list_txnid_for( + xc, + snapshot_txnids, + referenced_xids); + + if (x == TXNID_NONE) { + //Not in ANY live list, tl1 can read it. + rval = true; + } else { + //Newer than the 'newest one that has it in live list' + rval = tl1 > x; + } // we know tl1 > xc // we know x > xc // if tl1 == x, then we do not read, because tl1 is in xc's live list @@ -228,8 +289,7 @@ xid_reads_committed_xid(TXNID tl1, TXNID xc, const xid_omt_t &snapshot_txnids, c // than oldest_referenced_xid. All elements below this entry are garbage, // so we get rid of them. // -static void -ule_simple_garbage_collection(ULE ule, txn_gc_info *gc_info) { +static void ule_simple_garbage_collection(ULE ule, txn_gc_info *gc_info) { if (ule->num_cuxrs == 1) { return; } @@ -240,7 +300,8 @@ ule_simple_garbage_collection(ULE ule, txn_gc_info *gc_info) { // uxr with a txnid that is less than oldest_referenced_xid for (uint32_t i = 0; i < ule->num_cuxrs; i++) { curr_index = ule->num_cuxrs - i - 1; - if (ule->uxrs[curr_index].xid < gc_info->oldest_referenced_xid_for_simple_gc) { + if (ule->uxrs[curr_index].xid < + gc_info->oldest_referenced_xid_for_simple_gc) { break; } } @@ -250,12 +311,15 @@ ule_simple_garbage_collection(ULE ule, txn_gc_info *gc_info) { curr_index = ule->num_cuxrs - 1; } - // curr_index is now set to the youngest uxr older than oldest_referenced_xid - // so if it's not the bottom of the stack.. + // curr_index is now set to the youngest uxr older than + // oldest_referenced_xid so if it's not the bottom of the stack.. if (curr_index != 0) { // ..then we need to get rid of the entries below curr_index uint32_t num_entries = ule->num_cuxrs + ule->num_puxrs - curr_index; - memmove(&ule->uxrs[0], &ule->uxrs[curr_index], num_entries * sizeof(ule->uxrs[0])); + memmove( + &ule->uxrs[0], + &ule->uxrs[curr_index], + num_entries * sizeof(ule->uxrs[0])); ule->uxrs[0].xid = TXNID_NONE; // New 'bottom of stack' loses its TXNID ule->num_cuxrs -= curr_index; } @@ -264,8 +328,12 @@ ule_simple_garbage_collection(ULE ule, txn_gc_info *gc_info) { // TODO: Clean this up extern bool garbage_collection_debug; -static void -ule_garbage_collect(ULE ule, const xid_omt_t &snapshot_xids, const rx_omt_t &referenced_xids, const xid_omt_t &live_root_txns) { +static void ule_garbage_collect( + ULE ule, + const xid_omt_t& snapshot_xids, + const rx_omt_t& referenced_xids, + const xid_omt_t& live_root_txns) { + if (ule->num_cuxrs == 1) { return; } @@ -289,10 +357,12 @@ ule_garbage_collect(ULE ule, const xid_omt_t &snapshot_xids, const rx_omt_t &ref // If we find that the committed transaction is in the live list, // then xc is really in the process of being committed. It has not // been fully committed. As a result, our assumption that transactions - // newer than what is currently in these OMTs will read the top of the stack - // is not necessarily accurate. Transactions may read what is just below xc. - // As a result, we must mark what is just below xc as necessary and move on. - // This issue was found while testing flusher threads, and was fixed for #3979 + // newer than what is currently in these OMTs will read the top of the + // stack is not necessarily accurate. Transactions may read what is + // just below xc. + // As a result, we must mark what is just below xc as necessary and + // move on. This issue was found while testing flusher threads, and was + // fixed for #3979 // bool is_xc_live = toku_is_txn_in_live_root_txn_list(live_root_txns, xc); if (is_xc_live) { @@ -300,13 +370,19 @@ ule_garbage_collect(ULE ule, const xid_omt_t &snapshot_xids, const rx_omt_t &ref continue; } - tl1 = toku_get_youngest_live_list_txnid_for(xc, snapshot_xids, referenced_xids); + tl1 = + toku_get_youngest_live_list_txnid_for( + xc, + snapshot_xids, + referenced_xids); - // if tl1 == xc, that means xc should be live and show up in live_root_txns, which we check above. + // if tl1 == xc, that means xc should be live and show up in + // live_root_txns, which we check above. invariant(tl1 != xc); if (tl1 == TXNID_NONE) { - // set tl1 to youngest live transaction older than ule->uxrs[curr_committed_entry]->xid + // set tl1 to youngest live transaction older than + // ule->uxrs[curr_committed_entry]->xid tl1 = get_next_older_txnid(xc, snapshot_xids); if (tl1 == TXNID_NONE) { // remainder is garbage, we're done @@ -314,8 +390,13 @@ ule_garbage_collect(ULE ule, const xid_omt_t &snapshot_xids, const rx_omt_t &ref } } if (garbage_collection_debug) { - int r = snapshot_xids.find_zero(tl1, nullptr, nullptr); - invariant_zero(r); // make sure that the txn you are claiming is live is actually live + int r = + snapshot_xids.find_zero( + tl1, + nullptr, + nullptr); + // make sure that the txn you are claiming is live is actually live + invariant_zero(r); } // // tl1 should now be set @@ -323,7 +404,11 @@ ule_garbage_collect(ULE ule, const xid_omt_t &snapshot_xids, const rx_omt_t &ref curr_committed_entry--; while (curr_committed_entry > 0) { xc = ule->uxrs[curr_committed_entry].xid; - if (xid_reads_committed_xid(tl1, xc, snapshot_xids, referenced_xids)) { + if (xid_reads_committed_xid( + tl1, + xc, + snapshot_xids, + referenced_xids)) { break; } curr_committed_entry--; @@ -343,7 +428,10 @@ ule_garbage_collect(ULE ule, const xid_omt_t &snapshot_xids, const rx_omt_t &ref ule->uxrs[0].xid = TXNID_NONE; //New 'bottom of stack' loses its TXNID if (first_free != ule->num_cuxrs) { // Shift provisional values - memmove(&ule->uxrs[first_free], &ule->uxrs[ule->num_cuxrs], ule->num_puxrs * sizeof(ule->uxrs[0])); + memmove( + &ule->uxrs[first_free], + &ule->uxrs[ule->num_cuxrs], + ule->num_puxrs * sizeof(ule->uxrs[0])); } ule->num_cuxrs = saved; } @@ -367,29 +455,42 @@ enum { ULE_MIN_MEMSIZE_TO_FORCE_GC = 1024 * 1024 }; -///////////////////////////////////////////////////////////////////////////////// -// This is the big enchilada. (Bring Tums.) Note that this level of abstraction -// has no knowledge of the inner structure of either leafentry or msg. It makes -// calls into the next lower layer (msg_xxx) which handles messages. +//////////////////////////////////////////////////////////////////////////////// +// This is the big enchilada. (Bring Tums.) Note that this level of +// abstraction has no knowledge of the inner structure of either leafentry or +// msg. It makes calls into the next lower layer (msg_xxx) which handles +// messages. // // NOTE: This is the only function (at least in this body of code) that modifies // a leafentry. // NOTE: It is the responsibility of the caller to make sure that the key is set // in the FT_MSG, as it will be used to store the data in the data_buffer // -// Return 0 on success. -// If the leafentry is destroyed it sets *new_leafentry_p to NULL. -// Otehrwise the new_leafentry_p points at the new leaf entry. -// As of October 2011, this function always returns 0. -void -toku_le_apply_msg(const ft_msg &msg, - LEAFENTRY old_leafentry, // NULL if there was no stored data. - bn_data* data_buffer, // bn_data storing leafentry, if NULL, means there is no bn_data - uint32_t idx, // index in data_buffer where leafentry is stored (and should be replaced - uint32_t old_keylen, // length of the any key in data_buffer - txn_gc_info *gc_info, - LEAFENTRY *new_leafentry_p, - int64_t * numbytes_delta_p) { // change in total size of key and val, not including any overhead +// Returns -1, 0, or 1 that identifies the change in logical row count needed +// based on the results of the message application. For example, if a delete +// finds no logical leafentry or if an insert finds a duplicate and is +// converted to an update. +// +// old_leafentry - NULL if there was no stored data. +// data_buffer - bn_data storing leafentry, if NULL, means there is no bn_data +// idx - index in data_buffer where leafentry is stored +// (and should be replaced) +// old_keylen - length of the any key in data_buffer +// new_leafentry_p - If the leafentry is destroyed it sets *new_leafentry_p +// to NULL. Otherwise the new_leafentry_p points at the new +// leaf entry. +// numbytes_delta_p - change in total size of key and val, not including any +// overhead +int64_t toku_le_apply_msg( + const ft_msg& msg, + LEAFENTRY old_leafentry, + bn_data* data_buffer, + uint32_t idx, + uint32_t old_keylen, + txn_gc_info* gc_info, + LEAFENTRY* new_leafentry_p, + int64_t* numbytes_delta_p) { + invariant_notnull(gc_info); paranoid_invariant_notnull(new_leafentry_p); ULE_S ule; @@ -397,6 +498,7 @@ toku_le_apply_msg(const ft_msg &msg, int64_t newnumbytes = 0; uint64_t oldmemsize = 0; uint32_t keylen = msg.kdbt()->size; + int32_t rowcountdelta = 0; if (old_leafentry == NULL) { msg_init_empty_ule(&ule); @@ -405,49 +507,62 @@ toku_le_apply_msg(const ft_msg &msg, le_unpack(&ule, old_leafentry); // otherwise unpack leafentry oldnumbytes = ule_get_innermost_numbytes(&ule, keylen); } - msg_modify_ule(&ule, msg); // modify unpacked leafentry - // - we may be able to immediately promote the newly-apllied outermost provisonal uxr - // - either way, run simple gc first, and then full gc if there are still some committed uxrs. - ule_try_promote_provisional_outermost(&ule, gc_info->oldest_referenced_xid_for_implicit_promotion); + // modify unpacked leafentry + rowcountdelta = msg_modify_ule(&ule, msg); + + // - we may be able to immediately promote the newly-apllied outermost + // provisonal uxr + // - either way, run simple gc first, and then full gc if there are still + // some committed uxrs. + ule_try_promote_provisional_outermost( + &ule, + gc_info->oldest_referenced_xid_for_implicit_promotion); ule_simple_garbage_collection(&ule, gc_info); txn_manager_state *txn_state_for_gc = gc_info->txn_state_for_gc; size_t size_before_gc = 0; - if (ule.num_cuxrs > 1 && txn_state_for_gc != nullptr && // there is garbage to clean, and our caller gave us state.. - // ..and either the state is pre-initialized, or the committed stack is large enough - (txn_state_for_gc->initialized || ule.num_cuxrs >= ULE_MIN_STACK_SIZE_TO_FORCE_GC || - // ..or the ule's raw memsize is sufficiently large - (size_before_gc = ule_packed_memsize(&ule)) >= ULE_MIN_MEMSIZE_TO_FORCE_GC)) { - // ..then it's worth running gc, possibly initializing the txn manager state, if it isn't already + // there is garbage to clean, and our caller gave us state.. + // ..and either the state is pre-initialized, or the committed stack is + // large enough + // ..or the ule's raw memsize is sufficiently large + // ..then it's worth running gc, possibly initializing the txn manager + // state, if it isn't already + if (ule.num_cuxrs > 1 && txn_state_for_gc != nullptr && + (txn_state_for_gc->initialized || + ule.num_cuxrs >= ULE_MIN_STACK_SIZE_TO_FORCE_GC || + (size_before_gc = ule_packed_memsize(&ule)) >= + ULE_MIN_MEMSIZE_TO_FORCE_GC)) { if (!txn_state_for_gc->initialized) { txn_state_for_gc->init(); } - - size_before_gc = size_before_gc != 0 ? size_before_gc : // it's already been calculated above - ule_packed_memsize(&ule); - ule_garbage_collect(&ule, - txn_state_for_gc->snapshot_xids, - txn_state_for_gc->referenced_xids, - txn_state_for_gc->live_root_txns - ); + // it's already been calculated above + size_before_gc = + size_before_gc != 0 ? size_before_gc : ule_packed_memsize(&ule); + ule_garbage_collect( + &ule, + txn_state_for_gc->snapshot_xids, + txn_state_for_gc->referenced_xids, + txn_state_for_gc->live_root_txns); size_t size_after_gc = ule_packed_memsize(&ule); LE_STATUS_INC(LE_APPLY_GC_BYTES_IN, size_before_gc); LE_STATUS_INC(LE_APPLY_GC_BYTES_OUT, size_after_gc); } - void *maybe_free = nullptr; - int r = le_pack( - &ule, // create packed leafentry - data_buffer, - idx, - msg.kdbt()->data, // contract of this function is caller has this set, always - keylen, // contract of this function is caller has this set, always - old_keylen, - oldmemsize, - new_leafentry_p, - &maybe_free - ); + void* maybe_free = nullptr; + // create packed leafentry + // contract of this function is caller has keyp and keylen set, always + int r = + le_pack( + &ule, + data_buffer, + idx, + msg.kdbt()->data, + keylen, + old_keylen, + oldmemsize, + new_leafentry_p, + &maybe_free); invariant_zero(r); if (*new_leafentry_p) { newnumbytes = ule_get_innermost_numbytes(&ule, keylen); @@ -458,16 +573,22 @@ toku_le_apply_msg(const ft_msg &msg, if (maybe_free != nullptr) { toku_free(maybe_free); } + return rowcountdelta; } -bool toku_le_worth_running_garbage_collection(LEAFENTRY le, txn_gc_info *gc_info) { -// Effect: Quickly determines if it's worth trying to run garbage collection on a leafentry +bool toku_le_worth_running_garbage_collection( + LEAFENTRY le, + txn_gc_info* gc_info) { +// Effect: Quickly determines if it's worth trying to run garbage collection +// on a leafentry // Return: True if it makes sense to try garbage collection, false otherwise. // Rationale: Garbage collection is likely to clean up under two circumstances: -// 1.) There are multiple committed entries. Some may never be read by new txns. -// 2.) There is only one committed entry, but the outermost provisional entry -// is older than the oldest known referenced xid, so it must have commited. -// Therefor we can promote it to committed and get rid of the old commited entry. +// 1.) There are multiple committed entries. Some may never be read +// by new txns. +// 2.) There is only one committed entry, but the outermost +// provisional entry is older than the oldest known referenced +// xid, so it must have commited. Therefor we can promote it to +// committed and get rid of the old commited entry. if (le->type != LE_MVCC) { return false; } @@ -477,7 +598,8 @@ bool toku_le_worth_running_garbage_collection(LEAFENTRY le, txn_gc_info *gc_info paranoid_invariant(le->u.mvcc.num_cxrs == 1); } return le->u.mvcc.num_pxrs > 0 && - le_outermost_uncommitted_xid(le) < gc_info->oldest_referenced_xid_for_implicit_promotion; + le_outermost_uncommitted_xid(le) < + gc_info->oldest_referenced_xid_for_implicit_promotion; } // Garbage collect one leaf entry, using the given OMT's. @@ -498,16 +620,18 @@ bool toku_le_worth_running_garbage_collection(LEAFENTRY le, txn_gc_info *gc_info // -- referenced_xids : list of in memory active transactions. // NOTE: it is not a good idea to garbage collect a leaf // entry with only one committed value. -void -toku_le_garbage_collect(LEAFENTRY old_leaf_entry, - bn_data* data_buffer, - uint32_t idx, - void* keyp, - uint32_t keylen, - txn_gc_info *gc_info, - LEAFENTRY *new_leaf_entry, - int64_t * numbytes_delta_p) { - // We shouldn't want to run gc without having provided a snapshot of the txn system. +void toku_le_garbage_collect( + LEAFENTRY old_leaf_entry, + bn_data* data_buffer, + uint32_t idx, + void* keyp, + uint32_t keylen, + txn_gc_info* gc_info, + LEAFENTRY* new_leaf_entry, + int64_t* numbytes_delta_p) { + + // We shouldn't want to run gc without having provided a snapshot of the + // txn system. invariant_notnull(gc_info); invariant_notnull(gc_info->txn_state_for_gc); paranoid_invariant_notnull(new_leaf_entry); @@ -520,20 +644,24 @@ toku_le_garbage_collect(LEAFENTRY old_leaf_entry, oldnumbytes = ule_get_innermost_numbytes(&ule, keylen); uint32_t old_mem_size = leafentry_memsize(old_leaf_entry); - // Before running garbage collection, try to promote the outermost provisional - // entries to committed if its xid is older than the oldest possible live xid. + // Before running garbage collection, try to promote the outermost + // provisional entries to committed if its xid is older than the oldest + // possible live xid. // // The oldest known refeferenced xid is a lower bound on the oldest possible // live xid, so we use that. It's usually close enough to get rid of most // garbage in leafentries. - ule_try_promote_provisional_outermost(&ule, gc_info->oldest_referenced_xid_for_implicit_promotion); + ule_try_promote_provisional_outermost( + &ule, + gc_info->oldest_referenced_xid_for_implicit_promotion); // No need to run simple gc here if we're going straight for full gc. if (ule.num_cuxrs > 1) { size_t size_before_gc = ule_packed_memsize(&ule); - ule_garbage_collect(&ule, - gc_info->txn_state_for_gc->snapshot_xids, - gc_info->txn_state_for_gc->referenced_xids, - gc_info->txn_state_for_gc->live_root_txns); + ule_garbage_collect( + &ule, + gc_info->txn_state_for_gc->snapshot_xids, + gc_info->txn_state_for_gc->referenced_xids, + gc_info->txn_state_for_gc->live_root_txns); size_t size_after_gc = ule_packed_memsize(&ule); LE_STATUS_INC(LE_APPLY_GC_BYTES_IN, size_before_gc); @@ -541,17 +669,18 @@ toku_le_garbage_collect(LEAFENTRY old_leaf_entry, } void *maybe_free = nullptr; - int r = le_pack( - &ule, - data_buffer, - idx, - keyp, - keylen, - keylen, // old_keylen, same because the key isn't going to change for gc - old_mem_size, - new_leaf_entry, - &maybe_free - ); + // old_keylen, same because the key isn't going to change for gc + int r = + le_pack( + &ule, + data_buffer, + idx, + keyp, + keylen, + keylen, + old_mem_size, + new_leaf_entry, + &maybe_free); invariant_zero(r); if (*new_leaf_entry) { newnumbytes = ule_get_innermost_numbytes(&ule, keylen); @@ -564,49 +693,54 @@ toku_le_garbage_collect(LEAFENTRY old_leaf_entry, } } -///////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // This layer of abstraction (msg_xxx) // knows the accessors of msg, but not of leafentry or unpacked leaf entry. // It makes calls into the lower layer (le_xxx) which handles leafentries. // Purpose is to init the ule with given key and no transaction records // -static void -msg_init_empty_ule(ULE ule) { +static inline void msg_init_empty_ule(ULE ule) { ule_init_empty_ule(ule); } // Purpose is to modify the unpacked leafentry in our private workspace. // -static void -msg_modify_ule(ULE ule, const ft_msg &msg) { +// Returns -1, 0, or 1 that identifies the change in logical row count needed +// based on the results of the message application. For example, if a delete +// finds no logical leafentry or if an insert finds a duplicate and is +// converted to an update. +static int64_t msg_modify_ule(ULE ule, const ft_msg &msg) { + int64_t retval = 0; XIDS xids = msg.xids(); invariant(toku_xids_get_num_xids(xids) < MAX_TRANSACTION_RECORDS); enum ft_msg_type type = msg.type(); - if (type != FT_OPTIMIZE && type != FT_OPTIMIZE_FOR_UPGRADE) { + if (FT_LIKELY(type != FT_OPTIMIZE && type != FT_OPTIMIZE_FOR_UPGRADE)) { ule_do_implicit_promotions(ule, xids); } switch (type) { - case FT_INSERT_NO_OVERWRITE: { - UXR old_innermost_uxr = ule_get_innermost_uxr(ule); - //If something exists, quit (no overwrite). - if (uxr_is_insert(old_innermost_uxr)) break; - //else it is just an insert, so - //fall through to FT_INSERT on purpose. - } - case FT_INSERT: { - uint32_t vallen = msg.vdbt()->size; - invariant(IS_VALID_LEN(vallen)); - void * valp = msg.vdbt()->data; - ule_apply_insert(ule, xids, vallen, valp); + case FT_INSERT_NO_OVERWRITE: + retval = + ule_apply_insert_no_overwrite( + ule, + xids, + msg.vdbt()->size, + msg.vdbt()->data); + break; + case FT_INSERT: + retval = + ule_apply_insert( + ule, + xids, + msg.vdbt()->size, + msg.vdbt()->data); break; - } case FT_DELETE_ANY: - ule_apply_delete(ule, xids); + retval = ule_apply_delete(ule, xids); break; case FT_ABORT_ANY: case FT_ABORT_BROADCAST_TXN: - ule_apply_abort(ule, xids); + retval = ule_apply_abort(ule, xids); break; case FT_COMMIT_BROADCAST_ALL: ule_apply_broadcast_commit_all(ule); @@ -621,34 +755,40 @@ msg_modify_ule(ULE ule, const ft_msg &msg) { break; case FT_UPDATE: case FT_UPDATE_BROADCAST_ALL: - assert(false); // These messages don't get this far. Instead they get translated (in setval_fun in do_update) into FT_INSERT messages. + // These messages don't get this far. Instead they get translated (in + // setval_fun in do_update) into FT_INSERT messages. + assert(false); break; default: - assert(false); /* illegal ft msg type */ + // illegal ft msg type + assert(false); break; } + return retval; } -void test_msg_modify_ule(ULE ule, const ft_msg &msg){ +void test_msg_modify_ule(ULE ule, const ft_msg &msg) { msg_modify_ule(ule,msg); } static void ule_optimize(ULE ule, XIDS xids) { if (ule->num_puxrs) { - TXNID uncommitted = ule->uxrs[ule->num_cuxrs].xid; // outermost uncommitted + // outermost uncommitted + TXNID uncommitted = ule->uxrs[ule->num_cuxrs].xid; TXNID oldest_living_xid = TXNID_NONE; uint32_t num_xids = toku_xids_get_num_xids(xids); if (num_xids > 0) { invariant(num_xids==1); oldest_living_xid = toku_xids_get_xid(xids, 0); } - if (oldest_living_xid == TXNID_NONE || uncommitted < oldest_living_xid) { + if (oldest_living_xid == TXNID_NONE || + uncommitted < oldest_living_xid) { ule_promote_provisional_innermost_to_committed(ule); } } } -///////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // This layer of abstraction (le_xxx) understands the structure of the leafentry // and of the unpacked leafentry. It is the only layer that understands the // structure of leafentry. It has no knowledge of any other data structures. @@ -657,8 +797,7 @@ static void ule_optimize(ULE ule, XIDS xids) { // // required for every le_unpack that is done // -void -ule_cleanup(ULE ule) { +void ule_cleanup(ULE ule) { invariant(ule->uxrs); if (ule->uxrs != ule->uxrs_static) { toku_free(ule->uxrs); @@ -668,8 +807,7 @@ ule_cleanup(ULE ule) { // populate an unpacked leafentry using pointers into the given leafentry. // thus, the memory referenced by 'le' must live as long as the ULE. -void -le_unpack(ULE ule, LEAFENTRY le) { +void le_unpack(ULE ule, LEAFENTRY le) { uint8_t type = le->type; uint8_t *p; uint32_t i; @@ -694,9 +832,10 @@ le_unpack(ULE ule, LEAFENTRY le) { //Dynamic memory if (ule->num_cuxrs < MAX_TRANSACTION_RECORDS) { ule->uxrs = ule->uxrs_static; - } - else { - XMALLOC_N(ule->num_cuxrs + 1 + MAX_TRANSACTION_RECORDS, ule->uxrs); + } else { + XMALLOC_N( + ule->num_cuxrs + 1 + MAX_TRANSACTION_RECORDS, + ule->uxrs); } p = le->u.mvcc.xrs; @@ -717,9 +856,12 @@ le_unpack(ULE ule, LEAFENTRY le) { p += uxr_unpack_length_and_bit(innermost, p); } for (i = 0; i < ule->num_cuxrs; i++) { - p += uxr_unpack_length_and_bit(ule->uxrs + ule->num_cuxrs - 1 - i, p); + p += + uxr_unpack_length_and_bit( + ule->uxrs + ule->num_cuxrs - 1 - i, + p); } - + //unpack interesting values inner to outer if (ule->num_puxrs!=0) { UXR innermost = ule->uxrs + ule->num_cuxrs + ule->num_puxrs - 1; @@ -761,14 +903,12 @@ le_unpack(ULE ule, LEAFENTRY le) { #endif } -static inline size_t -uxr_pack_txnid(UXR uxr, uint8_t *p) { +static inline size_t uxr_pack_txnid(UXR uxr, uint8_t *p) { *(TXNID*)p = toku_htod64(uxr->xid); return sizeof(TXNID); } -static inline size_t -uxr_pack_type_and_length(UXR uxr, uint8_t *p) { +static inline size_t uxr_pack_type_and_length(UXR uxr, uint8_t *p) { size_t rval = 1; *p = uxr->type; if (uxr_is_insert(uxr)) { @@ -778,21 +918,18 @@ uxr_pack_type_and_length(UXR uxr, uint8_t *p) { return rval; } -static inline size_t -uxr_pack_length_and_bit(UXR uxr, uint8_t *p) { +static inline size_t uxr_pack_length_and_bit(UXR uxr, uint8_t *p) { uint32_t length_and_bit; if (uxr_is_insert(uxr)) { length_and_bit = INSERT_LENGTH(uxr->vallen); - } - else { + } else { length_and_bit = DELETE_LENGTH(uxr->vallen); } *(uint32_t*)p = toku_htod32(length_and_bit); return sizeof(uint32_t); } -static inline size_t -uxr_pack_data(UXR uxr, uint8_t *p) { +static inline size_t uxr_pack_data(UXR uxr, uint8_t *p) { if (uxr_is_insert(uxr)) { memcpy(p, uxr->valp, uxr->vallen); return uxr->vallen; @@ -800,14 +937,12 @@ uxr_pack_data(UXR uxr, uint8_t *p) { return 0; } -static inline size_t -uxr_unpack_txnid(UXR uxr, uint8_t *p) { +static inline size_t uxr_unpack_txnid(UXR uxr, uint8_t *p) { uxr->xid = toku_dtoh64(*(TXNID*)p); return sizeof(TXNID); } -static inline size_t -uxr_unpack_type_and_length(UXR uxr, uint8_t *p) { +static inline size_t uxr_unpack_type_and_length(UXR uxr, uint8_t *p) { size_t rval = 1; uxr->type = *p; if (uxr_is_insert(uxr)) { @@ -817,22 +952,19 @@ uxr_unpack_type_and_length(UXR uxr, uint8_t *p) { return rval; } -static inline size_t -uxr_unpack_length_and_bit(UXR uxr, uint8_t *p) { +static inline size_t uxr_unpack_length_and_bit(UXR uxr, uint8_t *p) { uint32_t length_and_bit = toku_dtoh32(*(uint32_t*)p); if (IS_INSERT(length_and_bit)) { uxr->type = XR_INSERT; uxr->vallen = GET_LENGTH(length_and_bit); - } - else { + } else { uxr->type = XR_DELETE; uxr->vallen = 0; } return sizeof(uint32_t); } -static inline size_t -uxr_unpack_data(UXR uxr, uint8_t *p) { +static inline size_t uxr_unpack_data(UXR uxr, uint8_t *p) { if (uxr_is_insert(uxr)) { uxr->valp = p; return uxr->vallen; @@ -841,8 +973,7 @@ uxr_unpack_data(UXR uxr, uint8_t *p) { } // executed too often to be worth making threadsafe -static inline void -update_le_status(ULE ule, size_t memsize) { +static inline void update_le_status(ULE ule, size_t memsize) { if (ule->num_cuxrs > LE_STATUS_VAL(LE_MAX_COMMITTED_XR)) LE_STATUS_VAL(LE_MAX_COMMITTED_XR) = ule->num_cuxrs; if (ule->num_puxrs > LE_STATUS_VAL(LE_MAX_PROVISIONAL_XR)) @@ -856,21 +987,22 @@ update_le_status(ULE ule, size_t memsize) { // Purpose is to return a newly allocated leaf entry in packed format, or // return null if leaf entry should be destroyed (if no transaction records // are for inserts). -// Transaction records in packed le are stored inner to outer (first xr is innermost), -// with some information extracted out of the transaction records into the header. +// Transaction records in packed le are stored inner to outer (first xr is +// innermost), with some information extracted out of the transaction records +// into the header. // Transaction records in ule are stored outer to inner (uxr[0] is outermost). -int -le_pack(ULE ule, // data to be packed into new leafentry - bn_data* data_buffer, - uint32_t idx, - void* keyp, - uint32_t keylen, - uint32_t old_keylen, - uint32_t old_le_size, - LEAFENTRY * const new_leafentry_p, // this is what this function creates - void **const maybe_free - ) -{ +// Takes 'ule' and creates 'new_leafentry_p +int le_pack( + ULE ule, + bn_data* data_buffer, + uint32_t idx, + void* keyp, + uint32_t keylen, + uint32_t old_keylen, + uint32_t old_le_size, + LEAFENTRY* const new_leafentry_p, + void** const maybe_free) { + invariant(ule->num_cuxrs > 0); invariant(ule->uxrs[0].xid == TXNID_NONE); int rval; @@ -888,7 +1020,8 @@ le_pack(ULE ule, // data to be packed into new leafentry } } if (data_buffer && old_le_size > 0) { - // must pass old_keylen and old_le_size, since that's what is actually stored in data_buffer + // must pass old_keylen and old_le_size, since that's what is + // actually stored in data_buffer data_buffer->delete_leafentry(idx, old_keylen, old_le_size); } *new_leafentry_p = NULL; @@ -898,14 +1031,24 @@ le_pack(ULE ule, // data to be packed into new leafentry found_insert: memsize = le_memsize_from_ule(ule); LEAFENTRY new_leafentry; - get_space_for_le(data_buffer, idx, keyp, keylen, old_keylen, old_le_size, memsize, &new_leafentry, maybe_free); + get_space_for_le( + data_buffer, + idx, + keyp, + keylen, + old_keylen, + old_le_size, + memsize, + &new_leafentry, + maybe_free); //p always points to first unused byte after leafentry we are packing uint8_t *p; invariant(ule->num_cuxrs>0); //Type specific data if (ule->num_cuxrs == 1 && ule->num_puxrs == 0) { - //Pack a 'clean leafentry' (no uncommitted transactions, only one committed value) + //Pack a 'clean leafentry' (no uncommitted transactions, only one + //committed value) new_leafentry->type = LE_CLEAN; uint32_t vallen = ule->uxrs[0].vallen; @@ -917,8 +1060,7 @@ found_insert: //Set p to after leafentry p = new_leafentry->u.clean.val + vallen; - } - else { + } else { uint32_t i; //Pack an 'mvcc leafentry' new_leafentry->type = LE_MVCC; @@ -969,7 +1111,9 @@ found_insert: p += uxr_pack_data(outermost, p); } //pack txnid, length, bit, data for non-outermost, non-innermost - for (i = ule->num_cuxrs + 1; i < ule->num_cuxrs + ule->num_puxrs - 1; i++) { + for (i = ule->num_cuxrs + 1; + i < ule->num_cuxrs + ule->num_puxrs - 1; + i++) { UXR uxr = ule->uxrs + i; p += uxr_pack_txnid(uxr, p); p += uxr_pack_type_and_length(uxr, p); @@ -1022,13 +1166,13 @@ cleanup: return rval; } -////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Following functions provide convenient access to a packed leafentry. //Requires: -// Leafentry that ule represents should not be destroyed (is not just all deletes) -size_t -le_memsize_from_ule (ULE ule) { +// Leafentry that ule represents should not be destroyed (is not just all +// deletes) +size_t le_memsize_from_ule (ULE ule) { invariant(ule->num_cuxrs); size_t rval; if (ule->num_cuxrs == 1 && ule->num_puxrs == 0) { @@ -1037,13 +1181,13 @@ le_memsize_from_ule (ULE ule) { rval = 1 //type +4 //vallen +committed->vallen; //actual val - } - else { + } else { rval = 1 //type +4 //num_cuxrs +1 //num_puxrs +4*(ule->num_cuxrs) //types+lengths for committed - +8*(ule->num_cuxrs + ule->num_puxrs - 1); //txnids (excluding superroot) + +8*(ule->num_cuxrs + ule->num_puxrs - 1); //txnids (excluding + //superroot) uint32_t i; //Count data from committed uxrs and innermost puxr for (i = 0; i < ule->num_cuxrs; i++) { @@ -1072,8 +1216,11 @@ le_memsize_from_ule (ULE ule) { } // TODO: rename -size_t -leafentry_rest_memsize(uint32_t num_puxrs, uint32_t num_cuxrs, uint8_t* start) { +size_t leafentry_rest_memsize( + uint32_t num_puxrs, + uint32_t num_cuxrs, + uint8_t* start) { + UXR_S uxr; size_t lengths = 0; uint8_t* p = start; @@ -1122,8 +1269,7 @@ leafentry_rest_memsize(uint32_t num_puxrs, uint32_t num_cuxrs, uint8_t* start) { return rval; } -size_t -leafentry_memsize (LEAFENTRY le) { +size_t leafentry_memsize (LEAFENTRY le) { size_t rval = 0; uint8_t type = le->type; @@ -1162,13 +1308,11 @@ leafentry_memsize (LEAFENTRY le) { return rval; } -size_t -leafentry_disksize (LEAFENTRY le) { +size_t leafentry_disksize (LEAFENTRY le) { return leafentry_memsize(le); } -bool -le_is_clean(LEAFENTRY le) { +bool le_is_clean(LEAFENTRY le) { uint8_t type = le->type; uint32_t rval; switch (type) { @@ -1228,13 +1372,14 @@ int le_latest_is_del(LEAFENTRY le) { // -// returns true if the outermost provisional transaction id on the leafentry's stack matches -// the outermost transaction id in xids -// It is used to determine if a broadcast commit/abort message (look in ft-ops.c) should be applied to this leafentry -// If the outermost transactions match, then the broadcast commit/abort should be applied +// returns true if the outermost provisional transaction id on the leafentry's +// stack matches the outermost transaction id in xids +// It is used to determine if a broadcast commit/abort message (look in ft-ops.c) +// should be applied to this leafentry +// If the outermost transactions match, then the broadcast commit/abort should +// be applied // -bool -le_has_xids(LEAFENTRY le, XIDS xids) { +bool le_has_xids(LEAFENTRY le, XIDS xids) { //Read num_uxrs uint32_t num_xids = toku_xids_get_num_xids(xids); invariant(num_xids > 0); //Disallow checking for having TXNID_NONE @@ -1245,8 +1390,7 @@ le_has_xids(LEAFENTRY le, XIDS xids) { return rval; } -void* -le_latest_val_and_len (LEAFENTRY le, uint32_t *len) { +void* le_latest_val_and_len (LEAFENTRY le, uint32_t *len) { uint8_t type = le->type; void *valp; @@ -1277,8 +1421,7 @@ le_latest_val_and_len (LEAFENTRY le, uint32_t *len) { if (uxr_is_insert(&uxr)) { *len = uxr.vallen; valp = p + (num_cuxrs - 1 + (num_puxrs!=0))*sizeof(uint32_t); - } - else { + } else { *len = 0; valp = NULL; } @@ -1295,8 +1438,7 @@ le_latest_val_and_len (LEAFENTRY le, uint32_t *len) { if (uxr_is_insert(uxr)) { slow_valp = uxr->valp; slow_len = uxr->vallen; - } - else { + } else { slow_valp = NULL; slow_len = 0; } @@ -1310,8 +1452,7 @@ le_latest_val_and_len (LEAFENTRY le, uint32_t *len) { } //DEBUG ONLY can be slow -void* -le_latest_val (LEAFENTRY le) { +void* le_latest_val (LEAFENTRY le) { ULE_S ule; le_unpack(&ule, le); UXR uxr = ule_get_innermost_uxr(&ule); @@ -1325,8 +1466,7 @@ le_latest_val (LEAFENTRY le) { } //needed to be fast for statistics. -uint32_t -le_latest_vallen (LEAFENTRY le) { +uint32_t le_latest_vallen (LEAFENTRY le) { uint32_t rval; uint8_t type = le->type; uint8_t *p; @@ -1354,8 +1494,7 @@ le_latest_vallen (LEAFENTRY le) { uxr_unpack_length_and_bit(&uxr, p); if (uxr_is_insert(&uxr)) { rval = uxr.vallen; - } - else { + } else { rval = 0; } break; @@ -1377,8 +1516,7 @@ le_latest_vallen (LEAFENTRY le) { return rval; } -uint64_t -le_outermost_uncommitted_xid (LEAFENTRY le) { +uint64_t le_outermost_uncommitted_xid (LEAFENTRY le) { uint64_t rval = TXNID_NONE; uint8_t type = le->type; @@ -1412,8 +1550,7 @@ le_outermost_uncommitted_xid (LEAFENTRY le) { //Optimization not required. This is a debug only function. //Print a leafentry out in human-readable format -int -print_klpair (FILE *outf, const void* keyp, uint32_t keylen, LEAFENTRY le) { +int print_klpair (FILE *outf, const void* keyp, uint32_t keylen, LEAFENTRY le) { ULE_S ule; le_unpack(&ule, le); uint32_t i; @@ -1444,23 +1581,21 @@ print_klpair (FILE *outf, const void* keyp, uint32_t keylen, LEAFENTRY le) { return 0; } -///////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // This layer of abstraction (ule_xxx) knows the structure of the unpacked // leafentry and no other structure. // // ule constructor // Note that transaction 0 is explicit in the ule -static void -ule_init_empty_ule(ULE ule) { +static inline void ule_init_empty_ule(ULE ule) { ule->num_cuxrs = 1; ule->num_puxrs = 0; ule->uxrs = ule->uxrs_static; ule->uxrs[0] = committed_delete; } -static inline int32_t -min_i32(int32_t a, int32_t b) { +static inline int32_t min_i32(int32_t a, int32_t b) { int32_t rval = a < b ? a : b; return rval; } @@ -1470,8 +1605,8 @@ min_i32(int32_t a, int32_t b) { // // If the leafentry has already been promoted, there is nothing to do. // We have two transaction stacks (one from message, one from leaf entry). -// We want to implicitly promote transactions newer than (but not including) -// the innermost common ancestor (ICA) of the two stacks of transaction ids. We +// We want to implicitly promote transactions newer than (but not including) +// the innermost common ancestor (ICA) of the two stacks of transaction ids. We // know that this is the right thing to do because each transaction with an id // greater (later) than the ICA must have been either committed or aborted. // If it was aborted then we would have seen an abort message and removed the @@ -1483,8 +1618,7 @@ min_i32(int32_t a, int32_t b) { // record of ICA, keeping the transaction id of the ICA. // Outermost xid is zero for both ule and xids<> // -static void -ule_do_implicit_promotions(ULE ule, XIDS xids) { +static void ule_do_implicit_promotions(ULE ule, XIDS xids) { //Optimization for (most) common case. //No commits necessary if everything is already committed. if (ule->num_puxrs > 0) { @@ -1506,17 +1640,16 @@ ule_do_implicit_promotions(ULE ule, XIDS xids) { if (ica_index < ule->num_cuxrs) { invariant(ica_index == ule->num_cuxrs - 1); ule_promote_provisional_innermost_to_committed(ule); - } - else if (ica_index < ule->num_cuxrs + ule->num_puxrs - 1) { - //If ica is the innermost uxr in the leafentry, no commits are necessary. + } else if (ica_index < ule->num_cuxrs + ule->num_puxrs - 1) { + //If ica is the innermost uxr in the leafentry, no commits are + //necessary. ule_promote_provisional_innermost_to_index(ule, ica_index); } } } -static void -ule_promote_provisional_innermost_to_committed(ULE ule) { +static void ule_promote_provisional_innermost_to_committed(ULE ule) { //Must be something to promote. invariant(ule->num_puxrs); //Take value (or delete flag) from innermost. @@ -1532,8 +1665,7 @@ ule_promote_provisional_innermost_to_committed(ULE ule) { ule->num_puxrs = 0; //Discard all provisional uxrs. if (uxr_is_delete(old_innermost_uxr)) { ule_push_delete_uxr(ule, true, old_outermost_uncommitted_uxr->xid); - } - else { + } else { ule_push_insert_uxr(ule, true, old_outermost_uncommitted_uxr->xid, old_innermost_uxr->vallen, @@ -1541,11 +1673,13 @@ ule_promote_provisional_innermost_to_committed(ULE ule) { } } -static void -ule_try_promote_provisional_outermost(ULE ule, TXNID oldest_possible_live_xid) { +static void ule_try_promote_provisional_outermost( + ULE ule, + TXNID oldest_possible_live_xid) { // Effect: If there is a provisional record whose outermost xid is older than // the oldest known referenced_xid, promote it to committed. - if (ule->num_puxrs > 0 && ule_get_xid(ule, ule->num_cuxrs) < oldest_possible_live_xid) { + if (ule->num_puxrs > 0 && + ule_get_xid(ule, ule->num_cuxrs) < oldest_possible_live_xid) { ule_promote_provisional_innermost_to_committed(ule); } } @@ -1553,8 +1687,9 @@ ule_try_promote_provisional_outermost(ULE ule, TXNID oldest_possible_live_xid) { // Purpose is to promote the value (and type) of the innermost transaction // record to the uxr at the specified index (keeping the txnid of the uxr at // specified index.) -static void -ule_promote_provisional_innermost_to_index(ULE ule, uint32_t index) { +static void ule_promote_provisional_innermost_to_index( + ULE ule, + uint32_t index) { //Must not promote to committed portion of stack. invariant(index >= ule->num_cuxrs); //Must actually be promoting. @@ -1562,15 +1697,17 @@ ule_promote_provisional_innermost_to_index(ULE ule, uint32_t index) { UXR old_innermost_uxr = ule_get_innermost_uxr(ule); assert(!uxr_is_placeholder(old_innermost_uxr)); TXNID new_innermost_xid = ule->uxrs[index].xid; - ule->num_puxrs = index - ule->num_cuxrs; //Discard old uxr at index (and everything inner) + //Discard old uxr at index (and everything inner) + ule->num_puxrs = index - ule->num_cuxrs; if (uxr_is_delete(old_innermost_uxr)) { ule_push_delete_uxr(ule, false, new_innermost_xid); - } - else { - ule_push_insert_uxr(ule, false, - new_innermost_xid, - old_innermost_uxr->vallen, - old_innermost_uxr->valp); + } else { + ule_push_insert_uxr( + ule, + false, + new_innermost_xid, + old_innermost_uxr->vallen, + old_innermost_uxr->valp); } } @@ -1581,19 +1718,60 @@ ule_promote_provisional_innermost_to_index(ULE ule, uint32_t index) { // Purpose is to apply an insert message to this leafentry: -static void -ule_apply_insert(ULE ule, XIDS xids, uint32_t vallen, void * valp) { +static inline int64_t ule_apply_insert_no_overwrite( + ULE ule, + XIDS xids, + uint32_t vallen, + void* valp) { + + invariant(IS_VALID_LEN(vallen)); + int64_t retval = 0; + UXR old_innermost_uxr = ule_get_innermost_uxr(ule); + // If something exists, don't overwrite + if (uxr_is_insert(old_innermost_uxr)) { + retval = -1; + return retval; + } ule_prepare_for_new_uxr(ule, xids); - TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction doing this insert + // xid of transaction doing this insert + TXNID this_xid = toku_xids_get_innermost_xid(xids); ule_push_insert_uxr(ule, this_xid == TXNID_NONE, this_xid, vallen, valp); + return retval; +} + +// Purpose is to apply an insert message to this leafentry: +static inline int64_t ule_apply_insert( + ULE ule, + XIDS xids, + uint32_t vallen, + void* valp) { + + invariant(IS_VALID_LEN(vallen)); + int64_t retval = 0; + UXR old_innermost_uxr = ule_get_innermost_uxr(ule); + // If something exists, overwrite + if (uxr_is_insert(old_innermost_uxr)) { + retval = -1; + } + ule_prepare_for_new_uxr(ule, xids); + // xid of transaction doing this insert + TXNID this_xid = toku_xids_get_innermost_xid(xids); + ule_push_insert_uxr(ule, this_xid == TXNID_NONE, this_xid, vallen, valp); + return retval; } // Purpose is to apply a delete message to this leafentry: -static void -ule_apply_delete(ULE ule, XIDS xids) { +static inline int64_t ule_apply_delete(ULE ule, XIDS xids) { + int64_t retval = 0; + UXR old_innermost_uxr = ule_get_innermost_uxr(ule); + if (FT_UNLIKELY(uxr_is_delete(old_innermost_uxr))) { + retval = 1; + } ule_prepare_for_new_uxr(ule, xids); - TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction doing this delete + // xid of transaction doing this delete + TXNID this_xid = toku_xids_get_innermost_xid(xids); ule_push_delete_uxr(ule, this_xid == TXNID_NONE, this_xid); + return retval; } // First, discard anything done earlier by this transaction. @@ -1601,20 +1779,18 @@ ule_apply_delete(ULE ule, XIDS xids) { // outer transactions that are newer than then newest (innermost) transaction in // the leafentry. If so, record those outer transactions in the leafentry // with placeholders. -static void -ule_prepare_for_new_uxr(ULE ule, XIDS xids) { +static inline void ule_prepare_for_new_uxr(ULE ule, XIDS xids) { TXNID this_xid = toku_xids_get_innermost_xid(xids); //This is for LOADER_USE_PUTS or transactionless environment //where messages use XIDS of 0 if (this_xid == TXNID_NONE && ule_get_innermost_xid(ule) == TXNID_NONE) { ule_remove_innermost_uxr(ule); - } - // case where we are transactional and xids stack matches ule stack - else if (ule->num_puxrs > 0 && ule_get_innermost_xid(ule) == this_xid) { + } else if (ule->num_puxrs > 0 && ule_get_innermost_xid(ule) == this_xid) { + // case where we are transactional and xids stack matches ule stack ule_remove_innermost_uxr(ule); - } - // case where we are transactional and xids stack does not match ule stack - else { + } else { + // case where we are transactional and xids stack does not match ule + // stack ule_add_placeholders(ule, xids); } } @@ -1625,10 +1801,12 @@ ule_prepare_for_new_uxr(ULE ule, XIDS xids) { // then there is nothing to be done. // If this transaction did modify the leafentry, then undo whatever it did (by // removing the transaction record (uxr) and any placeholders underneath. -// Remember, the innermost uxr can only be an insert or a delete, not a placeholder. -static void -ule_apply_abort(ULE ule, XIDS xids) { - TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction doing this abort +// Remember, the innermost uxr can only be an insert or a delete, not a +// placeholder. +static inline int64_t ule_apply_abort(ULE ule, XIDS xids) { + int64_t retval = 0; + // xid of transaction doing this abort + TXNID this_xid = toku_xids_get_innermost_xid(xids); invariant(this_xid!=TXNID_NONE); UXR innermost = ule_get_innermost_uxr(ule); // need to check for provisional entries in ule, otherwise @@ -1636,15 +1814,34 @@ ule_apply_abort(ULE ule, XIDS xids) { // in a bug where the most recently committed has same xid // as the XID's innermost if (ule->num_puxrs > 0 && innermost->xid == this_xid) { + // if this is a rollback of a delete of a new ule, return 0 + // (i.e. double delete) + if (uxr_is_delete(innermost)) { + if (ule->num_puxrs == 1 && ule->num_cuxrs == 1 && + uxr_is_delete(&(ule->uxrs[0]))) { + retval = 0; + } else { + retval = 1; + } + } else if (uxr_is_insert(innermost)) { + if (ule->num_puxrs == 1 && ule->num_cuxrs == 1 && + uxr_is_insert(&(ule->uxrs[0]))) { + retval = 0; + } else { + retval = -1; + } + } + // if this is a rollback of a insert of an exising ule, return 0 + // (i.e. double insert) invariant(ule->num_puxrs>0); ule_remove_innermost_uxr(ule); ule_remove_innermost_placeholders(ule); } invariant(ule->num_cuxrs > 0); + return retval; } -static void -ule_apply_broadcast_commit_all (ULE ule) { +static void ule_apply_broadcast_commit_all (ULE ule) { ule->uxrs[0] = ule->uxrs[ule->num_puxrs + ule->num_cuxrs - 1]; ule->uxrs[0].xid = TXNID_NONE; ule->num_puxrs = 0; @@ -1657,9 +1854,11 @@ ule_apply_broadcast_commit_all (ULE ule) { // then there is nothing to be done. // Also, if there are no uncommitted transaction records there is nothing to do. // If this transaction did modify the leafentry, then promote whatever it did. -// Remember, the innermost uxr can only be an insert or a delete, not a placeholder. +// Remember, the innermost uxr can only be an insert or a delete, not a +// placeholder. void ule_apply_commit(ULE ule, XIDS xids) { - TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction committing + // xid of transaction committing + TXNID this_xid = toku_xids_get_innermost_xid(xids); invariant(this_xid!=TXNID_NONE); // need to check for provisional entries in ule, otherwise // there is nothing to abort, not checking this may result @@ -1668,16 +1867,19 @@ void ule_apply_commit(ULE ule, XIDS xids) { if (ule->num_puxrs > 0 && ule_get_innermost_xid(ule) == this_xid) { // 3 cases: //1- it's already a committed value (do nothing) (num_puxrs==0) - //2- it's provisional but root level (make a new committed value (num_puxrs==1) + //2- it's provisional but root level (make a new committed value + // (num_puxrs==1) //3- it's provisional and not root (promote); (num_puxrs>1) if (ule->num_puxrs == 1) { //new committed value ule_promote_provisional_innermost_to_committed(ule); - } - else if (ule->num_puxrs > 1) { - //ule->uxrs[ule->num_cuxrs+ule->num_puxrs-1] is the innermost (this transaction) + } else if (ule->num_puxrs > 1) { + //ule->uxrs[ule->num_cuxrs+ule->num_puxrs-1] is the innermost + // (this transaction) //ule->uxrs[ule->num_cuxrs+ule->num_puxrs-2] is the 2nd innermost //We want to promote the innermost uxr one level out. - ule_promote_provisional_innermost_to_index(ule, ule->num_cuxrs+ule->num_puxrs-2); + ule_promote_provisional_innermost_to_index( + ule, + ule->num_cuxrs+ule->num_puxrs-2); } } } @@ -1687,14 +1889,17 @@ void ule_apply_commit(ULE ule, XIDS xids) { // // Purpose is to record an insert for this transaction (and set type correctly). -static void -ule_push_insert_uxr(ULE ule, bool is_committed, TXNID xid, uint32_t vallen, void * valp) { - UXR uxr = ule_get_first_empty_uxr(ule); +static inline void ule_push_insert_uxr( + ULE ule, + bool is_committed, TXNID xid, + uint32_t vallen, + void* valp) { + + UXR uxr = ule_get_first_empty_uxr(ule); if (is_committed) { invariant(ule->num_puxrs==0); ule->num_cuxrs++; - } - else { + } else { ule->num_puxrs++; } uxr->xid = xid; @@ -1706,23 +1911,21 @@ ule_push_insert_uxr(ULE ule, bool is_committed, TXNID xid, uint32_t vallen, void // Purpose is to record a delete for this transaction. If this transaction // is the root transaction, then truly delete the leafentry by marking the // ule as empty. -static void -ule_push_delete_uxr(ULE ule, bool is_committed, TXNID xid) { +static inline void ule_push_delete_uxr(ULE ule, bool is_committed, TXNID xid) { UXR uxr = ule_get_first_empty_uxr(ule); if (is_committed) { invariant(ule->num_puxrs==0); ule->num_cuxrs++; - } - else { + } else { ule->num_puxrs++; } uxr->xid = xid; uxr->type = XR_DELETE; } -// Purpose is to push a placeholder on the top of the leafentry's transaction stack. -static void -ule_push_placeholder_uxr(ULE ule, TXNID xid) { +// Purpose is to push a placeholder on the top of the leafentry's transaction +// stack. +static inline void ule_push_placeholder_uxr(ULE ule, TXNID xid) { invariant(ule->num_cuxrs>0); UXR uxr = ule_get_first_empty_uxr(ule); uxr->xid = xid; @@ -1731,16 +1934,14 @@ ule_push_placeholder_uxr(ULE ule, TXNID xid) { } // Return innermost transaction record. -static UXR -ule_get_innermost_uxr(ULE ule) { +static inline UXR ule_get_innermost_uxr(ULE ule) { invariant(ule->num_cuxrs > 0); UXR rval = &(ule->uxrs[ule->num_cuxrs + ule->num_puxrs - 1]); return rval; } // Return first empty transaction record -static UXR -ule_get_first_empty_uxr(ULE ule) { +static inline UXR ule_get_first_empty_uxr(ULE ule) { invariant(ule->num_puxrs < MAX_TRANSACTION_RECORDS-1); UXR rval = &(ule->uxrs[ule->num_cuxrs+ule->num_puxrs]); return rval; @@ -1748,14 +1949,12 @@ ule_get_first_empty_uxr(ULE ule) { // Remove the innermost transaction (pop the leafentry's stack), undoing // whatever the innermost transaction did. -static void -ule_remove_innermost_uxr(ULE ule) { +static inline void ule_remove_innermost_uxr(ULE ule) { //It is possible to remove the committed delete at first insert. invariant(ule->num_cuxrs > 0); if (ule->num_puxrs) { ule->num_puxrs--; - } - else { + } else { //This is for LOADER_USE_PUTS or transactionless environment //where messages use XIDS of 0 invariant(ule->num_cuxrs == 1); @@ -1764,14 +1963,12 @@ ule_remove_innermost_uxr(ULE ule) { } } -static TXNID -ule_get_innermost_xid(ULE ule) { +static inline TXNID ule_get_innermost_xid(ULE ule) { TXNID rval = ule_get_xid(ule, ule->num_cuxrs + ule->num_puxrs - 1); return rval; } -static TXNID -ule_get_xid(ULE ule, uint32_t index) { +static inline TXNID ule_get_xid(ULE ule, uint32_t index) { invariant(index < ule->num_cuxrs + ule->num_puxrs); TXNID rval = ule->uxrs[index].xid; return rval; @@ -1781,8 +1978,7 @@ ule_get_xid(ULE ule, uint32_t index) { // innermost recorded transactions), if necessary. This function is idempotent. // It makes no logical sense for a placeholder to be the innermost recorded // transaction record, so placeholders at the top of the stack are not legal. -static void -ule_remove_innermost_placeholders(ULE ule) { +static void ule_remove_innermost_placeholders(ULE ule) { UXR uxr = ule_get_innermost_uxr(ule); while (uxr_is_placeholder(uxr)) { invariant(ule->num_puxrs>0); @@ -1796,8 +1992,7 @@ ule_remove_innermost_placeholders(ULE ule) { // Note, after placeholders are added, an insert or delete will be added. This // function temporarily leaves the transaction stack in an illegal state (having // placeholders on top). -static void -ule_add_placeholders(ULE ule, XIDS xids) { +static void ule_add_placeholders(ULE ule, XIDS xids) { //Placeholders can be placed on top of the committed uxr. invariant(ule->num_cuxrs > 0); @@ -1819,47 +2014,40 @@ ule_add_placeholders(ULE ule, XIDS xids) { } } -uint64_t -ule_num_uxrs(ULE ule) { +uint64_t ule_num_uxrs(ULE ule) { return ule->num_cuxrs + ule->num_puxrs; } -UXR -ule_get_uxr(ULE ule, uint64_t ith) { +UXR ule_get_uxr(ULE ule, uint64_t ith) { invariant(ith < ule_num_uxrs(ule)); return &ule->uxrs[ith]; } -uint32_t -ule_get_num_committed(ULE ule) { +uint32_t ule_get_num_committed(ULE ule) { return ule->num_cuxrs; } -uint32_t -ule_get_num_provisional(ULE ule) { +uint32_t ule_get_num_provisional(ULE ule) { return ule->num_puxrs; } -int -ule_is_committed(ULE ule, uint64_t ith) { +int ule_is_committed(ULE ule, uint64_t ith) { invariant(ith < ule_num_uxrs(ule)); return ith < ule->num_cuxrs; } -int -ule_is_provisional(ULE ule, uint64_t ith) { +int ule_is_provisional(ULE ule, uint64_t ith) { invariant(ith < ule_num_uxrs(ule)); return ith >= ule->num_cuxrs; } // return size of data for innermost uxr, the size of val -uint32_t -ule_get_innermost_numbytes(ULE ule, uint32_t keylen) { +uint32_t ule_get_innermost_numbytes(ULE ule, uint32_t keylen) { uint32_t rval; UXR uxr = ule_get_innermost_uxr(ule); - if (uxr_is_delete(uxr)) + if (uxr_is_delete(uxr)) { rval = 0; - else { + } else { rval = uxr_get_vallen(uxr) + keylen; } return rval; @@ -1870,68 +2058,65 @@ ule_get_innermost_numbytes(ULE ule, uint32_t keylen) { // This layer of abstraction (uxr_xxx) understands uxr and nothing else. // -static inline bool -uxr_type_is_insert(uint8_t type) { +static inline bool uxr_type_is_insert(uint8_t type) { bool rval = (bool)(type == XR_INSERT); return rval; } -bool -uxr_is_insert(UXR uxr) { +bool uxr_is_insert(UXR uxr) { return uxr_type_is_insert(uxr->type); } -static inline bool -uxr_type_is_delete(uint8_t type) { +static inline bool uxr_type_is_delete(uint8_t type) { bool rval = (bool)(type == XR_DELETE); return rval; } -bool -uxr_is_delete(UXR uxr) { +bool uxr_is_delete(UXR uxr) { return uxr_type_is_delete(uxr->type); } -static inline bool -uxr_type_is_placeholder(uint8_t type) { +static inline bool uxr_type_is_placeholder(uint8_t type) { bool rval = (bool)(type == XR_PLACEHOLDER); return rval; } -bool -uxr_is_placeholder(UXR uxr) { +bool uxr_is_placeholder(UXR uxr) { return uxr_type_is_placeholder(uxr->type); } -void * -uxr_get_val(UXR uxr) { +void* uxr_get_val(UXR uxr) { return uxr->valp; } -uint32_t -uxr_get_vallen(UXR uxr) { +uint32_t uxr_get_vallen(UXR uxr) { return uxr->vallen; } -TXNID -uxr_get_txnid(UXR uxr) { +TXNID uxr_get_txnid(UXR uxr) { return uxr->xid; } -static int -le_iterate_get_accepted_index(TXNID *xids, uint32_t *index, uint32_t num_xids, LE_ITERATE_CALLBACK f, TOKUTXN context, bool top_is_provisional) { +static int le_iterate_get_accepted_index( + TXNID* xids, + uint32_t* index, + uint32_t num_xids, + LE_ITERATE_CALLBACK f, + TOKUTXN context, + bool top_is_provisional) { + uint32_t i; int r = 0; - // if this for loop does not return anything, we return num_xids-1, which should map to T_0 + // if this for loop does not return anything, we return num_xids-1, which + // should map to T_0 for (i = 0; i < num_xids - 1; i++) { TXNID xid = toku_dtoh64(xids[i]); r = f(xid, context, (i == 0 && top_is_provisional)); if (r==TOKUDB_ACCEPT) { r = 0; break; //or goto something - } - else if (r!=0) { + } else if (r!=0) { break; } } @@ -1940,8 +2125,7 @@ le_iterate_get_accepted_index(TXNID *xids, uint32_t *index, uint32_t num_xids, L } #if ULE_DEBUG -static void -ule_verify_xids(ULE ule, uint32_t interesting, TXNID *xids) { +static void ule_verify_xids(ULE ule, uint32_t interesting, TXNID *xids) { int has_p = (ule->num_puxrs != 0); invariant(ule->num_cuxrs + has_p == interesting); uint32_t i; @@ -1953,21 +2137,29 @@ ule_verify_xids(ULE ule, uint32_t interesting, TXNID *xids) { #endif // -// Iterates over "possible" TXNIDs in a leafentry's stack, until one is accepted by 'f'. If the value -// associated with the accepted TXNID is not an insert, then set *is_emptyp to true, otherwise false +// Iterates over "possible" TXNIDs in a leafentry's stack, until one is +// accepted by 'f'. If the value associated with the accepted TXNID is not an +// insert, then set *is_emptyp to true, otherwise false // The "possible" TXNIDs are: -// if provisionals exist, then the first possible TXNID is the outermost provisional. -// The next possible TXNIDs are the committed TXNIDs, from most recently committed to T_0. -// If provisionals exist, and the outermost provisional is accepted by 'f', +// If provisionals exist, then the first possible TXNID is the outermost +// provisional. +// The next possible TXNIDs are the committed TXNIDs, from most recently +// committed to T_0. +// If provisionals exist, and the outermost provisional is accepted by 'f', // the associated value checked is the innermost provisional's value. // Parameters: // le - leafentry to iterate over -// f - callback function that checks if a TXNID in le is accepted, and its associated value should be examined. +// f - callback function that checks if a TXNID in le is accepted, and its +// associated value should be examined. // is_delp - output parameter that returns answer // context - parameter for f // -static int -le_iterate_is_del(LEAFENTRY le, LE_ITERATE_CALLBACK f, bool *is_delp, TOKUTXN context) { +static int le_iterate_is_del( + LEAFENTRY le, + LE_ITERATE_CALLBACK f, + bool* is_delp, + TOKUTXN context) { + #if ULE_DEBUG ULE_S ule; le_unpack(&ule, le); @@ -2002,8 +2194,17 @@ le_iterate_is_del(LEAFENTRY le, LE_ITERATE_CALLBACK f, bool *is_delp, TOKUTXN co #if ULE_DEBUG ule_verify_xids(&ule, num_interesting, xids); #endif - r = le_iterate_get_accepted_index(xids, &index, num_interesting, f, context, (num_puxrs != 0)); - if (r!=0) goto cleanup; + r = + le_iterate_get_accepted_index( + xids, + &index, + num_interesting, + f, + context, + (num_puxrs != 0)); + if (r != 0) { + goto cleanup; + } invariant(index < num_interesting); //Skip TXNIDs @@ -2017,7 +2218,9 @@ le_iterate_is_del(LEAFENTRY le, LE_ITERATE_CALLBACK f, bool *is_delp, TOKUTXN co #if ULE_DEBUG { uint32_t has_p = (ule.num_puxrs != 0); - uint32_t ule_index = (index==0) ? ule.num_cuxrs + ule.num_puxrs - 1 : ule.num_cuxrs - 1 + has_p - index; + uint32_t ule_index = (index==0) ? + ule.num_cuxrs + ule.num_puxrs - 1 : + ule.num_cuxrs - 1 + has_p - index; UXR uxr = ule.uxrs + ule_index; invariant(uxr_is_delete(uxr) == is_del); } @@ -2034,7 +2237,11 @@ cleanup: return r; } -static int le_iterate_read_committed_callback(TXNID txnid, TOKUTXN txn, bool is_provisional UU()) { +static int le_iterate_read_committed_callback( + TXNID txnid, + TOKUTXN txn, + bool is_provisional UU()) { + if (is_provisional) { return toku_txn_reads_txnid(txnid, txn, is_provisional); } @@ -2058,33 +2265,40 @@ int le_val_is_del(LEAFENTRY le, enum cursor_read_type read_type, TOKUTXN txn) { txn ); rval = is_del; - } - else if (read_type == C_READ_ANY) { + } else if (read_type == C_READ_ANY) { rval = le_latest_is_del(le); - } - else { + } else { invariant(false); } return rval; } // -// Iterates over "possible" TXNIDs in a leafentry's stack, until one is accepted by 'f'. Set -// valpp and vallenp to value and length associated with accepted TXNID +// Iterates over "possible" TXNIDs in a leafentry's stack, until one is accepted +// by 'f'. Set valpp and vallenp to value and length associated with accepted +// TXNID // The "possible" TXNIDs are: -// if provisionals exist, then the first possible TXNID is the outermost provisional. -// The next possible TXNIDs are the committed TXNIDs, from most recently committed to T_0. -// If provisionals exist, and the outermost provisional is accepted by 'f', +// If provisionals exist, then the first possible TXNID is the outermost +// provisional. +// The next possible TXNIDs are the committed TXNIDs, from most recently +// committed to T_0. +// If provisionals exist, and the outermost provisional is accepted by 'f', // the associated length value is the innermost provisional's length and value. // Parameters: // le - leafentry to iterate over -// f - callback function that checks if a TXNID in le is accepted, and its associated value should be examined. +// f - callback function that checks if a TXNID in le is accepted, and its +// associated value should be examined. // valpp - output parameter that returns pointer to value // vallenp - output parameter that returns length of value // context - parameter for f // -int -le_iterate_val(LEAFENTRY le, LE_ITERATE_CALLBACK f, void** valpp, uint32_t *vallenp, TOKUTXN context) { +int le_iterate_val( + LEAFENTRY le, + LE_ITERATE_CALLBACK f, + void** valpp, + uint32_t* vallenp, + TOKUTXN context) { + #if ULE_DEBUG ULE_S ule; le_unpack(&ule, le); @@ -2124,8 +2338,17 @@ le_iterate_val(LEAFENTRY le, LE_ITERATE_CALLBACK f, void** valpp, uint32_t *vall #if ULE_DEBUG ule_verify_xids(&ule, num_interesting, xids); #endif - r = le_iterate_get_accepted_index(xids, &index, num_interesting, f, context, (num_puxrs != 0)); - if (r!=0) goto cleanup; + r = + le_iterate_get_accepted_index( + xids, + &index, + num_interesting, + f, + context, + (num_puxrs != 0)); + if (r != 0) { + goto cleanup; + } invariant(index < num_interesting); //Skip TXNIDs @@ -2158,7 +2381,9 @@ le_iterate_val(LEAFENTRY le, LE_ITERATE_CALLBACK f, void** valpp, uint32_t *vall #if ULE_DEBUG { uint32_t has_p = (ule.num_puxrs != 0); - uint32_t ule_index = (index==0) ? ule.num_cuxrs + ule.num_puxrs - 1 : ule.num_cuxrs - 1 + has_p - index; + uint32_t ule_index = (index==0) ? + ule.num_cuxrs + ule.num_puxrs - 1 : + ule.num_cuxrs - 1 + has_p - index; UXR uxr = ule.uxrs + ule_index; invariant(uxr_is_insert(uxr)); invariant(uxr->vallen == vallen); @@ -2188,10 +2413,15 @@ cleanup: return r; } -void le_extract_val(LEAFENTRY le, - // should we return the entire leafentry as the val? - bool is_leaf_mode, enum cursor_read_type read_type, - TOKUTXN ttxn, uint32_t *vallen, void **val) { +void le_extract_val( + LEAFENTRY le, + // should we return the entire leafentry as the val? + bool is_leaf_mode, + enum cursor_read_type read_type, + TOKUTXN ttxn, + uint32_t* vallen, + void** val) { + if (is_leaf_mode) { *val = le; *vallen = leafentry_memsize(le); @@ -2199,18 +2429,11 @@ void le_extract_val(LEAFENTRY le, LE_ITERATE_CALLBACK f = (read_type == C_READ_SNAPSHOT) ? toku_txn_reads_txnid : le_iterate_read_committed_callback; - int r = le_iterate_val( - le, - f, - val, - vallen, - ttxn - ); + int r = le_iterate_val(le, f, val, vallen, ttxn); lazy_assert_zero(r); } else if (read_type == C_READ_ANY){ *val = le_latest_val_and_len(le, vallen); - } - else { + } else { assert(false); } } @@ -2244,9 +2467,9 @@ static_assert(18 == sizeof(leafentry_13), "wrong size"); static_assert(9 == __builtin_offsetof(leafentry_13, u), "wrong offset"); //Requires: -// Leafentry that ule represents should not be destroyed (is not just all deletes) -static size_t -le_memsize_from_ule_13 (ULE ule, LEAFENTRY_13 le) { +// Leafentry that ule represents should not be destroyed (is not just all +// deletes) +static size_t le_memsize_from_ule_13 (ULE ule, LEAFENTRY_13 le) { uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs; assert(num_uxrs); size_t rval; @@ -2257,8 +2480,7 @@ le_memsize_from_ule_13 (ULE ule, LEAFENTRY_13 le) { +4 //vallen +le->keylen //actual key +ule->uxrs[0].vallen; //actual val - } - else { + } else { rval = 1 //num_uxrs +4 //keylen +le->keylen //actual key @@ -2276,16 +2498,20 @@ le_memsize_from_ule_13 (ULE ule, LEAFENTRY_13 le) { return rval; } -//This function is mostly copied from 4.1.1 (which is version 12, same as 13 except that only 13 is upgradable). -// Note, number of transaction records in version 13 has been replaced by separate counters in version 14 (MVCC), -// one counter for committed transaction records and one counter for provisional transaction records. When -// upgrading a version 13 le to version 14, the number of committed transaction records is always set to one (1) -// and the number of provisional transaction records is set to the original number of transaction records -// minus one. The bottom transaction record is assumed to be a committed value. (If there is no committed -// value then the bottom transaction record of version 13 is a committed delete.) -// This is the only change from the 4.1.1 code. The rest of the leafentry is read as is. -static void -le_unpack_13(ULE ule, LEAFENTRY_13 le) { +// This function is mostly copied from 4.1.1 (which is version 12, same as 13 +// except that only 13 is upgradable). +// Note, number of transaction records in version 13 has been replaced by +// separate counters in version 14 (MVCC), one counter for committed transaction +// records and one counter for provisional transaction records. When upgrading +// a version 13 le to version 14, the number of committed transaction records is +// always set to one (1) and the number of provisional transaction records is +// set to the original number of transaction records minus one. The bottom +// transaction record is assumed to be a committed value. (If there is no +// committed value then the bottom transaction record of version 13 is a +// committed delete.) +// This is the only change from the 4.1.1 code. The rest of the leafentry is +// read as is. +static void le_unpack_13(ULE ule, LEAFENTRY_13 le) { //Read num_uxrs uint8_t num_xrs = le->num_xrs; assert(num_xrs > 0); @@ -2302,15 +2528,15 @@ le_unpack_13(ULE ule, LEAFENTRY_13 le) { uint8_t *p; if (num_xrs == 1) { //Unpack a 'committed leafentry' (No uncommitted transactions exist) - ule->uxrs[0].type = XR_INSERT; //Must be or the leafentry would not exist + //Must be or the leafentry would not exist + ule->uxrs[0].type = XR_INSERT; ule->uxrs[0].vallen = vallen_of_innermost_insert; ule->uxrs[0].valp = &le->u.comm.key_val[keylen]; ule->uxrs[0].xid = 0; //Required. //Set p to immediately after leafentry p = &le->u.comm.key_val[keylen + vallen_of_innermost_insert]; - } - else { + } else { //Unpack a 'provisional leafentry' (Uncommitted transactions exist) //Read in type. @@ -2337,8 +2563,7 @@ le_unpack_13(ULE ule, LEAFENTRY_13 le) { //Not innermost, so load the type. uxr->type = *p; p += 1; - } - else { + } else { //Innermost, load the type previously read from header uxr->type = innermost_type; } @@ -2349,12 +2574,11 @@ le_unpack_13(ULE ule, LEAFENTRY_13 le) { //Not committed nor outermost uncommitted, so load the xid. uxr->xid = toku_dtoh64(*(TXNID*)p); p += 8; - } - else if (i == 1) { - //Outermost uncommitted, load the xid previously read from header + } else if (i == 1) { + //Outermost uncommitted, load the xid previously read from + //header uxr->xid = xid_outermost_uncommitted; - } - else { + } else { // i == 0, committed entry uxr->xid = 0; } @@ -2367,9 +2591,9 @@ le_unpack_13(ULE ule, LEAFENTRY_13 le) { uxr->valp = p; p += uxr->vallen; - } - else { - //Innermost insert, load the vallen/valp previously read from header + } else { + //Innermost insert, load the vallen/valp previously read + //from header uxr->vallen = vallen_of_innermost_insert; uxr->valp = valp_of_innermost_insert; found_innermost_insert = true; @@ -2384,8 +2608,7 @@ le_unpack_13(ULE ule, LEAFENTRY_13 le) { #endif } -size_t -leafentry_disksize_13(LEAFENTRY_13 le) { +size_t leafentry_disksize_13(LEAFENTRY_13 le) { ULE_S ule; le_unpack_13(&ule, le); size_t memsize = le_memsize_from_ule_13(&ule, le); @@ -2393,13 +2616,13 @@ leafentry_disksize_13(LEAFENTRY_13 le) { return memsize; } -int -toku_le_upgrade_13_14(LEAFENTRY_13 old_leafentry, - void** keyp, - uint32_t* keylen, - size_t *new_leafentry_memorysize, - LEAFENTRY *new_leafentry_p - ) { +int toku_le_upgrade_13_14( + LEAFENTRY_13 old_leafentry, + void** keyp, + uint32_t* keylen, + size_t* new_leafentry_memorysize, + LEAFENTRY* new_leafentry_p) { + ULE_S ule; int rval; invariant(old_leafentry); @@ -2408,23 +2631,23 @@ toku_le_upgrade_13_14(LEAFENTRY_13 old_leafentry, *keylen = old_leafentry->keylen; if (old_leafentry->num_xrs == 1) { *keyp = old_leafentry->u.comm.key_val; - } - else { + } else { *keyp = old_leafentry->u.prov.key_val_xrs; } // We used to pass NULL for omt and mempool, so that we would use // malloc instead of a mempool. However after supporting upgrade, // we need to use mempools and the OMT. - rval = le_pack(&ule, // create packed leafentry - nullptr, - 0, //only matters if we are passing in a bn_data - nullptr, //only matters if we are passing in a bn_data - 0, //only matters if we are passing in a bn_data - 0, //only matters if we are passing in a bn_data - 0, //only matters if we are passing in a bn_data - new_leafentry_p, - nullptr //only matters if we are passing in a bn_data - ); + rval = + le_pack( + &ule, // create packed leafentry + nullptr, + 0, //only matters if we are passing in a bn_data + nullptr, //only matters if we are passing in a bn_data + 0, //only matters if we are passing in a bn_data + 0, //only matters if we are passing in a bn_data + 0, //only matters if we are passing in a bn_data + new_leafentry_p, + nullptr); //only matters if we are passing in a bn_data ule_cleanup(&ule); *new_leafentry_memorysize = leafentry_memsize(*new_leafentry_p); return rval; diff --git a/storage/tokudb/PerconaFT/ftcxx/tests/CMakeLists.txt b/storage/tokudb/PerconaFT/ftcxx/tests/CMakeLists.txt index 8cea16c914d..6f9146ce5b2 100644 --- a/storage/tokudb/PerconaFT/ftcxx/tests/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/ftcxx/tests/CMakeLists.txt @@ -2,6 +2,8 @@ include_directories(..) include_directories(../../src) include_directories(../../src/tests) +find_library(JEMALLOC_STATIC_LIBRARY libjemalloc.a) + if (BUILD_TESTING) ## reference implementation with simple size-doubling buffer without ## jemalloc size tricks @@ -24,15 +26,15 @@ if (BUILD_TESTING) cursor_test ) set(_testname ${impl}_${test}) - if (with_jemalloc) + if (with_jemalloc AND JEMALLOC_STATIC_LIBRARY) set(_testname ${_testname}_j) endif () add_executable(${_testname} ${test}) - if (with_jemalloc) + if (with_jemalloc AND JEMALLOC_STATIC_LIBRARY) if (APPLE) - target_link_libraries(${_testname} -Wl,-force_load jemalloc) + target_link_libraries(${_testname} -Wl,-force_load ${JEMALLOC_STATIC_LIBRARY}) else () - target_link_libraries(${_testname} -Wl,--whole-archive jemalloc -Wl,--no-whole-archive) + target_link_libraries(${_testname} -Wl,--whole-archive ${JEMALLOC_STATIC_LIBRARY} -Wl,--no-whole-archive) endif () endif () target_link_libraries(${_testname} ${impl}) diff --git a/storage/tokudb/PerconaFT/portability/toku_pthread.h b/storage/tokudb/PerconaFT/portability/toku_pthread.h index 25cf48dfd8c..84c27736201 100644 --- a/storage/tokudb/PerconaFT/portability/toku_pthread.h +++ b/storage/tokudb/PerconaFT/portability/toku_pthread.h @@ -72,15 +72,18 @@ typedef struct toku_mutex_aligned { toku_mutex_t aligned_mutex __attribute__((__aligned__(64))); } toku_mutex_aligned_t; -// Different OSes implement mutexes as different amounts of nested structs. -// C++ will fill out all missing values with zeroes if you provide at least one zero, but it needs the right amount of nesting. -#if defined(__FreeBSD__) -# define ZERO_MUTEX_INITIALIZER {0} -#elif defined(__APPLE__) -# define ZERO_MUTEX_INITIALIZER {{0}} -#else // __linux__, at least -# define ZERO_MUTEX_INITIALIZER {{{0}}} -#endif +// Initializing with {} will fill in a struct with all zeros. +// But you may also need a pragma to suppress the warnings, as follows +// +// #pragma GCC diagnostic push +// #pragma GCC diagnostic ignored "-Wmissing-field-initializers" +// toku_mutex_t foo = ZERO_MUTEX_INITIALIZER; +// #pragma GCC diagnostic pop +// +// In general it will be a lot of busy work to make this codebase compile +// cleanly with -Wmissing-field-initializers + +# define ZERO_MUTEX_INITIALIZER {} #if TOKU_PTHREAD_DEBUG # define TOKU_MUTEX_INITIALIZER { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true } @@ -223,15 +226,9 @@ typedef struct toku_cond { pthread_cond_t pcond; } toku_cond_t; -// Different OSes implement mutexes as different amounts of nested structs. -// C++ will fill out all missing values with zeroes if you provide at least one zero, but it needs the right amount of nesting. -#if defined(__FreeBSD__) -# define ZERO_COND_INITIALIZER {0} -#elif defined(__APPLE__) -# define ZERO_COND_INITIALIZER {{0}} -#else // __linux__, at least -# define ZERO_COND_INITIALIZER {{{0}}} -#endif +// Same considerations as for ZERO_MUTEX_INITIALIZER apply +#define ZERO_COND_INITIALIZER {} + #define TOKU_COND_INITIALIZER {PTHREAD_COND_INITIALIZER} static inline void diff --git a/storage/tokudb/PerconaFT/portability/toku_time.h b/storage/tokudb/PerconaFT/portability/toku_time.h index c476b64a212..11a3f3aa2b9 100644 --- a/storage/tokudb/PerconaFT/portability/toku_time.h +++ b/storage/tokudb/PerconaFT/portability/toku_time.h @@ -108,3 +108,13 @@ static inline uint64_t toku_current_time_microsec(void) { gettimeofday(&t, NULL); return t.tv_sec * (1UL * 1000 * 1000) + t.tv_usec; } + +// sleep microseconds +static inline void toku_sleep_microsec(uint64_t ms) { + struct timeval t; + + t.tv_sec = ms / 1000000; + t.tv_usec = ms % 1000000; + + select(0, NULL, NULL, NULL, &t); +} diff --git a/storage/tokudb/PerconaFT/scripts/run.stress-tests.py b/storage/tokudb/PerconaFT/scripts/run.stress-tests.py index a8df83a3b55..e983fe8ccd9 100644 --- a/storage/tokudb/PerconaFT/scripts/run.stress-tests.py +++ b/storage/tokudb/PerconaFT/scripts/run.stress-tests.py @@ -521,14 +521,16 @@ Test output: })) def send_mail(toaddrs, subject, body): - m = MIMEText(body) - fromaddr = 'tim@tokutek.com' - m['From'] = fromaddr - m['To'] = ', '.join(toaddrs) - m['Subject'] = subject - s = SMTP('192.168.1.114') - s.sendmail(fromaddr, toaddrs, str(m)) - s.quit() + # m = MIMEText(body) + # fromaddr = 'dev-private@percona.com' + # m['From'] = fromaddr + # m['To'] = ', '.join(toaddrs) + # m['Subject'] = subject + # s = SMTP('192.168.1.114') + # s.sendmail(fromaddr, toaddrs, str(m)) + # s.quit() + info(subject); + info(body); def update(tokudb): info('Updating from git.') @@ -554,12 +556,12 @@ def rebuild(tokudb, builddir, tokudb_data, cc, cxx, tests): env=newenv, cwd=builddir) if r != 0: - send_mail(['leif@tokutek.com'], 'Stress tests on %s failed to build.' % gethostname(), '') + send_mail(['dev-private@percona.com'], 'Stress tests on %s failed to build.' % gethostname(), '') error('Building the tests failed.') sys.exit(r) r = call(['make', '-j8'], cwd=builddir) if r != 0: - send_mail(['leif@tokutek.com'], 'Stress tests on %s failed to build.' % gethostname(), '') + send_mail(['dev-private@percona.com'], 'Stress tests on %s failed to build.' % gethostname(), '') error('Building the tests failed.') sys.exit(r) @@ -671,7 +673,7 @@ def main(opts): sys.exit(0) except Exception, e: exception('Unhandled exception caught in main.') - send_mail(['leif@tokutek.com'], 'Stress tests caught unhandled exception in main, on %s' % gethostname(), format_exc()) + send_mail(['dev-private@percona.com'], 'Stress tests caught unhandled exception in main, on %s' % gethostname(), format_exc()) raise e if __name__ == '__main__': @@ -786,7 +788,7 @@ if __name__ == '__main__': if not opts.send_emails: opts.email = None elif len(opts.email) == 0: - opts.email.append('tokueng@tokutek.com') + opts.email.append('dev-private@percona.com') if opts.debug: logging.basicConfig(level=logging.DEBUG) diff --git a/storage/tokudb/PerconaFT/src/export.map b/storage/tokudb/PerconaFT/src/export.map index 3f2c7569ea4..fc2be5f41a5 100644 --- a/storage/tokudb/PerconaFT/src/export.map +++ b/storage/tokudb/PerconaFT/src/export.map @@ -82,6 +82,7 @@ toku_test_db_redirect_dictionary; toku_test_get_latest_lsn; toku_test_get_checkpointing_user_data_status; + toku_set_test_txn_sync_callback; toku_indexer_set_test_only_flags; toku_increase_last_xid; diff --git a/storage/tokudb/PerconaFT/src/indexer-undo-do.cc b/storage/tokudb/PerconaFT/src/indexer-undo-do.cc index b93429407eb..8d0b080b9fe 100644 --- a/storage/tokudb/PerconaFT/src/indexer-undo-do.cc +++ b/storage/tokudb/PerconaFT/src/indexer-undo-do.cc @@ -313,7 +313,7 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info break; if (outermost_xid_state != TOKUTXN_LIVE && xrindex > num_committed) { - // if the outermost is not live, then the inner state must be retired. thats the way that the txn API works. + // If the outermost is not live, then the inner state must be retired. That's the way that the txn API works. assert(this_xid_state == TOKUTXN_RETIRED); } diff --git a/storage/tokudb/PerconaFT/src/tests/CMakeLists.txt b/storage/tokudb/PerconaFT/src/tests/CMakeLists.txt index 70977a9dfda..47f6aa44a75 100644 --- a/storage/tokudb/PerconaFT/src/tests/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/src/tests/CMakeLists.txt @@ -53,7 +53,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS) target_link_libraries(test-5138.tdb ${LIBTOKUDB}_static z ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS}) add_space_separated_property(TARGET test-5138.tdb COMPILE_FLAGS -fvisibility=hidden) add_ydb_test(test-5138.tdb) - + add_ydb_test(rollback-inconsistency.tdb) foreach(bin ${tdb_bins}) get_filename_component(base ${bin} NAME_WE) diff --git a/storage/tokudb/PerconaFT/src/tests/rollback-inconsistency.cc b/storage/tokudb/PerconaFT/src/tests/rollback-inconsistency.cc new file mode 100644 index 00000000000..f8099c7a639 --- /dev/null +++ b/storage/tokudb/PerconaFT/src/tests/rollback-inconsistency.cc @@ -0,0 +1,161 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/*====== +This file is part of PerconaFT. + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PerconaFT. If not, see . + +---------------------------------------- + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with PerconaFT. If not, see . +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "test.h" + +// insert enough rows with a child txn and then force an eviction to verify the rollback +// log node is in valid state. +// the test fails without the fix (and of course passes with it). +// The test basically simulates the test script of George's. + + +static void +populate_table(int start, int end, DB_TXN * parent, DB_ENV * env, DB * db) { + DB_TXN *txn = NULL; + int r = env->txn_begin(env, parent, &txn, 0); assert_zero(r); + for (int i = start; i < end; i++) { + int k = htonl(i); + char kk[4]; + char str[220]; + memset(kk, 0, sizeof kk); + memcpy(kk, &k, sizeof k); + memset(str,'a', sizeof str); + DBT key = { .data = kk, .size = sizeof kk }; + DBT val = { .data = str, .size = sizeof str }; + r = db->put(db, txn, &key, &val, 0); + assert_zero(r); + } + r = txn->commit(txn, 0); + assert_zero(r); +} + +static void +populate_and_test(DB_ENV *env, DB *db) { + int r; + DB_TXN *parent = NULL; + r = env->txn_begin(env, NULL, &parent, 0); assert_zero(r); + + populate_table(0, 128, parent, env, db); + + //we know the eviction is going to happen here and the log node of parent txn is going to be evicted + //due to the extremely low cachesize. + populate_table(128, 256, parent, env, db); + + //again eviction due to the memory pressure. 256 rows is the point when that rollback log spills out. The spilled node + //will be written back but will not be dirtied by including rollback nodes from child txn(in which case the bug is bypassed). + populate_table(256, 512, parent, env, db); + + r = parent->abort(parent); assert_zero(r); + + //try to search anything in the lost range + int k = htonl(200); + char kk[4]; + memset(kk, 0, sizeof kk); + memcpy(kk, &k, sizeof k); + DBT key = { .data = kk, .size = sizeof kk }; + DBT val; + r = db->get(db, NULL, &key, &val, 0); + assert(r==DB_NOTFOUND); + +} + +static void +run_test(void) { + int r; + DB_ENV *env = NULL; + r = db_env_create(&env, 0); + assert_zero(r); + env->set_errfile(env, stderr); + + //setting up the cachetable size 64k + uint32_t cachesize = 64*1024; + r = env->set_cachesize(env, 0, cachesize, 1); + assert_zero(r); + + //setting up the log write block size to 4k so the rollback log nodes spill in accordance with the node size + r = env->set_lg_bsize(env, 4096); + assert_zero(r); + + r = env->open(env, TOKU_TEST_FILENAME, DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); + assert_zero(r); + + DB *db = NULL; + r = db_create(&db, env, 0); + assert_zero(r); + + r = db->set_pagesize(db, 4096); + assert_zero(r); + + r = db->set_readpagesize(db, 1024); + assert_zero(r); + + r = db->open(db, NULL, "test.tdb", NULL, DB_BTREE, DB_AUTO_COMMIT+DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); + assert_zero(r); + + populate_and_test(env, db); + + r = db->close(db, 0); assert_zero(r); + + r = env->close(env, 0); assert_zero(r); +} + +int +test_main(int argc, char * const argv[]) { + int r; + + // parse_args(argc, argv); + for (int i = 1; i < argc; i++) { + char * const arg = argv[i]; + if (strcmp(arg, "-v") == 0) { + verbose++; + continue; + } + if (strcmp(arg, "-q") == 0) { + verbose = 0; + continue; + } + } + + toku_os_recursive_delete(TOKU_TEST_FILENAME); + r = toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert_zero(r); + + run_test(); + + return 0; +} + diff --git a/storage/tokudb/PerconaFT/src/tests/stat64-root-changes.cc b/storage/tokudb/PerconaFT/src/tests/stat64-root-changes.cc index 0c70b0669ad..a2b48e443cd 100644 --- a/storage/tokudb/PerconaFT/src/tests/stat64-root-changes.cc +++ b/storage/tokudb/PerconaFT/src/tests/stat64-root-changes.cc @@ -166,7 +166,7 @@ run_test (void) { DB_BTREE_STAT64 s; r = db->stat64(db, NULL, &s); CKERR(r); - assert(s.bt_nkeys == 1 && s.bt_dsize == sizeof key + sizeof val); + assert(s.bt_nkeys == 0); r = db->close(db, 0); CKERR(r); @@ -176,7 +176,7 @@ run_test (void) { r = txn->commit(txn, 0); CKERR(r); r = db->stat64(db, NULL, &s); CKERR(r); - assert(s.bt_nkeys == 1 && s.bt_dsize == sizeof key + sizeof val); + assert(s.bt_nkeys == 0); } // verify update callback overwrites the row diff --git a/storage/tokudb/PerconaFT/src/tests/test_db_rowcount.cc b/storage/tokudb/PerconaFT/src/tests/test_db_rowcount.cc new file mode 100644 index 00000000000..c440bdc59e7 --- /dev/null +++ b/storage/tokudb/PerconaFT/src/tests/test_db_rowcount.cc @@ -0,0 +1,523 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/*====== +This file is part of PerconaFT. + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PerconaFT. If not, see . + +---------------------------------------- + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with PerconaFT. If not, see . +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "test.h" +#include + +#include +#include + +// Tests that the logical row counts are correct and not subject to variance +// due to normal insert/delete messages within the tree with the few exceptions +// of 1) rollback messages not yet applied; 2) inserts messages turned to +// updates on apply; and 3) missing leafentries on delete messages on apply. + +static DB_TXN* const null_txn = 0; +static const uint64_t num_records = 4*1024; + +#define CHECK_NUM_ROWS(_expected, _stats) assert(_stats.bt_ndata == _expected) + +static DB* create_db(const char* fname, DB_ENV* env) { + int r; + DB* db; + + r = db_create(&db, env, 0); + assert(r == 0); + db->set_errfile(db, stderr); + + r = db->set_pagesize(db, 8192); + assert(r == 0); + + r = db->set_readpagesize(db, 1024); + assert(r == 0); + + r = db->set_fanout(db, 4); + assert(r == 0); + + r = db->set_compression_method(db, TOKU_NO_COMPRESSION); + assert(r == 0); + + r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, + 0666); + assert(r == 0); + + return db; +} +static void add_records(DB* db, DB_TXN* txn, uint64_t start_id, uint64_t num) { + int r; + for (uint64_t i = 0, j=start_id; i < num; i++,j++) { + char key[100], val[256]; + DBT k,v; + snprintf(key, 100, "%08" PRIu64, j); + snprintf(val, 256, "%*s", 200, key); + r = + db->put( + db, + txn, + dbt_init(&k, key, 1+strlen(key)), + dbt_init(&v, val, 1+strlen(val)), + 0); + assert(r == 0); + } +} +static void delete_records( + DB* db, + DB_TXN* txn, + uint64_t start_id, + uint64_t num) { + + int r; + for (uint64_t i = 0, j=start_id; i < num; i++,j++) { + char key[100]; + DBT k; + snprintf(key, 100, "%08" PRIu64, j); + r = + db->del( + db, + txn, + dbt_init(&k, key, 1+strlen(key)), + 0); + assert(r == 0); + } +} +static void full_optimize(DB* db) { + int r; + uint64_t loops_run = 0; + + r = db->optimize(db); + assert(r == 0); + + r = db->hot_optimize(db, NULL, NULL, NULL, NULL, &loops_run); + assert(r == 0); +} +static void test_insert_commit(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf("%s : before commit %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + r = txn->commit(txn, 0); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf("%s : after commit %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + db->close(db, 0); +} +static void test_insert_delete_commit(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf("%s : before delete %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + delete_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf("%s : after delete %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + r = txn->commit(txn, 0); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf("%s : after commit %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + db->close(db, 0); +} +static void test_insert_commit_delete_commit(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf( + "%s : before insert commit %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + r = txn->commit(txn, 0); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf( + "%s : after insert commit %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + delete_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf("%s : after delete %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + r = txn->commit(txn, 0); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf( + "%s : after delete commit %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + db->close(db, 0); +} +static void test_insert_rollback(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf("%s : before rollback %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + r = txn->abort(txn); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + // CAN NOT TEST stats HERE AS THEY ARE SOMEWHAT NON_DETERMINISTIC UNTIL + // optimize + hot_optimize HAVE BEEN RUN DUE TO THE FACT THAT ROLLBACK + // MESSAGES ARE "IN-FLIGHT" IN THE TREE AND MUST BE APPLIED IN ORDER TO + // CORRECT THE RUNNING LOGICAL COUNT + if (verbose) + printf("%s : after rollback %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + full_optimize(db); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf( + "%s : after rollback optimize %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + db->close(db, 0); +} +static void test_insert_delete_rollback(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf("%s : before delete %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + delete_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf("%s : after delete %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + r = txn->abort(txn); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf("%s : after commit %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + db->close(db, 0); +} +static void test_insert_commit_delete_rollback(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf( + "%s : before insert commit %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + r = txn->commit(txn, 0); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf( + "%s : after insert commit %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + delete_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(0, stats); + if (verbose) + printf("%s : after delete %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + r = txn->abort(txn); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + // CAN NOT TEST stats HERE AS THEY ARE SOMEWHAT NON_DETERMINISTIC UNTIL + // optimize + hot_optimize HAVE BEEN RUN DUE TO THE FACT THAT ROLLBACK + // MESSAGES ARE "IN-FLIGHT" IN THE TREE AND MUST BE APPLIED IN ORDER TO + // CORRECT THE RUNNING LOGICAL COUNT + if (verbose) + printf( + "%s : after delete rollback %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + full_optimize(db); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf( + "%s : after delete rollback optimize %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + db->close(db, 0); +} + +static int test_recount_insert_commit_progress( + uint64_t count, + uint64_t deleted, + void*) { + + if (verbose) + printf( + "%s : count[%" PRIu64 "] deleted[%" PRIu64 "]\n", + __FUNCTION__, + count, + deleted); + return 0; +} +static int test_recount_cancel_progress(uint64_t, uint64_t, void*) { + return 1; +} + +static void test_recount_insert_commit(DB_ENV* env) { + int r; + DB* db; + DB_TXN* txn; + DB_BTREE_STAT64 stats; + + db = create_db(__FUNCTION__, env); + + r = env->txn_begin(env, null_txn, &txn, 0); + assert(r == 0); + + add_records(db, txn, 0, num_records); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf( + "%s : before commit %" PRIu64 " rows\n", + __FUNCTION__, + stats.bt_ndata); + + r = txn->commit(txn, 0); + assert(r == 0); + + r = db->stat64(db, null_txn, &stats); + assert(r == 0); + + CHECK_NUM_ROWS(num_records, stats); + if (verbose) + printf("%s : after commit %" PRIu64 " rows\n", __FUNCTION__, stats.bt_ndata); + + // test that recount counted correct # of rows + r = db->recount_rows(db, test_recount_insert_commit_progress, NULL); + assert(r == 0); + CHECK_NUM_ROWS(num_records, stats); + + // test that recount callback cancel returns + r = db->recount_rows(db, test_recount_cancel_progress, NULL); + assert(r == 1); + CHECK_NUM_ROWS(num_records, stats); + + db->close(db, 0); +} +int test_main(int UU(argc), char UU(*const argv[])) { + int r; + DB_ENV* env; + + toku_os_recursive_delete(TOKU_TEST_FILENAME); + toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU + S_IRWXG + S_IRWXO); + + r = db_env_create(&env, 0); + assert(r == 0); + + r = + env->open( + env, + TOKU_TEST_FILENAME, + DB_INIT_MPOOL + DB_INIT_LOG + DB_INIT_TXN + DB_PRIVATE + DB_CREATE, + S_IRWXU + S_IRWXG + S_IRWXO); + assert(r == 0); + + test_insert_commit(env); + test_insert_delete_commit(env); + test_insert_commit_delete_commit(env); + test_insert_rollback(env); + test_insert_delete_rollback(env); + test_insert_commit_delete_rollback(env); + test_recount_insert_commit(env); + + r = env->close(env, 0); + assert(r == 0); + + return 0; +} diff --git a/storage/tokudb/PerconaFT/src/tests/txn_manager_handle_snapshot_atomicity.cc b/storage/tokudb/PerconaFT/src/tests/txn_manager_handle_snapshot_atomicity.cc new file mode 100644 index 00000000000..30cc16d73a7 --- /dev/null +++ b/storage/tokudb/PerconaFT/src/tests/txn_manager_handle_snapshot_atomicity.cc @@ -0,0 +1,217 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/*====== +This file is part of PerconaFT. + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PerconaFT. If not, see . + +---------------------------------------- + + PerconaFT is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License, version 3, + as published by the Free Software Foundation. + + PerconaFT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with PerconaFT. If not, see . +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +//In response to the read-commit crash bug in the sysbench, this test is created to test +//the atomicity of the txn manager when handling the child txn snapshot. +//The test is supposed to fail before the read-commit-fix. + +#include "test.h" +#include "toku_pthread.h" +#include "ydb.h" +struct test_sync { + int state; + toku_mutex_t lock; + toku_cond_t cv; +}; + +static void test_sync_init(struct test_sync *UU(sync)) { +#if TOKU_DEBUG_TXN_SYNC + sync->state = 0; + toku_mutex_init(&sync->lock, NULL); + toku_cond_init(&sync->cv, NULL); +#endif +} + +static void test_sync_destroy(struct test_sync *UU(sync)) { +#if TOKU_DEBUG_TXN_SYNC + toku_mutex_destroy(&sync->lock); + toku_cond_destroy(&sync->cv); +#endif +} + +static void test_sync_sleep(struct test_sync *UU(sync), int UU(new_state)) { +#if TOKU_DEBUG_TXN_SYNC + toku_mutex_lock(&sync->lock); + while (sync->state != new_state) { + toku_cond_wait(&sync->cv, &sync->lock); + } + toku_mutex_unlock(&sync->lock); +#endif +} + +static void test_sync_next_state(struct test_sync *UU(sync)) { +#if TOKU_DEBUG_TXN_SYNC + toku_mutex_lock(&sync->lock); + sync->state++; + toku_cond_broadcast(&sync->cv); + toku_mutex_unlock(&sync->lock); +#endif +} + + +struct start_txn_arg { + DB_ENV *env; + DB *db; + DB_TXN * parent; +}; + +static struct test_sync sync_s; + +static void test_callback(pthread_t self_tid, void * extra) { + pthread_t **p = (pthread_t **) extra; + pthread_t tid_1 = *p[0]; + pthread_t tid_2 = *p[1]; + assert(pthread_equal(self_tid, tid_2)); + printf("%s: the thread[%" PRIu64 "] is going to wait...\n", __func__, reinterpret_cast(tid_1)); + test_sync_next_state(&sync_s); + sleep(3); + //test_sync_sleep(&sync_s,3); + //using test_sync_sleep/test_sync_next_state pair can sync threads better, however + //after the fix, this might cause a deadlock. just simply use sleep to do a proof- + //of-concept test. + printf("%s: the thread[%" PRIu64 "] is resuming...\n", __func__, reinterpret_cast(tid_1)); + return; +} + +static void * start_txn2(void * extra) { + struct start_txn_arg * args = (struct start_txn_arg *) extra; + DB_ENV * env = args -> env; + DB * db = args->db; + DB_TXN * parent = args->parent; + test_sync_sleep(&sync_s, 1); + printf("start %s [thread %" PRIu64 "]\n", __func__, reinterpret_cast(pthread_self())); + DB_TXN *txn; + int r = env->txn_begin(env, parent, &txn, DB_READ_COMMITTED); + assert(r == 0); + //do some random things... + DBT key, data; + dbt_init(&key, "hello", 6); + dbt_init(&data, "world", 6); + db->put(db, txn, &key, &data, 0); + db->get(db, txn, &key, &data, 0); + + r = txn->commit(txn, 0); + assert(r == 0); + printf("%s done[thread %" PRIu64 "]\n", __func__, reinterpret_cast(pthread_self())); + return extra; +} + +static void * start_txn1(void * extra) { + struct start_txn_arg * args = (struct start_txn_arg *) extra; + DB_ENV * env = args -> env; + DB * db = args->db; + printf("start %s: [thread %" PRIu64 "]\n", __func__, reinterpret_cast(pthread_self())); + DB_TXN *txn; + int r = env->txn_begin(env, NULL, &txn, DB_READ_COMMITTED); + assert(r == 0); + printf("%s: txn began by [thread %" PRIu64 "], will wait\n", __func__, reinterpret_cast(pthread_self())); + test_sync_next_state(&sync_s); + test_sync_sleep(&sync_s,2); + printf("%s: [thread %" PRIu64 "] resumed\n", __func__, reinterpret_cast(pthread_self())); + //do some random things... + DBT key, data; + dbt_init(&key, "hello", 6); + dbt_init(&data, "world", 6); + db->put(db, txn, &key, &data, 0); + db->get(db, txn, &key, &data, 0); + r = txn->commit(txn, 0); + assert(r == 0); + printf("%s: done[thread %" PRIu64 "]\n", __func__, reinterpret_cast(pthread_self())); + //test_sync_next_state(&sync_s); + return extra; +} + +int test_main (int UU(argc), char * const UU(argv[])) { + int r; + toku_os_recursive_delete(TOKU_TEST_FILENAME); + r = toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); + assert(r == 0); + + DB_ENV *env; + r = db_env_create(&env, 0); + assert(r == 0); + + r = env->open(env, TOKU_TEST_FILENAME, DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); + assert(r == 0); + + DB *db = NULL; + r = db_create(&db, env, 0); + assert(r == 0); + + r = db->open(db, NULL, "testit", NULL, DB_BTREE, DB_AUTO_COMMIT+DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); + assert(r == 0); + + DB_TXN * parent = NULL; + r = env->txn_begin(env, 0, &parent, DB_READ_COMMITTED); + assert(r == 0); + + ZERO_STRUCT(sync_s); + test_sync_init(&sync_s); + + pthread_t tid_1 = 0; + pthread_t tid_2 = 0; + pthread_t* callback_extra[2] = {&tid_1, &tid_2}; + toku_set_test_txn_sync_callback(test_callback, callback_extra); + + struct start_txn_arg args = {env, db, parent}; + + r = pthread_create(&tid_1, NULL, start_txn1, &args); + assert(r==0); + + r= pthread_create(&tid_2, NULL, start_txn2, &args); + assert(r==0); + + void * ret; + r = pthread_join(tid_1, &ret); + assert(r == 0); + r = pthread_join(tid_2, &ret); + assert(r == 0); + + r = parent->commit(parent, 0); + assert(r ==0); + + test_sync_destroy(&sync_s); + r = db->close(db, 0); + assert(r == 0); + + r = env->close(env, 0); + assert(r == 0); + + return 0; +} + diff --git a/storage/tokudb/PerconaFT/src/ydb-internal.h b/storage/tokudb/PerconaFT/src/ydb-internal.h index 3737a1caf99..462a2a3d861 100644 --- a/storage/tokudb/PerconaFT/src/ydb-internal.h +++ b/storage/tokudb/PerconaFT/src/ydb-internal.h @@ -132,6 +132,7 @@ struct __toku_db_env_internal { int datadir_lockfd; int logdir_lockfd; int tmpdir_lockfd; + bool check_thp; // if set check if transparent huge pages are disables uint64_t (*get_loader_memory_size_callback)(void); uint64_t default_lock_timeout_msec; uint64_t (*get_lock_timeout_callback)(uint64_t default_lock_timeout_msec); diff --git a/storage/tokudb/PerconaFT/src/ydb.cc b/storage/tokudb/PerconaFT/src/ydb.cc index 88c6c86f214..aed271bce40 100644 --- a/storage/tokudb/PerconaFT/src/ydb.cc +++ b/storage/tokudb/PerconaFT/src/ydb.cc @@ -623,32 +623,39 @@ ydb_recover_log_exists(DB_ENV *env) { } // Validate that all required files are present, no side effects. -// Return 0 if all is well, ENOENT if some files are present but at least one is missing, +// Return 0 if all is well, ENOENT if some files are present but at least one is +// missing, // other non-zero value if some other error occurs. // Set *valid_newenv if creating a new environment (all files missing). -// (Note, if special dictionaries exist, then they were created transactionally and log should exist.) -static int -validate_env(DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) { +// (Note, if special dictionaries exist, then they were created transactionally +// and log should exist.) +static int validate_env(DB_ENV *env, + bool *valid_newenv, + bool need_rollback_cachefile) { int r; - bool expect_newenv = false; // set true if we expect to create a new env + bool expect_newenv = false; // set true if we expect to create a new env toku_struct_stat buf; - char* path = NULL; + char *path = NULL; // Test for persistent environment - path = toku_construct_full_name(2, env->i->dir, toku_product_name_strings.environmentdictionary); + path = toku_construct_full_name( + 2, env->i->dir, toku_product_name_strings.environmentdictionary); assert(path); r = toku_stat(path, &buf); if (r == 0) { expect_newenv = false; // persistent info exists - } - else { + } else { int stat_errno = get_error_errno(); if (stat_errno == ENOENT) { expect_newenv = true; r = 0; - } - else { - r = toku_ydb_do_error(env, stat_errno, "Unable to access persistent environment\n"); + } else { + r = toku_ydb_do_error( + env, + stat_errno, + "Unable to access persistent environment [%s] in [%s]\n", + toku_product_name_strings.environmentdictionary, + env->i->dir); assert(r); } } @@ -656,23 +663,40 @@ validate_env(DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) { // Test for existence of rollback cachefile if it is expected to exist if (r == 0 && need_rollback_cachefile) { - path = toku_construct_full_name(2, env->i->dir, toku_product_name_strings.rollback_cachefile); + path = toku_construct_full_name( + 2, env->i->dir, toku_product_name_strings.rollback_cachefile); assert(path); r = toku_stat(path, &buf); - if (r == 0) { - if (expect_newenv) // rollback cachefile exists, but persistent env is missing - r = toku_ydb_do_error(env, ENOENT, "Persistent environment is missing\n"); - } - else { + if (r == 0) { + if (expect_newenv) // rollback cachefile exists, but persistent env + // is missing + r = toku_ydb_do_error( + env, + ENOENT, + "Persistent environment is missing while looking for " + "rollback cachefile [%s] in [%s]\n", + toku_product_name_strings.rollback_cachefile, env->i->dir); + } else { int stat_errno = get_error_errno(); if (stat_errno == ENOENT) { - if (!expect_newenv) // rollback cachefile is missing but persistent env exists - r = toku_ydb_do_error(env, ENOENT, "rollback cachefile directory is missing\n"); - else - r = 0; // both rollback cachefile and persistent env are missing - } - else { - r = toku_ydb_do_error(env, stat_errno, "Unable to access rollback cachefile\n"); + if (!expect_newenv) // rollback cachefile is missing but + // persistent env exists + r = toku_ydb_do_error( + env, + ENOENT, + "rollback cachefile [%s] is missing from [%s]\n", + toku_product_name_strings.rollback_cachefile, + env->i->dir); + else + r = 0; // both rollback cachefile and persistent env are + // missing + } else { + r = toku_ydb_do_error( + env, + stat_errno, + "Unable to access rollback cachefile [%s] in [%s]\n", + toku_product_name_strings.rollback_cachefile, + env->i->dir); assert(r); } } @@ -681,23 +705,41 @@ validate_env(DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) { // Test for fileops directory if (r == 0) { - path = toku_construct_full_name(2, env->i->dir, toku_product_name_strings.fileopsdirectory); + path = toku_construct_full_name( + 2, env->i->dir, toku_product_name_strings.fileopsdirectory); assert(path); r = toku_stat(path, &buf); - if (r == 0) { - if (expect_newenv) // fileops directory exists, but persistent env is missing - r = toku_ydb_do_error(env, ENOENT, "Persistent environment is missing\n"); - } - else { + if (r == 0) { + if (expect_newenv) // fileops directory exists, but persistent env + // is missing + r = toku_ydb_do_error( + env, + ENOENT, + "Persistent environment is missing while looking for " + "fileops directory [%s] in [%s]\n", + toku_product_name_strings.fileopsdirectory, + env->i->dir); + } else { int stat_errno = get_error_errno(); if (stat_errno == ENOENT) { - if (!expect_newenv) // fileops directory is missing but persistent env exists - r = toku_ydb_do_error(env, ENOENT, "Fileops directory is missing\n"); - else - r = 0; // both fileops directory and persistent env are missing - } - else { - r = toku_ydb_do_error(env, stat_errno, "Unable to access fileops directory\n"); + if (!expect_newenv) // fileops directory is missing but + // persistent env exists + r = toku_ydb_do_error( + env, + ENOENT, + "Fileops directory [%s] is missing from [%s]\n", + toku_product_name_strings.fileopsdirectory, + env->i->dir); + else + r = 0; // both fileops directory and persistent env are + // missing + } else { + r = toku_ydb_do_error( + env, + stat_errno, + "Unable to access fileops directory [%s] in [%s]\n", + toku_product_name_strings.fileopsdirectory, + env->i->dir); assert(r); } } @@ -709,16 +751,26 @@ validate_env(DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) { // if using transactions, test for existence of log r = ydb_recover_log_exists(env); // return 0 or ENOENT if (expect_newenv && (r != ENOENT)) - r = toku_ydb_do_error(env, ENOENT, "Persistent environment information is missing (but log exists)\n"); + r = toku_ydb_do_error(env, + ENOENT, + "Persistent environment information is " + "missing (but log exists) while looking for " + "recovery log files in [%s]\n", + env->i->real_log_dir); else if (!expect_newenv && r == ENOENT) - r = toku_ydb_do_error(env, ENOENT, "Recovery log is missing (persistent environment information is present)\n"); + r = toku_ydb_do_error(env, + ENOENT, + "Recovery log is missing (persistent " + "environment information is present) while " + "looking for recovery log files in [%s]\n", + env->i->real_log_dir); else r = 0; } if (r == 0) *valid_newenv = expect_newenv; - else + else *valid_newenv = false; return r; } @@ -768,7 +820,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) { goto cleanup; } - if (toku_os_huge_pages_enabled()) { + if (env->get_check_thp(env) && toku_os_huge_pages_enabled()) { r = toku_ydb_do_error(env, TOKUDB_HUGE_PAGES_ENABLED, "Huge pages are enabled, disable them before continuing\n"); goto cleanup; @@ -1234,6 +1286,18 @@ env_set_checkpoint_pool_threads(DB_ENV * env, uint32_t threads) { return 0; } +static void +env_set_check_thp(DB_ENV * env, bool new_val) { + assert(env); + env->i->check_thp = new_val; +} + +static bool +env_get_check_thp(DB_ENV * env) { + assert(env); + return env->i->check_thp; +} + static int env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbname, uint32_t flags); static int @@ -2634,6 +2698,8 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) { USENV(get_loader_memory_size); USENV(set_killed_callback); USENV(do_backtrace); + USENV(set_check_thp); + USENV(get_check_thp); #undef USENV // unlocked methods @@ -2659,6 +2725,8 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) { env_fs_init(result); env_fsync_log_init(result); + result->i->check_thp = true; + result->i->bt_compare = toku_builtin_compare_fun; r = toku_logger_create(&result->i->logger); @@ -3148,6 +3216,10 @@ toku_test_get_latest_lsn(DB_ENV *env) { return rval.lsn; } +void toku_set_test_txn_sync_callback(void (* cb) (pthread_t, void *), void * extra) { + set_test_txn_sync_callback(cb, extra); +} + int toku_test_get_checkpointing_user_data_status (void) { return toku_cachetable_get_checkpointing_user_data_status(); diff --git a/storage/tokudb/PerconaFT/src/ydb.h b/storage/tokudb/PerconaFT/src/ydb.h index 9d4e94c6f30..facbfdc9252 100644 --- a/storage/tokudb/PerconaFT/src/ydb.h +++ b/storage/tokudb/PerconaFT/src/ydb.h @@ -58,3 +58,6 @@ extern "C" uint64_t toku_test_get_latest_lsn(DB_ENV *env) __attribute__((__visib // test-only function extern "C" int toku_test_get_checkpointing_user_data_status(void) __attribute__((__visibility__("default"))); + +// test-only function +extern "C" void toku_set_test_txn_sync_callback(void (* ) (pthread_t, void *), void * extra) __attribute__((__visibility__("default"))); diff --git a/storage/tokudb/PerconaFT/src/ydb_db.cc b/storage/tokudb/PerconaFT/src/ydb_db.cc index 25b24467684..e5bd4e7d089 100644 --- a/storage/tokudb/PerconaFT/src/ydb_db.cc +++ b/storage/tokudb/PerconaFT/src/ydb_db.cc @@ -1015,6 +1015,25 @@ toku_db_verify_with_progress(DB *db, int (*progress_callback)(void *extra, float return r; } + +static int +toku_db_recount_rows(DB* db, int (*progress_callback)(uint64_t count, + uint64_t deleted, + void* progress_extra), + void* progress_extra) { + + HANDLE_PANICKED_DB(db); + int r = 0; + r = + toku_ft_recount_rows( + db->i->ft_handle, + progress_callback, + progress_extra); + + return r; +} + + int toku_setup_db_internal (DB **dbp, DB_ENV *env, uint32_t flags, FT_HANDLE ft_handle, bool is_open) { if (flags || env == NULL) return EINVAL; @@ -1098,6 +1117,7 @@ toku_db_create(DB ** db, DB_ENV * env, uint32_t flags) { USDB(dbt_pos_infty); USDB(dbt_neg_infty); USDB(get_fragmentation); + USDB(recount_rows); #undef USDB result->get_indexer = db_get_indexer; result->del = autotxn_db_del; diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 6ff879c9f1a..672ae32f80a 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -23,60 +23,31 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include -extern "C" { -#include "stdint.h" -#define __STDC_FORMAT_MACROS -#include "inttypes.h" -#if defined(_WIN32) -#include "misc.h" -#endif -} - -#define MYSQL_SERVER 1 -#include "mysql_version.h" -#include "sql_table.h" -#include "handler.h" -#include "table.h" -#include "log.h" -#include "sql_class.h" -#include "sql_show.h" -#include "discover.h" - -#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || (50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799) -#include -#endif - -#include "db.h" -#include "toku_os.h" -#include "hatoku_defines.h" +#include "hatoku_hton.h" #include "hatoku_cmp.h" - -static inline uint get_key_parts(const KEY *key); - -#undef PACKAGE -#undef VERSION -#undef HAVE_DTRACE -#undef _DTRACE_VERSION - -/* We define DTRACE after mysql_priv.h in case it disabled dtrace in the main server */ -#ifdef HAVE_DTRACE -#define _DTRACE_VERSION 1 -#else -#endif - #include "tokudb_buffer.h" #include "tokudb_status.h" #include "tokudb_card.h" #include "ha_tokudb.h" -#include "hatoku_hton.h" -#include -static const char *ha_tokudb_exts[] = { + +#if TOKU_INCLUDE_EXTENDED_KEYS +static inline uint get_ext_key_parts(const KEY *key) { +#if (50609 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \ + (50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799) + return key->actual_key_parts; +#elif defined(MARIADB_BASE_VERSION) + return key->ext_key_parts; +#else +#error +#endif +} +#endif + +HASH TOKUDB_SHARE::_open_tables; +tokudb::thread::mutex_t TOKUDB_SHARE::_open_tables_mutex; + +static const char* ha_tokudb_exts[] = { ha_tokudb_ext, NullS }; @@ -84,10 +55,15 @@ static const char *ha_tokudb_exts[] = { // // This offset is calculated starting from AFTER the NULL bytes // -static inline uint32_t get_fixed_field_size(KEY_AND_COL_INFO* kc_info, TABLE_SHARE* table_share, uint keynr) { +static inline uint32_t get_fixed_field_size( + KEY_AND_COL_INFO* kc_info, + TABLE_SHARE* table_share, + uint keynr) { + uint offset = 0; for (uint i = 0; i < table_share->fields; i++) { - if (is_fixed_field(kc_info, i) && !bitmap_is_set(&kc_info->key_filters[keynr],i)) { + if (is_fixed_field(kc_info, i) && + !bitmap_is_set(&kc_info->key_filters[keynr], i)) { offset += kc_info->field_lengths[i]; } } @@ -95,10 +71,15 @@ static inline uint32_t get_fixed_field_size(KEY_AND_COL_INFO* kc_info, TABLE_SHA } -static inline uint32_t get_len_of_offsets(KEY_AND_COL_INFO* kc_info, TABLE_SHARE* table_share, uint keynr) { +static inline uint32_t get_len_of_offsets( + KEY_AND_COL_INFO* kc_info, + TABLE_SHARE* table_share, + uint keynr) { + uint len = 0; for (uint i = 0; i < table_share->fields; i++) { - if (is_variable_field(kc_info, i) && !bitmap_is_set(&kc_info->key_filters[keynr],i)) { + if (is_variable_field(kc_info, i) && + !bitmap_is_set(&kc_info->key_filters[keynr], i)) { len += kc_info->num_offset_bytes; } } @@ -106,32 +87,36 @@ static inline uint32_t get_len_of_offsets(KEY_AND_COL_INFO* kc_info, TABLE_SHARE } -static int allocate_key_and_col_info ( TABLE_SHARE* table_share, KEY_AND_COL_INFO* kc_info) { +static int allocate_key_and_col_info( + TABLE_SHARE* table_share, + KEY_AND_COL_INFO* kc_info) { + int error; // // initialize all of the bitmaps // for (uint i = 0; i < MAX_KEY + 1; i++) { - error = bitmap_init( - &kc_info->key_filters[i], - NULL, - table_share->fields, - false - ); + error = + bitmap_init( + &kc_info->key_filters[i], + NULL, + table_share->fields, + false); if (error) { goto exit; } } - + // // create the field lengths // - kc_info->multi_ptr = tokudb_my_multi_malloc(MYF(MY_WME+MY_ZEROFILL), - &kc_info->field_types, (uint)(table_share->fields * sizeof (uint8_t)), - &kc_info->field_lengths, (uint)(table_share->fields * sizeof (uint16_t)), - &kc_info->length_bytes, (uint)(table_share->fields * sizeof (uint8_t)), - &kc_info->blob_fields, (uint)(table_share->fields * sizeof (uint32_t)), - NullS); + kc_info->multi_ptr = tokudb::memory::multi_malloc( + MYF(MY_WME+MY_ZEROFILL), + &kc_info->field_types, (uint)(table_share->fields * sizeof (uint8_t)), + &kc_info->field_lengths, (uint)(table_share->fields * sizeof (uint16_t)), + &kc_info->length_bytes, (uint)(table_share->fields * sizeof (uint8_t)), + &kc_info->blob_fields, (uint)(table_share->fields * sizeof (uint32_t)), + NullS); if (kc_info->multi_ptr == NULL) { error = ENOMEM; goto exit; @@ -141,7 +126,7 @@ exit: for (uint i = 0; MAX_KEY + 1; i++) { bitmap_free(&kc_info->key_filters[i]); } - tokudb_my_free(kc_info->multi_ptr); + tokudb::memory::free(kc_info->multi_ptr); } return error; } @@ -150,136 +135,306 @@ static void free_key_and_col_info (KEY_AND_COL_INFO* kc_info) { for (uint i = 0; i < MAX_KEY+1; i++) { bitmap_free(&kc_info->key_filters[i]); } - + for (uint i = 0; i < MAX_KEY+1; i++) { - tokudb_my_free(kc_info->cp_info[i]); + tokudb::memory::free(kc_info->cp_info[i]); kc_info->cp_info[i] = NULL; // 3144 } - tokudb_my_free(kc_info->multi_ptr); + tokudb::memory::free(kc_info->multi_ptr); kc_info->field_types = NULL; kc_info->field_lengths = NULL; kc_info->length_bytes = NULL; kc_info->blob_fields = NULL; } -void TOKUDB_SHARE::init(void) { - use_count = 0; - thr_lock_init(&lock); - tokudb_pthread_mutex_init(&mutex, MY_MUTEX_INIT_FAST); - my_rwlock_init(&num_DBs_lock, 0); - tokudb_pthread_cond_init(&m_openclose_cond, NULL); - m_state = CLOSED; -} -void TOKUDB_SHARE::destroy(void) { - assert(m_state == CLOSED); - thr_lock_delete(&lock); - tokudb_pthread_mutex_destroy(&mutex); - rwlock_destroy(&num_DBs_lock); - tokudb_pthread_cond_destroy(&m_openclose_cond); - tokudb_my_free(rec_per_key); - rec_per_key = NULL; -} +uchar* TOKUDB_SHARE::hash_get_key( + TOKUDB_SHARE* share, + size_t* length, + TOKUDB_UNUSED(my_bool not_used)) { -// MUST have tokudb_mutex locked on input -static TOKUDB_SHARE *get_share(const char *table_name, TABLE_SHARE* table_share) { - TOKUDB_SHARE *share = NULL; + *length = share->_full_table_name.length(); + return (uchar *) share->_full_table_name.c_ptr(); +} +void TOKUDB_SHARE::hash_free_element(TOKUDB_SHARE* share) { + share->destroy(); + delete share; +} +void TOKUDB_SHARE::static_init() { + my_hash_init( + &_open_tables, + table_alias_charset, + 32, + 0, + 0, + (my_hash_get_key)hash_get_key, + (my_hash_free_key)hash_free_element, 0); +} +void TOKUDB_SHARE::static_destroy() { + my_hash_free(&_open_tables); +} +const char* TOKUDB_SHARE::get_state_string(share_state_t state) { + static const char* state_string[] = { + "CLOSED", + "OPENED", + "ERROR" + }; + assert_always(state == CLOSED || state == OPENED || state == ERROR); + return state_string[state]; +} +void* TOKUDB_SHARE::operator new(size_t sz) { + return tokudb::memory::malloc(sz, MYF(MY_WME|MY_ZEROFILL|MY_FAE)); +} +void TOKUDB_SHARE::operator delete(void* p) { + tokudb::memory::free(p); +} +TOKUDB_SHARE::TOKUDB_SHARE() : + _num_DBs_lock(), + _mutex() { +} +void TOKUDB_SHARE::init(const char* table_name) { + _use_count = 0; + thr_lock_init(&_thr_lock); + _state = CLOSED; + _row_delta_activity = 0; + _allow_auto_analysis = true; + + _full_table_name.append(table_name); + + String tmp_dictionary_name; + tokudb_split_dname( + table_name, + _database_name, + _table_name, + tmp_dictionary_name); + + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count); + TOKUDB_SHARE_DBUG_VOID_RETURN(); +} +void TOKUDB_SHARE::destroy() { + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count); + + assert_always(_use_count == 0); + assert_always( + _state == TOKUDB_SHARE::CLOSED || _state == TOKUDB_SHARE::ERROR); + thr_lock_delete(&_thr_lock); + TOKUDB_SHARE_DBUG_VOID_RETURN(); +} +TOKUDB_SHARE* TOKUDB_SHARE::get_share( + const char* table_name, + TABLE_SHARE* table_share, + THR_LOCK_DATA* data, + bool create_new) { + + _open_tables_mutex.lock(); int error = 0; uint length = (uint) strlen(table_name); - if (!(share = (TOKUDB_SHARE *) my_hash_search(&tokudb_open_tables, (uchar *) table_name, length))) { - char *tmp_name; + TOKUDB_SHARE* share = + (TOKUDB_SHARE*)my_hash_search( + &_open_tables, + (uchar*)table_name, + length); + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_SHARE, + "existing share[%s] %s:share[%p]", + table_name, + share == NULL ? "not found" : "found", + share); + + if (!share) { + if (create_new == false) + goto exit; // create share and fill it with all zeroes // hence, all pointers are initialized to NULL - share = (TOKUDB_SHARE *) tokudb_my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &share, sizeof(*share), - &tmp_name, length + 1, - NullS - ); - assert(share); + share = new TOKUDB_SHARE; + assert_always(share); - share->init(); + share->init(table_name); - share->table_name_length = length; - share->table_name = tmp_name; - strmov(share->table_name, table_name); - - error = my_hash_insert(&tokudb_open_tables, (uchar *) share); + error = my_hash_insert(&_open_tables, (uchar*)share); if (error) { free_key_and_col_info(&share->kc_info); + share->destroy(); + tokudb::memory::free((uchar*)share); + share = NULL; goto exit; } } + share->addref(); + + if (data) + thr_lock_data_init(&(share->_thr_lock), data, NULL); + exit: - if (error) { - share->destroy(); - tokudb_my_free((uchar *) share); - share = NULL; - } + _open_tables_mutex.unlock(); return share; } +void TOKUDB_SHARE::drop_share(TOKUDB_SHARE* share) { + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_SHARE, + "share[%p]:file[%s]:state[%s]:use_count[%d]", + share, + share->_full_table_name.ptr(), + get_state_string(share->_state), + share->_use_count); + + _open_tables_mutex.lock(); + my_hash_delete(&_open_tables, (uchar*)share); + _open_tables_mutex.unlock(); +} +TOKUDB_SHARE::share_state_t TOKUDB_SHARE::addref() { + TOKUDB_SHARE_TRACE_FOR_FLAGS((TOKUDB_DEBUG_ENTER & TOKUDB_DEBUG_SHARE), + "file[%s]:state[%s]:use_count[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count); + + lock(); + _use_count++; + + return _state; +} +int TOKUDB_SHARE::release() { + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count); -static int free_share(TOKUDB_SHARE * share) { int error, result = 0; - tokudb_pthread_mutex_lock(&share->mutex); - DBUG_PRINT("info", ("share->use_count %u", share->use_count)); - if (!--share->use_count) { - share->m_state = TOKUDB_SHARE::CLOSING; - tokudb_pthread_mutex_unlock(&share->mutex); - - // - // number of open DB's may not be equal to number of keys we have because add_index - // may have added some. So, we loop through entire array and close any non-NULL value - // It is imperative that we reset a DB to NULL once we are done with it. - // - for (uint i = 0; i < sizeof(share->key_file)/sizeof(share->key_file[0]); i++) { - if (share->key_file[i]) { - if (tokudb_debug & TOKUDB_DEBUG_OPEN) { - TOKUDB_TRACE("dbclose:%p", share->key_file[i]); - } - error = share->key_file[i]->close(share->key_file[i], 0); - assert(error == 0); + _mutex.lock(); + assert_always(_use_count != 0); + _use_count--; + if (_use_count == 0 && _state == TOKUDB_SHARE::OPENED) { + // number of open DB's may not be equal to number of keys we have + // because add_index may have added some. So, we loop through entire + // array and close any non-NULL value. It is imperative that we reset + // a DB to NULL once we are done with it. + for (uint i = 0; i < sizeof(key_file)/sizeof(key_file[0]); i++) { + if (key_file[i]) { + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_OPEN, + "dbclose:%p", + key_file[i]); + error = key_file[i]->close(key_file[i], 0); + assert_always(error == 0); if (error) { result = error; } - if (share->key_file[i] == share->file) - share->file = NULL; - share->key_file[i] = NULL; + if (key_file[i] == file) + file = NULL; + key_file[i] = NULL; } } - error = tokudb::close_status(&share->status_block); - assert(error == 0); + error = tokudb::metadata::close(&status_block); + assert_always(error == 0); - free_key_and_col_info(&share->kc_info); + free_key_and_col_info(&kc_info); - tokudb_pthread_mutex_lock(&tokudb_mutex); - tokudb_pthread_mutex_lock(&share->mutex); - share->m_state = TOKUDB_SHARE::CLOSED; - if (share->use_count > 0) { - tokudb_pthread_cond_broadcast(&share->m_openclose_cond); - tokudb_pthread_mutex_unlock(&share->mutex); - tokudb_pthread_mutex_unlock(&tokudb_mutex); - } else { - - my_hash_delete(&tokudb_open_tables, (uchar *) share); - - tokudb_pthread_mutex_unlock(&share->mutex); - tokudb_pthread_mutex_unlock(&tokudb_mutex); - - share->destroy(); - tokudb_my_free((uchar *) share); + if (_rec_per_key) { + tokudb::memory::free(_rec_per_key); + _rec_per_key = NULL; + _rec_per_keys = 0; } - } else { - tokudb_pthread_mutex_unlock(&share->mutex); + + for (uint i = 0; i < _keys; i++) { + tokudb::memory::free(_key_descriptors[i]._name); + } + tokudb::memory::free(_key_descriptors); + _keys = _max_key_parts = 0; _key_descriptors = NULL; + + _state = TOKUDB_SHARE::CLOSED; } + _mutex.unlock(); - return result; + TOKUDB_SHARE_DBUG_RETURN(result); } +void TOKUDB_SHARE::update_row_count( + THD* thd, + uint64_t added, + uint64_t deleted, + uint64_t updated) { + uint64_t delta = added + deleted + updated; + lock(); + if (deleted > added && _rows < (deleted - added)) { + _rows = 0; + } else { + _rows += added - deleted; + } + _row_delta_activity += delta; + if (_row_delta_activity == (uint64_t)~0) + _row_delta_activity = 1; + + ulonglong auto_threshold = tokudb::sysvars::auto_analyze(thd); + if (delta && auto_threshold > 0 && _allow_auto_analysis) { + ulonglong pct_of_rows_changed_to_trigger; + pct_of_rows_changed_to_trigger = ((_rows * auto_threshold) / 100); + if (_row_delta_activity >= pct_of_rows_changed_to_trigger) { + char msg[200]; + snprintf( + msg, + sizeof(msg), + "TokuDB: Auto %s background analysis for %s, delta_activity " + "%llu is greater than %llu percent of %llu rows.", + tokudb::sysvars::analyze_in_background(thd) > 0 ? + "scheduling" : "running", + full_table_name(), + _row_delta_activity, + auto_threshold, + (ulonglong)(_rows)); + + // analyze_standard will unlock _mutex regardless of success/failure + int ret = analyze_standard(thd, NULL); + if (ret == 0) { + sql_print_information("%s - succeeded.", msg); + } else { + sql_print_information( + "%s - failed, likely a job already running.", + msg); + } + } + } + unlock(); +} +void TOKUDB_SHARE::set_cardinality_counts_in_table(TABLE* table) { + lock(); + uint32_t next_key_part = 0; + for (uint32_t i = 0; i < table->s->keys; i++) { + KEY* key = &table->key_info[i]; + bool is_unique_key = + (i == table->s->primary_key) || (key->flags & HA_NOSAME); + + for (uint32_t j = 0; j < get_ext_key_parts(key); j++) { + if (j >= key->user_defined_key_parts) { + // MySQL 'hidden' keys, really needs deeper investigation + // into MySQL hidden keys vs TokuDB hidden keys + key->rec_per_key[j] = 1; + continue; + } + + assert_always(next_key_part < _rec_per_keys); + ulong val = _rec_per_key[next_key_part++]; + val = (val * tokudb::sysvars::cardinality_scale_percent) / 100; + if (val == 0 || _rows == 0 || + (is_unique_key && j == get_ext_key_parts(key) - 1)) { + val = 1; + } + key->rec_per_key[j] = val; + } + } + unlock(); +} #define HANDLE_INVALID_CURSOR() \ if (cursor == NULL) { \ @@ -288,7 +443,6 @@ static int free_share(TOKUDB_SHARE * share) { } const char *ha_tokudb::table_type() const { - extern const char *tokudb_hton_name; return tokudb_hton_name; } @@ -296,7 +450,7 @@ const char *ha_tokudb::index_type(uint inx) { return "BTREE"; } -/* +/* * returns NULL terminated file extension string */ const char **ha_tokudb::bas_ext() const { @@ -315,46 +469,23 @@ static inline bool is_replace_into(THD* thd) { return thd->lex->duplicates == DUP_REPLACE; } -static inline bool do_ignore_flag_optimization(THD* thd, TABLE* table, bool opt_eligible) { +static inline bool do_ignore_flag_optimization( + THD* thd, + TABLE* table, + bool opt_eligible) { + bool do_opt = false; - if (opt_eligible) { - if (is_replace_into(thd) || is_insert_ignore(thd)) { - uint pk_insert_mode = get_pk_insert_mode(thd); - if ((!table->triggers && pk_insert_mode < 2) || pk_insert_mode == 0) { - if (mysql_bin_log.is_open() && thd->variables.binlog_format != BINLOG_FORMAT_STMT) { - do_opt = false; - } else { - do_opt = true; - } - } - } + if (opt_eligible && + (is_replace_into(thd) || is_insert_ignore(thd)) && + tokudb::sysvars::pk_insert_mode(thd) == 1 && + !table->triggers && + !(mysql_bin_log.is_open() && + thd->variables.binlog_format != BINLOG_FORMAT_STMT)) { + do_opt = true; } return do_opt; } -static inline uint get_key_parts(const KEY *key) { -#if (50609 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \ - (50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799) || \ - (100009 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199) - return key->user_defined_key_parts; -#else - return key->key_parts; -#endif -} - -#if TOKU_INCLUDE_EXTENDED_KEYS -static inline uint get_ext_key_parts(const KEY *key) { -#if (50609 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \ - (50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799) - return key->actual_key_parts; -#elif defined(MARIADB_BASE_VERSION) - return key->ext_key_parts; -#else -#error -#endif -} -#endif - ulonglong ha_tokudb::table_flags() const { return int_table_flags | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE; } @@ -365,11 +496,9 @@ ulonglong ha_tokudb::table_flags() const { // ulong ha_tokudb::index_flags(uint idx, uint part, bool all_parts) const { TOKUDB_HANDLER_DBUG_ENTER(""); - assert(table_share); - ulong flags = (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE); -#if defined(MARIADB_BASE_VERSION) || (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) - flags |= HA_DO_INDEX_COND_PUSHDOWN; -#endif + assert_always(table_share); + ulong flags = (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | + HA_KEYREAD_ONLY | HA_READ_RANGE | HA_DO_INDEX_COND_PUSHDOWN); if (key_is_clustering(&table_share->key_info[idx])) { flags |= HA_CLUSTERED_INDEX; } @@ -434,13 +563,13 @@ static int loader_poll_fun(void *extra, float progress) { static void loader_ai_err_fun(DB *db, int i, int err, DBT *key, DBT *val, void *error_extra) { LOADER_CONTEXT context = (LOADER_CONTEXT)error_extra; - assert(context->ha); + assert_always(context->ha); context->ha->set_loader_error(err); } static void loader_dup_fun(DB *db, int i, int err, DBT *key, DBT *val, void *error_extra) { LOADER_CONTEXT context = (LOADER_CONTEXT)error_extra; - assert(context->ha); + assert_always(context->ha); context->ha->set_loader_error(err); if (err == DB_KEYEXIST) { context->ha->set_dup_value_for_pk(key); @@ -620,8 +749,7 @@ static ulonglong retrieve_auto_increment(uint16 type, uint32 offset,const uchar break; default: - DBUG_ASSERT(0); - unsigned_autoinc = 0; + assert_unreachable(); } if (signed_autoinc < 0) { @@ -632,21 +760,6 @@ static ulonglong retrieve_auto_increment(uint16 type, uint32 offset,const uchar unsigned_autoinc : (ulonglong) signed_autoinc; } -static inline bool -is_null_field( TABLE* table, Field* field, const uchar* record) { - uint null_offset; - bool ret_val; - if (!field->real_maybe_null()) { - ret_val = false; - goto exitpt; - } - null_offset = get_null_offset(table,field); - ret_val = (record[null_offset] & field->null_bit) ? true: false; - -exitpt: - return ret_val; -} - static inline ulong field_offset(Field* field, TABLE* table) { return((ulong) (field->ptr - table->record[0])); } @@ -692,29 +805,36 @@ static int filter_key_part_compare (const void* left, const void* right) { // if key, table have proper info set. I had to verify by checking // in the debugger. // -void set_key_filter(MY_BITMAP* key_filter, KEY* key, TABLE* table, bool get_offset_from_keypart) { +void set_key_filter( + MY_BITMAP* key_filter, + KEY* key, + TABLE* table, + bool get_offset_from_keypart) { + FILTER_KEY_PART_INFO parts[MAX_REF_PARTS]; uint curr_skip_index = 0; - for (uint i = 0; i < get_key_parts(key); i++) { + for (uint i = 0; i < key->user_defined_key_parts; i++) { // // horrendous hack due to bugs in mysql, basically // we cannot always reliably get the offset from the same source // - parts[i].offset = get_offset_from_keypart ? key->key_part[i].offset : field_offset(key->key_part[i].field, table); + parts[i].offset = + get_offset_from_keypart ? + key->key_part[i].offset : + field_offset(key->key_part[i].field, table); parts[i].part_index = i; } qsort( parts, // start of array - get_key_parts(key), //num elements + key->user_defined_key_parts, //num elements sizeof(*parts), //size of each element - filter_key_part_compare - ); + filter_key_part_compare); for (uint i = 0; i < table->s->fields; i++) { Field* field = table->field[i]; uint curr_field_offset = field_offset(field, table); - if (curr_skip_index < get_key_parts(key)) { + if (curr_skip_index < key->user_defined_key_parts) { uint curr_skip_offset = 0; curr_skip_offset = parts[curr_skip_index].offset; if (curr_skip_offset == curr_field_offset) { @@ -830,7 +950,7 @@ static inline uchar* write_var_field( int2store(to_tokudb_offset_ptr,offset); break; default: - assert(false); + assert_unreachable(); break; } return to_tokudb_data + data_length; @@ -850,8 +970,7 @@ static inline uint32_t get_var_data_length( data_length = uint2korr(from_mysql); break; default: - assert(false); - break; + assert_unreachable(); } return data_length; } @@ -894,8 +1013,7 @@ static inline void unpack_var_field( int2store(to_mysql, from_tokudb_data_len); break; default: - assert(false); - break; + assert_unreachable(); } // // store the data @@ -928,7 +1046,7 @@ static uchar* pack_toku_field_blob( length = uint4korr(from_mysql); break; default: - assert(false); + assert_unreachable(); } if (length > 0) { @@ -940,7 +1058,9 @@ static uchar* pack_toku_field_blob( static int create_tokudb_trx_data_instance(tokudb_trx_data** out_trx) { int error; - tokudb_trx_data* trx = (tokudb_trx_data *) tokudb_my_malloc(sizeof(*trx), MYF(MY_ZEROFILL)); + tokudb_trx_data* trx = (tokudb_trx_data *) tokudb::memory::malloc( + sizeof(*trx), + MYF(MY_ZEROFILL)); if (!trx) { error = ENOMEM; goto cleanup; @@ -1011,32 +1131,27 @@ static inline int tokudb_generate_row( void* old_ptr = dest_key->data; void* new_ptr = NULL; new_ptr = realloc(old_ptr, max_key_len); - assert(new_ptr); + assert_always(new_ptr); dest_key->data = new_ptr; dest_key->ulen = max_key_len; } buff = (uchar *)dest_key->data; - assert(buff != NULL && max_key_len > 0); - } - else { - assert(false); + assert_always(buff != NULL && max_key_len > 0); + } else { + assert_unreachable(); } - dest_key->size = pack_key_from_desc( - buff, - row_desc, - desc_size, - src_key, - src_val - ); - assert(dest_key->ulen >= dest_key->size); - if (tokudb_debug & TOKUDB_DEBUG_CHECK_KEY && !max_key_len) { + dest_key->size = pack_key_from_desc(buff, row_desc, desc_size, src_key, + src_val); + assert_always(dest_key->ulen >= dest_key->size); + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_CHECK_KEY)) && + !max_key_len) { max_key_len = max_key_size_from_desc(row_desc, desc_size); max_key_len += src_key->size; } if (max_key_len) { - assert(max_key_len >= dest_key->size); + assert_always(max_key_len >= dest_key->size); } row_desc += desc_size; @@ -1045,8 +1160,7 @@ static inline int tokudb_generate_row( if (dest_val != NULL) { if (!is_key_clustering(row_desc, desc_size) || src_val->size == 0) { dest_val->size = 0; - } - else { + } else { uchar* buff = NULL; if (dest_val->flags == 0) { dest_val->ulen = 0; @@ -1059,23 +1173,21 @@ static inline int tokudb_generate_row( void* old_ptr = dest_val->data; void* new_ptr = NULL; new_ptr = realloc(old_ptr, src_val->size); - assert(new_ptr); + assert_always(new_ptr); dest_val->data = new_ptr; dest_val->ulen = src_val->size; } buff = (uchar *)dest_val->data; - assert(buff != NULL); - } - else { - assert(false); + assert_always(buff != NULL); + } else { + assert_unreachable(); } dest_val->size = pack_clustering_val_from_desc( buff, row_desc, desc_size, - src_val - ); - assert(dest_val->ulen >= dest_val->size); + src_val); + assert_always(dest_val->ulen >= dest_val->size); } } error = 0; @@ -1143,6 +1255,7 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, t read_key = false; added_rows = 0; deleted_rows = 0; + updated_rows = 0; last_dup_key = UINT_MAX; using_ignore = false; using_ignore_no_key = false; @@ -1224,41 +1337,42 @@ bool ha_tokudb::has_auto_increment_flag(uint* index) { static int open_status_dictionary(DB** ptr, const char* name, DB_TXN* txn) { int error; char* newname = NULL; - newname = (char *)tokudb_my_malloc( - get_max_dict_name_path_length(name), - MYF(MY_WME)); + size_t newname_len = get_max_dict_name_path_length(name); + newname = (char*)tokudb::memory::malloc(newname_len, MYF(MY_WME)); if (newname == NULL) { error = ENOMEM; goto cleanup; } - make_name(newname, name, "status"); - if (tokudb_debug & TOKUDB_DEBUG_OPEN) { - TOKUDB_TRACE("open:%s", newname); - } + make_name(newname, newname_len, name, "status"); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_OPEN, "open:%s", newname); - error = tokudb::open_status(db_env, ptr, newname, txn); + error = tokudb::metadata::open(db_env, ptr, newname, txn); cleanup: - tokudb_my_free(newname); + tokudb::memory::free(newname); return error; } -int ha_tokudb::open_main_dictionary(const char* name, bool is_read_only, DB_TXN* txn) { +int ha_tokudb::open_main_dictionary( + const char* name, + bool is_read_only, + DB_TXN* txn) { + int error; char* newname = NULL; + size_t newname_len = 0; uint open_flags = (is_read_only ? DB_RDONLY : 0) | DB_THREAD; - assert(share->file == NULL); - assert(share->key_file[primary_key] == NULL); - - newname = (char *)tokudb_my_malloc( - get_max_dict_name_path_length(name), - MYF(MY_WME|MY_ZEROFILL) - ); + assert_always(share->file == NULL); + assert_always(share->key_file[primary_key] == NULL); + newname_len = get_max_dict_name_path_length(name); + newname = (char*)tokudb::memory::malloc( + newname_len, + MYF(MY_WME|MY_ZEROFILL)); if (newname == NULL) { error = ENOMEM; goto exit; } - make_name(newname, name, "main"); + make_name(newname, newname_len, name, "main"); error = db_create(&share->file, db_env, 0); if (error) { @@ -1266,14 +1380,24 @@ int ha_tokudb::open_main_dictionary(const char* name, bool is_read_only, DB_TXN* } share->key_file[primary_key] = share->file; - error = share->file->open(share->file, txn, newname, NULL, DB_BTREE, open_flags, 0); + error = + share->file->open( + share->file, + txn, + newname, + NULL, + DB_BTREE, + open_flags, + 0); if (error) { goto exit; } - - if (tokudb_debug & TOKUDB_DEBUG_OPEN) { - TOKUDB_HANDLER_TRACE("open:%s:file=%p", newname, share->file); - } + + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_OPEN, + "open:%s:file=%p", + newname, + share->file); error = 0; exit: @@ -1283,34 +1407,42 @@ exit: share->file, 0 ); - assert(r==0); + assert_always(r==0); share->file = NULL; share->key_file[primary_key] = NULL; } } - tokudb_my_free(newname); + tokudb::memory::free(newname); return error; } // -// Open a secondary table, the key will be a secondary index, the data will be a primary key +// Open a secondary table, the key will be a secondary index, the data will +// be a primary key // -int ha_tokudb::open_secondary_dictionary(DB** ptr, KEY* key_info, const char* name, bool is_read_only, DB_TXN* txn) { +int ha_tokudb::open_secondary_dictionary( + DB** ptr, + KEY* key_info, + const char* name, + bool is_read_only, + DB_TXN* txn) { + int error = ENOSYS; char dict_name[MAX_DICT_NAME_LEN]; uint open_flags = (is_read_only ? DB_RDONLY : 0) | DB_THREAD; char* newname = NULL; - uint newname_len = 0; - + size_t newname_len = 0; + sprintf(dict_name, "key-%s", key_info->name); newname_len = get_max_dict_name_path_length(name); - newname = (char *)tokudb_my_malloc(newname_len, MYF(MY_WME|MY_ZEROFILL)); + newname = + (char*)tokudb::memory::malloc(newname_len, MYF(MY_WME|MY_ZEROFILL)); if (newname == NULL) { error = ENOMEM; goto cleanup; } - make_name(newname, name, dict_name); + make_name(newname, newname_len, name, dict_name); if ((error = db_create(ptr, db_env, 0))) { @@ -1319,22 +1451,25 @@ int ha_tokudb::open_secondary_dictionary(DB** ptr, KEY* key_info, const char* na } - if ((error = (*ptr)->open(*ptr, txn, newname, NULL, DB_BTREE, open_flags, 0))) { + error = (*ptr)->open(*ptr, txn, newname, NULL, DB_BTREE, open_flags, 0); + if (error) { my_errno = error; goto cleanup; } - if (tokudb_debug & TOKUDB_DEBUG_OPEN) { - TOKUDB_HANDLER_TRACE("open:%s:file=%p", newname, *ptr); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_OPEN, + "open:%s:file=%p", + newname, + *ptr); cleanup: if (error) { if (*ptr) { int r = (*ptr)->close(*ptr, 0); - assert(r==0); + assert_always(r==0); *ptr = NULL; } } - tokudb_my_free(newname); + tokudb::memory::free(newname); return error; } @@ -1343,11 +1478,10 @@ static int initialize_col_pack_info(KEY_AND_COL_INFO* kc_info, TABLE_SHARE* tabl // // set up the cp_info // - assert(kc_info->cp_info[keynr] == NULL); - kc_info->cp_info[keynr] = (COL_PACK_INFO *)tokudb_my_malloc( - table_share->fields*sizeof(COL_PACK_INFO), - MYF(MY_WME | MY_ZEROFILL) - ); + assert_always(kc_info->cp_info[keynr] == NULL); + kc_info->cp_info[keynr] = (COL_PACK_INFO*)tokudb::memory::malloc( + table_share->fields * sizeof(COL_PACK_INFO), + MYF(MY_WME | MY_ZEROFILL)); if (kc_info->cp_info[keynr] == NULL) { error = ENOMEM; goto exit; @@ -1396,12 +1530,18 @@ exit: // reset the kc_info state at keynr static void reset_key_and_col_info(KEY_AND_COL_INFO *kc_info, uint keynr) { bitmap_clear_all(&kc_info->key_filters[keynr]); - tokudb_my_free(kc_info->cp_info[keynr]); + tokudb::memory::free(kc_info->cp_info[keynr]); kc_info->cp_info[keynr] = NULL; kc_info->mcp_info[keynr] = (MULTI_COL_PACK_INFO) { 0, 0 }; } -static int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, KEY_AND_COL_INFO* kc_info, uint hidden_primary_key, uint primary_key) { +static int initialize_key_and_col_info( + TABLE_SHARE* table_share, + TABLE* table, + KEY_AND_COL_INFO* kc_info, + uint hidden_primary_key, + uint primary_key) { + int error = 0; uint32_t curr_blob_field_index = 0; uint32_t max_var_bytes = 0; @@ -1420,7 +1560,7 @@ static int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, K case toku_type_fixbinary: case toku_type_fixstring: pack_length = field->pack_length(); - assert(pack_length < 1<<16); + assert_always(pack_length < 1<<16); kc_info->field_types[i] = KEY_AND_COL_INFO::TOKUDB_FIXED_FIELD; kc_info->field_lengths[i] = (uint16_t)pack_length; kc_info->length_bytes[i] = 0; @@ -1436,11 +1576,12 @@ static int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, K case toku_type_varbinary: kc_info->field_types[i] = KEY_AND_COL_INFO::TOKUDB_VARIABLE_FIELD; kc_info->field_lengths[i] = 0; - kc_info->length_bytes[i] = (uchar)((Field_varstring *)field)->length_bytes; + kc_info->length_bytes[i] = + (uchar)((Field_varstring*)field)->length_bytes; max_var_bytes += field->field_length; break; default: - assert(false); + assert_unreachable(); } } kc_info->num_blobs = curr_blob_field_index; @@ -1452,54 +1593,54 @@ static int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, K // if (max_var_bytes < 256) { kc_info->num_offset_bytes = 1; - } - else { + } else { kc_info->num_offset_bytes = 2; } - for (uint i = 0; i < table_share->keys + tokudb_test(hidden_primary_key); i++) { + for (uint i = 0; + i < table_share->keys + tokudb_test(hidden_primary_key); + i++) { // // do the cluster/primary key filtering calculations // - if (! (i==primary_key && hidden_primary_key) ){ - if ( i == primary_key ) { + if (!(i==primary_key && hidden_primary_key)) { + if (i == primary_key) { set_key_filter( &kc_info->key_filters[primary_key], &table_share->key_info[primary_key], table, - true - ); - } - else { + true); + } else { set_key_filter( &kc_info->key_filters[i], &table_share->key_info[i], table, - true - ); + true); if (!hidden_primary_key) { set_key_filter( &kc_info->key_filters[i], &table_share->key_info[primary_key], table, - true - ); + true); } } } if (i == primary_key || key_is_clustering(&table_share->key_info[i])) { - error = initialize_col_pack_info(kc_info,table_share,i); + error = initialize_col_pack_info(kc_info, table_share, i); if (error) { goto exit; } } - } exit: return error; } -bool ha_tokudb::can_replace_into_be_fast(TABLE_SHARE* table_share, KEY_AND_COL_INFO* kc_info, uint pk) { +bool ha_tokudb::can_replace_into_be_fast( + TABLE_SHARE* table_share, + KEY_AND_COL_INFO* kc_info, + uint pk) { + uint curr_num_DBs = table_share->keys + tokudb_test(hidden_primary_key); bool ret_val; if (curr_num_DBs == 1) { @@ -1510,7 +1651,7 @@ bool ha_tokudb::can_replace_into_be_fast(TABLE_SHARE* table_share, KEY_AND_COL_I for (uint curr_index = 0; curr_index < table_share->keys; curr_index++) { if (curr_index == pk) continue; KEY* curr_key_info = &table_share->key_info[curr_index]; - for (uint i = 0; i < get_key_parts(curr_key_info); i++) { + for (uint i = 0; i < curr_key_info->user_defined_key_parts; i++) { uint16 curr_field_index = curr_key_info->key_part[i].field->field_index; if (!bitmap_is_set(&kc_info->key_filters[curr_index],curr_field_index)) { ret_val = false; @@ -1544,8 +1685,6 @@ int ha_tokudb::initialize_share(const char* name, int mode) { if (error) { goto exit; } } - DBUG_PRINT("info", ("share->use_count %u", share->use_count)); - share->m_initialize_count++; error = get_status(txn); if (error) { @@ -1574,43 +1713,64 @@ int ha_tokudb::initialize_share(const char* name, int mode) { goto exit; #endif - error = initialize_key_and_col_info( - table_share, - table, - &share->kc_info, - hidden_primary_key, - primary_key - ); - if (error) { goto exit; } - - error = open_main_dictionary(name, mode == O_RDONLY, txn); + error = + initialize_key_and_col_info( + table_share, + table, + &share->kc_info, + hidden_primary_key, + primary_key); if (error) { goto exit; } + error = open_main_dictionary(name, mode == O_RDONLY, txn); + if (error) { + goto exit; + } + share->has_unique_keys = false; + share->_keys = table_share->keys; + share->_max_key_parts = table_share->key_parts; + share->_key_descriptors = + (TOKUDB_SHARE::key_descriptor_t*)tokudb::memory::malloc( + sizeof(TOKUDB_SHARE::key_descriptor_t) * share->_keys, + MYF(MY_ZEROFILL)); + /* Open other keys; These are part of the share structure */ for (uint i = 0; i < table_share->keys; i++) { + share->_key_descriptors[i]._parts = + table_share->key_info[i].user_defined_key_parts; + if (i == primary_key) { + share->_key_descriptors[i]._is_unique = true; + share->_key_descriptors[i]._name = tokudb::memory::strdup("primary", 0); + } else { + share->_key_descriptors[i]._is_unique = false; + share->_key_descriptors[i]._name = + tokudb::memory::strdup(table_share->key_info[i].name, 0); + } + if (table_share->key_info[i].flags & HA_NOSAME) { + share->_key_descriptors[i]._is_unique = true; share->has_unique_keys = true; } if (i != primary_key) { - error = open_secondary_dictionary( - &share->key_file[i], - &table_share->key_info[i], - name, - mode == O_RDONLY, - txn - ); + error = + open_secondary_dictionary( + &share->key_file[i], + &table_share->key_info[i], + name, + mode == O_RDONLY, + txn); if (error) { goto exit; } } } - share->replace_into_fast = can_replace_into_be_fast( - table_share, - &share->kc_info, - primary_key - ); - + share->replace_into_fast = + can_replace_into_be_fast( + table_share, + &share->kc_info, + primary_key); + share->pk_has_string = false; if (!hidden_primary_key) { // @@ -1618,8 +1778,9 @@ int ha_tokudb::initialize_share(const char* name, int mode) { // the "infinity byte" in keys, and for placing the DBT size in the first four bytes // ref_length = sizeof(uint32_t) + sizeof(uchar); - KEY_PART_INFO *key_part = table->key_info[primary_key].key_part; - KEY_PART_INFO *end = key_part + get_key_parts(&table->key_info[primary_key]); + KEY_PART_INFO* key_part = table->key_info[primary_key].key_part; + KEY_PART_INFO* end = + key_part + table->key_info[primary_key].user_defined_key_parts; for (; key_part != end; key_part++) { ref_length += key_part->field->max_packed_col_length(key_part->length); TOKU_TYPE toku_type = mysql_to_toku_type(key_part->field); @@ -1640,9 +1801,8 @@ int ha_tokudb::initialize_share(const char* name, int mode) { // estimate_num_rows should not fail under normal conditions // if (error == 0) { - share->rows = num_rows; - } - else { + share->set_row_count(num_rows, true); + } else { goto exit; } // @@ -1655,8 +1815,7 @@ int ha_tokudb::initialize_share(const char* name, int mode) { if (may_table_be_empty(txn)) { share->try_table_lock = true; - } - else { + } else { share->try_table_lock = false; } @@ -1665,12 +1824,22 @@ int ha_tokudb::initialize_share(const char* name, int mode) { init_hidden_prim_key_info(txn); // initialize cardinality info from the status dictionary - share->n_rec_per_key = tokudb::compute_total_key_parts(table_share); - share->rec_per_key = (uint64_t *) tokudb_my_realloc(share->rec_per_key, share->n_rec_per_key * sizeof (uint64_t), MYF(MY_FAE + MY_ALLOW_ZERO_PTR)); - error = tokudb::get_card_from_status(share->status_block, txn, share->n_rec_per_key, share->rec_per_key); - if (error) { - for (uint i = 0; i < share->n_rec_per_key; i++) - share->rec_per_key[i] = 0; + { + uint32_t rec_per_keys = tokudb::compute_total_key_parts(table_share); + uint64_t* rec_per_key = + (uint64_t*)tokudb::memory::malloc( + rec_per_keys * sizeof(uint64_t), + MYF(MY_FAE)); + error = + tokudb::get_card_from_status( + share->status_block, + txn, + rec_per_keys, + rec_per_key); + if (error) { + memset(rec_per_key, 0, sizeof(ulonglong) * rec_per_keys); + } + share->init_cardinality_counts(rec_per_keys, rec_per_key); } error = 0; @@ -1720,7 +1889,8 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { // the "+ 1" is for the first byte that states +/- infinity // multiply everything by 2 to account for clustered keys having a key and primary key together max_key_length = 2*(table_share->max_key_length + MAX_REF_PARTS * 3 + sizeof(uchar)); - alloc_ptr = tokudb_my_multi_malloc(MYF(MY_WME), + alloc_ptr = tokudb::memory::multi_malloc( + MYF(MY_WME), &key_buff, max_key_length, &key_buff2, max_key_length, &key_buff3, max_key_length, @@ -1730,82 +1900,82 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { &primary_key_buff, (hidden_primary_key ? 0 : max_key_length), &fixed_cols_for_query, table_share->fields*sizeof(uint32_t), &var_cols_for_query, table_share->fields*sizeof(uint32_t), - NullS - ); + NullS); if (alloc_ptr == NULL) { ret_val = 1; goto exit; } - size_range_query_buff = get_tokudb_read_buf_size(thd); - range_query_buff = (uchar *)tokudb_my_malloc(size_range_query_buff, MYF(MY_WME)); + size_range_query_buff = tokudb::sysvars::read_buf_size(thd); + range_query_buff = + (uchar*)tokudb::memory::malloc(size_range_query_buff, MYF(MY_WME)); if (range_query_buff == NULL) { ret_val = 1; goto exit; } - alloced_rec_buff_length = table_share->rec_buff_length + table_share->fields; - rec_buff = (uchar *) tokudb_my_malloc(alloced_rec_buff_length, MYF(MY_WME)); + alloced_rec_buff_length = table_share->rec_buff_length + + table_share->fields; + rec_buff = (uchar *) tokudb::memory::malloc( + alloced_rec_buff_length, + MYF(MY_WME)); if (rec_buff == NULL) { ret_val = 1; goto exit; } alloced_update_rec_buff_length = alloced_rec_buff_length; - rec_update_buff = (uchar *) tokudb_my_malloc(alloced_update_rec_buff_length, MYF(MY_WME)); + rec_update_buff = (uchar*)tokudb::memory::malloc( + alloced_update_rec_buff_length, + MYF(MY_WME)); if (rec_update_buff == NULL) { ret_val = 1; goto exit; } // lookup or create share - tokudb_pthread_mutex_lock(&tokudb_mutex); - share = get_share(name, table_share); - assert(share); + share = TOKUDB_SHARE::get_share(name, table_share, &lock, true); + assert_always(share); - thr_lock_data_init(&share->lock, &lock, NULL); - - tokudb_pthread_mutex_lock(&share->mutex); - tokudb_pthread_mutex_unlock(&tokudb_mutex); - share->use_count++; - while (share->m_state == TOKUDB_SHARE::OPENING || share->m_state == TOKUDB_SHARE::CLOSING) { - tokudb_pthread_cond_wait(&share->m_openclose_cond, &share->mutex); - } - if (share->m_state == TOKUDB_SHARE::CLOSED) { - share->m_state = TOKUDB_SHARE::OPENING; - tokudb_pthread_mutex_unlock(&share->mutex); + if (share->state() != TOKUDB_SHARE::OPENED) { + // means we're responsible for the transition to OPENED, ERROR or CLOSED ret_val = allocate_key_and_col_info(table_share, &share->kc_info); if (ret_val == 0) { ret_val = initialize_share(name, mode); } - tokudb_pthread_mutex_lock(&share->mutex); if (ret_val == 0) { - share->m_state = TOKUDB_SHARE::OPENED; + share->set_state(TOKUDB_SHARE::OPENED); } else { - share->m_state = TOKUDB_SHARE::ERROR; - share->m_error = ret_val; + free_key_and_col_info(&share->kc_info); + share->set_state(TOKUDB_SHARE::ERROR); } - tokudb_pthread_cond_broadcast(&share->m_openclose_cond); - } - if (share->m_state == TOKUDB_SHARE::ERROR) { - ret_val = share->m_error; - tokudb_pthread_mutex_unlock(&share->mutex); - free_share(share); - goto exit; + share->unlock(); } else { - assert(share->m_state == TOKUDB_SHARE::OPENED); - tokudb_pthread_mutex_unlock(&share->mutex); + // got an already OPENED instance + share->unlock(); } - ref_length = share->ref_length; // If second open - - if (tokudb_debug & TOKUDB_DEBUG_OPEN) { - TOKUDB_HANDLER_TRACE("tokudbopen:%p:share=%p:file=%p:table=%p:table->s=%p:%d", - this, share, share->file, table, table->s, share->use_count); + if (share->state() == TOKUDB_SHARE::ERROR) { + share->release(); + goto exit; } + assert_always(share->state() == TOKUDB_SHARE::OPENED); + + ref_length = share->ref_length; // If second open + + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_OPEN, + "tokudbopen:%p:share=%p:file=%p:table=%p:table->s=%p:%d", + this, + share, + share->file, + table, + table->s, + share->use_count()); + key_read = false; stats.block_size = 1<<20; // QQQ Tokudb DB block size @@ -1813,13 +1983,13 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { exit: if (ret_val) { - tokudb_my_free(range_query_buff); + tokudb::memory::free(range_query_buff); range_query_buff = NULL; - tokudb_my_free(alloc_ptr); + tokudb::memory::free(alloc_ptr); alloc_ptr = NULL; - tokudb_my_free(rec_buff); + tokudb::memory::free(rec_buff); rec_buff = NULL; - tokudb_my_free(rec_update_buff); + tokudb::memory::free(rec_update_buff); rec_update_buff = NULL; if (error) { @@ -1982,7 +2152,7 @@ int ha_tokudb::write_frm_data(DB* db, DB_TXN* txn, const char* frm_name) { error = 0; cleanup: - tokudb_my_free(frm_data); + tokudb::memory::free(frm_data); TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -1993,8 +2163,8 @@ int ha_tokudb::remove_frm_data(DB *db, DB_TXN *txn) { static int smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) { DBT* stored_frm = (DBT *)context; stored_frm->size = row->size; - stored_frm->data = (uchar *)tokudb_my_malloc(row->size, MYF(MY_WME)); - assert(stored_frm->data); + stored_frm->data = (uchar *)tokudb::memory::malloc(row->size, MYF(MY_WME)); + assert_always(stored_frm->data); memcpy(stored_frm->data, row->data, row->size); return 0; } @@ -2046,8 +2216,8 @@ int ha_tokudb::verify_frm_data(const char* frm_name, DB_TXN* txn) { error = 0; cleanup: - tokudb_my_free(mysql_frm_data); - tokudb_my_free(stored_frm.data); + tokudb::memory::free(mysql_frm_data); + tokudb::memory::free(stored_frm.data); TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -2083,7 +2253,7 @@ int ha_tokudb::write_auto_inc_create(DB* db, ulonglong val, DB_TXN* txn){ // // Closes a handle to a table. // -int ha_tokudb::close(void) { +int ha_tokudb::close() { TOKUDB_HANDLER_DBUG_ENTER(""); int r = __close(); TOKUDB_HANDLER_DBUG_RETURN(r); @@ -2091,13 +2261,12 @@ int ha_tokudb::close(void) { int ha_tokudb::__close() { TOKUDB_HANDLER_DBUG_ENTER(""); - if (tokudb_debug & TOKUDB_DEBUG_OPEN) - TOKUDB_HANDLER_TRACE("close:%p", this); - tokudb_my_free(rec_buff); - tokudb_my_free(rec_update_buff); - tokudb_my_free(blob_buff); - tokudb_my_free(alloc_ptr); - tokudb_my_free(range_query_buff); + TOKUDB_HANDLER_TRACE_FOR_FLAGS(TOKUDB_DEBUG_OPEN, "close:%p", this); + tokudb::memory::free(rec_buff); + tokudb::memory::free(rec_update_buff); + tokudb::memory::free(blob_buff); + tokudb::memory::free(alloc_ptr); + tokudb::memory::free(range_query_buff); for (uint32_t i = 0; i < sizeof(mult_key_dbt_array)/sizeof(mult_key_dbt_array[0]); i++) { toku_dbt_array_destroy(&mult_key_dbt_array[i]); } @@ -2108,7 +2277,7 @@ int ha_tokudb::__close() { rec_update_buff = NULL; alloc_ptr = NULL; ha_tokudb::reset(); - int retval = free_share(share); + int retval = share->release(); TOKUDB_HANDLER_DBUG_RETURN(retval); } @@ -2120,8 +2289,11 @@ int ha_tokudb::__close() { // bool ha_tokudb::fix_rec_buff_for_blob(ulong length) { if (!rec_buff || (length > alloced_rec_buff_length)) { - uchar *newptr; - if (!(newptr = (uchar *) tokudb_my_realloc((void *) rec_buff, length, MYF(MY_ALLOW_ZERO_PTR)))) + uchar* newptr = (uchar*)tokudb::memory::realloc( + (void*)rec_buff, + length, + MYF(MY_ALLOW_ZERO_PTR)); + if (!newptr) return 1; rec_buff = newptr; alloced_rec_buff_length = length; @@ -2137,8 +2309,11 @@ bool ha_tokudb::fix_rec_buff_for_blob(ulong length) { // bool ha_tokudb::fix_rec_update_buff_for_blob(ulong length) { if (!rec_update_buff || (length > alloced_update_rec_buff_length)) { - uchar *newptr; - if (!(newptr = (uchar *) tokudb_my_realloc((void *) rec_update_buff, length, MYF(MY_ALLOW_ZERO_PTR)))) + uchar* newptr = (uchar*)tokudb::memory::realloc( + (void*)rec_update_buff, + length, + MYF(MY_ALLOW_ZERO_PTR)); + if (!newptr) return 1; rec_update_buff= newptr; alloced_update_rec_buff_length = length; @@ -2273,9 +2448,11 @@ int ha_tokudb::unpack_blobs( // // assert that num_bytes > 0 iff share->num_blobs > 0 // - assert( !((share->kc_info.num_blobs == 0) && (num_bytes > 0)) ); + assert_always( !((share->kc_info.num_blobs == 0) && (num_bytes > 0)) ); if (num_bytes > num_blob_bytes) { - ptr = (uchar *)tokudb_my_realloc((void *)blob_buff, num_bytes, MYF(MY_ALLOW_ZERO_PTR)); + ptr = (uchar*)tokudb::memory::realloc( + (void*)blob_buff, num_bytes, + MYF(MY_ALLOW_ZERO_PTR)); if (ptr == NULL) { error = ENOMEM; goto exit; @@ -2390,8 +2567,7 @@ int ha_tokudb::unpack_row( data_end_offset = uint2korr(var_field_offset_ptr); break; default: - assert(false); - break; + assert_unreachable(); } unpack_var_field( record + field_offset(field, table), @@ -2488,13 +2664,13 @@ exit: } uint32_t ha_tokudb::place_key_into_mysql_buff( - KEY* key_info, - uchar * record, - uchar* data - ) -{ - KEY_PART_INFO *key_part = key_info->key_part, *end = key_part + get_key_parts(key_info); - uchar *pos = data; + KEY* key_info, + uchar* record, + uchar* data) { + + KEY_PART_INFO* key_part = key_info->key_part; + KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts; + uchar* pos = data; for (; key_part != end; key_part++) { if (key_part->field->null_bit) { @@ -2513,7 +2689,7 @@ uint32_t ha_tokudb::place_key_into_mysql_buff( // // HOPEFULLY TEMPORARY // - assert(table->s->db_low_byte_first); + assert_always(table->s->db_low_byte_first); #endif pos = unpack_toku_key_field( record + field_offset(key_part->field, table), @@ -2554,15 +2730,14 @@ void ha_tokudb::unpack_key(uchar * record, DBT const *key, uint index) { } uint32_t ha_tokudb::place_key_into_dbt_buff( - KEY* key_info, - uchar * buff, - const uchar * record, - bool* has_null, - int key_length - ) -{ - KEY_PART_INFO *key_part = key_info->key_part; - KEY_PART_INFO *end = key_part + get_key_parts(key_info); + KEY* key_info, + uchar* buff, + const uchar* record, + bool* has_null, + int key_length) { + + KEY_PART_INFO* key_part = key_info->key_part; + KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts; uchar* curr_buff = buff; *has_null = false; for (; key_part != end && key_length > 0; key_part++) { @@ -2585,7 +2760,7 @@ uint32_t ha_tokudb::place_key_into_dbt_buff( // // HOPEFULLY TEMPORARY // - assert(table->s->db_low_byte_first); + assert_always(table->s->db_low_byte_first); #endif // // accessing field_offset(key_part->field) instead off key_part->offset @@ -2742,25 +2917,29 @@ DBT* ha_tokudb::create_dbt_key_for_lookup( // Returns: // the parameter key // -DBT *ha_tokudb::pack_key( - DBT * key, - uint keynr, - uchar * buff, - const uchar * key_ptr, - uint key_length, - int8_t inf_byte - ) -{ - TOKUDB_HANDLER_DBUG_ENTER("key %p %u:%2.2x inf=%d", key_ptr, key_length, key_length > 0 ? key_ptr[0] : 0, inf_byte); +DBT* ha_tokudb::pack_key( + DBT* key, + uint keynr, + uchar* buff, + const uchar* key_ptr, + uint key_length, + int8_t inf_byte) { + + TOKUDB_HANDLER_DBUG_ENTER( + "key %p %u:%2.2x inf=%d", + key_ptr, + key_length, + key_length > 0 ? key_ptr[0] : 0, + inf_byte); #if TOKU_INCLUDE_EXTENDED_KEYS if (keynr != primary_key && !tokudb_test(hidden_primary_key)) { DBUG_RETURN(pack_ext_key(key, keynr, buff, key_ptr, key_length, inf_byte)); } #endif - KEY *key_info = &table->key_info[keynr]; - KEY_PART_INFO *key_part = key_info->key_part; - KEY_PART_INFO *end = key_part + get_key_parts(key_info); - my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->write_set); + KEY* key_info = &table->key_info[keynr]; + KEY_PART_INFO* key_part = key_info->key_part; + KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts; + my_bitmap_map* old_map = dbug_tmp_use_all_columns(table, table->write_set); memset((void *) key, 0, sizeof(*key)); key->data = buff; @@ -2782,7 +2961,7 @@ DBT *ha_tokudb::pack_key( offset = 1; // Data is at key_ptr+1 } #if !defined(MARIADB_BASE_VERSION) - assert(table->s->db_low_byte_first); + assert_always(table->s->db_low_byte_first); #endif buff = pack_key_toku_key_field( buff, @@ -2802,31 +2981,30 @@ DBT *ha_tokudb::pack_key( } #if TOKU_INCLUDE_EXTENDED_KEYS -DBT *ha_tokudb::pack_ext_key( - DBT * key, - uint keynr, - uchar * buff, - const uchar * key_ptr, - uint key_length, - int8_t inf_byte - ) -{ +DBT* ha_tokudb::pack_ext_key( + DBT* key, + uint keynr, + uchar* buff, + const uchar* key_ptr, + uint key_length, + int8_t inf_byte) { + TOKUDB_HANDLER_DBUG_ENTER(""); // build a list of PK parts that are in the SK. we will use this list to build the // extended key if necessary. - KEY *pk_key_info = &table->key_info[primary_key]; - uint pk_parts = get_key_parts(pk_key_info); + KEY* pk_key_info = &table->key_info[primary_key]; + uint pk_parts = pk_key_info->user_defined_key_parts; uint pk_next = 0; struct { const uchar *key_ptr; KEY_PART_INFO *key_part; } pk_info[pk_parts]; - KEY *key_info = &table->key_info[keynr]; - KEY_PART_INFO *key_part = key_info->key_part; - KEY_PART_INFO *end = key_part + get_key_parts(key_info); - my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->write_set); + KEY* key_info = &table->key_info[keynr]; + KEY_PART_INFO* key_part = key_info->key_part; + KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts; + my_bitmap_map* old_map = dbug_tmp_use_all_columns(table, table->write_set); memset((void *) key, 0, sizeof(*key)); key->data = buff; @@ -2838,7 +3016,7 @@ DBT *ha_tokudb::pack_ext_key( for (; key_part != end && (int) key_length > 0; key_part++) { // if the SK part is part of the PK, then append it to the list. if (key_part->field->part_of_key.is_set(primary_key)) { - assert(pk_next < pk_parts); + assert_always(pk_next < pk_parts); pk_info[pk_next].key_ptr = key_ptr; pk_info[pk_next].key_part = key_part; pk_next++; @@ -2855,7 +3033,7 @@ DBT *ha_tokudb::pack_ext_key( offset = 1; // Data is at key_ptr+1 } #if !defined(MARIADB_BASE_VERSION) - assert(table->s->db_low_byte_first); + assert_always(table->s->db_low_byte_first); #endif buff = pack_key_toku_key_field( buff, @@ -2869,22 +3047,33 @@ DBT *ha_tokudb::pack_ext_key( } if (key_length > 0) { - assert(key_part == end); + assert_always(key_part == end); end = key_info->key_part + get_ext_key_parts(key_info); // pack PK in order of PK key parts - for (uint pk_index = 0; key_part != end && (int) key_length > 0 && pk_index < pk_parts; pk_index++) { + for (uint pk_index = 0; + key_part != end && (int) key_length > 0 && pk_index < pk_parts; + pk_index++) { uint i; for (i = 0; i < pk_next; i++) { - if (pk_info[i].key_part->fieldnr == pk_key_info->key_part[pk_index].fieldnr) + if (pk_info[i].key_part->fieldnr == + pk_key_info->key_part[pk_index].fieldnr) break; } if (i < pk_next) { const uchar *this_key_ptr = pk_info[i].key_ptr; KEY_PART_INFO *this_key_part = pk_info[i].key_part; - buff = pack_key_toku_key_field(buff, (uchar *) this_key_ptr, this_key_part->field, this_key_part->length); + buff = pack_key_toku_key_field( + buff, + (uchar*)this_key_ptr, + this_key_part->field, + this_key_part->length); } else { - buff = pack_key_toku_key_field(buff, (uchar *) key_ptr, key_part->field, key_part->length); + buff = pack_key_toku_key_field( + buff, + (uchar*)key_ptr, + key_part->field, + key_part->length); key_ptr += key_part->store_length; key_length -= key_part->store_length; key_part++; @@ -2907,18 +3096,22 @@ void ha_tokudb::init_hidden_prim_key_info(DB_TXN *txn) { if (!(share->status & STATUS_PRIMARY_KEY_INIT)) { int error = 0; DBC* c = NULL; - error = share->key_file[primary_key]->cursor(share->key_file[primary_key], txn, &c, 0); - assert(error == 0); + error = share->key_file[primary_key]->cursor( + share->key_file[primary_key], + txn, + &c, + 0); + assert_always(error == 0); DBT key,val; memset(&key, 0, sizeof(key)); memset(&val, 0, sizeof(val)); error = c->c_get(c, &key, &val, DB_LAST); if (error == 0) { - assert(key.size == TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH); + assert_always(key.size == TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH); share->auto_ident = hpk_char_to_num((uchar *)key.data); } error = c->c_close(c); - assert(error == 0); + assert_always(error == 0); share->status |= STATUS_PRIMARY_KEY_INIT; } TOKUDB_HANDLER_DBUG_VOID_RETURN; @@ -2939,11 +3132,11 @@ int ha_tokudb::get_status(DB_TXN* txn) { // open status.tokudb // if (!share->status_block) { - error = open_status_dictionary( - &share->status_block, - share->table_name, - txn - ); + error = + open_status_dictionary( + &share->status_block, + share->full_table_name(), + txn); if (error) { goto cleanup; } @@ -2958,7 +3151,7 @@ int ha_tokudb::get_status(DB_TXN* txn) { key.size = sizeof(curr_key); value.flags = DB_DBT_USERMEM; - assert(share->status_block); + assert_always(share->status_block); // // get version // @@ -3048,7 +3241,7 @@ cleanup: */ ha_rows ha_tokudb::estimate_rows_upper_bound() { TOKUDB_HANDLER_DBUG_ENTER(""); - DBUG_RETURN(share->rows + HA_TOKUDB_EXTRA_ROWS); + DBUG_RETURN(share->row_count() + HA_TOKUDB_EXTRA_ROWS); } // @@ -3112,8 +3305,8 @@ bool ha_tokudb::may_table_be_empty(DB_TXN *txn) { DBC* tmp_cursor = NULL; DB_TXN* tmp_txn = NULL; - const int empty_scan = THDVAR(ha_thd(), empty_scan); - if (empty_scan == TOKUDB_EMPTY_SCAN_DISABLED) + const int empty_scan = tokudb::sysvars::empty_scan(ha_thd()); + if (empty_scan == tokudb::sysvars::TOKUDB_EMPTY_SCAN_DISABLED) goto cleanup; if (txn == NULL) { @@ -3128,7 +3321,7 @@ bool ha_tokudb::may_table_be_empty(DB_TXN *txn) { if (error) goto cleanup; tmp_cursor->c_set_check_interrupt_callback(tmp_cursor, tokudb_killed_thd_callback, ha_thd()); - if (empty_scan == TOKUDB_EMPTY_SCAN_LR) + if (empty_scan == tokudb::sysvars::TOKUDB_EMPTY_SCAN_LR) error = tmp_cursor->c_getf_next(tmp_cursor, 0, smart_dbt_do_nothing, NULL); else error = tmp_cursor->c_getf_prev(tmp_cursor, 0, smart_dbt_do_nothing, NULL); @@ -3142,7 +3335,7 @@ bool ha_tokudb::may_table_be_empty(DB_TXN *txn) { cleanup: if (tmp_cursor) { int r = tmp_cursor->c_close(tmp_cursor); - assert(r == 0); + assert_always(r == 0); tmp_cursor = NULL; } if (tmp_txn) { @@ -3165,23 +3358,24 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) { ai_metadata_update_required = false; abort_loader = false; - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); num_DBs_locked_in_bulk = true; lock_count = 0; if ((rows == 0 || rows > 1) && share->try_table_lock) { - if (get_prelock_empty(thd) && may_table_be_empty(transaction) && transaction != NULL) { + if (tokudb::sysvars::prelock_empty(thd) && + may_table_be_empty(transaction) && + transaction != NULL) { if (using_ignore || is_insert_ignore(thd) || thd->lex->duplicates != DUP_ERROR || table->s->next_number_key_offset) { acquire_table_lock(transaction, lock_write); - } - else { + } else { mult_dbt_flags[primary_key] = 0; if (!thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS) && !hidden_primary_key) { mult_put_flags[primary_key] = DB_NOOVERWRITE; } - uint32_t loader_flags = (get_load_save_space(thd)) ? + uint32_t loader_flags = (tokudb::sysvars::load_save_space(thd)) ? LOADER_COMPRESS_INTERMEDIATES : 0; int error = db_env->create_loader( @@ -3196,7 +3390,7 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) { loader_flags ); if (error) { - assert(loader == NULL); + assert_always(loader == NULL); goto exit_try_table_lock; } @@ -3204,18 +3398,18 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) { lc.ha = this; error = loader->set_poll_function(loader, loader_poll_fun, &lc); - assert(!error); + assert_always(!error); error = loader->set_error_callback(loader, loader_dup_fun, &lc); - assert(!error); + assert_always(!error); trx->stmt_progress.using_loader = true; } } exit_try_table_lock: - tokudb_pthread_mutex_lock(&share->mutex); + share->lock(); share->try_table_lock = false; - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); } TOKUDB_HANDLER_DBUG_VOID_RETURN; } @@ -3232,9 +3426,9 @@ int ha_tokudb::end_bulk_insert(bool abort) { tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); bool using_loader = (loader != NULL); if (ai_metadata_update_required) { - tokudb_pthread_mutex_lock(&share->mutex); + share->lock(); error = update_max_auto_inc(share->status_block, share->last_auto_increment); - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); if (error) { goto cleanup; } } delay_updating_ai_metadata = false; @@ -3285,7 +3479,7 @@ int ha_tokudb::end_bulk_insert(bool abort) { cleanup: if (num_DBs_locked_in_bulk) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } num_DBs_locked_in_bulk = false; lock_count = 0; @@ -3380,10 +3574,10 @@ int ha_tokudb::is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_in cnt++; if ((cnt % 10000) == 0) { sprintf( - status_msg, - "Verifying index uniqueness: Checked %llu of %llu rows in key-%s.", - (long long unsigned) cnt, - share->rows, + status_msg, + "Verifying index uniqueness: Checked %llu of %llu rows in key-%s.", + (long long unsigned) cnt, + share->row_count(), key_info->name); thd_proc_info(thd, status_msg); if (thd_killed(thd)) { @@ -3467,7 +3661,7 @@ int ha_tokudb::is_val_unique(bool* is_unique, uchar* record, KEY* key_info, uint cleanup: if (tmp_cursor) { int r = tmp_cursor->c_close(tmp_cursor); - assert(r==0); + assert_always(r==0); tmp_cursor = NULL; } return error; @@ -3475,21 +3669,25 @@ cleanup: static void maybe_do_unique_checks_delay(THD *thd) { if (thd->slave_thread) { - uint64_t delay_ms = THDVAR(thd, rpl_unique_checks_delay); + uint64_t delay_ms = tokudb::sysvars::rpl_unique_checks_delay(thd); if (delay_ms) usleep(delay_ms * 1000); } } static bool need_read_only(THD *thd) { - return opt_readonly || !THDVAR(thd, rpl_check_readonly); -} + return opt_readonly || !tokudb::sysvars::rpl_check_readonly(thd); +} static bool do_unique_checks(THD *thd, bool do_rpl_event) { - if (do_rpl_event && thd->slave_thread && need_read_only(thd) && !THDVAR(thd, rpl_unique_checks)) + if (do_rpl_event && + thd->slave_thread && + need_read_only(thd) && + !tokudb::sysvars::rpl_unique_checks(thd)) { return false; - else + } else { return !thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS); + } } int ha_tokudb::do_uniqueness_checks(uchar* record, DB_TXN* txn, THD* thd) { @@ -3552,10 +3750,10 @@ void ha_tokudb::test_row_packing(uchar* record, DBT* pk_key, DBT* pk_val) { // //use for testing the packing of keys // - tmp_pk_key_data = (uchar *)tokudb_my_malloc(pk_key->size, MYF(MY_WME)); - assert(tmp_pk_key_data); - tmp_pk_val_data = (uchar *)tokudb_my_malloc(pk_val->size, MYF(MY_WME)); - assert(tmp_pk_val_data); + tmp_pk_key_data = (uchar*)tokudb::memory::malloc(pk_key->size, MYF(MY_WME)); + assert_always(tmp_pk_key_data); + tmp_pk_val_data = (uchar*)tokudb::memory::malloc(pk_val->size, MYF(MY_WME)); + assert_always(tmp_pk_val_data); memcpy(tmp_pk_key_data, pk_key->data, pk_key->size); memcpy(tmp_pk_val_data, pk_val->data, pk_val->size); tmp_pk_key.data = tmp_pk_key_data; @@ -3588,19 +3786,21 @@ void ha_tokudb::test_row_packing(uchar* record, DBT* pk_key, DBT* pk_val) { &tmp_pk_key, &tmp_pk_val ); - assert(tmp_num_bytes == key.size); + assert_always(tmp_num_bytes == key.size); cmp = memcmp(key_buff3,key_buff2,tmp_num_bytes); - assert(cmp == 0); + assert_always(cmp == 0); // // test key packing of clustering keys // if (key_is_clustering(&table->key_info[keynr])) { error = pack_row(&row, (const uchar *) record, keynr); - assert(error == 0); + assert_always(error == 0); uchar* tmp_buff = NULL; - tmp_buff = (uchar *)tokudb_my_malloc(alloced_rec_buff_length,MYF(MY_WME)); - assert(tmp_buff); + tmp_buff = (uchar*)tokudb::memory::malloc( + alloced_rec_buff_length, + MYF(MY_WME)); + assert_always(tmp_buff); row_desc = (uchar *)share->key_file[keynr]->descriptor->dbt.data; row_desc += (*(uint32_t *)row_desc); row_desc += (*(uint32_t *)row_desc); @@ -3612,10 +3812,10 @@ void ha_tokudb::test_row_packing(uchar* record, DBT* pk_key, DBT* pk_val) { desc_size, &tmp_pk_val ); - assert(tmp_num_bytes == row.size); + assert_always(tmp_num_bytes == row.size); cmp = memcmp(tmp_buff,rec_buff,tmp_num_bytes); - assert(cmp == 0); - tokudb_my_free(tmp_buff); + assert_always(cmp == 0); + tokudb::memory::free(tmp_buff); } } @@ -3623,12 +3823,12 @@ void ha_tokudb::test_row_packing(uchar* record, DBT* pk_key, DBT* pk_val) { // copy stuff back out // error = pack_row(pk_val, (const uchar *) record, primary_key); - assert(pk_val->size == tmp_pk_val.size); + assert_always(pk_val->size == tmp_pk_val.size); cmp = memcmp(pk_val->data, tmp_pk_val_data, pk_val->size); - assert( cmp == 0); + assert_always( cmp == 0); - tokudb_my_free(tmp_pk_key_data); - tokudb_my_free(tmp_pk_val_data); + tokudb::memory::free(tmp_pk_key_data); + tokudb::memory::free(tmp_pk_val_data); } // set the put flags for the main dictionary @@ -3675,7 +3875,7 @@ void ha_tokudb::set_main_dict_put_flags(THD* thd, bool opt_eligible, uint32_t* p int ha_tokudb::insert_row_to_main_dictionary(uchar* record, DBT* pk_key, DBT* pk_val, DB_TXN* txn) { int error = 0; uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); - assert(curr_num_DBs == 1); + assert_always(curr_num_DBs == 1); uint32_t put_flags = mult_put_flags[primary_key]; THD *thd = ha_thd(); @@ -3807,33 +4007,36 @@ int ha_tokudb::write_row(uchar * record) { // of the auto inc field. // if (share->has_auto_inc && record == table->record[0]) { - tokudb_pthread_mutex_lock(&share->mutex); + share->lock(); ulonglong curr_auto_inc = retrieve_auto_increment( - table->field[share->ai_field_index]->key_type(), field_offset(table->field[share->ai_field_index], table), record); + table->field[share->ai_field_index]->key_type(), + field_offset(table->field[share->ai_field_index], table), + record); if (curr_auto_inc > share->last_auto_increment) { share->last_auto_increment = curr_auto_inc; if (delay_updating_ai_metadata) { ai_metadata_update_required = true; - } - else { - update_max_auto_inc(share->status_block, share->last_auto_increment); + } else { + update_max_auto_inc( + share->status_block, + share->last_auto_increment); } } - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); } // // grab reader lock on numDBs_lock // if (!num_DBs_locked_in_bulk) { - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); num_DBs_locked = true; } else { lock_count++; if (lock_count >= 2000) { - rw_unlock(&share->num_DBs_lock); - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); + share->_num_DBs_lock.lock_read(); lock_count = 0; } } @@ -3863,10 +4066,8 @@ int ha_tokudb::write_row(uchar * record) { } } txn = create_sub_trans ? sub_trans : transaction; - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("txn %p", txn); - } - if (tokudb_debug & TOKUDB_DEBUG_CHECK_KEY) { + TOKUDB_HANDLER_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "txn %p", txn); + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_CHECK_KEY))) { test_row_packing(record,&prim_key,&row); } if (loader) { @@ -3875,8 +4076,7 @@ int ha_tokudb::write_row(uchar * record) { abort_loader = true; goto cleanup; } - } - else { + } else { error = do_uniqueness_checks(record, txn, thd); if (error) { // for #4633 @@ -3889,8 +4089,7 @@ int ha_tokudb::write_row(uchar * record) { // was found and this is a duplicate key, // so we set last_dup_key last_dup_key = primary_key; - } - else if (r != DB_NOTFOUND) { + } else if (r != DB_NOTFOUND) { // if some other error is returned, return that to the user. error = r; } @@ -3900,8 +4099,7 @@ int ha_tokudb::write_row(uchar * record) { if (curr_num_DBs == 1) { error = insert_row_to_main_dictionary(record,&prim_key, &row, txn); if (error) { goto cleanup; } - } - else { + } else { error = insert_rows_to_dictionaries_mult(&prim_key, &row, txn, thd); if (error) { goto cleanup; } } @@ -3919,7 +4117,7 @@ int ha_tokudb::write_row(uchar * record) { } cleanup: if (num_DBs_locked) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } if (error == DB_KEYEXIST) { error = HA_ERR_FOUND_DUPP_KEY; @@ -3989,7 +4187,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { // of the auto inc field. // if (share->has_auto_inc && new_row == table->record[0]) { - tokudb_pthread_mutex_lock(&share->mutex); + share->lock(); ulonglong curr_auto_inc = retrieve_auto_increment( table->field[share->ai_field_index]->key_type(), field_offset(table->field[share->ai_field_index], table), @@ -4001,7 +4199,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { share->last_auto_increment = curr_auto_inc; } } - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); } // @@ -4009,7 +4207,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { // bool num_DBs_locked = false; if (!num_DBs_locked_in_bulk) { - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); num_DBs_locked = true; } curr_num_DBs = share->num_DBs; @@ -4100,6 +4298,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { last_dup_key = primary_key; } else if (!error) { + updated_rows++; trx->stmt_progress.updated++; track_progress(thd); } @@ -4107,7 +4306,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { cleanup: if (num_DBs_locked) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } if (error == DB_KEYEXIST) { error = HA_ERR_FOUND_DUPP_KEY; @@ -4150,7 +4349,7 @@ int ha_tokudb::delete_row(const uchar * record) { // bool num_DBs_locked = false; if (!num_DBs_locked_in_bulk) { - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); num_DBs_locked = true; } curr_num_DBs = share->num_DBs; @@ -4166,33 +4365,36 @@ int ha_tokudb::delete_row(const uchar * record) { goto cleanup; } - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("all %p stmt %p sub_sp_level %p transaction %p", trx->all, trx->stmt, trx->sub_sp_level, transaction); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "all %p stmt %p sub_sp_level %p transaction %p", + trx->all, + trx->stmt, + trx->sub_sp_level, + transaction); - error = db_env->del_multiple( - db_env, - share->key_file[primary_key], - transaction, - &prim_key, - &row, - curr_num_DBs, - share->key_file, - mult_key_dbt_array, - mult_del_flags - ); + error = + db_env->del_multiple( + db_env, + share->key_file[primary_key], + transaction, + &prim_key, + &row, + curr_num_DBs, + share->key_file, + mult_key_dbt_array, + mult_del_flags); if (error) { DBUG_PRINT("error", ("Got error %d", error)); - } - else { + } else { deleted_rows++; trx->stmt_progress.deleted++; track_progress(thd); } cleanup: if (num_DBs_locked) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -4287,11 +4489,16 @@ cleanup: TOKUDB_HANDLER_DBUG_RETURN(error); } -static bool index_key_is_null(TABLE *table, uint keynr, const uchar *key, uint key_len) { +static bool index_key_is_null( + TABLE* table, + uint keynr, + const uchar* key, + uint key_len) { + bool key_can_be_null = false; - KEY *key_info = &table->key_info[keynr]; - KEY_PART_INFO *key_part = key_info->key_part; - KEY_PART_INFO *end = key_part + get_key_parts(key_info); + KEY* key_info = &table->key_info[keynr]; + KEY_PART_INFO* key_part = key_info->key_part; + KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts; for (; key_part != end; key_part++) { if (key_part->null_bit) { key_can_be_null = true; @@ -4309,7 +4516,7 @@ static bool tokudb_do_bulk_fetch(THD *thd) { case SQLCOM_INSERT_SELECT: case SQLCOM_REPLACE_SELECT: case SQLCOM_DELETE: - return THDVAR(thd, bulk_fetch) != 0; + return tokudb::sysvars::bulk_fetch(thd) != 0; default: return false; } @@ -4361,7 +4568,7 @@ cleanup: // if (cursor) { int r = cursor->c_close(cursor); - assert(r==0); + assert_always(r==0); cursor = NULL; remove_from_trx_handler_list(); } @@ -4404,7 +4611,7 @@ int ha_tokudb::index_init(uint keynr, bool sorted) { if (cursor) { DBUG_PRINT("note", ("Closing active cursor")); int r = cursor->c_close(cursor); - assert(r==0); + assert_always(r==0); remove_from_trx_handler_list(); } active_index = keynr; @@ -4430,10 +4637,12 @@ int ha_tokudb::index_init(uint keynr, bool sorted) { if (use_write_locks) { cursor_flags |= DB_RMW; } - if (get_disable_prefetching(thd)) { + if (tokudb::sysvars::disable_prefetching(thd)) { cursor_flags |= DBC_DISABLE_PREFETCHING; } - if ((error = share->key_file[keynr]->cursor(share->key_file[keynr], transaction, &cursor, cursor_flags))) { + if ((error = share->key_file[keynr]->cursor(share->key_file[keynr], + transaction, &cursor, + cursor_flags))) { if (error == TOKUDB_MVCC_DICTIONARY_TOO_NEW) { error = HA_ERR_TABLE_DEF_CHANGED; my_error(ER_TABLE_DEF_CHANGED, MYF(0)); @@ -4478,7 +4687,7 @@ int ha_tokudb::index_end() { if (cursor) { DBUG_PRINT("enter", ("table: '%s'", table_share->table_name.str)); int r = cursor->c_close(cursor); - assert(r==0); + assert_always(r==0); cursor = NULL; remove_from_trx_handler_list(); last_cursor_error = 0; @@ -4546,7 +4755,7 @@ void ha_tokudb::extract_hidden_primary_key(uint keynr, DBT const *found_key) { int ha_tokudb::read_row_callback (uchar * buf, uint keynr, DBT const *row, DBT const *found_key) { - assert(keynr == primary_key); + assert_always(keynr == primary_key); return unpack_row(buf, row,found_key, keynr); } @@ -4672,7 +4881,7 @@ int ha_tokudb::read_full_row(uchar * buf) { // HA_ERR_END_OF_FILE if not found // error otherwise // -int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) { +int ha_tokudb::index_next_same(uchar* buf, const uchar* key, uint keylen) { TOKUDB_HANDLER_DBUG_ENTER(""); ha_statistic_increment(&SSV::ha_read_next_count); @@ -4690,8 +4899,16 @@ int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) { // // now do the comparison // - create_dbt_key_from_table(&found_key,tokudb_active_index,key_buff3,buf,&has_null); - cmp = tokudb_prefix_cmp_dbt_key(share->key_file[tokudb_active_index], &curr_key, &found_key); + create_dbt_key_from_table( + &found_key, + tokudb_active_index, + key_buff3,buf, + &has_null); + cmp = + tokudb_prefix_cmp_dbt_key( + share->key_file[tokudb_active_index], + &curr_key, + &found_key); if (cmp) { error = HA_ERR_END_OF_FILE; } @@ -4703,7 +4920,7 @@ cleanup: // -// According to InnoDB handlerton: Positions an index cursor to the index +// According to InnoDB handlerton: Positions an index cursor to the index // specified in keynr. Fetches the row if any // Parameters: // [out] buf - buffer for the returned row @@ -4719,10 +4936,20 @@ cleanup: // TODO: investigate this for correctness // error otherwise // -int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag) { - TOKUDB_HANDLER_DBUG_ENTER("key %p %u:%2.2x find=%u", key, key_len, key ? key[0] : 0, find_flag); +int ha_tokudb::index_read( + uchar* buf, + const uchar* key, + uint key_len, + enum ha_rkey_function find_flag) { + + TOKUDB_HANDLER_DBUG_ENTER( + "key %p %u:%2.2x find=%u", + key, + key_len, + key ? key[0] : 0, + find_flag); invalidate_bulk_fetch(); - if (tokudb_debug & TOKUDB_DEBUG_INDEX_KEY) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_INDEX_KEY))) { TOKUDB_DBUG_DUMP("mysql key=", key, key_len); } DBT row; @@ -4730,14 +4957,17 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ int error = 0; uint32_t flags = 0; THD* thd = ha_thd(); - tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton);; + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); struct smart_dbt_info info; struct index_read_info ir_info; HANDLE_INVALID_CURSOR(); - // if we locked a non-null key range and we now have a null key, then remove the bounds from the cursor - if (range_lock_grabbed && !range_lock_grabbed_null && index_key_is_null(table, tokudb_active_index, key, key_len)) { + // if we locked a non-null key range and we now have a null key, then + // remove the bounds from the cursor + if (range_lock_grabbed && + !range_lock_grabbed_null && + index_key_is_null(table, tokudb_active_index, key, key_len)) { range_lock_grabbed = range_lock_grabbed_null = false; cursor->c_remove_restriction(cursor); } @@ -4758,7 +4988,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ pack_key(&lookup_key, tokudb_active_index, key_buff3, key, key_len, COL_NEG_INF); DBT lookup_bound; pack_key(&lookup_bound, tokudb_active_index, key_buff4, key, key_len, COL_POS_INF); - if (tokudb_debug & TOKUDB_DEBUG_INDEX_KEY) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_INDEX_KEY))) { TOKUDB_DBUG_DUMP("tokudb key=", lookup_key.data, lookup_key.size); } ir_info.orig_key = &lookup_key; @@ -4815,8 +5045,8 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ if (!error && !key_read && tokudb_active_index != primary_key && !key_is_clustering(&table->key_info[tokudb_active_index])) { error = read_full_row(buf); } - - if (error && (tokudb_debug & TOKUDB_DEBUG_ERROR)) { + + if (TOKUDB_UNLIKELY(error && TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ERROR))) { TOKUDB_HANDLER_TRACE("error:%d:%d", error, find_flag); } trx->stmt_progress.queried++; @@ -4845,7 +5075,7 @@ int ha_tokudb::read_data_from_range_query_buff(uchar* buf, bool need_val, bool d // if this is a covering index, this is all we need if (do_key_read) { - assert(!need_val); + assert_always(!need_val); extract_hidden_primary_key(tokudb_active_index, &curr_key); read_key_only(buf, tokudb_active_index, &curr_key); error = 0; @@ -4937,17 +5167,27 @@ exit: return error; } -static int -smart_dbt_bf_callback(DBT const *key, DBT const *row, void *context) { +static int smart_dbt_bf_callback( + DBT const* key, + DBT const* row, + void* context) { SMART_DBT_BF_INFO info = (SMART_DBT_BF_INFO)context; - return info->ha->fill_range_query_buf(info->need_val, key, row, info->direction, info->thd, info->buf, info->key_to_compare); + return + info->ha->fill_range_query_buf( + info->need_val, + key, + row, + info->direction, + info->thd, + info->buf, + info->key_to_compare); } -#if defined(MARIADB_BASE_VERSION) || (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) -enum icp_result ha_tokudb::toku_handler_index_cond_check(Item* pushed_idx_cond) -{ +enum icp_result ha_tokudb::toku_handler_index_cond_check( + Item* pushed_idx_cond) { + enum icp_result res; - if (end_range ) { + if (end_range) { int cmp; #ifdef MARIADB_BASE_VERSION cmp = compare_key2(end_range); @@ -4957,37 +5197,36 @@ enum icp_result ha_tokudb::toku_handler_index_cond_check(Item* pushed_idx_cond) if (cmp > 0) { return ICP_OUT_OF_RANGE; } - } + } res = pushed_idx_cond->val_int() ? ICP_MATCH : ICP_NO_MATCH; return res; } -#endif // fill in the range query buf for bulk fetch int ha_tokudb::fill_range_query_buf( bool need_val, - DBT const *key, - DBT const *row, + DBT const* key, + DBT const* row, int direction, THD* thd, uchar* buf, - DBT* key_to_compare - ) { + DBT* key_to_compare) { + int error; // // first put the value into range_query_buf // - uint32_t size_remaining = size_range_query_buff - bytes_used_in_range_query_buff; + uint32_t size_remaining = + size_range_query_buff - bytes_used_in_range_query_buff; uint32_t size_needed; - uint32_t user_defined_size = get_tokudb_read_buf_size(thd); + uint32_t user_defined_size = tokudb::sysvars::read_buf_size(thd); uchar* curr_pos = NULL; if (key_to_compare) { int cmp = tokudb_prefix_cmp_dbt_key( share->key_file[tokudb_active_index], key_to_compare, - key - ); + key); if (cmp) { icp_went_out_of_range = true; error = 0; @@ -4995,26 +5234,38 @@ int ha_tokudb::fill_range_query_buf( } } -#if defined(MARIADB_BASE_VERSION) || (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) // if we have an index condition pushed down, we check it - if (toku_pushed_idx_cond && (tokudb_active_index == toku_pushed_idx_cond_keyno)) { + if (toku_pushed_idx_cond && + (tokudb_active_index == toku_pushed_idx_cond_keyno)) { unpack_key(buf, key, tokudb_active_index); - enum icp_result result = toku_handler_index_cond_check(toku_pushed_idx_cond); + enum icp_result result = + toku_handler_index_cond_check(toku_pushed_idx_cond); + // If we have reason to stop, we set icp_went_out_of_range and get out - if (result == ICP_OUT_OF_RANGE || thd_killed(thd)) { - icp_went_out_of_range = true; - error = 0; - goto cleanup; - } // otherwise, if we simply see that the current key is no match, // we tell the cursor to continue and don't store // the key locally - else if (result == ICP_NO_MATCH) { + if (result == ICP_OUT_OF_RANGE || thd_killed(thd)) { + icp_went_out_of_range = true; + error = 0; + DEBUG_SYNC(ha_thd(), "tokudb_icp_asc_scan_out_of_range"); + goto cleanup; + } else if (result == ICP_NO_MATCH) { + // if we are performing a DESC ICP scan and have no end_range + // to compare to stop using ICP filtering as there isn't much more + // that we can do without going through contortions with remembering + // and comparing key parts. + if (!end_range && + direction < 0) { + + cancel_pushed_idx_cond(); + DEBUG_SYNC(ha_thd(), "tokudb_icp_desc_scan_invalidate"); + } + error = TOKUDB_CURSOR_CONTINUE; goto cleanup; } } -#endif // at this point, if ICP is on, we have verified that the key is one // we are interested in, so we proceed with placing the data @@ -5023,57 +5274,63 @@ int ha_tokudb::fill_range_query_buf( if (need_val) { if (unpack_entire_row) { size_needed = 2*sizeof(uint32_t) + key->size + row->size; - } - else { + } else { // this is an upper bound - size_needed = sizeof(uint32_t) + // size of key length - key->size + row->size + //key and row - num_var_cols_for_query*(sizeof(uint32_t)) + //lengths of varchars stored - sizeof(uint32_t); //length of blobs + size_needed = + // size of key length + sizeof(uint32_t) + + // key and row + key->size + row->size + + // lengths of varchars stored + num_var_cols_for_query * (sizeof(uint32_t)) + + // length of blobs + sizeof(uint32_t); } - } - else { + } else { size_needed = sizeof(uint32_t) + key->size; } if (size_remaining < size_needed) { - range_query_buff = (uchar *)tokudb_my_realloc( - (void *)range_query_buff, - bytes_used_in_range_query_buff+size_needed, - MYF(MY_WME) - ); + range_query_buff = + static_cast(tokudb::memory::realloc( + static_cast(range_query_buff), + bytes_used_in_range_query_buff + size_needed, + MYF(MY_WME))); if (range_query_buff == NULL) { error = ENOMEM; invalidate_bulk_fetch(); goto cleanup; } - size_range_query_buff = bytes_used_in_range_query_buff+size_needed; + size_range_query_buff = bytes_used_in_range_query_buff + size_needed; } // // now we know we have the size, let's fill the buffer, starting with the key // curr_pos = range_query_buff + bytes_used_in_range_query_buff; - *(uint32_t *)curr_pos = key->size; + *reinterpret_cast(curr_pos) = key->size; curr_pos += sizeof(uint32_t); memcpy(curr_pos, key->data, key->size); curr_pos += key->size; if (need_val) { if (unpack_entire_row) { - *(uint32_t *)curr_pos = row->size; + *reinterpret_cast(curr_pos) = row->size; curr_pos += sizeof(uint32_t); memcpy(curr_pos, row->data, row->size); curr_pos += row->size; - } - else { + } else { // need to unpack just the data we care about - const uchar* fixed_field_ptr = (const uchar *) row->data; + const uchar* fixed_field_ptr = static_cast(row->data); fixed_field_ptr += table_share->null_bytes; const uchar* var_field_offset_ptr = NULL; const uchar* var_field_data_ptr = NULL; - var_field_offset_ptr = fixed_field_ptr + share->kc_info.mcp_info[tokudb_active_index].fixed_field_size; - var_field_data_ptr = var_field_offset_ptr + share->kc_info.mcp_info[tokudb_active_index].len_of_offsets; + var_field_offset_ptr = + fixed_field_ptr + + share->kc_info.mcp_info[tokudb_active_index].fixed_field_size; + var_field_data_ptr = + var_field_offset_ptr + + share->kc_info.mcp_info[tokudb_active_index].len_of_offsets; // first the null bytes memcpy(curr_pos, row->data, table_share->null_bytes); @@ -5087,8 +5344,7 @@ int ha_tokudb::fill_range_query_buf( memcpy( curr_pos, fixed_field_ptr + share->kc_info.cp_info[tokudb_active_index][field_index].col_pack_val, - share->kc_info.field_lengths[field_index] - ); + share->kc_info.field_lengths[field_index]); curr_pos += share->kc_info.field_lengths[field_index]; } @@ -5097,7 +5353,8 @@ int ha_tokudb::fill_range_query_buf( // for (uint32_t i = 0; i < num_var_cols_for_query; i++) { uint field_index = var_cols_for_query[i]; - uint32_t var_field_index = share->kc_info.cp_info[tokudb_active_index][field_index].col_pack_val; + uint32_t var_field_index = + share->kc_info.cp_info[tokudb_active_index][field_index].col_pack_val; uint32_t data_start_offset; uint32_t field_len; @@ -5106,11 +5363,13 @@ int ha_tokudb::fill_range_query_buf( &data_start_offset, var_field_index, var_field_offset_ptr, - share->kc_info.num_offset_bytes - ); + share->kc_info.num_offset_bytes); memcpy(curr_pos, &field_len, sizeof(field_len)); curr_pos += sizeof(field_len); - memcpy(curr_pos, var_field_data_ptr + data_start_offset, field_len); + memcpy( + curr_pos, + var_field_data_ptr + data_start_offset, + field_len); curr_pos += field_len; } @@ -5124,9 +5383,12 @@ int ha_tokudb::fill_range_query_buf( &blob_offset, share->kc_info.mcp_info[tokudb_active_index].len_of_offsets, var_field_data_ptr, - share->kc_info.num_offset_bytes - ); - data_size = row->size - blob_offset - (uint32_t)(var_field_data_ptr - (const uchar *)row->data); + share->kc_info.num_offset_bytes); + data_size = + row->size - + blob_offset - + static_cast((var_field_data_ptr - + static_cast(row->data))); memcpy(curr_pos, &data_size, sizeof(data_size)); curr_pos += sizeof(data_size); memcpy(curr_pos, var_field_data_ptr + blob_offset, data_size); @@ -5136,7 +5398,7 @@ int ha_tokudb::fill_range_query_buf( } bytes_used_in_range_query_buff = curr_pos - range_query_buff; - assert(bytes_used_in_range_query_buff <= size_range_query_buff); + assert_always(bytes_used_in_range_query_buff <= size_range_query_buff); // // now determine if we should continue with the bulk fetch @@ -5153,14 +5415,16 @@ int ha_tokudb::fill_range_query_buf( // row fetch upper bound. if (bulk_fetch_iteration < HA_TOKU_BULK_FETCH_ITERATION_MAX) { uint64_t row_fetch_upper_bound = 1LLU << bulk_fetch_iteration; - assert(row_fetch_upper_bound > 0); + assert_always(row_fetch_upper_bound > 0); if (rows_fetched_using_bulk_fetch >= row_fetch_upper_bound) { error = 0; goto cleanup; } } - if (bytes_used_in_range_query_buff + table_share->rec_buff_length > user_defined_size) { + if (bytes_used_in_range_query_buff + + table_share->rec_buff_length > + user_defined_size) { error = 0; goto cleanup; } @@ -5178,11 +5442,9 @@ int ha_tokudb::fill_range_query_buf( int cmp = tokudb_cmp_dbt_key( share->key_file[tokudb_active_index], key, - &right_range - ); + &right_range); error = (cmp > 0) ? 0 : TOKUDB_CURSOR_CONTINUE; - } - else { + } else { // compare what we got to the left endpoint of prelocked range // because we are searching keys in descending order if (prelocked_left_range_size == 0) { @@ -5196,15 +5458,19 @@ int ha_tokudb::fill_range_query_buf( int cmp = tokudb_cmp_dbt_key( share->key_file[tokudb_active_index], key, - &left_range - ); + &left_range); error = (cmp < 0) ? 0 : TOKUDB_CURSOR_CONTINUE; } cleanup: return error; } -int ha_tokudb::get_next(uchar* buf, int direction, DBT* key_to_compare, bool do_key_read) { +int ha_tokudb::get_next( + uchar* buf, + int direction, + DBT* key_to_compare, + bool do_key_read) { + int error = 0; HANDLE_INVALID_CURSOR(); @@ -5221,17 +5487,18 @@ int ha_tokudb::get_next(uchar* buf, int direction, DBT* key_to_compare, bool do_ // we need to read the val of what we retrieve if // we do NOT have a covering index AND we are using a clustering secondary // key - bool need_val = (do_key_read == 0) && - (tokudb_active_index == primary_key || key_is_clustering(&table->key_info[tokudb_active_index])); + bool need_val = + (do_key_read == 0) && + (tokudb_active_index == primary_key || + key_is_clustering(&table->key_info[tokudb_active_index])); - if ((bytes_used_in_range_query_buff - curr_range_query_buff_offset) > 0) { + if ((bytes_used_in_range_query_buff - + curr_range_query_buff_offset) > 0) { error = read_data_from_range_query_buff(buf, need_val, do_key_read); - } - else if (icp_went_out_of_range) { + } else if (icp_went_out_of_range) { icp_went_out_of_range = false; error = HA_ERR_END_OF_FILE; - } - else { + } else { invalidate_bulk_fetch(); if (doing_bulk_fetch) { struct smart_dbt_bf_info bf_info; @@ -5252,16 +5519,28 @@ int ha_tokudb::get_next(uchar* buf, int direction, DBT* key_to_compare, bool do_ // this while loop. icp_out_of_range will be set if we hit a row that // the index condition states is out of our range. When that hits, // we know all the data in the buffer is the last data we will retrieve - while (bytes_used_in_range_query_buff == 0 && !icp_went_out_of_range && error == 0) { + while (bytes_used_in_range_query_buff == 0 && + !icp_went_out_of_range && error == 0) { if (direction > 0) { - error = cursor->c_getf_next(cursor, flags, smart_dbt_bf_callback, &bf_info); + error = + cursor->c_getf_next( + cursor, + flags, + smart_dbt_bf_callback, + &bf_info); } else { - error = cursor->c_getf_prev(cursor, flags, smart_dbt_bf_callback, &bf_info); + error = + cursor->c_getf_prev( + cursor, + flags, + smart_dbt_bf_callback, + &bf_info); } } // if there is no data set and we went out of range, // then there is nothing to return - if (bytes_used_in_range_query_buff == 0 && icp_went_out_of_range) { + if (bytes_used_in_range_query_buff == 0 && + icp_went_out_of_range) { icp_went_out_of_range = false; error = HA_ERR_END_OF_FILE; } @@ -5269,26 +5548,46 @@ int ha_tokudb::get_next(uchar* buf, int direction, DBT* key_to_compare, bool do_ bulk_fetch_iteration++; } - error = handle_cursor_error(error, HA_ERR_END_OF_FILE,tokudb_active_index); - if (error) { goto cleanup; } + error = + handle_cursor_error( + error, + HA_ERR_END_OF_FILE, + tokudb_active_index); + if (error) { + goto cleanup; + } // // now that range_query_buff is filled, read an element // - error = read_data_from_range_query_buff(buf, need_val, do_key_read); - } - else { + error = + read_data_from_range_query_buff(buf, need_val, do_key_read); + } else { struct smart_dbt_info info; info.ha = this; info.buf = buf; info.keynr = tokudb_active_index; if (direction > 0) { - error = cursor->c_getf_next(cursor, flags, SMART_DBT_CALLBACK(do_key_read), &info); + error = + cursor->c_getf_next( + cursor, + flags, + SMART_DBT_CALLBACK(do_key_read), + &info); } else { - error = cursor->c_getf_prev(cursor, flags, SMART_DBT_CALLBACK(do_key_read), &info); + error = + cursor->c_getf_prev( + cursor, + flags, + SMART_DBT_CALLBACK(do_key_read), + &info); } - error = handle_cursor_error(error, HA_ERR_END_OF_FILE, tokudb_active_index); + error = + handle_cursor_error( + error, + HA_ERR_END_OF_FILE, + tokudb_active_index); } } } @@ -5301,13 +5600,17 @@ int ha_tokudb::get_next(uchar* buf, int direction, DBT* key_to_compare, bool do_ // read the full row by doing a point query into the // main table. // - if (!error && !do_key_read && (tokudb_active_index != primary_key) && !key_is_clustering(&table->key_info[tokudb_active_index])) { + if (!error && + !do_key_read && + (tokudb_active_index != primary_key) && + !key_is_clustering(&table->key_info[tokudb_active_index])) { error = read_full_row(buf); } if (!error) { THD *thd = ha_thd(); - tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); + tokudb_trx_data* trx = + static_cast(thd_get_ha_data(thd, tokudb_hton)); trx->stmt_progress.queried++; track_progress(thd); if (thd_killed(thd)) @@ -5509,40 +5812,69 @@ int ha_tokudb::rnd_next(uchar * buf) { void ha_tokudb::track_progress(THD* thd) { tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); if (trx) { - ulonglong num_written = trx->stmt_progress.inserted + trx->stmt_progress.updated + trx->stmt_progress.deleted; + ulonglong num_written = trx->stmt_progress.inserted + + trx->stmt_progress.updated + + trx->stmt_progress.deleted; bool update_status = - (trx->stmt_progress.queried && tokudb_read_status_frequency && (trx->stmt_progress.queried % tokudb_read_status_frequency) == 0) || - (num_written && tokudb_write_status_frequency && (num_written % tokudb_write_status_frequency) == 0); + (trx->stmt_progress.queried && + tokudb::sysvars::read_status_frequency && + (trx->stmt_progress.queried % + tokudb::sysvars::read_status_frequency) == 0) || + (num_written && tokudb::sysvars::write_status_frequency && + (num_written % tokudb::sysvars::write_status_frequency) == 0); if (update_status) { char *next_status = write_status_msg; bool first = true; int r; if (trx->stmt_progress.queried) { - r = sprintf(next_status, "Queried about %llu row%s", trx->stmt_progress.queried, trx->stmt_progress.queried == 1 ? "" : "s"); - assert(r >= 0); + r = sprintf( + next_status, + "Queried about %llu row%s", + trx->stmt_progress.queried, + trx->stmt_progress.queried == 1 ? "" : "s"); + assert_always(r >= 0); next_status += r; first = false; } if (trx->stmt_progress.inserted) { if (trx->stmt_progress.using_loader) { - r = sprintf(next_status, "%sFetched about %llu row%s, loading data still remains", first ? "" : ", ", trx->stmt_progress.inserted, trx->stmt_progress.inserted == 1 ? "" : "s"); + r = sprintf( + next_status, + "%sFetched about %llu row%s, loading data still remains", + first ? "" : ", ", + trx->stmt_progress.inserted, + trx->stmt_progress.inserted == 1 ? "" : "s"); + } else { + r = sprintf( + next_status, + "%sInserted about %llu row%s", + first ? "" : ", ", + trx->stmt_progress.inserted, + trx->stmt_progress.inserted == 1 ? "" : "s"); } - else { - r = sprintf(next_status, "%sInserted about %llu row%s", first ? "" : ", ", trx->stmt_progress.inserted, trx->stmt_progress.inserted == 1 ? "" : "s"); - } - assert(r >= 0); + assert_always(r >= 0); next_status += r; first = false; } if (trx->stmt_progress.updated) { - r = sprintf(next_status, "%sUpdated about %llu row%s", first ? "" : ", ", trx->stmt_progress.updated, trx->stmt_progress.updated == 1 ? "" : "s"); - assert(r >= 0); + r = sprintf( + next_status, + "%sUpdated about %llu row%s", + first ? "" : ", ", + trx->stmt_progress.updated, + trx->stmt_progress.updated == 1 ? "" : "s"); + assert_always(r >= 0); next_status += r; first = false; } if (trx->stmt_progress.deleted) { - r = sprintf(next_status, "%sDeleted about %llu row%s", first ? "" : ", ", trx->stmt_progress.deleted, trx->stmt_progress.deleted == 1 ? "" : "s"); - assert(r >= 0); + r = sprintf( + next_status, + "%sDeleted about %llu row%s", + first ? "" : ", ", + trx->stmt_progress.deleted, + trx->stmt_progress.deleted == 1 ? "" : "s"); + assert_always(r >= 0); next_status += r; first = false; } @@ -5583,7 +5915,7 @@ int ha_tokudb::rnd_pos(uchar * buf, uchar * pos) { // test rpl slave by inducing a delay before the point query THD *thd = ha_thd(); if (thd->slave_thread && (in_rpl_delete_rows || in_rpl_update_rows)) { - uint64_t delay_ms = THDVAR(thd, rpl_lookup_rows_delay); + uint64_t delay_ms = tokudb::sysvars::rpl_lookup_rows_delay(thd); if (delay_ms) usleep(delay_ms * 1000); } @@ -5664,7 +5996,7 @@ int ha_tokudb::prelock_range(const key_range *start_key, const key_range *end_ke // if (cursor) { int r = cursor->c_close(cursor); - assert(r==0); + assert_always(r==0); cursor = NULL; remove_from_trx_handler_list(); } @@ -5783,8 +6115,7 @@ int ha_tokudb::info(uint flag) { #endif DB_TXN* txn = NULL; if (flag & HA_STATUS_VARIABLE) { - // Just to get optimizations right - stats.records = share->rows + share->rows_from_locked_table; + stats.records = share->row_count() + share->rows_from_locked_table; stats.deleted = 0; if (!(flag & HA_STATUS_NO_LOCK)) { uint64_t num_rows = 0; @@ -5792,27 +6123,32 @@ int ha_tokudb::info(uint flag) { memset(&frag_info, 0, sizeof frag_info); error = txn_begin(db_env, NULL, &txn, DB_READ_UNCOMMITTED, ha_thd()); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } // we should always have a primary key - assert(share->file != NULL); + assert_always(share->file != NULL); error = estimate_num_rows(share->file,&num_rows, txn); if (error == 0) { - share->rows = num_rows; + share->set_row_count(num_rows, false); stats.records = num_rows; - } - else { + } else { goto cleanup; } error = share->file->get_fragmentation(share->file, &frag_info); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } stats.delete_length = frag_info.unused_bytes; DB_BTREE_STAT64 dict_stats; error = share->file->stat64(share->file, txn, &dict_stats); - if (error) { goto cleanup; } - + if (error) { + goto cleanup; + } + stats.create_time = dict_stats.bt_create_time_sec; stats.update_time = dict_stats.bt_modify_time_sec; stats.check_time = dict_stats.bt_verify_time_sec; @@ -5822,18 +6158,24 @@ int ha_tokudb::info(uint flag) { // in this case, we have a hidden primary key, do not // want to report space taken up by the hidden primary key to the user // - uint64_t hpk_space = TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH*dict_stats.bt_ndata; - stats.data_file_length = (hpk_space > stats.data_file_length) ? 0 : stats.data_file_length - hpk_space; - } - else { + uint64_t hpk_space = + TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH * dict_stats.bt_ndata; + stats.data_file_length = + (hpk_space > stats.data_file_length) ? + 0 : stats.data_file_length - hpk_space; + } else { // // one infinity byte per key needs to be subtracted // uint64_t inf_byte_space = dict_stats.bt_ndata; - stats.data_file_length = (inf_byte_space > stats.data_file_length) ? 0 : stats.data_file_length - inf_byte_space; + stats.data_file_length = + (inf_byte_space > stats.data_file_length) ? + 0 : stats.data_file_length - inf_byte_space; } - stats.mean_rec_length = stats.records ? (ulong)(stats.data_file_length/stats.records) : 0; + stats.mean_rec_length = + stats.records ? + (ulong)(stats.data_file_length/stats.records) : 0; stats.index_file_length = 0; // curr_num_DBs is the number of keys we have, according // to the mysql layer. if drop index is running concurrently @@ -5852,37 +6194,58 @@ int ha_tokudb::info(uint flag) { if (i == primary_key || share->key_file[i] == NULL) { continue; } - error = share->key_file[i]->stat64( - share->key_file[i], - txn, - &dict_stats - ); - if (error) { goto cleanup; } + error = + share->key_file[i]->stat64( + share->key_file[i], + txn, + &dict_stats); + if (error) { + goto cleanup; + } stats.index_file_length += dict_stats.bt_dsize; - error = share->file->get_fragmentation( - share->file, - &frag_info - ); - if (error) { goto cleanup; } + error = + share->file->get_fragmentation( + share->file, + &frag_info); + if (error) { + goto cleanup; + } stats.delete_length += frag_info.unused_bytes; } } + + /* + The following comment and logic has been taken from InnoDB and + an old hack was removed that forced to always set stats.records > 0 + --- + The MySQL optimizer seems to assume in a left join that n_rows + is an accurate estimate if it is zero. Of course, it is not, + since we do not have any locks on the rows yet at this phase. + Since SHOW TABLE STATUS seems to call this function with the + HA_STATUS_TIME flag set, while the left join optimizer does not + set that flag, we add one to a zero value if the flag is not + set. That way SHOW TABLE STATUS will show the best estimate, + while the optimizer never sees the table empty. */ + if (stats.records == 0 && !(flag & HA_STATUS_TIME)) { + stats.records++; + } } if ((flag & HA_STATUS_CONST)) { - stats.max_data_file_length= 9223372036854775807ULL; - tokudb::set_card_in_key_info(table, share->n_rec_per_key, share->rec_per_key); + stats.max_data_file_length = 9223372036854775807ULL; + share->set_cardinality_counts_in_table(table); } /* Don't return key if we got an error for the internal primary key */ if (flag & HA_STATUS_ERRKEY && last_dup_key < table_share->keys) { errkey = last_dup_key; - } + } - if (flag & HA_STATUS_AUTO && table->found_next_number_field) { - THD *thd= table->in_use; - struct system_variables *variables= &thd->variables; - stats.auto_increment_value = share->last_auto_increment + variables->auto_increment_increment; + if (flag & HA_STATUS_AUTO && table->found_next_number_field) { + THD* thd = table->in_use; + struct system_variables* variables = &thd->variables; + stats.auto_increment_value = + share->last_auto_increment + variables->auto_increment_increment; } error = 0; cleanup: @@ -5929,7 +6292,7 @@ int ha_tokudb::extra(enum ha_extra_function operation) { TOKUDB_HANDLER_DBUG_RETURN(0); } -int ha_tokudb::reset(void) { +int ha_tokudb::reset() { TOKUDB_HANDLER_DBUG_ENTER(""); key_read = false; using_ignore = false; @@ -5953,14 +6316,13 @@ int ha_tokudb::acquire_table_lock (DB_TXN* trans, TABLE_LOCK_TYPE lt) { TOKUDB_HANDLER_DBUG_ENTER("%p %s", trans, lt == lock_read ? "r" : "w"); int error = ENOSYS; if (!num_DBs_locked_in_bulk) { - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); } uint curr_num_DBs = share->num_DBs; if (lt == lock_read) { error = 0; goto cleanup; - } - else if (lt == lock_write) { + } else if (lt == lock_write) { for (uint i = 0; i < curr_num_DBs; i++) { DB* db = share->key_file[i]; error = db->pre_acquire_table_lock(db, trans); @@ -5968,11 +6330,9 @@ int ha_tokudb::acquire_table_lock (DB_TXN* trans, TABLE_LOCK_TYPE lt) { TOKUDB_HANDLER_TRACE("%d db=%p trans=%p", i, db, trans); if (error) break; } - if (tokudb_debug & TOKUDB_DEBUG_LOCK) - TOKUDB_HANDLER_TRACE("error=%d", error); + TOKUDB_HANDLER_TRACE_FOR_FLAGS(TOKUDB_DEBUG_LOCK, "error=%d", error); if (error) goto cleanup; - } - else { + } else { error = ENOSYS; goto cleanup; } @@ -5980,7 +6340,7 @@ int ha_tokudb::acquire_table_lock (DB_TXN* trans, TABLE_LOCK_TYPE lt) { error = 0; cleanup: if (!num_DBs_locked_in_bulk) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -6011,17 +6371,19 @@ int ha_tokudb::create_txn(THD* thd, tokudb_trx_data* trx) { if ((error = txn_begin(db_env, NULL, &trx->all, txn_begin_flags, thd))) { goto cleanup; } - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("created master %p", trx->all); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "created master %p", + trx->all); trx->sp_level = trx->all; trans_register_ha(thd, true, tokudb_hton); } DBUG_PRINT("trans", ("starting transaction stmt")); if (trx->stmt) { - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("warning:stmt=%p", trx->stmt); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "warning:stmt=%p", + trx->stmt); } uint32_t txn_begin_flags; if (trx->all == NULL) { @@ -6036,21 +6398,25 @@ int ha_tokudb::create_txn(THD* thd, tokudb_trx_data* trx) { if (txn_begin_flags == 0 && is_autocommit && thd_sql_command(thd) == SQLCOM_SELECT) { txn_begin_flags = DB_TXN_SNAPSHOT; } - if (is_autocommit && thd_sql_command(thd) == SQLCOM_SELECT && !thd->in_sub_stmt && lock.type <= TL_READ_NO_INSERT && !thd->lex->uses_stored_routines()) { + if (is_autocommit && thd_sql_command(thd) == SQLCOM_SELECT && + !thd->in_sub_stmt && lock.type <= TL_READ_NO_INSERT && + !thd->lex->uses_stored_routines()) { txn_begin_flags |= DB_TXN_READ_ONLY; } - } - else { + } else { txn_begin_flags = DB_INHERIT_ISOLATION; } - if ((error = txn_begin(db_env, trx->sp_level, &trx->stmt, txn_begin_flags, thd))) { + error = txn_begin(db_env, trx->sp_level, &trx->stmt, txn_begin_flags, thd); + if (error) { /* We leave the possible master transaction open */ goto cleanup; } trx->sub_sp_level = trx->stmt; - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("created stmt %p sp_level %p", trx->sp_level, trx->stmt); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "created stmt %p sp_level %p", + trx->sp_level, + trx->stmt); reset_stmt_progress(&trx->stmt_progress); trans_register_ha(thd, false, tokudb_hton); cleanup: @@ -6081,26 +6447,40 @@ static const char *lock_type_str(int lock_type) { // error otherwise // int ha_tokudb::external_lock(THD * thd, int lock_type) { - TOKUDB_HANDLER_DBUG_ENTER("cmd %d lock %d %s %s", thd_sql_command(thd), lock_type, lock_type_str(lock_type), share->table_name); - if (!(tokudb_debug & TOKUDB_DEBUG_ENTER) && (tokudb_debug & TOKUDB_DEBUG_LOCK)) { - TOKUDB_HANDLER_TRACE("cmd %d lock %d %s %s", thd_sql_command(thd), lock_type, lock_type_str(lock_type), share->table_name); - } - if (tokudb_debug & TOKUDB_DEBUG_LOCK) { - TOKUDB_HANDLER_TRACE("q %s", thd->query()); + TOKUDB_HANDLER_DBUG_ENTER( + "cmd %d lock %d %s %s", + thd_sql_command(thd), + lock_type, + lock_type_str(lock_type), + share->full_table_name()); + if (TOKUDB_UNLIKELY(!TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ENTER) && + TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_LOCK))) { + TOKUDB_HANDLER_TRACE( + "cmd %d lock %d %s %s", + thd_sql_command(thd), + lock_type, + lock_type_str(lock_type), + share->full_table_name()); } + TOKUDB_HANDLER_TRACE_FOR_FLAGS(TOKUDB_DEBUG_LOCK, "q %s", thd->query()); int error = 0; - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); if (!trx) { error = create_tokudb_trx_data_instance(&trx); if (error) { goto cleanup; } thd_set_ha_data(thd, tokudb_hton, trx); } - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("trx %p %p %p %p %u %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level, - trx->tokudb_lock_count, trx->create_lock_count); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "trx %p %p %p %p %u %u", + trx->all, + trx->stmt, + trx->sp_level, + trx->sub_sp_level, + trx->tokudb_lock_count, + trx->create_lock_count); if (trx->all == NULL) { trx->sp_level = NULL; @@ -6120,19 +6500,11 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { } transaction = trx->sub_sp_level; trx->tokudb_lock_count++; - } - else { - tokudb_pthread_mutex_lock(&share->mutex); - // hate dealing with comparison of signed vs unsigned, so doing this - if (deleted_rows > added_rows && share->rows < (deleted_rows - added_rows)) { - share->rows = 0; - } - else { - share->rows += (added_rows - deleted_rows); - } - tokudb_pthread_mutex_unlock(&share->mutex); + } else { + share->update_row_count(thd, added_rows, deleted_rows, updated_rows); added_rows = 0; deleted_rows = 0; + updated_rows = 0; share->rows_from_locked_table = 0; if (trx->tokudb_lock_count > 0) { if (--trx->tokudb_lock_count <= trx->create_lock_count) { @@ -6154,8 +6526,7 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { } } cleanup: - if (tokudb_debug & TOKUDB_DEBUG_LOCK) - TOKUDB_HANDLER_TRACE("error=%d", error); + TOKUDB_HANDLER_TRACE_FOR_FLAGS(TOKUDB_DEBUG_LOCK, "error=%d", error); TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -6164,24 +6535,32 @@ cleanup: TABLE LOCK is done. Under LOCK TABLES, each used tables will force a call to start_stmt. */ -int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { - TOKUDB_HANDLER_DBUG_ENTER("cmd %d lock %d %s", thd_sql_command(thd), lock_type, share->table_name); - if (tokudb_debug & TOKUDB_DEBUG_LOCK) { - TOKUDB_HANDLER_TRACE("q %s", thd->query()); - } +int ha_tokudb::start_stmt(THD* thd, thr_lock_type lock_type) { + TOKUDB_HANDLER_DBUG_ENTER( + "cmd %d lock %d %s", + thd_sql_command(thd), + lock_type, + share->full_table_name()); + + TOKUDB_HANDLER_TRACE_FOR_FLAGS(TOKUDB_DEBUG_LOCK, "q %s", thd->query()); int error = 0; - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); if (!trx) { error = create_tokudb_trx_data_instance(&trx); if (error) { goto cleanup; } thd_set_ha_data(thd, tokudb_hton, trx); } - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("trx %p %p %p %p %u %u", trx->all, trx->stmt, trx->sp_level, trx->sub_sp_level, - trx->tokudb_lock_count, trx->create_lock_count); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "trx %p %p %p %p %u %u", + trx->all, + trx->stmt, + trx->sp_level, + trx->sub_sp_level, + trx->tokudb_lock_count, + trx->create_lock_count); /* note that trx->stmt may have been already initialized as start_stmt() @@ -6194,11 +6573,11 @@ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { goto cleanup; } trx->create_lock_count = trx->tokudb_lock_count; - } - else { - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_HANDLER_TRACE("trx->stmt %p already existed", trx->stmt); - } + } else { + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "trx->stmt %p already existed", + trx->stmt); } if (added_rows > deleted_rows) { share->rows_from_locked_table = added_rows - deleted_rows; @@ -6272,27 +6651,40 @@ uint32_t ha_tokudb::get_cursor_isolation_flags(enum thr_lock_type lock_type, THD time). In the future we will probably try to remove this. */ -THR_LOCK_DATA **ha_tokudb::store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_lock_type lock_type) { - TOKUDB_HANDLER_DBUG_ENTER("lock_type=%d cmd=%d", lock_type, thd_sql_command(thd)); - if (tokudb_debug & TOKUDB_DEBUG_LOCK) { - TOKUDB_HANDLER_TRACE("lock_type=%d cmd=%d", lock_type, thd_sql_command(thd)); - } +THR_LOCK_DATA* *ha_tokudb::store_lock( + THD* thd, + THR_LOCK_DATA** to, + enum thr_lock_type lock_type) { + + TOKUDB_HANDLER_DBUG_ENTER( + "lock_type=%d cmd=%d", + lock_type, + thd_sql_command(thd)); + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_LOCK, + "lock_type=%d cmd=%d", + lock_type, + thd_sql_command(thd)); if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) { enum_sql_command sql_command = (enum_sql_command) thd_sql_command(thd); if (!thd->in_lock_tables) { - if (sql_command == SQLCOM_CREATE_INDEX && get_create_index_online(thd)) { + if (sql_command == SQLCOM_CREATE_INDEX && + tokudb::sysvars::create_index_online(thd)) { // hot indexing - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); if (share->num_DBs == (table->s->keys + tokudb_test(hidden_primary_key))) { lock_type = TL_WRITE_ALLOW_WRITE; } - rw_unlock(&share->num_DBs_lock); - } else if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && - sql_command != SQLCOM_TRUNCATE && !thd_tablespace_op(thd)) { + share->_num_DBs_lock.unlock(); + } else if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && + lock_type <= TL_WRITE) && + sql_command != SQLCOM_TRUNCATE && + !thd_tablespace_op(thd)) { // allow concurrent writes lock_type = TL_WRITE_ALLOW_WRITE; - } else if (sql_command == SQLCOM_OPTIMIZE && lock_type == TL_READ_NO_INSERT) { + } else if (sql_command == SQLCOM_OPTIMIZE && + lock_type == TL_READ_NO_INSERT) { // hot optimize table lock_type = TL_READ; } @@ -6300,88 +6692,130 @@ THR_LOCK_DATA **ha_tokudb::store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_l lock.type = lock_type; } *to++ = &lock; - if (tokudb_debug & TOKUDB_DEBUG_LOCK) - TOKUDB_HANDLER_TRACE("lock_type=%d", lock_type); - DBUG_RETURN(to); + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_LOCK, + "lock_type=%d", + lock_type); + TOKUDB_HANDLER_DBUG_RETURN_PTR(to); } -static toku_compression_method get_compression_method(DB *file) { +static toku_compression_method get_compression_method(DB* file) { enum toku_compression_method method; int r = file->get_compression_method(file, &method); - assert(r == 0); + assert_always(r == 0); return method; } #if TOKU_INCLUDE_ROW_TYPE_COMPRESSION -enum row_type ha_tokudb::get_row_type(void) const { +enum row_type ha_tokudb::get_row_type() const { toku_compression_method compression_method = get_compression_method(share->file); return toku_compression_method_to_row_type(compression_method); } #endif static int create_sub_table( - const char *table_name, - DBT* row_descriptor, - DB_TXN* txn, - uint32_t block_size, + const char* table_name, + DBT* row_descriptor, + DB_TXN* txn, + uint32_t block_size, uint32_t read_block_size, toku_compression_method compression_method, bool is_hot_index, - uint32_t fanout - ) -{ + uint32_t fanout) { + TOKUDB_DBUG_ENTER(""); int error; DB *file = NULL; uint32_t create_flags; - - + + error = db_create(&file, db_env, 0); if (error) { DBUG_PRINT("error", ("Got error: %d when creating table", error)); my_errno = error; goto exit; } - + if (block_size != 0) { error = file->set_pagesize(file, block_size); if (error != 0) { - DBUG_PRINT("error", ("Got error: %d when setting block size %u for table '%s'", error, block_size, table_name)); + DBUG_PRINT( + "error", + ("Got error: %d when setting block size %u for table '%s'", + error, + block_size, + table_name)); goto exit; } } if (read_block_size != 0) { error = file->set_readpagesize(file, read_block_size); if (error != 0) { - DBUG_PRINT("error", ("Got error: %d when setting read block size %u for table '%s'", error, read_block_size, table_name)); + DBUG_PRINT( + "error", + ("Got error: %d when setting read block size %u for table '%s'", + error, + read_block_size, + table_name)); goto exit; } } if (fanout != 0) { error = file->set_fanout(file, fanout); if (error != 0) { - DBUG_PRINT("error", ("Got error: %d when setting fanout %u for table '%s'", - error, fanout, table_name)); + DBUG_PRINT( + "error", + ("Got error: %d when setting fanout %u for table '%s'", + error, + fanout, + table_name)); goto exit; } } error = file->set_compression_method(file, compression_method); if (error != 0) { - DBUG_PRINT("error", ("Got error: %d when setting compression type %u for table '%s'", error, compression_method, table_name)); + DBUG_PRINT( + "error", + ("Got error: %d when setting compression type %u for table '%s'", + error, + compression_method, + table_name)); goto exit; } - create_flags = DB_THREAD | DB_CREATE | DB_EXCL | (is_hot_index ? DB_IS_HOT_INDEX : 0); - error = file->open(file, txn, table_name, NULL, DB_BTREE, create_flags, my_umask); + create_flags = + DB_THREAD | DB_CREATE | DB_EXCL | (is_hot_index ? DB_IS_HOT_INDEX : 0); + error = + file->open( + file, + txn, + table_name, + NULL, + DB_BTREE, + create_flags, + my_umask); if (error) { - DBUG_PRINT("error", ("Got error: %d when opening table '%s'", error, table_name)); + DBUG_PRINT( + "error", + ("Got error: %d when opening table '%s'", error, table_name)); goto exit; } - error = file->change_descriptor(file, txn, row_descriptor, (is_hot_index ? DB_IS_HOT_INDEX | DB_UPDATE_CMP_DESCRIPTOR : DB_UPDATE_CMP_DESCRIPTOR)); + error = + file->change_descriptor( + file, + txn, + row_descriptor, + (is_hot_index ? DB_IS_HOT_INDEX | + DB_UPDATE_CMP_DESCRIPTOR : + DB_UPDATE_CMP_DESCRIPTOR)); if (error) { - DBUG_PRINT("error", ("Got error: %d when setting row descriptor for table '%s'", error, table_name)); + DBUG_PRINT( + "error", + ("Got error: %d when setting row descriptor for table '%s'", + error, + table_name)); goto exit; } @@ -6389,7 +6823,7 @@ static int create_sub_table( exit: if (file) { int r = file->close(file, 0); - assert(r==0); + assert_always(r==0); } TOKUDB_DBUG_RETURN(error); } @@ -6407,7 +6841,8 @@ void ha_tokudb::update_create_info(HA_CREATE_INFO* create_info) { // show create table asks us to update this create_info, this makes it // so we'll always show what compression type we're using create_info->row_type = get_row_type(); - if (create_info->row_type == ROW_TYPE_TOKU_ZLIB && THDVAR(ha_thd(), hide_default_row_format) != 0) { + if (create_info->row_type == ROW_TYPE_TOKU_ZLIB && + tokudb::sysvars::hide_default_row_format(ha_thd()) != 0) { create_info->row_type = ROW_TYPE_DEFAULT; } } @@ -6471,27 +6906,43 @@ int ha_tokudb::write_key_name_to_status(DB* status_block, char* key_name, DB_TXN } // -// some tracing moved out of ha_tokudb::create, because ::create was getting cluttered +// some tracing moved out of ha_tokudb::create, because ::create was +// getting cluttered // void ha_tokudb::trace_create_table_info(const char *name, TABLE * form) { uint i; // // tracing information about what type of table we are creating // - if (tokudb_debug & TOKUDB_DEBUG_OPEN) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_OPEN))) { for (i = 0; i < form->s->fields; i++) { Field *field = form->s->field[i]; - TOKUDB_HANDLER_TRACE("field:%d:%s:type=%d:flags=%x", i, field->field_name, field->type(), field->flags); + TOKUDB_HANDLER_TRACE( + "field:%d:%s:type=%d:flags=%x", + i, + field->field_name, + field->type(), + field->flags); } for (i = 0; i < form->s->keys; i++) { KEY *key = &form->s->key_info[i]; - TOKUDB_HANDLER_TRACE("key:%d:%s:%d", i, key->name, get_key_parts(key)); + TOKUDB_HANDLER_TRACE( + "key:%d:%s:%d", + i, + key->name, + key->user_defined_key_parts); uint p; - for (p = 0; p < get_key_parts(key); p++) { - KEY_PART_INFO *key_part = &key->key_part[p]; - Field *field = key_part->field; - TOKUDB_HANDLER_TRACE("key:%d:%d:length=%d:%s:type=%d:flags=%x", - i, p, key_part->length, field->field_name, field->type(), field->flags); + for (p = 0; p < key->user_defined_key_parts; p++) { + KEY_PART_INFO* key_part = &key->key_part[p]; + Field* field = key_part->field; + TOKUDB_HANDLER_TRACE( + "key:%d:%d:length=%d:%s:type=%d:flags=%x", + i, + p, + key_part->length, + field->field_name, + field->type(), + field->flags); } } } @@ -6499,9 +6950,12 @@ void ha_tokudb::trace_create_table_info(const char *name, TABLE * form) { static uint32_t get_max_desc_size(KEY_AND_COL_INFO* kc_info, TABLE* form) { uint32_t max_row_desc_buff_size; - max_row_desc_buff_size = 2*(form->s->fields * 6)+10; // upper bound of key comparison descriptor - max_row_desc_buff_size += get_max_secondary_key_pack_desc_size(kc_info); // upper bound for sec. key part - max_row_desc_buff_size += get_max_clustering_val_pack_desc_size(form->s); // upper bound for clustering val part + // upper bound of key comparison descriptor + max_row_desc_buff_size = 2*(form->s->fields * 6)+10; + // upper bound for sec. key part + max_row_desc_buff_size += get_max_secondary_key_pack_desc_size(kc_info); + // upper bound for clustering val part + max_row_desc_buff_size += get_max_clustering_val_pack_desc_size(form->s); return max_row_desc_buff_size; } @@ -6513,9 +6967,8 @@ static uint32_t create_secondary_key_descriptor( TABLE* form, uint primary_key, uint32_t keynr, - KEY_AND_COL_INFO* kc_info - ) -{ + KEY_AND_COL_INFO* kc_info) { + uchar* ptr = NULL; ptr = buf; @@ -6554,23 +7007,25 @@ static uint32_t create_secondary_key_descriptor( // creates dictionary for secondary index, with key description key_info, all using txn // int ha_tokudb::create_secondary_dictionary( - const char* name, TABLE* form, - KEY* key_info, - DB_TXN* txn, - KEY_AND_COL_INFO* kc_info, + const char* name, + TABLE* form, + KEY* key_info, + DB_TXN* txn, + KEY_AND_COL_INFO* kc_info, uint32_t keynr, bool is_hot_index, - toku_compression_method compression_method - ) -{ + toku_compression_method compression_method) { + int error; DBT row_descriptor; uchar* row_desc_buff = NULL; char* newname = NULL; + size_t newname_len = 0; KEY* prim_key = NULL; char dict_name[MAX_DICT_NAME_LEN]; uint32_t max_row_desc_buff_size; - uint hpk= (form->s->primary_key >= MAX_KEY) ? TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH : 0; + uint hpk= (form->s->primary_key >= MAX_KEY) ? + TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH : 0; uint32_t block_size; uint32_t read_block_size; uint32_t fanout; @@ -6580,14 +7035,23 @@ int ha_tokudb::create_secondary_dictionary( max_row_desc_buff_size = get_max_desc_size(kc_info,form); - row_desc_buff = (uchar *)tokudb_my_malloc(max_row_desc_buff_size, MYF(MY_WME)); - if (row_desc_buff == NULL){ error = ENOMEM; goto cleanup;} + row_desc_buff = (uchar*)tokudb::memory::malloc( + max_row_desc_buff_size, + MYF(MY_WME)); + if (row_desc_buff == NULL) { + error = ENOMEM; + goto cleanup; + } - newname = (char *)tokudb_my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME)); - if (newname == NULL){ error = ENOMEM; goto cleanup;} + newname_len = get_max_dict_name_path_length(name); + newname = (char*)tokudb::memory::malloc(newname_len, MYF(MY_WME)); + if (newname == NULL) { + error = ENOMEM; + goto cleanup; + } sprintf(dict_name, "key-%s", key_info->name); - make_name(newname, name, dict_name); + make_name(newname, newname_len, name, dict_name); prim_key = (hpk) ? NULL : &form->s->key_info[primary_key]; @@ -6606,20 +7070,25 @@ int ha_tokudb::create_secondary_dictionary( form, primary_key, keynr, - kc_info - ); - assert(row_descriptor.size <= max_row_desc_buff_size); + kc_info); + assert_always(row_descriptor.size <= max_row_desc_buff_size); - block_size = get_tokudb_block_size(thd); - read_block_size = get_tokudb_read_block_size(thd); - fanout = get_tokudb_fanout(thd); + block_size = tokudb::sysvars::block_size(thd); + read_block_size = tokudb::sysvars::read_block_size(thd); + fanout = tokudb::sysvars::fanout(thd); - error = create_sub_table(newname, &row_descriptor, txn, block_size, - read_block_size, compression_method, is_hot_index, - fanout); + error = create_sub_table( + newname, + &row_descriptor, + txn, + block_size, + read_block_size, + compression_method, + is_hot_index, + fanout); cleanup: - tokudb_my_free(newname); - tokudb_my_free(row_desc_buff); + tokudb::memory::free(newname); + tokudb::memory::free(row_desc_buff); return error; } @@ -6630,21 +7099,17 @@ static uint32_t create_main_key_descriptor( uint hpk, uint primary_key, TABLE* form, - KEY_AND_COL_INFO* kc_info - ) -{ + KEY_AND_COL_INFO* kc_info) { + uchar* ptr = buf; ptr += create_toku_key_descriptor( ptr, hpk, prim_key, false, - NULL - ); + NULL); - ptr += create_toku_main_key_pack_descriptor( - ptr - ); + ptr += create_toku_main_key_pack_descriptor(ptr); ptr += create_toku_clustering_val_pack_descriptor( ptr, @@ -6652,8 +7117,7 @@ static uint32_t create_main_key_descriptor( form->s, kc_info, primary_key, - false - ); + false); return ptr - buf; } @@ -6661,14 +7125,21 @@ static uint32_t create_main_key_descriptor( // create and close the main dictionarr with name of "name" using table form, all within // transaction txn. // -int ha_tokudb::create_main_dictionary(const char* name, TABLE* form, DB_TXN* txn, KEY_AND_COL_INFO* kc_info, toku_compression_method compression_method) { +int ha_tokudb::create_main_dictionary( + const char* name, + TABLE* form, + DB_TXN* txn, + KEY_AND_COL_INFO* kc_info, + toku_compression_method compression_method) { + int error; DBT row_descriptor; uchar* row_desc_buff = NULL; char* newname = NULL; + size_t newname_len = 0; KEY* prim_key = NULL; uint32_t max_row_desc_buff_size; - uint hpk= (form->s->primary_key >= MAX_KEY) ? TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH : 0; + uint hpk = (form->s->primary_key >= MAX_KEY) ? TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH : 0; uint32_t block_size; uint32_t read_block_size; uint32_t fanout; @@ -6677,13 +7148,22 @@ int ha_tokudb::create_main_dictionary(const char* name, TABLE* form, DB_TXN* txn memset(&row_descriptor, 0, sizeof(row_descriptor)); max_row_desc_buff_size = get_max_desc_size(kc_info, form); - row_desc_buff = (uchar *)tokudb_my_malloc(max_row_desc_buff_size, MYF(MY_WME)); - if (row_desc_buff == NULL){ error = ENOMEM; goto cleanup;} + row_desc_buff = (uchar*)tokudb::memory::malloc( + max_row_desc_buff_size, + MYF(MY_WME)); + if (row_desc_buff == NULL) { + error = ENOMEM; + goto cleanup; + } - newname = (char *)tokudb_my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME)); - if (newname == NULL){ error = ENOMEM; goto cleanup;} + newname_len = get_max_dict_name_path_length(name); + newname = (char*)tokudb::memory::malloc(newname_len, MYF(MY_WME)); + if (newname == NULL) { + error = ENOMEM; + goto cleanup; + } - make_name(newname, name, "main"); + make_name(newname, newname_len, name, "main"); prim_key = (hpk) ? NULL : &form->s->key_info[primary_key]; @@ -6700,21 +7180,26 @@ int ha_tokudb::create_main_dictionary(const char* name, TABLE* form, DB_TXN* txn hpk, primary_key, form, - kc_info - ); - assert(row_descriptor.size <= max_row_desc_buff_size); + kc_info); + assert_always(row_descriptor.size <= max_row_desc_buff_size); - block_size = get_tokudb_block_size(thd); - read_block_size = get_tokudb_read_block_size(thd); - fanout = get_tokudb_fanout(thd); + block_size = tokudb::sysvars::block_size(thd); + read_block_size = tokudb::sysvars::read_block_size(thd); + fanout = tokudb::sysvars::fanout(thd); /* Create the main table that will hold the real rows */ - error = create_sub_table(newname, &row_descriptor, txn, block_size, - read_block_size, compression_method, false, - fanout); + error = create_sub_table( + newname, + &row_descriptor, + txn, + block_size, + read_block_size, + compression_method, + false, + fanout); cleanup: - tokudb_my_free(newname); - tokudb_my_free(row_desc_buff); + tokudb::memory::free(newname); + tokudb::memory::free(row_desc_buff); return error; } @@ -6728,7 +7213,11 @@ cleanup: // 0 on success // error otherwise // -int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_info) { +int ha_tokudb::create( + const char* name, + TABLE* form, + HA_CREATE_INFO* create_info) { + TOKUDB_HANDLER_DBUG_ENTER("%s", name); int error; @@ -6738,6 +7227,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in DB_TXN* txn = NULL; bool do_commit = false; char* newname = NULL; + size_t newname_len = 0; KEY_AND_COL_INFO kc_info; tokudb_trx_data *trx = NULL; THD* thd = ha_thd(); @@ -6753,15 +7243,18 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in #endif #if TOKU_INCLUDE_OPTION_STRUCTS - const srv_row_format_t row_format = (srv_row_format_t) form->s->option_struct->row_format; + const tokudb::sysvars::row_format_t row_format = + (tokudb::sysvars::row_format_t)form->s->option_struct->row_format; #else - const srv_row_format_t row_format = (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) + const tokudb::sysvars::row_format_t row_format = + (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) ? row_type_to_row_format(create_info->row_type) - : get_row_format(thd); + : tokudb::sysvars::row_format(thd); #endif - const toku_compression_method compression_method = row_format_to_toku_compression_method(row_format); + const toku_compression_method compression_method = + row_format_to_toku_compression_method(row_format); - bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE); + bool create_from_engine = (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE); if (create_from_engine) { // table already exists, nothing to do error = 0; @@ -6786,17 +7279,23 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in } } - newname = (char *)tokudb_my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME)); - if (newname == NULL){ error = ENOMEM; goto cleanup;} + newname_len = get_max_dict_name_path_length(name); + newname = (char*)tokudb::memory::malloc(newname_len, MYF(MY_WME)); + if (newname == NULL) { + error = ENOMEM; + goto cleanup; + } trx = (tokudb_trx_data *) thd_get_ha_data(ha_thd(), tokudb_hton); - if (trx && trx->sub_sp_level && thd_sql_command(thd) == SQLCOM_CREATE_TABLE) { + if (trx && trx->sub_sp_level && + thd_sql_command(thd) == SQLCOM_CREATE_TABLE) { txn = trx->sub_sp_level; - } - else { + } else { do_commit = true; error = txn_begin(db_env, 0, &txn, 0, thd); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } } primary_key = form->s->primary_key; @@ -6809,45 +7308,76 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in trace_create_table_info(name,form); /* Create status.tokudb and save relevant metadata */ - make_name(newname, name, "status"); + make_name(newname, newname_len, name, "status"); - error = tokudb::create_status(db_env, &status_block, newname, txn); + error = tokudb::metadata::create(db_env, &status_block, newname, txn); if (error) { goto cleanup; } version = HA_TOKU_VERSION; - error = write_to_status(status_block, hatoku_new_version,&version,sizeof(version), txn); - if (error) { goto cleanup; } + error = write_to_status( + status_block, + hatoku_new_version, + &version, + sizeof(version), + txn); + if (error) { + goto cleanup; + } capabilities = HA_TOKU_CAP; - error = write_to_status(status_block, hatoku_capabilities,&capabilities,sizeof(capabilities), txn); - if (error) { goto cleanup; } + error = write_to_status( + status_block, + hatoku_capabilities, + &capabilities, + sizeof(capabilities), + txn); + if (error) { + goto cleanup; + } - error = write_auto_inc_create(status_block, create_info->auto_increment_value, txn); - if (error) { goto cleanup; } + error = write_auto_inc_create( + status_block, + create_info->auto_increment_value, + txn); + if (error) { + goto cleanup; + } #if WITH_PARTITION_STORAGE_ENGINE if (TOKU_PARTITION_WRITE_FRM_DATA || form->part_info == NULL) { error = write_frm_data(status_block, txn, form->s->path.str); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } } #else error = write_frm_data(status_block, txn, form->s->path.str); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } #endif error = allocate_key_and_col_info(form->s, &kc_info); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } error = initialize_key_and_col_info( - form->s, + form->s, form, &kc_info, hidden_primary_key, - primary_key - ); - if (error) { goto cleanup; } + primary_key); + if (error) { + goto cleanup; + } - error = create_main_dictionary(name, form, txn, &kc_info, compression_method); + error = create_main_dictionary( + name, + form, + txn, + &kc_info, + compression_method); if (error) { goto cleanup; } @@ -6855,32 +7385,44 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in for (uint i = 0; i < form->s->keys; i++) { if (i != primary_key) { - error = create_secondary_dictionary(name, form, &form->key_info[i], txn, &kc_info, i, false, compression_method); + error = create_secondary_dictionary( + name, + form, + &form->key_info[i], + txn, + &kc_info, + i, + false, + compression_method); if (error) { goto cleanup; } - error = write_key_name_to_status(status_block, form->s->key_info[i].name, txn); - if (error) { goto cleanup; } + error = write_key_name_to_status( + status_block, + form->s->key_info[i].name, + txn); + if (error) { + goto cleanup; + } } } error = 0; cleanup: if (status_block != NULL) { - int r = tokudb::close_status(&status_block); - assert(r==0); + int r = tokudb::metadata::close(&status_block); + assert_always(r==0); } free_key_and_col_info(&kc_info); if (do_commit && txn) { if (error) { abort_txn(txn); - } - else { + } else { commit_txn(txn,0); } } - tokudb_my_free(newname); + tokudb::memory::free(newname); TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -6903,27 +7445,36 @@ int ha_tokudb::discard_or_import_tablespace(my_bool discard) { // is_key specifies if it is a secondary index (and hence a "key-" needs to be prepended) or // if it is not a secondary index // -int ha_tokudb::delete_or_rename_dictionary( const char* from_name, const char* to_name, const char* secondary_name, bool is_key, DB_TXN* txn, bool is_delete) { +int ha_tokudb::delete_or_rename_dictionary( + const char* from_name, + const char* to_name, + const char* secondary_name, + bool is_key, + DB_TXN* txn, + bool is_delete) { + int error; char dict_name[MAX_DICT_NAME_LEN]; char* new_from_name = NULL; + size_t new_from_name_len = 0; char* new_to_name = NULL; - assert(txn); + size_t new_to_name_len = 0; + assert_always(txn); - new_from_name = (char *)tokudb_my_malloc( - get_max_dict_name_path_length(from_name), - MYF(MY_WME) - ); + new_from_name_len = get_max_dict_name_path_length(from_name); + new_from_name = (char*)tokudb::memory::malloc( + new_from_name_len, + MYF(MY_WME)); if (new_from_name == NULL) { error = ENOMEM; goto cleanup; } if (!is_delete) { - assert(to_name); - new_to_name = (char *)tokudb_my_malloc( - get_max_dict_name_path_length(to_name), - MYF(MY_WME) - ); + assert_always(to_name); + new_to_name_len = get_max_dict_name_path_length(to_name); + new_to_name = (char*)tokudb::memory::malloc( + new_to_name_len, + MYF(MY_WME)); if (new_to_name == NULL) { error = ENOMEM; goto cleanup; @@ -6932,32 +7483,37 @@ int ha_tokudb::delete_or_rename_dictionary( const char* from_name, const char* t if (is_key) { sprintf(dict_name, "key-%s", secondary_name); - make_name(new_from_name, from_name, dict_name); - } - else { - make_name(new_from_name, from_name, secondary_name); + make_name(new_from_name, new_from_name_len, from_name, dict_name); + } else { + make_name(new_from_name, new_from_name_len, from_name, secondary_name); } if (!is_delete) { if (is_key) { sprintf(dict_name, "key-%s", secondary_name); - make_name(new_to_name, to_name, dict_name); - } - else { - make_name(new_to_name, to_name, secondary_name); + make_name(new_to_name, new_to_name_len, to_name, dict_name); + } else { + make_name(new_to_name, new_to_name_len, to_name, secondary_name); } } if (is_delete) { error = db_env->dbremove(db_env, txn, new_from_name, NULL, 0); + } else { + error = db_env->dbrename( + db_env, + txn, + new_from_name, + NULL, + new_to_name, + 0); } - else { - error = db_env->dbrename(db_env, txn, new_from_name, NULL, new_to_name, 0); + if (error) { + goto cleanup; } - if (error) { goto cleanup; } cleanup: - tokudb_my_free(new_from_name); - tokudb_my_free(new_to_name); + tokudb::memory::free(new_from_name); + tokudb::memory::free(new_to_name); return error; } @@ -7023,12 +7579,12 @@ int ha_tokudb::delete_or_rename_table (const char* from_name, const char* to_nam if (error) { goto cleanup; } error = status_cursor->c_close(status_cursor); - assert(error==0); + assert_always(error==0); status_cursor = NULL; if (error) { goto cleanup; } error = status_db->close(status_db, 0); - assert(error == 0); + assert_always(error == 0); status_db = NULL; // @@ -7041,11 +7597,11 @@ int ha_tokudb::delete_or_rename_table (const char* from_name, const char* to_nam cleanup: if (status_cursor) { int r = status_cursor->c_close(status_cursor); - assert(r==0); + assert_always(r==0); } if (status_db) { int r = status_db->close(status_db, 0); - assert(r==0); + assert_always(r==0); } if (txn) { if (error) { @@ -7069,12 +7625,25 @@ cleanup: // int ha_tokudb::delete_table(const char *name) { TOKUDB_HANDLER_DBUG_ENTER("%s", name); + TOKUDB_SHARE* share = TOKUDB_SHARE::get_share(name, NULL, NULL, false); + if (share) { + share->unlock(); + share->release(); + // this should be enough to handle locking as the higher level MDL + // on this table should prevent any new analyze tasks. + share->cancel_background_jobs(); + TOKUDB_SHARE::drop_share(share); + } + int error; error = delete_or_rename_table(name, NULL, true); - if (error == DB_LOCK_NOTGRANTED && ((tokudb_debug & TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0)) { - sql_print_error("Could not delete table %s because \ -another transaction has accessed the table. \ -To drop the table, make sure no transactions touch the table.", name); + if (TOKUDB_LIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0) && + error == DB_LOCK_NOTGRANTED) { + sql_print_error( + "Could not delete table %s because another transaction has " + "accessed the table. To drop the table, make sure no " + "transactions touch the table.", + name); } TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -7091,12 +7660,25 @@ To drop the table, make sure no transactions touch the table.", name); // int ha_tokudb::rename_table(const char *from, const char *to) { TOKUDB_HANDLER_DBUG_ENTER("%s %s", from, to); + TOKUDB_SHARE* share = TOKUDB_SHARE::get_share(from, NULL, NULL, false); + if (share) { + share->unlock(); + share->release(); + // this should be enough to handle locking as the higher level MDL + // on this table should prevent any new analyze tasks. + share->cancel_background_jobs(); + TOKUDB_SHARE::drop_share(share); + } int error; error = delete_or_rename_table(from, to, false); - if (error == DB_LOCK_NOTGRANTED && ((tokudb_debug & TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0)) { - sql_print_error("Could not rename table from %s to %s because \ -another transaction has accessed the table. \ -To rename the table, make sure no transactions touch the table.", from, to); + if (TOKUDB_LIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0) && + error == DB_LOCK_NOTGRANTED) { + sql_print_error( + "Could not rename table from %s to %s because another transaction " + "has accessed the table. To rename the table, make sure no " + "transactions touch the table.", + from, + to); } TOKUDB_HANDLER_DBUG_RETURN(error); } @@ -7111,9 +7693,11 @@ To rename the table, make sure no transactions touch the table.", from, to); double ha_tokudb::scan_time() { TOKUDB_HANDLER_DBUG_ENTER(""); double ret_val = (double)stats.records / 3; - if (tokudb_debug & TOKUDB_DEBUG_RETURN) { - TOKUDB_HANDLER_TRACE("return %" PRIu64 " %f", (uint64_t) stats.records, ret_val); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_RETURN, + "return %" PRIu64 " %f", + (uint64_t)stats.records, + ret_val); DBUG_RETURN(ret_val); } @@ -7137,10 +7721,7 @@ double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows) (table->key_info[index].key_length + ref_length) + 1); ret_val = (rows + keys_per_block - 1)/ keys_per_block; - if (tokudb_debug & TOKUDB_DEBUG_RETURN) { - TOKUDB_HANDLER_TRACE("return %f", ret_val); - } - DBUG_RETURN(ret_val); + TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val); } // @@ -7202,19 +7783,13 @@ double ha_tokudb::read_time( ret_val = is_clustering ? ret_val + 0.00001 : ret_val; cleanup: - if (tokudb_debug & TOKUDB_DEBUG_RETURN) { - TOKUDB_HANDLER_TRACE("return %f", ret_val); - } - DBUG_RETURN(ret_val); + TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val); } double ha_tokudb::index_only_read_time(uint keynr, double records) { TOKUDB_HANDLER_DBUG_ENTER("%u %f", keynr, records); double ret_val = keyread_time(keynr, 1, (ha_rows)records); - if (tokudb_debug & TOKUDB_DEBUG_RETURN) { - TOKUDB_HANDLER_TRACE("return %f", ret_val); - } - DBUG_RETURN(ret_val); + TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val); } // @@ -7287,9 +7862,11 @@ ha_rows ha_tokudb::records_in_range(uint keynr, key_range* start_key, key_range* ret_val = (ha_rows) (rows <= 1 ? 1 : rows); cleanup: - if (tokudb_debug & TOKUDB_DEBUG_RETURN) { - TOKUDB_HANDLER_TRACE("return %" PRIu64 " %" PRIu64, (uint64_t) ret_val, rows); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_RETURN, + "return %" PRIu64 " %" PRIu64, + (uint64_t)ret_val, + rows); DBUG_RETURN(ret_val); } @@ -7345,12 +7922,19 @@ void ha_tokudb::init_auto_increment() { commit_txn(txn, 0); } - if (tokudb_debug & TOKUDB_DEBUG_AUTO_INCREMENT) { - TOKUDB_HANDLER_TRACE("init auto increment:%lld", share->last_auto_increment); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_AUTO_INCREMENT, + "init auto increment:%lld", + share->last_auto_increment); } -void ha_tokudb::get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong * first_value, ulonglong * nb_reserved_values) { +void ha_tokudb::get_auto_increment( + ulonglong offset, + ulonglong increment, + ulonglong nb_desired_values, + ulonglong* first_value, + ulonglong* nb_reserved_values) { + TOKUDB_HANDLER_DBUG_ENTER(""); ulonglong nr; bool over; @@ -7361,14 +7945,13 @@ void ha_tokudb::get_auto_increment(ulonglong offset, ulonglong increment, ulongl DBUG_VOID_RETURN; } - tokudb_pthread_mutex_lock(&share->mutex); + share->lock(); if (share->auto_inc_create_value > share->last_auto_increment) { nr = share->auto_inc_create_value; over = false; share->last_auto_increment = share->auto_inc_create_value; - } - else { + } else { nr = share->last_auto_increment + increment; over = nr < share->last_auto_increment; if (over) @@ -7378,19 +7961,23 @@ void ha_tokudb::get_auto_increment(ulonglong offset, ulonglong increment, ulongl share->last_auto_increment = nr + (nb_desired_values - 1)*increment; if (delay_updating_ai_metadata) { ai_metadata_update_required = true; - } - else { - update_max_auto_inc(share->status_block, share->last_auto_increment); + } else { + update_max_auto_inc( + share->status_block, + share->last_auto_increment); } } - - if (tokudb_debug & TOKUDB_DEBUG_AUTO_INCREMENT) { - TOKUDB_HANDLER_TRACE("get_auto_increment(%lld,%lld,%lld):got:%lld:%lld", - offset, increment, nb_desired_values, nr, nb_desired_values); - } + TOKUDB_HANDLER_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_AUTO_INCREMENT, + "get_auto_increment(%lld,%lld,%lld): got:%lld:%lld", + offset, + increment, + nb_desired_values, + nr, + nb_desired_values); *first_value = nr; *nb_reserved_values = nb_desired_values; - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); TOKUDB_HANDLER_DBUG_VOID_RETURN; } @@ -7419,16 +8006,15 @@ bool ha_tokudb::is_auto_inc_singleton(){ // 0 on success, error otherwise // int ha_tokudb::tokudb_add_index( - TABLE *table_arg, - KEY *key_info, - uint num_of_keys, - DB_TXN* txn, + TABLE* table_arg, + KEY* key_info, + uint num_of_keys, + DB_TXN* txn, bool* inc_num_DBs, - bool* modified_DBs - ) -{ + bool* modified_DBs) { + TOKUDB_HANDLER_DBUG_ENTER(""); - assert(txn); + assert_always(txn); int error; uint curr_index = 0; @@ -7438,7 +8024,7 @@ int ha_tokudb::tokudb_add_index( THD* thd = ha_thd(); DB_LOADER* loader = NULL; DB_INDEXER* indexer = NULL; - bool loader_save_space = get_load_save_space(thd); + bool loader_save_space = tokudb::sysvars::load_save_space(thd); bool use_hot_index = (lock.type == TL_WRITE_ALLOW_WRITE); uint32_t loader_flags = loader_save_space ? LOADER_COMPRESS_INTERMEDIATES : 0; uint32_t indexer_flags = 0; @@ -7468,14 +8054,17 @@ int ha_tokudb::tokudb_add_index( // // get the row type to use for the indexes we're adding // - toku_compression_method compression_method = get_compression_method(share->file); + toku_compression_method compression_method = + get_compression_method(share->file); // // status message to be shown in "show process list" // const char *orig_proc_info = tokudb_thd_get_proc_info(thd); - char status_msg[MAX_ALIAS_NAME + 200]; //buffer of 200 should be a good upper bound. - ulonglong num_processed = 0; //variable that stores number of elements inserted thus far + // buffer of 200 should be a good upper bound. + char status_msg[MAX_ALIAS_NAME + 200]; + // variable that stores number of elements inserted thus far + ulonglong num_processed = 0; thd_proc_info(thd, "Adding indexes"); // @@ -7500,13 +8089,15 @@ int ha_tokudb::tokudb_add_index( } } - rw_wrlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_write(); rw_lock_taken = true; // // open all the DB files and set the appropriate variables in share // they go to the end of share->key_file // - creating_hot_index = use_hot_index && num_of_keys == 1 && (key_info[0].flags & HA_NOSAME) == 0; + creating_hot_index = + use_hot_index && num_of_keys == 1 && + (key_info[0].flags & HA_NOSAME) == 0; if (use_hot_index && (share->num_DBs > curr_num_DBs)) { // // already have hot index in progress, get out @@ -7522,35 +8113,47 @@ int ha_tokudb::tokudb_add_index( &share->kc_info.key_filters[curr_index], &key_info[i], table_arg, - false - ); + false); if (!hidden_primary_key) { set_key_filter( &share->kc_info.key_filters[curr_index], &table_arg->key_info[primary_key], table_arg, - false - ); + false); } - error = initialize_col_pack_info(&share->kc_info,table_arg->s,curr_index); + error = initialize_col_pack_info( + &share->kc_info, + table_arg->s, + curr_index); if (error) { goto cleanup; } } - error = create_secondary_dictionary(share->table_name, table_arg, &key_info[i], txn, &share->kc_info, curr_index, creating_hot_index, compression_method); - if (error) { goto cleanup; } + error = create_secondary_dictionary( + share->full_table_name(), + table_arg, + &key_info[i], + txn, + &share->kc_info, + curr_index, + creating_hot_index, + compression_method); + if (error) { + goto cleanup; + } error = open_secondary_dictionary( - &share->key_file[curr_index], + &share->key_file[curr_index], &key_info[i], - share->table_name, + share->full_table_name(), false, - txn - ); - if (error) { goto cleanup; } + txn); + if (error) { + goto cleanup; + } } if (creating_hot_index) { @@ -7564,17 +8167,22 @@ int ha_tokudb::tokudb_add_index( num_of_keys, &share->key_file[curr_num_DBs], mult_db_flags, - indexer_flags - ); - if (error) { goto cleanup; } + indexer_flags); + if (error) { + goto cleanup; + } error = indexer->set_poll_function(indexer, ai_poll_fun, &lc); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } error = indexer->set_error_callback(indexer, loader_ai_err_fun, &lc); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); rw_lock_taken = false; #ifdef HA_TOKUDB_HAS_THD_PROGRESS @@ -7585,17 +8193,20 @@ int ha_tokudb::tokudb_add_index( error = indexer->build(indexer); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } - rw_wrlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_write(); error = indexer->close(indexer); - rw_unlock(&share->num_DBs_lock); - if (error) { goto cleanup; } + share->_num_DBs_lock.unlock(); + if (error) { + goto cleanup; + } indexer = NULL; - } - else { + } else { DBUG_ASSERT(table->mdl_ticket->get_type() >= MDL_SHARED_NO_WRITE); - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); rw_lock_taken = false; prelocked_right_range_size = 0; prelocked_left_range_size = 0; @@ -7608,27 +8219,37 @@ int ha_tokudb::tokudb_add_index( bf_info.key_to_compare = NULL; error = db_env->create_loader( - db_env, - txn, - &loader, + db_env, + txn, + &loader, NULL, // no src_db needed - num_of_keys, - &share->key_file[curr_num_DBs], + num_of_keys, + &share->key_file[curr_num_DBs], mult_put_flags, mult_dbt_flags, - loader_flags - ); - if (error) { goto cleanup; } + loader_flags); + if (error) { + goto cleanup; + } error = loader->set_poll_function(loader, loader_poll_fun, &lc); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } error = loader->set_error_callback(loader, loader_ai_err_fun, &lc); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } // // scan primary table, create each secondary key, add to each DB // - if ((error = share->file->cursor(share->file, txn, &tmp_cursor, DB_SERIALIZABLE))) { + error = share->file->cursor( + share->file, + txn, + &tmp_cursor, + DB_SERIALIZABLE); + if (error) { tmp_cursor = NULL; // Safety goto cleanup; } @@ -7643,16 +8264,21 @@ int ha_tokudb::tokudb_add_index( share->file->dbt_neg_infty(), share->file->dbt_pos_infty(), true, - 0 - ); - if (error) { goto cleanup; } + 0); + if (error) { + goto cleanup; + } // set the bulk fetch iteration to its max so that adding an // index fills the bulk fetch buffer every time. we do not // want it to grow exponentially fast. rows_fetched_using_bulk_fetch = 0; bulk_fetch_iteration = HA_TOKU_BULK_FETCH_ITERATION_MAX; - cursor_ret_val = tmp_cursor->c_getf_next(tmp_cursor, DB_PRELOCKED,smart_dbt_bf_callback, &bf_info); + cursor_ret_val = tmp_cursor->c_getf_next( + tmp_cursor, + DB_PRELOCKED, + smart_dbt_bf_callback, + &bf_info); #ifdef HA_TOKUDB_HAS_THD_PROGRESS // initialize a two phase progress report. @@ -7660,21 +8286,30 @@ int ha_tokudb::tokudb_add_index( thd_progress_init(thd, 2); #endif - while (cursor_ret_val != DB_NOTFOUND || ((bytes_used_in_range_query_buff - curr_range_query_buff_offset) > 0)) { - if ((bytes_used_in_range_query_buff - curr_range_query_buff_offset) == 0) { + while (cursor_ret_val != DB_NOTFOUND || + ((bytes_used_in_range_query_buff - + curr_range_query_buff_offset) > 0)) { + if ((bytes_used_in_range_query_buff - + curr_range_query_buff_offset) == 0) { invalidate_bulk_fetch(); // reset the buffers - cursor_ret_val = tmp_cursor->c_getf_next(tmp_cursor, DB_PRELOCKED, smart_dbt_bf_callback, &bf_info); + cursor_ret_val = tmp_cursor->c_getf_next( + tmp_cursor, + DB_PRELOCKED, + smart_dbt_bf_callback, + &bf_info); if (cursor_ret_val != DB_NOTFOUND && cursor_ret_val != 0) { error = cursor_ret_val; goto cleanup; } } - // do this check in case the the c_getf_next did not put anything into the buffer because - // there was no more data - if ((bytes_used_in_range_query_buff - curr_range_query_buff_offset) == 0) { + // do this check in case the the c_getf_next did not put anything + // into the buffer because there was no more data + if ((bytes_used_in_range_query_buff - + curr_range_query_buff_offset) == 0) { break; } - // at this point, we know the range query buffer has at least one key/val pair + // at this point, we know the range query buffer has at least one + // key/val pair uchar* curr_pos = range_query_buff+curr_range_query_buff_offset; uint32_t key_size = *(uint32_t *)curr_pos; @@ -7694,17 +8329,26 @@ int ha_tokudb::tokudb_add_index( curr_range_query_buff_offset = curr_pos - range_query_buff; error = loader->put(loader, &curr_pk_key, &curr_pk_val); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } num_processed++; if ((num_processed % 1000) == 0) { - sprintf(status_msg, "Adding indexes: Fetched %llu of about %llu rows, loading of data still remains.", - num_processed, (long long unsigned) share->rows); + sprintf( + status_msg, + "Adding indexes: Fetched %llu of about %llu rows, loading " + "of data still remains.", + num_processed, + (long long unsigned)share->row_count()); thd_proc_info(thd, status_msg); #ifdef HA_TOKUDB_HAS_THD_PROGRESS - thd_progress_report(thd, num_processed, (long long unsigned) share->rows); + thd_progress_report( + thd, + num_processed, + (long long unsigned)share->row_count()); #endif if (thd_killed(thd)) { @@ -7714,7 +8358,7 @@ int ha_tokudb::tokudb_add_index( } } error = tmp_cursor->c_close(tmp_cursor); - assert(error==0); + assert_always(error==0); tmp_cursor = NULL; #ifdef HA_TOKUDB_HAS_THD_PROGRESS @@ -7732,9 +8376,14 @@ int ha_tokudb::tokudb_add_index( for (uint i = 0; i < num_of_keys; i++, curr_index++) { if (key_info[i].flags & HA_NOSAME) { bool is_unique; - error = is_index_unique(&is_unique, txn, share->key_file[curr_index], &key_info[i], - creating_hot_index ? 0 : DB_PRELOCKED_WRITE); - if (error) goto cleanup; + error = is_index_unique( + &is_unique, + txn, + share->key_file[curr_index], + &key_info[i], + creating_hot_index ? 0 : DB_PRELOCKED_WRITE); + if (error) + goto cleanup; if (!is_unique) { error = HA_ERR_FOUND_DUPP_KEY; last_dup_key = i; @@ -7743,22 +8392,20 @@ int ha_tokudb::tokudb_add_index( } } + share->lock(); // // We have an accurate row count, might as well update share->rows // if(!creating_hot_index) { - tokudb_pthread_mutex_lock(&share->mutex); - share->rows = num_processed; - tokudb_pthread_mutex_unlock(&share->mutex); + share->set_row_count(num_processed, true); } // // now write stuff to status.tokudb // - tokudb_pthread_mutex_lock(&share->mutex); for (uint i = 0; i < num_of_keys; i++) { write_key_name_to_status(share->status_block, key_info[i].name, txn); } - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); error = 0; cleanup: @@ -7766,12 +8413,12 @@ cleanup: thd_progress_end(thd); #endif if (rw_lock_taken) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); rw_lock_taken = false; } if (tmp_cursor) { int r = tmp_cursor->c_close(tmp_cursor); - assert(r==0); + assert_always(r==0); tmp_cursor = NULL; } if (loader != NULL) { @@ -7782,14 +8429,17 @@ cleanup: if (indexer != NULL) { sprintf(status_msg, "aborting creation of indexes."); thd_proc_info(thd, status_msg); - rw_wrlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_write(); indexer->abort(indexer); - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } - if (error == DB_LOCK_NOTGRANTED && ((tokudb_debug & TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0)) { - sql_print_error("Could not add indexes to table %s because \ -another transaction has accessed the table. \ -To add indexes, make sure no transactions touch the table.", share->table_name); + if (TOKUDB_LIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0) && + error == DB_LOCK_NOTGRANTED) { + sql_print_error( + "Could not add indexes to table %s because another transaction has " + "accessed the table. To add indexes, make sure no transactions " + "touch the table.", + share->full_table_name()); } thd_proc_info(thd, orig_proc_info); TOKUDB_HANDLER_DBUG_RETURN(error ? error : loader_error); @@ -7799,7 +8449,12 @@ To add indexes, make sure no transactions touch the table.", share->table_name); // Internal function called by ha_tokudb::add_index and ha_tokudb::alter_table_phase2 // Closes added indexes in case of error in error path of add_index and alter_table_phase2 // -void ha_tokudb::restore_add_index(TABLE* table_arg, uint num_of_keys, bool incremented_numDBs, bool modified_DBs) { +void ha_tokudb::restore_add_index( + TABLE* table_arg, + uint num_of_keys, + bool incremented_numDBs, + bool modified_DBs) { + uint curr_num_DBs = table_arg->s->keys + tokudb_test(hidden_primary_key); uint curr_index = 0; @@ -7808,7 +8463,7 @@ void ha_tokudb::restore_add_index(TABLE* table_arg, uint num_of_keys, bool incre // so that there is not a window // if (incremented_numDBs) { - rw_wrlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_write(); share->num_DBs--; } if (modified_DBs) { @@ -7821,15 +8476,14 @@ void ha_tokudb::restore_add_index(TABLE* table_arg, uint num_of_keys, bool incre if (share->key_file[curr_index]) { int r = share->key_file[curr_index]->close( share->key_file[curr_index], - 0 - ); - assert(r==0); + 0); + assert_always(r==0); share->key_file[curr_index] = NULL; } } } if (incremented_numDBs) { - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); } } @@ -7837,14 +8491,22 @@ void ha_tokudb::restore_add_index(TABLE* table_arg, uint num_of_keys, bool incre // Internal function called by ha_tokudb::prepare_drop_index and ha_tokudb::alter_table_phase2 // With a transaction, drops dictionaries associated with indexes in key_num // -int ha_tokudb::drop_indexes(TABLE *table_arg, uint *key_num, uint num_of_keys, KEY *key_info, DB_TXN* txn) { +int ha_tokudb::drop_indexes( + TABLE* table_arg, + uint* key_num, + uint num_of_keys, + KEY* key_info, + DB_TXN* txn) { + TOKUDB_HANDLER_DBUG_ENTER(""); - assert(txn); + assert_always(txn); int error = 0; for (uint i = 0; i < num_of_keys; i++) { uint curr_index = key_num[i]; - error = share->key_file[curr_index]->pre_acquire_fileops_lock(share->key_file[curr_index],txn); + error = share->key_file[curr_index]->pre_acquire_fileops_lock( + share->key_file[curr_index], + txn); if (error != 0) { goto cleanup; } @@ -7852,30 +8514,51 @@ int ha_tokudb::drop_indexes(TABLE *table_arg, uint *key_num, uint num_of_keys, K for (uint i = 0; i < num_of_keys; i++) { uint curr_index = key_num[i]; int r = share->key_file[curr_index]->close(share->key_file[curr_index],0); - assert(r==0); + assert_always(r==0); share->key_file[curr_index] = NULL; - error = remove_key_name_from_status(share->status_block, key_info[curr_index].name, txn); - if (error) { goto cleanup; } + error = remove_key_name_from_status( + share->status_block, + key_info[curr_index].name, + txn); + if (error) { + goto cleanup; + } - error = delete_or_rename_dictionary(share->table_name, NULL, key_info[curr_index].name, true, txn, true); - if (error) { goto cleanup; } + error = delete_or_rename_dictionary( + share->full_table_name(), + NULL, + key_info[curr_index].name, + true, + txn, + true); + if (error) { + goto cleanup; + } } cleanup: - if (error == DB_LOCK_NOTGRANTED && ((tokudb_debug & TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0)) { - sql_print_error("Could not drop indexes from table %s because \ -another transaction has accessed the table. \ -To drop indexes, make sure no transactions touch the table.", share->table_name); + if (TOKUDB_LIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0) && + error == DB_LOCK_NOTGRANTED) { + sql_print_error( + "Could not drop indexes from table %s because another transaction " + "has accessed the table. To drop indexes, make sure no " + "transactions touch the table.", + share->full_table_name()); } TOKUDB_HANDLER_DBUG_RETURN(error); } // -// Internal function called by ha_tokudb::prepare_drop_index and ha_tokudb::alter_table_phase2 -// Restores dropped indexes in case of error in error path of prepare_drop_index and alter_table_phase2 +// Internal function called by ha_tokudb::prepare_drop_index and +// ha_tokudb::alter_table_phase2 +// Restores dropped indexes in case of error in error path of +// prepare_drop_index and alter_table_phase2 // -void ha_tokudb::restore_drop_indexes(TABLE *table_arg, uint *key_num, uint num_of_keys) { +void ha_tokudb::restore_drop_indexes( + TABLE* table_arg, + uint* key_num, + uint num_of_keys) { // // reopen closed dictionaries @@ -7885,13 +8568,12 @@ void ha_tokudb::restore_drop_indexes(TABLE *table_arg, uint *key_num, uint num_o uint curr_index = key_num[i]; if (share->key_file[curr_index] == NULL) { r = open_secondary_dictionary( - &share->key_file[curr_index], + &share->key_file[curr_index], &table_share->key_info[curr_index], - share->table_name, - false, // - NULL - ); - assert(!r); + share->full_table_name(), + false, + NULL); + assert_always(!r); } } } @@ -7937,56 +8619,65 @@ void ha_tokudb::print_error(int error, myf errflag) { // does so by deleting and then recreating the dictionary in the context // of a transaction // -int ha_tokudb::truncate_dictionary( uint keynr, DB_TXN* txn ) { +int ha_tokudb::truncate_dictionary(uint keynr, DB_TXN* txn) { int error; bool is_pk = (keynr == primary_key); - toku_compression_method compression_method = get_compression_method(share->key_file[keynr]); + toku_compression_method compression_method = + get_compression_method(share->key_file[keynr]); error = share->key_file[keynr]->close(share->key_file[keynr], 0); - assert(error == 0); + assert_always(error == 0); share->key_file[keynr] = NULL; - if (is_pk) { share->file = NULL; } + if (is_pk) { + share->file = NULL; + } if (is_pk) { error = delete_or_rename_dictionary( - share->table_name, + share->full_table_name(), NULL, - "main", + "main", false, //is_key txn, - true // is a delete - ); - if (error) { goto cleanup; } - } - else { + true); // is a delete + if (error) { + goto cleanup; + } + } else { error = delete_or_rename_dictionary( - share->table_name, + share->full_table_name(), NULL, - table_share->key_info[keynr].name, + table_share->key_info[keynr].name, true, //is_key txn, - true // is a delete - ); - if (error) { goto cleanup; } + true); // is a delete + if (error) { + goto cleanup; + } } if (is_pk) { - error = create_main_dictionary(share->table_name, table, txn, &share->kc_info, compression_method); - } - else { + error = create_main_dictionary( + share->full_table_name(), + table, + txn, + &share->kc_info, + compression_method); + } else { error = create_secondary_dictionary( - share->table_name, - table, - &table_share->key_info[keynr], + share->full_table_name(), + table, + &table_share->key_info[keynr], txn, &share->kc_info, keynr, false, - compression_method - ); + compression_method); + } + if (error) { + goto cleanup; } - if (error) { goto cleanup; } cleanup: return error; @@ -8025,40 +8716,51 @@ int ha_tokudb::delete_all_rows_internal() { uint curr_num_DBs = 0; DB_TXN* txn = NULL; + // this should be enough to handle locking as the higher level MDL + // on this table should prevent any new analyze tasks. + share->cancel_background_jobs(); + error = txn_begin(db_env, 0, &txn, 0, ha_thd()); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); for (uint i = 0; i < curr_num_DBs; i++) { error = share->key_file[i]->pre_acquire_fileops_lock( - share->key_file[i], - txn - ); - if (error) { goto cleanup; } + share->key_file[i], + txn); + if (error) { + goto cleanup; + } error = share->key_file[i]->pre_acquire_table_lock( - share->key_file[i], - txn - ); - if (error) { goto cleanup; } + share->key_file[i], + txn); + if (error) { + goto cleanup; + } } for (uint i = 0; i < curr_num_DBs; i++) { error = truncate_dictionary(i, txn); - if (error) { goto cleanup; } + if (error) { + goto cleanup; + } } + DEBUG_SYNC(ha_thd(), "tokudb_after_truncate_all_dictionarys"); + // zap the row count if (error == 0) { - share->rows = 0; - // update auto increment - share->last_auto_increment = 0; - // calling write_to_status directly because we need to use txn - write_to_status( - share->status_block, + share->set_row_count(0, false); + // update auto increment + share->last_auto_increment = 0; + // calling write_to_status directly because we need to use txn + write_to_status( + share->status_block, hatoku_max_ai, - &share->last_auto_increment, - sizeof(share->last_auto_increment), - txn - ); + &share->last_auto_increment, + sizeof(share->last_auto_increment), + txn); } share->try_table_lock = true; @@ -8066,16 +8768,19 @@ cleanup: if (txn) { if (error) { abort_txn(txn); - } - else { + } else { commit_txn(txn,0); } } - if (error == DB_LOCK_NOTGRANTED && ((tokudb_debug & TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0)) { - sql_print_error("Could not truncate table %s because another transaction has accessed the \ - table. To truncate the table, make sure no transactions touch the table.", - share->table_name); + if (TOKUDB_LIKELY(TOKUDB_DEBUG_FLAGS( + TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS) == 0) && + error == DB_LOCK_NOTGRANTED) { + sql_print_error( + "Could not truncate table %s because another transaction has " + "accessed the table. To truncate the table, make sure no " + "transactions touch the table.", + share->full_table_name()); } // // regardless of errors, need to reopen the DB's @@ -8085,21 +8790,18 @@ cleanup: if (share->key_file[i] == NULL) { if (i != primary_key) { r = open_secondary_dictionary( - &share->key_file[i], - &table_share->key_info[i], - share->table_name, - false, // - NULL - ); - assert(!r); - } - else { + &share->key_file[i], + &table_share->key_info[i], + share->full_table_name(), + false, + NULL); + assert_always(!r); + } else { r = open_main_dictionary( - share->table_name, - false, - NULL - ); - assert(!r); + share->full_table_name(), + false, + NULL); + assert_always(!r); } } } @@ -8111,7 +8813,7 @@ void ha_tokudb::set_loader_error(int err) { } void ha_tokudb::set_dup_value_for_pk(DBT* key) { - assert(!hidden_primary_key); + assert_always(!hidden_primary_key); unpack_key(table->record[0],key,primary_key); last_dup_key = primary_key; } @@ -8144,21 +8846,28 @@ Item* ha_tokudb::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) { return idx_cond_arg; } +void ha_tokudb::cancel_pushed_idx_cond() { + invalidate_icp(); + handler::cancel_pushed_idx_cond(); +} + void ha_tokudb::cleanup_txn(DB_TXN *txn) { if (transaction == txn && cursor) { int r = cursor->c_close(cursor); - assert(r == 0); + assert_always(r == 0); cursor = NULL; } } void ha_tokudb::add_to_trx_handler_list() { - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(ha_thd(), tokudb_hton); + tokudb_trx_data* trx = + (tokudb_trx_data*)thd_get_ha_data(ha_thd(), tokudb_hton); trx->handlers = list_add(trx->handlers, &trx_handler_list); } void ha_tokudb::remove_from_trx_handler_list() { - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(ha_thd(), tokudb_hton); + tokudb_trx_data* trx = + (tokudb_trx_data*)thd_get_ha_data(ha_thd(), tokudb_hton); trx->handlers = list_delete(trx->handlers, &trx_handler_list); } @@ -8190,7 +8899,7 @@ bool ha_tokudb::rpl_lookup_rows() { if (!in_rpl_delete_rows && !in_rpl_update_rows) return true; else - return THDVAR(ha_thd(), rpl_lookup_rows); + return tokudb::sysvars::rpl_lookup_rows(ha_thd()); } // table admin diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index 5b387924b1e..3d7a3a7fa05 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -23,11 +23,12 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." -#if !defined(HA_TOKUDB_H) -#define HA_TOKUDB_H +#ifndef _HA_TOKUDB_H +#define _HA_TOKUDB_H -#include +#include "hatoku_hton.h" #include "hatoku_cmp.h" +#include "tokudb_background.h" #define HA_TOKU_ORIG_VERSION 4 #define HA_TOKU_VERSION 4 @@ -45,84 +46,384 @@ typedef struct loader_context { } *LOADER_CONTEXT; // -// This object stores table information that is to be shared +// This class stores table information that is to be shared // among all ha_tokudb objects. -// There is one instance per table, shared among threads. +// There is one instance per table, shared among handlers. // Some of the variables here are the DB* pointers to indexes, // and auto increment information. // +// When the last user releases it's reference on the share, +// it closes all of its database handles and releases all info +// The share instance stays around though so some data can be transiently +// kept across open-close-open-close cycles. These data will be explicitly +// noted below. +// class TOKUDB_SHARE { public: - void init(void); - void destroy(void); + enum share_state_t { + CLOSED = 0, + OPENED = 1, + ERROR = 2 + }; + + // one time, start up init + static void static_init(); + + // one time, shutdown destroy + static void static_destroy(); + + // retuns a locked, properly reference counted share + // callers must check to ensure share is in correct state for callers use + // and unlock the share. + // if create_new is set, a new "CLOSED" share will be created if one + // doesn't exist, otherwise will return NULL if an existing is not found. + static TOKUDB_SHARE* get_share( + const char* table_name, + TABLE_SHARE* table_share, + THR_LOCK_DATA* data, + bool create_new); + + // removes a share entirely from the pool, call to rename/deleta a table + // caller must hold ddl_mutex on this share and the share MUST have + // exactly 0 _use_count + static void drop_share(TOKUDB_SHARE* share); + + // returns state string for logging/reporting + static const char* get_state_string(share_state_t state); + + void* operator new(size_t sz); + void operator delete(void* p); + + TOKUDB_SHARE(); + + // increases the ref count and waits for any currently executing state + // transition to complete + // returns current state and leaves share locked + // callers must check to ensure share is in correct state for callers use + // and unlock the share. + share_state_t addref(); + + // decreases the ref count and potentially closes the share + // caller must not have ownership of mutex, will lock and release + int release(); + + // returns the current use count + // no locking requirements + inline int use_count() const; + + // locks the share + inline void lock() const; + + // unlocks the share + inline void unlock() const; + + // returns the current state of the share + // no locking requirements + inline share_state_t state() const; + + // sets the state of the share + // caller must hold mutex on this share + inline void set_state(share_state_t state); + + // returns the full MySQL table name of the table ex: + // ./database/table + // no locking requirements + inline const char* full_table_name() const; + + // returns the strlen of the full table name + // no locking requirements + inline uint full_table_name_length() const; + + // returns the parsed database name this table resides in + // no locking requirements + inline const char* database_name() const; + + // returns the strlen of the database name + // no locking requirements + inline uint database_name_length() const; + + // returns the parsed table name of this table + // no locking requirements + inline const char* table_name() const; + + // returns the strlen of the the table name + // no locking requirements + inline uint table_name_length() const; + + // sets the estimated number of rows in the table + // should be called only during share initialization and info call + // caller must hold mutex on this share unless specified by 'locked' + inline void set_row_count(uint64_t rows, bool locked); + + // updates tracked row count and ongoing table change delta tracking + // called from any ha_tokudb operation that inserts/modifies/deletes rows + // may spawn background analysis if enabled, allowed and threshold hit + // caller must not have ownership of mutex, will lock and release + void update_row_count( + THD* thd, + uint64_t added, + uint64_t deleted, + uint64_t updated); + + // returns the current row count estimate + // no locking requirements + inline ha_rows row_count() const; + + // initializes cardinality statistics, takes ownership of incoming buffer + // caller must hold mutex on this share + inline void init_cardinality_counts( + uint32_t rec_per_keys, + uint64_t* rec_per_key); + + // update the cardinality statistics. number of records must match + // caller must hold mutex on this share + inline void update_cardinality_counts( + uint32_t rec_per_keys, + const uint64_t* rec_per_key); + + // disallow any auto analysis from taking place + // caller must hold mutex on this share + inline void disallow_auto_analysis(); + + // allow any auto analysis to take place + // pass in true for 'reset_deltas' to reset delta counting to 0 + // caller must hold mutex on this share + inline void allow_auto_analysis(bool reset_deltas); + + // cancels all background jobs for this share + // no locking requirements + inline void cancel_background_jobs() const; + + // copies cardinality statistics into TABLE counter set + // caller must not have ownership of mutex, will lock and release + void set_cardinality_counts_in_table(TABLE* table); + + // performs table analysis on underlying indices and produces estimated + // cardinality statistics. + // on success updates cardinality counts in status database and this share + // MUST pass a valid THD to access session variables. + // MAY pass txn. If txn is passed, assumes an explicit user scheduled + // ANALYZE and not an auto ANALYZE resulting from delta threshold + // uses session variables: + // tokudb_analyze_in_background, tokudb_analyze_throttle, + // tokudb_analyze_time, and tokudb_analyze_delete_fraction + // caller must hold mutex on this share + int analyze_standard(THD* thd, DB_TXN* txn); + + // performs table scan and updates the internal FT logical row count value + // on success also updates share row count estimate. + // MUST pass a valid THD to access session variables. + // MAY pass txn. If txn is passed, assumes an explicit user scheduled + // uses session variables: + // tokudb_analyze_in_background, and tokudb_analyze_throttle + // caller must not have ownership of mutex, will lock and release + int analyze_recount_rows(THD* thd, DB_TXN* txn); public: - char *table_name; - uint table_name_length, use_count; - pthread_mutex_t mutex; - THR_LOCK lock; - + //********************************* + // Destroyed and recreated on open-close-open ulonglong auto_ident; ulonglong last_auto_increment, auto_inc_create_value; - // - // estimate on number of rows in table - // - ha_rows rows; - // + // estimate on number of rows added in the process of a locked tables // this is so we can better estimate row count during a lock table - // ha_rows rows_from_locked_table; - DB *status_block; - // + DB* status_block; + // DB that is indexed on the primary key - // - DB *file; - // + DB* file; + // array of all DB's that make up table, includes DB that // is indexed on the primary key, add 1 in case primary // key is hidden - // - DB *key_file[MAX_KEY +1]; - rw_lock_t key_file_lock; + DB* key_file[MAX_KEY + 1]; uint status, version, capabilities; uint ref_length; - // + // whether table has an auto increment column - // bool has_auto_inc; - // + // index of auto increment column in table->field, if auto_inc exists - // uint ai_field_index; - // + // whether the primary key has a string - // bool pk_has_string; KEY_AND_COL_INFO kc_info; - - // + + // key info copied from TABLE_SHARE, used by background jobs that have no + // access to a handler instance + uint _keys; + uint _max_key_parts; + struct key_descriptor_t { + uint _parts; + bool _is_unique; + char* _name; + }; + key_descriptor_t* _key_descriptors; + // we want the following optimization for bulk loads, if the table is empty, // attempt to grab a table lock. emptiness check can be expensive, // so we try it once for a table. After that, we keep this variable around - // to tell us to not try it again. - // - bool try_table_lock; + // to tell us to not try it again. + bool try_table_lock; bool has_unique_keys; bool replace_into_fast; - rw_lock_t num_DBs_lock; + tokudb::thread::rwlock_t _num_DBs_lock; uint32_t num_DBs; - pthread_cond_t m_openclose_cond; - enum { CLOSED, OPENING, OPENED, CLOSING, ERROR } m_state; - int m_error; - int m_initialize_count; +private: + static HASH _open_tables; + static tokudb::thread::mutex_t _open_tables_mutex; - uint n_rec_per_key; - uint64_t *rec_per_key; + static uchar* hash_get_key( + TOKUDB_SHARE* share, + size_t* length, + TOKUDB_UNUSED(my_bool not_used)); + + static void hash_free_element(TOKUDB_SHARE* share); + + //********************************* + // Spans open-close-open + mutable tokudb::thread::mutex_t _mutex; + mutable tokudb::thread::mutex_t _ddl_mutex; + uint _use_count; + + share_state_t _state; + + ulonglong _row_delta_activity; + bool _allow_auto_analysis; + + String _full_table_name; + String _database_name; + String _table_name; + + //********************************* + // Destroyed and recreated on open-close-open + THR_LOCK _thr_lock; + + // estimate on number of rows in table + ha_rows _rows; + + // cardinality counts + uint32_t _rec_per_keys; + uint64_t* _rec_per_key; + + void init(const char* table_name); + void destroy(); }; +inline int TOKUDB_SHARE::use_count() const { + return _use_count; +} +inline void TOKUDB_SHARE::lock() const { + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count); + _mutex.lock(); + TOKUDB_SHARE_DBUG_VOID_RETURN(); +} +inline void TOKUDB_SHARE::unlock() const { + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count); + _mutex.unlock(); + TOKUDB_SHARE_DBUG_VOID_RETURN(); +} +inline TOKUDB_SHARE::share_state_t TOKUDB_SHARE::state() const { + return _state; +} +inline void TOKUDB_SHARE::set_state(TOKUDB_SHARE::share_state_t state) { + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]:new_state[%s]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count, + get_state_string(state)); + + assert_debug(_mutex.is_owned_by_me()); + _state = state; + TOKUDB_SHARE_DBUG_VOID_RETURN(); +} +inline const char* TOKUDB_SHARE::full_table_name() const { + return _full_table_name.ptr(); +} +inline uint TOKUDB_SHARE::full_table_name_length() const { + return _full_table_name.length(); +} +inline const char* TOKUDB_SHARE::database_name() const { + return _database_name.ptr(); +} +inline uint TOKUDB_SHARE::database_name_length() const { + return _database_name.length(); +} +inline const char* TOKUDB_SHARE::table_name() const { + return _table_name.ptr(); +} +inline uint TOKUDB_SHARE::table_name_length() const { + return _table_name.length(); +} +inline void TOKUDB_SHARE::set_row_count(uint64_t rows, bool locked) { + TOKUDB_SHARE_DBUG_ENTER("file[%s]:state[%s]:use_count[%d]:rows[%" PRIu64 "]:locked[%d]", + _full_table_name.ptr(), + get_state_string(_state), + _use_count, + rows, + locked); + + if (!locked) { + lock(); + } else { + assert_debug(_mutex.is_owned_by_me()); + } + if (_rows && rows == 0) + _row_delta_activity = 0; + + _rows = rows; + if (!locked) { + unlock(); + } + TOKUDB_SHARE_DBUG_VOID_RETURN(); +} +inline ha_rows TOKUDB_SHARE::row_count() const { + return _rows; +} +inline void TOKUDB_SHARE::init_cardinality_counts( + uint32_t rec_per_keys, + uint64_t* rec_per_key) { + + assert_debug(_mutex.is_owned_by_me()); + // can not change number of keys live + assert_always(_rec_per_key == NULL && _rec_per_keys == 0); + _rec_per_keys = rec_per_keys; + _rec_per_key = rec_per_key; +} +inline void TOKUDB_SHARE::update_cardinality_counts( + uint32_t rec_per_keys, + const uint64_t* rec_per_key) { + + assert_debug(_mutex.is_owned_by_me()); + // can not change number of keys live + assert_always(rec_per_keys == _rec_per_keys); + assert_always(rec_per_key != NULL); + memcpy(_rec_per_key, rec_per_key, _rec_per_keys * sizeof(uint64_t)); +} +inline void TOKUDB_SHARE::disallow_auto_analysis() { + assert_debug(_mutex.is_owned_by_me()); + _allow_auto_analysis = false; +} +inline void TOKUDB_SHARE::allow_auto_analysis(bool reset_deltas) { + assert_debug(_mutex.is_owned_by_me()); + _allow_auto_analysis = true; + if (reset_deltas) + _row_delta_activity = 0; +} +inline void TOKUDB_SHARE::cancel_background_jobs() const { + tokudb::background::_job_manager->cancel_job(full_table_name()); +} + + typedef struct st_filter_key_part_info { uint offset; @@ -278,6 +579,7 @@ private: // ulonglong added_rows; ulonglong deleted_rows; + ulonglong updated_rows; uint last_dup_key; @@ -438,7 +740,7 @@ public: // Returns a bit mask of capabilities of storage engine. Capabilities // defined in sql/handler.h // - ulonglong table_flags(void) const; + ulonglong table_flags() const; ulong index_flags(uint inx, uint part, bool all_parts) const; @@ -482,7 +784,7 @@ public: double index_only_read_time(uint keynr, double records); int open(const char *name, int mode, uint test_if_locked); - int close(void); + int close(); void update_create_info(HA_CREATE_INFO* create_info); int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info); int delete_table(const char *name); @@ -528,7 +830,7 @@ public: void position(const uchar * record); int info(uint); int extra(enum ha_extra_function operation); - int reset(void); + int reset(); int external_lock(THD * thd, int lock_type); int start_stmt(THD * thd, thr_lock_type lock_type); @@ -540,12 +842,17 @@ public: int get_status(DB_TXN* trans); void init_hidden_prim_key_info(DB_TXN *txn); inline void get_auto_primary_key(uchar * to) { - tokudb_pthread_mutex_lock(&share->mutex); + share->lock(); share->auto_ident++; hpk_num_to_char(to, share->auto_ident); - tokudb_pthread_mutex_unlock(&share->mutex); + share->unlock(); } - virtual void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong * first_value, ulonglong * nb_reserved_values); + virtual void get_auto_increment( + ulonglong offset, + ulonglong increment, + ulonglong nb_desired_values, + ulonglong* first_value, + ulonglong* nb_reserved_values); bool is_optimize_blocking(); bool is_auto_inc_singleton(); void print_error(int error, myf errflag); @@ -555,9 +862,6 @@ public: bool primary_key_is_clustered() { return true; } - bool supports_clustered_keys() { - return true; - } int cmp_ref(const uchar * ref1, const uchar * ref2); bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes); @@ -599,15 +903,8 @@ public: #endif - // 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 + void cancel_pushed_idx_cond(); #if TOKU_INCLUDE_ALTER_56 public: @@ -693,13 +990,13 @@ public: int fill_range_query_buf( bool need_val, - DBT const *key, - DBT const *row, + DBT const* key, + DBT const* row, int direction, THD* thd, uchar* buf, - DBT* key_to_compare - ); + DBT* key_to_compare); + #if TOKU_INCLUDE_ROW_TYPE_COMPRESSION enum row_type get_row_type() const; #endif @@ -709,9 +1006,7 @@ private: int get_next(uchar* buf, int direction, DBT* key_to_compare, bool do_key_read); int read_data_from_range_query_buff(uchar* buf, bool need_val, bool do_key_read); // for ICP, only in MariaDB and MySQL 5.6 -#if defined(MARIADB_BASE_VERSION) || (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) enum icp_result toku_handler_index_cond_check(Item* pushed_idx_cond); -#endif void invalidate_bulk_fetch(); void invalidate_icp(); int delete_all_rows_internal(); @@ -758,25 +1053,5 @@ private: bool in_rpl_update_rows; }; -#if TOKU_INCLUDE_OPTION_STRUCTS -struct ha_table_option_struct { - uint row_format; -}; - -struct ha_index_option_struct { - bool clustering; -}; - -static inline bool key_is_clustering(const KEY *key) { - return (key->flags & HA_CLUSTERING) || (key->option_struct && key->option_struct->clustering); -} - -#else - -static inline bool key_is_clustering(const KEY *key) { - return key->flags & HA_CLUSTERING; -} -#endif - -#endif +#endif // _HA_TOKUDB_H diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc index 996ce49d85f..db3d6c112d4 100644 --- a/storage/tokudb/ha_tokudb_admin.cc +++ b/storage/tokudb/ha_tokudb_admin.cc @@ -23,132 +23,801 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." +#include "tokudb_sysvars.h" #include "toku_time.h" -struct analyze_progress_extra { - THD *thd; - TOKUDB_SHARE *share; - TABLE_SHARE *table_share; - uint key_i; - const char *key_name; - time_t t_start; - char *write_status_msg; +namespace tokudb { +namespace analyze { + +class recount_rows_t : public tokudb::background::job_manager_t::job_t { +public: + void* operator new(size_t sz); + void operator delete(void* p); + + recount_rows_t( + bool user_schedued, + THD* thd, + TOKUDB_SHARE* share, + DB_TXN* txn); + + virtual ~recount_rows_t(); + + virtual const char* key(); + + virtual void status( + char* database, + char* table, + char* type, + char* params, + char* status); + +protected: + virtual void on_run(); + + virtual void on_destroy(); + +private: + // to be provided by the initiator of recount rows + THD* _thd; + TOKUDB_SHARE* _share; + DB_TXN* _txn; + ulonglong _throttle; + + // for recount rows status reporting + int _result; + ulonglong _recount_start; // in microseconds + ulonglong _total_elapsed_time; // in microseconds + + bool _local_txn; + ulonglong _rows; + ulonglong _deleted_rows; + ulonglong _ticks; + + static int analyze_recount_rows_progress( + uint64_t count, + uint64_t deleted, + void* extra); + int analyze_recount_rows_progress(uint64_t count, uint64_t deleted); + void get_analyze_status(char*); }; -static int analyze_progress(void *v_extra, uint64_t rows) { - struct analyze_progress_extra *extra = (struct analyze_progress_extra *) v_extra; - THD *thd = extra->thd; - if (thd_killed(thd)) - return ER_ABORTING_CONNECTION; +void* recount_rows_t::operator new(size_t sz) { + return tokudb::memory::malloc(sz, MYF(MY_WME|MY_ZEROFILL|MY_FAE)); +} +void recount_rows_t::operator delete(void* p) { + tokudb::memory::free(p); +} +recount_rows_t::recount_rows_t( + bool user_scheduled, + THD* thd, + TOKUDB_SHARE* share, + DB_TXN* txn) : + tokudb::background::job_manager_t::job_t(user_scheduled), + _share(share), + _result(HA_ADMIN_OK), + _recount_start(0), + _total_elapsed_time(0), + _local_txn(false), + _rows(0), + _deleted_rows(0), + _ticks(0) { - time_t t_now = time(0); - time_t t_limit = THDVAR(thd, analyze_time); - time_t t_start = extra->t_start; - if (t_limit > 0 && t_now - t_start > t_limit) - return ETIME; - float progress_rows = 0.0; - TOKUDB_SHARE *share = extra->share; - if (share->rows > 0) - progress_rows = (float) rows / (float) share->rows; - float progress_time = 0.0; - if (t_limit > 0) - progress_time = (float) (t_now - t_start) / (float) t_limit; - char *write_status_msg = extra->write_status_msg; - TABLE_SHARE *table_share = extra->table_share; - sprintf(write_status_msg, "%.*s.%.*s.%s %u of %u %.lf%% rows %.lf%% time", - (int) table_share->db.length, table_share->db.str, - (int) table_share->table_name.length, table_share->table_name.str, - extra->key_name, extra->key_i, table_share->keys, progress_rows * 100.0, progress_time * 100.0); - thd_proc_info(thd, write_status_msg); + assert_debug(thd != NULL); + assert_debug(share != NULL); + + if (tokudb::sysvars::analyze_in_background(thd)) { + _thd = NULL; + _txn = NULL; + } else { + _thd = thd; + _txn = txn; + } + + _throttle = tokudb::sysvars::analyze_throttle(thd); +} +recount_rows_t::~recount_rows_t() { +} +void recount_rows_t::on_run() { + _recount_start = tokudb::time::microsec(); + _total_elapsed_time = 0; + + if (_txn == NULL) { + _result = db_env->txn_begin(db_env, NULL, &_txn, DB_READ_UNCOMMITTED); + + if (_result != 0) { + _txn = NULL; + _result = HA_ADMIN_FAILED; + goto error; + } + _local_txn = true; + } else { + _local_txn = false; + } + + _result = + _share->file->recount_rows( + _share->file, + analyze_recount_rows_progress, + this); + + if (_result != 0) { + if (_local_txn) { + _txn->abort(_txn); + _txn = NULL; + } + _result = HA_ADMIN_FAILED; + goto error; + } + + DB_BTREE_STAT64 dict_stats; + _result = _share->file->stat64(_share->file, _txn, &dict_stats); + if (_result == 0) { + _share->set_row_count(dict_stats.bt_ndata, false); + } + if (_result != 0) + _result = HA_ADMIN_FAILED; + + if (_local_txn) { + if (_result == HA_ADMIN_OK) { + _txn->commit(_txn, 0); + } else { + _txn->abort(_txn); + } + _txn = NULL; + } + + sql_print_information( + "tokudb analyze recount rows %d counted %lld", + _result, + _share->row_count()); +error: + return; +} +void recount_rows_t::on_destroy() { + _share->release(); +} +const char* recount_rows_t::key() { + return _share->full_table_name(); +} +void recount_rows_t::status( + char* database, + char* table, + char* type, + char* params, + char* status) { + + strcpy(database, _share->database_name()); + strcpy(table, _share->table_name()); + strcpy(type, "TOKUDB_ANALYZE_MODE_RECOUNT_ROWS"); + sprintf(params, "TOKUDB_ANALYZE_THROTTLE=%llu;", _throttle); + get_analyze_status(status); +} +int recount_rows_t::analyze_recount_rows_progress( + uint64_t count, + uint64_t deleted, + void* extra) { + + recount_rows_t* context = (recount_rows_t*)extra; + return context->analyze_recount_rows_progress(count, deleted); +} +int recount_rows_t::analyze_recount_rows_progress( + uint64_t count, + uint64_t deleted) { + + _rows = count; + _deleted_rows += deleted; + deleted > 0 ? _ticks += deleted : _ticks++; + + if (_ticks > 1000) { + _ticks = 0; + uint64_t now = tokudb::time::microsec(); + _total_elapsed_time = now - _recount_start; + if ((_thd && thd_killed(_thd)) || cancelled()) { + // client killed + return ER_ABORTING_CONNECTION; + } + + // report + if (_thd) { + char status[256]; + get_analyze_status(status); + thd_proc_info(_thd, status); + } + + // throttle + // given the throttle value, lets calculate the maximum number of rows + // we should have seen so far in a .1 sec resolution + if (_throttle > 0) { + uint64_t estimated_rows = _total_elapsed_time / 100000; + estimated_rows = estimated_rows * (_throttle / 10); + if (_rows + _deleted_rows > estimated_rows) { + // sleep for 1/10 of a second + tokudb::time::sleep_microsec(100000); + } + } + } return 0; } +void recount_rows_t::get_analyze_status(char* msg) { + sprintf( + msg, + "recount_rows %s.%s counted %llu rows and %llu deleted in %llu " + "seconds.", + _share->database_name(), + _share->table_name(), + _rows, + _deleted_rows, + _total_elapsed_time / tokudb::time::MICROSECONDS); +} + + +class standard_t : public tokudb::background::job_manager_t::job_t { +public: + void* operator new(size_t sz); + void operator delete(void* p); + + standard_t(bool user_scheduled, THD* thd, TOKUDB_SHARE* share, DB_TXN* txn); + + virtual ~standard_t(); + + virtual const char* key(void); + + virtual void status( + char* database, + char* table, + char* type, + char* params, + char* status); + +protected: + virtual void on_run(); + + virtual void on_destroy(); + +private: + // to be provided by initiator of analyze + THD* _thd; + TOKUDB_SHARE* _share; + DB_TXN* _txn; + ulonglong _throttle; // in microseconds + ulonglong _time_limit; // in microseconds + double _delete_fraction; + + // for analyze status reporting, may also use other state + int _result; + ulonglong _analyze_start; // in microseconds + ulonglong _total_elapsed_time; // in microseconds + + // for analyze internal use, pretty much these are per-key/index + ulonglong _current_key; + bool _local_txn; + ulonglong _half_time; + ulonglong _half_rows; + ulonglong _rows; + ulonglong _deleted_rows; + ulonglong _ticks; + ulonglong _analyze_key_start; // in microseconds + ulonglong _key_elapsed_time; // in microseconds + uint _scan_direction; + + static bool analyze_standard_cursor_callback( + void* extra, + uint64_t deleted_rows); + bool analyze_standard_cursor_callback(uint64_t deleted_rows); + + void get_analyze_status(char*); + int analyze_key_progress(); + int analyze_key(uint64_t* rec_per_key_part); +}; + +void* standard_t::operator new(size_t sz) { + return tokudb::memory::malloc(sz, MYF(MY_WME|MY_ZEROFILL|MY_FAE)); +} +void standard_t::operator delete(void* p) { + tokudb::memory::free(p); +} +standard_t::standard_t( + bool user_scheduled, + THD* thd, + TOKUDB_SHARE* share, + DB_TXN* txn) : + tokudb::background::job_manager_t::job_t(user_scheduled), + _share(share), + _result(HA_ADMIN_OK), + _analyze_start(0), + _total_elapsed_time(0), + _current_key(0), + _local_txn(false), + _half_time(0), + _half_rows(0), + _rows(0), + _deleted_rows(0), + _ticks(0), + _analyze_key_start(0), + _key_elapsed_time(0), + _scan_direction(0) { + + assert_debug(thd != NULL); + assert_debug(share != NULL); + + if (tokudb::sysvars::analyze_in_background(thd)) { + _thd = NULL; + _txn = NULL; + } else { + _thd = thd; + _txn = txn; + } + _throttle = tokudb::sysvars::analyze_throttle(thd); + _time_limit = + tokudb::sysvars::analyze_time(thd) * tokudb::time::MICROSECONDS; + _delete_fraction = tokudb::sysvars::analyze_delete_fraction(thd); +} +standard_t::~standard_t() { +} +void standard_t::on_run() { + DB_BTREE_STAT64 stat64; + uint64_t rec_per_key_part[_share->_max_key_parts]; + uint64_t total_key_parts = 0; + _analyze_start = tokudb::time::microsec(); + _half_time = _time_limit > 0 ? _time_limit/2 : 0; + + if (_txn == NULL) { + _result = db_env->txn_begin(db_env, NULL, &_txn, DB_READ_UNCOMMITTED); + + if (_result != 0) { + _txn = NULL; + _result = HA_ADMIN_FAILED; + goto error; + } + _local_txn = true; + } else { + _local_txn = false; + } + + assert_always(_share->key_file[0] != NULL); + _result = _share->key_file[0]->stat64(_share->key_file[0], _txn, &stat64); + if (_result != 0) { + _result = HA_ADMIN_FAILED; + goto cleanup; + } + _half_rows = stat64.bt_ndata / 2; + + for (ulonglong current_key = 0; + _result == HA_ADMIN_OK && current_key < _share->_keys; + current_key++) { + + _current_key = current_key; + _rows = _deleted_rows = _ticks = 0; + _result = analyze_key(&rec_per_key_part[total_key_parts]); + + if ((_result != 0 && _result != ETIME) || + (_result != 0 && _rows == 0 && _deleted_rows > 0)) { + _result = HA_ADMIN_FAILED; + } + if (_thd && (_result == HA_ADMIN_FAILED || + (double)_deleted_rows > + _delete_fraction * (_rows + _deleted_rows))) { + + char name[256]; int namelen; + namelen = + snprintf( + name, + sizeof(name), + "%s.%s.%s", + _share->database_name(), + _share->table_name(), + _share->_key_descriptors[_current_key]._name); + _thd->protocol->prepare_for_resend(); + _thd->protocol->store(name, namelen, system_charset_info); + _thd->protocol->store("analyze", 7, system_charset_info); + _thd->protocol->store("info", 4, system_charset_info); + char rowmsg[256]; + int rowmsglen; + rowmsglen = + snprintf( + rowmsg, + sizeof(rowmsg), + "rows processed %llu rows deleted %llu", + _rows, + _deleted_rows); + _thd->protocol->store(rowmsg, rowmsglen, system_charset_info); + _thd->protocol->write(); + + sql_print_information( + "tokudb analyze on %.*s %.*s", + namelen, + name, + rowmsglen, + rowmsg); + } + + total_key_parts += _share->_key_descriptors[_current_key]._parts; + } + if (_result == HA_ADMIN_OK) { + int error = + tokudb::set_card_in_status( + _share->status_block, + _txn, + total_key_parts, + rec_per_key_part); + if (error) + _result = HA_ADMIN_FAILED; + + _share->lock(); + _share->update_cardinality_counts(total_key_parts, rec_per_key_part); + _share->allow_auto_analysis(true); + _share->unlock(); + } + +cleanup: + if (_local_txn) { + if (_result == HA_ADMIN_OK) { + _txn->commit(_txn, 0); + } else { + _txn->abort(_txn); + } + _txn = NULL; + } + +error: + return; + +} +void standard_t::on_destroy() { + _share->lock(); + _share->allow_auto_analysis(false); + _share->unlock(); + _share->release(); +} +const char* standard_t::key() { + return _share->full_table_name(); +} +void standard_t::status( + char* database, + char* table, + char* type, + char* params, + char* status) { + + strcpy(database, _share->database_name()); + strcpy(table, _share->table_name()); + strcpy(type, "TOKUDB_ANALYZE_MODE_STANDARD"); + sprintf( + params, + "TOKUDB_ANALYZE_DELETE_FRACTION=%f; " + "TOKUDB_ANALYZE_TIME=%llu; TOKUDB_ANALYZE_THROTTLE=%llu;", + _delete_fraction, + _time_limit / tokudb::time::MICROSECONDS, + _throttle); + get_analyze_status(status); +} +bool standard_t::analyze_standard_cursor_callback( + void* extra, + uint64_t deleted_rows) { + standard_t* context = (standard_t*)extra; + return context->analyze_standard_cursor_callback(deleted_rows); +} +bool standard_t::analyze_standard_cursor_callback(uint64_t deleted_rows) { + _deleted_rows += deleted_rows; + _ticks += deleted_rows; + return analyze_key_progress() != 0; +} +void standard_t::get_analyze_status(char* msg) { + static const char* scan_direction_str[] = { + "not scanning", + "scanning forward", + "scanning backward", + "scan unknown" + }; + + const char* scan_direction = NULL; + switch (_scan_direction) { + case 0: scan_direction = scan_direction_str[0]; break; + case DB_NEXT: scan_direction = scan_direction_str[1]; break; + case DB_PREV: scan_direction = scan_direction_str[2]; break; + default: scan_direction = scan_direction_str[3]; break; + } + + float progress_rows = 0.0; + if (_share->row_count() > 0) + progress_rows = (float) _rows / (float) _share->row_count(); + float progress_time = 0.0; + if (_time_limit > 0) + progress_time = (float) _key_elapsed_time / (float) _time_limit; + sprintf( + msg, + "analyze table standard %s.%s.%s %llu of %u %.lf%% rows %.lf%% time, " + "%s", + _share->database_name(), + _share->table_name(), + _share->_key_descriptors[_current_key]._name, + _current_key, + _share->_keys, + progress_rows * 100.0, + progress_time * 100.0, + scan_direction); +} +int standard_t::analyze_key_progress(void) { + if (_ticks > 1000) { + _ticks = 0; + uint64_t now = tokudb::time::microsec(); + _total_elapsed_time = now - _analyze_start; + _key_elapsed_time = now - _analyze_key_start; + if ((_thd && thd_killed(_thd)) || cancelled()) { + // client killed + return ER_ABORTING_CONNECTION; + } else if(_time_limit > 0 && + (uint64_t)_key_elapsed_time > _time_limit) { + // time limit reached + return ETIME; + } + + // report + if (_thd) { + char status[256]; + get_analyze_status(status); + thd_proc_info(_thd, status); + } + + // throttle + // given the throttle value, lets calculate the maximum number of rows + // we should have seen so far in a .1 sec resolution + if (_throttle > 0) { + uint64_t estimated_rows = _key_elapsed_time / 100000; + estimated_rows = estimated_rows * (_throttle / 10); + if (_rows + _deleted_rows > estimated_rows) { + // sleep for 1/10 of a second + tokudb::time::sleep_microsec(100000); + } + } + } + return 0; +} +int standard_t::analyze_key(uint64_t* rec_per_key_part) { + int error = 0; + DB* db = _share->key_file[_current_key]; + assert_always(db != NULL); + uint64_t num_key_parts = _share->_key_descriptors[_current_key]._parts; + uint64_t unique_rows[num_key_parts]; + bool is_unique = _share->_key_descriptors[_current_key]._is_unique; + DBC* cursor = NULL; + int close_error = 0; + DBT key, prev_key; + bool copy_key = false; + + _analyze_key_start = tokudb::time::microsec(); + _key_elapsed_time = 0; + _scan_direction = DB_NEXT; + + if (is_unique && num_key_parts == 1) { + // don't compute for unique keys with a single part. we already know + // the answer. + _rows = unique_rows[0] = 1; + goto done; + } + + for (uint64_t i = 0; i < num_key_parts; i++) + unique_rows[i] = 1; + + // stop looking when the entire dictionary was analyzed, or a + // cap on execution time was reached, or the analyze was killed. + while (1) { + if (cursor == NULL) { + error = db->cursor(db, _txn, &cursor, 0); + if (error != 0) + goto done; + + cursor->c_set_check_interrupt_callback( + cursor, + analyze_standard_cursor_callback, + this); + + memset(&key, 0, sizeof(DBT)); + memset(&prev_key, 0, sizeof(DBT)); + copy_key = true; + } + + error = cursor->c_get(cursor, &key, 0, _scan_direction); + if (error != 0) { + if (error == DB_NOTFOUND || error == TOKUDB_INTERRUPTED) + error = 0; // not an error + break; + } else if (cancelled()) { + error = ER_ABORTING_CONNECTION; + break; + } + + _rows++; + _ticks++; + + // if copy_key is false at this pont, we have some value sitting in + // prev_key that we can compare to + // if the comparison reveals a unique key, we must set copy_key to true + // so the code following can copy he current key into prev_key for the + // next iteration + if (copy_key == false) { + // compare this key with the previous key. ignore + // appended PK for SK's. + // TODO if a prefix is different, then all larger keys + // that include the prefix are also different. + // TODO if we are comparing the entire primary key or + // the entire unique secondary key, then the cardinality + // must be 1, so we can avoid computing it. + for (uint64_t i = 0; i < num_key_parts; i++) { + int cmp = tokudb_cmp_dbt_key_parts(db, &prev_key, &key, i+1); + if (cmp != 0) { + unique_rows[i]++; + copy_key = true; + } + } + } + + // prev_key = key or prev_key is NULL + if (copy_key) { + prev_key.data = + tokudb::memory::realloc( + prev_key.data, + key.size, + MYF(MY_WME|MY_ZEROFILL|MY_FAE)); + assert_always(prev_key.data); + prev_key.size = key.size; + memcpy(prev_key.data, key.data, prev_key.size); + copy_key = false; + } + + error = analyze_key_progress(); + if (error == ETIME) { + error = 0; + break; + } else if (error) { + break; + } + + // if we have a time limit, are scanning forward and have exceed the + // _half_time and not passed the _half_rows number of the rows in the + // index: clean up the keys, close the cursor and reverse direction. + if (TOKUDB_UNLIKELY(_half_time > 0 && + _scan_direction == DB_NEXT && + _key_elapsed_time >= _half_time && + _rows < _half_rows)) { + + tokudb::memory::free(prev_key.data); prev_key.data = NULL; + close_error = cursor->c_close(cursor); + assert_always(close_error == 0); + cursor = NULL; + _scan_direction = DB_PREV; + } + } + // cleanup + if (prev_key.data) tokudb::memory::free(prev_key.data); + if (cursor) close_error = cursor->c_close(cursor); + assert_always(close_error == 0); + +done: + // return cardinality + for (uint64_t i = 0; i < num_key_parts; i++) { + rec_per_key_part[i] = _rows / unique_rows[i]; + } + return error; +} + +} // namespace analyze +} // namespace tokudb + int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { - TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); - const char *orig_proc_info = tokudb_thd_get_proc_info(thd); - uint64_t rec_per_key[table_share->key_parts]; + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name()); int result = HA_ADMIN_OK; + tokudb::sysvars::analyze_mode_t mode = tokudb::sysvars::analyze_mode(thd); - // stub out analyze if optimize is remapped to alter recreate + analyze - if (thd_sql_command(thd) != SQLCOM_ANALYZE && thd_sql_command(thd) != SQLCOM_ALTER_TABLE) { - TOKUDB_HANDLER_DBUG_RETURN(result); + switch (mode) { + case tokudb::sysvars::TOKUDB_ANALYZE_RECOUNT_ROWS: + result = share->analyze_recount_rows(thd, transaction); + break; + case tokudb::sysvars::TOKUDB_ANALYZE_STANDARD: + share->lock(); + result = share->analyze_standard(thd, transaction); + share->unlock(); + break; + case tokudb::sysvars::TOKUDB_ANALYZE_CANCEL: + share->cancel_background_jobs(); + break; + default: + break; // no-op } - - DB_TXN *txn = transaction; - if (!txn) { - result = HA_ADMIN_FAILED; - } - uint total_key_parts = 0; - if (result == HA_ADMIN_OK) { - // compute cardinality for each key - for (uint i = 0; result == HA_ADMIN_OK && i < table_share->keys; i++) { - KEY *key_info = &table_share->key_info[i]; - uint64_t num_key_parts = get_key_parts(key_info); - const char *key_name = i == primary_key ? "primary" : key_info->name; - struct analyze_progress_extra analyze_progress_extra = { - thd, share, table_share, i, key_name, time(0), write_status_msg - }; - bool is_unique = false; - if (i == primary_key || (key_info->flags & HA_NOSAME)) - is_unique = true; - uint64_t rows = 0; - uint64_t deleted_rows = 0; - int error = tokudb::analyze_card(share->key_file[i], txn, is_unique, num_key_parts, &rec_per_key[total_key_parts], - tokudb_cmp_dbt_key_parts, analyze_progress, &analyze_progress_extra, - &rows, &deleted_rows); - sql_print_information("tokudb analyze %d %" PRIu64 " %" PRIu64, error, rows, deleted_rows); - if (error != 0 && error != ETIME) { - result = HA_ADMIN_FAILED; - } - if (error != 0 && rows == 0 && deleted_rows > 0) { - result = HA_ADMIN_FAILED; - } - double f = THDVAR(thd, analyze_delete_fraction); - if (result == HA_ADMIN_FAILED || (double) deleted_rows > f * (rows + deleted_rows)) { - char name[256]; int namelen; - namelen = snprintf(name, sizeof name, "%.*s.%.*s.%s", - (int) table_share->db.length, table_share->db.str, - (int) table_share->table_name.length, table_share->table_name.str, - key_name); - thd->protocol->prepare_for_resend(); - thd->protocol->store(name, namelen, system_charset_info); - thd->protocol->store("analyze", 7, system_charset_info); - thd->protocol->store("info", 4, system_charset_info); - char rowmsg[256]; int rowmsglen; - rowmsglen = snprintf(rowmsg, sizeof rowmsg, "rows processed %" PRIu64 " rows deleted %" PRIu64, rows, deleted_rows); - thd->protocol->store(rowmsg, rowmsglen, system_charset_info); - thd->protocol->write(); - - sql_print_information("tokudb analyze on %.*s %.*s", - namelen, name, rowmsglen, rowmsg); - } - if (tokudb_debug & TOKUDB_DEBUG_ANALYZE) { - char name[256]; int namelen; - namelen = snprintf(name, sizeof name, "%.*s.%.*s.%s", - (int) table_share->db.length, table_share->db.str, - (int) table_share->table_name.length, table_share->table_name.str, - key_name); - TOKUDB_HANDLER_TRACE("%.*s rows %" PRIu64 " deleted %" PRIu64, - namelen, name, rows, deleted_rows); - for (uint j = 0; j < num_key_parts; j++) - TOKUDB_HANDLER_TRACE("%lu", rec_per_key[total_key_parts+j]); - } - total_key_parts += num_key_parts; - } - } - if (result == HA_ADMIN_OK) { - int error = tokudb::set_card_in_status(share->status_block, txn, total_key_parts, rec_per_key); - if (error) - result = HA_ADMIN_FAILED; - } - thd_proc_info(thd, orig_proc_info); TOKUDB_HANDLER_DBUG_RETURN(result); } +int TOKUDB_SHARE::analyze_recount_rows(THD* thd,DB_TXN* txn) { + TOKUDB_HANDLER_DBUG_ENTER("%s", table_name()); + + assert_always(thd != NULL); + + const char *orig_proc_info = tokudb_thd_get_proc_info(thd); + int result = HA_ADMIN_OK; + + tokudb::analyze::recount_rows_t* job + = new tokudb::analyze::recount_rows_t(true, thd, this, txn); + assert_always(job != NULL); + + // job->destroy will drop the ref + addref(); + unlock(); + + bool ret = tokudb::background::_job_manager-> + run_job(job, tokudb::sysvars::analyze_in_background(thd)); + + if (!ret) { + job->destroy(); + delete job; + result = HA_ADMIN_FAILED; + } + + thd_proc_info(thd, orig_proc_info); + + TOKUDB_HANDLER_DBUG_RETURN(result); +} + +// on entry, if txn is !NULL, it is a user session invoking ANALYZE directly +// and no lock will be held on 'this', else if txn is NULL it is an auto and +// 'this' will be locked. +int TOKUDB_SHARE::analyze_standard(THD* thd, DB_TXN* txn) { + TOKUDB_HANDLER_DBUG_ENTER("%s", table_name()); + + assert_always(thd != NULL); + assert_debug(_mutex.is_owned_by_me() == true); + + int result = HA_ADMIN_OK; + + // stub out analyze if optimize is remapped to alter recreate + analyze + // when not auto analyze or if this is an alter + if ((txn && + thd_sql_command(thd) != SQLCOM_ANALYZE && + thd_sql_command(thd) != SQLCOM_ALTER_TABLE) || + thd_sql_command(thd) == SQLCOM_ALTER_TABLE) { + TOKUDB_HANDLER_DBUG_RETURN(result); + } + + const char *orig_proc_info = tokudb_thd_get_proc_info(thd); + + tokudb::analyze::standard_t* job + = new tokudb::analyze::standard_t(txn == NULL ? false : true, thd, + this, txn); + assert_always(job != NULL); + + // akin to calling addref, but we know, right here, right now, everything + // in the share is set up, files open, etc... + // job->destroy will drop the ref + _use_count++; + + // don't want any autos kicking off while we are analyzing + disallow_auto_analysis(); + + unlock(); + + bool ret = + tokudb::background::_job_manager->run_job( + job, + tokudb::sysvars::analyze_in_background(thd)); + + if (!ret) { + job->destroy(); + delete job; + result = HA_ADMIN_FAILED; + } + + lock(); + + thd_proc_info(thd, orig_proc_info); + + TOKUDB_HANDLER_DBUG_RETURN(result); +} + + typedef struct hot_optimize_context { - THD *thd; + THD* thd; char* write_status_msg; - ha_tokudb *ha; + ha_tokudb* ha; uint progress_stage; uint current_table; uint num_tables; @@ -160,11 +829,18 @@ typedef struct hot_optimize_context { static int hot_optimize_progress_fun(void *extra, float progress) { HOT_OPTIMIZE_CONTEXT context = (HOT_OPTIMIZE_CONTEXT)extra; if (thd_killed(context->thd)) { - sprintf(context->write_status_msg, "The process has been killed, aborting hot optimize."); + sprintf( + context->write_status_msg, + "The process has been killed, aborting hot optimize."); return ER_ABORTING_CONNECTION; } float percentage = progress * 100; - sprintf(context->write_status_msg, "Optimization of index %u of %u about %.lf%% done", context->current_table + 1, context->num_tables, percentage); + sprintf( + context->write_status_msg, + "Optimization of index %u of %u about %.lf%% done", + context->current_table + 1, + context->num_tables, + percentage); thd_proc_info(context->thd, context->write_status_msg); #ifdef HA_TOKUDB_HAS_THD_PROGRESS if (context->progress_stage < context->current_table) { @@ -193,10 +869,10 @@ static int hot_optimize_progress_fun(void *extra, float progress) { } // flatten all DB's in this table, to do so, peform hot optimize on each db -int ha_tokudb::do_optimize(THD *thd) { - TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); +int ha_tokudb::do_optimize(THD* thd) { + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name()); int error = 0; - const char *orig_proc_info = tokudb_thd_get_proc_info(thd); + const char* orig_proc_info = tokudb_thd_get_proc_info(thd); uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); #ifdef HA_TOKUDB_HAS_THD_PROGRESS @@ -207,16 +883,22 @@ int ha_tokudb::do_optimize(THD *thd) { // for each DB, run optimize and hot_optimize for (uint i = 0; i < curr_num_DBs; i++) { - // only optimize the index if it matches the optimize_index_name session variable - const char *optimize_index_name = THDVAR(thd, optimize_index_name); + // only optimize the index if it matches the optimize_index_name + // session variable + const char* optimize_index_name = + tokudb::sysvars::optimize_index_name(thd); if (optimize_index_name) { - const char *this_index_name = i >= table_share->keys ? "primary" : table_share->key_info[i].name; + const char* this_index_name = + i >= table_share->keys ? + "primary" : + table_share->key_info[i].name; if (strcasecmp(optimize_index_name, this_index_name) != 0) { continue; } } DB* db = share->key_file[i]; + assert_always(db != NULL); error = db->optimize(db); if (error) { goto cleanup; @@ -229,11 +911,18 @@ int ha_tokudb::do_optimize(THD *thd) { hc.ha = this; hc.current_table = i; hc.num_tables = curr_num_DBs; - hc.progress_limit = THDVAR(thd, optimize_index_fraction); + hc.progress_limit = tokudb::sysvars::optimize_index_fraction(thd); hc.progress_last_time = toku_current_time_microsec(); - hc.throttle = THDVAR(thd, optimize_throttle); + hc.throttle = tokudb::sysvars::optimize_throttle(thd); uint64_t loops_run; - error = db->hot_optimize(db, NULL, NULL, hot_optimize_progress_fun, &hc, &loops_run); + error = + db->hot_optimize( + db, + NULL, + NULL, + hot_optimize_progress_fun, + &hc, + &loops_run); if (error) { goto cleanup; } @@ -248,8 +937,8 @@ cleanup: TOKUDB_HANDLER_DBUG_RETURN(error); } -int ha_tokudb::optimize(THD *thd, HA_CHECK_OPT *check_opt) { - TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); +int ha_tokudb::optimize(THD* thd, HA_CHECK_OPT* check_opt) { + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name()); int error; #if TOKU_OPTIMIZE_WITH_RECREATE error = HA_ADMIN_TRY_ALTER; @@ -260,23 +949,30 @@ int ha_tokudb::optimize(THD *thd, HA_CHECK_OPT *check_opt) { } struct check_context { - THD *thd; + THD* thd; }; -static int ha_tokudb_check_progress(void *extra, float progress) { - struct check_context *context = (struct check_context *) extra; +static int ha_tokudb_check_progress(void* extra, float progress) { + struct check_context* context = (struct check_context*)extra; int result = 0; if (thd_killed(context->thd)) result = ER_ABORTING_CONNECTION; return result; } -static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) { +static void ha_tokudb_check_info(THD* thd, TABLE* table, const char* msg) { if (thd->vio_ok()) { - char tablename[table->s->db.length + 1 + table->s->table_name.length + 1]; - snprintf(tablename, sizeof tablename, "%.*s.%.*s", - (int) table->s->db.length, table->s->db.str, - (int) table->s->table_name.length, table->s->table_name.str); + char tablename[ + table->s->db.length + 1 + + table->s->table_name.length + 1]; + snprintf( + tablename, + sizeof(tablename), + "%.*s.%.*s", + (int)table->s->db.length, + table->s->db.str, + (int)table->s->table_name.length, + table->s->table_name.str); thd->protocol->prepare_for_resend(); thd->protocol->store(tablename, strlen(tablename), system_charset_info); thd->protocol->store("check", 5, system_charset_info); @@ -286,9 +982,9 @@ static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) { } } -int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { - TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name); - const char *orig_proc_info = tokudb_thd_get_proc_info(thd); +int ha_tokudb::check(THD* thd, HA_CHECK_OPT* check_opt) { + TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name()); + const char* orig_proc_info = tokudb_thd_get_proc_info(thd); int result = HA_ADMIN_OK; int r; @@ -305,38 +1001,73 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) { result = HA_ADMIN_INTERNAL_ERROR; if (result == HA_ADMIN_OK) { uint32_t num_DBs = table_share->keys + tokudb_test(hidden_primary_key); - snprintf(write_status_msg, sizeof write_status_msg, "%s primary=%d num=%d", share->table_name, primary_key, num_DBs); - if (tokudb_debug & TOKUDB_DEBUG_CHECK) { + snprintf( + write_status_msg, + sizeof(write_status_msg), + "%s primary=%d num=%d", + share->table_name(), + primary_key, + num_DBs); + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_CHECK))) { ha_tokudb_check_info(thd, table, write_status_msg); time_t now = time(0); char timebuf[32]; - TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg); + TOKUDB_HANDLER_TRACE( + "%.24s %s", + ctime_r(&now, timebuf), + write_status_msg); } for (uint i = 0; i < num_DBs; i++) { - DB *db = share->key_file[i]; - const char *kname = i == primary_key ? "primary" : table_share->key_info[i].name; - snprintf(write_status_msg, sizeof write_status_msg, "%s key=%s %u", share->table_name, kname, i); + DB* db = share->key_file[i]; + assert_always(db != NULL); + const char* kname = + i == primary_key ? "primary" : table_share->key_info[i].name; + snprintf( + write_status_msg, + sizeof(write_status_msg), + "%s key=%s %u", + share->table_name(), + kname, + i); thd_proc_info(thd, write_status_msg); - if (tokudb_debug & TOKUDB_DEBUG_CHECK) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_CHECK))) { ha_tokudb_check_info(thd, table, write_status_msg); time_t now = time(0); char timebuf[32]; - TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg); + TOKUDB_HANDLER_TRACE( + "%.24s %s", + ctime_r(&now, timebuf), + write_status_msg); } struct check_context check_context = { thd }; - r = db->verify_with_progress(db, ha_tokudb_check_progress, &check_context, (tokudb_debug & TOKUDB_DEBUG_CHECK) != 0, keep_going); + r = db->verify_with_progress( + db, + ha_tokudb_check_progress, + &check_context, + (tokudb::sysvars::debug & TOKUDB_DEBUG_CHECK) != 0, + keep_going); if (r != 0) { char msg[32 + strlen(kname)]; sprintf(msg, "Corrupt %s", kname); ha_tokudb_check_info(thd, table, msg); } - snprintf(write_status_msg, sizeof write_status_msg, "%s key=%s %u result=%d", share->table_name, kname, i, r); + snprintf( + write_status_msg, + sizeof(write_status_msg), + "%s key=%s %u result=%d", + share->full_table_name(), + kname, + i, + r); thd_proc_info(thd, write_status_msg); - if (tokudb_debug & TOKUDB_DEBUG_CHECK) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_CHECK))) { ha_tokudb_check_info(thd, table, write_status_msg); time_t now = time(0); char timebuf[32]; - TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg); + TOKUDB_HANDLER_TRACE( + "%.24s %s", + ctime_r(&now, timebuf), + write_status_msg); } if (result == HA_ADMIN_OK && r != 0) { result = HA_ADMIN_CORRUPT; diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc index a54bebc5420..473c4984eb6 100644 --- a/storage/tokudb/ha_tokudb_alter_56.cc +++ b/storage/tokudb/ha_tokudb_alter_56.cc @@ -67,7 +67,7 @@ public: } public: ulong handler_flags; - DB_TXN *alter_txn; + DB_TXN* alter_txn; bool add_index_changed; bool incremented_num_DBs, modified_DBs; bool drop_index_changed; @@ -79,81 +79,110 @@ public: bool expand_blob_update_needed; bool optimize_needed; Dynamic_array changed_fields; - KEY_AND_COL_INFO *table_kc_info; - KEY_AND_COL_INFO *altered_table_kc_info; + KEY_AND_COL_INFO* table_kc_info; + KEY_AND_COL_INFO* altered_table_kc_info; KEY_AND_COL_INFO altered_table_kc_info_base; }; // Debug function to print out an alter table operation -void ha_tokudb::print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { - printf("***are keys of two tables same? %d\n", tables_have_same_keys(table, altered_table, false, false)); +void ha_tokudb::print_alter_info( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + + TOKUDB_TRACE( + "***are keys of two tables same? %d", + tables_have_same_keys(table, altered_table, false, false)); if (ha_alter_info->handler_flags) { - printf("***alter flags set ***\n"); + TOKUDB_TRACE("***alter flags set ***"); for (int i = 0; i < 32; i++) { if (ha_alter_info->handler_flags & (1 << i)) - printf("%d\n", i); + TOKUDB_TRACE("%d", i); } } - // everyone calculates data by doing some default_values - record[0], but I do not see why - // that is necessary - printf("******\n"); - printf("***orig table***\n"); + // everyone calculates data by doing some default_values - record[0], but + // I do not see why that is necessary + TOKUDB_TRACE("******"); + TOKUDB_TRACE("***orig table***"); for (uint i = 0; i < table->s->fields; i++) { // // make sure to use table->field, and NOT table->s->field // Field* curr_field = table->field[i]; uint null_offset = get_null_offset(table, curr_field); - printf( - "name: %s, types: %u %u, nullable: %d, null_offset: %d, is_null_field: %d, is_null %d, pack_length %u\n", - curr_field->field_name, - curr_field->real_type(), mysql_to_toku_type(curr_field), - curr_field->null_bit, - null_offset, - curr_field->real_maybe_null(), - curr_field->real_maybe_null() ? table->s->default_values[null_offset] & curr_field->null_bit : 0xffffffff, - curr_field->pack_length() - ); + TOKUDB_TRACE( + "name: %s, types: %u %u, nullable: %d, null_offset: %d, is_null_field: " + "%d, is_null %d, pack_length %u", + curr_field->field_name, + curr_field->real_type(), + mysql_to_toku_type(curr_field), + curr_field->null_bit, + null_offset, + curr_field->real_maybe_null(), + curr_field->real_maybe_null() ? + table->s->default_values[null_offset] & curr_field->null_bit : + 0xffffffff, + curr_field->pack_length()); } - printf("******\n"); - printf("***altered table***\n"); + TOKUDB_TRACE("******"); + TOKUDB_TRACE("***altered table***"); for (uint i = 0; i < altered_table->s->fields; i++) { Field* curr_field = altered_table->field[i]; uint null_offset = get_null_offset(altered_table, curr_field); - printf( - "name: %s, types: %u %u, nullable: %d, null_offset: %d, is_null_field: %d, is_null %d, pack_length %u\n", - curr_field->field_name, - curr_field->real_type(), mysql_to_toku_type(curr_field), - curr_field->null_bit, - null_offset, - curr_field->real_maybe_null(), - curr_field->real_maybe_null() ? altered_table->s->default_values[null_offset] & curr_field->null_bit : 0xffffffff, - curr_field->pack_length() - ); + TOKUDB_TRACE( + "name: %s, types: %u %u, nullable: %d, null_offset: %d, " + "is_null_field: %d, is_null %d, pack_length %u", + curr_field->field_name, + curr_field->real_type(), + mysql_to_toku_type(curr_field), + curr_field->null_bit, + null_offset, + curr_field->real_maybe_null(), + curr_field->real_maybe_null() ? + altered_table->s->default_values[null_offset] & + curr_field->null_bit : 0xffffffff, + curr_field->pack_length()); } - printf("******\n"); + TOKUDB_TRACE("******"); } -// Given two tables with equal number of fields, find all of the fields with different types -// and return the indexes of the different fields in the changed_fields array. This function ignores field -// name differences. -static int find_changed_fields(TABLE *table_a, TABLE *table_b, Dynamic_array &changed_fields) { +// Given two tables with equal number of fields, find all of the fields with +// different types and return the indexes of the different fields in the +// changed_fields array. This function ignores field name differences. +static int find_changed_fields( + TABLE* table_a, + TABLE* table_b, + Dynamic_array& changed_fields) { + for (uint i = 0; i < table_a->s->fields; i++) { - Field *field_a = table_a->field[i]; - Field *field_b = table_b->field[i]; + Field* field_a = table_a->field[i]; + Field* field_b = table_b->field[i]; if (!fields_are_same_type(field_a, field_b)) changed_fields.append(i); } return changed_fields.elements(); } -static bool change_length_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx); +static bool change_length_is_supported( + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + tokudb_alter_ctx* ctx); -static bool change_type_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx); +static bool change_type_is_supported( + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + tokudb_alter_ctx* ctx); + +// The ha_alter_info->handler_flags can not be trusted. +// This function maps the bogus handler flags to something we like. +static ulong fix_handler_flags( + THD* thd, + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { -// The ha_alter_info->handler_flags can not be trusted. This function maps the bogus handler flags to something we like. -static ulong fix_handler_flags(THD *thd, TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info) { ulong handler_flags = ha_alter_info->handler_flags; #if 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199 @@ -162,23 +191,33 @@ static ulong fix_handler_flags(THD *thd, TABLE *table, TABLE *altered_table, Alt #endif // workaround for fill_alter_inplace_info bug (#5193) - // the function erroneously sets the ADD_INDEX and DROP_INDEX flags for a column addition that does not - // change the keys. the following code turns the ADD_INDEX and DROP_INDEX flags so that we can do hot - // column addition later. - if (handler_flags & (Alter_inplace_info::ADD_COLUMN + Alter_inplace_info::DROP_COLUMN)) { - if (handler_flags & (Alter_inplace_info::ADD_INDEX + Alter_inplace_info::DROP_INDEX)) { - if (tables_have_same_keys(table, altered_table, THDVAR(thd, alter_print_error) != 0, false)) { - handler_flags &= ~(Alter_inplace_info::ADD_INDEX + Alter_inplace_info::DROP_INDEX); + // the function erroneously sets the ADD_INDEX and DROP_INDEX flags for a + // column addition that does not change the keys. + // the following code turns the ADD_INDEX and DROP_INDEX flags so that + // we can do hot column addition later. + if (handler_flags & + (Alter_inplace_info::ADD_COLUMN + Alter_inplace_info::DROP_COLUMN)) { + if (handler_flags & + (Alter_inplace_info::ADD_INDEX + Alter_inplace_info::DROP_INDEX)) { + if (tables_have_same_keys( + table, + altered_table, + tokudb::sysvars::alter_print_error(thd) != 0, false)) { + handler_flags &= + ~(Alter_inplace_info::ADD_INDEX + + Alter_inplace_info::DROP_INDEX); } } } - // always allow rename table + any other operation, so turn off the rename flag + // always allow rename table + any other operation, so turn off the + // rename flag if (handler_flags & Alter_inplace_info::TOKU_ALTER_RENAME) { handler_flags &= ~Alter_inplace_info::TOKU_ALTER_RENAME; } - // ALTER_COLUMN_TYPE may be set when no columns have been changed, so turn off the flag + // ALTER_COLUMN_TYPE may be set when no columns have been changed, + // so turn off the flag if (handler_flags & Alter_inplace_info::ALTER_COLUMN_TYPE) { if (all_fields_are_same_type(table, altered_table)) { handler_flags &= ~Alter_inplace_info::ALTER_COLUMN_TYPE; @@ -191,9 +230,10 @@ static ulong fix_handler_flags(THD *thd, TABLE *table, TABLE *altered_table, Alt // Require that there is no intersection of add and drop names. static bool is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) { for (uint d = 0; d < ha_alter_info->index_drop_count; d++) { - KEY *drop_key = ha_alter_info->index_drop_buffer[d]; + KEY* drop_key = ha_alter_info->index_drop_buffer[d]; for (uint a = 0; a < ha_alter_info->index_add_count; a++) { - KEY *add_key = &ha_alter_info->key_info_buffer[ha_alter_info->index_add_buffer[a]]; + KEY* add_key = + &ha_alter_info->key_info_buffer[ha_alter_info->index_add_buffer[a]]; if (strcmp(drop_key->name, add_key->name) == 0) { return false; } @@ -202,196 +242,294 @@ static bool is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) { return true; } -// Return true if some bit in mask is set and no bit in ~mask is set, otherwise return false. +// Return true if some bit in mask is set and no bit in ~mask is set, +// otherwise return false. static bool only_flags(ulong bits, ulong mask) { return (bits & mask) != 0 && (bits & ~mask) == 0; } -// Check if an alter table operation on this table and described by the alter table parameters is supported inplace -// and if so, what type of locking is needed to execute it. -// return values: +// Check if an alter table operation on this table and described by the alter +// table parameters is supported inplace and if so, what type of locking is +// needed to execute it. return values: + +// HA_ALTER_INPLACE_NOT_SUPPORTED: alter operation is not supported as an +// inplace operation, a table copy is required -// HA_ALTER_INPLACE_NOT_SUPPORTED: alter operation is not supported as an inplace operation, a table copy is required // HA_ALTER_ERROR: the alter table operation should fail // HA_ALTER_INPLACE_EXCLUSIVE_LOCK: prepare and alter runs with MDL X -// HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE: prepare runs with MDL X, alter runs with MDL SNW -// HA_ALTER_INPLACE_SHARED_LOCK: prepare and alter methods called with MDL SNW, concurrent reads, no writes +// HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE: prepare runs with MDL X, +// alter runs with MDL SNW + +// HA_ALTER_INPLACE_SHARED_LOCK: prepare and alter methods called with MDL SNW, +// concurrent reads, no writes + +// HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE: prepare runs with MDL X, +// alter runs with MDL SW + +// HA_ALTER_INPLACE_NO_LOCK: prepare and alter methods called with MDL SW, +// concurrent reads, writes. +// must set WRITE_ALLOW_WRITE lock type in the external lock method to avoid +// deadlocks with the MDL lock and the table lock +enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { -// HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE: prepare runs with MDL X, alter runs with MDL SW -// HA_ALTER_INPLACE_NO_LOCK: prepare and alter methods called with MDL SW, concurrent reads, writes. -// must set WRITE_ALLOW_WRITE lock type in the external lock method to avoid deadlocks -// with the MDL lock and the table lock -enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { TOKUDB_HANDLER_DBUG_ENTER(""); - if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ALTER_TABLE))) { print_alter_info(altered_table, ha_alter_info); } - enum_alter_inplace_result result = HA_ALTER_INPLACE_NOT_SUPPORTED; // default is NOT inplace - THD *thd = ha_thd(); + // default is NOT inplace + enum_alter_inplace_result result = HA_ALTER_INPLACE_NOT_SUPPORTED; + THD* thd = ha_thd(); // setup context - tokudb_alter_ctx *ctx = new tokudb_alter_ctx; + tokudb_alter_ctx* ctx = new tokudb_alter_ctx; ha_alter_info->handler_ctx = ctx; - ctx->handler_flags = fix_handler_flags(thd, table, altered_table, ha_alter_info); + ctx->handler_flags = + fix_handler_flags(thd, table, altered_table, ha_alter_info); ctx->table_kc_info = &share->kc_info; ctx->altered_table_kc_info = &ctx->altered_table_kc_info_base; memset(ctx->altered_table_kc_info, 0, sizeof (KEY_AND_COL_INFO)); - if (get_disable_hot_alter(thd)) { + if (tokudb::sysvars::disable_hot_alter(thd)) { ; // do nothing - } else - // add or drop index - if (only_flags(ctx->handler_flags, Alter_inplace_info::DROP_INDEX + Alter_inplace_info::DROP_UNIQUE_INDEX + - Alter_inplace_info::ADD_INDEX + Alter_inplace_info::ADD_UNIQUE_INDEX)) { + } else if (only_flags( + ctx->handler_flags, + Alter_inplace_info::DROP_INDEX + + Alter_inplace_info::DROP_UNIQUE_INDEX + + Alter_inplace_info::ADD_INDEX + + Alter_inplace_info::ADD_UNIQUE_INDEX)) { + // add or drop index if (table->s->null_bytes == altered_table->s->null_bytes && - (ha_alter_info->index_add_count > 0 || ha_alter_info->index_drop_count > 0) && - !tables_have_same_keys(table, altered_table, THDVAR(thd, alter_print_error) != 0, false) && + (ha_alter_info->index_add_count > 0 || + ha_alter_info->index_drop_count > 0) && + !tables_have_same_keys( + table, + altered_table, + tokudb::sysvars::alter_print_error(thd) != 0, false) && is_disjoint_add_drop(ha_alter_info)) { - if (ctx->handler_flags & (Alter_inplace_info::DROP_INDEX + Alter_inplace_info::DROP_UNIQUE_INDEX)) { - // the fractal tree can not handle dropping an index concurrent with querying with the index. + if (ctx->handler_flags & + (Alter_inplace_info::DROP_INDEX + + Alter_inplace_info::DROP_UNIQUE_INDEX)) { + // the fractal tree can not handle dropping an index concurrent + // with querying with the index. // we grab an exclusive MDL for the drop index. result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } else { result = HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE; - // someday, allow multiple hot indexes via alter table add key. don't forget to change the store_lock function. - // for now, hot indexing is only supported via session variable with the create index sql command - if (ha_alter_info->index_add_count == 1 && ha_alter_info->index_drop_count == 0 && // only one add or drop - ctx->handler_flags == Alter_inplace_info::ADD_INDEX && // must be add index not add unique index - thd_sql_command(thd) == SQLCOM_CREATE_INDEX && // must be a create index command - get_create_index_online(thd)) { // must be enabled - // external_lock set WRITE_ALLOW_WRITE which allows writes concurrent with the index creation + // someday, allow multiple hot indexes via alter table add key. + // don't forget to change the store_lock function. + // for now, hot indexing is only supported via session variable + // with the create index sql command + if (ha_alter_info->index_add_count == 1 && + // only one add or drop + ha_alter_info->index_drop_count == 0 && + // must be add index not add unique index + ctx->handler_flags == Alter_inplace_info::ADD_INDEX && + // must be a create index command + thd_sql_command(thd) == SQLCOM_CREATE_INDEX && + // must be enabled + tokudb::sysvars::create_index_online(thd)) { + // external_lock set WRITE_ALLOW_WRITE which allows writes + // concurrent with the index creation result = HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE; } } } - } else - // column default - if (only_flags(ctx->handler_flags, Alter_inplace_info::ALTER_COLUMN_DEFAULT)) { + } else if (only_flags( + ctx->handler_flags, + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) { + // column default if (table->s->null_bytes == altered_table->s->null_bytes) result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; - } else - // column rename - if (ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_NAME && - only_flags(ctx->handler_flags, Alter_inplace_info::ALTER_COLUMN_NAME + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) { - // we have identified a possible column rename, + } else if (ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_NAME && + only_flags( + ctx->handler_flags, + Alter_inplace_info::ALTER_COLUMN_NAME + + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) { + // column rename + // we have identified a possible column rename, // but let's do some more checks - + // we will only allow an hcr if there are no changes // in column positions (ALTER_COLUMN_ORDER is not set) - + // now need to verify that one and only one column // has changed only its name. If we find anything to // the contrary, we don't allow it, also check indexes if (table->s->null_bytes == altered_table->s->null_bytes) { - bool cr_supported = column_rename_supported(table, altered_table, (ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_ORDER) != 0); + bool cr_supported = + column_rename_supported( + table, + altered_table, + (ctx->handler_flags & + Alter_inplace_info::ALTER_COLUMN_ORDER) != 0); if (cr_supported) result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } - } else - // add column - if (ctx->handler_flags & Alter_inplace_info::ADD_COLUMN && - only_flags(ctx->handler_flags, Alter_inplace_info::ADD_COLUMN + Alter_inplace_info::ALTER_COLUMN_ORDER) && - setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { + } else if (ctx->handler_flags & Alter_inplace_info::ADD_COLUMN && + only_flags( + ctx->handler_flags, + Alter_inplace_info::ADD_COLUMN + + Alter_inplace_info::ALTER_COLUMN_ORDER) && + setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { + // add column uint32_t added_columns[altered_table->s->fields]; uint32_t num_added_columns = 0; - int r = find_changed_columns(added_columns, &num_added_columns, table, altered_table); + int r = + find_changed_columns( + added_columns, + &num_added_columns, + table, + altered_table); if (r == 0) { - if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ALTER_TABLE))) { for (uint32_t i = 0; i < num_added_columns; i++) { uint32_t curr_added_index = added_columns[i]; - Field* curr_added_field = altered_table->field[curr_added_index]; - printf("Added column: index %d, name %s\n", curr_added_index, curr_added_field->field_name); + Field* curr_added_field = + altered_table->field[curr_added_index]; + TOKUDB_TRACE( + "Added column: index %d, name %s", + curr_added_index, + curr_added_field->field_name); } } result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } - } else - // drop column - if (ctx->handler_flags & Alter_inplace_info::DROP_COLUMN && - only_flags(ctx->handler_flags, Alter_inplace_info::DROP_COLUMN + Alter_inplace_info::ALTER_COLUMN_ORDER) && - setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { + } else if (ctx->handler_flags & Alter_inplace_info::DROP_COLUMN && + only_flags( + ctx->handler_flags, + Alter_inplace_info::DROP_COLUMN + + Alter_inplace_info::ALTER_COLUMN_ORDER) && + setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { + // drop column uint32_t dropped_columns[table->s->fields]; uint32_t num_dropped_columns = 0; - int r = find_changed_columns(dropped_columns, &num_dropped_columns, altered_table, table); + int r = + find_changed_columns( + dropped_columns, + &num_dropped_columns, + altered_table, + table); if (r == 0) { - if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ALTER_TABLE))) { for (uint32_t i = 0; i < num_dropped_columns; i++) { uint32_t curr_dropped_index = dropped_columns[i]; Field* curr_dropped_field = table->field[curr_dropped_index]; - printf("Dropped column: index %d, name %s\n", curr_dropped_index, curr_dropped_field->field_name); + TOKUDB_TRACE( + "Dropped column: index %d, name %s", + curr_dropped_index, + curr_dropped_field->field_name); } } result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } - } else - // change column length - if ((ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH) && - only_flags(ctx->handler_flags, Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH + Alter_inplace_info::ALTER_COLUMN_DEFAULT) && - table->s->fields == altered_table->s->fields && - find_changed_fields(table, altered_table, ctx->changed_fields) > 0 && - setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { + } else if ((ctx->handler_flags & + Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH) && + only_flags( + ctx->handler_flags, + Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH + + Alter_inplace_info::ALTER_COLUMN_DEFAULT) && + table->s->fields == altered_table->s->fields && + find_changed_fields( + table, + altered_table, + ctx->changed_fields) > 0 && + setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { - if (change_length_is_supported(table, altered_table, ha_alter_info, ctx)) { + // change column length + if (change_length_is_supported( + table, + altered_table, + ha_alter_info, ctx)) { result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } - } else - // change column type - if ((ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_TYPE) && - only_flags(ctx->handler_flags, Alter_inplace_info::ALTER_COLUMN_TYPE + Alter_inplace_info::ALTER_COLUMN_DEFAULT) && - table->s->fields == altered_table->s->fields && - find_changed_fields(table, altered_table, ctx->changed_fields) > 0 && - setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { - - if (change_type_is_supported(table, altered_table, ha_alter_info, ctx)) { + } else if ((ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_TYPE) && + only_flags( + ctx->handler_flags, + Alter_inplace_info::ALTER_COLUMN_TYPE + + Alter_inplace_info::ALTER_COLUMN_DEFAULT) && + table->s->fields == altered_table->s->fields && + find_changed_fields( + table, + altered_table, + ctx->changed_fields) > 0 && + setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) { + + // change column type + if (change_type_is_supported( + table, + altered_table, + ha_alter_info, ctx)) { result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } - } else - if (only_flags(ctx->handler_flags, Alter_inplace_info::CHANGE_CREATE_OPTION)) { - HA_CREATE_INFO *create_info = ha_alter_info->create_info; + } else if (only_flags( + ctx->handler_flags, + Alter_inplace_info::CHANGE_CREATE_OPTION)) { + + HA_CREATE_INFO* create_info = ha_alter_info->create_info; #if TOKU_INCLUDE_OPTION_STRUCTS // set the USED_ROW_FORMAT flag for use later in this file for changes in the table's // compression - if (create_info->option_struct->row_format != table_share->option_struct->row_format) + if (create_info->option_struct->row_format != + table_share->option_struct->row_format) create_info->used_fields |= HA_CREATE_USED_ROW_FORMAT; #endif // alter auto_increment if (only_flags(create_info->used_fields, HA_CREATE_USED_AUTO)) { // do a sanity check that the table is what we think it is - if (tables_have_same_keys_and_columns(table, altered_table, THDVAR(thd, alter_print_error) != 0)) { + if (tables_have_same_keys_and_columns( + table, + altered_table, + tokudb::sysvars::alter_print_error(thd) != 0)) { result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } - } - // alter row_format - else if (only_flags(create_info->used_fields, HA_CREATE_USED_ROW_FORMAT)) { + } else if (only_flags( + create_info->used_fields, + HA_CREATE_USED_ROW_FORMAT)) { + // alter row_format // do a sanity check that the table is what we think it is - if (tables_have_same_keys_and_columns(table, altered_table, THDVAR(thd, alter_print_error) != 0)) { + if (tables_have_same_keys_and_columns( + table, + altered_table, + tokudb::sysvars::alter_print_error(thd) != 0)) { result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } } - } + } #if TOKU_OPTIMIZE_WITH_RECREATE - else if (only_flags(ctx->handler_flags, Alter_inplace_info::RECREATE_TABLE + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) { + else if (only_flags( + ctx->handler_flags, + Alter_inplace_info::RECREATE_TABLE + + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) { ctx->optimize_needed = true; result = HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE; } #endif - if (result != HA_ALTER_INPLACE_NOT_SUPPORTED && table->s->null_bytes != altered_table->s->null_bytes && - (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE)) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ALTER_TABLE)) && + result != HA_ALTER_INPLACE_NOT_SUPPORTED && + table->s->null_bytes != altered_table->s->null_bytes) { + TOKUDB_HANDLER_TRACE("q %s", thd->query()); - TOKUDB_HANDLER_TRACE("null bytes %u -> %u", table->s->null_bytes, altered_table->s->null_bytes); + TOKUDB_HANDLER_TRACE( + "null bytes %u -> %u", + table->s->null_bytes, + altered_table->s->null_bytes); } - // turn a not supported result into an error if the slow alter table (copy) is disabled - if (result == HA_ALTER_INPLACE_NOT_SUPPORTED && get_disable_slow_alter(thd)) { + // turn a not supported result into an error if the slow alter table + // (copy) is disabled + if (result == HA_ALTER_INPLACE_NOT_SUPPORTED && + tokudb::sysvars::disable_slow_alter(thd)) { print_error(HA_ERR_UNSUPPORTED, MYF(0)); result = HA_ALTER_ERROR; } @@ -400,46 +538,77 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(TABLE *alt } // Prepare for the alter operations -bool ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +bool ha_tokudb::prepare_inplace_alter_table( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + TOKUDB_HANDLER_DBUG_ENTER(""); - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); - assert(transaction); // transaction must exist after table is locked + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); + assert_always(transaction); // transaction must exist after table is locked ctx->alter_txn = transaction; bool result = false; // success DBUG_RETURN(result); } // Execute the alter operations. -bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +bool ha_tokudb::inplace_alter_table( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = 0; - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); - HA_CREATE_INFO *create_info = ha_alter_info->create_info; + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); + HA_CREATE_INFO* create_info = ha_alter_info->create_info; - if (error == 0 && (ctx->handler_flags & (Alter_inplace_info::DROP_INDEX + Alter_inplace_info::DROP_UNIQUE_INDEX))) { + // this should be enough to handle locking as the higher level MDL + // on this table should prevent any new analyze tasks. + share->cancel_background_jobs(); + + if (error == 0 && + (ctx->handler_flags & + (Alter_inplace_info::DROP_INDEX + + Alter_inplace_info::DROP_UNIQUE_INDEX))) { error = alter_table_drop_index(altered_table, ha_alter_info); } - if (error == 0 && (ctx->handler_flags & (Alter_inplace_info::ADD_INDEX + Alter_inplace_info::ADD_UNIQUE_INDEX))) { + if (error == 0 && + (ctx->handler_flags & + (Alter_inplace_info::ADD_INDEX + + Alter_inplace_info::ADD_UNIQUE_INDEX))) { error = alter_table_add_index(altered_table, ha_alter_info); } - if (error == 0 && (ctx->handler_flags & (Alter_inplace_info::ADD_COLUMN + Alter_inplace_info::DROP_COLUMN))) { + if (error == 0 && + (ctx->handler_flags & + (Alter_inplace_info::ADD_COLUMN + + Alter_inplace_info::DROP_COLUMN))) { error = alter_table_add_or_drop_column(altered_table, ha_alter_info); } - if (error == 0 && (ctx->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) && (create_info->used_fields & HA_CREATE_USED_AUTO)) { - error = write_auto_inc_create(share->status_block, create_info->auto_increment_value, ctx->alter_txn); + if (error == 0 && + (ctx->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) && + (create_info->used_fields & HA_CREATE_USED_AUTO)) { + error = write_auto_inc_create( + share->status_block, + create_info->auto_increment_value, + ctx->alter_txn); } - if (error == 0 && (ctx->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) && (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) { + if (error == 0 && + (ctx->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) && + (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) { // Get the current compression DB *db = share->key_file[0]; error = db->get_compression_method(db, &ctx->orig_compression_method); - assert(error == 0); + assert_always(error == 0); // Set the new compression #if TOKU_INCLUDE_OPTION_STRUCTS - toku_compression_method method = row_format_to_toku_compression_method((srv_row_format_t) create_info->option_struct->row_format); + toku_compression_method method = + row_format_to_toku_compression_method( + (tokudb::sysvars::row_format_t)create_info->option_struct->row_format); #else - toku_compression_method method = row_type_to_toku_compression_method(create_info->row_type); + toku_compression_method method = + row_type_to_toku_compression_method(create_info->row_type); #endif uint32_t curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); for (uint32_t i = 0; i < curr_num_DBs; i++) { @@ -457,13 +626,19 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha error = alter_table_expand_columns(altered_table, ha_alter_info); if (error == 0 && ctx->expand_varchar_update_needed) - error = alter_table_expand_varchar_offsets(altered_table, ha_alter_info); + error = alter_table_expand_varchar_offsets( + altered_table, + ha_alter_info); if (error == 0 && ctx->expand_blob_update_needed) error = alter_table_expand_blobs(altered_table, ha_alter_info); if (error == 0 && ctx->reset_card) { - error = tokudb::alter_card(share->status_block, ctx->alter_txn, table->s, altered_table->s); + error = tokudb::alter_card( + share->status_block, + ctx->alter_txn, + table->s, + altered_table->s); } if (error == 0 && ctx->optimize_needed) { error = do_optimize(ha_thd()); @@ -472,11 +647,15 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha #if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \ (50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799) #if WITH_PARTITION_STORAGE_ENGINE - if (error == 0 && (TOKU_PARTITION_WRITE_FRM_DATA || altered_table->part_info == NULL)) { + if (error == 0 && + (TOKU_PARTITION_WRITE_FRM_DATA || altered_table->part_info == NULL)) { #else if (error == 0) { #endif - error = write_frm_data(share->status_block, ctx->alter_txn, altered_table->s->path.str); + error = write_frm_data( + share->status_block, + ctx->alter_txn, + altered_table->s->path.str); } #endif @@ -489,20 +668,34 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha DBUG_RETURN(result); } -int ha_tokudb::alter_table_add_index(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +int ha_tokudb::alter_table_add_index( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { // sort keys in add index order - KEY *key_info = (KEY*) tokudb_my_malloc(sizeof (KEY) * ha_alter_info->index_add_count, MYF(MY_WME)); + KEY* key_info = (KEY*)tokudb::memory::malloc( + sizeof(KEY) * ha_alter_info->index_add_count, + MYF(MY_WME)); for (uint i = 0; i < ha_alter_info->index_add_count; i++) { KEY *key = &key_info[i]; *key = ha_alter_info->key_info_buffer[ha_alter_info->index_add_buffer[i]]; - for (KEY_PART_INFO *key_part= key->key_part; key_part < key->key_part + get_key_parts(key); key_part++) + for (KEY_PART_INFO* key_part = key->key_part; + key_part < key->key_part + key->user_defined_key_parts; + key_part++) { key_part->field = table->field[key_part->fieldnr]; + } } - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); ctx->add_index_changed = true; - int error = tokudb_add_index(table, key_info, ha_alter_info->index_add_count, ctx->alter_txn, &ctx->incremented_num_DBs, &ctx->modified_DBs); + int error = tokudb_add_index( + table, + key_info, + ha_alter_info->index_add_count, + ctx->alter_txn, + &ctx->incremented_num_DBs, + &ctx->modified_DBs); if (error == HA_ERR_FOUND_DUPP_KEY) { // hack for now, in case of duplicate key error, // because at the moment we cannot display the right key @@ -511,7 +704,7 @@ int ha_tokudb::alter_table_add_index(TABLE *altered_table, Alter_inplace_info *h last_dup_key = MAX_KEY; } - tokudb_my_free(key_info); + tokudb::memory::free(key_info); if (error == 0) ctx->reset_card = true; @@ -519,7 +712,11 @@ int ha_tokudb::alter_table_add_index(TABLE *altered_table, Alter_inplace_info *h return error; } -static bool find_index_of_key(const char *key_name, TABLE *table, uint *index_offset_ptr) { +static bool find_index_of_key( + const char* key_name, + TABLE* table, + uint* index_offset_ptr) { + for (uint i = 0; i < table->s->keys; i++) { if (strcmp(key_name, table->key_info[i].name) == 0) { *index_offset_ptr = i; @@ -529,7 +726,12 @@ static bool find_index_of_key(const char *key_name, TABLE *table, uint *index_of return false; } -static bool find_index_of_key(const char *key_name, KEY *key_info, uint key_count, uint *index_offset_ptr) { +static bool find_index_of_key( + const char* key_name, + KEY* key_info, + uint key_count, + uint* index_offset_ptr) { + for (uint i = 0; i < key_count; i++) { if (strcmp(key_name, key_info[i].name) == 0) { *index_offset_ptr = i; @@ -539,26 +741,42 @@ static bool find_index_of_key(const char *key_name, KEY *key_info, uint key_coun return false; } -int ha_tokudb::alter_table_drop_index(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +int ha_tokudb::alter_table_drop_index( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + KEY *key_info = table->key_info; // translate key names to indexes into the key_info array uint index_drop_offsets[ha_alter_info->index_drop_count]; for (uint i = 0; i < ha_alter_info->index_drop_count; i++) { bool found; - found = find_index_of_key(ha_alter_info->index_drop_buffer[i]->name, table, &index_drop_offsets[i]); + found = find_index_of_key( + ha_alter_info->index_drop_buffer[i]->name, + table, + &index_drop_offsets[i]); if (!found) { // undo of add key in partition engine - found = find_index_of_key(ha_alter_info->index_drop_buffer[i]->name, ha_alter_info->key_info_buffer, ha_alter_info->key_count, &index_drop_offsets[i]); - assert(found); + found = find_index_of_key( + ha_alter_info->index_drop_buffer[i]->name, + ha_alter_info->key_info_buffer, + ha_alter_info->key_count, + &index_drop_offsets[i]); + assert_always(found); key_info = ha_alter_info->key_info_buffer; } } // drop indexes - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); ctx->drop_index_changed = true; - int error = drop_indexes(table, index_drop_offsets, ha_alter_info->index_drop_count, key_info, ctx->alter_txn); + int error = drop_indexes( + table, + index_drop_offsets, + ha_alter_info->index_drop_count, + key_info, + ctx->alter_txn); if (error == 0) ctx->reset_card = true; @@ -566,93 +784,122 @@ int ha_tokudb::alter_table_drop_index(TABLE *altered_table, Alter_inplace_info * return error; } -int ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); +int ha_tokudb::alter_table_add_or_drop_column( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); int error; uchar *column_extra = NULL; uint32_t max_column_extra_size; uint32_t num_column_extra; uint32_t num_columns = 0; uint32_t curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); - - uint32_t columns[table->s->fields + altered_table->s->fields]; // set size such that we know it is big enough for both cases + // set size such that we know it is big enough for both cases + uint32_t columns[table->s->fields + altered_table->s->fields]; memset(columns, 0, sizeof(columns)); // generate the array of columns if (ha_alter_info->handler_flags & Alter_inplace_info::DROP_COLUMN) { find_changed_columns( - columns, - &num_columns, - altered_table, - table - ); - } else - if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN) { + columns, + &num_columns, + altered_table, + table); + } else if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN) { find_changed_columns( - columns, - &num_columns, - table, - altered_table - ); - } else - assert(0); + columns, + &num_columns, + table, + altered_table); + } else { + assert_unreachable(); + } max_column_extra_size = - STATIC_ROW_MUTATOR_SIZE + //max static row_mutator - 4 + num_columns*(1+1+4+1+1+4) + altered_table->s->reclength + // max dynamic row_mutator - (4 + share->kc_info.num_blobs) + // max static blob size - (num_columns*(1+4+1+4)); // max dynamic blob size - column_extra = (uchar *)tokudb_my_malloc(max_column_extra_size, MYF(MY_WME)); - if (column_extra == NULL) { error = ENOMEM; goto cleanup; } + // max static row_mutator + STATIC_ROW_MUTATOR_SIZE + + // max dynamic row_mutator + 4 + num_columns*(1+1+4+1+1+4) + altered_table->s->reclength + + // max static blob size + (4 + share->kc_info.num_blobs) + + // max dynamic blob size + (num_columns*(1+4+1+4)); + column_extra = (uchar*)tokudb::memory::malloc( + max_column_extra_size, + MYF(MY_WME)); + if (column_extra == NULL) { + error = ENOMEM; + goto cleanup; + } for (uint32_t i = 0; i < curr_num_DBs; i++) { // change to a new descriptor DBT row_descriptor; memset(&row_descriptor, 0, sizeof row_descriptor); - error = new_row_descriptor(table, altered_table, ha_alter_info, i, &row_descriptor); + error = new_row_descriptor( + table, + altered_table, + ha_alter_info, + i, + &row_descriptor); if (error) goto cleanup; - error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0); - tokudb_my_free(row_descriptor.data); + error = share->key_file[i]->change_descriptor( + share->key_file[i], + ctx->alter_txn, + &row_descriptor, + 0); + tokudb::memory::free(row_descriptor.data); if (error) goto cleanup; if (i == primary_key || key_is_clustering(&table_share->key_info[i])) { num_column_extra = fill_row_mutator( - column_extra, - columns, - num_columns, - altered_table, - ctx->altered_table_kc_info, - i, - (ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN) != 0 // true if adding columns, otherwise is a drop - ); + column_extra, + columns, + num_columns, + altered_table, + ctx->altered_table_kc_info, + i, + // true if adding columns, otherwise is a drop + (ha_alter_info->handler_flags & + Alter_inplace_info::ADD_COLUMN) != 0); DBT column_dbt; memset(&column_dbt, 0, sizeof column_dbt); column_dbt.data = column_extra; column_dbt.size = num_column_extra; DBUG_ASSERT(num_column_extra <= max_column_extra_size); error = share->key_file[i]->update_broadcast( - share->key_file[i], - ctx->alter_txn, - &column_dbt, - DB_IS_RESETTING_OP - ); - if (error) { goto cleanup; } + share->key_file[i], + ctx->alter_txn, + &column_dbt, + DB_IS_RESETTING_OP); + if (error) { + goto cleanup; + } } } error = 0; cleanup: - tokudb_my_free(column_extra); + tokudb::memory::free(column_extra); return error; } // Commit or abort the alter operations. -// If commit then write the new frm data to the status using the alter transaction. -// If abort then abort the alter transaction and try to rollback the non-transactional changes. -bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit) { +// If commit then write the new frm data to the status using the alter +// transaction. +// If abort then abort the alter transaction and try to rollback the +// non-transactional changes. +bool ha_tokudb::commit_inplace_alter_table( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + bool commit) { + TOKUDB_HANDLER_DBUG_ENTER(""); - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); bool result = false; // success THD *thd = ha_thd(); @@ -671,7 +918,10 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i #else if (true) { #endif - int error = write_frm_data(share->status_block, ctx->alter_txn, altered_table->s->path.str); + int error = write_frm_data( + share->status_block, + ctx->alter_txn, + altered_table->s->path.str); if (error) { commit = false; result = true; @@ -683,42 +933,55 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i if (!commit) { if (table->mdl_ticket->get_type() != MDL_EXCLUSIVE && - (ctx->add_index_changed || ctx->drop_index_changed || ctx->compression_changed)) { + (ctx->add_index_changed || ctx->drop_index_changed || + ctx->compression_changed)) { // get exclusive lock no matter what #if defined(MARIADB_BASE_VERSION) killed_state saved_killed_state = thd->killed; thd->killed = NOT_KILLED; - for (volatile uint i = 0; wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED); i++) { + for (volatile uint i = 0; + wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED); + i++) { if (thd->killed != NOT_KILLED) thd->killed = NOT_KILLED; sleep(1); } - assert(table->mdl_ticket->get_type() == MDL_EXCLUSIVE); + assert_always(table->mdl_ticket->get_type() == MDL_EXCLUSIVE); if (thd->killed == NOT_KILLED) thd->killed = saved_killed_state; #else THD::killed_state saved_killed_state = thd->killed; thd->killed = THD::NOT_KILLED; - // MySQL does not handle HA_EXTRA_NOT_USED so we use HA_EXTRA_PREPARE_FOR_RENAME since it is passed through + // MySQL does not handle HA_EXTRA_NOT_USED so we use + // HA_EXTRA_PREPARE_FOR_RENAME since it is passed through // the partition storage engine and is treated as a NOP by tokudb - for (volatile uint i = 0; wait_while_table_is_used(thd, table, HA_EXTRA_PREPARE_FOR_RENAME); i++) { + for (volatile uint i = 0; + wait_while_table_is_used( + thd, + table, + HA_EXTRA_PREPARE_FOR_RENAME); + i++) { if (thd->killed != THD::NOT_KILLED) thd->killed = THD::NOT_KILLED; sleep(1); } - assert(table->mdl_ticket->get_type() == MDL_EXCLUSIVE); + assert_always(table->mdl_ticket->get_type() == MDL_EXCLUSIVE); if (thd->killed == THD::NOT_KILLED) thd->killed = saved_killed_state; #endif } - // abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work. - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); - assert(ctx->alter_txn == trx->stmt); - assert(trx->tokudb_lock_count > 0); - // for partitioned tables, we use a single transaction to do all of the partition changes. the tokudb_lock_count - // is a reference count for each of the handlers to the same transaction. obviously, we want to only abort once. + // abort the alter transaction NOW so that any alters are rolled back. + // this allows the following restores to work. + tokudb_trx_data* trx = + (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); + assert_always(ctx->alter_txn == trx->stmt); + assert_always(trx->tokudb_lock_count > 0); + // for partitioned tables, we use a single transaction to do all of the + // partition changes. the tokudb_lock_count is a reference count for + // each of the handlers to the same transaction. obviously, we want + // to only abort once. if (trx->tokudb_lock_count > 0) { if (--trx->tokudb_lock_count <= trx->create_lock_count) { trx->create_lock_count = 0; @@ -731,82 +994,125 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i } if (ctx->add_index_changed) { - restore_add_index(table, ha_alter_info->index_add_count, ctx->incremented_num_DBs, ctx->modified_DBs); + restore_add_index( + table, + ha_alter_info->index_add_count, + ctx->incremented_num_DBs, + ctx->modified_DBs); } if (ctx->drop_index_changed) { // translate key names to indexes into the key_info array uint index_drop_offsets[ha_alter_info->index_drop_count]; for (uint i = 0; i < ha_alter_info->index_drop_count; i++) { - bool found = find_index_of_key(ha_alter_info->index_drop_buffer[i]->name, table, &index_drop_offsets[i]); - assert(found); + bool found = find_index_of_key( + ha_alter_info->index_drop_buffer[i]->name, + table, + &index_drop_offsets[i]); + assert_always(found); } - restore_drop_indexes(table, index_drop_offsets, ha_alter_info->index_drop_count); + restore_drop_indexes( + table, + index_drop_offsets, + ha_alter_info->index_drop_count); } if (ctx->compression_changed) { - uint32_t curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); + uint32_t curr_num_DBs = + table->s->keys + tokudb_test(hidden_primary_key); for (uint32_t i = 0; i < curr_num_DBs; i++) { DB *db = share->key_file[i]; - int error = db->change_compression_method(db, ctx->orig_compression_method); - assert(error == 0); + int error = db->change_compression_method( + db, + ctx->orig_compression_method); + assert_always(error == 0); } } } - DBUG_RETURN(result); } // Setup the altered table's key and col info. -int ha_tokudb::setup_kc_info(TABLE *altered_table, KEY_AND_COL_INFO *altered_kc_info) { +int ha_tokudb::setup_kc_info( + TABLE* altered_table, + KEY_AND_COL_INFO* altered_kc_info) { + int error = allocate_key_and_col_info(altered_table->s, altered_kc_info); if (error == 0) - error = initialize_key_and_col_info(altered_table->s, altered_table, altered_kc_info, hidden_primary_key, primary_key); + error = initialize_key_and_col_info( + altered_table->s, + altered_table, + altered_kc_info, + hidden_primary_key, + primary_key); return error; } // Expand the variable length fields offsets from 1 to 2 bytes. -int ha_tokudb::alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +int ha_tokudb::alter_table_expand_varchar_offsets( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + int error = 0; - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); uint32_t curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); for (uint32_t i = 0; i < curr_num_DBs; i++) { // change to a new descriptor DBT row_descriptor; memset(&row_descriptor, 0, sizeof row_descriptor); - error = new_row_descriptor(table, altered_table, ha_alter_info, i, &row_descriptor); + error = new_row_descriptor( + table, + altered_table, + ha_alter_info, + i, + &row_descriptor); if (error) break; - error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0); - tokudb_my_free(row_descriptor.data); + error = share->key_file[i]->change_descriptor( + share->key_file[i], + ctx->alter_txn, + &row_descriptor, + 0); + tokudb::memory::free(row_descriptor.data); if (error) break; - // for all trees that have values, make an update variable offsets message and broadcast it into the tree + // for all trees that have values, make an update variable offsets + // message and broadcast it into the tree if (i == primary_key || key_is_clustering(&table_share->key_info[i])) { - uint32_t offset_start = table_share->null_bytes + share->kc_info.mcp_info[i].fixed_field_size; - uint32_t offset_end = offset_start + share->kc_info.mcp_info[i].len_of_offsets; + uint32_t offset_start = + table_share->null_bytes + + share->kc_info.mcp_info[i].fixed_field_size; + uint32_t offset_end = + offset_start + + share->kc_info.mcp_info[i].len_of_offsets; uint32_t number_of_offsets = offset_end - offset_start; // make the expand variable offsets message DBT expand; memset(&expand, 0, sizeof expand); - expand.size = sizeof (uchar) + sizeof offset_start + sizeof offset_end; - expand.data = tokudb_my_malloc(expand.size, MYF(MY_WME)); + expand.size = + sizeof(uchar) + sizeof(offset_start) + sizeof(offset_end); + expand.data = tokudb::memory::malloc(expand.size, MYF(MY_WME)); if (!expand.data) { error = ENOMEM; break; } - uchar *expand_ptr = (uchar *)expand.data; + uchar* expand_ptr = (uchar*)expand.data; expand_ptr[0] = UPDATE_OP_EXPAND_VARIABLE_OFFSETS; - expand_ptr += sizeof (uchar); + expand_ptr += sizeof(uchar); - memcpy(expand_ptr, &number_of_offsets, sizeof number_of_offsets); - expand_ptr += sizeof number_of_offsets; + memcpy(expand_ptr, &number_of_offsets, sizeof(number_of_offsets)); + expand_ptr += sizeof(number_of_offsets); - memcpy(expand_ptr, &offset_start, sizeof offset_start); - expand_ptr += sizeof offset_start; + memcpy(expand_ptr, &offset_start, sizeof(offset_start)); + expand_ptr += sizeof(offset_start); // and broadcast it into the tree - error = share->key_file[i]->update_broadcast(share->key_file[i], ctx->alter_txn, &expand, DB_IS_RESETTING_OP); - tokudb_my_free(expand.data); + error = share->key_file[i]->update_broadcast( + share->key_file[i], + ctx->alter_txn, + &expand, + DB_IS_RESETTING_OP); + tokudb::memory::free(expand.data); if (error) break; } @@ -817,7 +1123,7 @@ int ha_tokudb::alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_in // Return true if a field is part of a key static bool field_in_key(KEY *key, Field *field) { - for (uint i = 0; i < get_key_parts(key); i++) { + for (uint i = 0; i < key->user_defined_key_parts; i++) { KEY_PART_INFO *key_part = &key->key_part[i]; if (strcmp(key_part->field->field_name, field->field_name) == 0) return true; @@ -834,30 +1140,49 @@ static bool field_in_key_of_table(TABLE *table, Field *field) { return false; } -// Return true if all changed varchar/varbinary field lengths can be changed inplace, otherwise return false -static bool change_varchar_length_is_supported(Field *old_field, Field *new_field, TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx) { +// Return true if all changed varchar/varbinary field lengths can be changed +// inplace, otherwise return false +static bool change_varchar_length_is_supported( + Field* old_field, + Field* new_field, + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + tokudb_alter_ctx* ctx) { + if (old_field->real_type() != MYSQL_TYPE_VARCHAR || new_field->real_type() != MYSQL_TYPE_VARCHAR || old_field->binary() != new_field->binary() || old_field->charset()->number != new_field->charset()->number || old_field->field_length > new_field->field_length) return false; - if (ctx->table_kc_info->num_offset_bytes > ctx->altered_table_kc_info->num_offset_bytes) + if (ctx->table_kc_info->num_offset_bytes > + ctx->altered_table_kc_info->num_offset_bytes) return false; // shrink is not supported - if (ctx->table_kc_info->num_offset_bytes < ctx->altered_table_kc_info->num_offset_bytes) - ctx->expand_varchar_update_needed = true; // sum of varchar lengths changed from 1 to 2 + if (ctx->table_kc_info->num_offset_bytes < + ctx->altered_table_kc_info->num_offset_bytes) + // sum of varchar lengths changed from 1 to 2 + ctx->expand_varchar_update_needed = true; return true; } -// Return true if all changed field lengths can be changed inplace, otherwise return false -static bool change_length_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx) { +// Return true if all changed field lengths can be changed inplace, otherwise +// return false +static bool change_length_is_supported( + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + tokudb_alter_ctx* ctx) { + if (table->s->fields != altered_table->s->fields) return false; if (table->s->null_bytes != altered_table->s->null_bytes) return false; if (ctx->changed_fields.elements() > 1) return false; // only support one field change - for (DYNAMIC_ARRAY_ELEMENTS_TYPE ai = 0; ai < ctx->changed_fields.elements(); ai++) { + for (DYNAMIC_ARRAY_ELEMENTS_TYPE ai = 0; + ai < ctx->changed_fields.elements(); + ai++) { uint i = ctx->changed_fields.at(ai); Field *old_field = table->field[i]; Field *new_field = altered_table->field[i]; @@ -865,9 +1190,16 @@ static bool change_length_is_supported(TABLE *table, TABLE *altered_table, Alter return false; // no type conversions if (old_field->real_type() != MYSQL_TYPE_VARCHAR) return false; // only varchar - if (field_in_key_of_table(table, old_field) || field_in_key_of_table(altered_table, new_field)) + if (field_in_key_of_table(table, old_field) || + field_in_key_of_table(altered_table, new_field)) return false; // not in any key - if (!change_varchar_length_is_supported(old_field, new_field, table, altered_table, ha_alter_info, ctx)) + if (!change_varchar_length_is_supported( + old_field, + new_field, + table, + altered_table, + ha_alter_info, + ctx)) return false; } @@ -886,13 +1218,23 @@ static bool is_sorted(Dynamic_array &a) { return r; } -int ha_tokudb::alter_table_expand_columns(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +int ha_tokudb::alter_table_expand_columns( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + int error = 0; - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); - assert(is_sorted(ctx->changed_fields)); // since we build the changed_fields array in field order, it must be sorted - for (DYNAMIC_ARRAY_ELEMENTS_TYPE ai = 0; error == 0 && ai < ctx->changed_fields.elements(); ai++) { + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); + // since we build the changed_fields array in field order, it must be sorted + assert_always(is_sorted(ctx->changed_fields)); + for (DYNAMIC_ARRAY_ELEMENTS_TYPE ai = 0; + error == 0 && ai < ctx->changed_fields.elements(); + ai++) { uint expand_field_num = ctx->changed_fields.at(ai); - error = alter_table_expand_one_column(altered_table, ha_alter_info, expand_field_num); + error = alter_table_expand_one_column( + altered_table, + ha_alter_info, + expand_field_num); } return error; @@ -903,10 +1245,15 @@ static bool is_unsigned(Field *f) { return (f->flags & UNSIGNED_FLAG) != 0; } -// Return the starting offset in the value for a particular index (selected by idx) of a -// particular field (selected by expand_field_num) +// Return the starting offset in the value for a particular index (selected by +// idx) of a particular field (selected by expand_field_num) // TODO: replace this? -static uint32_t alter_table_field_offset(uint32_t null_bytes, KEY_AND_COL_INFO *kc_info, int idx, int expand_field_num) { +static uint32_t alter_table_field_offset( + uint32_t null_bytes, + KEY_AND_COL_INFO* kc_info, + int idx, + int expand_field_num) { + uint32_t offset = null_bytes; for (int i = 0; i < expand_field_num; i++) { if (bitmap_is_set(&kc_info->key_filters[idx], i)) // skip key fields @@ -917,21 +1264,26 @@ static uint32_t alter_table_field_offset(uint32_t null_bytes, KEY_AND_COL_INFO * } // Send an expand message into all clustered indexes including the primary -int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info, int expand_field_num) { +int ha_tokudb::alter_table_expand_one_column( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + int expand_field_num) { + int error = 0; - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); Field *old_field = table->field[expand_field_num]; TOKU_TYPE old_field_type = mysql_to_toku_type(old_field); Field *new_field = altered_table->field[expand_field_num]; TOKU_TYPE new_field_type = mysql_to_toku_type(new_field); - assert(old_field_type == new_field_type); + assert_always(old_field_type == new_field_type); uchar operation; uchar pad_char; switch (old_field_type) { case toku_type_int: - assert(is_unsigned(old_field) == is_unsigned(new_field)); + assert_always(is_unsigned(old_field) == is_unsigned(new_field)); if (is_unsigned(old_field)) operation = UPDATE_OP_EXPAND_UINT; else @@ -947,38 +1299,61 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace pad_char = 0; break; default: - assert(0); + assert_unreachable(); } uint32_t curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); for (uint32_t i = 0; i < curr_num_DBs; i++) { // change to a new descriptor DBT row_descriptor; memset(&row_descriptor, 0, sizeof row_descriptor); - error = new_row_descriptor(table, altered_table, ha_alter_info, i, &row_descriptor); + error = new_row_descriptor( + table, + altered_table, + ha_alter_info, + i, + &row_descriptor); if (error) break; - error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0); - tokudb_my_free(row_descriptor.data); + error = share->key_file[i]->change_descriptor( + share->key_file[i], + ctx->alter_txn, + &row_descriptor, + 0); + tokudb::memory::free(row_descriptor.data); if (error) break; - // for all trees that have values, make an expand update message and broadcast it into the tree + // for all trees that have values, make an expand update message and + // broadcast it into the tree if (i == primary_key || key_is_clustering(&table_share->key_info[i])) { - uint32_t old_offset = alter_table_field_offset(table_share->null_bytes, ctx->table_kc_info, i, expand_field_num); - uint32_t new_offset = alter_table_field_offset(table_share->null_bytes, ctx->altered_table_kc_info, i, expand_field_num); - assert(old_offset <= new_offset); + uint32_t old_offset = alter_table_field_offset( + table_share->null_bytes, + ctx->table_kc_info, + i, + expand_field_num); + uint32_t new_offset = alter_table_field_offset( + table_share->null_bytes, + ctx->altered_table_kc_info, + i, + expand_field_num); + assert_always(old_offset <= new_offset); - uint32_t old_length = ctx->table_kc_info->field_lengths[expand_field_num]; - assert(old_length == old_field->pack_length()); + uint32_t old_length = + ctx->table_kc_info->field_lengths[expand_field_num]; + assert_always(old_length == old_field->pack_length()); - uint32_t new_length = ctx->altered_table_kc_info->field_lengths[expand_field_num]; - assert(new_length == new_field->pack_length()); + uint32_t new_length = + ctx->altered_table_kc_info->field_lengths[expand_field_num]; + assert_always(new_length == new_field->pack_length()); - DBT expand; memset(&expand, 0, sizeof expand); - expand.size = sizeof operation + sizeof new_offset + sizeof old_length + sizeof new_length; - if (operation == UPDATE_OP_EXPAND_CHAR || operation == UPDATE_OP_EXPAND_BINARY) - expand.size += sizeof pad_char; - expand.data = tokudb_my_malloc(expand.size, MYF(MY_WME)); + DBT expand; memset(&expand, 0, sizeof(expand)); + expand.size = + sizeof(operation) + sizeof(new_offset) + + sizeof(old_length) + sizeof(new_length); + if (operation == UPDATE_OP_EXPAND_CHAR || + operation == UPDATE_OP_EXPAND_BINARY) + expand.size += sizeof(pad_char); + expand.data = tokudb::memory::malloc(expand.size, MYF(MY_WME)); if (!expand.data) { error = ENOMEM; break; @@ -987,27 +1362,34 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace expand_ptr[0] = operation; expand_ptr += sizeof operation; - // for the first altered field, old_offset == new_offset. for the subsequent altered fields, the new_offset - // should be used as it includes the length changes from the previous altered fields. - memcpy(expand_ptr, &new_offset, sizeof new_offset); - expand_ptr += sizeof new_offset; + // for the first altered field, old_offset == new_offset. + // for the subsequent altered fields, the new_offset + // should be used as it includes the length changes from the + // previous altered fields. + memcpy(expand_ptr, &new_offset, sizeof(new_offset)); + expand_ptr += sizeof(new_offset); - memcpy(expand_ptr, &old_length, sizeof old_length); - expand_ptr += sizeof old_length; + memcpy(expand_ptr, &old_length, sizeof(old_length)); + expand_ptr += sizeof(old_length); - memcpy(expand_ptr, &new_length, sizeof new_length); - expand_ptr += sizeof new_length; + memcpy(expand_ptr, &new_length, sizeof(new_length)); + expand_ptr += sizeof(new_length); - if (operation == UPDATE_OP_EXPAND_CHAR || operation == UPDATE_OP_EXPAND_BINARY) { - memcpy(expand_ptr, &pad_char, sizeof pad_char); - expand_ptr += sizeof pad_char; + if (operation == UPDATE_OP_EXPAND_CHAR || + operation == UPDATE_OP_EXPAND_BINARY) { + memcpy(expand_ptr, &pad_char, sizeof(pad_char)); + expand_ptr += sizeof(pad_char); } - assert(expand_ptr == (uchar *)expand.data + expand.size); + assert_always(expand_ptr == (uchar*)expand.data + expand.size); // and broadcast it into the tree - error = share->key_file[i]->update_broadcast(share->key_file[i], ctx->alter_txn, &expand, DB_IS_RESETTING_OP); - tokudb_my_free(expand.data); + error = share->key_file[i]->update_broadcast( + share->key_file[i], + ctx->alter_txn, + &expand, + DB_IS_RESETTING_OP); + tokudb::memory::free(expand.data); if (error) break; } @@ -1016,52 +1398,85 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace return error; } -static void marshall_blob_lengths(tokudb::buffer &b, uint32_t n, TABLE *table, KEY_AND_COL_INFO *kc_info) { +static void marshall_blob_lengths( + tokudb::buffer& b, + uint32_t n, + TABLE* table, + KEY_AND_COL_INFO* kc_info) { + for (uint i = 0; i < n; i++) { uint blob_field_index = kc_info->blob_fields[i]; - assert(blob_field_index < table->s->fields); - uint8_t blob_field_length = table->s->field[blob_field_index]->row_pack_length(); + assert_always(blob_field_index < table->s->fields); + uint8_t blob_field_length = + table->s->field[blob_field_index]->row_pack_length(); b.append(&blob_field_length, sizeof blob_field_length); } } -int ha_tokudb::alter_table_expand_blobs(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +int ha_tokudb::alter_table_expand_blobs( + TABLE* altered_table, + Alter_inplace_info* ha_alter_info) { + int error = 0; - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); uint32_t curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key); for (uint32_t i = 0; i < curr_num_DBs; i++) { // change to a new descriptor DBT row_descriptor; memset(&row_descriptor, 0, sizeof row_descriptor); - error = new_row_descriptor(table, altered_table, ha_alter_info, i, &row_descriptor); + error = new_row_descriptor( + table, + altered_table, + ha_alter_info, + i, + &row_descriptor); if (error) break; - error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0); - tokudb_my_free(row_descriptor.data); + error = share->key_file[i]->change_descriptor( + share->key_file[i], + ctx->alter_txn, + &row_descriptor, + 0); + tokudb::memory::free(row_descriptor.data); if (error) break; - // for all trees that have values, make an update blobs message and broadcast it into the tree + // for all trees that have values, make an update blobs message and + // broadcast it into the tree if (i == primary_key || key_is_clustering(&table_share->key_info[i])) { tokudb::buffer b; uint8_t op = UPDATE_OP_EXPAND_BLOB; b.append(&op, sizeof op); - b.append_ui(table->s->null_bytes + ctx->table_kc_info->mcp_info[i].fixed_field_size); - uint32_t var_offset_bytes = ctx->table_kc_info->mcp_info[i].len_of_offsets; + b.append_ui( + table->s->null_bytes + + ctx->table_kc_info->mcp_info[i].fixed_field_size); + uint32_t var_offset_bytes = + ctx->table_kc_info->mcp_info[i].len_of_offsets; b.append_ui(var_offset_bytes); - b.append_ui(var_offset_bytes == 0 ? 0 : ctx->table_kc_info->num_offset_bytes); + b.append_ui( + var_offset_bytes == 0 ? 0 : + ctx->table_kc_info->num_offset_bytes); // add blobs info uint32_t num_blobs = ctx->table_kc_info->num_blobs; b.append_ui(num_blobs); marshall_blob_lengths(b, num_blobs, table, ctx->table_kc_info); - marshall_blob_lengths(b, num_blobs, altered_table, ctx->altered_table_kc_info); + marshall_blob_lengths( + b, + num_blobs, + altered_table, + ctx->altered_table_kc_info); // and broadcast it into the tree DBT expand; memset(&expand, 0, sizeof expand); expand.data = b.data(); expand.size = b.size(); - error = share->key_file[i]->update_broadcast(share->key_file[i], ctx->alter_txn, &expand, DB_IS_RESETTING_OP); + error = share->key_file[i]->update_broadcast( + share->key_file[i], + ctx->alter_txn, + &expand, + DB_IS_RESETTING_OP); if (error) break; } @@ -1071,7 +1486,13 @@ int ha_tokudb::alter_table_expand_blobs(TABLE *altered_table, Alter_inplace_info } // Return true if two fixed length fields can be changed inplace -static bool change_fixed_length_is_supported(TABLE *table, TABLE *altered_table, Field *old_field, Field *new_field, tokudb_alter_ctx *ctx) { +static bool change_fixed_length_is_supported( + TABLE* table, + TABLE* altered_table, + Field* old_field, + Field* new_field, + tokudb_alter_ctx* ctx) { + // no change in size is supported if (old_field->pack_length() == new_field->pack_length()) return true; @@ -1082,9 +1503,16 @@ static bool change_fixed_length_is_supported(TABLE *table, TABLE *altered_table, return true; } -static bool change_blob_length_is_supported(TABLE *table, TABLE *altered_table, Field *old_field, Field *new_field, tokudb_alter_ctx *ctx) { +static bool change_blob_length_is_supported( + TABLE* table, + TABLE* altered_table, + Field* old_field, + Field* new_field, + tokudb_alter_ctx* ctx) { + // blob -> longer or equal length blob - if (old_field->binary() && new_field->binary() && old_field->pack_length() <= new_field->pack_length()) { + if (old_field->binary() && new_field->binary() && + old_field->pack_length() <= new_field->pack_length()) { ctx->expand_blob_update_needed = true; return true; } @@ -1113,13 +1541,26 @@ static bool is_int_type(enum_field_types t) { } // Return true if two field types can be changed inplace -static bool change_field_type_is_supported(Field *old_field, Field *new_field, TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx) { +static bool change_field_type_is_supported( + Field* old_field, + Field* new_field, + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + tokudb_alter_ctx* ctx) { + enum_field_types old_type = old_field->real_type(); enum_field_types new_type = new_field->real_type(); if (is_int_type(old_type)) { // int and unsigned int expansion - if (is_int_type(new_type) && is_unsigned(old_field) == is_unsigned(new_field)) - return change_fixed_length_is_supported(table, altered_table, old_field, new_field, ctx); + if (is_int_type(new_type) && + is_unsigned(old_field) == is_unsigned(new_field)) + return change_fixed_length_is_supported( + table, + altered_table, + old_field, + new_field, + ctx); else return false; } else if (old_type == MYSQL_TYPE_STRING) { @@ -1127,67 +1568,112 @@ static bool change_field_type_is_supported(Field *old_field, Field *new_field, T if (new_type == MYSQL_TYPE_STRING && old_field->binary() == new_field->binary() && old_field->charset()->number == new_field->charset()->number) - return change_fixed_length_is_supported(table, altered_table, old_field, new_field, ctx); + return change_fixed_length_is_supported( + table, + altered_table, + old_field, + new_field, + ctx); else return false; } else if (old_type == MYSQL_TYPE_VARCHAR) { - // varchar(X) -> varchar(Y) and varbinary(X) -> varbinary(Y) expansion where X < 256 <= Y - // the ALTER_COLUMN_TYPE handler flag is set for these cases - return change_varchar_length_is_supported(old_field, new_field, table, altered_table, ha_alter_info, ctx); + // varchar(X) -> varchar(Y) and varbinary(X) -> varbinary(Y) expansion + // where X < 256 <= Y the ALTER_COLUMN_TYPE handler flag is set for + // these cases + return change_varchar_length_is_supported( + old_field, + new_field, + table, + altered_table, + ha_alter_info, + ctx); } else if (old_type == MYSQL_TYPE_BLOB && new_type == MYSQL_TYPE_BLOB) { - return change_blob_length_is_supported(table, altered_table, old_field, new_field, ctx); + return change_blob_length_is_supported( + table, + altered_table, + old_field, + new_field, + ctx); } else return false; } // Return true if all changed field types can be changed inplace -static bool change_type_is_supported(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, tokudb_alter_ctx *ctx) { +static bool change_type_is_supported( + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + tokudb_alter_ctx* ctx) { + if (table->s->null_bytes != altered_table->s->null_bytes) return false; if (table->s->fields != altered_table->s->fields) return false; if (ctx->changed_fields.elements() > 1) return false; // only support one field change - for (DYNAMIC_ARRAY_ELEMENTS_TYPE ai = 0; ai < ctx->changed_fields.elements(); ai++) { + for (DYNAMIC_ARRAY_ELEMENTS_TYPE ai = 0; + ai < ctx->changed_fields.elements(); + ai++) { uint i = ctx->changed_fields.at(ai); Field *old_field = table->field[i]; Field *new_field = altered_table->field[i]; - if (field_in_key_of_table(table, old_field) || field_in_key_of_table(altered_table, new_field)) + if (field_in_key_of_table(table, old_field) || + field_in_key_of_table(altered_table, new_field)) return false; - if (!change_field_type_is_supported(old_field, new_field, table, altered_table, ha_alter_info, ctx)) + if (!change_field_type_is_supported( + old_field, + new_field, + table, + altered_table, + ha_alter_info, + ctx)) return false; } return true; } -// Allocate and initialize a new descriptor for a dictionary in the altered table identified with idx. +// Allocate and initialize a new descriptor for a dictionary in the altered +// table identified with idx. // Return the new descriptor in the row_descriptor DBT. // Return non-zero on error. -int ha_tokudb::new_row_descriptor(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, uint32_t idx, DBT *row_descriptor) { +int ha_tokudb::new_row_descriptor( + TABLE* table, + TABLE* altered_table, + Alter_inplace_info* ha_alter_info, + uint32_t idx, + DBT* row_descriptor) { + int error = 0; - tokudb_alter_ctx *ctx = static_cast(ha_alter_info->handler_ctx); - row_descriptor->size = get_max_desc_size(ctx->altered_table_kc_info, altered_table); - row_descriptor->data = (uchar *) tokudb_my_malloc(row_descriptor->size, MYF(MY_WME)); + tokudb_alter_ctx* ctx = + static_cast(ha_alter_info->handler_ctx); + row_descriptor->size = + get_max_desc_size(ctx->altered_table_kc_info, altered_table); + row_descriptor->data = + (uchar*)tokudb::memory::malloc(row_descriptor->size, MYF(MY_WME)); if (row_descriptor->data == NULL) { error = ENOMEM; } else { - KEY* prim_key = hidden_primary_key ? NULL : &altered_table->s->key_info[primary_key]; + KEY* prim_key = + hidden_primary_key ? NULL : + &altered_table->s->key_info[primary_key]; if (idx == primary_key) { - row_descriptor->size = create_main_key_descriptor((uchar *)row_descriptor->data, - prim_key, - hidden_primary_key, - primary_key, - altered_table, - ctx->altered_table_kc_info); + row_descriptor->size = create_main_key_descriptor( + (uchar*)row_descriptor->data, + prim_key, + hidden_primary_key, + primary_key, + altered_table, + ctx->altered_table_kc_info); } else { - row_descriptor->size = create_secondary_key_descriptor((uchar *)row_descriptor->data, - &altered_table->key_info[idx], - prim_key, - hidden_primary_key, - altered_table, - primary_key, - idx, - ctx->altered_table_kc_info); + row_descriptor->size = create_secondary_key_descriptor( + (uchar*)row_descriptor->data, + &altered_table->key_info[idx], + prim_key, + hidden_primary_key, + altered_table, + primary_key, + idx, + ctx->altered_table_kc_info); } error = 0; } diff --git a/storage/tokudb/ha_tokudb_alter_common.cc b/storage/tokudb/ha_tokudb_alter_common.cc index b2c2a2b0252..d41a676de1f 100644 --- a/storage/tokudb/ha_tokudb_alter_common.cc +++ b/storage/tokudb/ha_tokudb_alter_common.cc @@ -26,8 +26,18 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #if !defined(TOKUDB_ALTER_COMMON) #define TOKUDB_ALTER_COMMON -static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print_error, bool check_field_index) __attribute__((unused)); -static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print_error, bool check_field_index) { +TOKUDB_UNUSED(static bool tables_have_same_keys( + TABLE* table, + TABLE* altered_table, + bool print_error, + bool check_field_index)); + +static bool tables_have_same_keys( + TABLE* table, + TABLE* altered_table, + bool print_error, + bool check_field_index) { + bool retval; if (table->s->keys != altered_table->s->keys) { if (print_error) { @@ -39,10 +49,9 @@ static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print if (table->s->primary_key != altered_table->s->primary_key) { if (print_error) { sql_print_error( - "Tables have different primary keys, %d %d", + "Tables have different primary keys, %d %d", table->s->primary_key, - altered_table->s->primary_key - ); + altered_table->s->primary_key); } retval = false; goto cleanup; @@ -53,44 +62,43 @@ static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print if (strcmp(curr_orig_key->name, curr_altered_key->name)) { if (print_error) { sql_print_error( - "key %d has different name, %s %s", - i, + "key %d has different name, %s %s", + i, curr_orig_key->name, - curr_altered_key->name - ); + curr_altered_key->name); } retval = false; goto cleanup; } - if (key_is_clustering(curr_orig_key) != key_is_clustering(curr_altered_key)) { + if (key_is_clustering(curr_orig_key) != + key_is_clustering(curr_altered_key)) { if (print_error) { sql_print_error( "keys disagree on if they are clustering, %d, %d", - get_key_parts(curr_orig_key), - get_key_parts(curr_altered_key) - ); + curr_orig_key->user_defined_key_parts, + curr_altered_key->user_defined_key_parts); } retval = false; goto cleanup; } - if (((curr_orig_key->flags & HA_NOSAME) == 0) != ((curr_altered_key->flags & HA_NOSAME) == 0)) { + if (((curr_orig_key->flags & HA_NOSAME) == 0) != + ((curr_altered_key->flags & HA_NOSAME) == 0)) { if (print_error) { sql_print_error( "keys disagree on if they are unique, %d, %d", - get_key_parts(curr_orig_key), - get_key_parts(curr_altered_key) - ); + curr_orig_key->user_defined_key_parts, + curr_altered_key->user_defined_key_parts); } retval = false; goto cleanup; } - if (get_key_parts(curr_orig_key) != get_key_parts(curr_altered_key)) { + if (curr_orig_key->user_defined_key_parts != + curr_altered_key->user_defined_key_parts) { if (print_error) { sql_print_error( "keys have different number of parts, %d, %d", - get_key_parts(curr_orig_key), - get_key_parts(curr_altered_key) - ); + curr_orig_key->user_defined_key_parts, + curr_altered_key->user_defined_key_parts); } retval = false; goto cleanup; @@ -98,7 +106,7 @@ static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print // // now verify that each field in the key is the same // - for (uint32_t j = 0; j < get_key_parts(curr_orig_key); j++) { + for (uint32_t j = 0; j < curr_orig_key->user_defined_key_parts; j++) { KEY_PART_INFO* curr_orig_part = &curr_orig_key->key_part[j]; KEY_PART_INFO* curr_altered_part = &curr_altered_key->key_part[j]; Field* curr_orig_field = curr_orig_part->field; @@ -106,10 +114,9 @@ static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print if (curr_orig_part->length != curr_altered_part->length) { if (print_error) { sql_print_error( - "Key %s has different length at index %d", - curr_orig_key->name, - j - ); + "Key %s has different length at index %d", + curr_orig_key->name, + j); } retval = false; goto cleanup; @@ -123,10 +130,9 @@ static bool tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print if (!are_fields_same) { if (print_error) { sql_print_error( - "Key %s has different field at index %d", - curr_orig_key->name, - j - ); + "Key %s has different field at index %d", + curr_orig_key->name, + j); } retval = false; goto cleanup; @@ -143,7 +149,8 @@ cleanup: // to evaluate whether a field is NULL or not. This value is a power of 2, from // 2^0 to 2^7. We return the position of the bit within the byte, which is // lg null_bit -static inline uint32_t get_null_bit_position(uint32_t null_bit) __attribute__((unused)); +TOKUDB_UNUSED(static inline uint32_t get_null_bit_position( + uint32_t null_bit)); static inline uint32_t get_null_bit_position(uint32_t null_bit) { uint32_t retval = 0; switch(null_bit) { @@ -170,23 +177,28 @@ static inline uint32_t get_null_bit_position(uint32_t null_bit) { break; case (128): retval = 7; - break; + break; default: - assert(false); + assert_unreachable(); } return retval; } // returns the index of the null bit of field. -static inline uint32_t get_overall_null_bit_position(TABLE* table, Field* field) __attribute__((unused)); -static inline uint32_t get_overall_null_bit_position(TABLE* table, Field* field) { +TOKUDB_UNUSED(static inline uint32_t get_overall_null_bit_position( + TABLE* table, + Field* field)); +static inline uint32_t get_overall_null_bit_position( + TABLE* table, + Field* field) { + uint32_t offset = get_null_offset(table, field); uint32_t null_bit = field->null_bit; return offset*8 + get_null_bit_position(null_bit); } // not static since 51 uses this and 56 does not -static bool are_null_bits_in_order(TABLE* table) __attribute__((unused)); +TOKUDB_UNUSED(static bool are_null_bits_in_order(TABLE* table)); static bool are_null_bits_in_order(TABLE* table) { uint32_t curr_null_pos = 0; bool first = true; @@ -195,10 +207,8 @@ static bool are_null_bits_in_order(TABLE* table) { Field* curr_field = table->field[i]; bool nullable = (curr_field->null_bit != 0); if (nullable) { - uint32_t pos = get_overall_null_bit_position( - table, - curr_field - ); + uint32_t pos = + get_overall_null_bit_position(table, curr_field); if (!first && pos != curr_null_pos+1){ retval = false; break; @@ -210,34 +220,38 @@ static bool are_null_bits_in_order(TABLE* table) { return retval; } -static uint32_t get_first_null_bit_pos(TABLE* table) __attribute__((unused)); +TOKUDB_UNUSED(static uint32_t get_first_null_bit_pos(TABLE* table)); static uint32_t get_first_null_bit_pos(TABLE* table) { uint32_t table_pos = 0; for (uint i = 0; i < table->s->fields; i++) { Field* curr_field = table->field[i]; bool nullable = (curr_field->null_bit != 0); if (nullable) { - table_pos = get_overall_null_bit_position( - table, - curr_field - ); + table_pos = + get_overall_null_bit_position(table, curr_field); break; } } return table_pos; } -static bool is_column_default_null(TABLE* src_table, uint32_t field_index) __attribute__((unused)); -static bool is_column_default_null(TABLE* src_table, uint32_t field_index) { +TOKUDB_UNUSED(static bool is_column_default_null( + TABLE* src_table, + uint32_t field_index)); +static bool is_column_default_null( + TABLE* src_table, + uint32_t field_index) { + Field* curr_field = src_table->field[field_index]; bool is_null_default = false; bool nullable = curr_field->null_bit != 0; if (nullable) { - uint32_t null_bit_position = get_overall_null_bit_position(src_table, curr_field); - is_null_default = is_overall_null_position_set( - src_table->s->default_values, - null_bit_position - ); + uint32_t null_bit_position = + get_overall_null_bit_position(src_table, curr_field); + is_null_default = + is_overall_null_position_set( + src_table->s->default_values, + null_bit_position); } return is_null_default; } @@ -248,9 +262,8 @@ static uint32_t fill_static_row_mutator( TABLE* altered_table, KEY_AND_COL_INFO* orig_kc_info, KEY_AND_COL_INFO* altered_kc_info, - uint32_t keynr - ) -{ + uint32_t keynr) { + // // start packing extra // @@ -258,25 +271,28 @@ static uint32_t fill_static_row_mutator( // says what the operation is pos[0] = UP_COL_ADD_OR_DROP; pos++; - + // // null byte information // memcpy(pos, &orig_table->s->null_bytes, sizeof(orig_table->s->null_bytes)); pos += sizeof(orig_table->s->null_bytes); - memcpy(pos, &altered_table->s->null_bytes, sizeof(orig_table->s->null_bytes)); + memcpy( + pos, + &altered_table->s->null_bytes, + sizeof(orig_table->s->null_bytes)); pos += sizeof(altered_table->s->null_bytes); - + // // num_offset_bytes // - assert(orig_kc_info->num_offset_bytes <= 2); + assert_always(orig_kc_info->num_offset_bytes <= 2); pos[0] = orig_kc_info->num_offset_bytes; pos++; - assert(altered_kc_info->num_offset_bytes <= 2); + assert_always(altered_kc_info->num_offset_bytes <= 2); pos[0] = altered_kc_info->num_offset_bytes; pos++; - + // // size of fixed fields // @@ -286,7 +302,7 @@ static uint32_t fill_static_row_mutator( fixed_field_size = altered_kc_info->mcp_info[keynr].fixed_field_size; memcpy(pos, &fixed_field_size, sizeof(fixed_field_size)); pos += sizeof(fixed_field_size); - + // // length of offsets // @@ -304,7 +320,7 @@ static uint32_t fill_static_row_mutator( memcpy(pos, &altered_start_null_pos, sizeof(altered_start_null_pos)); pos += sizeof(altered_start_null_pos); - assert((pos-buf) == STATIC_ROW_MUTATOR_SIZE); + assert_always((pos-buf) == STATIC_ROW_MUTATOR_SIZE); return pos - buf; } @@ -316,9 +332,8 @@ static uint32_t fill_dynamic_row_mutator( KEY_AND_COL_INFO* src_kc_info, uint32_t keynr, bool is_add, - bool* out_has_blobs - ) -{ + bool* out_has_blobs) { + uchar* pos = buf; bool has_blobs = false; uint32_t cols = num_columns; @@ -327,7 +342,7 @@ static uint32_t fill_dynamic_row_mutator( for (uint32_t i = 0; i < num_columns; i++) { uint32_t curr_index = columns[i]; Field* curr_field = src_table->field[curr_index]; - + pos[0] = is_add ? COL_ADD : COL_DROP; pos++; // @@ -338,22 +353,22 @@ static uint32_t fill_dynamic_row_mutator( if (!nullable) { pos[0] = 0; pos++; - } - else { + } else { pos[0] = 1; pos++; // write position of null byte that is to be removed - uint32_t null_bit_position = get_overall_null_bit_position(src_table, curr_field); + uint32_t null_bit_position = + get_overall_null_bit_position(src_table, curr_field); memcpy(pos, &null_bit_position, sizeof(null_bit_position)); pos += sizeof(null_bit_position); // // if adding a column, write the value of the default null_bit // if (is_add) { - is_null_default = is_overall_null_position_set( - src_table->s->default_values, - null_bit_position - ); + is_null_default = + is_overall_null_position_set( + src_table->s->default_values, + null_bit_position); pos[0] = is_null_default ? 1 : 0; pos++; } @@ -364,7 +379,8 @@ static uint32_t fill_dynamic_row_mutator( pos[0] = COL_FIXED; pos++; //store the offset - uint32_t fixed_field_offset = src_kc_info->cp_info[keynr][curr_index].col_pack_val; + uint32_t fixed_field_offset = + src_kc_info->cp_info[keynr][curr_index].col_pack_val; memcpy(pos, &fixed_field_offset, sizeof(fixed_field_offset)); pos += sizeof(fixed_field_offset); //store the number of bytes @@ -374,38 +390,35 @@ static uint32_t fill_dynamic_row_mutator( if (is_add && !is_null_default) { uint curr_field_offset = field_offset(curr_field, src_table); memcpy( - pos, - src_table->s->default_values + curr_field_offset, - num_bytes - ); + pos, + src_table->s->default_values + curr_field_offset, + num_bytes); pos += num_bytes; } - } - else if (is_variable_field(src_kc_info, curr_index)) { + } else if (is_variable_field(src_kc_info, curr_index)) { pos[0] = COL_VAR; pos++; //store the index of the variable column - uint32_t var_field_index = src_kc_info->cp_info[keynr][curr_index].col_pack_val; + uint32_t var_field_index = + src_kc_info->cp_info[keynr][curr_index].col_pack_val; memcpy(pos, &var_field_index, sizeof(var_field_index)); pos += sizeof(var_field_index); if (is_add && !is_null_default) { uint curr_field_offset = field_offset(curr_field, src_table); uint32_t len_bytes = src_kc_info->length_bytes[curr_index]; - uint32_t data_length = get_var_data_length( - src_table->s->default_values + curr_field_offset, - len_bytes - ); + uint32_t data_length = + get_var_data_length( + src_table->s->default_values + curr_field_offset, + len_bytes); memcpy(pos, &data_length, sizeof(data_length)); pos += sizeof(data_length); memcpy( pos, src_table->s->default_values + curr_field_offset + len_bytes, - data_length - ); + data_length); pos += data_length; } - } - else { + } else { pos[0] = COL_BLOB; pos++; has_blobs = true; @@ -418,9 +431,8 @@ static uint32_t fill_dynamic_row_mutator( static uint32_t fill_static_blob_row_mutator( uchar* buf, TABLE* src_table, - KEY_AND_COL_INFO* src_kc_info - ) -{ + KEY_AND_COL_INFO* src_kc_info) { + uchar* pos = buf; // copy number of blobs memcpy(pos, &src_kc_info->num_blobs, sizeof(src_kc_info->num_blobs)); @@ -430,11 +442,11 @@ static uint32_t fill_static_blob_row_mutator( uint32_t curr_field_index = src_kc_info->blob_fields[i]; Field* field = src_table->field[curr_field_index]; uint32_t len_bytes = field->row_pack_length(); - assert(len_bytes <= 4); + assert_always(len_bytes <= 4); pos[0] = len_bytes; pos++; } - + return pos-buf; } @@ -444,9 +456,8 @@ static uint32_t fill_dynamic_blob_row_mutator( uint32_t num_columns, TABLE* src_table, KEY_AND_COL_INFO* src_kc_info, - bool is_add - ) -{ + bool is_add) { + uchar* pos = buf; for (uint32_t i = 0; i < num_columns; i++) { uint32_t curr_field_index = columns[i]; @@ -461,19 +472,19 @@ static uint32_t fill_dynamic_blob_row_mutator( } } // assert we found blob in list - assert(blob_index < src_kc_info->num_blobs); + assert_always(blob_index < src_kc_info->num_blobs); pos[0] = is_add ? COL_ADD : COL_DROP; pos++; memcpy(pos, &blob_index, sizeof(blob_index)); pos += sizeof(blob_index); if (is_add) { uint32_t len_bytes = curr_field->row_pack_length(); - assert(len_bytes <= 4); + assert_always(len_bytes <= 4); pos[0] = len_bytes; pos++; - // create a zero length blob field that can be directly copied in - // for now, in MySQL, we can only have blob fields + // create a zero length blob field that can be directly copied + // in for now, in MySQL, we can only have blob fields // that have no default value memset(pos, 0, len_bytes); pos += len_bytes; @@ -487,93 +498,86 @@ static uint32_t fill_dynamic_blob_row_mutator( // TODO: namely, when do we get stuff from share->kc_info and when we get // TODO: it from altered_kc_info, and when is keynr associated with the right thing uint32_t ha_tokudb::fill_row_mutator( - uchar* buf, - uint32_t* columns, + uchar* buf, + uint32_t* columns, uint32_t num_columns, TABLE* altered_table, KEY_AND_COL_INFO* altered_kc_info, uint32_t keynr, - bool is_add - ) -{ - if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE) { - printf("*****some info:*************\n"); - printf( - "old things: num_null_bytes %d, num_offset_bytes %d, fixed_field_size %d, fixed_field_size %d\n", + bool is_add) { + + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_ALTER_TABLE))) { + TOKUDB_HANDLER_TRACE("*****some info:*************"); + TOKUDB_HANDLER_TRACE( + "old things: num_null_bytes %d, num_offset_bytes %d, " + "fixed_field_size %d, fixed_field_size %d", table->s->null_bytes, share->kc_info.num_offset_bytes, share->kc_info.mcp_info[keynr].fixed_field_size, - share->kc_info.mcp_info[keynr].len_of_offsets - ); - printf( - "new things: num_null_bytes %d, num_offset_bytes %d, fixed_field_size %d, fixed_field_size %d\n", + share->kc_info.mcp_info[keynr].len_of_offsets); + TOKUDB_HANDLER_TRACE( + "new things: num_null_bytes %d, num_offset_bytes %d, " + "fixed_field_size %d, fixed_field_size %d", altered_table->s->null_bytes, altered_kc_info->num_offset_bytes, altered_kc_info->mcp_info[keynr].fixed_field_size, - altered_kc_info->mcp_info[keynr].len_of_offsets - ); - printf("****************************\n"); + altered_kc_info->mcp_info[keynr].len_of_offsets); + TOKUDB_HANDLER_TRACE("****************************"); } uchar* pos = buf; bool has_blobs = false; - pos += fill_static_row_mutator( - pos, - table, - altered_table, - &share->kc_info, - altered_kc_info, - keynr - ); - - if (is_add) { - pos += fill_dynamic_row_mutator( + pos += + fill_static_row_mutator( pos, - columns, - num_columns, + table, altered_table, - altered_kc_info, - keynr, - is_add, - &has_blobs - ); - } - else { - pos += fill_dynamic_row_mutator( - pos, - columns, - num_columns, - table, &share->kc_info, - keynr, - is_add, - &has_blobs - ); - } - if (has_blobs) { - pos += fill_static_blob_row_mutator( - pos, - table, - &share->kc_info - ); - if (is_add) { - pos += fill_dynamic_blob_row_mutator( + altered_kc_info, + keynr); + + if (is_add) { + pos += + fill_dynamic_row_mutator( pos, columns, num_columns, altered_table, altered_kc_info, - is_add - ); - } - else { - pos += fill_dynamic_blob_row_mutator( + keynr, + is_add, + &has_blobs); + } else { + pos += + fill_dynamic_row_mutator( pos, columns, num_columns, table, &share->kc_info, - is_add - ); + keynr, + is_add, + &has_blobs); + } + if (has_blobs) { + pos += fill_static_blob_row_mutator(pos, table, &share->kc_info); + if (is_add) { + pos += + fill_dynamic_blob_row_mutator( + pos, + columns, + num_columns, + altered_table, + altered_kc_info, + is_add); + } else { + pos += + fill_dynamic_blob_row_mutator( + pos, + columns, + num_columns, + table, + &share->kc_info, + is_add); } } return pos-buf; @@ -583,16 +587,23 @@ static bool all_fields_are_same_type(TABLE *table_a, TABLE *table_b) { if (table_a->s->fields != table_b->s->fields) return false; for (uint i = 0; i < table_a->s->fields; i++) { - Field *field_a = table_a->field[i]; - Field *field_b = table_b->field[i]; + Field* field_a = table_a->field[i]; + Field* field_b = table_b->field[i]; if (!fields_are_same_type(field_a, field_b)) return false; } return true; } -static bool column_rename_supported(TABLE* orig_table, TABLE* new_table, bool alter_column_order) __attribute__((unused)); -static bool column_rename_supported(TABLE* orig_table, TABLE* new_table, bool alter_column_order) { +TOKUDB_UNUSED(static bool column_rename_supported( + TABLE* orig_table, + TABLE* new_table, + bool alter_column_order)); +static bool column_rename_supported( + TABLE* orig_table, + TABLE* new_table, + bool alter_column_order) { + bool retval = false; bool keys_same_for_cr; uint num_fields_with_different_names = 0; @@ -622,20 +633,20 @@ static bool column_rename_supported(TABLE* orig_table, TABLE* new_table, bool al retval = false; goto cleanup; } - assert(field_with_different_name < orig_table->s->fields); + assert_always(field_with_different_name < orig_table->s->fields); // // at this point, we have verified that the two tables have - // the same field types and with ONLY one field with a different name. + // the same field types and with ONLY one field with a different name. // We have also identified the field with the different name // // Now we need to check the indexes // - keys_same_for_cr = tables_have_same_keys( - orig_table, - new_table, - false, - true - ); + keys_same_for_cr = + tables_have_same_keys( + orig_table, + new_table, + false, + true); if (!keys_same_for_cr) { retval = false; goto cleanup; @@ -645,12 +656,21 @@ cleanup: return retval; } -static int find_changed_columns(uint32_t* changed_columns, uint32_t* num_changed_columns, TABLE* smaller_table, TABLE* bigger_table) __attribute__((unused)); -static int find_changed_columns(uint32_t* changed_columns, uint32_t* num_changed_columns, TABLE* smaller_table, TABLE* bigger_table) { +TOKUDB_UNUSED(static int find_changed_columns( + uint32_t* changed_columns, + uint32_t* num_changed_columns, + TABLE* smaller_table, + TABLE* bigger_table)); +static int find_changed_columns( + uint32_t* changed_columns, + uint32_t* num_changed_columns, + TABLE* smaller_table, + TABLE* bigger_table) { + int retval; uint curr_new_col_index = 0; uint32_t curr_num_changed_columns=0; - assert(bigger_table->s->fields > smaller_table->s->fields); + assert_always(bigger_table->s->fields > smaller_table->s->fields); for (uint i = 0; i < smaller_table->s->fields; i++, curr_new_col_index++) { if (curr_new_col_index >= bigger_table->s->fields) { sql_print_error("error in determining changed columns"); @@ -670,15 +690,15 @@ static int find_changed_columns(uint32_t* changed_columns, uint32_t* num_changed goto cleanup; } } - // at this point, curr_field_in_orig and curr_field_in_new should be the same, let's verify - // make sure the two fields that have the same name are ok + // at this point, curr_field_in_orig and curr_field_in_new should be + // the same, let's verify make sure the two fields that have the same + // name are ok if (!are_two_fields_same(curr_field_in_orig, curr_field_in_new)) { sql_print_error( - "Two fields that were supposedly the same are not: \ - %s in original, %s in new", + "Two fields that were supposedly the same are not: %s in " + "original, %s in new", curr_field_in_orig->field_name, - curr_field_in_new->field_name - ); + curr_field_in_new->field_name); retval = 1; goto cleanup; } @@ -693,17 +713,23 @@ cleanup: return retval; } -static bool tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_table, bool print_error) __attribute__((unused)); -static bool tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_table, bool print_error) { +TOKUDB_UNUSED(static bool tables_have_same_keys_and_columns( + TABLE* first_table, + TABLE* second_table, + bool print_error)); +static bool tables_have_same_keys_and_columns( + TABLE* first_table, + TABLE* second_table, + bool print_error) { + bool retval; if (first_table->s->null_bytes != second_table->s->null_bytes) { retval = false; if (print_error) { sql_print_error( - "tables have different number of null bytes, %d, %d", - first_table->s->null_bytes, - second_table->s->null_bytes - ); + "tables have different number of null bytes, %d, %d", + first_table->s->null_bytes, + second_table->s->null_bytes); } goto exit; } @@ -711,10 +737,9 @@ static bool tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_ retval = false; if (print_error) { sql_print_error( - "tables have different number of fields, %d, %d", - first_table->s->fields, - second_table->s->fields - ); + "tables have different number of fields, %d, %d", + first_table->s->fields, + second_table->s->fields); } goto exit; } @@ -724,9 +749,8 @@ static bool tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_ if (!are_two_fields_same(a,b)) { retval = false; sql_print_error( - "tables have different fields at position %d", - i - ); + "tables have different fields at position %d", + i); goto exit; } } @@ -741,21 +765,29 @@ exit: } #if TOKU_INCLUDE_WRITE_FRM_DATA -// write the new frm data to the status dictionary using the alter table transaction -int ha_tokudb::write_frm_data(const uchar *frm_data, size_t frm_len) { +// write the new frm data to the status dictionary using the alter table +// transaction +int ha_tokudb::write_frm_data(const uchar* frm_data, size_t frm_len) { TOKUDB_DBUG_ENTER("write_frm_data"); int error = 0; if (TOKU_PARTITION_WRITE_FRM_DATA || table->part_info == NULL) { // write frmdata to status - THD *thd = ha_thd(); - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); - assert(trx); - DB_TXN *txn = trx->stmt; // use alter table transaction - assert(txn); - error = write_to_status(share->status_block, hatoku_frm_data, (void *)frm_data, (uint)frm_len, txn); + THD* thd = ha_thd(); + tokudb_trx_data* trx = + (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); + assert_always(trx); + DB_TXN* txn = trx->stmt; // use alter table transaction + assert_always(txn); + error = + write_to_status( + share->status_block, + hatoku_frm_data, + (void*)frm_data, + (uint)frm_len, + txn); } - + TOKUDB_DBUG_RETURN(error); } #endif diff --git a/storage/tokudb/ha_tokudb_update.cc b/storage/tokudb/ha_tokudb_update.cc index 1e2d6c0cdbf..23de81f3d8a 100644 --- a/storage/tokudb/ha_tokudb_update.cc +++ b/storage/tokudb/ha_tokudb_update.cc @@ -53,14 +53,19 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. // Replace field_offset // Debug function to dump an Item -static void dump_item(Item *item) { +static void dump_item(Item* item) { fprintf(stderr, "%u", item->type()); switch (item->type()) { case Item::FUNC_ITEM: { - Item_func *func = static_cast(item); + Item_func* func = static_cast(item); uint n = func->argument_count(); - Item **arguments = func->arguments(); - fprintf(stderr, ":func=%u,%s,%u(", func->functype(), func->func_name(), n); + Item** arguments = func->arguments(); + fprintf( + stderr, + ":func=%u,%s,%u(", + func->functype(), + func->func_name(), + n); for (uint i = 0; i < n ; i++) { dump_item(arguments[i]); if (i < n-1) @@ -70,25 +75,30 @@ static void dump_item(Item *item) { break; } case Item::INT_ITEM: { - Item_int *int_item = static_cast(item); + Item_int* int_item = static_cast(item); fprintf(stderr, ":int=%lld", int_item->val_int()); break; } case Item::STRING_ITEM: { - Item_string *str_item = static_cast(item); + Item_string* str_item = static_cast(item); fprintf(stderr, ":str=%s", str_item->val_str(NULL)->c_ptr()); break; } case Item::FIELD_ITEM: { - Item_field *field_item = static_cast(item); - fprintf(stderr, ":field=%s.%s.%s", field_item->db_name, field_item->table_name, field_item->field_name); + Item_field* field_item = static_cast(item); + fprintf( + stderr, + ":field=%s.%s.%s", + field_item->db_name, + field_item->table_name, + field_item->field_name); break; } case Item::COND_ITEM: { - Item_cond *cond_item = static_cast(item); + Item_cond* cond_item = static_cast(item); fprintf(stderr, ":cond=%s(\n", cond_item->func_name()); List_iterator li(*cond_item->argument_list()); - Item *list_item; + Item* list_item; while ((list_item = li++)) { dump_item(list_item); fprintf(stderr, "\n"); @@ -97,7 +107,7 @@ static void dump_item(Item *item) { break; } case Item::INSERT_VALUE_ITEM: { - Item_insert_value *value_item = static_cast(item); + Item_insert_value* value_item = static_cast(item); fprintf(stderr, ":insert_value"); dump_item(value_item->arg); break; @@ -109,10 +119,10 @@ static void dump_item(Item *item) { } // Debug function to dump an Item list -static void dump_item_list(const char *h, List &l) { +static void dump_item_list(const char* h, List &l) { fprintf(stderr, "%s elements=%u\n", h, l.elements); List_iterator li(l); - Item *item; + Item* item; while ((item = li++) != NULL) { dump_item(item); fprintf(stderr, "\n"); @@ -120,10 +130,10 @@ static void dump_item_list(const char *h, List &l) { } // Find a Field by its Item name -static Field *find_field_by_name(TABLE *table, Item *item) { +static Field* find_field_by_name(TABLE* table, Item* item) { if (item->type() != Item::FIELD_ITEM) return NULL; - Item_field *field_item = static_cast(item); + Item_field* field_item = static_cast(item); #if 0 if (strcmp(table->s->db.str, field_item->db_name) != 0 || strcmp(table->s->table_name.str, field_item->table_name) != 0) @@ -146,7 +156,12 @@ static Field *find_field_by_name(TABLE *table, Item *item) { // Return the starting offset in the value for a particular index (selected by idx) of a // particular field (selected by expand_field_num). // This only works for fixed length fields -static uint32_t fixed_field_offset(uint32_t null_bytes, KEY_AND_COL_INFO *kc_info, uint idx, uint expand_field_num) { +static uint32_t fixed_field_offset( + uint32_t null_bytes, + KEY_AND_COL_INFO* kc_info, + uint idx, + uint expand_field_num) { + uint32_t offset = null_bytes; for (uint i = 0; i < expand_field_num; i++) { if (bitmap_is_set(&kc_info->key_filters[idx], i)) @@ -156,8 +171,13 @@ static uint32_t fixed_field_offset(uint32_t null_bytes, KEY_AND_COL_INFO *kc_inf return offset; } -static uint32_t var_field_index(TABLE *table, KEY_AND_COL_INFO *kc_info, uint idx, uint field_num) { - assert(field_num < table->s->fields); +static uint32_t var_field_index( + TABLE* table, + KEY_AND_COL_INFO* kc_info, + uint idx, + uint field_num) { + + assert_always(field_num < table->s->fields); uint v_index = 0; for (uint i = 0; i < table->s->fields; i++) { if (bitmap_is_set(&kc_info->key_filters[idx], i)) @@ -171,26 +191,37 @@ static uint32_t var_field_index(TABLE *table, KEY_AND_COL_INFO *kc_info, uint id return v_index; } -static uint32_t blob_field_index(TABLE *table, KEY_AND_COL_INFO *kc_info, uint idx, uint field_num) { - assert(field_num < table->s->fields); +static uint32_t blob_field_index( + TABLE* table, + KEY_AND_COL_INFO* kc_info, + uint idx, + uint field_num) { + + assert_always(field_num < table->s->fields); uint b_index; for (b_index = 0; b_index < kc_info->num_blobs; b_index++) { if (kc_info->blob_fields[b_index] == field_num) break; } - assert(b_index < kc_info->num_blobs); + assert_always(b_index < kc_info->num_blobs); return b_index; } // Determine if an update operation can be offloaded to the storage engine. -// The update operation consists of a list of update expressions (fields[i] = values[i]), and a list -// of where conditions (conds). The function returns 0 if the update is handled in the storage engine. +// The update operation consists of a list of update expressions +// (fields[i] = values[i]), and a list of where conditions (conds). +// The function returns 0 if the update is handled in the storage engine. // Otherwise, an error is returned. -int ha_tokudb::fast_update(THD *thd, List &update_fields, List &update_values, Item *conds) { +int ha_tokudb::fast_update( + THD* thd, + List& update_fields, + List& update_values, + Item* conds) { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = 0; - if (tokudb_debug & TOKUDB_DEBUG_UPSERT) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_UPSERT))) { dump_item_list("fields", update_fields); dump_item_list("values", update_values); if (conds) { @@ -198,7 +229,8 @@ int ha_tokudb::fast_update(THD *thd, List &update_fields, List &upda } } - if (update_fields.elements < 1 || update_fields.elements != update_values.elements) { + if (update_fields.elements < 1 || + update_fields.elements != update_values.elements) { error = ENOTSUP; // something is fishy with the parameters goto return_error; } @@ -208,14 +240,18 @@ int ha_tokudb::fast_update(THD *thd, List &update_fields, List &upda goto check_error; } - error = send_update_message(update_fields, update_values, conds, transaction); + error = send_update_message( + update_fields, + update_values, + conds, + transaction); if (error != 0) { goto check_error; } check_error: if (error != 0) { - if (THDVAR(thd, disable_slow_update) != 0) + if (tokudb::sysvars::disable_slow_update(thd) != 0) error = HA_ERR_UNSUPPORTED; if (error != ENOTSUP) print_error(error, MYF(0)); @@ -225,18 +261,20 @@ return_error: TOKUDB_HANDLER_DBUG_RETURN(error); } -// Return true if an expression is a simple int expression or a simple function of +- int expression. -static bool check_int_result(Item *item) { +// Return true if an expression is a simple int expression or a simple function +// of +- int expression. +static bool check_int_result(Item* item) { Item::Type t = item->type(); if (t == Item::INT_ITEM) { return true; } else if (t == Item::FUNC_ITEM) { - Item_func *item_func = static_cast(item); - if (strcmp(item_func->func_name(), "+") != 0 && strcmp(item_func->func_name(), "-") != 0) + Item_func* item_func = static_cast(item); + if (strcmp(item_func->func_name(), "+") != 0 && + strcmp(item_func->func_name(), "-") != 0) return false; if (item_func->argument_count() != 1) return false; - Item **arguments = item_func->arguments(); + Item** arguments = item_func->arguments(); if (arguments[0]->type() != Item::INT_ITEM) return false; return true; @@ -245,36 +283,43 @@ static bool check_int_result(Item *item) { } // check that an item is an insert value item with the same field name -static bool check_insert_value(Item *item, const char *field_name) { +static bool check_insert_value(Item* item, const char* field_name) { if (item->type() != Item::INSERT_VALUE_ITEM) return false; - Item_insert_value *value_item = static_cast(item); + Item_insert_value* value_item = static_cast(item); if (value_item->arg->type() != Item::FIELD_ITEM) return false; - Item_field *arg = static_cast(value_item->arg); + Item_field* arg = static_cast(value_item->arg); if (strcmp(field_name, arg->field_name) != 0) return false; return true; } // Return true if an expression looks like field_name op constant. -static bool check_x_op_constant(const char *field_name, Item *item, const char *op, Item **item_constant, bool allow_insert_value) { +static bool check_x_op_constant( + const char* field_name, + Item* item, + const char* op, + Item** item_constant, + bool allow_insert_value) { + if (item->type() != Item::FUNC_ITEM) return false; - Item_func *item_func = static_cast(item); + Item_func* item_func = static_cast(item); if (strcmp(item_func->func_name(), op) != 0) return false; - Item **arguments = item_func->arguments(); + Item** arguments = item_func->arguments(); uint n = item_func->argument_count(); if (n != 2) return false; if (arguments[0]->type() != Item::FIELD_ITEM) return false; - Item_field *arg0 = static_cast(arguments[0]); + Item_field* arg0 = static_cast(arguments[0]); if (strcmp(field_name, arg0->field_name) != 0) return false; if (!check_int_result(arguments[1])) - if (!(allow_insert_value && check_insert_value(arguments[1], field_name))) + if (!(allow_insert_value && + check_insert_value(arguments[1], field_name))) return false; *item_constant = arguments[1]; return true; @@ -282,33 +327,35 @@ static bool check_x_op_constant(const char *field_name, Item *item, const char * // Return true if an expression looks like field_name = constant static bool check_x_equal_0(const char *field_name, Item *item) { - Item *item_constant; + Item* item_constant; if (!check_x_op_constant(field_name, item, "=", &item_constant, false)) return false; - if (item_constant->type() != Item::INT_ITEM || item_constant->val_int() != 0) + if (item_constant->type() != Item::INT_ITEM || + item_constant->val_int() != 0) return false; return true; } // Return true if an expression looks like fieldname - 1 -static bool check_x_minus_1(const char *field_name, Item *item) { - Item *item_constant; +static bool check_x_minus_1(const char* field_name, Item* item) { + Item* item_constant; if (!check_x_op_constant(field_name, item, "-", &item_constant, false)) return false; - if (item_constant->type() != Item::INT_ITEM || item_constant->val_int() != 1) + if (item_constant->type() != Item::INT_ITEM || + item_constant->val_int() != 1) return false; return true; } // Return true if an expression looks like if(fieldname=0, 0, fieldname-1) and // the field named by fieldname is an unsigned int. -static bool check_decr_floor_expression(Field *lhs_field, Item *item) { +static bool check_decr_floor_expression(Field* lhs_field, Item* item) { if (item->type() != Item::FUNC_ITEM) return false; - Item_func *item_func = static_cast(item); + Item_func* item_func = static_cast(item); if (strcmp(item_func->func_name(), "if") != 0) return false; - Item **arguments = item_func->arguments(); + Item** arguments = item_func->arguments(); uint n = item_func->argument_count(); if (n != 3) return false; @@ -324,8 +371,13 @@ static bool check_decr_floor_expression(Field *lhs_field, Item *item) { } // Check if lhs = rhs expression is simple. Return true if it is. -static bool check_update_expression(Item *lhs_item, Item *rhs_item, TABLE *table, bool allow_insert_value) { - Field *lhs_field = find_field_by_name(table, lhs_item); +static bool check_update_expression( + Item* lhs_item, + Item* rhs_item, + TABLE* table, + bool allow_insert_value) { + + Field* lhs_field = find_field_by_name(table, lhs_item); if (lhs_field == NULL) return false; if (!lhs_field->part_of_key.is_clear_all()) @@ -340,16 +392,26 @@ static bool check_update_expression(Item *lhs_item, Item *rhs_item, TABLE *table case MYSQL_TYPE_LONGLONG: if (check_int_result(rhs_item)) return true; - Item *item_constant; - if (check_x_op_constant(lhs_field->field_name, rhs_item, "+", &item_constant, allow_insert_value)) + Item* item_constant; + if (check_x_op_constant( + lhs_field->field_name, + rhs_item, + "+", + &item_constant, + allow_insert_value)) return true; - if (check_x_op_constant(lhs_field->field_name, rhs_item, "-", &item_constant, allow_insert_value)) + if (check_x_op_constant( + lhs_field->field_name, + rhs_item, + "-", + &item_constant, + allow_insert_value)) return true; if (check_decr_floor_expression(lhs_field, rhs_item)) return true; break; case MYSQL_TYPE_STRING: - if (rhs_type == Item::INT_ITEM || rhs_type == Item::STRING_ITEM) + if (rhs_type == Item::INT_ITEM || rhs_type == Item::STRING_ITEM) return true; break; case MYSQL_TYPE_VARCHAR: @@ -364,26 +426,35 @@ static bool check_update_expression(Item *lhs_item, Item *rhs_item, TABLE *table } // Check that all update expressions are simple. Return true if they are. -static bool check_all_update_expressions(List &fields, List &values, TABLE *table, bool allow_insert_value) { +static bool check_all_update_expressions( + List& fields, + List& values, + TABLE* table, + bool allow_insert_value) { + List_iterator lhs_i(fields); List_iterator rhs_i(values); while (1) { - Item *lhs_item = lhs_i++; + Item* lhs_item = lhs_i++; if (lhs_item == NULL) break; - Item *rhs_item = rhs_i++; - assert(rhs_item != NULL); - if (!check_update_expression(lhs_item, rhs_item, table, allow_insert_value)) + Item* rhs_item = rhs_i++; + assert_always(rhs_item != NULL); + if (!check_update_expression( + lhs_item, + rhs_item, + table, + allow_insert_value)) return false; } return true; } -static bool full_field_in_key(TABLE *table, Field *field) { - assert(table->s->primary_key < table->s->keys); - KEY *key = &table->s->key_info[table->s->primary_key]; - for (uint i = 0; i < get_key_parts(key); i++) { - KEY_PART_INFO *key_part = &key->key_part[i]; +static bool full_field_in_key(TABLE* table, Field* field) { + assert_always(table->s->primary_key < table->s->keys); + KEY* key = &table->s->key_info[table->s->primary_key]; + for (uint i = 0; i < key->user_defined_key_parts; i++) { + KEY_PART_INFO* key_part = &key->key_part[i]; if (strcmp(field->field_name, key_part->field->field_name) == 0) { return key_part->length == field->field_length; } @@ -391,19 +462,24 @@ static bool full_field_in_key(TABLE *table, Field *field) { return false; } -// Check that an expression looks like fieldname = constant, fieldname is part of the -// primary key, and the named field is an int, char or varchar type. Return true if it does. -static bool check_pk_field_equal_constant(Item *item, TABLE *table, MY_BITMAP *pk_fields) { +// Check that an expression looks like fieldname = constant, fieldname is part +// of the primary key, and the named field is an int, char or varchar type. +// Return true if it does. +static bool check_pk_field_equal_constant( + Item* item, + TABLE* table, + MY_BITMAP* pk_fields) { + if (item->type() != Item::FUNC_ITEM) return false; - Item_func *func = static_cast(item); + Item_func* func = static_cast(item); if (strcmp(func->func_name(), "=") != 0) return false; uint n = func->argument_count(); if (n != 2) return false; - Item **arguments = func->arguments(); - Field *field = find_field_by_name(table, arguments[0]); + Item** arguments = func->arguments(); + Field* field = find_field_by_name(table, arguments[0]); if (field == NULL) return false; if (!bitmap_test_and_clear(pk_fields, field->field_index)) @@ -414,19 +490,21 @@ static bool check_pk_field_equal_constant(Item *item, TABLE *table, MY_BITMAP *p case MYSQL_TYPE_INT24: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: - return arguments[1]->type() == Item::INT_ITEM || arguments[1]->type() == Item::STRING_ITEM; + return arguments[1]->type() == Item::INT_ITEM || + arguments[1]->type() == Item::STRING_ITEM; case MYSQL_TYPE_STRING: case MYSQL_TYPE_VARCHAR: return full_field_in_key(table, field) && - (arguments[1]->type() == Item::INT_ITEM || arguments[1]->type() == Item::STRING_ITEM); + (arguments[1]->type() == Item::INT_ITEM || + arguments[1]->type() == Item::STRING_ITEM); default: return false; } } -// Check that the where condition covers all of the primary key components with fieldname = constant -// expressions. Return true if it does. -static bool check_point_update(Item *conds, TABLE *table) { +// Check that the where condition covers all of the primary key components +// with fieldname = constant expressions. Return true if it does. +static bool check_point_update(Item* conds, TABLE* table) { bool result = false; if (conds == NULL) @@ -435,13 +513,13 @@ static bool check_point_update(Item *conds, TABLE *table) { if (table->s->primary_key >= table->s->keys) return false; // no primary key defined - // use a bitmap of the primary key fields to keep track of those fields that are covered - // by the where conditions + // use a bitmap of the primary key fields to keep track of those fields + // that are covered by the where conditions MY_BITMAP pk_fields; if (bitmap_init(&pk_fields, NULL, table->s->fields, FALSE)) // 1 -> failure return false; KEY *key = &table->s->key_info[table->s->primary_key]; - for (uint i = 0; i < get_key_parts(key); i++) + for (uint i = 0; i < key->user_defined_key_parts; i++) bitmap_set_bit(&pk_fields, key->key_part[i].field->field_index); switch (conds->type()) { @@ -449,14 +527,17 @@ static bool check_point_update(Item *conds, TABLE *table) { result = check_pk_field_equal_constant(conds, table, &pk_fields); break; case Item::COND_ITEM: { - Item_cond *cond_item = static_cast(conds); + Item_cond* cond_item = static_cast(conds); if (strcmp(cond_item->func_name(), "and") != 0) break; List_iterator li(*cond_item->argument_list()); - Item *list_item; + Item* list_item; result = true; while (result == true && (list_item = li++)) { - result = check_pk_field_equal_constant(list_item, table, &pk_fields); + result = check_pk_field_equal_constant( + list_item, + table, + &pk_fields); } break; } @@ -474,13 +555,14 @@ static bool check_point_update(Item *conds, TABLE *table) { // Precompute this when the table is opened. static bool clustering_keys_exist(TABLE *table) { for (uint keynr = 0; keynr < table->s->keys; keynr++) { - if (keynr != table->s->primary_key && key_is_clustering(&table->s->key_info[keynr])) + if (keynr != table->s->primary_key && + key_is_clustering(&table->s->key_info[keynr])) return true; } return false; } -static bool is_strict_mode(THD *thd) { +static bool is_strict_mode(THD* thd) { #if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699 return thd->is_strict_mode(); #else @@ -488,8 +570,14 @@ static bool is_strict_mode(THD *thd) { #endif } -// Check if an update operation can be handled by this storage engine. Return true if it can. -bool ha_tokudb::check_fast_update(THD *thd, List &fields, List &values, Item *conds) { +// Check if an update operation can be handled by this storage engine. +// Return true if it can. +bool ha_tokudb::check_fast_update( + THD* thd, + List& fields, + List& values, + Item* conds) { + if (!transaction) return false; @@ -503,10 +591,12 @@ bool ha_tokudb::check_fast_update(THD *thd, List &fields, List &valu // no binlog if (mysql_bin_log.is_open() && - !(thd->variables.binlog_format == BINLOG_FORMAT_STMT || thd->variables.binlog_format == BINLOG_FORMAT_MIXED)) + !(thd->variables.binlog_format == BINLOG_FORMAT_STMT || + thd->variables.binlog_format == BINLOG_FORMAT_MIXED)) return false; - // no clustering keys (need to broadcast an increment into the clustering keys since we are selecting with the primary key) + // no clustering keys (need to broadcast an increment into the clustering + // keys since we are selecting with the primary key) if (clustering_keys_exist(table)) return false; @@ -519,22 +609,34 @@ bool ha_tokudb::check_fast_update(THD *thd, List &fields, List &valu return true; } -static void marshall_varchar_descriptor(tokudb::buffer &b, TABLE *table, KEY_AND_COL_INFO *kc_info, uint key_num) { +static void marshall_varchar_descriptor( + tokudb::buffer& b, + TABLE* table, + KEY_AND_COL_INFO* kc_info, + uint key_num) { + b.append_ui('v'); - b.append_ui(table->s->null_bytes + kc_info->mcp_info[key_num].fixed_field_size); + b.append_ui( + table->s->null_bytes + kc_info->mcp_info[key_num].fixed_field_size); uint32_t var_offset_bytes = kc_info->mcp_info[key_num].len_of_offsets; b.append_ui(var_offset_bytes); - b.append_ui(var_offset_bytes == 0 ? 0 : kc_info->num_offset_bytes); + b.append_ui( + var_offset_bytes == 0 ? 0 : kc_info->num_offset_bytes); } -static void marshall_blobs_descriptor(tokudb::buffer &b, TABLE *table, KEY_AND_COL_INFO *kc_info) { +static void marshall_blobs_descriptor( + tokudb::buffer& b, + TABLE* table, + KEY_AND_COL_INFO* kc_info) { + b.append_ui('b'); uint32_t n = kc_info->num_blobs; b.append_ui(n); for (uint i = 0; i < n; i++) { uint blob_field_index = kc_info->blob_fields[i]; - assert(blob_field_index < table->s->fields); - uint8_t blob_field_length = table->s->field[blob_field_index]->row_pack_length(); + assert_always(blob_field_index < table->s->fields); + uint8_t blob_field_length = + table->s->field[blob_field_index]->row_pack_length(); b.append(&blob_field_length, sizeof blob_field_length); } } @@ -542,30 +644,37 @@ static void marshall_blobs_descriptor(tokudb::buffer &b, TABLE *table, KEY_AND_C static inline uint32_t get_null_bit_position(uint32_t null_bit); // evaluate the int value of an item -static longlong item_val_int(Item *item) { +static longlong item_val_int(Item* item) { Item::Type t = item->type(); if (t == Item::INSERT_VALUE_ITEM) { - Item_insert_value *value_item = static_cast(item); + Item_insert_value* value_item = static_cast(item); return value_item->arg->val_int(); } else return item->val_int(); } // Marshall update operations to a buffer. -static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, TABLE *table, TOKUDB_SHARE *share) { +static void marshall_update( + tokudb::buffer& b, + Item* lhs_item, + Item* rhs_item, + TABLE* table, + TOKUDB_SHARE* share) { + // figure out the update operation type (again) - Field *lhs_field = find_field_by_name(table, lhs_item); - assert(lhs_field); // we found it before, so this should work + Field* lhs_field = find_field_by_name(table, lhs_item); + assert_always(lhs_field); // we found it before, so this should work // compute the update info uint32_t field_type; uint32_t field_null_num = 0; if (lhs_field->real_maybe_null()) { uint32_t field_num = lhs_field->field_index; - field_null_num = ((field_num/8)*8 + get_null_bit_position(lhs_field->null_bit)) + 1; + field_null_num = + ((field_num/8)*8 + get_null_bit_position(lhs_field->null_bit)) + 1; } uint32_t offset; - void *v_ptr = NULL; + void* v_ptr = NULL; uint32_t v_length; uint32_t update_operation; longlong v_ll; @@ -577,9 +686,14 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T case MYSQL_TYPE_INT24: case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONGLONG: { - Field_num *lhs_num = static_cast(lhs_field); + Field_num* lhs_num = static_cast(lhs_field); field_type = lhs_num->unsigned_flag ? UPDATE_TYPE_UINT : UPDATE_TYPE_INT; - offset = fixed_field_offset(table->s->null_bytes, &share->kc_info, table->s->primary_key, lhs_field->field_index); + offset = + fixed_field_offset( + table->s->null_bytes, + &share->kc_info, + table->s->primary_key, + lhs_field->field_index); switch (rhs_item->type()) { case Item::INT_ITEM: { update_operation = '='; @@ -589,10 +703,12 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T break; } case Item::FUNC_ITEM: { - Item_func *rhs_func = static_cast(rhs_item); - Item **arguments = rhs_func->arguments(); + Item_func* rhs_func = static_cast(rhs_item); + Item** arguments = rhs_func->arguments(); + // we only support one if function for now, and it is a + // decrement with floor. if (strcmp(rhs_func->func_name(), "if") == 0) { - update_operation = '-'; // we only support one if function for now, and it is a decrement with floor. + update_operation = '-'; v_ll = 1; } else if (rhs_func->argument_count() == 1) { update_operation = '='; @@ -606,14 +722,20 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T break; } default: - assert(0); + assert_unreachable(); } break; } case MYSQL_TYPE_STRING: { update_operation = '='; - field_type = lhs_field->binary() ? UPDATE_TYPE_BINARY : UPDATE_TYPE_CHAR; - offset = fixed_field_offset(table->s->null_bytes, &share->kc_info, table->s->primary_key, lhs_field->field_index); + field_type = + lhs_field->binary() ? UPDATE_TYPE_BINARY : UPDATE_TYPE_CHAR; + offset = + fixed_field_offset( + table->s->null_bytes, + &share->kc_info, + table->s->primary_key, + lhs_field->field_index); v_str = *rhs_item->val_str(&v_str); v_length = v_str.length(); if (v_length >= lhs_field->pack_length()) { @@ -621,7 +743,8 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T v_str.length(v_length); // truncate } else { v_length = lhs_field->pack_length(); - uchar pad_char = lhs_field->binary() ? 0 : lhs_field->charset()->pad_char; + uchar pad_char = + lhs_field->binary() ? 0 : lhs_field->charset()->pad_char; v_str.fill(lhs_field->pack_length(), pad_char); // pad } v_ptr = v_str.c_ptr(); @@ -629,8 +752,14 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T } case MYSQL_TYPE_VARCHAR: { update_operation = '='; - field_type = lhs_field->binary() ? UPDATE_TYPE_VARBINARY : UPDATE_TYPE_VARCHAR; - offset = var_field_index(table, &share->kc_info, table->s->primary_key, lhs_field->field_index); + field_type = + lhs_field->binary() ? UPDATE_TYPE_VARBINARY : UPDATE_TYPE_VARCHAR; + offset = + var_field_index( + table, + &share->kc_info, + table->s->primary_key, + lhs_field->field_index); v_str = *rhs_item->val_str(&v_str); v_length = v_str.length(); if (v_length >= lhs_field->row_pack_length()) { @@ -643,7 +772,12 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T case MYSQL_TYPE_BLOB: { update_operation = '='; field_type = lhs_field->binary() ? UPDATE_TYPE_BLOB : UPDATE_TYPE_TEXT; - offset = blob_field_index(table, &share->kc_info, table->s->primary_key, lhs_field->field_index); + offset = + blob_field_index( + table, + &share->kc_info, + table->s->primary_key, + lhs_field->field_index); v_str = *rhs_item->val_str(&v_str); v_length = v_str.length(); if (v_length >= lhs_field->max_data_length()) { @@ -654,7 +788,7 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T break; } default: - assert(0); + assert_unreachable(); } // marshall the update fields into the buffer @@ -667,14 +801,14 @@ static void marshall_update(tokudb::buffer &b, Item *lhs_item, Item *rhs_item, T } // Save an item's value into the appropriate field. Return 0 if successful. -static int save_in_field(Item *item, TABLE *table) { - assert(item->type() == Item::FUNC_ITEM); +static int save_in_field(Item* item, TABLE* table) { + assert_always(item->type() == Item::FUNC_ITEM); Item_func *func = static_cast(item); - assert(strcmp(func->func_name(), "=") == 0); + assert_always(strcmp(func->func_name(), "=") == 0); uint n = func->argument_count(); - assert(n == 2); + assert_always(n == 2); Item **arguments = func->arguments(); - assert(arguments[0]->type() == Item::FIELD_ITEM); + assert_always(arguments[0]->type() == Item::FIELD_ITEM); Item_field *field_item = static_cast(arguments[0]); my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->write_set); int error = arguments[1]->save_in_field(field_item->field, 0); @@ -682,7 +816,11 @@ static int save_in_field(Item *item, TABLE *table) { return error; } -static void count_update_types(Field *lhs_field, uint *num_varchars, uint *num_blobs) { +static void count_update_types( + Field* lhs_field, + uint* num_varchars, + uint* num_blobs) { + switch (lhs_field->type()) { case MYSQL_TYPE_VARCHAR: *num_varchars += 1; @@ -695,8 +833,14 @@ static void count_update_types(Field *lhs_field, uint *num_varchars, uint *num_b } } -// Generate an update message for an update operation and send it into the primary tree. Return 0 if successful. -int ha_tokudb::send_update_message(List &update_fields, List &update_values, Item *conds, DB_TXN *txn) { +// Generate an update message for an update operation and send it into the +// primary tree. Return 0 if successful. +int ha_tokudb::send_update_message( + List& update_fields, + List& update_values, + Item* conds, + DB_TXN* txn) { + int error; // Save the primary key from the where conditions @@ -704,26 +848,32 @@ int ha_tokudb::send_update_message(List &update_fields, List &update if (t == Item::FUNC_ITEM) { error = save_in_field(conds, table); } else if (t == Item::COND_ITEM) { - Item_cond *cond_item = static_cast(conds); + Item_cond* cond_item = static_cast(conds); List_iterator li(*cond_item->argument_list()); - Item *list_item; + Item* list_item; error = 0; while (error == 0 && (list_item = li++)) { error = save_in_field(list_item, table); } - } else - assert(0); + } else { + assert_unreachable(); + } if (error) return error; // put the primary key into key_buff and wrap it with key_dbt DBT key_dbt; bool has_null; - create_dbt_key_from_table(&key_dbt, primary_key, key_buff, table->record[0], &has_null); - + create_dbt_key_from_table( + &key_dbt, + primary_key, + key_buff, + table->record[0], + &has_null); + // construct the update message tokudb::buffer update_message; - + uint8_t op = UPDATE_OP_UPDATE_2; update_message.append(&op, sizeof op); @@ -731,12 +881,12 @@ int ha_tokudb::send_update_message(List &update_fields, List &update uint num_varchars = 0, num_blobs = 0; if (1) { List_iterator lhs_i(update_fields); - Item *lhs_item; + Item* lhs_item; while ((lhs_item = lhs_i++)) { if (lhs_item == NULL) break; - Field *lhs_field = find_field_by_name(table, lhs_item); - assert(lhs_field); // we found it before, so this should work + Field* lhs_field = find_field_by_name(table, lhs_item); + assert_always(lhs_field); // we found it before, so this should work count_update_types(lhs_field, &num_varchars, &num_blobs); } if (num_varchars > 0 || num_blobs > 0) @@ -747,56 +897,75 @@ int ha_tokudb::send_update_message(List &update_fields, List &update // append the updates update_message.append_ui(num_updates); - + if (num_varchars > 0 || num_blobs > 0) - marshall_varchar_descriptor(update_message, table, &share->kc_info, table->s->primary_key); + marshall_varchar_descriptor( + update_message, + table, + &share->kc_info, + table->s->primary_key); if (num_blobs > 0) marshall_blobs_descriptor(update_message, table, &share->kc_info); List_iterator lhs_i(update_fields); List_iterator rhs_i(update_values); while (error == 0) { - Item *lhs_item = lhs_i++; + Item* lhs_item = lhs_i++; if (lhs_item == NULL) break; - Item *rhs_item = rhs_i++; - assert(rhs_item != NULL); + Item* rhs_item = rhs_i++; + assert_always(rhs_item != NULL); marshall_update(update_message, lhs_item, rhs_item, table, share); } - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); - if (share->num_DBs > table->s->keys + tokudb_test(hidden_primary_key)) { // hot index in progress + // hot index in progress + if (share->num_DBs > table->s->keys + tokudb_test(hidden_primary_key)) { error = ENOTSUP; // run on the slow path } else { - // send the update message + // send the update message DBT update_dbt; memset(&update_dbt, 0, sizeof update_dbt); update_dbt.data = update_message.data(); update_dbt.size = update_message.size(); - error = share->key_file[primary_key]->update(share->key_file[primary_key], txn, &key_dbt, &update_dbt, 0); + error = + share->key_file[primary_key]->update( + share->key_file[primary_key], + txn, + &key_dbt, + &update_dbt, + 0); } - rw_unlock(&share->num_DBs_lock); - + share->_num_DBs_lock.unlock(); + return error; } // Determine if an upsert operation can be offloaded to the storage engine. -// An upsert consists of a row and a list of update expressions (update_fields[i] = update_values[i]). -// The function returns 0 if the upsert is handled in the storage engine. Otherwise, an error code is returned. -int ha_tokudb::upsert(THD *thd, List &update_fields, List &update_values) { +// An upsert consists of a row and a list of update expressions +// (update_fields[i] = update_values[i]). +// The function returns 0 if the upsert is handled in the storage engine. +// Otherwise, an error code is returned. +int ha_tokudb::upsert( + THD* thd, + List& update_fields, + List& update_values) { + TOKUDB_HANDLER_DBUG_ENTER(""); int error = 0; - if (tokudb_debug & TOKUDB_DEBUG_UPSERT) { + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(TOKUDB_DEBUG_UPSERT))) { fprintf(stderr, "upsert\n"); dump_item_list("update_fields", update_fields); dump_item_list("update_values", update_values); } - if (update_fields.elements < 1 || update_fields.elements != update_values.elements) { - error = ENOTSUP; // not an upsert or something is fishy with the parameters + // not an upsert or something is fishy with the parameters + if (update_fields.elements < 1 || + update_fields.elements != update_values.elements) { + error = ENOTSUP; goto return_error; } @@ -812,7 +981,7 @@ int ha_tokudb::upsert(THD *thd, List &update_fields, List &update_va check_error: if (error != 0) { - if (THDVAR(thd, disable_slow_upsert) != 0) + if (tokudb::sysvars::disable_slow_upsert(thd) != 0) error = HA_ERR_UNSUPPORTED; if (error != ENOTSUP) print_error(error, MYF(0)); @@ -822,8 +991,13 @@ return_error: TOKUDB_HANDLER_DBUG_RETURN(error); } -// Check if an upsert can be handled by this storage engine. Return trus if it can. -bool ha_tokudb::check_upsert(THD *thd, List &update_fields, List &update_values) { +// Check if an upsert can be handled by this storage engine. +// Return true if it can. +bool ha_tokudb::check_upsert( + THD* thd, + List& update_fields, + List& update_values) { + if (!transaction) return false; @@ -845,23 +1019,38 @@ bool ha_tokudb::check_upsert(THD *thd, List &update_fields, List &up // no binlog if (mysql_bin_log.is_open() && - !(thd->variables.binlog_format == BINLOG_FORMAT_STMT || thd->variables.binlog_format == BINLOG_FORMAT_MIXED)) + !(thd->variables.binlog_format == BINLOG_FORMAT_STMT || + thd->variables.binlog_format == BINLOG_FORMAT_MIXED)) return false; - if (!check_all_update_expressions(update_fields, update_values, table, true)) + if (!check_all_update_expressions( + update_fields, + update_values, + table, + true)) return false; return true; } -// Generate an upsert message and send it into the primary tree. Return 0 if successful. -int ha_tokudb::send_upsert_message(THD *thd, List &update_fields, List &update_values, DB_TXN *txn) { +// Generate an upsert message and send it into the primary tree. +// Return 0 if successful. +int ha_tokudb::send_upsert_message( + THD* thd, + List& update_fields, + List& update_values, + DB_TXN* txn) { int error = 0; // generate primary key DBT key_dbt; bool has_null; - create_dbt_key_from_table(&key_dbt, primary_key, primary_key_buff, table->record[0], &has_null); + create_dbt_key_from_table( + &key_dbt, + primary_key, + primary_key_buff, + table->record[0], + &has_null); // generate packed row DBT row; @@ -883,12 +1072,12 @@ int ha_tokudb::send_upsert_message(THD *thd, List &update_fields, List lhs_i(update_fields); - Item *lhs_item; + Item* lhs_item; while ((lhs_item = lhs_i++)) { if (lhs_item == NULL) break; - Field *lhs_field = find_field_by_name(table, lhs_item); - assert(lhs_field); // we found it before, so this should work + Field* lhs_field = find_field_by_name(table, lhs_item); + assert_always(lhs_field); // we found it before, so this should work count_update_types(lhs_field, &num_varchars, &num_blobs); } if (num_varchars > 0 || num_blobs > 0) @@ -901,35 +1090,44 @@ int ha_tokudb::send_upsert_message(THD *thd, List &update_fields, List(num_updates); if (num_varchars > 0 || num_blobs > 0) - marshall_varchar_descriptor(update_message, table, &share->kc_info, table->s->primary_key); + marshall_varchar_descriptor( + update_message, + table, &share->kc_info, + table->s->primary_key); if (num_blobs > 0) marshall_blobs_descriptor(update_message, table, &share->kc_info); List_iterator lhs_i(update_fields); List_iterator rhs_i(update_values); while (1) { - Item *lhs_item = lhs_i++; + Item* lhs_item = lhs_i++; if (lhs_item == NULL) break; - Item *rhs_item = rhs_i++; - if (rhs_item == NULL) - assert(0); // can not happen + Item* rhs_item = rhs_i++; + assert_always(rhs_item != NULL); marshall_update(update_message, lhs_item, rhs_item, table, share); } - rw_rdlock(&share->num_DBs_lock); + share->_num_DBs_lock.lock_read(); - if (share->num_DBs > table->s->keys + tokudb_test(hidden_primary_key)) { // hot index in progress + // hot index in progress + if (share->num_DBs > table->s->keys + tokudb_test(hidden_primary_key)) { error = ENOTSUP; // run on the slow path } else { // send the upsert message DBT update_dbt; memset(&update_dbt, 0, sizeof update_dbt); update_dbt.data = update_message.data(); update_dbt.size = update_message.size(); - error = share->key_file[primary_key]->update(share->key_file[primary_key], txn, &key_dbt, &update_dbt, 0); + error = + share->key_file[primary_key]->update( + share->key_file[primary_key], + txn, + &key_dbt, + &update_dbt, + 0); } - rw_unlock(&share->num_DBs_lock); + share->_num_DBs_lock.unlock(); return error; } diff --git a/storage/tokudb/hatoku_cmp.cc b/storage/tokudb/hatoku_cmp.cc index 001af657c1d..13bc60e9d98 100644 --- a/storage/tokudb/hatoku_cmp.cc +++ b/storage/tokudb/hatoku_cmp.cc @@ -104,8 +104,7 @@ static void get_var_field_info( data_end_offset = uint2korr(var_field_offset_ptr + 2*var_field_index); break; default: - assert(false); - break; + assert_unreachable(); } if (var_field_index) { @@ -117,8 +116,7 @@ static void get_var_field_info( data_start_offset = uint2korr(var_field_offset_ptr + 2*(var_field_index-1)); break; default: - assert(false); - break; + assert_unreachable(); } } else { @@ -126,7 +124,7 @@ static void get_var_field_info( } *start_offset = data_start_offset; - assert(data_end_offset >= data_start_offset); + assert_always(data_end_offset >= data_start_offset); *field_len = data_end_offset - data_start_offset; } @@ -153,8 +151,7 @@ static void get_blob_field_info( data_end_offset = uint2korr(var_field_data_ptr - 2); break; default: - assert(false); - break; + assert_unreachable(); } } else { @@ -245,7 +242,7 @@ static TOKU_TYPE mysql_to_toku_type (Field* field) { case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_NULL: - assert(false); + assert_unreachable(); } exit: return ret_val; @@ -312,7 +309,7 @@ static inline uchar* pack_toku_int (uchar* to_tokudb, uchar* from_mysql, uint32_ memcpy(to_tokudb, from_mysql, 8); break; default: - assert(false); + assert_unreachable(); } return to_tokudb+num_bytes; } @@ -338,7 +335,7 @@ static inline uchar* unpack_toku_int(uchar* to_mysql, uchar* from_tokudb, uint32 memcpy(to_mysql, from_tokudb, 8); break; default: - assert(false); + assert_unreachable(); } return from_tokudb+num_bytes; } @@ -390,7 +387,7 @@ static inline int cmp_toku_int (uchar* a_buf, uchar* b_buf, bool is_unsigned, ui ret_val = 0; goto exit; default: - assert(false); + assert_unreachable(); } } // @@ -438,13 +435,13 @@ static inline int cmp_toku_int (uchar* a_buf, uchar* b_buf, bool is_unsigned, ui ret_val = 0; goto exit; default: - assert(false); + assert_unreachable(); } } // // if this is hit, indicates bug in writing of this function // - assert(false); + assert_unreachable(); exit: return ret_val; } @@ -653,7 +650,7 @@ static inline uchar* unpack_toku_varbinary( int4store(to_mysql, length); break; default: - assert(false); + assert_unreachable(); } // // copy the binary data @@ -779,7 +776,7 @@ static inline uchar* unpack_toku_blob( int4store(to_mysql, length); break; default: - assert(false); + assert_unreachable(); } // // copy the binary data @@ -957,7 +954,9 @@ static inline int tokudb_compare_two_hidden_keys( const void* saved_key_data, const uint32_t saved_key_size ) { - assert( (new_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH) && (saved_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH) ); + assert_always( + (new_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH) && + (saved_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH)); ulonglong a = hpk_char_to_num((uchar *) new_key_data); ulonglong b = hpk_char_to_num((uchar *) saved_key_data); return a < b ? -1 : (a > b ? 1 : 0); @@ -997,8 +996,7 @@ static uint32_t skip_field_in_descriptor(uchar* row_desc) { row_desc_pos += sizeof(uint32_t); break; default: - assert(false); - break; + assert_unreachable(); } return (uint32_t)(row_desc_pos - row_desc); } @@ -1012,7 +1010,7 @@ static int create_toku_key_descriptor_for_key(KEY* key, uchar* buf) { uchar* pos = buf; uint32_t num_bytes_in_field = 0; uint32_t charset_num = 0; - for (uint i = 0; i < get_key_parts(key); i++){ + for (uint i = 0; i < key->user_defined_key_parts; i++) { Field* field = key->key_part[i].field; // // The first byte states if there is a null byte @@ -1026,7 +1024,7 @@ static int create_toku_key_descriptor_for_key(KEY* key, uchar* buf) { // The second byte for each field is the type // TOKU_TYPE type = mysql_to_toku_type(field); - assert (type < 256); + assert_always((int)type < 256); *pos = (uchar)(type & 255); pos++; @@ -1041,7 +1039,7 @@ static int create_toku_key_descriptor_for_key(KEY* key, uchar* buf) { // case (toku_type_int): num_bytes_in_field = field->pack_length(); - assert (num_bytes_in_field < 256); + assert_always (num_bytes_in_field < 256); *pos = (uchar)(num_bytes_in_field & 255); pos++; *pos = (field->flags & UNSIGNED_FLAG) ? 1 : 0; @@ -1059,7 +1057,7 @@ static int create_toku_key_descriptor_for_key(KEY* key, uchar* buf) { case (toku_type_fixbinary): num_bytes_in_field = field->pack_length(); set_if_smaller(num_bytes_in_field, key->key_part[i].length); - assert(num_bytes_in_field < 256); + assert_always(num_bytes_in_field < 256); pos[0] = (uchar)(num_bytes_in_field & 255); pos++; break; @@ -1087,8 +1085,7 @@ static int create_toku_key_descriptor_for_key(KEY* key, uchar* buf) { pos += 4; break; default: - assert(false); - + assert_unreachable(); } } return pos - buf; @@ -1277,8 +1274,7 @@ static inline int compare_toku_field( *read_string = true; break; default: - assert(false); - break; + assert_unreachable(); } *row_desc_bytes_read = row_desc_pos - row_desc; @@ -1301,7 +1297,7 @@ static uchar* pack_toku_key_field( TOKU_TYPE toku_type = mysql_to_toku_type(field); switch(toku_type) { case (toku_type_int): - assert(key_part_length == field->pack_length()); + assert_always(key_part_length == field->pack_length()); new_pos = pack_toku_int( to_tokudb, from_mysql, @@ -1309,13 +1305,13 @@ static uchar* pack_toku_key_field( ); goto exit; case (toku_type_double): - assert(field->pack_length() == sizeof(double)); - assert(key_part_length == sizeof(double)); + assert_always(field->pack_length() == sizeof(double)); + assert_always(key_part_length == sizeof(double)); new_pos = pack_toku_double(to_tokudb, from_mysql); goto exit; case (toku_type_float): - assert(field->pack_length() == sizeof(float)); - assert(key_part_length == sizeof(float)); + assert_always(field->pack_length() == sizeof(float)); + assert_always(key_part_length == sizeof(float)); new_pos = pack_toku_float(to_tokudb, from_mysql); goto exit; case (toku_type_fixbinary): @@ -1368,9 +1364,9 @@ static uchar* pack_toku_key_field( ); goto exit; default: - assert(false); + assert_unreachable(); } - assert(false); + assert_unreachable(); exit: return new_pos; } @@ -1419,10 +1415,10 @@ static uchar* pack_key_toku_key_field( ); goto exit; default: - assert(false); + assert_unreachable(); } - assert(false); + assert_unreachable(); exit: return new_pos; } @@ -1432,16 +1428,15 @@ uchar* unpack_toku_key_field( uchar* to_mysql, uchar* from_tokudb, Field* field, - uint32_t key_part_length - ) -{ + uint32_t key_part_length) { + uchar* new_pos = NULL; uint32_t num_bytes = 0; uint32_t num_bytes_copied; TOKU_TYPE toku_type = mysql_to_toku_type(field); switch(toku_type) { case (toku_type_int): - assert(key_part_length == field->pack_length()); + assert_always(key_part_length == field->pack_length()); new_pos = unpack_toku_int( to_mysql, from_tokudb, @@ -1449,13 +1444,13 @@ uchar* unpack_toku_key_field( ); goto exit; case (toku_type_double): - assert(field->pack_length() == sizeof(double)); - assert(key_part_length == sizeof(double)); + assert_always(field->pack_length() == sizeof(double)); + assert_always(key_part_length == sizeof(double)); new_pos = unpack_toku_double(to_mysql, from_tokudb); goto exit; case (toku_type_float): - assert(field->pack_length() == sizeof(float)); - assert(key_part_length == sizeof(float)); + assert_always(field->pack_length() == sizeof(float)); + assert_always(key_part_length == sizeof(float)); new_pos = unpack_toku_float(to_mysql, from_tokudb); goto exit; case (toku_type_fixbinary): @@ -1464,8 +1459,7 @@ uchar* unpack_toku_key_field( new_pos = unpack_toku_binary( to_mysql, from_tokudb, - num_bytes - ); + num_bytes); goto exit; case (toku_type_fixstring): num_bytes = field->pack_length(); @@ -1473,11 +1467,15 @@ uchar* unpack_toku_key_field( to_mysql, from_tokudb, get_length_bytes_from_max(key_part_length), - 0 - ); - num_bytes_copied = new_pos - (from_tokudb + get_length_bytes_from_max(key_part_length)); - assert(num_bytes_copied <= num_bytes); - memset(to_mysql+num_bytes_copied, field->charset()->pad_char, num_bytes - num_bytes_copied); + 0); + num_bytes_copied = + new_pos - + (from_tokudb + get_length_bytes_from_max(key_part_length)); + assert_always(num_bytes_copied <= num_bytes); + memset( + to_mysql + num_bytes_copied, + field->charset()->pad_char, + num_bytes - num_bytes_copied); goto exit; case (toku_type_varbinary): case (toku_type_varstring): @@ -1485,21 +1483,20 @@ uchar* unpack_toku_key_field( to_mysql, from_tokudb, get_length_bytes_from_max(key_part_length), - ((Field_varstring *)field)->length_bytes - ); + ((Field_varstring*)field)->length_bytes); goto exit; case (toku_type_blob): new_pos = unpack_toku_blob( to_mysql, from_tokudb, get_length_bytes_from_max(key_part_length), - ((Field_blob *)field)->row_pack_length() //only calling this because packlength is returned - ); + //only calling this because packlength is returned + ((Field_blob *)field)->row_pack_length()); goto exit; default: - assert(false); + assert_unreachable(); } - assert(false); + assert_unreachable(); exit: return new_pos; } @@ -1513,9 +1510,8 @@ static int tokudb_compare_two_keys( const void* row_desc, const uint32_t row_desc_size, bool cmp_prefix, - bool* read_string - ) -{ + bool* read_string) { + int ret_val = 0; int8_t new_key_inf_val = COL_NEG_INF; int8_t saved_key_inf_val = COL_NEG_INF; @@ -1538,11 +1534,9 @@ static int tokudb_compare_two_keys( } row_desc_ptr++; - while ( (uint32_t)(new_key_ptr - (uchar *)new_key_data) < new_key_size && - (uint32_t)(saved_key_ptr - (uchar *)saved_key_data) < saved_key_size && - (uint32_t)(row_desc_ptr - (uchar *)row_desc) < row_desc_size - ) - { + while ((uint32_t)(new_key_ptr - (uchar*)new_key_data) < new_key_size && + (uint32_t)(saved_key_ptr - (uchar*)saved_key_data) < saved_key_size && + (uint32_t)(row_desc_ptr - (uchar*)row_desc) < row_desc_size) { uint32_t new_key_field_length; uint32_t saved_key_field_length; uint32_t row_desc_field_length; @@ -1583,8 +1577,7 @@ static int tokudb_compare_two_keys( &new_key_field_length, &saved_key_field_length, &row_desc_field_length, - read_string - ); + read_string); new_key_ptr += new_key_field_length; saved_key_ptr += saved_key_field_length; row_desc_ptr += row_desc_field_length; @@ -1592,35 +1585,30 @@ static int tokudb_compare_two_keys( goto exit; } - assert((uint32_t)(new_key_ptr - (uchar *)new_key_data) <= new_key_size); - assert((uint32_t)(saved_key_ptr - (uchar *)saved_key_data) <= saved_key_size); - assert((uint32_t)(row_desc_ptr - (uchar *)row_desc) <= row_desc_size); + assert_always( + (uint32_t)(new_key_ptr - (uchar*)new_key_data) <= new_key_size); + assert_always( + (uint32_t)(saved_key_ptr - (uchar*)saved_key_data) <= saved_key_size); + assert_always( + (uint32_t)(row_desc_ptr - (uchar*)row_desc) <= row_desc_size); } - new_key_bytes_left = new_key_size - ((uint32_t)(new_key_ptr - (uchar *)new_key_data)); - saved_key_bytes_left = saved_key_size - ((uint32_t)(saved_key_ptr - (uchar *)saved_key_data)); + new_key_bytes_left = + new_key_size - ((uint32_t)(new_key_ptr - (uchar*)new_key_data)); + saved_key_bytes_left = + saved_key_size - ((uint32_t)(saved_key_ptr - (uchar*)saved_key_data)); if (cmp_prefix) { ret_val = 0; - } - // - // in this case, read both keys to completion, now read infinity byte - // - else if (new_key_bytes_left== 0 && saved_key_bytes_left== 0) { + } else if (new_key_bytes_left== 0 && saved_key_bytes_left== 0) { + // in this case, read both keys to completion, now read infinity byte ret_val = new_key_inf_val - saved_key_inf_val; - } - // - // at this point, one SHOULD be 0 - // - else if (new_key_bytes_left == 0 && saved_key_bytes_left > 0) { + } else if (new_key_bytes_left == 0 && saved_key_bytes_left > 0) { + // at this point, one SHOULD be 0 ret_val = (new_key_inf_val == COL_POS_INF ) ? 1 : -1; - } - else if (new_key_bytes_left > 0 && saved_key_bytes_left == 0) { + } else if (new_key_bytes_left > 0 && saved_key_bytes_left == 0) { ret_val = (saved_key_inf_val == COL_POS_INF ) ? -1 : 1; - } - // - // this should never happen, perhaps we should assert(false) - // - else { - assert(false); + } else { + // this should never happen, perhaps we should assert(false) + assert_unreachable(); ret_val = new_key_bytes_left - saved_key_bytes_left; } exit: @@ -1765,9 +1753,9 @@ static int tokudb_compare_two_key_parts( goto exit; } - assert((uint32_t)(new_key_ptr - (uchar *)new_key_data) <= new_key_size); - assert((uint32_t)(saved_key_ptr - (uchar *)saved_key_data) <= saved_key_size); - assert((uint32_t)(row_desc_ptr - (uchar *)row_desc) <= row_desc_size); + assert_always((uint32_t)(new_key_ptr - (uchar *)new_key_data) <= new_key_size); + assert_always((uint32_t)(saved_key_ptr - (uchar *)saved_key_data) <= saved_key_size); + assert_always((uint32_t)(row_desc_ptr - (uchar *)row_desc) <= row_desc_size); } ret_val = 0; @@ -1776,7 +1764,7 @@ exit: } static int tokudb_cmp_dbt_key_parts(DB *file, const DBT *keya, const DBT *keyb, uint max_parts) { - assert(file->cmp_descriptor->dbt.size); + assert_always(file->cmp_descriptor->dbt.size); return tokudb_compare_two_key_parts( keya->data, keya->size, @@ -1847,7 +1835,7 @@ static uint32_t pack_desc_pk_info(uchar* buf, KEY_AND_COL_INFO* kc_info, TABLE_S case (toku_type_float): pos[0] = COL_FIX_FIELD; pos++; - assert(kc_info->field_lengths[field_index] < 256); + assert_always(kc_info->field_lengths[field_index] < 256); pos[0] = kc_info->field_lengths[field_index]; pos++; break; @@ -1856,7 +1844,7 @@ static uint32_t pack_desc_pk_info(uchar* buf, KEY_AND_COL_INFO* kc_info, TABLE_S pos++; field_length = field->pack_length(); set_if_smaller(key_part_length, field_length); - assert(key_part_length < 256); + assert_always(key_part_length < 256); pos[0] = (uchar)key_part_length; pos++; break; @@ -1871,7 +1859,7 @@ static uint32_t pack_desc_pk_info(uchar* buf, KEY_AND_COL_INFO* kc_info, TABLE_S pos++; break; default: - assert(false); + assert_unreachable(); } return pos - buf; @@ -1893,7 +1881,7 @@ static uint32_t pack_desc_pk_offset_info( bool is_constant_offset = true; uint32_t offset = 0; - for (uint i = 0; i < get_key_parts(prim_key); i++) { + for (uint i = 0; i < prim_key->user_defined_key_parts; i++) { KEY_PART_INFO curr = prim_key->key_part[i]; uint16 curr_field_index = curr.field->field_index; @@ -1908,7 +1896,7 @@ static uint32_t pack_desc_pk_offset_info( } offset += pk_info[2*i + 1]; } - assert(found_col_in_pk); + assert_always(found_col_in_pk); if (is_constant_offset) { pos[0] = COL_FIX_PK_OFFSET; pos++; @@ -1966,10 +1954,10 @@ static uint32_t pack_desc_offset_info(uchar* buf, KEY_AND_COL_INFO* kc_info, uin break; } } - assert(found_index); + assert_always(found_index); break; default: - assert(false); + assert_unreachable(); } return pos - buf; @@ -2004,7 +1992,7 @@ static uint32_t pack_desc_key_length_info(uchar* buf, KEY_AND_COL_INFO* kc_info, pos += sizeof(key_part_length); break; default: - assert(false); + assert_unreachable(); } return pos - buf; @@ -2041,7 +2029,7 @@ static uint32_t pack_desc_char_info(uchar* buf, KEY_AND_COL_INFO* kc_info, TABLE pos += 4; break; default: - assert(false); + assert_unreachable(); } return pos - buf; @@ -2151,7 +2139,7 @@ static uint32_t create_toku_clustering_val_pack_descriptor ( bool col_filtered = bitmap_is_set(&kc_info->key_filters[keynr],i); bool col_filtered_in_pk = bitmap_is_set(&kc_info->key_filters[pk_index],i); if (col_filtered_in_pk) { - assert(col_filtered); + assert_always(col_filtered); } } @@ -2321,7 +2309,7 @@ static uint32_t pack_clustering_val_from_desc( memcpy(&end, desc_pos, sizeof(end)); desc_pos += sizeof(end); - assert (start <= end); + assert_always (start <= end); if (curr == CK_FIX_RANGE) { length = end - start; @@ -2367,24 +2355,21 @@ static uint32_t pack_clustering_val_from_desc( offset_diffs = (end_data_offset + end_data_size) - (uint32_t)(var_dest_data_ptr - orig_var_dest_data_ptr); for (uint32_t i = start; i <= end; i++) { if ( num_offset_bytes == 1 ) { - assert(offset_diffs < 256); + assert_always(offset_diffs < 256); var_dest_offset_ptr[0] = var_src_offset_ptr[i] - (uchar)offset_diffs; var_dest_offset_ptr++; - } - else if ( num_offset_bytes == 2 ) { + } else if ( num_offset_bytes == 2 ) { uint32_t tmp = uint2korr(var_src_offset_ptr + 2*i); uint32_t new_offset = tmp - offset_diffs; - assert(new_offset < 1<<16); + assert_always(new_offset < 1<<16); int2store(var_dest_offset_ptr,new_offset); var_dest_offset_ptr += 2; - } - else { - assert(false); + } else { + assert_unreachable(); } } - } - else { - assert(false); + } else { + assert_unreachable(); } } // @@ -2518,8 +2503,8 @@ static uint32_t create_toku_secondary_key_pack_descriptor ( // // store number of parts // - assert(get_key_parts(prim_key) < 128); - pos[0] = 2 * get_key_parts(prim_key); + assert_always(prim_key->user_defined_key_parts < 128); + pos[0] = 2 * prim_key->user_defined_key_parts; pos++; // // for each part, store if it is a fixed field or var field @@ -2529,7 +2514,7 @@ static uint32_t create_toku_secondary_key_pack_descriptor ( // pk_info = pos; uchar* tmp = pos; - for (uint i = 0; i < get_key_parts(prim_key); i++) { + for (uint i = 0; i < prim_key->user_defined_key_parts; i++) { tmp += pack_desc_pk_info( tmp, kc_info, @@ -2540,18 +2525,18 @@ static uint32_t create_toku_secondary_key_pack_descriptor ( // // asserting that we moved forward as much as we think we have // - assert(tmp - pos == (2 * get_key_parts(prim_key))); + assert_always(tmp - pos == (2 * prim_key->user_defined_key_parts)); pos = tmp; } - for (uint i = 0; i < get_key_parts(key_info); i++) { + for (uint i = 0; i < key_info->user_defined_key_parts; i++) { KEY_PART_INFO curr_kpi = key_info->key_part[i]; uint16 field_index = curr_kpi.field->field_index; Field* field = table_share->field[field_index]; bool is_col_in_pk = false; if (bitmap_is_set(&kc_info->key_filters[pk_index],field_index)) { - assert(!has_hpk && prim_key != NULL); + assert_always(!has_hpk && prim_key != NULL); is_col_in_pk = true; } else { @@ -2566,7 +2551,7 @@ static uint32_t create_toku_secondary_key_pack_descriptor ( // assert that columns in pk do not have a null bit // because in MySQL, pk columns cannot be null // - assert(!field->null_bit); + assert_always(!field->null_bit); } if (field->null_bit) { @@ -2668,7 +2653,7 @@ static uint32_t max_key_size_from_desc( // skip byte that states if main dictionary bool is_main_dictionary = desc_pos[0]; desc_pos++; - assert(!is_main_dictionary); + assert_always(!is_main_dictionary); // skip hpk byte desc_pos++; @@ -2731,7 +2716,7 @@ static uint32_t max_key_size_from_desc( desc_pos += sizeof(charset_num); } else { - assert(has_charset == COL_HAS_NO_CHARSET); + assert_always(has_charset == COL_HAS_NO_CHARSET); } } return max_size; @@ -2742,9 +2727,8 @@ static uint32_t pack_key_from_desc( void* row_desc, uint32_t row_desc_size, const DBT* pk_key, - const DBT* pk_val - ) -{ + const DBT* pk_val) { + MULTI_COL_PACK_INFO mcp_info; uint32_t num_null_bytes; uint32_t num_blobs; @@ -2762,7 +2746,7 @@ static uint32_t pack_key_from_desc( bool is_main_dictionary = desc_pos[0]; desc_pos++; - assert(!is_main_dictionary); + assert_always(!is_main_dictionary); // // get the constant info out of descriptor @@ -2810,7 +2794,7 @@ static uint32_t pack_key_from_desc( fixed_field_ptr = null_bytes_ptr + num_null_bytes; var_field_offset_ptr = fixed_field_ptr + mcp_info.fixed_field_size; var_field_data_ptr = var_field_offset_ptr + mcp_info.len_of_offsets; - while ( (uint32_t)(desc_pos - (uchar *)row_desc) < row_desc_size) { + while ((uint32_t)(desc_pos - (uchar*)row_desc) < row_desc_size) { uchar col_fix_val; uchar has_charset; uint32_t col_pack_val = 0; @@ -2834,8 +2818,7 @@ static uint32_t pack_key_from_desc( packed_key_pos++; desc_pos += skip_key_in_desc(desc_pos); continue; - } - else { + } else { packed_key_pos[0] = NONNULL_COL_VAL; packed_key_pos++; } @@ -2859,42 +2842,46 @@ static uint32_t pack_key_from_desc( if (has_charset == COL_HAS_CHARSET) { memcpy(&charset_num, desc_pos, sizeof(charset_num)); desc_pos += sizeof(charset_num); - } - else { - assert(has_charset == COL_HAS_NO_CHARSET); + } else { + assert_always(has_charset == COL_HAS_NO_CHARSET); } // // case where column is in pk val // - if (col_fix_val == COL_FIX_FIELD || col_fix_val == COL_VAR_FIELD || col_fix_val == COL_BLOB_FIELD) { - if (col_fix_val == COL_FIX_FIELD && has_charset == COL_HAS_NO_CHARSET) { - memcpy(packed_key_pos, &fixed_field_ptr[col_pack_val], key_length); + if (col_fix_val == COL_FIX_FIELD || + col_fix_val == COL_VAR_FIELD || + col_fix_val == COL_BLOB_FIELD) { + if (col_fix_val == COL_FIX_FIELD && + has_charset == COL_HAS_NO_CHARSET) { + memcpy( + packed_key_pos, + &fixed_field_ptr[col_pack_val], + key_length); packed_key_pos += key_length; - } - else if (col_fix_val == COL_VAR_FIELD && has_charset == COL_HAS_NO_CHARSET) { + } else if (col_fix_val == COL_VAR_FIELD && + has_charset == COL_HAS_NO_CHARSET) { uint32_t data_start_offset = 0; uint32_t data_size = 0; get_var_field_info( - &data_size, - &data_start_offset, - col_pack_val, - var_field_offset_ptr, - num_offset_bytes - ); + &data_size, + &data_start_offset, + col_pack_val, + var_field_offset_ptr, + num_offset_bytes); // // length of this field in this row is data_size // data is located beginning at var_field_data_ptr + data_start_offset // packed_key_pos = pack_toku_varbinary_from_desc( - packed_key_pos, - var_field_data_ptr + data_start_offset, - key_length, //number of bytes to use to encode the length in to_tokudb - data_size //length of field - ); - } - else { + packed_key_pos, + var_field_data_ptr + data_start_offset, + //number of bytes to use to encode the length in to_tokudb + key_length, + //length of field + data_size); + } else { const uchar* data_start = NULL; uint32_t data_start_offset = 0; uint32_t data_size = 0; @@ -2903,76 +2890,59 @@ static uint32_t pack_key_from_desc( data_start_offset = col_pack_val; data_size = key_length; data_start = fixed_field_ptr + data_start_offset; - } - else if (col_fix_val == COL_VAR_FIELD){ + } else if (col_fix_val == COL_VAR_FIELD){ get_var_field_info( - &data_size, - &data_start_offset, - col_pack_val, - var_field_offset_ptr, - num_offset_bytes - ); + &data_size, + &data_start_offset, + col_pack_val, + var_field_offset_ptr, + num_offset_bytes); data_start = var_field_data_ptr + data_start_offset; - } - else if (col_fix_val == COL_BLOB_FIELD) { + } else if (col_fix_val == COL_BLOB_FIELD) { uint32_t blob_index = col_pack_val; uint32_t blob_offset; const uchar* blob_ptr = NULL; uint32_t field_len; uint32_t field_len_bytes = blob_lengths[blob_index]; get_blob_field_info( - &blob_offset, + &blob_offset, mcp_info.len_of_offsets, - var_field_data_ptr, - num_offset_bytes - ); + var_field_data_ptr, + num_offset_bytes); blob_ptr = var_field_data_ptr + blob_offset; - assert(num_blobs > 0); - // - // skip over other blobs to get to the one we want to make a key out of - // + assert_always(num_blobs > 0); + + // skip over other blobs to get to the one we want to + // make a key out of for (uint32_t i = 0; i < blob_index; i++) { blob_ptr = unpack_toku_field_blob( NULL, blob_ptr, blob_lengths[i], - true - ); + true); } - // - // at this point, blob_ptr is pointing to the blob we want to make a key from - // + // at this point, blob_ptr is pointing to the blob we + // want to make a key from field_len = get_blob_field_len(blob_ptr, field_len_bytes); - // // now we set the variables to make the key - // data_start = blob_ptr + field_len_bytes; data_size = field_len; - - - } - else { - assert(false); + } else { + assert_unreachable(); } - packed_key_pos = pack_toku_varstring_from_desc( - packed_key_pos, + packed_key_pos = pack_toku_varstring_from_desc(packed_key_pos, data_start, key_length, data_size, - charset_num - ); + charset_num); } - } - // - // case where column is in pk key - // - else { + } else { + // case where column is in pk key if (col_fix_val == COL_FIX_PK_OFFSET) { memcpy(packed_key_pos, &pk_data_ptr[col_pack_val], key_length); packed_key_pos += key_length; - } - else if (col_fix_val == COL_VAR_PK_OFFSET) { + } else if (col_fix_val == COL_VAR_PK_OFFSET) { uchar* tmp_pk_data_ptr = pk_data_ptr; uint32_t index_in_pk = col_pack_val; // @@ -2981,25 +2951,21 @@ static uint32_t pack_key_from_desc( for (uint32_t i = 0; i < index_in_pk; i++) { if (pk_info[2*i] == COL_FIX_FIELD) { tmp_pk_data_ptr += pk_info[2*i + 1]; - } - else if (pk_info[2*i] == COL_VAR_FIELD) { + } else if (pk_info[2*i] == COL_VAR_FIELD) { uint32_t len_bytes = pk_info[2*i + 1]; uint32_t len; if (len_bytes == 1) { len = tmp_pk_data_ptr[0]; tmp_pk_data_ptr++; - } - else if (len_bytes == 2) { + } else if (len_bytes == 2) { len = uint2korr(tmp_pk_data_ptr); tmp_pk_data_ptr += 2; - } - else { - assert(false); + } else { + assert_unreachable(); } tmp_pk_data_ptr += len; - } - else { - assert(false); + } else { + assert_unreachable(); } } // @@ -3009,21 +2975,18 @@ static uint32_t pack_key_from_desc( if (is_fix_field == COL_FIX_FIELD) { memcpy(packed_key_pos, tmp_pk_data_ptr, key_length); packed_key_pos += key_length; - } - else if (is_fix_field == COL_VAR_FIELD) { + } else if (is_fix_field == COL_VAR_FIELD) { const uchar* data_start = NULL; uint32_t data_size = 0; uint32_t len_bytes = pk_info[2*index_in_pk + 1]; if (len_bytes == 1) { data_size = tmp_pk_data_ptr[0]; tmp_pk_data_ptr++; - } - else if (len_bytes == 2) { + } else if (len_bytes == 2) { data_size = uint2korr(tmp_pk_data_ptr); tmp_pk_data_ptr += 2; - } - else { - assert(false); + } else { + assert_unreachable(); } data_start = tmp_pk_data_ptr; @@ -3033,32 +2996,26 @@ static uint32_t pack_key_from_desc( data_start, key_length, data_size, - charset_num - ); - } - else if (has_charset == COL_HAS_NO_CHARSET) { + charset_num); + } else if (has_charset == COL_HAS_NO_CHARSET) { packed_key_pos = pack_toku_varbinary_from_desc( - packed_key_pos, - data_start, + packed_key_pos, + data_start, key_length, - data_size //length of field - ); - } - else { - assert(false); + data_size); + } else { + assert_unreachable(); } + } else { + assert_unreachable(); } - else { - assert(false); - } - } - else { - assert(false); + } else { + assert_unreachable(); } } } - assert( (uint32_t)(desc_pos - (uchar *)row_desc) == row_desc_size); + assert_always( (uint32_t)(desc_pos - (uchar *)row_desc) == row_desc_size); // // now append the primary key to the end of the key @@ -3066,13 +3023,12 @@ static uint32_t pack_key_from_desc( if (hpk) { memcpy(packed_key_pos, pk_key->data, pk_key->size); packed_key_pos += pk_key->size; - } - else { + } else { memcpy(packed_key_pos, (uchar *)pk_key->data + 1, pk_key->size - 1); packed_key_pos += (pk_key->size - 1); } - return (uint32_t)(packed_key_pos - buf); // + return (uint32_t)(packed_key_pos - buf); } static bool fields_have_same_name(Field* a, Field* b) { @@ -3249,7 +3205,7 @@ static bool fields_are_same_type(Field* a, Field* b) { case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_NULL: - assert(false); + assert_unreachable(); } cleanup: diff --git a/storage/tokudb/hatoku_cmp.h b/storage/tokudb/hatoku_cmp.h index 9a5358fc9af..34b3cfbe1f8 100644 --- a/storage/tokudb/hatoku_cmp.h +++ b/storage/tokudb/hatoku_cmp.h @@ -26,9 +26,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ifndef _HATOKU_CMP #define _HATOKU_CMP -#include "stdint.h" +#include "hatoku_defines.h" +#include "tokudb_debug.h" -#include // // A MySQL row is encoded in TokuDB, as follows: @@ -180,7 +180,7 @@ static inline uint32_t get_blob_field_len(const uchar* from_tokudb, uint32_t len length = uint4korr(from_tokudb); break; default: - assert(false); + assert_unreachable(); } return length; } diff --git a/storage/tokudb/hatoku_defines.h b/storage/tokudb/hatoku_defines.h index 3602e0b6b5a..b7726a746ad 100644 --- a/storage/tokudb/hatoku_defines.h +++ b/storage/tokudb/hatoku_defines.h @@ -23,8 +23,47 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." -#ifndef _TOKUDB_CONFIG_H -#define _TOKUDB_CONFIG_H +#ifndef _HATOKU_DEFINES_H +#define _HATOKU_DEFINES_H + +#include +#define MYSQL_SERVER 1 +#include "mysql_version.h" +#include "sql_table.h" +#include "handler.h" +#include "table.h" +#include "log.h" +#include "sql_class.h" +#include "sql_show.h" +#include "discover.h" +//#include +#include "debug_sync.h" + +#undef PACKAGE +#undef VERSION +#undef HAVE_DTRACE +#undef _DTRACE_VERSION + +/* We define DTRACE after mysql_priv.h in case it disabled dtrace in the main server */ +#ifdef HAVE_DTRACE +#define _DTRACE_VERSION 1 +#else +#endif + +#include + +#include +#include +#define __STDC_FORMAT_MACROS +#include +#if defined(_WIN32) +#include "misc.h" +#endif + +#include "db.h" +#include "toku_os.h" +#include "toku_time.h" +#include "partitioned_counter.h" #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ @@ -32,10 +71,6 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #if 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199 -#if !defined(TOKUDB_CHECK_JEMALLOC) -#define TOKUDB_CHECK_JEMALLOC 1 -#endif - // mariadb 10.0 #define TOKU_USE_DB_TYPE_TOKUDB 1 #define TOKU_INCLUDE_ALTER_56 1 @@ -163,326 +198,51 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. /* Bits for share->status */ #define STATUS_PRIMARY_KEY_INIT 0x1 -#endif // _TOKUDB_CONFIG_H - -#ifndef _TOKUDB_DEBUG_H -#define _TOKUDB_DEBUG_H - -#define TOKU_INCLUDE_BACKTRACE 0 -#if TOKU_INCLUDE_BACKTRACE -static void tokudb_backtrace(void); -#endif - -extern ulong tokudb_debug; - -// tokudb debug tracing -#define TOKUDB_DEBUG_INIT 1 -#define TOKUDB_DEBUG_OPEN 2 -#define TOKUDB_DEBUG_ENTER 4 -#define TOKUDB_DEBUG_RETURN 8 -#define TOKUDB_DEBUG_ERROR 16 -#define TOKUDB_DEBUG_TXN 32 -#define TOKUDB_DEBUG_AUTO_INCREMENT 64 -#define TOKUDB_DEBUG_INDEX_KEY 128 -#define TOKUDB_DEBUG_LOCK 256 -#define TOKUDB_DEBUG_CHECK_KEY 1024 -#define TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS 2048 -#define TOKUDB_DEBUG_ALTER_TABLE 4096 -#define TOKUDB_DEBUG_UPSERT 8192 -#define TOKUDB_DEBUG_CHECK (1<<14) -#define TOKUDB_DEBUG_ANALYZE (1<<15) - -#define TOKUDB_TRACE(f, ...) { \ - fprintf(stderr, "%u %s:%u %s " f "\n", my_tid(), __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ -} - -static inline unsigned int my_tid() { - return (unsigned int)toku_os_gettid(); -} - -#define TOKUDB_DBUG_ENTER(f, ...) { \ - if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \ - TOKUDB_TRACE(f, ##__VA_ARGS__); \ - } \ -} \ - DBUG_ENTER(__FUNCTION__); - -#define TOKUDB_DBUG_RETURN(r) { \ - int rr = (r); \ - if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \ - TOKUDB_TRACE("return %d", rr); \ - } \ - DBUG_RETURN(rr); \ -} - -#define TOKUDB_HANDLER_TRACE(f, ...) \ - fprintf(stderr, "%u %p %s:%u ha_tokudb::%s " f "\n", my_tid(), this, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); - -#define TOKUDB_HANDLER_DBUG_ENTER(f, ...) { \ - if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \ - TOKUDB_HANDLER_TRACE(f, ##__VA_ARGS__); \ - } \ -} \ - DBUG_ENTER(__FUNCTION__); - -#define TOKUDB_HANDLER_DBUG_RETURN(r) { \ - int rr = (r); \ - if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \ - TOKUDB_HANDLER_TRACE("return %d", rr); \ - } \ - DBUG_RETURN(rr); \ -} - -#define TOKUDB_HANDLER_DBUG_VOID_RETURN { \ - if (tokudb_debug & TOKUDB_DEBUG_RETURN) { \ - TOKUDB_HANDLER_TRACE("return"); \ - } \ - DBUG_VOID_RETURN; \ -} - -#define TOKUDB_DBUG_DUMP(s, p, len) \ -{ \ - TOKUDB_TRACE("%s", s); \ - uint i; \ - for (i=0; ideleted = 0; - val->inserted = 0; - val->updated = 0; - val->queried = 0; -} - -static inline int get_name_length(const char *name) { - int n = 0; - const char *newname = name; - n += strlen(newname); - n += strlen(ha_tokudb_ext); - return n; -} - -// -// returns maximum length of path to a dictionary -// -static inline int get_max_dict_name_path_length(const char *tablename) { - int n = 0; - n += get_name_length(tablename); - n += 1; //for the '-' - n += MAX_DICT_NAME_LEN; - return n; -} - -static inline void make_name(char *newname, const char *tablename, const char *dictname) { - const char *newtablename = tablename; - char *nn = newname; - assert(tablename); - assert(dictname); - nn += sprintf(nn, "%s", newtablename); - nn += sprintf(nn, "-%s", dictname); -} - -static inline int txn_begin(DB_ENV *env, DB_TXN *parent, DB_TXN **txn, uint32_t flags, THD *thd) { - *txn = NULL; - int r = env->txn_begin(env, parent, txn, flags); - if (r == 0 && thd) { - DB_TXN *this_txn = *txn; - this_txn->set_client_id(this_txn, thd_get_thread_id(thd)); - } - if ((tokudb_debug & TOKUDB_DEBUG_TXN)) { - TOKUDB_TRACE("begin txn %p %p %u r=%d", parent, *txn, flags, r); - } - return r; -} - -static inline void commit_txn(DB_TXN* txn, uint32_t flags) { - if (tokudb_debug & TOKUDB_DEBUG_TXN) - TOKUDB_TRACE("commit txn %p", txn); - int r = txn->commit(txn, flags); - if (r != 0) { - sql_print_error("tried committing transaction %p and got error code %d", txn, r); - } - assert(r == 0); -} - -static inline void abort_txn(DB_TXN* txn) { - if (tokudb_debug & TOKUDB_DEBUG_TXN) - TOKUDB_TRACE("abort txn %p", txn); - int r = txn->abort(txn); - if (r != 0) { - sql_print_error("tried aborting transaction %p and got error code %d", txn, r); - } - assert(r == 0); -} - -#endif // _TOKUDB_TXN_H - -#ifndef _TOKUDB_PORTABILITY_H -#define _TOKUDB_PORTABILITY_H - -static inline void *tokudb_my_malloc(size_t s, myf flags) { -#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799 - return my_malloc(0, s, flags); +#if defined(TOKUDB_VERSION_MAJOR) && defined(TOKUDB_VERSION_MINOR) +#define TOKUDB_PLUGIN_VERSION ((TOKUDB_VERSION_MAJOR << 8) + TOKUDB_VERSION_MINOR) #else - return my_malloc(s, flags); +#define TOKUDB_PLUGIN_VERSION 0 #endif -} -static inline void *tokudb_my_realloc(void *p, size_t s, myf flags) { - if (s == 0) - return p; -#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799 - return my_realloc(0, p, s, flags); +// Branch prediction macros. +// If supported by the compiler, will hint in instruction caching for likely +// branching. Should only be used where there is a very good idea of the correct +// branch heuristics as determined by profiling. Mostly copied from InnoDB. +// Use: +// "if (TOKUDB_LIKELY(x))" where the chances of "x" evaluating true are higher +// "if (TOKUDB_UNLIKELY(x))" where the chances of "x" evaluating false are higher +#if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER) + +// Tell the compiler that 'expr' probably evaluates to 'constant'. +#define TOKUDB_EXPECT(expr,constant) __builtin_expect(expr, constant) + #else - return my_realloc(p, s, flags | MY_ALLOW_ZERO_PTR); -#endif -} -static inline void tokudb_my_free(void *ptr) { - if (ptr) - my_free(ptr); -} +#error "No TokuDB branch prediction operations in use!" +#define TOKUDB_EXPECT(expr,constant) (expr) -static inline char *tokudb_my_strdup(const char *p, myf flags) { -#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799 - return my_strdup(0, p, flags); -#else - return my_strdup(p, flags); -#endif -} +#endif // defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER) -static inline void* tokudb_my_multi_malloc(myf myFlags, ...) { - va_list args; - char **ptr,*start,*res; - size_t tot_length,length; +// Tell the compiler that cond is likely to hold +#define TOKUDB_LIKELY(cond) TOKUDB_EXPECT(cond, 1) - va_start(args,myFlags); - tot_length=0; - while ((ptr=va_arg(args, char **))) { - length=va_arg(args,uint); - tot_length+=ALIGN_SIZE(length); - } - va_end(args); - - if (!(start=(char *) tokudb_my_malloc(tot_length,myFlags))) { - return 0; - } - - va_start(args,myFlags); - res=start; - while ((ptr=va_arg(args, char **))) { - *ptr=res; - length=va_arg(args,uint); - res+=ALIGN_SIZE(length); - } - va_end(args); - return start; -} - -static inline void tokudb_pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { - int r = pthread_mutex_init(mutex, attr); - assert(r == 0); -} - -static inline void tokudb_pthread_mutex_destroy(pthread_mutex_t *mutex) { - int r = pthread_mutex_destroy(mutex); - assert(r == 0); -} - -static inline void tokudb_pthread_mutex_lock(pthread_mutex_t *mutex) { - int r = pthread_mutex_lock(mutex); - assert(r == 0); -} - -static inline void tokudb_pthread_mutex_unlock(pthread_mutex_t *mutex) { - int r = pthread_mutex_unlock(mutex); - assert(r == 0); -} - -static inline void tokudb_pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { - int r = pthread_cond_init(cond, attr); - assert(r == 0); -} - -static inline void tokudb_pthread_cond_destroy(pthread_cond_t *cond) { - int r = pthread_cond_destroy(cond); - assert(r == 0); -} - -static inline void tokudb_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { - int r = pthread_cond_wait(cond, mutex); - assert(r == 0); -} - -static inline void tokudb_pthread_cond_broadcast(pthread_cond_t *cond) { - int r = pthread_cond_broadcast(cond); - assert(r == 0); -} +// Tell the compiler that cond is unlikely to hold +#define TOKUDB_UNLIKELY(cond) TOKUDB_EXPECT(cond, 0) +// Tell the compiler that the function/argument is unused +#define TOKUDB_UNUSED(_uu) _uu __attribute__((unused)) // mysql 5.6.15 removed the test macro, so we define our own #define tokudb_test(e) ((e) ? 1 : 0) -static const char *tokudb_thd_get_proc_info(THD *thd) { +inline const char* tokudb_thd_get_proc_info(const THD *thd) { return thd->proc_info; } // uint3korr reads 4 bytes and valgrind reports an error, so we use this function instead -static uint tokudb_uint3korr(const uchar *a) { +inline uint tokudb_uint3korr(const uchar *a) { uchar b[4] = {}; memcpy(b, a, 3); return uint3korr(b); } -#endif // _TOKUDB_PORTABILITY_H +#endif // _HATOKU_DEFINES_H diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index 74e133ecffd..ed2c104200d 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -24,35 +24,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." -#define MYSQL_SERVER 1 -#include "hatoku_defines.h" -#include -#include - -#include "stdint.h" -#if defined(_WIN32) -#include "misc.h" -#endif -#define __STDC_FORMAT_MACROS -#include -#include "toku_os.h" -#include "toku_time.h" -#include "partitioned_counter.h" - -/* We define DTRACE after mysql_priv.h in case it disabled dtrace in the main server */ -#ifdef HAVE_DTRACE -#define _DTRACE_VERSION 1 -#else -#endif - -#include #include "hatoku_hton.h" -#include "ha_tokudb.h" - -#undef PACKAGE -#undef VERSION -#undef HAVE_DTRACE -#undef _DTRACE_VERSION #define TOKU_METADB_NAME "tokudb_meta" @@ -62,75 +34,96 @@ typedef struct savepoint_info { bool in_sub_stmt; } *SP_INFO, SP_INFO_T; -#if TOKU_INCLUDE_OPTION_STRUCTS -ha_create_table_option tokudb_table_options[] = { - HA_TOPTION_SYSVAR("compression", row_format, row_format), - HA_TOPTION_END -}; +static handler* tokudb_create_handler( + handlerton* hton, + TABLE_SHARE* table, + MEM_ROOT* mem_root); -ha_create_table_option tokudb_index_options[] = { - HA_IOPTION_BOOL("clustering", clustering, 0), - HA_IOPTION_END -}; -#endif - -static uchar *tokudb_get_key(TOKUDB_SHARE * share, size_t * length, my_bool not_used __attribute__ ((unused))) { - *length = share->table_name_length; - return (uchar *) share->table_name; -} - -static handler *tokudb_create_handler(handlerton * hton, TABLE_SHARE * table, MEM_ROOT * mem_root); - - -static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer); +static void tokudb_print_error( + const DB_ENV* db_env, + const char* db_errpfx, + const char* buffer); static void tokudb_cleanup_log_files(void); -static int tokudb_end(handlerton * hton, ha_panic_function type); -static bool tokudb_flush_logs(handlerton * hton); -static bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * print, enum ha_stat_type); +static int tokudb_end(handlerton* hton, ha_panic_function type); +static bool tokudb_flush_logs(handlerton* hton); +static bool tokudb_show_status( + handlerton* hton, + THD* thd, + stat_print_fn* print, + enum ha_stat_type); #if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL -static void tokudb_handle_fatal_signal(handlerton *hton, THD *thd, int sig); +static void tokudb_handle_fatal_signal(handlerton* hton, THD* thd, int sig); #endif -static int tokudb_close_connection(handlerton * hton, THD * thd); -static int tokudb_commit(handlerton * hton, THD * thd, bool all); -static int tokudb_rollback(handlerton * hton, THD * thd, bool all); +static int tokudb_close_connection(handlerton* hton, THD* thd); +static int tokudb_commit(handlerton* hton, THD* thd, bool all); +static int tokudb_rollback(handlerton* hton, THD* thd, bool all); #if TOKU_INCLUDE_XA static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all); -static int tokudb_xa_recover(handlerton* hton, XID* xid_list, uint len); +static int tokudb_xa_recover(handlerton* hton, XID* xid_list, uint len); static int tokudb_commit_by_xid(handlerton* hton, XID* xid); -static int tokudb_rollback_by_xid(handlerton* hton, XID* xid); +static int tokudb_rollback_by_xid(handlerton* hton, XID* xid); #endif -static int tokudb_rollback_to_savepoint(handlerton * hton, THD * thd, void *savepoint); -static int tokudb_savepoint(handlerton * hton, THD * thd, void *savepoint); -static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoint); +static int tokudb_rollback_to_savepoint( + handlerton* hton, + THD* thd, + void* savepoint); +static int tokudb_savepoint(handlerton* hton, THD* thd, void* savepoint); +static int tokudb_release_savepoint( + handlerton* hton, + THD* thd, + void* savepoint); #if 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199 static int tokudb_discover_table(handlerton *hton, THD* thd, TABLE_SHARE *ts); -static int tokudb_discover_table_existence(handlerton *hton, const char *db, const char *name); +static int tokudb_discover_table_existence( + handlerton* hton, + const char* db, + const char* name); #endif -static int tokudb_discover(handlerton *hton, THD* thd, const char *db, const char *name, uchar **frmblob, size_t *frmlen); -static int tokudb_discover2(handlerton *hton, THD* thd, const char *db, const char *name, bool translate_name, uchar **frmblob, size_t *frmlen); -static int tokudb_discover3(handlerton *hton, THD* thd, const char *db, const char *name, char *path, uchar **frmblob, size_t *frmlen); -handlerton *tokudb_hton; +static int tokudb_discover( + handlerton* hton, + THD* thd, + const char* db, + const char* name, + uchar** frmblob, + size_t* frmlen); +static int tokudb_discover2( + handlerton* hton, + THD* thd, + const char* db, + const char* name, + bool translate_name, + uchar** frmblob, + size_t* frmlen); +static int tokudb_discover3( + handlerton* hton, + THD* thd, + const char* db, + const char* name, + char* path, + uchar** frmblob, + size_t* frmlen); +handlerton* tokudb_hton; -const char *ha_tokudb_ext = ".tokudb"; -char *tokudb_data_dir; -ulong tokudb_debug; -DB_ENV *db_env; -HASH tokudb_open_tables; -pthread_mutex_t tokudb_mutex; +const char* ha_tokudb_ext = ".tokudb"; +DB_ENV* db_env; #if TOKU_THDVAR_MEMALLOC_BUG -static pthread_mutex_t tokudb_map_mutex; +static tokudb::thread::mutex_t tokudb_map_mutex; static TREE tokudb_map; struct tokudb_map_pair { - THD *thd; + THD* thd; char *last_lock_timeout; }; #if 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599 static int tokudb_map_pair_cmp(void *custom_arg, const void *a, const void *b) { #else -static int tokudb_map_pair_cmp(const void *custom_arg, const void *a, const void *b) { +static int tokudb_map_pair_cmp( + const void* custom_arg, + const void* a, + const void* b) { #endif + const struct tokudb_map_pair *a_key = (const struct tokudb_map_pair *) a; const struct tokudb_map_pair *b_key = (const struct tokudb_map_pair *) b; if (a_key->thd < b_key->thd) @@ -142,30 +135,41 @@ static int tokudb_map_pair_cmp(const void *custom_arg, const void *a, const void }; #endif -#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL -static my_bool tokudb_gdb_on_fatal; -static char *tokudb_gdb_path; -#endif - static PARTITIONED_COUNTER tokudb_primary_key_bytes_inserted; void toku_hton_update_primary_key_bytes_inserted(uint64_t row_size) { increment_partitioned_counter(tokudb_primary_key_bytes_inserted, row_size); } -static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid); -static ulong tokudb_cleaner_period; -static ulong tokudb_cleaner_iterations; +static void tokudb_lock_timeout_callback( + DB* db, + uint64_t requesting_txnid, + const DBT* left_key, + const DBT* right_key, + uint64_t blocking_txnid); #define ASSERT_MSGLEN 1024 -void toku_hton_assert_fail(const char* expr_as_string, const char * fun, const char * file, int line, int caller_errno) { +void toku_hton_assert_fail( + const char* expr_as_string, + const char* fun, + const char* file, + int line, + int caller_errno) { + char msg[ASSERT_MSGLEN]; if (db_env) { snprintf(msg, ASSERT_MSGLEN, "Handlerton: %s ", expr_as_string); db_env->crash(db_env, msg, fun, file, line,caller_errno); - } - else { - snprintf(msg, ASSERT_MSGLEN, "Handlerton assertion failed, no env, %s, %d, %s, %s (errno=%d)\n", file, line, fun, expr_as_string, caller_errno); + } else { + snprintf( + msg, + ASSERT_MSGLEN, + "Handlerton assertion failed, no env, %s, %d, %s, %s (errno=%d)\n", + file, + line, + fun, + expr_as_string, + caller_errno); perror(msg); fflush(stderr); } @@ -184,36 +188,11 @@ static uint32_t tokudb_env_flags = 0; // static uint32_t tokudb_lock_type = DB_LOCK_DEFAULT; // static ulong tokudb_log_buffer_size = 0; // static ulong tokudb_log_file_size = 0; -static my_bool tokudb_directio = FALSE; -static my_bool tokudb_compress_buffers_before_eviction = TRUE; -static my_bool tokudb_checkpoint_on_flush_logs = FALSE; -static ulonglong tokudb_cache_size = 0; -static uint32_t tokudb_client_pool_threads = 0; -static uint32_t tokudb_cachetable_pool_threads = 0; -static uint32_t tokudb_checkpoint_pool_threads = 0; -static ulonglong tokudb_max_lock_memory = 0; -static my_bool tokudb_enable_partial_eviction = TRUE; -static char *tokudb_home; -static char *tokudb_tmp_dir; -static char *tokudb_log_dir; +static char* tokudb_home; // static long tokudb_lock_scan_time = 0; // static ulong tokudb_region_size = 0; // static ulong tokudb_cache_parts = 1; -const char *tokudb_hton_name = "TokuDB"; -static uint32_t tokudb_checkpointing_period; -static uint32_t tokudb_fsync_log_period; -uint32_t tokudb_write_status_frequency; -uint32_t tokudb_read_status_frequency; - -#ifdef TOKUDB_VERSION -#define tokudb_stringify_2(x) #x -#define tokudb_stringify(x) tokudb_stringify_2(x) -#define TOKUDB_VERSION_STR tokudb_stringify(TOKUDB_VERSION) -#else -#define TOKUDB_VERSION_STR NULL -#endif -char *tokudb_version = (char *) TOKUDB_VERSION_STR; -static int tokudb_fs_reserve_percent; // file system reserve as a percentage of total disk space +const char* tokudb_hton_name = "TokuDB"; #if defined(_WIN32) extern "C" { @@ -226,18 +205,8 @@ extern "C" { // Since we don't have static initializers for the opaque rwlock type, // use constructor and destructor functions to create and destroy // the lock before and after main(), respectively. -static int tokudb_hton_initialized; -static rw_lock_t tokudb_hton_initialized_lock; - -static void create_tokudb_hton_intialized_lock(void) __attribute__((constructor)); -static void create_tokudb_hton_intialized_lock(void) { - my_rwlock_init(&tokudb_hton_initialized_lock, 0); -} - -static void destroy_tokudb_hton_initialized_lock(void) __attribute__((destructor)); -static void destroy_tokudb_hton_initialized_lock(void) { - rwlock_destroy(&tokudb_hton_initialized_lock); -} +int tokudb_hton_initialized; +tokudb::thread::rwlock_t tokudb_hton_initialized_lock; static SHOW_VAR *toku_global_status_variables = NULL; static uint64_t toku_global_status_max_rows; @@ -266,7 +235,10 @@ static void handle_ydb_error(int error) { sql_print_error("************************************************************"); break; case TOKUDB_UPGRADE_FAILURE: - sql_print_error("%s upgrade failed. A clean shutdown of the previous version is required.", tokudb_hton_name); + sql_print_error( + "%s upgrade failed. A clean shutdown of the previous version is " + "required.", + tokudb_hton_name); break; default: sql_print_error("%s unknown error %d", tokudb_hton_name, error); @@ -289,41 +261,49 @@ static int tokudb_init_func(void *p) { int r; // 3938: lock the handlerton's initialized status flag for writing - r = rw_wrlock(&tokudb_hton_initialized_lock); - assert(r == 0); + tokudb_hton_initialized_lock.lock_write(); db_env = NULL; tokudb_hton = (handlerton *) p; -#if TOKUDB_CHECK_JEMALLOC - if (tokudb_check_jemalloc) { - typedef int (*mallctl_type)(const char *, void *, size_t *, void *, size_t); + if (tokudb::sysvars::check_jemalloc) { + typedef int (*mallctl_type)( + const char*, + void*, + size_t*, + void*, + size_t); mallctl_type mallctl_func; mallctl_func= (mallctl_type)dlsym(RTLD_DEFAULT, "mallctl"); if (!mallctl_func) { - sql_print_error("%s is not initialized because jemalloc is not loaded", tokudb_hton_name); + sql_print_error( + "%s is not initialized because jemalloc is not loaded", + tokudb_hton_name); goto error; } char *ver; - size_t len= sizeof(ver); + size_t len = sizeof(ver); mallctl_func("version", &ver, &len, NULL, 0); /* jemalloc 2.2.5 crashes mysql-test */ if (strcmp(ver, "2.3.") < 0) { - sql_print_error("%s is not initialized because jemalloc is older than 2.3.0", tokudb_hton_name); + sql_print_error( + "%s is not initialized because jemalloc is older than 2.3.0", + tokudb_hton_name); goto error; } - } -#endif r = tokudb_set_product_name(); if (r) { - sql_print_error("%s can not set product name error %d", tokudb_hton_name, r); + sql_print_error( + "%s can not set product name error %d", + tokudb_hton_name, + r); goto error; } - tokudb_pthread_mutex_init(&tokudb_mutex, MY_MUTEX_INIT_FAST); - (void) my_hash_init(&tokudb_open_tables, table_alias_charset, 32, 0, 0, (my_hash_get_key) tokudb_get_key, 0, 0); + TOKUDB_SHARE::static_init(); + tokudb::background::initialize(); tokudb_hton->state = SHOW_OPTION_YES; // tokudb_hton->flags= HTON_CAN_RECREATE; // QQQ this came from skeleton @@ -383,8 +363,8 @@ static int tokudb_init_func(void *p) { #endif #if TOKU_INCLUDE_OPTION_STRUCTS - tokudb_hton->table_options = tokudb_table_options; - tokudb_hton->index_options = tokudb_index_options; + tokudb_hton->table_options = tokudb::sysvars::tokudb_table_options; + tokudb_hton->index_options = tokudb::sysvars::tokudb_index_options; #endif if (!tokudb_home) @@ -400,8 +380,11 @@ static int tokudb_init_func(void *p) { DBUG_PRINT("info", ("tokudb_env_flags: 0x%x\n", tokudb_env_flags)); r = db_env->set_flags(db_env, tokudb_env_flags, 1); if (r) { // QQQ - if (tokudb_debug & TOKUDB_DEBUG_INIT) - TOKUDB_TRACE("WARNING: flags=%x r=%d", tokudb_env_flags, r); + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_INIT, + "WARNING: flags=%x r=%d", + tokudb_env_flags, + r); // goto error; } @@ -409,6 +392,16 @@ static int tokudb_init_func(void *p) { db_env->set_errcall(db_env, tokudb_print_error); db_env->set_errpfx(db_env, tokudb_hton_name); + // Handle deprecated options + if (tokudb::sysvars::pk_insert_mode(NULL) != 1) { + TOKUDB_TRACE("Using tokudb_pk_insert_mode is deprecated and the " + "parameter may be removed in future releases. " + "tokudb_pk_insert_mode=0 is now forbidden. " + "See documentation and release notes for details"); + if (tokudb::sysvars::pk_insert_mode(NULL) < 1) + tokudb::sysvars::set_pk_insert_mode(NULL, 1); + } + // // set default comparison functions // @@ -419,8 +412,8 @@ static int tokudb_init_func(void *p) { } { - char *tmp_dir = tokudb_tmp_dir; - char *data_dir = tokudb_data_dir; + char* tmp_dir = tokudb::sysvars::tmp_dir; + char* data_dir = tokudb::sysvars::data_dir; if (data_dir == 0) { data_dir = mysql_data_home; } @@ -433,36 +426,48 @@ static int tokudb_init_func(void *p) { db_env->set_tmp_dir(db_env, tmp_dir); } - if (tokudb_log_dir) { - DBUG_PRINT("info", ("tokudb_log_dir: %s\n", tokudb_log_dir)); - db_env->set_lg_dir(db_env, tokudb_log_dir); + if (tokudb::sysvars::log_dir) { + DBUG_PRINT("info", ("tokudb_log_dir: %s\n", tokudb::sysvars::log_dir)); + db_env->set_lg_dir(db_env, tokudb::sysvars::log_dir); } - // config the cache table size to min(1/2 of physical memory, 1/8 of the process address space) - if (tokudb_cache_size == 0) { + // config the cache table size to min(1/2 of physical memory, 1/8 of the + // process address space) + if (tokudb::sysvars::cache_size == 0) { uint64_t physmem, maxdata; physmem = toku_os_get_phys_memory_size(); - tokudb_cache_size = physmem / 2; + tokudb::sysvars::cache_size = physmem / 2; r = toku_os_get_max_process_data_size(&maxdata); if (r == 0) { - if (tokudb_cache_size > maxdata / 8) - tokudb_cache_size = maxdata / 8; + if (tokudb::sysvars::cache_size > maxdata / 8) + tokudb::sysvars::cache_size = maxdata / 8; } } - if (tokudb_cache_size) { - DBUG_PRINT("info", ("tokudb_cache_size: %lld\n", tokudb_cache_size)); - r = db_env->set_cachesize(db_env, (uint32_t)(tokudb_cache_size >> 30), (uint32_t)(tokudb_cache_size % (1024L * 1024L * 1024L)), 1); + if (tokudb::sysvars::cache_size) { + DBUG_PRINT( + "info", + ("tokudb_cache_size: %lld\n", tokudb::sysvars::cache_size)); + r = db_env->set_cachesize( + db_env, + (uint32_t)(tokudb::sysvars::cache_size >> 30), + (uint32_t)(tokudb::sysvars::cache_size % + (1024L * 1024L * 1024L)), 1); if (r) { DBUG_PRINT("info", ("set_cachesize %d\n", r)); goto error; } } - if (tokudb_max_lock_memory == 0) { - tokudb_max_lock_memory = tokudb_cache_size/8; + if (tokudb::sysvars::max_lock_memory == 0) { + tokudb::sysvars::max_lock_memory = tokudb::sysvars::cache_size/8; } - if (tokudb_max_lock_memory) { - DBUG_PRINT("info", ("tokudb_max_lock_memory: %lld\n", tokudb_max_lock_memory)); - r = db_env->set_lk_max_memory(db_env, tokudb_max_lock_memory); + if (tokudb::sysvars::max_lock_memory) { + DBUG_PRINT( + "info", + ("tokudb_max_lock_memory: %lld\n", + tokudb::sysvars::max_lock_memory)); + r = db_env->set_lk_max_memory( + db_env, + tokudb::sysvars::max_lock_memory); if (r) { DBUG_PRINT("info", ("set_lk_max_memory %d\n", r)); goto error; @@ -471,51 +476,75 @@ static int tokudb_init_func(void *p) { uint32_t gbytes, bytes; int parts; r = db_env->get_cachesize(db_env, &gbytes, &bytes, &parts); - if (tokudb_debug & TOKUDB_DEBUG_INIT) - TOKUDB_TRACE("tokudb_cache_size=%lld r=%d", ((unsigned long long) gbytes << 30) + bytes, r); + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_INIT, + "tokudb_cache_size=%lld r=%d", + ((unsigned long long) gbytes << 30) + bytes, + r); - r = db_env->set_client_pool_threads(db_env, tokudb_client_pool_threads); + r = db_env->set_client_pool_threads( + db_env, + tokudb::sysvars::client_pool_threads); if (r) { DBUG_PRINT("info", ("set_client_pool_threads %d\n", r)); goto error; } - r = db_env->set_cachetable_pool_threads(db_env, tokudb_cachetable_pool_threads); + r = db_env->set_cachetable_pool_threads( + db_env, + tokudb::sysvars::cachetable_pool_threads); if (r) { DBUG_PRINT("info", ("set_cachetable_pool_threads %d\n", r)); goto error; } - r = db_env->set_checkpoint_pool_threads(db_env, tokudb_checkpoint_pool_threads); + r = db_env->set_checkpoint_pool_threads( + db_env, + tokudb::sysvars::checkpoint_pool_threads); if (r) { DBUG_PRINT("info", ("set_checkpoint_pool_threads %d\n", r)); goto error; } if (db_env->set_redzone) { - r = db_env->set_redzone(db_env, tokudb_fs_reserve_percent); - if (tokudb_debug & TOKUDB_DEBUG_INIT) - TOKUDB_TRACE("set_redzone r=%d", r); + r = db_env->set_redzone(db_env, tokudb::sysvars::fs_reserve_percent); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_INIT, "set_redzone r=%d", r); } + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_INIT, + "env open:flags=%x", + tokudb_init_flags); - if (tokudb_debug & TOKUDB_DEBUG_INIT) - TOKUDB_TRACE("env open:flags=%x", tokudb_init_flags); + r = db_env->set_generate_row_callback_for_put(db_env, generate_row_for_put); + assert_always(r == 0); + + r = db_env->set_generate_row_callback_for_del(db_env, generate_row_for_del); + assert_always(r == 0); - r = db_env->set_generate_row_callback_for_put(db_env,generate_row_for_put); - assert(r == 0); - r = db_env->set_generate_row_callback_for_del(db_env,generate_row_for_del); - assert(r == 0); db_env->set_update(db_env, tokudb_update_fun); - db_env_set_direct_io(tokudb_directio == TRUE); - db_env_set_compress_buffers_before_eviction(tokudb_compress_buffers_before_eviction == TRUE); - db_env->change_fsync_log_period(db_env, tokudb_fsync_log_period); + + db_env_set_direct_io(tokudb::sysvars::directio == TRUE); + + db_env_set_compress_buffers_before_eviction( + tokudb::sysvars::compress_buffers_before_eviction == TRUE); + + db_env->change_fsync_log_period(db_env, tokudb::sysvars::fsync_log_period); + db_env->set_lock_timeout_callback(db_env, tokudb_lock_timeout_callback); - db_env->set_loader_memory_size(db_env, tokudb_get_loader_memory_size_callback); - r = db_env->open(db_env, tokudb_home, tokudb_init_flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); + db_env->set_loader_memory_size( + db_env, + tokudb_get_loader_memory_size_callback); - if (tokudb_debug & TOKUDB_DEBUG_INIT) - TOKUDB_TRACE("env opened:return=%d", r); + db_env->set_check_thp(db_env, tokudb::sysvars::check_jemalloc); + + r = db_env->open( + db_env, + tokudb_home, + tokudb_init_flags, + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); + + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_INIT, "env opened:return=%d", r); if (r) { DBUG_PRINT("info", ("env->open %d", r)); @@ -523,72 +552,106 @@ static int tokudb_init_func(void *p) { goto error; } - r = db_env->checkpointing_set_period(db_env, tokudb_checkpointing_period); - assert(r == 0); - r = db_env->cleaner_set_period(db_env, tokudb_cleaner_period); - assert(r == 0); - r = db_env->cleaner_set_iterations(db_env, tokudb_cleaner_iterations); - assert(r == 0); + r = db_env->checkpointing_set_period( + db_env, + tokudb::sysvars::checkpointing_period); + assert_always(r == 0); - r = db_env->set_lock_timeout(db_env, DEFAULT_TOKUDB_LOCK_TIMEOUT, tokudb_get_lock_wait_time_callback); - assert(r == 0); + r = db_env->cleaner_set_period(db_env, tokudb::sysvars::cleaner_period); + assert_always(r == 0); - r = db_env->evictor_set_enable_partial_eviction(db_env, - tokudb_enable_partial_eviction); - assert(r == 0); + r = db_env->cleaner_set_iterations( + db_env, + tokudb::sysvars::cleaner_iterations); + assert_always(r == 0); - db_env->set_killed_callback(db_env, DEFAULT_TOKUDB_KILLED_TIME, tokudb_get_killed_time_callback, tokudb_killed_callback); + r = db_env->set_lock_timeout( + db_env, + DEFAULT_TOKUDB_LOCK_TIMEOUT, + tokudb_get_lock_wait_time_callback); + assert_always(r == 0); - r = db_env->get_engine_status_num_rows (db_env, &toku_global_status_max_rows); - assert(r == 0); + r = db_env->evictor_set_enable_partial_eviction( + db_env, + tokudb::sysvars::enable_partial_eviction); + assert_always(r == 0); + + db_env->set_killed_callback( + db_env, + DEFAULT_TOKUDB_KILLED_TIME, + tokudb_get_killed_time_callback, + tokudb_killed_callback); + + r = db_env->get_engine_status_num_rows( + db_env, + &toku_global_status_max_rows); + assert_always(r == 0); { - const myf mem_flags = MY_FAE|MY_WME|MY_ZEROFILL|MY_ALLOW_ZERO_PTR|MY_FREE_ON_ERROR; - toku_global_status_variables = (SHOW_VAR*)tokudb_my_malloc(sizeof(*toku_global_status_variables)*toku_global_status_max_rows, mem_flags); - toku_global_status_rows = (TOKU_ENGINE_STATUS_ROW_S*)tokudb_my_malloc(sizeof(*toku_global_status_rows)*toku_global_status_max_rows, mem_flags); + const myf mem_flags = + MY_FAE|MY_WME|MY_ZEROFILL|MY_ALLOW_ZERO_PTR|MY_FREE_ON_ERROR; + toku_global_status_variables = + (SHOW_VAR*)tokudb::memory::malloc( + sizeof(*toku_global_status_variables) * + toku_global_status_max_rows, + mem_flags); + toku_global_status_rows = + (TOKU_ENGINE_STATUS_ROW_S*)tokudb::memory::malloc( + sizeof(*toku_global_status_rows)* + toku_global_status_max_rows, + mem_flags); } tokudb_primary_key_bytes_inserted = create_partitioned_counter(); #if TOKU_THDVAR_MEMALLOC_BUG - tokudb_pthread_mutex_init(&tokudb_map_mutex, MY_MUTEX_INIT_FAST); init_tree(&tokudb_map, 0, 0, 0, tokudb_map_pair_cmp, true, NULL, NULL); #endif + if (tokudb::sysvars::strip_frm_data) { + r = tokudb::metadata::strip_frm_data(db_env); + if (r) { + DBUG_PRINT("info", ("env->open %d", r)); + handle_ydb_error(r); + goto error; + } + } + //3938: succeeded, set the init status flag and unlock tokudb_hton_initialized = 1; - rw_unlock(&tokudb_hton_initialized_lock); + tokudb_hton_initialized_lock.unlock(); DBUG_RETURN(false); error: if (db_env) { int rr= db_env->close(db_env, 0); - assert(rr==0); + assert_always(rr==0); db_env = 0; } // 3938: failed to initialized, drop the flag and lock tokudb_hton_initialized = 0; - rw_unlock(&tokudb_hton_initialized_lock); + tokudb_hton_initialized_lock.unlock(); DBUG_RETURN(true); } -static int tokudb_done_func(void *p) { +static int tokudb_done_func(void* p) { TOKUDB_DBUG_ENTER(""); - tokudb_my_free(toku_global_status_variables); + tokudb::memory::free(toku_global_status_variables); toku_global_status_variables = NULL; - tokudb_my_free(toku_global_status_rows); + tokudb::memory::free(toku_global_status_rows); toku_global_status_rows = NULL; - my_hash_free(&tokudb_open_tables); - tokudb_pthread_mutex_destroy(&tokudb_mutex); TOKUDB_DBUG_RETURN(0); } -static handler *tokudb_create_handler(handlerton * hton, TABLE_SHARE * table, MEM_ROOT * mem_root) { +static handler* tokudb_create_handler( + handlerton* hton, + TABLE_SHARE* table, + MEM_ROOT* mem_root) { return new(mem_root) ha_tokudb(hton, table); } -int tokudb_end(handlerton * hton, ha_panic_function type) { +int tokudb_end(handlerton* hton, ha_panic_function type) { TOKUDB_DBUG_ENTER(""); int error = 0; @@ -596,41 +659,59 @@ int tokudb_end(handlerton * hton, ha_panic_function type) { // initialized. grab a writer lock for the duration of the // call, so we can drop the flag and destroy the mutexes // in isolation. - rw_wrlock(&tokudb_hton_initialized_lock); - assert(tokudb_hton_initialized); + tokudb_hton_initialized_lock.lock_write(); + assert_always(tokudb_hton_initialized); + + tokudb::background::destroy(); + TOKUDB_SHARE::static_destroy(); if (db_env) { if (tokudb_init_flags & DB_INIT_LOG) tokudb_cleanup_log_files(); - long total_prepared = 0; // count the total number of prepared txn's that we discard + + // count the total number of prepared txn's that we discard + long total_prepared = 0; #if TOKU_INCLUDE_XA + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "begin XA cleanup"); while (1) { // get xid's const long n_xid = 1; TOKU_XA_XID xids[n_xid]; long n_prepared = 0; - error = db_env->txn_xa_recover(db_env, xids, n_xid, &n_prepared, total_prepared == 0 ? DB_FIRST : DB_NEXT); - assert(error == 0); + error = db_env->txn_xa_recover( + db_env, + xids, + n_xid, + &n_prepared, + total_prepared == 0 ? DB_FIRST : DB_NEXT); + assert_always(error == 0); if (n_prepared == 0) break; // discard xid's for (long i = 0; i < n_xid; i++) { DB_TXN *txn = NULL; error = db_env->get_txn_from_xid(db_env, &xids[i], &txn); - assert(error == 0); + assert_always(error == 0); error = txn->discard(txn, 0); - assert(error == 0); + assert_always(error == 0); } total_prepared += n_prepared; } + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "end XA cleanup"); #endif - error = db_env->close(db_env, total_prepared > 0 ? TOKUFT_DIRTY_SHUTDOWN : 0); + error = db_env->close( + db_env, + total_prepared > 0 ? TOKUFT_DIRTY_SHUTDOWN : 0); #if TOKU_INCLUDE_XA if (error != 0 && total_prepared > 0) { - sql_print_error("%s: %ld prepared txns still live, please shutdown, error %d", tokudb_hton_name, total_prepared, error); + sql_print_error( + "%s: %ld prepared txns still live, please shutdown, error %d", + tokudb_hton_name, + total_prepared, + error); } else #endif - assert(error == 0); + assert_always(error == 0); db_env = NULL; } @@ -640,33 +721,34 @@ int tokudb_end(handlerton * hton, ha_panic_function type) { } #if TOKU_THDVAR_MEMALLOC_BUG - tokudb_pthread_mutex_destroy(&tokudb_map_mutex); delete_tree(&tokudb_map); #endif // 3938: drop the initialized flag and unlock tokudb_hton_initialized = 0; - rw_unlock(&tokudb_hton_initialized_lock); + tokudb_hton_initialized_lock.unlock(); TOKUDB_DBUG_RETURN(error); } -static int tokudb_close_connection(handlerton * hton, THD * thd) { +static int tokudb_close_connection(handlerton* hton, THD* thd) { int error = 0; - tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); if (trx && trx->checkpoint_lock_taken) { error = db_env->checkpointing_resume(db_env); } - tokudb_my_free(trx); + tokudb::memory::free(trx); #if TOKU_THDVAR_MEMALLOC_BUG - tokudb_pthread_mutex_lock(&tokudb_map_mutex); + tokudb_map_mutex.lock(); struct tokudb_map_pair key = { thd, NULL }; - struct tokudb_map_pair *found_key = (struct tokudb_map_pair *) tree_search(&tokudb_map, &key, NULL); + struct tokudb_map_pair* found_key = + (struct tokudb_map_pair*) tree_search(&tokudb_map, &key, NULL); + if (found_key) { - tokudb_my_free(found_key->last_lock_timeout); - tree_delete(&tokudb_map, found_key, sizeof *found_key, NULL); + tokudb::memory::free(found_key->last_lock_timeout); + tree_delete(&tokudb_map, found_key, sizeof(*found_key), NULL); } - tokudb_pthread_mutex_unlock(&tokudb_map_mutex); + tokudb_map_mutex.unlock(); #endif return error; } @@ -676,7 +758,7 @@ bool tokudb_flush_logs(handlerton * hton) { int error; bool result = 0; - if (tokudb_checkpoint_on_flush_logs) { + if (tokudb::sysvars::checkpoint_on_flush_logs) { // // take the checkpoint // @@ -689,7 +771,7 @@ bool tokudb_flush_logs(handlerton * hton) { } else { error = db_env->log_flush(db_env, NULL); - assert(error == 0); + assert_always(error == 0); } result = 0; @@ -705,14 +787,14 @@ typedef struct txn_progress_info { static void txn_progress_func(TOKU_TXN_PROGRESS progress, void* extra) { TXN_PROGRESS_INFO progress_info = (TXN_PROGRESS_INFO)extra; - int r = sprintf(progress_info->status, - "%sprocessing %s of transaction, %" PRId64 " out of %" PRId64, - progress->stalled_on_checkpoint ? "Writing committed changes to disk, " : "", - progress->is_commit ? "commit" : "abort", - progress->entries_processed, - progress->entries_total - ); - assert(r >= 0); + int r = sprintf( + progress_info->status, + "%sprocessing %s of transaction, %" PRId64 " out of %" PRId64, + progress->stalled_on_checkpoint ? "Writing committed changes to disk, " : "", + progress->is_commit ? "commit" : "abort", + progress->entries_processed, + progress->entries_total); + assert_always(r >= 0); thd_proc_info(progress_info->thd, progress_info->status); } @@ -722,9 +804,13 @@ static void commit_txn_with_progress(DB_TXN* txn, uint32_t flags, THD* thd) { info.thd = thd; int r = txn->commit_with_progress(txn, flags, txn_progress_func, &info); if (r != 0) { - sql_print_error("%s: tried committing transaction %p and got error code %d", tokudb_hton_name, txn, r); + sql_print_error( + "%s: tried committing transaction %p and got error code %d", + tokudb_hton_name, + txn, + r); } - assert(r == 0); + assert_always(r == 0); thd_proc_info(thd, orig_proc_info); } @@ -734,9 +820,13 @@ static void abort_txn_with_progress(DB_TXN* txn, THD* thd) { info.thd = thd; int r = txn->abort_with_progress(txn, txn_progress_func, &info); if (r != 0) { - sql_print_error("%s: tried aborting transaction %p and got error code %d", tokudb_hton_name, txn, r); + sql_print_error( + "%s: tried aborting transaction %p and got error code %d", + tokudb_hton_name, + txn, + r); } - assert(r == 0); + assert_always(r == 0); thd_proc_info(thd, orig_proc_info); } @@ -750,11 +840,12 @@ static void tokudb_cleanup_handlers(tokudb_trx_data *trx, DB_TXN *txn) { } #if MYSQL_VERSION_ID >= 50600 -extern "C" enum durability_properties thd_get_durability_property(const MYSQL_THD thd); +extern "C" enum durability_properties thd_get_durability_property( + const MYSQL_THD thd); #endif // Determine if an fsync is used when a transaction is committed. -static bool tokudb_sync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn) { +static bool tokudb_sync_on_commit(THD* thd, tokudb_trx_data* trx, DB_TXN* txn) { #if MYSQL_VERSION_ID >= 50600 // Check the client durability property which is set during 2PC if (thd_get_durability_property(thd) == HA_IGNORE_DURABILITY) @@ -765,9 +856,9 @@ static bool tokudb_sync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn) { if (txn->is_prepared(txn) && mysql_bin_log.is_open()) return false; #endif - if (tokudb_fsync_log_period > 0) + if (tokudb::sysvars::fsync_log_period > 0) return false; - return THDVAR(thd, commit_sync) != 0; + return tokudb::sysvars::commit_sync(thd) != 0; } static int tokudb_commit(handlerton * hton, THD * thd, bool all) { @@ -777,10 +868,14 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) { DB_TXN **txn = all ? &trx->all : &trx->stmt; DB_TXN *this_txn = *txn; if (this_txn) { - uint32_t syncflag = tokudb_sync_on_commit(thd, trx, this_txn) ? 0 : DB_TXN_NOSYNC; - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("commit trx %u txn %p syncflag %u", all, this_txn, syncflag); - } + uint32_t syncflag = + tokudb_sync_on_commit(thd, trx, this_txn) ? 0 : DB_TXN_NOSYNC; + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "commit trx %u txn %p syncflag %u", + all, + this_txn, + syncflag); // test hook to induce a crash on a debug build DBUG_EXECUTE_IF("tokudb_crash_commit_before", DBUG_SUICIDE();); tokudb_cleanup_handlers(trx, this_txn); @@ -792,9 +887,8 @@ static int tokudb_commit(handlerton * hton, THD * thd, bool all) { if (this_txn == trx->sp_level || trx->all == NULL) { trx->sp_level = NULL; } - } - else if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("nothing to commit %d", all); + } else { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "nothing to commit %d", all); } reset_stmt_progress(&trx->stmt_progress); TOKUDB_DBUG_RETURN(0); @@ -807,9 +901,11 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) { DB_TXN **txn = all ? &trx->all : &trx->stmt; DB_TXN *this_txn = *txn; if (this_txn) { - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("rollback %u txn %p", all, this_txn); - } + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "rollback %u txn %p", + all, + this_txn); tokudb_cleanup_handlers(trx, this_txn); abort_txn_with_progress(this_txn, thd); *txn = NULL; @@ -817,11 +913,8 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) { if (this_txn == trx->sp_level || trx->all == NULL) { trx->sp_level = NULL; } - } - else { - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("abort0"); - } + } else { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "abort0"); } reset_stmt_progress(&trx->stmt_progress); TOKUDB_DBUG_RETURN(0); @@ -829,19 +922,25 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) { #if TOKU_INCLUDE_XA static bool tokudb_sync_on_prepare(void) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); // skip sync of log if fsync log period > 0 - if (tokudb_fsync_log_period > 0) + if (tokudb::sysvars::fsync_log_period > 0) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit"); return false; - else + } else { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit"); return true; + } } static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { TOKUDB_DBUG_ENTER(""); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); int r = 0; // if tokudb_support_xa is disable, just return - if (!THDVAR(thd, support_xa)) { + if (!tokudb::sysvars::support_xa(thd)) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit %d", r); TOKUDB_DBUG_RETURN(r); } @@ -850,9 +949,11 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { DB_TXN* txn = all ? trx->all : trx->stmt; if (txn) { uint32_t syncflag = tokudb_sync_on_prepare() ? 0 : DB_TXN_NOSYNC; - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("doing txn prepare:%d:%p", all, txn); - } + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_XA, + "doing txn prepare:%d:%p", + all, + txn); // a TOKU_XA_XID is identical to a MYSQL_XID TOKU_XA_XID thd_xid; thd_get_xid(thd, (MYSQL_XID*) &thd_xid); @@ -861,17 +962,19 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { r = txn->xa_prepare(txn, &thd_xid, syncflag); // test hook to induce a crash on a debug build DBUG_EXECUTE_IF("tokudb_crash_prepare_after", DBUG_SUICIDE();); - } - else if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("nothing to prepare %d", all); + } else { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "nothing to prepare %d", all); } + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit %d", r); TOKUDB_DBUG_RETURN(r); } static int tokudb_xa_recover(handlerton* hton, XID* xid_list, uint len) { TOKUDB_DBUG_ENTER(""); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); int r = 0; if (len == 0 || xid_list == NULL) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit %d", 0); TOKUDB_DBUG_RETURN(0); } long num_returned = 0; @@ -880,14 +983,15 @@ static int tokudb_xa_recover(handlerton* hton, XID* xid_list, uint len) { (TOKU_XA_XID*)xid_list, len, &num_returned, - DB_NEXT - ); - assert(r == 0); + DB_NEXT); + assert_always(r == 0); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit %ld", num_returned); TOKUDB_DBUG_RETURN((int)num_returned); } static int tokudb_commit_by_xid(handlerton* hton, XID* xid) { TOKUDB_DBUG_ENTER(""); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); int r = 0; DB_TXN* txn = NULL; TOKU_XA_XID* toku_xid = (TOKU_XA_XID*)xid; @@ -900,11 +1004,13 @@ static int tokudb_commit_by_xid(handlerton* hton, XID* xid) { r = 0; cleanup: + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit %d", r); TOKUDB_DBUG_RETURN(r); } static int tokudb_rollback_by_xid(handlerton* hton, XID* xid) { TOKUDB_DBUG_ENTER(""); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); int r = 0; DB_TXN* txn = NULL; TOKU_XA_XID* toku_xid = (TOKU_XA_XID*)xid; @@ -917,6 +1023,7 @@ static int tokudb_rollback_by_xid(handlerton* hton, XID* xid) { r = 0; cleanup: + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "exit %d", r); TOKUDB_DBUG_RETURN(r); } @@ -928,43 +1035,55 @@ static int tokudb_savepoint(handlerton * hton, THD * thd, void *savepoint) { SP_INFO save_info = (SP_INFO)savepoint; tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton); if (thd->in_sub_stmt) { - assert(trx->stmt); - error = txn_begin(db_env, trx->sub_sp_level, &(save_info->txn), DB_INHERIT_ISOLATION, thd); + assert_always(trx->stmt); + error = txn_begin( + db_env, + trx->sub_sp_level, + &(save_info->txn), + DB_INHERIT_ISOLATION, + thd); if (error) { goto cleanup; } trx->sub_sp_level = save_info->txn; save_info->in_sub_stmt = true; - } - else { - error = txn_begin(db_env, trx->sp_level, &(save_info->txn), DB_INHERIT_ISOLATION, thd); + } else { + error = txn_begin( + db_env, + trx->sp_level, + &(save_info->txn), + DB_INHERIT_ISOLATION, + thd); if (error) { goto cleanup; } trx->sp_level = save_info->txn; save_info->in_sub_stmt = false; } - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("begin txn %p", save_info->txn); - } + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "begin txn %p", save_info->txn); save_info->trx = trx; error = 0; cleanup: TOKUDB_DBUG_RETURN(error); } -static int tokudb_rollback_to_savepoint(handlerton * hton, THD * thd, void *savepoint) { +static int tokudb_rollback_to_savepoint( + handlerton* hton, + THD* thd, + void* savepoint) { + TOKUDB_DBUG_ENTER("%p", savepoint); int error; SP_INFO save_info = (SP_INFO)savepoint; DB_TXN* parent = NULL; DB_TXN* txn_to_rollback = save_info->txn; - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton); + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, hton); parent = txn_to_rollback->parent; - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("rollback txn %p", txn_to_rollback); - } + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "rollback txn %p", + txn_to_rollback); if (!(error = txn_to_rollback->abort(txn_to_rollback))) { if (save_info->in_sub_stmt) { trx->sub_sp_level = parent; @@ -977,7 +1096,11 @@ static int tokudb_rollback_to_savepoint(handlerton * hton, THD * thd, void *save TOKUDB_DBUG_RETURN(error); } -static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoint) { +static int tokudb_release_savepoint( + handlerton* hton, + THD* thd, + void* savepoint) { + TOKUDB_DBUG_ENTER("%p", savepoint); int error = 0; SP_INFO save_info = (SP_INFO)savepoint; @@ -986,9 +1109,7 @@ static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoin tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton); parent = txn_to_commit->parent; - if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("commit txn %p", txn_to_commit); - } + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "commit txn %p", txn_to_commit); DB_TXN *child = txn_to_commit->get_child(txn_to_commit); if (child == NULL && !(error = txn_to_commit->commit(txn_to_commit, 0))) { if (save_info->in_sub_stmt) { @@ -1006,8 +1127,14 @@ static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoin static int tokudb_discover_table(handlerton *hton, THD* thd, TABLE_SHARE *ts) { uchar *frmblob = 0; size_t frmlen; - int res= tokudb_discover3(hton, thd, ts->db.str, ts->table_name.str, - ts->normalized_path.str, &frmblob, &frmlen); + int res= tokudb_discover3( + hton, + thd, + ts->db.str, + ts->table_name.str, + ts->normalized_path.str, + &frmblob, + &frmlen); if (!res) res= ts->init_from_binary_frm_image(thd, true, frmblob, frmlen); @@ -1016,7 +1143,11 @@ static int tokudb_discover_table(handlerton *hton, THD* thd, TABLE_SHARE *ts) { return res == ENOENT ? HA_ERR_NO_SUCH_TABLE : res; } -static int tokudb_discover_table_existence(handlerton *hton, const char *db, const char *name) { +static int tokudb_discover_table_existence( + handlerton* hton, + const char* db, + const char* name) { + uchar *frmblob = 0; size_t frmlen; int res= tokudb_discover(hton, current_thd, db, name, &frmblob, &frmlen); @@ -1025,19 +1156,46 @@ static int tokudb_discover_table_existence(handlerton *hton, const char *db, con } #endif -static int tokudb_discover(handlerton *hton, THD* thd, const char *db, const char *name, uchar **frmblob, size_t *frmlen) { +static int tokudb_discover( + handlerton* hton, + THD* thd, + const char* db, + const char* name, + uchar** frmblob, + size_t* frmlen) { + return tokudb_discover2(hton, thd, db, name, true, frmblob, frmlen); } -static int tokudb_discover2(handlerton *hton, THD* thd, const char *db, const char *name, bool translate_name, - uchar **frmblob, size_t *frmlen) { +static int tokudb_discover2( + handlerton* hton, + THD* thd, + const char* db, + const char* name, + bool translate_name, + uchar** frmblob, + size_t*frmlen) { + char path[FN_REFLEN + 1]; - build_table_filename(path, sizeof(path) - 1, db, name, "", translate_name ? 0 : FN_IS_TMP); + build_table_filename( + path, + sizeof(path) - 1, + db, + name, + "", + translate_name ? 0 : FN_IS_TMP); return tokudb_discover3(hton, thd, db, name, path, frmblob, frmlen); } -static int tokudb_discover3(handlerton *hton, THD* thd, const char *db, const char *name, char *path, - uchar **frmblob, size_t *frmlen) { +static int tokudb_discover3( + handlerton* hton, + THD* thd, + const char* db, + const char* name, + char* path, + uchar** frmblob, + size_t* frmlen) { + TOKUDB_DBUG_ENTER("%s %s %s", db, name, path); int error; DB* status_db = NULL; @@ -1048,8 +1206,10 @@ static int tokudb_discover3(handlerton *hton, THD* thd, const char *db, const ch bool do_commit = false; #if 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199 - tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); - if (thd_sql_command(thd) == SQLCOM_CREATE_TABLE && trx && trx->sub_sp_level) { + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); + if (thd_sql_command(thd) == SQLCOM_CREATE_TABLE && + trx && + trx->sub_sp_level) { do_commit = false; txn = trx->sub_sp_level; } else { @@ -1075,8 +1235,7 @@ static int tokudb_discover3(handlerton *hton, THD* thd, const char *db, const ch 0, &key, smart_dbt_callback_verify_frm, - &value - ); + &value); if (error) { goto cleanup; } @@ -1092,19 +1251,23 @@ cleanup: if (do_commit && txn) { commit_txn(txn, 0); } - TOKUDB_DBUG_RETURN(error); + TOKUDB_DBUG_RETURN(error); } -#define STATPRINT(legend, val) if (legend != NULL && val != NULL) stat_print(thd, \ - tokudb_hton_name, \ - strlen(tokudb_hton_name), \ - legend, \ - strlen(legend), \ - val, \ - strlen(val)) +#define STATPRINT(legend, val) if (legend != NULL && val != NULL) \ + stat_print(thd, \ + tokudb_hton_name, \ + strlen(tokudb_hton_name), \ + legend, \ + strlen(legend), \ + val, \ + strlen(val)) -extern sys_var *intern_find_sys_var(const char *str, uint length, bool no_error); +extern sys_var* intern_find_sys_var( + const char* str, + uint length, + bool no_error); static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { TOKUDB_DBUG_ENTER(""); @@ -1120,14 +1283,29 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { #if MYSQL_VERSION_ID < 50500 { - sys_var * version = intern_find_sys_var("version", 0, false); - snprintf(buf, bufsiz, "%s", version->value_ptr(thd, (enum_var_type)0, (LEX_STRING*)NULL)); + sys_var* version = intern_find_sys_var("version", 0, false); + snprintf( + buf, + bufsiz, + "%s", + version->value_ptr(thd, + (enum_var_type)0, + (LEX_STRING*)NULL)); STATPRINT("Version", buf); } #endif error = db_env->get_engine_status_num_rows (db_env, &max_rows); TOKU_ENGINE_STATUS_ROW_S mystat[max_rows]; - error = db_env->get_engine_status (db_env, mystat, max_rows, &num_rows, &redzone_state, &panic, panic_string, panic_string_len, TOKU_ENGINE_STATUS); + error = db_env->get_engine_status( + db_env, + mystat, + max_rows, + &num_rows, + &redzone_state, + &panic, + panic_string, + panic_string_len, + TOKU_ENGINE_STATUS); if (strlen(panic_string)) { STATPRINT("Environment panic string", panic_string); @@ -1139,20 +1317,35 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { } if(redzone_state == FS_BLOCKED) { - STATPRINT("*** URGENT WARNING ***", "FILE SYSTEM IS COMPLETELY FULL"); + STATPRINT( + "*** URGENT WARNING ***", "FILE SYSTEM IS COMPLETELY FULL"); snprintf(buf, bufsiz, "FILE SYSTEM IS COMPLETELY FULL"); - } - else if (redzone_state == FS_GREEN) { - snprintf(buf, bufsiz, "more than %d percent of total file system space", 2*tokudb_fs_reserve_percent); - } - else if (redzone_state == FS_YELLOW) { - snprintf(buf, bufsiz, "*** WARNING *** FILE SYSTEM IS GETTING FULL (less than %d percent free)", 2*tokudb_fs_reserve_percent); - } - else if (redzone_state == FS_RED){ - snprintf(buf, bufsiz, "*** WARNING *** FILE SYSTEM IS GETTING VERY FULL (less than %d percent free): INSERTS ARE PROHIBITED", tokudb_fs_reserve_percent); - } - else { - snprintf(buf, bufsiz, "information unavailable, unknown redzone state %d", redzone_state); + } else if (redzone_state == FS_GREEN) { + snprintf( + buf, + bufsiz, + "more than %d percent of total file system space", + 2 * tokudb::sysvars::fs_reserve_percent); + } else if (redzone_state == FS_YELLOW) { + snprintf( + buf, + bufsiz, + "*** WARNING *** FILE SYSTEM IS GETTING FULL (less than %d " + "percent free)", + 2 * tokudb::sysvars::fs_reserve_percent); + } else if (redzone_state == FS_RED){ + snprintf( + buf, + bufsiz, + "*** WARNING *** FILE SYSTEM IS GETTING VERY FULL (less than " + "%d percent free): INSERTS ARE PROHIBITED", + tokudb::sysvars::fs_reserve_percent); + } else { + snprintf( + buf, + bufsiz, + "information unavailable, unknown redzone state %d", + redzone_state); } STATPRINT ("disk free space", buf); @@ -1179,7 +1372,8 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { break; } case PARCOUNT: { - uint64_t v = read_partitioned_counter(mystat[row].value.parcount); + uint64_t v = read_partitioned_counter( + mystat[row].value.parcount); snprintf(buf, bufsiz, "%" PRIu64, v); break; } @@ -1187,12 +1381,17 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { snprintf(buf, bufsiz, "%.6f", mystat[row].value.dnum); break; default: - snprintf(buf, bufsiz, "UNKNOWN STATUS TYPE: %d", mystat[row].type); - break; + snprintf( + buf, + bufsiz, + "UNKNOWN STATUS TYPE: %d", + mystat[row].type); + break; } STATPRINT(mystat[row].legend, buf); } - uint64_t bytes_inserted = read_partitioned_counter(tokudb_primary_key_bytes_inserted); + uint64_t bytes_inserted = read_partitioned_counter( + tokudb_primary_key_bytes_inserted); snprintf(buf, bufsiz, "%" PRIu64, bytes_inserted); STATPRINT("handlerton: primary key bytes inserted", buf); } @@ -1200,16 +1399,16 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { TOKUDB_DBUG_RETURN(error); } -static void tokudb_checkpoint_lock(THD * thd) { +void tokudb_checkpoint_lock(THD * thd) { int error; const char *old_proc_info; - tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); if (!trx) { error = create_tokudb_trx_data_instance(&trx); // // can only fail due to memory allocation, so ok to assert // - assert(!error); + assert_always(!error); thd_set_ha_data(thd, tokudb_hton, trx); } @@ -1223,7 +1422,7 @@ static void tokudb_checkpoint_lock(THD * thd) { old_proc_info = tokudb_thd_get_proc_info(thd); thd_proc_info(thd, "Trying to grab checkpointing lock."); error = db_env->checkpointing_postpone(db_env); - assert(!error); + assert_always(!error); thd_proc_info(thd, old_proc_info); trx->checkpoint_lock_taken = true; @@ -1231,10 +1430,10 @@ cleanup: return; } -static void tokudb_checkpoint_unlock(THD * thd) { +void tokudb_checkpoint_unlock(THD * thd) { int error; const char *old_proc_info; - tokudb_trx_data* trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); + tokudb_trx_data* trx = (tokudb_trx_data*)thd_get_ha_data(thd, tokudb_hton); if (!trx) { error = 0; goto cleanup; @@ -1249,7 +1448,7 @@ static void tokudb_checkpoint_unlock(THD * thd) { old_proc_info = tokudb_thd_get_proc_info(thd); thd_proc_info(thd, "Trying to release checkpointing lock."); error = db_env->checkpointing_resume(db_env); - assert(!error); + assert_always(!error); thd_proc_info(thd, old_proc_info); trx->checkpoint_lock_taken = false; @@ -1258,7 +1457,12 @@ cleanup: return; } -static bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * stat_print, enum ha_stat_type stat_type) { +static bool tokudb_show_status( + handlerton* hton, + THD* thd, + stat_print_fn* stat_print, + enum ha_stat_type stat_type) { + switch (stat_type) { case HA_ENGINE_STATUS: return tokudb_show_engine_status(thd, stat_print); @@ -1270,14 +1474,21 @@ static bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * sta } #if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL -static void tokudb_handle_fatal_signal(handlerton *hton __attribute__ ((__unused__)), THD *thd __attribute__ ((__unused__)), int sig) { +static void tokudb_handle_fatal_signal( + TOKUDB_UNUSED(handlerton* hton), + TOKUDB_UNUSD(THD* thd), + int sig) { + if (tokudb_gdb_on_fatal) { db_env_try_gdb_stack_trace(tokudb_gdb_path); } } #endif -static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer) { +static void tokudb_print_error( + const DB_ENV* db_env, + const char* db_errpfx, + const char* buffer) { sql_print_error("%s: %s", db_errpfx, buffer); } @@ -1299,7 +1510,7 @@ static void tokudb_cleanup_log_files(void) { char **np; for (np = names; *np; ++np) { #if 1 - if (tokudb_debug) + if (TOKUDB_UNLIKELY(tokudb::sysvars::debug)) TOKUDB_TRACE("cleanup:%s", *np); #else my_delete(*np, MYF(MY_WME)); @@ -1312,246 +1523,13 @@ static void tokudb_cleanup_log_files(void) { DBUG_VOID_RETURN; } -// options flags -// PLUGIN_VAR_THDLOCAL Variable is per-connection -// PLUGIN_VAR_READONLY Server variable is read only -// PLUGIN_VAR_NOSYSVAR Not a server variable -// PLUGIN_VAR_NOCMDOPT Not a command line option -// PLUGIN_VAR_NOCMDARG No argument for cmd line -// PLUGIN_VAR_RQCMDARG Argument required for cmd line -// PLUGIN_VAR_OPCMDARG Argument optional for cmd line -// PLUGIN_VAR_MEMALLOC String needs memory allocated - - -// system variables -static void tokudb_cleaner_period_update(THD* thd, - struct st_mysql_sys_var* sys_var, - void* var, const void * save) { - ulong * cleaner_period = (ulong *) var; - *cleaner_period = *(const ulonglong *) save; - int r = db_env->cleaner_set_period(db_env, *cleaner_period); - assert(r == 0); -} - -#define DEFAULT_CLEANER_PERIOD 1 - -static MYSQL_SYSVAR_ULONG(cleaner_period, tokudb_cleaner_period, - 0, "TokuDB cleaner_period", - NULL, tokudb_cleaner_period_update, DEFAULT_CLEANER_PERIOD, - 0, ~0UL, 0); - -static void tokudb_cleaner_iterations_update(THD* thd, - struct st_mysql_sys_var* sys_var, - void* var, const void* save) { - ulong * cleaner_iterations = (ulong *) var; - *cleaner_iterations = *(const ulonglong *) save; - int r = db_env->cleaner_set_iterations(db_env, *cleaner_iterations); - assert(r == 0); -} - -#define DEFAULT_CLEANER_ITERATIONS 5 - -static MYSQL_SYSVAR_ULONG(cleaner_iterations, tokudb_cleaner_iterations, - 0, "TokuDB cleaner_iterations", - NULL, tokudb_cleaner_iterations_update, DEFAULT_CLEANER_ITERATIONS, - 0, ~0UL, 0); - -static void tokudb_checkpointing_period_update(THD* thd, - struct st_mysql_sys_var* sys_var, - void* var, const void* save) { - uint * checkpointing_period = (uint *) var; - *checkpointing_period = *(const ulonglong *) save; - int r = db_env->checkpointing_set_period(db_env, *checkpointing_period); - assert(r == 0); -} - -static MYSQL_SYSVAR_UINT(checkpointing_period, tokudb_checkpointing_period, - 0, "TokuDB Checkpointing period", - NULL, tokudb_checkpointing_period_update, 60, - 0, ~0U, 0); - -static MYSQL_SYSVAR_BOOL(directio, tokudb_directio, - PLUGIN_VAR_READONLY, "TokuDB Enable Direct I/O ", - NULL, NULL, FALSE); - -static MYSQL_SYSVAR_BOOL(compress_buffers_before_eviction, - tokudb_compress_buffers_before_eviction, - PLUGIN_VAR_READONLY, - "TokuDB Enable buffer compression before partial eviction", - NULL, NULL, TRUE); - -static MYSQL_SYSVAR_BOOL(checkpoint_on_flush_logs, tokudb_checkpoint_on_flush_logs, - 0, "TokuDB Checkpoint on Flush Logs ", - NULL, NULL, FALSE); - -static MYSQL_SYSVAR_ULONGLONG(cache_size, tokudb_cache_size, - PLUGIN_VAR_READONLY, "TokuDB cache table size", - NULL, NULL, 0, - 0, ~0ULL, 0); - -static MYSQL_SYSVAR_ULONGLONG(max_lock_memory, tokudb_max_lock_memory, - PLUGIN_VAR_READONLY, "TokuDB max memory for locks", - NULL, NULL, 0, - 0, ~0ULL, 0); - -static MYSQL_SYSVAR_UINT(client_pool_threads, tokudb_client_pool_threads, - PLUGIN_VAR_READONLY, "TokuDB client ops thread pool size", NULL, NULL, 0, - 0, 1024, 0); - -static MYSQL_SYSVAR_UINT(cachetable_pool_threads, tokudb_cachetable_pool_threads, - PLUGIN_VAR_READONLY, "TokuDB cachetable ops thread pool size", NULL, NULL, 0, - 0, 1024, 0); - -static MYSQL_SYSVAR_UINT(checkpoint_pool_threads, tokudb_checkpoint_pool_threads, - PLUGIN_VAR_READONLY, "TokuDB checkpoint ops thread pool size", NULL, NULL, 0, - 0, 1024, 0); - -static void tokudb_enable_partial_eviction_update(THD* thd, - struct st_mysql_sys_var* sys_var, - void* var, const void* save) { - my_bool * enable_partial_eviction = (my_bool *) var; - *enable_partial_eviction = *(const my_bool *) save; - int r = db_env->evictor_set_enable_partial_eviction(db_env, *enable_partial_eviction); - assert(r == 0); -} - -static MYSQL_SYSVAR_BOOL(enable_partial_eviction, tokudb_enable_partial_eviction, - 0, "TokuDB enable partial node eviction", - NULL, tokudb_enable_partial_eviction_update, TRUE); - -static MYSQL_SYSVAR_ULONG(debug, tokudb_debug, - 0, "TokuDB Debug", - NULL, NULL, 0, - 0, ~0UL, 0); - -static MYSQL_SYSVAR_STR(log_dir, tokudb_log_dir, - PLUGIN_VAR_READONLY, "TokuDB Log Directory", - NULL, NULL, NULL); - -static MYSQL_SYSVAR_STR(data_dir, tokudb_data_dir, - PLUGIN_VAR_READONLY, "TokuDB Data Directory", - NULL, NULL, NULL); - -static MYSQL_SYSVAR_STR(version, tokudb_version, - PLUGIN_VAR_READONLY, "TokuDB Version", - NULL, NULL, NULL); - -static MYSQL_SYSVAR_UINT(write_status_frequency, tokudb_write_status_frequency, - 0, "TokuDB frequency that show processlist updates status of writes", - NULL, NULL, 1000, - 0, ~0U, 0); - -static MYSQL_SYSVAR_UINT(read_status_frequency, tokudb_read_status_frequency, - 0, "TokuDB frequency that show processlist updates status of reads", - NULL, NULL, 10000, - 0, ~0U, 0); - -static MYSQL_SYSVAR_INT(fs_reserve_percent, tokudb_fs_reserve_percent, - PLUGIN_VAR_READONLY, "TokuDB file system space reserve (percent free required)", - NULL, NULL, 5, - 0, 100, 0); - -static MYSQL_SYSVAR_STR(tmp_dir, tokudb_tmp_dir, - PLUGIN_VAR_READONLY, "Tokudb Tmp Dir", - NULL, NULL, NULL); - -#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL -static MYSQL_SYSVAR_STR(gdb_path, tokudb_gdb_path, - PLUGIN_VAR_READONLY|PLUGIN_VAR_RQCMDARG, "TokuDB path to gdb for extra debug info on fatal signal", - NULL, NULL, "/usr/bin/gdb"); - -static MYSQL_SYSVAR_BOOL(gdb_on_fatal, tokudb_gdb_on_fatal, - 0, "TokuDB enable gdb debug info on fatal signal", - NULL, NULL, true); -#endif - -static void tokudb_fsync_log_period_update(THD* thd, - struct st_mysql_sys_var* sys_var, - void* var, const void* save) { - uint32 *period = (uint32 *) var; - *period = *(const ulonglong *) save; - db_env->change_fsync_log_period(db_env, *period); -} - -static MYSQL_SYSVAR_UINT(fsync_log_period, tokudb_fsync_log_period, - 0, "TokuDB fsync log period", - NULL, tokudb_fsync_log_period_update, 0, - 0, ~0U, 0); - -static struct st_mysql_sys_var *tokudb_system_variables[] = { - MYSQL_SYSVAR(cache_size), - MYSQL_SYSVAR(client_pool_threads), - MYSQL_SYSVAR(cachetable_pool_threads), - MYSQL_SYSVAR(checkpoint_pool_threads), - MYSQL_SYSVAR(max_lock_memory), - MYSQL_SYSVAR(enable_partial_eviction), - MYSQL_SYSVAR(data_dir), - MYSQL_SYSVAR(log_dir), - MYSQL_SYSVAR(debug), - MYSQL_SYSVAR(commit_sync), - MYSQL_SYSVAR(lock_timeout), - MYSQL_SYSVAR(cleaner_period), - MYSQL_SYSVAR(cleaner_iterations), - MYSQL_SYSVAR(pk_insert_mode), - MYSQL_SYSVAR(load_save_space), - MYSQL_SYSVAR(disable_slow_alter), - MYSQL_SYSVAR(disable_hot_alter), - MYSQL_SYSVAR(alter_print_error), - MYSQL_SYSVAR(create_index_online), - MYSQL_SYSVAR(disable_prefetching), - MYSQL_SYSVAR(version), - MYSQL_SYSVAR(checkpointing_period), - MYSQL_SYSVAR(prelock_empty), - MYSQL_SYSVAR(checkpoint_lock), - MYSQL_SYSVAR(write_status_frequency), - MYSQL_SYSVAR(read_status_frequency), - MYSQL_SYSVAR(fs_reserve_percent), - MYSQL_SYSVAR(tmp_dir), - MYSQL_SYSVAR(block_size), - MYSQL_SYSVAR(read_block_size), - MYSQL_SYSVAR(read_buf_size), - MYSQL_SYSVAR(fanout), - MYSQL_SYSVAR(row_format), - MYSQL_SYSVAR(directio), - MYSQL_SYSVAR(compress_buffers_before_eviction), - MYSQL_SYSVAR(checkpoint_on_flush_logs), -#if TOKU_INCLUDE_UPSERT - MYSQL_SYSVAR(disable_slow_update), - MYSQL_SYSVAR(disable_slow_upsert), -#endif - MYSQL_SYSVAR(analyze_time), - MYSQL_SYSVAR(analyze_delete_fraction), - MYSQL_SYSVAR(fsync_log_period), -#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL - MYSQL_SYSVAR(gdb_path), - MYSQL_SYSVAR(gdb_on_fatal), -#endif - MYSQL_SYSVAR(last_lock_timeout), - MYSQL_SYSVAR(lock_timeout_debug), - MYSQL_SYSVAR(loader_memory_size), - MYSQL_SYSVAR(hide_default_row_format), - MYSQL_SYSVAR(killed_time), - MYSQL_SYSVAR(empty_scan), -#if TOKUDB_CHECK_JEMALLOC - MYSQL_SYSVAR(check_jemalloc), -#endif - MYSQL_SYSVAR(bulk_fetch), -#if TOKU_INCLUDE_XA - MYSQL_SYSVAR(support_xa), -#endif - MYSQL_SYSVAR(rpl_unique_checks), - MYSQL_SYSVAR(rpl_unique_checks_delay), - MYSQL_SYSVAR(rpl_lookup_rows), - MYSQL_SYSVAR(rpl_lookup_rows_delay), - MYSQL_SYSVAR(rpl_check_readonly), - MYSQL_SYSVAR(optimize_index_name), - MYSQL_SYSVAR(optimize_index_fraction), - MYSQL_SYSVAR(optimize_throttle), - NULL -}; - // Split ./database/table-dictionary into database, table and dictionary strings -static void tokudb_split_dname(const char *dname, String &database_name, String &table_name, String &dictionary_name) { +void tokudb_split_dname( + const char* dname, + String& database_name, + String& table_name, + String& dictionary_name) { + const char *splitter = strchr(dname, '/'); if (splitter) { const char *database_ptr = splitter+1; @@ -1564,482 +1542,18 @@ static void tokudb_split_dname(const char *dname, String &database_name, String table_name.append(table_ptr, dictionary_ptr - table_ptr); dictionary_ptr += 1; dictionary_name.append(dictionary_ptr); + } else { + table_name.append(table_ptr); } - } - } -} - -struct st_mysql_storage_engine tokudb_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; - -static struct st_mysql_information_schema tokudb_file_map_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; - -static ST_FIELD_INFO tokudb_file_map_field_info[] = { - {"dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"internal_file_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} -}; - -static int tokudb_file_map(TABLE *table, THD *thd) { - int error; - DB_TXN* txn = NULL; - DBC* tmp_cursor = NULL; - DBT curr_key; - DBT curr_val; - memset(&curr_key, 0, sizeof curr_key); - memset(&curr_val, 0, sizeof curr_val); - error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED, thd); - if (error) { - goto cleanup; - } - error = db_env->get_cursor_for_directory(db_env, txn, &tmp_cursor); - if (error) { - goto cleanup; - } - while (error == 0) { - error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); - if (!error) { - // We store the NULL terminator in the directory so it's included in the size. - // See #5789 - // Recalculate and check just to be safe. - const char *dname = (const char *) curr_key.data; - size_t dname_len = strlen(dname); - assert(dname_len == curr_key.size - 1); - table->field[0]->store(dname, dname_len, system_charset_info); - - const char *iname = (const char *) curr_val.data; - size_t iname_len = strlen(iname); - assert(iname_len == curr_val.size - 1); - table->field[1]->store(iname, iname_len, system_charset_info); - - // split the dname - String database_name, table_name, dictionary_name; - tokudb_split_dname(dname, database_name, table_name, dictionary_name); - table->field[2]->store(database_name.c_ptr(), database_name.length(), system_charset_info); - table->field[3]->store(table_name.c_ptr(), table_name.length(), system_charset_info); - table->field[4]->store(dictionary_name.c_ptr(), dictionary_name.length(), system_charset_info); - - error = schema_table_store_record(thd, table); - } - if (!error && thd_killed(thd)) - error = ER_QUERY_INTERRUPTED; - } - if (error == DB_NOTFOUND) { - error = 0; - } -cleanup: - if (tmp_cursor) { - int r = tmp_cursor->c_close(tmp_cursor); - assert(r == 0); - } - if (txn) { - commit_txn(txn, 0); - } - return error; -} - -#if MYSQL_VERSION_ID >= 50600 -static int tokudb_file_map_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { -#else -static int tokudb_file_map_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { -#endif - TOKUDB_DBUG_ENTER(""); - int error; - TABLE *table = tables->table; - - rw_rdlock(&tokudb_hton_initialized_lock); - - if (!tokudb_hton_initialized) { - error = ER_PLUGIN_IS_NOT_LOADED; - my_error(error, MYF(0), tokudb_hton_name); - } else { - error = tokudb_file_map(table, thd); - if (error) - my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); - } - - rw_unlock(&tokudb_hton_initialized_lock); - TOKUDB_DBUG_RETURN(error); -} - -static int tokudb_file_map_init(void *p) { - ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; - schema->fields_info = tokudb_file_map_field_info; - schema->fill_table = tokudb_file_map_fill_table; - return 0; -} - -static int tokudb_file_map_done(void *p) { - return 0; -} - -static struct st_mysql_information_schema tokudb_fractal_tree_info_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; - -static ST_FIELD_INFO tokudb_fractal_tree_info_field_info[] = { - {"dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"internal_file_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"bt_num_blocks_allocated", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"bt_num_blocks_in_use", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"bt_size_allocated", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"bt_size_in_use", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} -}; - -static int tokudb_report_fractal_tree_info_for_db(const DBT *dname, const DBT *iname, TABLE *table, THD *thd) { - int error; - uint64_t bt_num_blocks_allocated; - uint64_t bt_num_blocks_in_use; - uint64_t bt_size_allocated; - uint64_t bt_size_in_use; - - DB *db = NULL; - error = db_create(&db, db_env, 0); - if (error) { - goto exit; - } - error = db->open(db, NULL, (char *)dname->data, NULL, DB_BTREE, 0, 0666); - if (error) { - goto exit; - } - error = db->get_fractal_tree_info64(db, - &bt_num_blocks_allocated, &bt_num_blocks_in_use, - &bt_size_allocated, &bt_size_in_use); - if (error) { - goto exit; - } - - // We store the NULL terminator in the directory so it's included in the size. - // See #5789 - // Recalculate and check just to be safe. - { - size_t dname_len = strlen((const char *)dname->data); - assert(dname_len == dname->size - 1); - table->field[0]->store((char *)dname->data, dname_len, system_charset_info); - size_t iname_len = strlen((const char *)iname->data); - assert(iname_len == iname->size - 1); - table->field[1]->store((char *)iname->data, iname_len, system_charset_info); - } - table->field[2]->store(bt_num_blocks_allocated, false); - table->field[3]->store(bt_num_blocks_in_use, false); - table->field[4]->store(bt_size_allocated, false); - table->field[5]->store(bt_size_in_use, false); - - // split the dname - { - String database_name, table_name, dictionary_name; - tokudb_split_dname((const char *)dname->data, database_name, table_name, dictionary_name); - table->field[6]->store(database_name.c_ptr(), database_name.length(), system_charset_info); - table->field[7]->store(table_name.c_ptr(), table_name.length(), system_charset_info); - table->field[8]->store(dictionary_name.c_ptr(), dictionary_name.length(), system_charset_info); - } - error = schema_table_store_record(thd, table); - -exit: - if (db) { - int close_error = db->close(db, 0); - if (error == 0) - error = close_error; - } - return error; -} - -static int tokudb_fractal_tree_info(TABLE *table, THD *thd) { - int error; - DB_TXN* txn = NULL; - DBC* tmp_cursor = NULL; - DBT curr_key; - DBT curr_val; - memset(&curr_key, 0, sizeof curr_key); - memset(&curr_val, 0, sizeof curr_val); - error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED, thd); - if (error) { - goto cleanup; - } - error = db_env->get_cursor_for_directory(db_env, txn, &tmp_cursor); - if (error) { - goto cleanup; - } - while (error == 0) { - error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); - if (!error) { - error = tokudb_report_fractal_tree_info_for_db(&curr_key, &curr_val, table, thd); - if (error) - error = 0; // ignore read uncommitted errors - } - if (!error && thd_killed(thd)) - error = ER_QUERY_INTERRUPTED; - } - if (error == DB_NOTFOUND) { - error = 0; - } -cleanup: - if (tmp_cursor) { - int r = tmp_cursor->c_close(tmp_cursor); - assert(r == 0); - } - if (txn) { - commit_txn(txn, 0); - } - return error; -} - -#if MYSQL_VERSION_ID >= 50600 -static int tokudb_fractal_tree_info_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { -#else -static int tokudb_fractal_tree_info_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { -#endif - TOKUDB_DBUG_ENTER(""); - int error; - TABLE *table = tables->table; - - // 3938: Get a read lock on the status flag, since we must - // read it before safely proceeding - rw_rdlock(&tokudb_hton_initialized_lock); - - if (!tokudb_hton_initialized) { - error = ER_PLUGIN_IS_NOT_LOADED; - my_error(error, MYF(0), tokudb_hton_name); - } else { - error = tokudb_fractal_tree_info(table, thd); - if (error) - my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); - } - - //3938: unlock the status flag lock - rw_unlock(&tokudb_hton_initialized_lock); - TOKUDB_DBUG_RETURN(error); -} - -static int tokudb_fractal_tree_info_init(void *p) { - ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; - schema->fields_info = tokudb_fractal_tree_info_field_info; - schema->fill_table = tokudb_fractal_tree_info_fill_table; - return 0; -} - -static int tokudb_fractal_tree_info_done(void *p) { - return 0; -} - -static struct st_mysql_information_schema tokudb_fractal_tree_block_map_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; - -static ST_FIELD_INFO tokudb_fractal_tree_block_map_field_info[] = { - {"dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"internal_file_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"checkpoint_count", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"blocknum", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"offset", 0, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, NULL, SKIP_OPEN_TABLE }, - {"size", 0, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, NULL, SKIP_OPEN_TABLE }, - {"table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} -}; - -struct tokudb_report_fractal_tree_block_map_iterator_extra { - int64_t num_rows; - int64_t i; - uint64_t *checkpoint_counts; - int64_t *blocknums; - int64_t *diskoffs; - int64_t *sizes; -}; - -// This iterator is called while holding the blocktable lock. We should be as quick as possible. -// We don't want to do one call to get the number of rows, release the blocktable lock, and then do another call to get all the rows because the number of rows may change if we don't hold the lock. -// As a compromise, we'll do some mallocs inside the lock on the first call, but everything else should be fast. -static int tokudb_report_fractal_tree_block_map_iterator(uint64_t checkpoint_count, - int64_t num_rows, - int64_t blocknum, - int64_t diskoff, - int64_t size, - void *iter_extra) { - struct tokudb_report_fractal_tree_block_map_iterator_extra *e = static_cast(iter_extra); - - assert(num_rows > 0); - if (e->num_rows == 0) { - e->checkpoint_counts = (uint64_t *) tokudb_my_malloc(num_rows * (sizeof *e->checkpoint_counts), MYF(MY_WME|MY_ZEROFILL|MY_FAE)); - e->blocknums = (int64_t *) tokudb_my_malloc(num_rows * (sizeof *e->blocknums), MYF(MY_WME|MY_ZEROFILL|MY_FAE)); - e->diskoffs = (int64_t *) tokudb_my_malloc(num_rows * (sizeof *e->diskoffs), MYF(MY_WME|MY_ZEROFILL|MY_FAE)); - e->sizes = (int64_t *) tokudb_my_malloc(num_rows * (sizeof *e->sizes), MYF(MY_WME|MY_ZEROFILL|MY_FAE)); - e->num_rows = num_rows; - } - - e->checkpoint_counts[e->i] = checkpoint_count; - e->blocknums[e->i] = blocknum; - e->diskoffs[e->i] = diskoff; - e->sizes[e->i] = size; - ++(e->i); - - return 0; -} - -static int tokudb_report_fractal_tree_block_map_for_db(const DBT *dname, const DBT *iname, TABLE *table, THD *thd) { - int error; - DB *db; - struct tokudb_report_fractal_tree_block_map_iterator_extra e = {}; // avoid struct initializers so that we can compile with older gcc versions - - error = db_create(&db, db_env, 0); - if (error) { - goto exit; - } - error = db->open(db, NULL, (char *)dname->data, NULL, DB_BTREE, 0, 0666); - if (error) { - goto exit; - } - error = db->iterate_fractal_tree_block_map(db, tokudb_report_fractal_tree_block_map_iterator, &e); - { - int close_error = db->close(db, 0); - if (!error) { - error = close_error; - } - } - if (error) { - goto exit; - } - - // If not, we should have gotten an error and skipped this section of code - assert(e.i == e.num_rows); - for (int64_t i = 0; error == 0 && i < e.num_rows; ++i) { - // We store the NULL terminator in the directory so it's included in the size. - // See #5789 - // Recalculate and check just to be safe. - size_t dname_len = strlen((const char *)dname->data); - assert(dname_len == dname->size - 1); - table->field[0]->store((char *)dname->data, dname_len, system_charset_info); - - size_t iname_len = strlen((const char *)iname->data); - assert(iname_len == iname->size - 1); - table->field[1]->store((char *)iname->data, iname_len, system_charset_info); - - table->field[2]->store(e.checkpoint_counts[i], false); - table->field[3]->store(e.blocknums[i], false); - static const int64_t freelist_null = -1; - static const int64_t diskoff_unused = -2; - if (e.diskoffs[i] == diskoff_unused || e.diskoffs[i] == freelist_null) { - table->field[4]->set_null(); } else { - table->field[4]->set_notnull(); - table->field[4]->store(e.diskoffs[i], false); + database_name.append(database_ptr); } - static const int64_t size_is_free = -1; - if (e.sizes[i] == size_is_free) { - table->field[5]->set_null(); - } else { - table->field[5]->set_notnull(); - table->field[5]->store(e.sizes[i], false); - } - - // split the dname - String database_name, table_name, dictionary_name; - tokudb_split_dname((const char *)dname->data, database_name, table_name,dictionary_name); - table->field[6]->store(database_name.c_ptr(), database_name.length(), system_charset_info); - table->field[7]->store(table_name.c_ptr(), table_name.length(), system_charset_info); - table->field[8]->store(dictionary_name.c_ptr(), dictionary_name.length(), system_charset_info); - - error = schema_table_store_record(thd, table); } - -exit: - if (e.checkpoint_counts != NULL) { - tokudb_my_free(e.checkpoint_counts); - e.checkpoint_counts = NULL; - } - if (e.blocknums != NULL) { - tokudb_my_free(e.blocknums); - e.blocknums = NULL; - } - if (e.diskoffs != NULL) { - tokudb_my_free(e.diskoffs); - e.diskoffs = NULL; - } - if (e.sizes != NULL) { - tokudb_my_free(e.sizes); - e.sizes = NULL; - } - return error; } -static int tokudb_fractal_tree_block_map(TABLE *table, THD *thd) { - int error; - DB_TXN* txn = NULL; - DBC* tmp_cursor = NULL; - DBT curr_key; - DBT curr_val; - memset(&curr_key, 0, sizeof curr_key); - memset(&curr_val, 0, sizeof curr_val); - error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED, thd); - if (error) { - goto cleanup; - } - error = db_env->get_cursor_for_directory(db_env, txn, &tmp_cursor); - if (error) { - goto cleanup; - } - while (error == 0) { - error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); - if (!error) { - error = tokudb_report_fractal_tree_block_map_for_db(&curr_key, &curr_val, table, thd); - } - if (!error && thd_killed(thd)) - error = ER_QUERY_INTERRUPTED; - } - if (error == DB_NOTFOUND) { - error = 0; - } -cleanup: - if (tmp_cursor) { - int r = tmp_cursor->c_close(tmp_cursor); - assert(r == 0); - } - if (txn) { - commit_txn(txn, 0); - } - return error; -} - -#if MYSQL_VERSION_ID >= 50600 -static int tokudb_fractal_tree_block_map_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { -#else -static int tokudb_fractal_tree_block_map_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { -#endif - TOKUDB_DBUG_ENTER(""); - int error; - TABLE *table = tables->table; - - // 3938: Get a read lock on the status flag, since we must - // read it before safely proceeding - rw_rdlock(&tokudb_hton_initialized_lock); - - if (!tokudb_hton_initialized) { - error = ER_PLUGIN_IS_NOT_LOADED; - my_error(error, MYF(0), tokudb_hton_name); - } else { - error = tokudb_fractal_tree_block_map(table, thd); - if (error) - my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); - } - - //3938: unlock the status flag lock - rw_unlock(&tokudb_hton_initialized_lock); - TOKUDB_DBUG_RETURN(error); -} - -static int tokudb_fractal_tree_block_map_init(void *p) { - ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; - schema->fields_info = tokudb_fractal_tree_block_map_field_info; - schema->fill_table = tokudb_fractal_tree_block_map_fill_table; - return 0; -} - -static int tokudb_fractal_tree_block_map_done(void *p) { - return 0; -} +struct st_mysql_storage_engine tokudb_storage_engine = { + MYSQL_HANDLERTON_INTERFACE_VERSION +}; #if TOKU_INCLUDE_LOCK_TIMEOUT_QUERY_STRING struct tokudb_search_txn_extra { @@ -2048,10 +1562,16 @@ struct tokudb_search_txn_extra { uint64_t match_client_id; }; -static int tokudb_search_txn_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { +static int tokudb_search_txn_callback( + DB_TXN* txn, + iterate_row_locks_callback iterate_locks, + void* locks_extra, + void* extra) { + uint64_t txn_id = txn->id64(txn); uint64_t client_id = txn->get_client_id(txn); - struct tokudb_search_txn_extra *e = reinterpret_cast(extra); + struct tokudb_search_txn_extra* e = + reinterpret_cast(extra); if (e->match_txn_id == txn_id) { e->match_found = true; e->match_client_id = client_id; @@ -2060,9 +1580,17 @@ static int tokudb_search_txn_callback(DB_TXN *txn, iterate_row_locks_callback it return 0; } -static bool tokudb_txn_id_to_client_id(THD *thd, uint64_t blocking_txnid, uint64_t *blocking_client_id) { - struct tokudb_search_txn_extra e = { false, blocking_txnid, 0}; - (void) db_env->iterate_live_transactions(db_env, tokudb_search_txn_callback, &e); +static bool tokudb_txn_id_to_client_id( + THD* thd, + uint64_t blocking_txnid, + uint64_t* blocking_client_id) { + + struct tokudb_search_txn_extra e = { + false, + blocking_txnid, + 0 + }; + db_env->iterate_live_transactions(db_env, tokudb_search_txn_callback, &e); if (e.match_found) { *blocking_client_id = e.match_client_id; } @@ -2070,14 +1598,20 @@ static bool tokudb_txn_id_to_client_id(THD *thd, uint64_t blocking_txnid, uint64 } #endif -static void tokudb_pretty_key(const DB *db, const DBT *key, const char *default_key, String *out) { +static void tokudb_pretty_key( + const DB* db, + const DBT* key, + const char* default_key, + String* out) { + if (key->data == NULL) { out->append(default_key); } else { bool do_hexdump = true; if (do_hexdump) { // hexdump the key - const unsigned char *data = reinterpret_cast(key->data); + const unsigned char* data = + reinterpret_cast(key->data); for (size_t i = 0; i < key->size; i++) { char str[3]; snprintf(str, sizeof str, "%2.2x", data[i]); @@ -2087,15 +1621,15 @@ static void tokudb_pretty_key(const DB *db, const DBT *key, const char *default_ } } -static void tokudb_pretty_left_key(const DB *db, const DBT *key, String *out) { +void tokudb_pretty_left_key(const DB* db, const DBT* key, String* out) { tokudb_pretty_key(db, key, "-infinity", out); } -static void tokudb_pretty_right_key(const DB *db, const DBT *key, String *out) { +void tokudb_pretty_right_key(const DB* db, const DBT* key, String* out) { tokudb_pretty_key(db, key, "+infinity", out); } -static const char *tokudb_get_index_name(DB *db) { +const char* tokudb_get_index_name(DB* db) { if (db != NULL) { return db->get_dname(db); } else { @@ -2104,17 +1638,24 @@ static const char *tokudb_get_index_name(DB *db) { } static int tokudb_equal_key(const DBT *left_key, const DBT *right_key) { - if (left_key->data == NULL || right_key->data == NULL || left_key->size != right_key->size) + if (left_key->data == NULL || right_key->data == NULL || + left_key->size != right_key->size) return 0; else return memcmp(left_key->data, right_key->data, left_key->size) == 0; } -static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, uint64_t blocking_txnid) { - THD *thd = current_thd; +static void tokudb_lock_timeout_callback( + DB* db, + uint64_t requesting_txnid, + const DBT* left_key, + const DBT* right_key, + uint64_t blocking_txnid) { + + THD* thd = current_thd; if (!thd) return; - ulong lock_timeout_debug = THDVAR(thd, lock_timeout_debug); + ulong lock_timeout_debug = tokudb::sysvars::lock_timeout_debug(thd); if (lock_timeout_debug != 0) { // generate a JSON document with the lock timeout info String log_str; @@ -2123,7 +1664,9 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons log_str.append("\"mysql_thread_id\":"); log_str.append_ulonglong(mysql_thread_id); log_str.append(", \"dbname\":"); - log_str.append("\""); log_str.append(tokudb_get_index_name(db)); log_str.append("\""); + log_str.append("\""); + log_str.append(tokudb_get_index_name(db)); + log_str.append("\""); log_str.append(", \"requesting_txnid\":"); log_str.append_ulonglong(requesting_txnid); log_str.append(", \"blocking_txnid\":"); @@ -2132,44 +1675,71 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons String key_str; tokudb_pretty_key(db, left_key, "?", &key_str); log_str.append(", \"key\":"); - log_str.append("\""); log_str.append(key_str); log_str.append("\""); + log_str.append("\""); + log_str.append(key_str); + log_str.append("\""); } else { String left_str; tokudb_pretty_left_key(db, left_key, &left_str); log_str.append(", \"key_left\":"); - log_str.append("\""); log_str.append(left_str); log_str.append("\""); + log_str.append("\""); + log_str.append(left_str); + log_str.append("\""); String right_str; tokudb_pretty_right_key(db, right_key, &right_str); log_str.append(", \"key_right\":"); - log_str.append("\""); log_str.append(right_str); log_str.append("\""); + log_str.append("\""); + log_str.append(right_str); + log_str.append("\""); } log_str.append("}"); // set last_lock_timeout if (lock_timeout_debug & 1) { - char *old_lock_timeout = THDVAR(thd, last_lock_timeout); - char *new_lock_timeout = tokudb_my_strdup(log_str.c_ptr(), MY_FAE); - THDVAR(thd, last_lock_timeout) = new_lock_timeout; - tokudb_my_free(old_lock_timeout); + char* old_lock_timeout = tokudb::sysvars::last_lock_timeout(thd); + char* new_lock_timeout = + tokudb::memory::strdup(log_str.c_ptr(), MY_FAE); + tokudb::sysvars::set_last_lock_timeout(thd, new_lock_timeout); #if TOKU_THDVAR_MEMALLOC_BUG - tokudb_pthread_mutex_lock(&tokudb_map_mutex); + tokudb_map_mutex.lock(); struct tokudb_map_pair old_key = { thd, old_lock_timeout }; tree_delete(&tokudb_map, &old_key, sizeof old_key, NULL); struct tokudb_map_pair new_key = { thd, new_lock_timeout }; tree_insert(&tokudb_map, &new_key, sizeof new_key, NULL); - tokudb_pthread_mutex_unlock(&tokudb_map_mutex); + tokudb_map_mutex.unlock(); #endif + tokudb::memory::free(old_lock_timeout); } // dump to stderr if (lock_timeout_debug & 2) { - sql_print_error("%s: lock timeout %s", tokudb_hton_name, log_str.c_ptr()); + sql_print_error( + "%s: lock timeout %s", + tokudb_hton_name, + log_str.c_ptr()); LEX_STRING *qs = thd_query_string(thd); - sql_print_error("%s: requesting_thread_id:%" PRIu64 " q:%.*s", tokudb_hton_name, mysql_thread_id, (int) qs->length, qs->str); + sql_print_error( + "%s: requesting_thread_id:%" PRIu64 " q:%.*s", + tokudb_hton_name, + mysql_thread_id, + (int)qs->length, + qs->str); #if TOKU_INCLUDE_LOCK_TIMEOUT_QUERY_STRING uint64_t blocking_thread_id = 0; - if (tokudb_txn_id_to_client_id(thd, blocking_txnid, &blocking_thread_id)) { + if (tokudb_txn_id_to_client_id( + thd, + blocking_txnid, + &blocking_thread_id)) { + String blocking_qs; - if (get_thread_query_string(blocking_thread_id, blocking_qs) == 0) { - sql_print_error("%s: blocking_thread_id:%" PRIu64 " q:%.*s", tokudb_hton_name, blocking_thread_id, blocking_qs.length(), blocking_qs.c_ptr()); + if (get_thread_query_string( + blocking_thread_id, + blocking_qs) == 0) { + + sql_print_error( + "%s: blocking_thread_id:%" PRIu64 " q:%.*s", + tokudb_hton_name, + blocking_thread_id, + blocking_qs.length(), + blocking_qs.c_ptr()); } } #endif @@ -2177,254 +1747,9 @@ static void tokudb_lock_timeout_callback(DB *db, uint64_t requesting_txnid, cons } } -static struct st_mysql_information_schema tokudb_trx_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; - -static ST_FIELD_INFO tokudb_trx_field_info[] = { - {"trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"trx_mysql_thread_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"trx_time", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} -}; - -struct tokudb_trx_extra { - THD *thd; - TABLE *table; -}; - -static int tokudb_trx_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { - uint64_t txn_id = txn->id64(txn); - uint64_t client_id = txn->get_client_id(txn); - uint64_t start_time = txn->get_start_time(txn); - struct tokudb_trx_extra *e = reinterpret_cast(extra); - THD *thd = e->thd; - TABLE *table = e->table; - table->field[0]->store(txn_id, false); - table->field[1]->store(client_id, false); - uint64_t tnow = (uint64_t) time(NULL); - table->field[2]->store(tnow >= start_time ? tnow - start_time : 0, false); - int error = schema_table_store_record(thd, table); - if (!error && thd_killed(thd)) - error = ER_QUERY_INTERRUPTED; - return error; -} - -#if MYSQL_VERSION_ID >= 50600 -static int tokudb_trx_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { -#else -static int tokudb_trx_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { -#endif - TOKUDB_DBUG_ENTER(""); - int error; - - rw_rdlock(&tokudb_hton_initialized_lock); - - if (!tokudb_hton_initialized) { - error = ER_PLUGIN_IS_NOT_LOADED; - my_error(error, MYF(0), tokudb_hton_name); - } else { - struct tokudb_trx_extra e = { thd, tables->table }; - error = db_env->iterate_live_transactions(db_env, tokudb_trx_callback, &e); - if (error) - my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); - } - - rw_unlock(&tokudb_hton_initialized_lock); - TOKUDB_DBUG_RETURN(error); -} - -static int tokudb_trx_init(void *p) { - ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; - schema->fields_info = tokudb_trx_field_info; - schema->fill_table = tokudb_trx_fill_table; - return 0; -} - -static int tokudb_trx_done(void *p) { - return 0; -} - -static struct st_mysql_information_schema tokudb_lock_waits_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; - -static ST_FIELD_INFO tokudb_lock_waits_field_info[] = { - {"requesting_trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"blocking_trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_dname", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_key_left", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_key_right", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_start_time", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"lock_waits_table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} -}; - -struct tokudb_lock_waits_extra { - THD *thd; - TABLE *table; -}; - -static int tokudb_lock_waits_callback(DB *db, uint64_t requesting_txnid, const DBT *left_key, const DBT *right_key, - uint64_t blocking_txnid, uint64_t start_time, void *extra) { - struct tokudb_lock_waits_extra *e = reinterpret_cast(extra); - THD *thd = e->thd; - TABLE *table = e->table; - table->field[0]->store(requesting_txnid, false); - table->field[1]->store(blocking_txnid, false); - const char *dname = tokudb_get_index_name(db); - size_t dname_length = strlen(dname); - table->field[2]->store(dname, dname_length, system_charset_info); - String left_str; - tokudb_pretty_left_key(db, left_key, &left_str); - table->field[3]->store(left_str.ptr(), left_str.length(), system_charset_info); - String right_str; - tokudb_pretty_right_key(db, right_key, &right_str); - table->field[4]->store(right_str.ptr(), right_str.length(), system_charset_info); - table->field[5]->store(start_time, false); - - String database_name, table_name, dictionary_name; - tokudb_split_dname(dname, database_name, table_name, dictionary_name); - table->field[6]->store(database_name.c_ptr(), database_name.length(), system_charset_info); - table->field[7]->store(table_name.c_ptr(), table_name.length(), system_charset_info); - table->field[8]->store(dictionary_name.c_ptr(), dictionary_name.length(), system_charset_info); - - int error = schema_table_store_record(thd, table); - - if (!error && thd_killed(thd)) - error = ER_QUERY_INTERRUPTED; - - return error; -} - -#if MYSQL_VERSION_ID >= 50600 -static int tokudb_lock_waits_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { -#else -static int tokudb_lock_waits_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { -#endif - TOKUDB_DBUG_ENTER(""); - int error; - - rw_rdlock(&tokudb_hton_initialized_lock); - - if (!tokudb_hton_initialized) { - error = ER_PLUGIN_IS_NOT_LOADED; - my_error(error, MYF(0), tokudb_hton_name); - } else { - struct tokudb_lock_waits_extra e = { thd, tables->table }; - error = db_env->iterate_pending_lock_requests(db_env, tokudb_lock_waits_callback, &e); - if (error) - my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); - } - - rw_unlock(&tokudb_hton_initialized_lock); - TOKUDB_DBUG_RETURN(error); -} - -static int tokudb_lock_waits_init(void *p) { - ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; - schema->fields_info = tokudb_lock_waits_field_info; - schema->fill_table = tokudb_lock_waits_fill_table; - return 0; -} - -static int tokudb_lock_waits_done(void *p) { - return 0; -} - -static struct st_mysql_information_schema tokudb_locks_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; - -static ST_FIELD_INFO tokudb_locks_field_info[] = { - {"locks_trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_mysql_thread_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_dname", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_key_left", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_key_right", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {"locks_table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, - {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} -}; - -struct tokudb_locks_extra { - THD *thd; - TABLE *table; -}; - -static int tokudb_locks_callback(DB_TXN *txn, iterate_row_locks_callback iterate_locks, void *locks_extra, void *extra) { - uint64_t txn_id = txn->id64(txn); - uint64_t client_id = txn->get_client_id(txn); - struct tokudb_locks_extra *e = reinterpret_cast(extra); - THD *thd = e->thd; - TABLE *table = e->table; - int error = 0; - DB *db; - DBT left_key, right_key; - while (error == 0 && iterate_locks(&db, &left_key, &right_key, locks_extra) == 0) { - table->field[0]->store(txn_id, false); - table->field[1]->store(client_id, false); - - const char *dname = tokudb_get_index_name(db); - size_t dname_length = strlen(dname); - table->field[2]->store(dname, dname_length, system_charset_info); - - String left_str; - tokudb_pretty_left_key(db, &left_key, &left_str); - table->field[3]->store(left_str.ptr(), left_str.length(), system_charset_info); - - String right_str; - tokudb_pretty_right_key(db, &right_key, &right_str); - table->field[4]->store(right_str.ptr(), right_str.length(), system_charset_info); - - String database_name, table_name, dictionary_name; - tokudb_split_dname(dname, database_name, table_name, dictionary_name); - table->field[5]->store(database_name.c_ptr(), database_name.length(), system_charset_info); - table->field[6]->store(table_name.c_ptr(), table_name.length(), system_charset_info); - table->field[7]->store(dictionary_name.c_ptr(), dictionary_name.length(), system_charset_info); - - error = schema_table_store_record(thd, table); - - if (!error && thd_killed(thd)) - error = ER_QUERY_INTERRUPTED; - } - return error; -} - -#if MYSQL_VERSION_ID >= 50600 -static int tokudb_locks_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { -#else -static int tokudb_locks_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { -#endif - TOKUDB_DBUG_ENTER(""); - int error; - - rw_rdlock(&tokudb_hton_initialized_lock); - - if (!tokudb_hton_initialized) { - error = ER_PLUGIN_IS_NOT_LOADED; - my_error(error, MYF(0), tokudb_hton_name); - } else { - struct tokudb_locks_extra e = { thd, tables->table }; - error = db_env->iterate_live_transactions(db_env, tokudb_locks_callback, &e); - if (error) - my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); - } - - rw_unlock(&tokudb_hton_initialized_lock); - TOKUDB_DBUG_RETURN(error); -} - -static int tokudb_locks_init(void *p) { - ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; - schema->fields_info = tokudb_locks_field_info; - schema->fill_table = tokudb_locks_fill_table; - return 0; -} - -static int tokudb_locks_done(void *p) { - return 0; -} - // Retrieves variables for information_schema.global_status. -// Names (columnname) are automatically converted to upper case, and prefixed with "TOKUDB_" +// Names (columnname) are automatically converted to upper case, +// and prefixed with "TOKUDB_" static int show_tokudb_vars(THD *thd, SHOW_VAR *var, char *buff) { TOKUDB_DBUG_ENTER(""); @@ -2435,13 +1760,23 @@ static int show_tokudb_vars(THD *thd, SHOW_VAR *var, char *buff) { fs_redzone_state redzone_state; uint64_t num_rows; - error = db_env->get_engine_status (db_env, toku_global_status_rows, toku_global_status_max_rows, &num_rows, &redzone_state, &panic, panic_string, panic_string_len, TOKU_GLOBAL_STATUS); + error = db_env->get_engine_status( + db_env, + toku_global_status_rows, + toku_global_status_max_rows, + &num_rows, + &redzone_state, + &panic, + panic_string, + panic_string_len, + TOKU_GLOBAL_STATUS); //TODO: Maybe do something with the panic output? if (error == 0) { - assert(num_rows <= toku_global_status_max_rows); + assert_always(num_rows <= toku_global_status_max_rows); //TODO: Maybe enable some of the items here: (copied from engine status - //TODO: (optionally) add redzone state, panic, panic string, etc. Right now it's being ignored. + //TODO: (optionally) add redzone state, panic, panic string, etc. + //Right now it's being ignored. for (uint64_t row = 0; row < num_rows; row++) { SHOW_VAR &status_var = toku_global_status_variables[row]; @@ -2463,7 +1798,11 @@ static int show_tokudb_vars(THD *thd, SHOW_VAR *var, char *buff) { time_t t = status_row.value.num; char tbuf[26]; // Reuse the memory in status_row. (It belongs to us). - snprintf(status_row.value.datebuf, sizeof(status_row.value.datebuf), "%.24s", ctime_r(&t, tbuf)); + snprintf( + status_row.value.datebuf, + sizeof(status_row.value.datebuf), + "%.24s", + ctime_r(&t, tbuf)); status_var.value = (char*)&status_row.value.datebuf[0]; break; } @@ -2489,7 +1828,11 @@ static int show_tokudb_vars(THD *thd, SHOW_VAR *var, char *buff) { status_var.type = SHOW_CHAR; // Reuse the memory in status_row.datebuf. (It belongs to us). // UNKNOWN TYPE: %d fits in 26 bytes (sizeof datebuf) for any integer. - snprintf(status_row.value.datebuf, sizeof(status_row.value.datebuf), "UNKNOWN TYPE: %d", status_row.type); + snprintf( + status_row.value.datebuf, + sizeof(status_row.value.datebuf), + "UNKNOWN TYPE: %d", + status_row.type); status_var.value = (char*)&status_row.value.datebuf[0]; break; } @@ -2521,157 +1864,38 @@ static void tokudb_backtrace(void) { } #endif -#if defined(TOKUDB_VERSION_MAJOR) && defined(TOKUDB_VERSION_MINOR) -#define TOKUDB_PLUGIN_VERSION ((TOKUDB_VERSION_MAJOR << 8) + TOKUDB_VERSION_MINOR) -#else -#define TOKUDB_PLUGIN_VERSION 0 -#endif - #ifdef MARIA_PLUGIN_INTERFACE_VERSION maria_declare_plugin(tokudb) #else mysql_declare_plugin(tokudb) #endif -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &tokudb_storage_engine, - tokudb_hton_name, - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_init_func, /* plugin init */ - tokudb_done_func, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - toku_global_status_variables_export, /* status variables */ - tokudb_system_variables, /* system variables */ + { + MYSQL_STORAGE_ENGINE_PLUGIN, + &tokudb_storage_engine, + tokudb_hton_name, + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + tokudb_init_func, /* plugin init */ + tokudb_done_func, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + toku_global_status_variables_export, /* status variables */ + tokudb::sysvars::system_variables, /* system variables */ #ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ #else - NULL, /* config options */ - 0, /* flags */ + NULL, /* config options */ + 0, /* flags */ #endif -}, -{ - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &tokudb_trx_information_schema, - "TokuDB_trx", - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_trx_init, /* plugin init */ - tokudb_trx_done, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - NULL, /* status variables */ - NULL, /* system variables */ -#ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -#else - NULL, /* config options */ - 0, /* flags */ -#endif -}, -{ - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &tokudb_lock_waits_information_schema, - "TokuDB_lock_waits", - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_lock_waits_init, /* plugin init */ - tokudb_lock_waits_done, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - NULL, /* status variables */ - NULL, /* system variables */ -#ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -#else - NULL, /* config options */ - 0, /* flags */ -#endif -}, -{ - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &tokudb_locks_information_schema, - "TokuDB_locks", - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_locks_init, /* plugin init */ - tokudb_locks_done, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - NULL, /* status variables */ - NULL, /* system variables */ -#ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -#else - NULL, /* config options */ - 0, /* flags */ -#endif -}, -{ - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &tokudb_file_map_information_schema, - "TokuDB_file_map", - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_file_map_init, /* plugin init */ - tokudb_file_map_done, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - NULL, /* status variables */ - NULL, /* system variables */ -#ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -#else - NULL, /* config options */ - 0, /* flags */ -#endif -}, -{ - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &tokudb_fractal_tree_info_information_schema, - "TokuDB_fractal_tree_info", - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_fractal_tree_info_init, /* plugin init */ - tokudb_fractal_tree_info_done, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - NULL, /* status variables */ - NULL, /* system variables */ -#ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -#else - NULL, /* config options */ - 0, /* flags */ -#endif -}, -{ - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &tokudb_fractal_tree_block_map_information_schema, - "TokuDB_fractal_tree_block_map", - "Percona", - "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", - PLUGIN_LICENSE_GPL, - tokudb_fractal_tree_block_map_init, /* plugin init */ - tokudb_fractal_tree_block_map_done, /* plugin deinit */ - TOKUDB_PLUGIN_VERSION, - NULL, /* status variables */ - NULL, /* system variables */ -#ifdef MARIA_PLUGIN_INTERFACE_VERSION - tokudb_version, - MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ -#else - NULL, /* config options */ - 0, /* flags */ -#endif -} + }, + tokudb::information_schema::trx, + tokudb::information_schema::lock_waits, + tokudb::information_schema::locks, + tokudb::information_schema::file_map, + tokudb::information_schema::fractal_tree_info, + tokudb::information_schema::fractal_tree_block_map, + tokudb::information_schema::background_job_status #ifdef MARIA_PLUGIN_INTERFACE_VERSION maria_declare_plugin_end; #else diff --git a/storage/tokudb/hatoku_hton.h b/storage/tokudb/hatoku_hton.h index 2237047ef75..ade7be128a5 100644 --- a/storage/tokudb/hatoku_hton.h +++ b/storage/tokudb/hatoku_hton.h @@ -26,434 +26,177 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ifndef _HATOKU_HTON_H #define _HATOKU_HTON_H -#include "db.h" +#include "hatoku_defines.h" +#include "tokudb_debug.h" +#include "tokudb_information_schema.h" +#include "tokudb_memory.h" +#include "tokudb_thread.h" +#include "tokudb_time.h" +#include "tokudb_txn.h" +#include "tokudb_sysvars.h" -extern handlerton *tokudb_hton; +extern handlerton* tokudb_hton; -extern DB_ENV *db_env; +extern DB_ENV* db_env; -enum srv_row_format_enum { - SRV_ROW_FORMAT_UNCOMPRESSED = 0, - SRV_ROW_FORMAT_ZLIB = 1, - SRV_ROW_FORMAT_SNAPPY = 2, - SRV_ROW_FORMAT_QUICKLZ = 3, - SRV_ROW_FORMAT_LZMA = 4, - SRV_ROW_FORMAT_FAST = 5, - SRV_ROW_FORMAT_SMALL = 6, - SRV_ROW_FORMAT_DEFAULT = 7 -}; -typedef enum srv_row_format_enum srv_row_format_t; +inline tokudb::sysvars::row_format_t toku_compression_method_to_row_format( + toku_compression_method method) { -static inline srv_row_format_t toku_compression_method_to_row_format(toku_compression_method method) { switch (method) { case TOKU_NO_COMPRESSION: - return SRV_ROW_FORMAT_UNCOMPRESSED; + return tokudb::sysvars::SRV_ROW_FORMAT_UNCOMPRESSED; case TOKU_ZLIB_WITHOUT_CHECKSUM_METHOD: case TOKU_ZLIB_METHOD: - return SRV_ROW_FORMAT_ZLIB; + return tokudb::sysvars::SRV_ROW_FORMAT_ZLIB; case TOKU_SNAPPY_METHOD: - return SRV_ROW_FORMAT_SNAPPY; + return tokudb::sysvars::SRV_ROW_FORMAT_SNAPPY; case TOKU_QUICKLZ_METHOD: - return SRV_ROW_FORMAT_QUICKLZ; + return tokudb::sysvars::SRV_ROW_FORMAT_QUICKLZ; case TOKU_LZMA_METHOD: - return SRV_ROW_FORMAT_LZMA; + return tokudb::sysvars::SRV_ROW_FORMAT_LZMA; case TOKU_DEFAULT_COMPRESSION_METHOD: - return SRV_ROW_FORMAT_DEFAULT; + return tokudb::sysvars::SRV_ROW_FORMAT_DEFAULT; case TOKU_FAST_COMPRESSION_METHOD: - return SRV_ROW_FORMAT_FAST; + return tokudb::sysvars::SRV_ROW_FORMAT_FAST; case TOKU_SMALL_COMPRESSION_METHOD: - return SRV_ROW_FORMAT_SMALL; + return tokudb::sysvars::SRV_ROW_FORMAT_SMALL; default: - assert(0); + assert_unreachable(); } } -static inline toku_compression_method row_format_to_toku_compression_method(srv_row_format_t row_format) { +inline toku_compression_method row_format_to_toku_compression_method( + tokudb::sysvars::row_format_t row_format) { + switch (row_format) { - case SRV_ROW_FORMAT_UNCOMPRESSED: + case tokudb::sysvars::SRV_ROW_FORMAT_UNCOMPRESSED: return TOKU_NO_COMPRESSION; - case SRV_ROW_FORMAT_QUICKLZ: - case SRV_ROW_FORMAT_FAST: + case tokudb::sysvars::SRV_ROW_FORMAT_QUICKLZ: + case tokudb::sysvars::SRV_ROW_FORMAT_FAST: return TOKU_QUICKLZ_METHOD; - case SRV_ROW_FORMAT_SNAPPY: + case tokudb::sysvars::SRV_ROW_FORMAT_SNAPPY: return TOKU_SNAPPY_METHOD; - case SRV_ROW_FORMAT_ZLIB: - case SRV_ROW_FORMAT_DEFAULT: + case tokudb::sysvars::SRV_ROW_FORMAT_ZLIB: + case tokudb::sysvars::SRV_ROW_FORMAT_DEFAULT: return TOKU_ZLIB_WITHOUT_CHECKSUM_METHOD; - case SRV_ROW_FORMAT_LZMA: - case SRV_ROW_FORMAT_SMALL: + case tokudb::sysvars::SRV_ROW_FORMAT_LZMA: + case tokudb::sysvars::SRV_ROW_FORMAT_SMALL: return TOKU_LZMA_METHOD; default: - assert(0); + assert_unreachable(); } } -// thread variables - -static MYSQL_THDVAR_BOOL(commit_sync, - PLUGIN_VAR_THDLOCAL, - "sync on txn commit", - /* check */ NULL, - /* update */ NULL, - /* default*/ true -); - -static MYSQL_THDVAR_UINT(pk_insert_mode, - 0, - "set the primary key insert mode", - NULL, - NULL, - 1, // default - 0, // min? - 2, // max - 1 // blocksize -); - -static uint get_pk_insert_mode(THD* thd) { - return THDVAR(thd, pk_insert_mode); -} - -static MYSQL_THDVAR_BOOL(load_save_space, - 0, - "compress intermediate bulk loader files to save space", - NULL, - NULL, - true -); - -static bool get_load_save_space(THD* thd) { - return (THDVAR(thd, load_save_space) != 0); -} - -static MYSQL_THDVAR_BOOL(disable_slow_alter, - 0, - "if on, alter tables that require copy are disabled", - NULL, - NULL, - false -); - -static bool get_disable_slow_alter(THD* thd) { - return (THDVAR(thd, disable_slow_alter) != 0); -} - -static MYSQL_THDVAR_BOOL(disable_hot_alter, - 0, - "if on, hot alter table is disabled", - NULL, - NULL, - false -); - -static bool get_disable_hot_alter(THD* thd) { - return THDVAR(thd, disable_hot_alter) != 0; -} - -static MYSQL_THDVAR_BOOL(create_index_online, - 0, - "if on, create index done online", - NULL, - NULL, - true -); - -static bool get_create_index_online(THD* thd) { - return (THDVAR(thd, create_index_online) != 0); -} - -static MYSQL_THDVAR_BOOL(alter_print_error, - 0, - "Print errors for alter table operations", - NULL, - NULL, - false -); - -static MYSQL_THDVAR_BOOL(disable_prefetching, - 0, - "if on, prefetching disabled", - NULL, - NULL, - false -); - -static bool get_disable_prefetching(THD* thd) { - return (THDVAR(thd, disable_prefetching) != 0); -} - -static MYSQL_THDVAR_BOOL(prelock_empty, - 0, - "Tokudb Prelock Empty Table", - NULL, - NULL, - true -); - -static bool get_prelock_empty(THD* thd) { - return (THDVAR(thd, prelock_empty) != 0); -} - -static MYSQL_THDVAR_UINT(block_size, - 0, - "fractal tree block size", - NULL, - NULL, - 4<<20, // default - 4096, // min - ~0U, // max - 1 // blocksize??? -); - -static uint get_tokudb_block_size(THD* thd) { - return THDVAR(thd, block_size); -} - -static MYSQL_THDVAR_UINT(read_block_size, - 0, - "fractal tree read block size", - NULL, - NULL, - 64*1024, // default - 4096, // min - ~0U, // max - 1 // blocksize??? -); - -static uint get_tokudb_read_block_size(THD* thd) { - return THDVAR(thd, read_block_size); -} - -static MYSQL_THDVAR_UINT(read_buf_size, - 0, - "fractal tree read block size", //TODO: Is this a typo? - NULL, - NULL, - 128*1024, // default - 0, // min - 1*1024*1024, // max - 1 // blocksize??? -); - -static uint get_tokudb_read_buf_size(THD* thd) { - return THDVAR(thd, read_buf_size); -} - -#if TOKU_INCLUDE_UPSERT -static MYSQL_THDVAR_BOOL(disable_slow_update, - PLUGIN_VAR_THDLOCAL, - "disable slow update", - NULL, // check - NULL, // update - false // default -); - -static MYSQL_THDVAR_BOOL(disable_slow_upsert, - PLUGIN_VAR_THDLOCAL, - "disable slow upsert", - NULL, // check - NULL, // update - false // default -); +inline enum row_type row_format_to_row_type( + tokudb::sysvars::row_format_t row_format) { +#if TOKU_INCLUDE_ROW_TYPE_COMPRESSION + switch (row_format) { + case tokudb::sysvars::SRV_ROW_FORMAT_UNCOMPRESSED: + return ROW_TYPE_TOKU_UNCOMPRESSED; + case tokudb::sysvars::SRV_ROW_FORMAT_ZLIB: + return ROW_TYPE_TOKU_ZLIB; + case tokudb::sysvars::SRV_ROW_FORMAT_SNAPPY: + return ROW_TYPE_TOKU_SNAPPY; + case tokudb::sysvars::SRV_ROW_FORMAT_QUICKLZ: + return ROW_TYPE_TOKU_QUICKLZ; + case tokudb::sysvars::SRV_ROW_FORMAT_LZMA: + return ROW_TYPE_TOKU_LZMA; + case tokudb::sysvars::SRV_ROW_FORMAT_SMALL: + return ROW_TYPE_TOKU_SMALL; + case tokudb::sysvars::SRV_ROW_FORMAT_FAST: + return ROW_TYPE_TOKU_FAST; + case tokudb::sysvars::SRV_ROW_FORMAT_DEFAULT: + return ROW_TYPE_DEFAULT; + } #endif - -static MYSQL_THDVAR_UINT(fanout, - 0, - "fractal tree fanout", - NULL, - NULL, - 16, // default - 2, // min - 16*1024, // max - 1 // blocksize??? -); - -static uint get_tokudb_fanout(THD* thd) { - return THDVAR(thd, fanout); + return ROW_TYPE_DEFAULT; } -static MYSQL_THDVAR_UINT(analyze_time, 0, "analyze time (seconds)", NULL /*check*/, NULL /*update*/, 5 /*default*/, 0 /*min*/, ~0U /*max*/, 1 /*blocksize*/); - -static MYSQL_THDVAR_DOUBLE(analyze_delete_fraction, 0, "fraction of rows allowed to be deleted", NULL /*check*/, NULL /*update*/, 1.0 /*def*/, 0 /*min*/, 1.0 /*max*/, 1); - -static void tokudb_checkpoint_lock(THD * thd); -static void tokudb_checkpoint_unlock(THD * thd); - -static void tokudb_checkpoint_lock_update( - THD* thd, - struct st_mysql_sys_var* var, - void* var_ptr, - const void* save) -{ - my_bool* val = (my_bool *) var_ptr; - *val= *(my_bool *) save ? true : false; - if (*val) { - tokudb_checkpoint_lock(thd); +inline tokudb::sysvars::row_format_t row_type_to_row_format( + enum row_type type) { +#if TOKU_INCLUDE_ROW_TYPE_COMPRESSION + switch (type) { + case ROW_TYPE_TOKU_UNCOMPRESSED: + return tokudb::sysvars::SRV_ROW_FORMAT_UNCOMPRESSED; + case ROW_TYPE_TOKU_ZLIB: + return tokudb::sysvars::SRV_ROW_FORMAT_ZLIB; + case ROW_TYPE_TOKU_SNAPPY: + return tokudb::sysvars::SRV_ROW_FORMAT_SNAPPY; + case ROW_TYPE_TOKU_QUICKLZ: + return tokudb::sysvars::SRV_ROW_FORMAT_QUICKLZ; + case ROW_TYPE_TOKU_LZMA: + return tokudb::sysvars::SRV_ROW_FORMAT_LZMA; + case ROW_TYPE_TOKU_SMALL: + return tokudb::sysvars::SRV_ROW_FORMAT_SMALL; + case ROW_TYPE_TOKU_FAST: + return tokudb::sysvars::SRV_ROW_FORMAT_FAST; + case ROW_TYPE_DEFAULT: + return tokudb::sysvars::SRV_ROW_FORMAT_DEFAULT; + default: + return tokudb::sysvars::SRV_ROW_FORMAT_DEFAULT; } - else { - tokudb_checkpoint_unlock(thd); - } -} - -static MYSQL_THDVAR_BOOL(checkpoint_lock, - 0, - "Tokudb Checkpoint Lock", - NULL, - tokudb_checkpoint_lock_update, - false -); - -static const char *tokudb_row_format_names[] = { - "tokudb_uncompressed", - "tokudb_zlib", - "tokudb_snappy", - "tokudb_quicklz", - "tokudb_lzma", - "tokudb_fast", - "tokudb_small", - "tokudb_default", - NullS -}; - -static TYPELIB tokudb_row_format_typelib = { - array_elements(tokudb_row_format_names) - 1, - "tokudb_row_format_typelib", - tokudb_row_format_names, - NULL -}; - -static MYSQL_THDVAR_ENUM(row_format, PLUGIN_VAR_OPCMDARG, - "Specifies the compression method for a table during this session. " - "Possible values are TOKUDB_UNCOMPRESSED, TOKUDB_ZLIB, TOKUDB_SNAPPY, " - "TOKUDB_QUICKLZ, TOKUDB_LZMA, TOKUDB_FAST, TOKUDB_SMALL and TOKUDB_DEFAULT", - NULL, NULL, SRV_ROW_FORMAT_ZLIB, &tokudb_row_format_typelib); - -static inline srv_row_format_t get_row_format(THD *thd) { - return (srv_row_format_t) THDVAR(thd, row_format); +#endif + return tokudb::sysvars::SRV_ROW_FORMAT_DEFAULT; } -static MYSQL_THDVAR_UINT(lock_timeout_debug, 0, "TokuDB lock timeout debug", NULL /*check*/, NULL /*update*/, 1 /*default*/, 0 /*min*/, ~0U /*max*/, 1); +inline enum row_type toku_compression_method_to_row_type( + toku_compression_method method) { -static MYSQL_THDVAR_STR(last_lock_timeout, PLUGIN_VAR_MEMALLOC, "last TokuDB lock timeout", NULL /*check*/, NULL /*update*/, NULL /*default*/); + return row_format_to_row_type( + toku_compression_method_to_row_format(method)); +} -static MYSQL_THDVAR_BOOL(hide_default_row_format, 0, "hide the default row format", NULL /*check*/, NULL /*update*/, true); +inline toku_compression_method row_type_to_toku_compression_method( + enum row_type type) { -static const uint64_t DEFAULT_TOKUDB_LOCK_TIMEOUT = 4000; /*milliseconds*/ + return row_format_to_toku_compression_method(row_type_to_row_format(type)); +} -static MYSQL_THDVAR_ULONGLONG(lock_timeout, 0, "TokuDB lock timeout", NULL, NULL, DEFAULT_TOKUDB_LOCK_TIMEOUT, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/); +void tokudb_checkpoint_lock(THD * thd); +void tokudb_checkpoint_unlock(THD * thd); -static uint64_t tokudb_get_lock_wait_time_callback(uint64_t default_wait_time) { +inline uint64_t tokudb_get_lock_wait_time_callback(uint64_t default_wait_time) { THD *thd = current_thd; - uint64_t wait_time = THDVAR(thd, lock_timeout); - return wait_time; + return tokudb::sysvars::lock_timeout(thd); } -static MYSQL_THDVAR_ULONGLONG(loader_memory_size, - 0, - "TokuDB loader memory size", - NULL, - NULL, - 100*1000*1000, /*default*/ - 0, /*min*/ - ~0ULL, /*max*/ - 1 /*blocksize*/ -); - -static uint64_t tokudb_get_loader_memory_size_callback(void) { +inline uint64_t tokudb_get_loader_memory_size_callback(void) { THD *thd = current_thd; - uint64_t memory_size = THDVAR(thd, loader_memory_size); - return memory_size; + return tokudb::sysvars::loader_memory_size(thd); } -static const uint64_t DEFAULT_TOKUDB_KILLED_TIME = 4000; - -static MYSQL_THDVAR_ULONGLONG(killed_time, 0, "TokuDB killed time", NULL, NULL, DEFAULT_TOKUDB_KILLED_TIME, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/); - -static uint64_t tokudb_get_killed_time_callback(uint64_t default_killed_time) { +inline uint64_t tokudb_get_killed_time_callback(uint64_t default_killed_time) { THD *thd = current_thd; - uint64_t killed_time = THDVAR(thd, killed_time); - return killed_time; + return tokudb::sysvars::killed_time(thd); } -static int tokudb_killed_callback(void) { +inline int tokudb_killed_callback(void) { THD *thd = current_thd; return thd_killed(thd); } -static bool tokudb_killed_thd_callback(void *extra, uint64_t deleted_rows) { +inline bool tokudb_killed_thd_callback(void *extra, uint64_t deleted_rows) { THD *thd = static_cast(extra); return thd_killed(thd) != 0; } -enum { - TOKUDB_EMPTY_SCAN_DISABLED = 0, - TOKUDB_EMPTY_SCAN_LR = 1, - TOKUDB_EMPTY_SCAN_RL = 2, -}; - -static const char *tokudb_empty_scan_names[] = { - "disabled", - "lr", - "rl", - NullS -}; - -static TYPELIB tokudb_empty_scan_typelib = { - array_elements(tokudb_empty_scan_names) - 1, - "tokudb_empty_scan_typelib", - tokudb_empty_scan_names, - NULL -}; - -static MYSQL_THDVAR_ENUM(empty_scan, PLUGIN_VAR_OPCMDARG, - "TokuDB algorithm to check if the table is empty when opened. ", - NULL, NULL, TOKUDB_EMPTY_SCAN_RL, &tokudb_empty_scan_typelib -); - -#if TOKUDB_CHECK_JEMALLOC -static uint tokudb_check_jemalloc; -static MYSQL_SYSVAR_UINT(check_jemalloc, tokudb_check_jemalloc, 0, "Check if jemalloc is linked", - NULL, NULL, 1, 0, 1, 0); -#endif - -static MYSQL_THDVAR_BOOL(bulk_fetch, PLUGIN_VAR_THDLOCAL, "enable bulk fetch", - NULL /*check*/, NULL /*update*/, true /*default*/); - -#if TOKU_INCLUDE_XA -static MYSQL_THDVAR_BOOL(support_xa, - PLUGIN_VAR_OPCMDARG, - "Enable TokuDB support for the XA two-phase commit", - NULL, // check - NULL, // update - true // default -); -#endif - -static MYSQL_THDVAR_BOOL(rpl_unique_checks, PLUGIN_VAR_THDLOCAL, "enable unique checks on replication slave", - NULL /*check*/, NULL /*update*/, true /*default*/); - -static MYSQL_THDVAR_ULONGLONG(rpl_unique_checks_delay, PLUGIN_VAR_THDLOCAL, "time in milliseconds to add to unique checks test on replication slave", - NULL, NULL, 0 /*default*/, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/); - -static MYSQL_THDVAR_BOOL(rpl_lookup_rows, PLUGIN_VAR_THDLOCAL, "lookup a row on rpl slave", - NULL /*check*/, NULL /*update*/, true /*default*/); - -static MYSQL_THDVAR_ULONGLONG(rpl_lookup_rows_delay, PLUGIN_VAR_THDLOCAL, "time in milliseconds to add to lookups on replication slave", - NULL, NULL, 0 /*default*/, 0 /*min*/, ~0ULL /*max*/, 1 /*blocksize*/); - -static MYSQL_THDVAR_BOOL(rpl_check_readonly, PLUGIN_VAR_THDLOCAL, "check if the slave is read only", - NULL /*check*/, NULL /*update*/, true /*default*/); - -static MYSQL_THDVAR_STR(optimize_index_name, PLUGIN_VAR_THDLOCAL + PLUGIN_VAR_MEMALLOC, "optimize index name (default all indexes)", NULL /*check*/, NULL /*update*/, NULL /*default*/); - -static MYSQL_THDVAR_DOUBLE(optimize_index_fraction, 0, "optimize index fraction (default 1.0 all)", NULL /*check*/, NULL /*update*/, 1.0 /*def*/, 0 /*min*/, 1.0 /*max*/, 1); - -static MYSQL_THDVAR_ULONGLONG(optimize_throttle, 0, "optimize throttle (default no throttle)", NULL /*check*/, NULL /*update*/, 0 /*def*/, 0 /*min*/, ~0ULL /*max*/, 1); extern HASH tokudb_open_tables; -extern pthread_mutex_t tokudb_mutex; -extern uint32_t tokudb_write_status_frequency; -extern uint32_t tokudb_read_status_frequency; +extern tokudb::thread::mutex_t tokudb_mutex; +extern const char* tokudb_hton_name; +extern int tokudb_hton_initialized; +extern tokudb::thread::rwlock_t tokudb_hton_initialized_lock; void toku_hton_update_primary_key_bytes_inserted(uint64_t row_size); +void tokudb_split_dname( + const char* dname, + String& database_name, + String& table_name, + String& dictionary_name); + +void tokudb_pretty_left_key(const DB* db, const DBT* key, String* out); +void tokudb_pretty_right_key(const DB* db, const DBT* key, String* out); +const char *tokudb_get_index_name(DB* db); + #endif //#ifdef _HATOKU_HTON diff --git a/storage/tokudb/mysql-test/rpl/disabled.def b/storage/tokudb/mysql-test/rpl/disabled.def index 25c44654676..4c1a9a3e785 100644 --- a/storage/tokudb/mysql-test/rpl/disabled.def +++ b/storage/tokudb/mysql-test/rpl/disabled.def @@ -13,4 +13,3 @@ rpl_tokudb_write_unique_uc1: unreliable, uses timestamp differences rpl_tokudb_read_only_ff: unreliable, uses timestamp differences rpl_tokudb_read_only_tf: unreliable, uses timestamp differences rpl_tokudb_read_only_tt: unreliable, uses timestamp differences -rpl_row_sp002_tokudb : tokudb does not support foreign keys diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result b/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result index b58beb68c8a..929f2c54bf1 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result @@ -96,13 +96,11 @@ f5 DOUBLE DEFAULT '2.00', f6 ENUM('a', 'b', 'c') default 'a', f7 DECIMAL(17,9) default '1000.00', f8 MEDIUMBLOB, -f9 NUMERIC(6,4) default '2000.00', +f9 NUMERIC(6,2) default '2000.00', f10 VARCHAR(1024), f11 BINARY(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f12 SET('a', 'b', 'c') default 'b') ENGINE=TokuDB; -Warnings: -Warning 1264 Out of range value for column 'f9' at row 1 CREATE TABLE t3 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), /* extra */ @@ -119,13 +117,11 @@ CREATE TABLE t4 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), f5 DOUBLE DEFAULT '2.00', f6 DECIMAL(17,9) default '1000.00', f7 MEDIUMBLOB, -f8 NUMERIC(6,4) default '2000.00', +f8 NUMERIC(6,2) default '2000.00', f9 VARCHAR(1024), f10 BINARY(20) not null default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', f11 CHAR(255)) ENGINE=TokuDB; -Warnings: -Warning 1264 Out of range value for column 'f8' at row 1 CREATE TABLE t31 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20), /* extra */ @@ -184,9 +180,6 @@ INSERT into t2 values (2, 2, 2, 'second', (3, 3, 3, 'third', 3.0, 'b', 3000.0003, 'f8: medium size blob', 3000, 'f10: some var char', '01234567', 'c'); -Warnings: -Warning 1264 Out of range value for column 'f9' at row 1 -Warning 1264 Out of range value for column 'f9' at row 2 INSERT into t3 set f1=1, f2=1, f3=1, f4='first', f10='f10: some var char'; INSERT into t4 set f1=1, f2=1, f3=1, f4='first', f7='f7: medium size blob', f10='f10: binary data'; diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result index cd8608f4387..5935e5ddcbd 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result @@ -1,6 +1,13 @@ include/master-slave.inc [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows OFF +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, primary key(a)) engine=tokudb; insert into t values (1); insert into t values (2),(3); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result index 1ba442ecde2..daa04e5f43e 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result @@ -1,6 +1,13 @@ include/master-slave.inc [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows OFF +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, primary key(a)) engine=tokudb; insert into t values (1,0); insert into t values (2,0),(3,0); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result index 608e85249fb..518d3318710 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result @@ -1,6 +1,10 @@ include/master-slave.inc [connection master] drop table if exists t; +show variables like 'tokudb_rpl_unique_checks%'; +Variable_name Value +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk.result index c77cbbc71c9..6fab29177d7 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows OFF +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, primary key(a)) engine=tokudb; insert into t values (1); insert into t values (2),(3); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk_lookup1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk_lookup1.result index e178b8ad137..f8efd5e04ee 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk_lookup1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_delete_pk_lookup1.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks ON +tokudb_rpl_unique_checks_delay 0 create table t (a bigint not null, primary key(a)) engine=tokudb; insert into t values (1); insert into t values (2),(3); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result index 30c3d188f9a..59b05ea4dfb 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result @@ -1,3 +1,6 @@ +SET SESSION tokudb_pk_insert_mode = 2; +Warnings: +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. include/master-slave.inc [connection master] ==========MASTER========== diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ff.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ff.result index 5926cdda565..76a5e31b969 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ff.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ff.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl%'; +Variable_name Value +tokudb_rpl_check_readonly OFF +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 0 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ft.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ft.result index 3bcd3e8ccdd..c81a2ebac44 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ft.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_ft.result @@ -1,6 +1,13 @@ include/master-slave.inc [connection master] drop table if exists t; +show variables like 'tokudb_rpl%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 0 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tf.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tf.result index 5926cdda565..76a5e31b969 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tf.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tf.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl%'; +Variable_name Value +tokudb_rpl_check_readonly OFF +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 0 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tt.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tt.result index 5926cdda565..0cba2a1cddb 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tt.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_read_only_tt.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 0 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup0.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup0.result index 162655f9896..50f43ebe5bf 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup0.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup0.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows OFF +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, primary key(a)) engine=tokudb; insert into t values (1,0); insert into t values (2,0),(3,0); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup1.result index 3c909718426..9e7f932a3c9 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc0_lookup1.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, primary key(a)) engine=tokudb; insert into t values (1,0); insert into t values (2,0),(3,0); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup0.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup0.result index 3c909718426..348734b206d 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup0.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup0.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows OFF +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks ON +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, primary key(a)) engine=tokudb; insert into t values (1,0); insert into t values (2,0),(3,0); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result index 3c909718426..bfd640e52e9 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks ON +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, primary key(a)) engine=tokudb; insert into t values (1,0); insert into t values (2,0),(3,0); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup0.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup0.result index 941010071ae..faf969f851a 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup0.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup0.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows OFF +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, c bigint not null, primary key(a), unique key(c)) engine=tokudb; insert into t values (1,0,-1); insert into t values (2,0,-2),(3,0,-3); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup1.result index 6a0b1126710..9ac87512f80 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_unique_uc0_lookup1.result @@ -4,6 +4,13 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_%'; +Variable_name Value +tokudb_rpl_check_readonly ON +tokudb_rpl_lookup_rows ON +tokudb_rpl_lookup_rows_delay 10000 +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, b bigint not null, c bigint not null, primary key(a), unique key(c)) engine=tokudb; insert into t values (1,0,-1); insert into t values (2,0,-2),(3,0,-3); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk.result index 5926cdda565..ea1b84f8138 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk.result @@ -4,6 +4,10 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_unique_checks%'; +Variable_name Value +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk_uc1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk_uc1.result index 0b5ac77481f..c846ec81612 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk_uc1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_pk_uc1.result @@ -4,6 +4,10 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_unique_checks%'; +Variable_name Value +tokudb_rpl_unique_checks ON +tokudb_rpl_unique_checks_delay 10000 create table t (a bigint not null, primary key(a)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique.result index 60ffc0d0530..808303387d5 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique.result @@ -4,6 +4,10 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_unique_checks%'; +Variable_name Value +tokudb_rpl_unique_checks OFF +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, b bigint not null, primary key(a), unique key(b)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1,2); diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique_uc1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique_uc1.result index 2f2cf58032e..a40548cec62 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique_uc1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_write_unique_uc1.result @@ -4,6 +4,10 @@ Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] drop table if exists t; +show variables like 'tokudb_rpl_unique_checks%'; +Variable_name Value +tokudb_rpl_unique_checks ON +tokudb_rpl_unique_checks_delay 5000 create table t (a bigint not null, b bigint not null, primary key(a), unique key(b)) engine=tokudb; select unix_timestamp() into @tstart; insert into t values (1,2); diff --git a/storage/tokudb/mysql-test/rpl/t/disabled.def b/storage/tokudb/mysql-test/rpl/t/disabled.def new file mode 100644 index 00000000000..30bc9fea7c5 --- /dev/null +++ b/storage/tokudb/mysql-test/rpl/t/disabled.def @@ -0,0 +1 @@ +rpl_row_sp002_tokudb : tokudb does not support foreign keys diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb.test b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb.test index efb60fac2ba..23d2d6cdf51 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb.test @@ -1,3 +1,4 @@ +--source include/have_tokudb.inc #Want to skip this test from daily Valgrind execution --source include/no_valgrind_without_big.inc # diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk-slave.opt index 98240735800..0aa48174807 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk-slave.opt @@ -1,6 +1,5 @@ --read-only=ON ---tokudb-rpl-unique-checks-delay=10000 ---tokudb-rpl-unique-checks=OFF ---tokudb-rpl-lookup-rows-delay=10000 ---tokudb-rpl-lookup-rows=OFF - +--loose-tokudb-rpl-unique-checks-delay=10000 +--loose-tokudb-rpl-unique-checks=OFF +--loose-tokudb-rpl-lookup-rows-delay=10000 +--loose-tokudb-rpl-lookup-rows=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test index fb42f40bb62..bedeb9513be 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0-slave.opt index 8d0e95decb2..0aa48174807 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0-slave.opt @@ -1,5 +1,5 @@ --read-only=ON ---tokudb-rpl-unique-checks-delay=10000 ---tokudb-rpl-unique-checks=OFF ---tokudb-rpl-lookup-rows-delay=10000 ---tokudb-rpl-lookup-rows=OFF +--loose-tokudb-rpl-unique-checks-delay=10000 +--loose-tokudb-rpl-unique-checks=OFF +--loose-tokudb-rpl-lookup-rows-delay=10000 +--loose-tokudb-rpl-lookup-rows=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0.test index 62e123d5a04..d6ccf2487ae 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_update_pk_uc0_lookup0.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk-slave.opt index c11308c89bf..7f49776e4e8 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk-slave.opt @@ -1,3 +1,3 @@ --read-only=ON ---tokudb-rpl-unique-checks-delay=5000 ---tokudb-rpl-unique-checks=OFF +--loose-tokudb-rpl-unique-checks-delay=5000 +--loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk.test index bd27ceb2c2b..db96ac321c0 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_write_pk.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl_unique_checks%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk-slave.opt index dc139282dc4..93a2685e847 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=OFF --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=OFF +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=OFF --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test index fb42f40bb62..bedeb9513be 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1-slave.opt index 4675b07763d..9a2fec628f9 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=0 --tokudb-rpl-unique-checks=ON --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=ON +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=0 --loose-tokudb-rpl-unique-checks=ON --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=ON diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test index bf5edbd2c1b..9e9aaede416 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test @@ -15,7 +15,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml-master.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml-master.opt deleted file mode 100644 index fd3de58d816..00000000000 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---tokudb_pk_insert_mode=2 - diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml.test index c27625abd7f..6147d321784 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_mixed_dml.test @@ -6,4 +6,7 @@ --source include/have_binlog_format_mixed.inc --source include/have_tokudb.inc let $engine_type=TokuDB; + +SET SESSION tokudb_pk_insert_mode = 2; + --source suite/rpl/include/rpl_mixed_dml.inc diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff-slave.opt index b9eb687d8d5..0240c9d6ae4 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff-slave.opt @@ -1 +1 @@ ---read-only=OFF --tokudb-rpl-check-readonly=OFF --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF +--read-only=OFF --loose-tokudb-rpl-check-readonly=OFF --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test index c77e4b49605..7b3e8f0c0d3 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft-slave.opt index 8283875e8a7..e1ee193d4c1 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft-slave.opt @@ -1 +1 @@ ---read-only=OFF --tokudb-rpl-check-readonly=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF +--read-only=OFF --loose-tokudb-rpl-check-readonly=ON --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test index c77e4b49605..7b3e8f0c0d3 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf-slave.opt index 21e57d27c17..e60afd0380a 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-check-readonly=OFF --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF +--read-only=ON --loose-tokudb-rpl-check-readonly=OFF --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test index c77e4b49605..7b3e8f0c0d3 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt-slave.opt index fd77ee0da9c..f6658646e65 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-check-readonly=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF +--read-only=ON --loose-tokudb-rpl-check-readonly=ON --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test index c77e4b49605..7b3e8f0c0d3 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0-slave.opt index dc139282dc4..93a2685e847 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=OFF --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=OFF +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=OFF --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test index 998987349c7..6dd9b660eed 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1-slave.opt index d546dd00669..a4ca1104425 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=OFF --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=ON +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=OFF --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=ON diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test index 998987349c7..6dd9b660eed 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0-slave.opt index 5cfe5f83a91..4b1d21daf5f 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=ON --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=OFF +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=ON --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test index 998987349c7..6dd9b660eed 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1-slave.opt index 7cd575c52bb..239e19ac040 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=ON --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=ON +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=ON --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=ON diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test index 998987349c7..6dd9b660eed 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0-slave.opt index dc139282dc4..93a2685e847 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=OFF --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=OFF +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=OFF --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test index 11401ac0ce0..93fef3699d9 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1-slave.opt index d546dd00669..a4ca1104425 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=OFF --tokudb-rpl-lookup-rows-delay=10000 --tokudb-rpl-lookup-rows=ON +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=OFF --loose-tokudb-rpl-lookup-rows-delay=10000 --loose-tokudb-rpl-lookup-rows=ON diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test index ea77447bc75..c8976db8ccd 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test @@ -13,7 +13,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_%'; +show variables like 'tokudb_rpl_%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk-slave.opt index 9baf0d65ecf..19b40f86454 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test index c77e4b49605..0ed12b34e1f 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl_unique_checks%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1-slave.opt index b1df0b6daf0..646a9991753 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=10000 --tokudb-rpl-unique-checks=ON +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=10000 --loose-tokudb-rpl-unique-checks=ON diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test index c77e4b49605..0ed12b34e1f 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl_unique_checks%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique-slave.opt index 9baf0d65ecf..19b40f86454 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=OFF +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=OFF diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test index cf6a26b423d..fc4c9597dac 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl_unique_checks%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1-slave.opt b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1-slave.opt index 0518efd3da5..9139a370e57 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1-slave.opt +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1-slave.opt @@ -1 +1 @@ ---read-only=ON --tokudb-rpl-unique-checks-delay=5000 --tokudb-rpl-unique-checks=ON +--read-only=ON --loose-tokudb-rpl-unique-checks-delay=5000 --loose-tokudb-rpl-unique-checks=ON diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test index cf6a26b423d..fc4c9597dac 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test @@ -14,7 +14,7 @@ enable_warnings; connection slave; # show variables like 'read_only'; -# show variables like 'tokudb_rpl_unique_checks%'; +show variables like 'tokudb_rpl_unique_checks%'; # insert some rows connection master; diff --git a/storage/tokudb/mysql-test/rpl/t/suite.opt b/storage/tokudb/mysql-test/rpl/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/rpl/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb/bulk-fetch-gen.py b/storage/tokudb/mysql-test/tokudb/bulk-fetch-gen.py index f125ce771da..4e343772511 100644 --- a/storage/tokudb/mysql-test/tokudb/bulk-fetch-gen.py +++ b/storage/tokudb/mysql-test/tokudb/bulk-fetch-gen.py @@ -71,6 +71,7 @@ tables = [ ] # Code generation stats here +print "source include/have_tokudb.inc;" print "# Tokutek" print "# Test that bulk fetch works with various table types" print "" diff --git a/storage/tokudb/mysql-test/tokudb/disabled.def b/storage/tokudb/mysql-test/tokudb/disabled.def index 5b7afa1753e..c98a8aa622a 100644 --- a/storage/tokudb/mysql-test/tokudb/disabled.def +++ b/storage/tokudb/mysql-test/tokudb/disabled.def @@ -26,9 +26,5 @@ type_temporal_fractional: type_temporal_upgrade: type_timestamp_explicit: cluster_key_part: engine options on partitioned tables -#i_s_tokudb_lock_waits_released: unstable, race conditions -#i_s_tokudb_locks_released: unstable, race conditions -mvcc-19: tokutek -mvcc-20: tokutek -mvcc-27: tokutek -storage_engine_default: tokudb is not the default storage engine +i_s_tokudb_lock_waits_released: unstable, race conditions +i_s_tokudb_locks_released: unstable, race conditions diff --git a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc new file mode 100644 index 00000000000..d637b46e8fc --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc @@ -0,0 +1,138 @@ +# test for TokuDB clustering keys. +# test assumes that a table 't1' exists with the following columns: +# a int, b int, c int, d int +insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); + + +#normal queries + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where a > 5; +select * from t1 where a > 5; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where b > 30; +select * from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where c > 750; +select * from t1 where c > 750; + +#covering indexes + +# ignore rows column +--replace_column 9 NULL; +explain select a from t1 where a > 8; +select a from t1 where a > 8; + +# ignore rows column +--replace_column 9 NULL; +explain select a,b from t1 where b > 30; +select a,b from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select a,b from t1 where c > 750; +select a,c from t1 where c > 750; + + +alter table t1 add index bdca(b,d,c,a) clustering=yes; +insert into t1 values (10,10,10,10); +alter table t1 drop index bdca; + +alter table t1 drop primary key; +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where a > 5; +select * from t1 where a > 5; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where b > 30; +select * from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where c > 750; +select * from t1 where c > 750; + +#covering indexes + +# ignore rows column +--replace_column 9 NULL; +explain select b from t1 where b > 30; +select b from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select b from t1 where c > 750; +select c from t1 where c > 750; + +alter table t1 add e varchar(20); + +alter table t1 add primary key (a,b,c); + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where a > 5; +select * from t1 where a > 5; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where b > 30; +select * from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where c > 750; +select * from t1 where c > 750; + +#covering indexes + +# ignore rows column +--replace_column 9 NULL; +explain select a from t1 where a > 8; +select a from t1 where a > 8; + +# ignore rows column +--replace_column 9 NULL; +explain select a,b from t1 where b > 30; +select a,b from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select a,b from t1 where c > 750; +select a,c from t1 where c > 750; + + +alter table t1 drop primary key; +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where a > 5; +select * from t1 where a > 5; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where b > 30; +select * from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select * from t1 where c > 750; +select * from t1 where c > 750; + +#covering indexes +# ignore rows column +--replace_column 9 NULL; +explain select b from t1 where b > 30; +select b from t1 where b > 30; + +# ignore rows column +--replace_column 9 NULL; +explain select b from t1 where c > 750; +select c from t1 where c > 750; + + diff --git a/storage/tokudb/mysql-test/tokudb/locks-blocking-row-locks-testgen.py b/storage/tokudb/mysql-test/tokudb/locks-blocking-row-locks-testgen.py index 372431ada04..28bea5dea56 100644 --- a/storage/tokudb/mysql-test/tokudb/locks-blocking-row-locks-testgen.py +++ b/storage/tokudb/mysql-test/tokudb/locks-blocking-row-locks-testgen.py @@ -56,6 +56,7 @@ write_range_queries = [ timeouts = [0, 500] # Here's where all the magic happens +print "source include/have_tokudb.inc;" print "# Tokutek" print "# Blocking row lock tests;" print "# Generated by %s on %s;" % (__file__, datetime.date.today()) diff --git a/storage/tokudb/mysql-test/tokudb/r/background_job_manager.result b/storage/tokudb/mysql-test/tokudb/r/background_job_manager.result new file mode 100644 index 00000000000..5769ee74071 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/r/background_job_manager.result @@ -0,0 +1,122 @@ +set @orig_auto_analyze = @@session.tokudb_auto_analyze; +set @orig_in_background = @@session.tokudb_analyze_in_background; +set @orig_mode = @@session.tokudb_analyze_mode; +set @orig_throttle = @@session.tokudb_analyze_throttle; +set @orig_time = @@session.tokudb_analyze_time; +set @orig_scale_percent = @@global.tokudb_cardinality_scale_percent; +set @orig_default_storage_engine = @@session.default_storage_engine; +set @orig_pause_background_job_manager = @@global.tokudb_debug_pause_background_job_manager; +set session default_storage_engine='tokudb'; +set session tokudb_auto_analyze=1; +set session tokudb_analyze_in_background=1; +set session tokudb_analyze_mode=tokudb_analyze_standard; +set session tokudb_analyze_throttle=0; +set session tokudb_analyze_time=0; +set global tokudb_cardinality_scale_percent=DEFAULT; +set global tokudb_debug_pause_background_job_manager=TRUE; +show create table information_schema.tokudb_background_job_status; +Table Create Table +TokuDB_background_job_status CREATE TEMPORARY TABLE `TokuDB_background_job_status` ( + `id` bigint(0) NOT NULL DEFAULT '0', + `database_name` varchar(256) NOT NULL DEFAULT '', + `table_name` varchar(256) NOT NULL DEFAULT '', + `job_type` varchar(256) NOT NULL DEFAULT '', + `job_params` varchar(256) NOT NULL DEFAULT '', + `scheduler` varchar(32) NOT NULL DEFAULT '', + `scheduled_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `started_time` datetime DEFAULT NULL, + `status` varchar(256) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8 +create table t1 (a int not null auto_increment, b int, c int, primary key(a), key kb(b), key kc(c), key kabc(a,b,c), key kab(a,b), key kbc(b,c)); +insert into t1(b,c) values(0,0), (1,1), (2,2), (3,3); +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t1 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; AUTO +create table t2 like t1; +create table t3 like t1; +create table t4 like t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Operation failed +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +analyze table t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t1 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; AUTO +test t2 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t3 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t4 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +set global tokudb_debug_pause_background_job_manager=FALSE; +set global tokudb_debug_pause_background_job_manager=TRUE; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +analyze table t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t1 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t2 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t3 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t4 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +alter table t1 add column d int; +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t2 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t3 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t4 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +set session tokudb_analyze_mode=tokudb_analyze_cancel; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t3 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t4 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +set session tokudb_analyze_mode=tokudb_analyze_recount_rows; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t3 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t4 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t1 TOKUDB_ANALYZE_MODE_RECOUNT_ROWS TOKUDB_ANALYZE_THROTTLE=0; USER +set session tokudb_analyze_mode=tokudb_analyze_standard; +set session tokudb_analyze_in_background=0; +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t4 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; USER +test t1 TOKUDB_ANALYZE_MODE_RECOUNT_ROWS TOKUDB_ANALYZE_THROTTLE=0; USER +drop table t1; +drop table t2; +drop table t3; +drop table t4; +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +set global tokudb_debug_pause_background_job_manager=FALSE; +set session tokudb_auto_analyze = @orig_auto_analyze; +set session tokudb_analyze_in_background = @orig_in_background; +set session tokudb_analyze_mode = @orig_mode; +set session tokudb_analyze_throttle = @orig_throttle; +set session tokudb_analyze_time = @orig_time; +set global tokudb_cardinality_scale_percent = @orig_scale_percent; +set session default_storage_engine = @orig_default_storage_engine; +set global tokudb_debug_pause_background_job_manager = @orig_pause_background_job_manager; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_add_drop.result b/storage/tokudb/mysql-test/tokudb/r/card_add_drop.result index 431f0200a7a..71a39eb1f3e 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_add_drop.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_add_drop.result @@ -4,35 +4,35 @@ create table tt (a int, b int, c int, d int, key(a), key(b), key(c)); insert into tt values (0,0,0,0),(1,0,0,0),(2,0,1,0),(3,0,1,0); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 a 1 a A NULL NULL NULL YES BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 a 1 a A 4 NULL NULL YES BTREE +tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 1 a 1 a A 4 NULL NULL YES BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE alter table tt drop key b, add key (d); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 1 a 1 a A 4 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE -tt 1 d 1 d A NULL NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE +tt 1 d 1 d A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 1 a 1 a A 4 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE -tt 1 d 1 d A 1 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE +tt 1 d 1 d A 2 NULL NULL YES BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 1 a 1 a A 4 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE -tt 1 d 1 d A 1 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE +tt 1 d 1 d A 2 NULL NULL YES BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_add_index.result b/storage/tokudb/mysql-test/tokudb/r/card_add_index.result index f5ba5b58bed..9a929b19a80 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_add_index.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_add_index.result @@ -15,32 +15,32 @@ alter table tt add key (b); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE alter table tt add key (c); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_auto_analyze_lots.result b/storage/tokudb/mysql-test/tokudb/r/card_auto_analyze_lots.result new file mode 100644 index 00000000000..662ffbade25 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/r/card_auto_analyze_lots.result @@ -0,0 +1,805 @@ +SHOW INDEX FROM ar_200; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_200 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_200 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_199; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_199 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_199 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_198; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_198 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_198 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_197; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_197 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_197 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_196; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_196 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_196 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_195; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_195 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_195 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_194; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_194 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_194 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_193; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_193 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_193 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_192; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_192 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_192 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_191; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_191 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_191 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_190; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_190 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_190 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_189; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_189 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_189 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_188; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_188 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_188 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_187; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_187 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_187 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_186; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_186 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_186 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_185; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_185 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_185 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_184; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_184 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_184 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_183; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_183 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_183 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_182; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_182 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_182 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_181; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_181 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_181 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_180; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_180 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_180 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_179; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_179 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_179 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_178; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_178 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_178 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_177; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_177 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_177 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_176; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_176 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_176 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_175; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_175 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_175 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_174; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_174 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_174 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_173; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_173 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_173 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_172; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_172 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_172 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_171; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_171 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_171 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_170; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_170 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_170 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_169; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_169 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_169 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_168; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_168 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_168 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_167; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_167 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_167 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_166; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_166 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_166 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_165; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_165 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_165 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_164; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_164 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_164 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_163; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_163 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_163 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_162; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_162 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_162 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_161; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_161 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_161 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_160; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_160 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_160 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_159; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_159 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_159 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_158; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_158 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_158 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_157; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_157 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_157 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_156; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_156 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_156 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_155; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_155 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_155 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_154; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_154 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_154 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_153; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_153 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_153 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_152; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_152 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_152 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_151; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_151 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_151 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_150; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_150 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_150 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_149; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_149 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_149 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_148; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_148 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_148 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_147; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_147 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_147 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_146; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_146 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_146 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_145; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_145 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_145 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_144; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_144 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_144 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_143; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_143 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_143 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_142; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_142 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_142 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_141; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_141 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_141 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_140; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_140 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_140 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_139; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_139 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_139 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_138; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_138 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_138 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_137; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_137 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_137 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_136; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_136 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_136 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_135; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_135 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_135 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_134; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_134 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_134 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_133; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_133 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_133 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_132; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_132 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_132 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_131; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_131 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_131 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_130; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_130 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_130 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_129; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_129 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_129 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_128; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_128 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_128 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_127; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_127 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_127 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_126; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_126 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_126 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_125; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_125 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_125 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_124; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_124 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_124 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_123; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_123 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_123 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_122; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_122 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_122 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_121; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_121 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_121 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_120; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_120 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_120 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_119; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_119 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_119 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_118; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_118 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_118 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_117; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_117 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_117 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_116; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_116 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_116 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_115; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_115 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_115 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_114; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_114 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_114 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_113; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_113 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_113 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_112; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_112 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_112 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_111; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_111 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_111 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_110; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_110 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_110 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_109; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_109 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_109 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_108; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_108 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_108 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_107; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_107 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_107 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_106; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_106 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_106 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_105; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_105 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_105 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_104; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_104 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_104 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_103; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_103 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_103 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_102; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_102 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_102 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_101; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_101 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_101 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_100; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_100 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_100 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_99; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_99 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_99 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_98; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_98 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_98 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_97; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_97 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_97 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_96; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_96 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_96 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_95; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_95 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_95 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_94; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_94 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_94 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_93; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_93 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_93 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_92; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_92 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_92 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_91; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_91 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_91 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_90; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_90 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_90 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_89; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_89 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_89 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_88; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_88 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_88 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_87; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_87 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_87 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_86; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_86 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_86 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_85; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_85 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_85 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_84; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_84 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_84 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_83; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_83 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_83 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_82; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_82 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_82 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_81; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_81 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_81 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_80; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_80 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_80 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_79; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_79 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_79 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_78; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_78 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_78 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_77; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_77 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_77 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_76; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_76 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_76 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_75; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_75 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_75 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_74; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_74 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_74 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_73; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_73 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_73 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_72; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_72 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_72 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_71; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_71 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_71 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_70; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_70 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_70 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_69; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_69 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_69 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_68; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_68 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_68 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_67; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_67 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_67 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_66; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_66 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_66 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_65; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_65 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_65 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_64; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_64 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_64 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_63; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_63 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_63 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_62; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_62 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_62 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_61; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_61 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_61 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_60; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_60 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_60 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_59; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_59 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_59 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_58; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_58 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_58 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_57; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_57 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_57 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_56; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_56 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_56 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_55; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_55 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_55 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_54; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_54 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_54 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_53; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_53 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_53 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_52; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_52 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_52 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_51; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_51 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_51 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_50; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_50 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_50 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_49; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_49 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_49 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_48; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_48 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_48 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_47; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_47 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_47 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_46; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_46 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_46 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_45; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_45 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_45 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_44; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_44 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_44 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_43; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_43 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_43 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_42; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_42 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_42 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_41; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_41 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_41 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_40; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_40 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_40 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_39; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_39 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_39 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_38; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_38 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_38 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_37; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_37 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_37 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_36; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_36 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_36 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_35; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_35 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_35 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_34; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_34 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_34 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_33; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_33 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_33 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_32; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_32 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_32 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_31; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_31 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_31 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_30; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_30 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_30 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_29; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_29 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_29 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_28; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_28 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_28 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_27; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_27 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_27 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_26; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_26 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_26 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_25; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_25 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_25 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_24; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_24 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_24 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_23; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_23 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_23 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_22; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_22 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_22 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_21; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_21 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_21 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_20; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_20 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_20 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_19; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_19 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_19 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_18; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_18 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_18 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_17; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_17 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_17 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_16; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_16 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_16 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_15; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_15 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_15 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_14; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_14 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_14 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_13; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_13 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_13 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_12; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_12 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_12 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_11; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_11 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_11 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_10; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_10 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_10 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_9; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_9 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_9 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_8; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_8 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_8 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_7; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_7 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_7 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_6; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_6 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_6 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_5; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_5 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_5 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_4; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_4 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_4 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_3; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_3 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_3 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_2 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_2 1 bkey 1 b A 1 NULL NULL YES BTREE +SHOW INDEX FROM ar_1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +ar_1 0 PRIMARY 1 a A 1 NULL NULL BTREE +ar_1 1 bkey 1 b A 1 NULL NULL YES BTREE +SET SESSION tokudb_auto_analyze = @orig_auto_analyze; +SET SESSION tokudb_analyze_in_background = @orig_in_background; +SET SESSION tokudb_analyze_mode = @orig_mode; +SET SESSION tokudb_analyze_throttle = @orig_throttle; +SET SESSION tokudb_analyze_time = @orig_time; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_drop_index.result b/storage/tokudb/mysql-test/tokudb/r/card_drop_index.result index 9fc8fb6a6b8..2cfdfe11296 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_drop_index.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_drop_index.result @@ -5,21 +5,21 @@ insert into tt values (1,0,0),(2,0,0),(3,0,1),(4,0,1); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE alter table tt drop key b; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE alter table tt drop key c; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment diff --git a/storage/tokudb/mysql-test/tokudb/r/card_drop_index_2.result b/storage/tokudb/mysql-test/tokudb/r/card_drop_index_2.result index 4103a37a6ed..ed28d2a3226 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_drop_index_2.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_drop_index_2.result @@ -132,21 +132,21 @@ count(*) show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 500 NULL NULL BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 b 1 b A 500 NULL NULL YES BTREE +tt 1 c 1 c A 500 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 500 NULL NULL BTREE -tt 1 b 1 b A 125 NULL NULL YES BTREE -tt 1 c 1 c A 1 NULL NULL YES BTREE +tt 1 b 1 b A 250 NULL NULL YES BTREE +tt 1 c 1 c A 2 NULL NULL YES BTREE alter table tt drop key b; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 500 NULL NULL BTREE -tt 1 c 1 c A 1 NULL NULL YES BTREE +tt 1 c 1 c A 2 NULL NULL YES BTREE alter table tt drop key c; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment diff --git a/storage/tokudb/mysql-test/tokudb/r/card_drop_pk.result b/storage/tokudb/mysql-test/tokudb/r/card_drop_pk.result index bdbd9a3f097..2369d88c274 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_drop_pk.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_drop_pk.result @@ -5,24 +5,24 @@ insert into tt values (1,0,0),(2,0,0),(3,0,1),(4,0,1); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE -tt 1 c 1 c A 2 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE alter table tt drop primary key; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 b 1 b A NULL NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 b 1 b A NULL NULL NULL YES BTREE -tt 1 c 1 c A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 c 1 c A 4 NULL NULL YES BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_pk_2.result b/storage/tokudb/mysql-test/tokudb/r/card_pk_2.result index dd850df9a89..3c1b652db15 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_pk_2.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_pk_2.result @@ -4,18 +4,18 @@ create table tt (a int, b int, primary key(a,b)); insert into tt values (0,0),(0,1),(1,0),(1,1); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 0 PRIMARY 1 a A NULL NULL NULL BTREE +tt 0 PRIMARY 1 a A 4 NULL NULL BTREE tt 0 PRIMARY 2 b A 4 NULL NULL BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 0 PRIMARY 1 a A 2 NULL NULL BTREE +tt 0 PRIMARY 1 a A 4 NULL NULL BTREE tt 0 PRIMARY 2 b A 4 NULL NULL BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 0 PRIMARY 1 a A 2 NULL NULL BTREE +tt 0 PRIMARY 1 a A 4 NULL NULL BTREE tt 0 PRIMARY 2 b A 4 NULL NULL BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_pk_sk.result b/storage/tokudb/mysql-test/tokudb/r/card_pk_sk.result index 5458f19de32..02c8d1f8218 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_pk_sk.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_pk_sk.result @@ -1004,7 +1004,7 @@ insert into tt values (4*999,4*999+1),(4*999+1,4*999+2),(4*999+2,4*999+3),(4*999 show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4000 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK @@ -2022,17 +2022,17 @@ insert into tt values (4*999,0),(4*999+1,0),(4*999+2,0),(4*999+3,0); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE -tt 1 b 1 b A NULL NULL NULL YES BTREE +tt 1 b 1 b A 4000 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE -tt 1 b 1 b A 1 NULL NULL YES BTREE +tt 1 b 1 b A 2 NULL NULL YES BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_scale_percent.result b/storage/tokudb/mysql-test/tokudb/r/card_scale_percent.result new file mode 100644 index 00000000000..cfd7e38179c --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/r/card_scale_percent.result @@ -0,0 +1,42 @@ +set global tokudb_cardinality_scale_percent = 10; +analyze table tt; +Table Op Msg_type Msg_text +test.tt analyze status OK +show indexes from tt; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE +tt 1 b 1 b A 4000 NULL NULL YES BTREE +tt 1 c 1 c A 4000 NULL NULL YES BTREE +tt 1 d 1 d A 4000 NULL NULL YES BTREE +set global tokudb_cardinality_scale_percent = 50; +analyze table tt; +Table Op Msg_type Msg_text +test.tt analyze status OK +show indexes from tt; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE +tt 1 b 1 b A 4000 NULL NULL YES BTREE +tt 1 c 1 c A 4000 NULL NULL YES BTREE +tt 1 d 1 d A 2000 NULL NULL YES BTREE +set global tokudb_cardinality_scale_percent = 100; +analyze table tt; +Table Op Msg_type Msg_text +test.tt analyze status OK +show indexes from tt; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE +tt 1 b 1 b A 4000 NULL NULL YES BTREE +tt 1 c 1 c A 2000 NULL NULL YES BTREE +tt 1 d 1 d A 1000 NULL NULL YES BTREE +set global tokudb_cardinality_scale_percent = 200; +Warnings: +Warning 1292 Truncated incorrect tokudb_cardinality_scale_percent value: '200' +analyze table tt; +Table Op Msg_type Msg_text +test.tt analyze status OK +show indexes from tt; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +tt 0 PRIMARY 1 a A 4000 NULL NULL BTREE +tt 1 b 1 b A 4000 NULL NULL YES BTREE +tt 1 c 1 c A 2000 NULL NULL YES BTREE +tt 1 d 1 d A 1000 NULL NULL YES BTREE diff --git a/storage/tokudb/mysql-test/tokudb/r/card_sk.result b/storage/tokudb/mysql-test/tokudb/r/card_sk.result index 1846b4e82bc..310fc863a9b 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_sk.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_sk.result @@ -5,15 +5,15 @@ insert into tt values (1,0),(2,1),(3,2),(4,3); insert into tt values (5,0),(6,1),(7,2),(8,3); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 b 1 b A NULL NULL NULL YES BTREE +tt 1 b 1 b A 8 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 b 1 b A 8 NULL NULL YES BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 b 1 b A 4 NULL NULL YES BTREE +tt 1 b 1 b A 8 NULL NULL YES BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/card_sk_2.result b/storage/tokudb/mysql-test/tokudb/r/card_sk_2.result index c087bad3b18..8ff57b63e5d 100644 --- a/storage/tokudb/mysql-test/tokudb/r/card_sk_2.result +++ b/storage/tokudb/mysql-test/tokudb/r/card_sk_2.result @@ -4,18 +4,18 @@ create table tt (a int, b int, key(a,b)); insert into tt values (0,0),(0,1),(1,0),(1,1); show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 a 1 a A NULL NULL NULL YES BTREE -tt 1 a 2 b A NULL NULL NULL YES BTREE +tt 1 a 1 a A 4 NULL NULL YES BTREE +tt 1 a 2 b A 4 NULL NULL YES BTREE analyze table tt; Table Op Msg_type Msg_text test.tt analyze status OK show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 a 1 a A 2 NULL NULL YES BTREE +tt 1 a 1 a A 4 NULL NULL YES BTREE tt 1 a 2 b A 4 NULL NULL YES BTREE flush tables; show indexes from tt; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -tt 1 a 1 a A 2 NULL NULL YES BTREE +tt 1 a 1 a A 4 NULL NULL YES BTREE tt 1 a 2 b A 4 NULL NULL YES BTREE drop table tt; diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-0.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-0.result index 1e0935543dc..9e524df3276 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-0.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-0.result @@ -1042,5 +1042,5 @@ t CREATE TABLE `t` ( explain select straight_join * from s,t where s.b = t.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s index b b 5 NULL 1000 Using where; Using index -1 SIMPLE t ref b b 5 test.s.b 11 Using index +1 SIMPLE t ref b b 5 test.s.b 1 Using index drop table s,t; diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-1.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-1.result index 9337718ce35..1aeb40d182a 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-1.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-1.result @@ -1042,7 +1042,7 @@ t CREATE TABLE `t` ( explain select straight_join * from s,t where s.b = t.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s ALL b NULL NULL NULL 1000 Using where -1 SIMPLE t ref b b 5 test.s.b 11 +1 SIMPLE t ref b b 5 test.s.b 1 alter table s add key(b) clustering=yes; Warnings: Note 1831 Duplicate index 'b_2' defined on the table 'test.s'. This is deprecated and will be disallowed in a future release. @@ -1092,7 +1092,7 @@ t CREATE TABLE `t` ( explain select straight_join * from s,t where s.b = t.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s index b_2 b_2 5 NULL 1000 Using where; Using index -1 SIMPLE t ref b_2 b_2 5 test.s.b 11 Using index +1 SIMPLE t ref b_2 b_2 5 test.s.b 1 Using index alter table s add key(b); Warnings: Note 1831 Duplicate index 'b' defined on the table 'test.s'. This is deprecated and will be disallowed in a future release. diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result index 710509b2acf..9fdb28404c7 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result @@ -1042,7 +1042,7 @@ t CREATE TABLE `t` ( explain select straight_join s.a,t.a from s,t where s.b = t.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s ALL b NULL NULL NULL 1000 Using where -1 SIMPLE t ref b b 5 test.s.b 11 +1 SIMPLE t ref b b 5 test.s.b 1 alter table s add key(b,a); alter table t add key(b,a); show create table s; @@ -1066,7 +1066,7 @@ t CREATE TABLE `t` ( explain select straight_join s.a,t.a from s,t where s.b = t.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s index b,b_2 b_2 10 NULL 1000 Using where; Using index -1 SIMPLE t ref b,b_2 b_2 5 test.s.b 11 Using index +1 SIMPLE t ref b,b_2 b_2 5 test.s.b 1 Using index alter table s add key(b) clustering=yes; Warnings: Note 1831 Duplicate index 'b_3' defined on the table 'test.s'. This is deprecated and will be disallowed in a future release. @@ -1096,7 +1096,7 @@ t CREATE TABLE `t` ( explain select straight_join s.a,t.a from s,t where s.b = t.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s index b,b_2,b_3 b_2 10 NULL 1000 Using where; Using index -1 SIMPLE t ref b,b_2,b_3 b_3 5 test.s.b 1 Using index +1 SIMPLE t ref b,b_2,b_3 b_2 5 test.s.b 1 Using index alter table s drop key b_2; alter table t drop key b_2; show create table s; diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-3.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-3.result index 660d63c54c8..eec0e67ef30 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-3.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-3.result @@ -1062,8 +1062,8 @@ u CREATE TABLE `u` ( explain select straight_join * from s,t,u where s.b = t.b and s.c = u.c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE s ALL b NULL NULL NULL 1000 Using where -1 SIMPLE t ref b b 5 test.s.b 11 -1 SIMPLE u ref c c 5 test.s.c 11 +1 SIMPLE t ref b b 5 test.s.b 1 +1 SIMPLE u ref c c 5 test.s.c 1 alter table s add key (b) clustering=yes; Warnings: Note 1831 Duplicate index 'b_2' defined on the table 'test.s'. This is deprecated and will be disallowed in a future release. diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result index 74298d69114..fab288047be 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result @@ -1,6 +1,6 @@ SET DEFAULT_STORAGE_ENGINE='tokudb'; DROP TABLE IF EXISTS t1; -create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; +create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb; insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); explain select * from t1 where a > 5; id select_type table type possible_keys key key_len ref rows Extra @@ -13,7 +13,7 @@ a b c d 9 90 900 9000 explain select * from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index select * from t1 where b > 30; a b c d 4 40 400 4000 @@ -24,7 +24,7 @@ a b c d 9 90 900 9000 explain select * from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 range c c 4 NULL NULL; Using where select * from t1 where c > 750; a b c d 8 80 800 8000 @@ -37,7 +37,7 @@ a 9 explain select a,b from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index select a,b from t1 where b > 30; a b 4 40 @@ -48,7 +48,7 @@ a b 9 90 explain select a,b from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index select a,c from t1 where c > 750; a c 8 800 @@ -69,7 +69,7 @@ a b c d 10 10 10 10 explain select * from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index select * from t1 where b > 30; a b c d 4 40 400 4000 @@ -80,14 +80,14 @@ a b c d 9 90 900 9000 explain select * from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 range c c 4 NULL NULL; Using where select * from t1 where c > 750; a b c d 8 80 800 8000 9 90 900 9000 explain select b from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index select b from t1 where b > 30; b 40 @@ -98,13 +98,13 @@ b 90 explain select b from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 range c c 4 NULL NULL; Using where select c from t1 where c > 750; c 800 900 alter table t1 add e varchar(20); -alter table t1 add primary key (a); +alter table t1 add primary key (a,b,c); explain select * from t1 where a > 5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where @@ -117,7 +117,7 @@ a b c d e 10 10 10 10 NULL explain select * from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index select * from t1 where b > 30; a b c d e 4 40 400 4000 NULL @@ -128,7 +128,7 @@ a b c d e 9 90 900 9000 NULL explain select * from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 range c c 4 NULL NULL; Using where select * from t1 where c > 750; a b c d e 8 80 800 8000 NULL @@ -142,7 +142,7 @@ a 10 explain select a,b from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index select a,b from t1 where b > 30; a b 4 40 @@ -153,7 +153,7 @@ a b 9 90 explain select a,b from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index select a,c from t1 where c > 750; a c 8 800 @@ -171,7 +171,7 @@ a b c d e 10 10 10 10 NULL explain select * from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index select * from t1 where b > 30; a b c d e 4 40 400 4000 NULL @@ -182,14 +182,14 @@ a b c d e 9 90 900 9000 NULL explain select * from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 range c c 4 NULL NULL; Using where select * from t1 where c > 750; a b c d e 8 80 800 8000 NULL 9 90 900 9000 NULL explain select b from t1 where b > 30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index select b from t1 where b > 30; b 40 @@ -200,7 +200,7 @@ b 90 explain select b from t1 where c > 750; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL NULL; Using where +1 SIMPLE t1 range c c 4 NULL NULL; Using where select c from t1 where c > 750; c 800 diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_key_part.result b/storage/tokudb/mysql-test/tokudb/r/cluster_key_part.result index cd8fc340314..6df54cac05a 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_key_part.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_key_part.result @@ -1,11 +1,22 @@ set default_storage_engine='tokudb'; -drop table if exists t; -create table t ( -x int not null, -y int not null, -primary key(x)) -partition by hash(x) partitions 2; -show create table t; +DROP TABLE IF EXISTS t; +CREATE TABLE t (a INT NOT NULL AUTO_INCREMENT, b INT, PRIMARY KEY(a), CLUSTERING KEY b(b)) ENGINE=TokuDB +PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (100) ENGINE = TokuDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TokuDB); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL AUTO_INCREMENT, + `b` int(11) DEFAULT NULL, + PRIMARY KEY (`a`), + CLUSTERING KEY `b` (`b`) +) ENGINE=TokuDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (100) ENGINE = TokuDB, + PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TokuDB) */ +DROP TABLE t; +CREATE TABLE t (x INT NOT NULL, y INT NOT NULL, PRIMARY KEY(x)) +PARTITION BY HASH(x) PARTITIONS 2; +SHOW CREATE TABLE t; Table Create Table t CREATE TABLE `t` ( `x` int(11) NOT NULL, @@ -14,8 +25,8 @@ t CREATE TABLE `t` ( ) ENGINE=TokuDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (x) PARTITIONS 2 */ -alter table t add clustering key(y); -show create table t; +ALTER TABLE t ADD CLUSTERING KEY(y); +SHOW CREATE TABLE t; Table Create Table t CREATE TABLE `t` ( `x` int(11) NOT NULL, @@ -25,4 +36,625 @@ t CREATE TABLE `t` ( ) ENGINE=TokuDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (x) PARTITIONS 2 */ -drop table t; +DROP TABLE t; +CREATE TABLE t1(a INT, b INT, c INT, d INT, PRIMARY KEY(a,b,c), CLUSTERING KEY(b), KEY (c)) ENGINE=TOKUDB +PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (5) ENGINE = TOKUDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TOKUDB); +insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where +select * from t1 where a > 5; +a b c d +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d +4 40 400 4000 +5 50 500 5000 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d +8 80 800 8000 +9 90 900 9000 +explain select a from t1 where a > 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index +select a from t1 where a > 8; +a +9 +explain select a,b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select a,b from t1 where b > 30; +a b +4 40 +5 50 +6 60 +7 70 +8 80 +9 90 +explain select a,b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c b 4 NULL NULL; Using where; Using index +select a,c from t1 where c > 750; +a c +8 800 +9 900 +alter table t1 add clustering index bdca(b,d,c,a); +insert into t1 values (10,10,10,10); +alter table t1 drop index bdca; +alter table t1 drop primary key; +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where +select * from t1 where a > 5; +a b c d +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +10 10 10 10 +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d +4 40 400 4000 +5 50 500 5000 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d +8 80 800 8000 +9 90 900 9000 +explain select b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select b from t1 where b > 30; +b +40 +50 +60 +70 +80 +90 +explain select b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select c from t1 where c > 750; +c +800 +900 +alter table t1 add e varchar(20); +alter table t1 add primary key (a,b,c); +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where +select * from t1 where a > 5; +a b c d e +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +10 10 10 10 NULL +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d e +4 40 400 4000 NULL +5 50 500 5000 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d e +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select a from t1 where a > 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index +select a from t1 where a > 8; +a +9 +10 +explain select a,b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select a,b from t1 where b > 30; +a b +4 40 +5 50 +6 60 +7 70 +8 80 +9 90 +explain select a,b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where; Using index +select a,c from t1 where c > 750; +a c +8 800 +9 900 +alter table t1 drop primary key; +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where +select * from t1 where a > 5; +a b c d e +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +10 10 10 10 NULL +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d e +4 40 400 4000 NULL +5 50 500 5000 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d e +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select b from t1 where b > 30; +b +40 +50 +60 +70 +80 +90 +explain select b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select c from t1 where c > 750; +c +800 +900 +DROP TABLE t1; +CREATE TABLE t1(a INT, b INT, c INT, d INT, PRIMARY KEY(a,b,c), CLUSTERING KEY(b), KEY (c)) ENGINE=TOKUDB +PARTITION BY RANGE(b) (PARTITION p0 VALUES LESS THAN (50) ENGINE = TOKUDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TOKUDB); +insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where +select * from t1 where a > 5; +a b c d +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d +4 40 400 4000 +5 50 500 5000 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d +8 80 800 8000 +9 90 900 9000 +explain select a from t1 where a > 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index +select a from t1 where a > 8; +a +9 +explain select a,b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select a,b from t1 where b > 30; +a b +4 40 +5 50 +6 60 +7 70 +8 80 +9 90 +explain select a,b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c b 4 NULL NULL; Using where; Using index +select a,c from t1 where c > 750; +a c +8 800 +9 900 +alter table t1 add clustering index bdca(b,d,c,a); +insert into t1 values (10,10,10,10); +alter table t1 drop index bdca; +alter table t1 drop primary key; +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where +select * from t1 where a > 5; +a b c d +10 10 10 10 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d +4 40 400 4000 +5 50 500 5000 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d +8 80 800 8000 +9 90 900 9000 +explain select b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select b from t1 where b > 30; +b +40 +50 +60 +70 +80 +90 +explain select b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select c from t1 where c > 750; +c +800 +900 +alter table t1 add e varchar(20); +alter table t1 add primary key (a,b,c); +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where +select * from t1 where a > 5; +a b c d e +10 10 10 10 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d e +4 40 400 4000 NULL +5 50 500 5000 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d e +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select a from t1 where a > 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index +select a from t1 where a > 8; +a +10 +9 +explain select a,b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select a,b from t1 where b > 30; +a b +4 40 +5 50 +6 60 +7 70 +8 80 +9 90 +explain select a,b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c b 4 NULL NULL; Using where; Using index +select a,c from t1 where c > 750; +a c +8 800 +9 900 +alter table t1 drop primary key; +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where +select * from t1 where a > 5; +a b c d e +10 10 10 10 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d e +4 40 400 4000 NULL +5 50 500 5000 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d e +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select b from t1 where b > 30; +b +40 +50 +60 +70 +80 +90 +explain select b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select c from t1 where c > 750; +c +800 +900 +DROP TABLE t1; +CREATE TABLE t1(a INT, b INT, c INT, d INT, PRIMARY KEY(a,b,c), CLUSTERING KEY(b), KEY (c)) ENGINE=TOKUDB +PARTITION BY RANGE(c) (PARTITION p0 VALUES LESS THAN (500) ENGINE = TOKUDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TOKUDB); +insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where +select * from t1 where a > 5; +a b c d +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d +4 40 400 4000 +5 50 500 5000 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d +8 80 800 8000 +9 90 900 9000 +explain select a from t1 where a > 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index +select a from t1 where a > 8; +a +9 +explain select a,b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select a,b from t1 where b > 30; +a b +4 40 +5 50 +6 60 +7 70 +8 80 +9 90 +explain select a,b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c b 4 NULL NULL; Using where; Using index +select a,c from t1 where c > 750; +a c +8 800 +9 900 +alter table t1 add clustering index bdca(b,d,c,a); +insert into t1 values (10,10,10,10); +alter table t1 drop index bdca; +alter table t1 drop primary key; +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where +select * from t1 where a > 5; +a b c d +10 10 10 10 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d +4 40 400 4000 +5 50 500 5000 +6 60 600 6000 +7 70 700 7000 +8 80 800 8000 +9 90 900 9000 +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d +8 80 800 8000 +9 90 900 9000 +explain select b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select b from t1 where b > 30; +b +40 +50 +60 +70 +80 +90 +explain select b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select c from t1 where c > 750; +c +800 +900 +alter table t1 add e varchar(20); +alter table t1 add primary key (a,b,c); +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where +select * from t1 where a > 5; +a b c d e +10 10 10 10 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d e +4 40 400 4000 NULL +5 50 500 5000 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d e +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select a from t1 where a > 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index +select a from t1 where a > 8; +a +10 +9 +explain select a,b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select a,b from t1 where b > 30; +a b +4 40 +5 50 +6 60 +7 70 +8 80 +9 90 +explain select a,b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index c b 4 NULL NULL; Using where; Using index +select a,c from t1 where c > 750; +a c +8 800 +9 900 +alter table t1 drop primary key; +explain select * from t1 where a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where +select * from t1 where a > 5; +a b c d e +10 10 10 10 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where +select * from t1 where b > 30; +a b c d e +4 40 400 4000 NULL +5 50 500 5000 NULL +6 60 600 6000 NULL +7 70 700 7000 NULL +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select * from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select * from t1 where c > 750; +a b c d e +8 80 800 8000 NULL +9 90 900 9000 NULL +explain select b from t1 where b > 30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index +select b from t1 where b > 30; +b +40 +50 +60 +70 +80 +90 +explain select b from t1 where c > 750; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL NULL; Using where +select c from t1 where c > 750; +c +800 +900 +DROP TABLE t1; diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result index 912c45db54f..43d8a526665 100644 --- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result +++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result @@ -18,6 +18,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -35,6 +36,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -51,6 +53,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -67,6 +70,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -84,6 +88,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -100,6 +105,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result index bbaa51c2e6f..f539746a1b1 100644 --- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result @@ -18,6 +18,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -35,6 +36,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -51,6 +53,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -67,6 +70,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -84,6 +88,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -100,6 +105,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result index 01705af6b57..191f509c915 100644 --- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result +++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result @@ -18,6 +18,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -35,6 +36,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result index a45a2f7b04f..14756b1e66b 100644 --- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result @@ -18,6 +18,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 @@ -35,6 +36,7 @@ Handler_read_key 1 Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 +Handler_read_retry 0 Handler_read_rnd 0 Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result index 190581eddae..6f9592ddc1f 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_released.result @@ -10,8 +10,10 @@ select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name set autocommit=0; set tokudb_prelock_empty=OFF; +set tokudb_lock_timeout=600000; insert into t values (1); set autocommit=0; +set tokudb_lock_timeout=600000; insert into t values (1); select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name @@ -38,9 +40,11 @@ locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right lo select * from information_schema.tokudb_lock_waits; requesting_trx_id blocking_trx_id lock_waits_dname lock_waits_key_left lock_waits_key_right lock_waits_start_time lock_waits_table_schema lock_waits_table_name lock_waits_table_dictionary_name set autocommit=0; +set tokudb_lock_timeout=600000; set tokudb_prelock_empty=OFF; replace into t values (1); set autocommit=0; +set tokudb_lock_timeout=600000; replace into t values (1); select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result index 13cdad7a438..ce8f7d2d7ec 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_lock_waits_timeout.result @@ -12,7 +12,9 @@ set autocommit=0; set tokudb_prelock_empty=OFF; insert into t values (1); set autocommit=0; -insert into t values (1); +set tokudb_prelock_empty=OFF; +set tokudb_lock_timeout=60000; +replace into t values (1); select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks.result index a07f7ba52fe..070f42b30de 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks.result @@ -3,8 +3,8 @@ set tokudb_prelock_empty=false; drop table if exists t; create table t (id int primary key); set autocommit=0; -select * from information_schema.tokudb_locks; -locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name +select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right; +locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name insert into t values (1); insert into t values (3); insert into t values (5); @@ -12,17 +12,17 @@ set autocommit=0; insert into t values (2); insert into t values (4); insert into t values (6); -select * from information_schema.tokudb_locks order by locks_trx_id,locks_key_left; -locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name -TRX_ID MYSQL_ID ./test/t-main 0001000000 0001000000 test t main -TRX_ID MYSQL_ID ./test/t-main 0003000000 0003000000 test t main -TRX_ID MYSQL_ID ./test/t-main 0005000000 0005000000 test t main -TRX_ID MYSQL_ID ./test/t-main 0002000000 0002000000 test t main -TRX_ID MYSQL_ID ./test/t-main 0004000000 0004000000 test t main -TRX_ID MYSQL_ID ./test/t-main 0006000000 0006000000 test t main +select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right; +locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name +./test/t-main 0001000000 0001000000 test t main +./test/t-main 0002000000 0002000000 test t main +./test/t-main 0003000000 0003000000 test t main +./test/t-main 0004000000 0004000000 test t main +./test/t-main 0005000000 0005000000 test t main +./test/t-main 0006000000 0006000000 test t main commit; commit; -select * from information_schema.tokudb_locks; -locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name +select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right; +locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name commit; drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks_released.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks_released.result index 0a5862e9322..aa58437fc69 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks_released.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_locks_released.result @@ -9,6 +9,8 @@ set autocommit=0; set tokudb_prelock_empty=OFF; insert into t values (1); set autocommit=0; +set tokudb_prelock_empty=OFF; +set tokudb_lock_timeout=600000; insert into t values (1); select * from information_schema.tokudb_locks; locks_trx_id locks_mysql_thread_id locks_dname locks_key_left locks_key_right locks_table_schema locks_table_name locks_table_dictionary_name diff --git a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result index 63e4816e16e..3a9a936a7a6 100644 --- a/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result +++ b/storage/tokudb/mysql-test/tokudb/r/i_s_tokudb_trx.result @@ -1,23 +1,26 @@ set default_storage_engine='tokudb'; set tokudb_prelock_empty=false; drop table if exists t; -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); trx_id trx_mysql_thread_id set autocommit=0; create table t (id int primary key); insert into t values (1); -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; -trx_id trx_mysql_thread_id -TXN_ID_DEFAULT CLIENT_ID_DEFAULT +select count(trx_mysql_thread_id) from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); +count(trx_mysql_thread_id) +1 commit; -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); trx_id trx_mysql_thread_id set autocommit=0; insert into t values (2); -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; -trx_id trx_mysql_thread_id -TXN_ID_A CLIENT_ID_A +select count(trx_mysql_thread_id) from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); +count(trx_mysql_thread_id) +1 +select count(trx_mysql_thread_id) from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); +count(trx_mysql_thread_id) +0 commit; -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); trx_id trx_mysql_thread_id drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/r/type_bit.result b/storage/tokudb/mysql-test/tokudb/r/type_bit.result index a5587de9e54..c147c203d43 100644 --- a/storage/tokudb/mysql-test/tokudb/r/type_bit.result +++ b/storage/tokudb/mysql-test/tokudb/r/type_bit.result @@ -675,7 +675,7 @@ INSERT INTO t1(a) VALUES (65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535); EXPLAIN SELECT 1 FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL a 3 NULL 6 Using index for group-by +1 SIMPLE t1 index NULL a 3 NULL 10 Using index SELECT 1 FROM t1 GROUP BY a; 1 1 diff --git a/storage/tokudb/mysql-test/tokudb/replace-ignore-gen.py b/storage/tokudb/mysql-test/tokudb/replace-ignore-gen.py index d8227da96a5..65c0f317abe 100644 --- a/storage/tokudb/mysql-test/tokudb/replace-ignore-gen.py +++ b/storage/tokudb/mysql-test/tokudb/replace-ignore-gen.py @@ -23,6 +23,7 @@ def sqlgen_explain_and_do(query): def sqlgen_drop_table(): print "drop table t;" +print "source include/have_tokudb.inc;" print "# Tokutek" print "# Test that replace into and insert ignore insertions " print "# work under various index schemas. " diff --git a/storage/tokudb/mysql-test/tokudb/t/background_job_manager.opt b/storage/tokudb/mysql-test/tokudb/t/background_job_manager.opt new file mode 100644 index 00000000000..3cc9ea3009e --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/t/background_job_manager.opt @@ -0,0 +1 @@ +--tokudb-background-job-status diff --git a/storage/tokudb/mysql-test/tokudb/t/background_job_manager.test b/storage/tokudb/mysql-test/tokudb/t/background_job_manager.test new file mode 100644 index 00000000000..933814442e0 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/t/background_job_manager.test @@ -0,0 +1,139 @@ +# This is a comprehensive test for the background job manager and +# the information_schema.tokudb_background_job_status table +# +# This test validates that analyze table in various modes operate as expected +# for both foreground and background jobs. +# +# This test is NOT intended to test the actual results of an analysis. +# +# This test makes use of a global, debug only tokudb variable +# tokudb_debug_pause_background_job_manager in order to control the bjm and +# prevent it from acting on any queued jobs. +# This variable was necessary since the debug_sync facility requires any thread +# that is syncing to have a valid THD associated with it, which a background +# thread would not have. This variable is compiled out of release builds. + +-- source include/have_tokudb.inc +-- source include/have_debug.inc + +-- enable_query_log + +set @orig_auto_analyze = @@session.tokudb_auto_analyze; +set @orig_in_background = @@session.tokudb_analyze_in_background; +set @orig_mode = @@session.tokudb_analyze_mode; +set @orig_throttle = @@session.tokudb_analyze_throttle; +set @orig_time = @@session.tokudb_analyze_time; +set @orig_scale_percent = @@global.tokudb_cardinality_scale_percent; +set @orig_default_storage_engine = @@session.default_storage_engine; +set @orig_pause_background_job_manager = @@global.tokudb_debug_pause_background_job_manager; + +# first, lets set up to auto analyze in the background with about any activity +set session default_storage_engine='tokudb'; +set session tokudb_auto_analyze=1; +set session tokudb_analyze_in_background=1; +set session tokudb_analyze_mode=tokudb_analyze_standard; +set session tokudb_analyze_throttle=0; +set session tokudb_analyze_time=0; +set global tokudb_cardinality_scale_percent=DEFAULT; + +# in debug build, we can prevent the background job manager from running, +# let's do it so we can see that there was an analyze scheduled on the first +# insert +set global tokudb_debug_pause_background_job_manager=TRUE; + +# let's see what the i_s table is laid out like +show create table information_schema.tokudb_background_job_status; + +create table t1 (a int not null auto_increment, b int, c int, primary key(a), key kb(b), key kc(c), key kabc(a,b,c), key kab(a,b), key kbc(b,c)); + +insert into t1(b,c) values(0,0), (1,1), (2,2), (3,3); + +# insert above should have triggered an analyze, but since the bjm is paused, +# we will see it sitting in the queue +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# some more tables +create table t2 like t1; +create table t3 like t1; +create table t4 like t1; + +# manually analyze, the t1 should be rejected because there is already a job +# pending. t2, t3 and t4 should get queued. +analyze table t1; +analyze table t2; +analyze table t3; +analyze table t4; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# let the bjm go to clear the jobs +set global tokudb_debug_pause_background_job_manager=FALSE; + +# wait for the bjm queue to empty +-- disable_query_log +let $wait_condition=select count(*)=0 from information_schema.tokudb_background_job_status; +-- source include/wait_condition.inc +-- enable_query_log + +# pause the bjm again +set global tokudb_debug_pause_background_job_manager=TRUE; + +# add some new jobs +analyze table t1; +analyze table t2; +analyze table t3; +analyze table t4; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# alter a table, should kill the job for t1 +alter table t1 add column d int; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# try an explicit cancel on t2 +set session tokudb_analyze_mode=tokudb_analyze_cancel; +analyze table t2; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# try a recount on t1, should reschedule a new job +set session tokudb_analyze_mode=tokudb_analyze_recount_rows; +analyze table t1; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# do a foreground analysis that clashes with a background job, it should +# kill the background job for t3 and perform the analysis immediately +set session tokudb_analyze_mode=tokudb_analyze_standard; +set session tokudb_analyze_in_background=0; +analyze table t3; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# drop the tables, should kill the remaining jobs for t1, and t4 +drop table t1; +drop table t2; +drop table t3; +drop table t4; + +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# let the bjm go +set global tokudb_debug_pause_background_job_manager=FALSE; + +#cleanup +-- disable_query_log +let $wait_condition=select count(*)=0 from information_schema.tokudb_background_job_status; +-- source include/wait_condition.inc + +set session tokudb_auto_analyze = @orig_auto_analyze; +set session tokudb_analyze_in_background = @orig_in_background; +set session tokudb_analyze_mode = @orig_mode; +set session tokudb_analyze_throttle = @orig_throttle; +set session tokudb_analyze_time = @orig_time; +set global tokudb_cardinality_scale_percent = @orig_scale_percent; +set session default_storage_engine = @orig_default_storage_engine; +set global tokudb_debug_pause_background_job_manager = @orig_pause_background_job_manager; + +-- enable_query_log diff --git a/storage/tokudb/mysql-test/tokudb/t/card_auto_analyze_lots.test b/storage/tokudb/mysql-test/tokudb/t/card_auto_analyze_lots.test new file mode 100644 index 00000000000..ec74a4a28bc --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/t/card_auto_analyze_lots.test @@ -0,0 +1,82 @@ +# Test the auto analyze on lots of tables +-- source include/have_tokudb.inc + +-- disable_query_log +let $max = 200; + +SET @orig_auto_analyze = @@session.tokudb_auto_analyze; +SET @orig_in_background = @@session.tokudb_analyze_in_background; +SET @orig_mode = @@session.tokudb_analyze_mode; +SET @orig_throttle = @@session.tokudb_analyze_throttle; +SET @orig_time = @@session.tokudb_analyze_time; + +SET SESSION tokudb_auto_analyze = 1; +SET SESSION tokudb_analyze_in_background = 0; +SET SESSION tokudb_analyze_mode = TOKUDB_ANALYZE_STANDARD; +SET SESSION tokudb_analyze_throttle = 0; +SET SESSION tokudb_analyze_time = 0; + +let $i = $max; +while ($i > 0) { + eval CREATE TABLE ar_$i (a INT, b INT, PRIMARY KEY (a), KEY bkey (b)) ENGINE=TOKUDB; + dec $i; +} + +# check that the one row insertion triggered auto analyze within the calling +# client context, the cardinality should go from NULL to 1 +let $i = $max; +while ($i > 0) { + eval INSERT INTO ar_$i VALUES (0, 0); + dec $i; +} +-- enable_query_log +let $i = $max; +while ($i > 0) { + eval SHOW INDEX FROM ar_$i; + dec $i; +} + + +-- disable_query_log +# check that lots of background analysis get scheduled and run +# cleanly and serially in the background +SET SESSION tokudb_auto_analyze = 1; +SET SESSION tokudb_analyze_in_background = 1; +SET SESSION tokudb_analyze_mode = TOKUDB_ANALYZE_STANDARD; +SET SESSION tokudb_analyze_throttle = 0; +SET SESSION tokudb_analyze_time = 0; + +let $i = $max; +while ($i > 0) { + eval INSERT INTO ar_$i VALUES (1, 1), (2, 1), (3, 2), (4, 2); + dec $i; +} + +let $i = $max; +while ($i > 0) { + eval INSERT INTO ar_$i VALUES (5, 3), (6, 3), (7, 4), (8, 4); + dec $i; +} + +# would be too long to wait for stats to become up to date here and +# checking is quite non-deterministic, InnoDB test does same thing + +# dropping tables should cancel any running background jobs +let $i = $max; +while ($i > 0) { + eval DROP TABLE ar_$i; + dec $i; +} + +# wait for the bjm queue to empty +-- disable_query_log +let $wait_condition=select count(*)=0 from information_schema.tokudb_background_job_status; +-- source include/wait_condition.inc + +SET SESSION tokudb_auto_analyze = @orig_auto_analyze; +SET SESSION tokudb_analyze_in_background = @orig_in_background; +SET SESSION tokudb_analyze_mode = @orig_mode; +SET SESSION tokudb_analyze_throttle = @orig_throttle; +SET SESSION tokudb_analyze_time = @orig_time; + +-- enable_query_log diff --git a/storage/tokudb/mysql-test/tokudb/t/card_scale_percent.test b/storage/tokudb/mysql-test/tokudb/t/card_scale_percent.test new file mode 100644 index 00000000000..47f1eb37989 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/t/card_scale_percent.test @@ -0,0 +1,56 @@ +-- source include/have_tokudb.inc + +-- disable_query_log + +set @orig_throttle = @@session.tokudb_analyze_throttle; +set @orig_time = @@session.tokudb_analyze_time; +set @orig_scale_percent = @@global.tokudb_cardinality_scale_percent; + +create table tt (a int, b int, c int, d int, primary key(a), key(b), key(c), key(d)) engine=tokudb; +let $i=0; +while ($i < 1000) { + eval insert into tt values ($i, $i, $i, $i); + inc $i; +} +while ($i < 2000) { + eval insert into tt values ($i, $i, $i, 0); + inc $i; +} +while ($i < 3000) { + eval insert into tt values ($i, $i, 0, 0); + inc $i; +} +while ($i < 4000) { + eval insert into tt values ($i, 0, 0, 0); + inc $i; +} + +set session tokudb_analyze_time=0; +set session tokudb_analyze_throttle=0; + +-- enable_query_log + +set global tokudb_cardinality_scale_percent = 10; +analyze table tt; +show indexes from tt; + +set global tokudb_cardinality_scale_percent = 50; +analyze table tt; +show indexes from tt; + +set global tokudb_cardinality_scale_percent = 100; +analyze table tt; +show indexes from tt; + +set global tokudb_cardinality_scale_percent = 200; +analyze table tt; +show indexes from tt; + +-- disable_query_log + +drop table tt; +set session tokudb_analyze_throttle = @orig_throttle; +set session tokudb_analyze_time = @orig_time; +set global tokudb_cardinality_scale_percent = @orig_scale_percent; + +-- enable_query_log diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py b/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py old mode 100644 new mode 100755 index b94a80ec7be..2c7d8dd9a54 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py @@ -22,6 +22,7 @@ def gen_test(n): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_bin.py" print "# test binary expansion is hot" print "--source include/big_test.inc" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py old mode 100644 new mode 100755 index b574f15735a..6bd5de38fe8 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py @@ -26,6 +26,7 @@ def gen_test(n): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_char_rename.py" print "# test char expansion + rename is hot" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_blob.py b/storage/tokudb/mysql-test/tokudb/t/change_column_blob.py index d884932307f..e25fce54d0e 100644 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_blob.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_blob.py @@ -1,5 +1,6 @@ import sys def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_blob.py" print "# generate hot blob expansion test cases" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char.py old mode 100644 new mode 100755 index 7481d9092f2..c53442ade50 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_char.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char.py @@ -22,6 +22,7 @@ def gen_test(n): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_char.py" print "# test char expansion" print "--source include/big_test.inc" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py old mode 100644 new mode 100755 index 4b94d2fc98b..e92797918d5 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py @@ -23,6 +23,7 @@ def gen_test(n): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_char_binary.py" print "# test that char(X) <-> binary(X) is not hot" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py old mode 100644 new mode 100755 index 81cf2058a3e..065e37b186d --- a/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py @@ -23,6 +23,7 @@ def gen_test(n): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_char_charbinary.py" print "# test that char(X) <-> char(X) binary is not hot" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py old mode 100644 new mode 100755 index 6bc8ae80c7d..fe73fce0d53 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py @@ -26,6 +26,7 @@ def gen_test(n): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_char_rename.py" print "# test char expansion + rename is hot" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int.py old mode 100644 new mode 100755 index f93b9d7bb69..6f69156e260 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_int.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int.py @@ -25,6 +25,7 @@ def gen_test(types, values): print "DROP TABLE ti;" print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_int.py" print "# test int expansion is hot" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py old mode 100644 new mode 100755 index 8b217b59ab1..fd7e5868c40 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py @@ -25,6 +25,7 @@ def gen_test(types): print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_int_key.py" print "# ensure that changing an int column that is part of a key is not hot" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py old mode 100644 new mode 100755 index 6fbb2343fea..1708c65efde --- a/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py @@ -21,6 +21,7 @@ def gen_tests(int_types, modifiers): for from_modifier in range(len(modifiers)): gen_tests_for_int(from_int, from_modifier, int_types, modifiers) def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_int_not_supported.py" print "# ensure that int types are only expanded and are not cnverted to some other type" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py old mode 100644 new mode 100755 index a1cd155f3de..5222564a9a2 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py @@ -27,6 +27,7 @@ def gen_test(types, values): print "DROP TABLE ti;" print "DROP TABLE t;" def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_int_rename.py" print "--disable_warnings" print "DROP TABLE IF EXISTS t, ti;" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_multiple_columns.py b/storage/tokudb/mysql-test/tokudb/t/change_column_multiple_columns.py index 7e562f38a0f..05f3683a14f 100644 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_multiple_columns.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_multiple_columns.py @@ -6,6 +6,7 @@ old_types = [ 'VARCHAR(1)', 'VARBINARY(1)', 'INT', 'CHAR(1)', 'BINARY(1)' ] new_types = [ 'VARCHAR(2)', 'VARBINARY(2)', 'BIGINT', 'CHAR(2)', 'BINARY(2)' ] def main(): + print "source include/have_tokudb.inc;" print "# this test generated by change_multiple_columns.py" print "# this test generated multiple column changes which should all fail since we support only one at a time" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_text.py b/storage/tokudb/mysql-test/tokudb/t/change_column_text.py index 13de13dc222..fada9b0852e 100644 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_text.py +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_text.py @@ -1,5 +1,6 @@ import sys def main(): + print "source include/have_tokudb.inc;" print "# this test is generated by change_text.py" print "# generate hot text expansion test cases" print "--disable_warnings" diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_key.test b/storage/tokudb/mysql-test/tokudb/t/cluster_key.test index 9280324b8cc..d491784577e 100644 --- a/storage/tokudb/mysql-test/tokudb/t/cluster_key.test +++ b/storage/tokudb/mysql-test/tokudb/t/cluster_key.test @@ -5,140 +5,8 @@ SET DEFAULT_STORAGE_ENGINE='tokudb'; DROP TABLE IF EXISTS t1; --enable_warnings -create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; +create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb; -insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); - - -#normal queries - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where a > 5; -select * from t1 where a > 5; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where b > 30; -select * from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where c > 750; -select * from t1 where c > 750; - -#covering indexes - -# ignore rows column ---replace_column 9 NULL; -explain select a from t1 where a > 8; -select a from t1 where a > 8; - -# ignore rows column ---replace_column 9 NULL; -explain select a,b from t1 where b > 30; -select a,b from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select a,b from t1 where c > 750; -select a,c from t1 where c > 750; - - -alter table t1 add index bdca(b,d,c,a) clustering=yes; -insert into t1 values (10,10,10,10); -alter table t1 drop index bdca; - -alter table t1 drop primary key; -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where a > 5; -select * from t1 where a > 5; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where b > 30; -select * from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where c > 750; -select * from t1 where c > 750; - -#covering indexes - -# ignore rows column ---replace_column 9 NULL; -explain select b from t1 where b > 30; -select b from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select b from t1 where c > 750; -select c from t1 where c > 750; - -alter table t1 add e varchar(20); - -alter table t1 add primary key (a); - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where a > 5; -select * from t1 where a > 5; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where b > 30; -select * from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where c > 750; -select * from t1 where c > 750; - -#covering indexes - -# ignore rows column ---replace_column 9 NULL; -explain select a from t1 where a > 8; -select a from t1 where a > 8; - -# ignore rows column ---replace_column 9 NULL; -explain select a,b from t1 where b > 30; -select a,b from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select a,b from t1 where c > 750; -select a,c from t1 where c > 750; - - -alter table t1 drop primary key; -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where a > 5; -select * from t1 where a > 5; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where b > 30; -select * from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select * from t1 where c > 750; -select * from t1 where c > 750; - -#covering indexes -# ignore rows column ---replace_column 9 NULL; -explain select b from t1 where b > 30; -select b from t1 where b > 30; - -# ignore rows column ---replace_column 9 NULL; -explain select b from t1 where c > 750; -select c from t1 where c > 750; +--source ../include/cluster_key.inc drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_key_part.test b/storage/tokudb/mysql-test/tokudb/t/cluster_key_part.test index 8da7aa1078f..310866d14bc 100644 --- a/storage/tokudb/mysql-test/tokudb/t/cluster_key_part.test +++ b/storage/tokudb/mysql-test/tokudb/t/cluster_key_part.test @@ -5,19 +5,47 @@ source include/have_partition.inc; set default_storage_engine='tokudb'; disable_warnings; -drop table if exists t; +DROP TABLE IF EXISTS t; enable_warnings; -create table t ( - x int not null, - y int not null, - primary key(x)) -partition by hash(x) partitions 2; +CREATE TABLE t (a INT NOT NULL AUTO_INCREMENT, b INT, PRIMARY KEY(a), KEY b(b) CLUSTERING=YES) ENGINE=TokuDB +PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (100) ENGINE = TokuDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TokuDB); -show create table t; +SHOW CREATE TABLE t; -alter table t add key(y) clustering=yes; +DROP TABLE t; -show create table t; -drop table t; + +CREATE TABLE t (x INT NOT NULL, y INT NOT NULL, PRIMARY KEY(x)) +PARTITION BY HASH(x) PARTITIONS 2; + +SHOW CREATE TABLE t; + +ALTER TABLE t ADD KEY(y) CLUSTERING=YES; + +SHOW CREATE TABLE t; + +DROP TABLE t; + + +CREATE TABLE t1(a INT, b INT, c INT, d INT, PRIMARY KEY(a,b,c), KEY(b) CLUSTERING=YES, KEY (c)) ENGINE=TOKUDB +PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (5) ENGINE = TOKUDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TOKUDB); + +--source ../include/cluster_key.inc + +DROP TABLE t1; + +CREATE TABLE t1(a INT, b INT, c INT, d INT, PRIMARY KEY(a,b,c), KEY(b) CLUSTERING=YES, KEY (c)) ENGINE=TOKUDB +PARTITION BY RANGE(b) (PARTITION p0 VALUES LESS THAN (50) ENGINE = TOKUDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TOKUDB); + +--source ../include/cluster_key.inc + +DROP TABLE t1; + +CREATE TABLE t1(a INT, b INT, c INT, d INT, PRIMARY KEY(a,b,c), KEY(b) CLUSTERING=YES, KEY (c)) ENGINE=TOKUDB +PARTITION BY RANGE(c) (PARTITION p0 VALUES LESS THAN (500) ENGINE = TOKUDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = TOKUDB); + +--source ../include/cluster_key.inc + +DROP TABLE t1; diff --git a/storage/tokudb/mysql-test/tokudb/t/disabled.def b/storage/tokudb/mysql-test/tokudb/t/disabled.def new file mode 100644 index 00000000000..f7413a0edc5 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/t/disabled.def @@ -0,0 +1,28 @@ +mvcc-19: tokutek +mvcc-20: tokutek +mvcc-27: tokutek +storage_engine_default: tokudb is not the default storage engine +fast_update_binlog_mixed : https://tokutek.atlassian.net/browse/DB-871 +fast_update_binlog_row : https://tokutek.atlassian.net/browse/DB-871 +fast_update_binlog_statement : https://tokutek.atlassian.net/browse/DB-871 +fast_update_blobs_fixed_varchar : https://tokutek.atlassian.net/browse/DB-871 +fast_update_blobs : https://tokutek.atlassian.net/browse/DB-871 +fast_update_blobs_with_varchar : https://tokutek.atlassian.net/browse/DB-871 +fast_update_char : https://tokutek.atlassian.net/browse/DB-871 +fast_update_deadlock : https://tokutek.atlassian.net/browse/DB-871 +fast_update_decr_floor : https://tokutek.atlassian.net/browse/DB-871 +fast_update_disable_slow_update : https://tokutek.atlassian.net/browse/DB-871 +fast_update_error : https://tokutek.atlassian.net/browse/DB-871 +fast_update_int_bounds : https://tokutek.atlassian.net/browse/DB-871 +fast_update_int : https://tokutek.atlassian.net/browse/DB-871 +fast_update_key : https://tokutek.atlassian.net/browse/DB-871 +fast_update_sqlmode : https://tokutek.atlassian.net/browse/DB-871 +fast_update_uint_bounds : https://tokutek.atlassian.net/browse/DB-871 +fast_update_varchar : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_bin_pad : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_char : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_deadlock : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_int : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_key : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_sqlmode : https://tokutek.atlassian.net/browse/DB-871 +fast_upsert_values : https://tokutek.atlassian.net/browse/DB-871 diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test index 3fd6ddb88fe..d8ce18b3aa7 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_released.test @@ -25,10 +25,12 @@ select * from information_schema.tokudb_lock_waits; connect (conn_a,localhost,root,,); set autocommit=0; set tokudb_prelock_empty=OFF; # disable the bulk loader +set tokudb_lock_timeout=600000; # set lock wait timeout to 10 minutes insert into t values (1); connect (conn_b,localhost,root,,); set autocommit=0; +set tokudb_lock_timeout=600000; # set lock wait timeout to 10 minutes send insert into t values (1); # should find the presence of a lock on 1st transaction @@ -51,6 +53,9 @@ select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connection conn_a; commit; # verify that the lock on the 1st transaction is released and replaced by the lock for the 2nd transaction +let $wait_condition= select count(*)=1 from information_schema.tokudb_locks where locks_dname='./test/t-main'; +source include/wait_condition.inc; + replace_column 1 TRX_ID 2 MYSQL_ID; select * from information_schema.tokudb_locks; select * from information_schema.tokudb_lock_waits; @@ -74,11 +79,13 @@ select * from information_schema.tokudb_lock_waits; connect (conn_a,localhost,root,,); set autocommit=0; +set tokudb_lock_timeout=600000; # set lock wait timeout to 10 minutes set tokudb_prelock_empty=OFF; # disable the bulk loader replace into t values (1); connect (conn_b,localhost,root,,); set autocommit=0; +set tokudb_lock_timeout=600000; # set lock wait timeout to 10 minutes send replace into t values (1); # should find the presence of a lock on 1st transaction diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test index 06923d4ca58..42fb548814f 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test @@ -21,11 +21,14 @@ insert into t values (1); connect (conn_b,localhost,root,,); set autocommit=0; -send insert into t values (1); +set tokudb_prelock_empty=OFF; +set tokudb_lock_timeout=60000; # set lock wait timeout to 1 minute + +send replace into t values (1); # should find the presence of a lock on 1st transaction connection default; -let $wait_condition= select count(*)=1 from information_schema.processlist where info='insert into t values (1)' and state='update'; +let $wait_condition= select count(*)=1 from information_schema.processlist where info='replace into t values (1)' and state='update'; source include/wait_condition.inc; real_sleep 1; # delay a little to shorten the update -> write row -> lock wait race @@ -41,7 +44,9 @@ replace_column 1 TRX_ID 2 MYSQL_ID; select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; connection conn_a; -sleep 5; # sleep longer than the lock timer to force a lock timeout on txn_b +real_sleep 45; # sleep till we get close to timeout since wait_condidion will timeout @ 30 seconds +let $wait_condition= select count(*)=0 from information_schema.processlist where info='replace into t values (1)' and state='update'; +source include/wait_condition.inc; commit; # verify that the lock on the 1st transaction is released and replaced by the lock for the 2nd transaction diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks.test index e5a67559b1a..8f205ad7f45 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks.test @@ -12,7 +12,7 @@ set autocommit=0; let $default_id=`select connection_id()`; # should be empty -select * from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right; insert into t values (1); insert into t values (3); @@ -28,8 +28,7 @@ insert into t values (6); # should find 3 locks for 2 transactions connection default; -replace_column 1 TRX_ID 2 MYSQL_ID; -eval select * from information_schema.tokudb_locks order by locks_trx_id,locks_key_left; +eval select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right; connection conn_a; commit; @@ -37,9 +36,9 @@ connection default; commit; # should be empty -select * from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right; commit; disconnect conn_a; -drop table t; \ No newline at end of file +drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks_released.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks_released.test index 19f413e79f9..93ae4767ecd 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks_released.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_locks_released.test @@ -27,6 +27,8 @@ insert into t values (1); connect (conn_b,localhost,root,,); set autocommit=0; +set tokudb_prelock_empty=OFF; +set tokudb_lock_timeout=600000; # set lock wait timeout to 10 minutes send insert into t values (1); @@ -42,6 +44,9 @@ eval select * from information_schema.tokudb_locks; connection conn_a; commit; # verify that the lock on the 1st transaction is released and replaced by the lock for the 2nd transaction +let $wait_condition= select count(*)=1 from information_schema.tokudb_locks where locks_dname='./test/t-main'; +source include/wait_condition.inc; + replace_column 1 TRX_ID 2 MYSQL_ID; select * from information_schema.tokudb_locks; diff --git a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test index d3c2636ba54..517280391c4 100644 --- a/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test +++ b/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_trx.test @@ -8,35 +8,32 @@ drop table if exists t; enable_warnings; # should be empty -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); # should have my txn -let $default_id=`select connection_id()`; set autocommit=0; create table t (id int primary key); insert into t values (1); -replace_column 1 TXN_ID_DEFAULT 2 CLIENT_ID_DEFAULT; -eval select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select count(trx_mysql_thread_id) from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); # should be empty commit; -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); connect(conn_a,localhost,root,,); -let a_id=`select connection_id()`; set autocommit=0; insert into t values (2); +select count(trx_mysql_thread_id) from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); connection default; -replace_column 1 TXN_ID_A 2 CLIENT_ID_A; -eval select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select count(trx_mysql_thread_id) from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); connection conn_a; commit; connection default; # should be empty -select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx; +select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx where trx_mysql_thread_id in(connection_id()); disconnect conn_a; -drop table t; \ No newline at end of file +drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/suite.opt b/storage/tokudb/mysql-test/tokudb/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_add_index/disabled.def b/storage/tokudb/mysql-test/tokudb_add_index/disabled.def deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/storage/tokudb/mysql-test/tokudb_add_index/t/suite.opt b/storage/tokudb/mysql-test/tokudb_add_index/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_add_index/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_alter_table/disabled.def b/storage/tokudb/mysql-test/tokudb_alter_table/disabled.def deleted file mode 100644 index 828c5ee216b..00000000000 --- a/storage/tokudb/mysql-test/tokudb_alter_table/disabled.def +++ /dev/null @@ -1,6 +0,0 @@ -# alter table -hcad_tmp_tables: tmp tables bypass hot alter, we run hcad_tmp_tables_56 instead -hcad_with_locks: how this could work, if alter needs an exclusive mdl lock? - -frm_discover_partition: No partition discovery in MariaDB 5.5 - diff --git a/storage/tokudb/mysql-test/tokudb_alter_table/t/disabled.def b/storage/tokudb/mysql-test/tokudb_alter_table/t/disabled.def new file mode 100644 index 00000000000..3ea96dac116 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_alter_table/t/disabled.def @@ -0,0 +1,8 @@ +# alter table +hcad_tmp_tables: tmp tables bypass hot alter, we run hcad_tmp_tables_56 instead +hcad_with_locks: cant alter table concurrent with reading a table in 5.5 + +# virtual columns +virtual_columns: no virtual columns in MySQL 5.5 + +frm_discover_partition: needs the tokutek patch for frm discovery for partitioned tables diff --git a/storage/tokudb/mysql-test/tokudb_alter_table/t/suite.opt b/storage/tokudb/mysql-test/tokudb_alter_table/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_alter_table/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_backup/r/tokudb_backup_exclude.result b/storage/tokudb/mysql-test/tokudb_backup/r/tokudb_backup_exclude.result new file mode 100644 index 00000000000..0bec62e54f6 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_backup/r/tokudb_backup_exclude.result @@ -0,0 +1,31 @@ +create table t1(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +create table t1a(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +create table t1b(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +create table t1c(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +select @@session.tokudb_backup_last_error; +@@session.tokudb_backup_last_error +0 +select @@session.tokudb_backup_last_error_string; +@@session.tokudb_backup_last_error_string +NULL +20 +set session tokudb_backup_exclude='(t1a|t1c)+'; +select @@session.tokudb_backup_last_error; +@@session.tokudb_backup_last_error +0 +select @@session.tokudb_backup_last_error_string; +@@session.tokudb_backup_last_error_string +NULL +10 +set session tokudb_backup_exclude='t1[abc]+'; +select @@session.tokudb_backup_last_error; +@@session.tokudb_backup_last_error +0 +select @@session.tokudb_backup_last_error_string; +@@session.tokudb_backup_last_error_string +NULL +5 +drop table t1; +drop table t1a; +drop table t1b; +drop table t1c; diff --git a/storage/tokudb/mysql-test/tokudb_backup/r/tokudb_backup_set_last_error.result b/storage/tokudb/mysql-test/tokudb_backup/r/tokudb_backup_set_last_error.result new file mode 100644 index 00000000000..e1baf8418ad --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_backup/r/tokudb_backup_set_last_error.result @@ -0,0 +1,20 @@ +create table t1(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +set session tokudb_backup_dir='/aint/no/way/this/exists/here'; +ERROR 42000: Variable 'tokudb_backup_dir' can't be set to the value of '/aint/no/way/this/exists/here' +select @@session.tokudb_backup_last_error; +@@session.tokudb_backup_last_error +2 +select @@session.tokudb_backup_last_error_string; +@@session.tokudb_backup_last_error_string +Could not get real path for /aint/no/way/this/exists/here +set session tokudb_backup_last_error_string='this should not crash the server'; +select @@session.tokudb_backup_last_error_string; +@@session.tokudb_backup_last_error_string +this should not crash the server +set session tokudb_backup_dir='/aint/no/way/this/exists/here'; +ERROR 42000: Variable 'tokudb_backup_dir' can't be set to the value of '/aint/no/way/this/exists/here' +select @@session.tokudb_backup_last_error_string; +@@session.tokudb_backup_last_error_string +Could not get real path for /aint/no/way/this/exists/here +set session tokudb_backup_last_error_string = @old_backup_last_error_string; +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_backup/t/suite.opt b/storage/tokudb/mysql-test/tokudb_backup/t/suite.opt new file mode 100644 index 00000000000..0d80cf85a91 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_backup/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD $TOKUDB_BACKUP_OPT $TOKUDB_BACKUP_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_backup/t/tokudb_backup_exclude.test b/storage/tokudb/mysql-test/tokudb_backup/t/tokudb_backup_exclude.test new file mode 100644 index 00000000000..a0ff5152f66 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_backup/t/tokudb_backup_exclude.test @@ -0,0 +1,69 @@ +# This test is to specifically test the TokuDB backup excluse functionality. +# This is _not_ an illustration of how to exclude tables from a TokuDB backup, +# if you exclude TokuDB database files in this way, you will have a useless +# backup. +source include/have_tokudb_backup.inc; + +disable_query_log; + +set @old_backup_exclude = @@session.tokudb_backup_exclude; + +enable_query_log; + +# This should create 20 files prefixed with '_test_t1' +create table t1(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +create table t1a(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +create table t1b(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; +create table t1c(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; + +# This should not filter any files +disable_query_log; +--exec mkdir $MYSQLTEST_VARDIR/tmp/backup +--eval set session tokudb_backup_dir='$MYSQLTEST_VARDIR/tmp/backup' +enable_query_log; + +select @@session.tokudb_backup_last_error; +select @@session.tokudb_backup_last_error_string; + +# 20 files should be in the backup set +--exec ls $MYSQLTEST_VARDIR/tmp/backup/mysql_data_dir | grep -c _test_t1 + +--exec rm -rf $MYSQLTEST_VARDIR/tmp/backup + + +# This should filter all files for the t1a and t1c tables +set session tokudb_backup_exclude='(t1a|t1c)+'; + +disable_query_log; +--exec mkdir $MYSQLTEST_VARDIR/tmp/backup +--eval set session tokudb_backup_dir='$MYSQLTEST_VARDIR/tmp/backup' +enable_query_log; + +select @@session.tokudb_backup_last_error; +select @@session.tokudb_backup_last_error_string; + +# 10 files should be in the backup set +--exec ls $MYSQLTEST_VARDIR/tmp/backup/mysql_data_dir | grep -c _test_t1 + +--exec rm -rf $MYSQLTEST_VARDIR/tmp/backup + +# This should filter all files for the t1a, t1b, and t1c tables +set session tokudb_backup_exclude='t1[abc]+'; + +disable_query_log; +--exec mkdir $MYSQLTEST_VARDIR/tmp/backup +--eval set session tokudb_backup_dir='$MYSQLTEST_VARDIR/tmp/backup' +enable_query_log; + +select @@session.tokudb_backup_last_error; +select @@session.tokudb_backup_last_error_string; + +# 5 files should be in the backup set +--exec ls $MYSQLTEST_VARDIR/tmp/backup/mysql_data_dir | grep -c _test_t1 + +--exec rm -rf $MYSQLTEST_VARDIR/tmp/backup + +drop table t1; +drop table t1a; +drop table t1b; +drop table t1c; diff --git a/storage/tokudb/mysql-test/tokudb_backup/t/tokudb_backup_set_last_error.test b/storage/tokudb/mysql-test/tokudb_backup/t/tokudb_backup_set_last_error.test new file mode 100644 index 00000000000..18fc8cc5efb --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_backup/t/tokudb_backup_set_last_error.test @@ -0,0 +1,32 @@ +# This test validates that the plugin will not crash if a user sets +# tokudb_backup_last_error_string after performing a backup. +source include/have_tokudb_backup.inc; + +disable_query_log; + +set @old_backup_last_error_string = @@session.tokudb_backup_last_error_string; + +enable_query_log; + +create table t1(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c)) engine='tokudb'; + +# this should fail and set the error string since the dummy directory +# doesn't exist +--error ER_WRONG_VALUE_FOR_VAR +--eval set session tokudb_backup_dir='/aint/no/way/this/exists/here' + +select @@session.tokudb_backup_last_error; +select @@session.tokudb_backup_last_error_string; + +set session tokudb_backup_last_error_string='this should not crash the server'; +select @@session.tokudb_backup_last_error_string; + +# this should fail again and set the error string since the dummy directory +# doesn't exist +--error ER_WRONG_VALUE_FOR_VAR +--eval set session tokudb_backup_dir='/aint/no/way/this/exists/here' +select @@session.tokudb_backup_last_error_string; + +set session tokudb_backup_last_error_string = @old_backup_last_error_string; + +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/disabled.def b/storage/tokudb/mysql-test/tokudb_bugs/disabled.def index 068cbb413e0..d0d1a47e006 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/disabled.def +++ b/storage/tokudb/mysql-test/tokudb_bugs/disabled.def @@ -1,14 +1,2 @@ -memcache_dirty : #4609 memcache patch from facebook not ported to mysql 5.5 -4472 : #4521 MDL for alter table in 5.5 prohibits this test from having any chance of working - -tokudb_drop_part_table_668: no tokudb test data in mariadb tree -tokudb_drop_simple_table_668: no tokudb test data in mariadb tree 5585: times out, too many huge insert...selects -fileops-3: how this could work, if alter needs an exclusive mdl lock? -6053: tokudb is not the default storage engine - -checkpoint_lock_2: test can not work when the checkpoint_safe_lock is a fair rwlock - -# this test was added in 7.5.4 and fails in 10.0 -# but running this very test in 7.5.3 fails in exactly the same manner -db768: never worked. tokutek was informed, 2015-01-14 +db233: different execution path in mariadb, debug_sync point is not hit diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/5585.result b/storage/tokudb/mysql-test/tokudb_bugs/r/5585.result index 608afa00370..1008764148b 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/5585.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/5585.result @@ -10,12 +10,6 @@ insert into t1 select t1.file_id+40, t1.file_number+40 from t1; insert into t1 select t1.file_id+100, t1.file_number+100 from t1; insert into t1 select t1.file_id+200, t1.file_number+200 from t1; insert into t1 select t1.file_id+400, t1.file_number+400 from t1; -insert into t1 select t1.file_id+1000, t1.file_number+1000 from t1; -insert into t1 select t1.file_id+10000, t1.file_number+10000 from t1; -insert into t1 select t1.file_id+100000, t1.file_number+100000 from t1; -insert into t1 select t1.file_id+1000000, t1.file_number+1000000 from t1; -insert into t1 select t1.file_id+10000000, t1.file_number+10000000 from t1; -insert into t1 select t1.file_id+100000000, t1.file_number+100000000 from t1; create table t2 ( file_id bigint unsigned not null, country char(2) not null, diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db233.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db233.result new file mode 100644 index 00000000000..e5808f52e69 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db233.result @@ -0,0 +1,37 @@ +SET SESSION tokudb_auto_analyze = 0; +SET SESSION tokudb_analyze_in_background = 0; +CREATE TABLE t1( +`id` int(10) unsigned NOT NULL, +`k` int(10) unsigned NOT NULL DEFAULT '0', +`c` char(120) NOT NULL DEFAULT '', +`pad` char(60) NOT NULL DEFAULT '', +KEY `xid` (`id`), +KEY `k` (`k`) +) ENGINE=TokuDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES(1, 1, '1', '1'), (2, 2, '2', '2'), (3, 3, '3', '3'), (4, 4, '4', '4'), +(5, 5, '5', '5'), (6, 6, '6', '6'), (6, 6, '6', '6'), (7, 7, '7', '7'), +(8, 8, '8', '8'), (9, 9, '9', '9'), (10, 10, '10', '10'), (11, 11, '11', '11'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set DEBUG_SYNC = 'tokudb_icp_desc_scan_invalidate SIGNAL hit1 WAIT_FOR done1'; +SELECT c FROM t1 WHERE id BETWEEN 5 AND 8 ORDER BY id DESC; +set DEBUG_SYNC = 'now WAIT_FOR hit1'; +set DEBUG_SYNC = 'now SIGNAL done1'; +c +8 +7 +6 +6 +5 +set DEBUG_SYNC = 'tokudb_icp_asc_scan_out_of_range SIGNAL hit2 WAIT_FOR done2'; +SELECT c FROM t1 WHERE id BETWEEN 5 AND 8 ORDER BY id ASC; +set DEBUG_SYNC = 'now WAIT_FOR hit2'; +set DEBUG_SYNC = 'now SIGNAL done2'; +c +5 +6 +6 +7 +8 +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db397_delete_trigger.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db397_delete_trigger.result index da82fa445e8..c8565fb4b2b 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db397_delete_trigger.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db397_delete_trigger.result @@ -25,11 +25,11 @@ select col1,action from t1_audit; col1 action 0 DUMMY 1 BEFORE DEL -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; locks_dname locks_key_left locks_key_right -./test/t1_audit-main 0200000000000000 0200000000000000 -./test/t1-main ff01000000 0101000000 ./test/t1-main 0001000000 0001000000 +./test/t1-main ff01000000 0101000000 +./test/t1_audit-main 0200000000000000 0200000000000000 commit; drop trigger t1_trigger; create trigger t1_trigger after delete on t1 @@ -46,11 +46,11 @@ col1 action 0 DUMMY 1 BEFORE DEL 2 AFTER DELE -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; locks_dname locks_key_left locks_key_right -./test/t1_audit-main 0300000000000000 0300000000000000 -./test/t1-main ff02000000 0102000000 ./test/t1-main 0002000000 0002000000 +./test/t1-main ff02000000 0102000000 +./test/t1_audit-main 0300000000000000 0300000000000000 commit; drop trigger t1_trigger; drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db397_insert_trigger.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db397_insert_trigger.result index 41765a6fcd3..aef99a9adcd 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db397_insert_trigger.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db397_insert_trigger.result @@ -25,10 +25,10 @@ select col1,action from t1_audit; col1 action 0 DUMMY 1 BEFORE INSERT -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; locks_dname locks_key_left locks_key_right -./test/t1_audit-main 0200000000000000 0200000000000000 ./test/t1-main 0001000000 0001000000 +./test/t1_audit-main 0200000000000000 0200000000000000 commit; drop trigger t1_trigger; create trigger t1_trigger after insert on t1 @@ -46,10 +46,10 @@ col1 action 0 DUMMY 1 BEFORE INSERT 2 AFTER INSERT -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; locks_dname locks_key_left locks_key_right -./test/t1_audit-main 0300000000000000 0300000000000000 ./test/t1-main 0002000000 0002000000 +./test/t1_audit-main 0300000000000000 0300000000000000 commit; drop trigger t1_trigger; drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db397_update_trigger.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db397_update_trigger.result index c197430ad25..d9b944d3849 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db397_update_trigger.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db397_update_trigger.result @@ -25,11 +25,11 @@ select col1,action from t1_audit; col1 action 0 DUMMY 1 BEFORE UPDATE -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; locks_dname locks_key_left locks_key_right -./test/t1_audit-main 0200000000000000 0200000000000000 -./test/t1-main ff01000000 0101000000 ./test/t1-main 0001000000 0001000000 +./test/t1-main ff01000000 0101000000 +./test/t1_audit-main 0200000000000000 0200000000000000 commit; drop trigger t1_trigger; create trigger t1_trigger after update on t1 @@ -48,11 +48,11 @@ col1 action 0 DUMMY 1 BEFORE UPDATE 2 AFTER UPDATE -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; locks_dname locks_key_left locks_key_right -./test/t1_audit-main 0300000000000000 0300000000000000 -./test/t1-main ff02000000 0102000000 ./test/t1-main 0002000000 0002000000 +./test/t1-main ff02000000 0102000000 +./test/t1_audit-main 0300000000000000 0300000000000000 commit; drop trigger t1_trigger; drop table t1, t1_audit; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db739_replace.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db739_replace.result index 2bf141add9a..58a4ed6708a 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db739_replace.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db739_replace.result @@ -100010,5 +100010,7 @@ insert into t (id,a) values (999,98); insert into t (id,a) values (999,99); delete from t where id=404; set tokudb_pk_insert_mode=2; +Warnings: +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. replace into t values (404,0,0,0); drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash.result index 3ed5758bd15..70bc86e1abc 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash.result @@ -3,19 +3,19 @@ drop table if exists t; create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2; show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 0 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 2 NULL NULL BTREE +t 1 x 1 x A 2 NULL NULL YES BTREE insert into t values (1,1),(3,1),(5,1); insert into t values (2,1),(4,1),(6,1); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 6 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 1 x 1 x A 6 NULL NULL YES BTREE analyze table t; Table Op Msg_type Msg_text test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 6 NULL NULL BTREE -t 1 x 1 x A 2 NULL NULL YES BTREE +t 1 x 1 x A 6 NULL NULL YES BTREE drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1.result index 776342ce90e..b6d9fd7da85 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1.result @@ -3,18 +3,18 @@ drop table if exists t; create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2; show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 0 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 2 NULL NULL BTREE +t 1 x 1 x A 2 NULL NULL YES BTREE insert into t values (1,1),(3,1),(5,1); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 3 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 4 NULL NULL BTREE +t 1 x 1 x A 4 NULL NULL YES BTREE analyze table t; Table Op Msg_type Msg_text test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 3 NULL NULL BTREE -t 1 x 1 x A 1 NULL NULL YES BTREE +t 0 PRIMARY 1 id A 4 NULL NULL BTREE +t 1 x 1 x A 4 NULL NULL YES BTREE drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result index 480978a545b..5ba5da21789 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result @@ -3,19 +3,19 @@ drop table if exists t; create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2; show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 0 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 2 NULL NULL BTREE +t 1 x 1 x A 2 NULL NULL YES BTREE insert into t values (1,1),(3,2),(5,3); insert into t values (2,1),(4,1),(6,1),(8,1); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 7 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 1 x 1 x A 7 NULL NULL YES BTREE analyze table t; Table Op Msg_type Msg_text test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 7 NULL NULL BTREE -t 1 x 1 x A 1 NULL NULL YES BTREE +t 1 x 1 x A 3 NULL NULL YES BTREE drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2.result index ec2a37b02d4..6d345d98c95 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2.result @@ -3,18 +3,18 @@ drop table if exists t; create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2; show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 0 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 2 NULL NULL BTREE +t 1 x 1 x A 2 NULL NULL YES BTREE insert into t values (2,1),(4,1),(6,1); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 3 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 4 NULL NULL BTREE +t 1 x 1 x A 4 NULL NULL YES BTREE analyze table t; Table Op Msg_type Msg_text test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 3 NULL NULL BTREE -t 1 x 1 x A 1 NULL NULL YES BTREE +t 0 PRIMARY 1 id A 4 NULL NULL BTREE +t 1 x 1 x A 4 NULL NULL YES BTREE drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2_pick.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2_pick.result index c1160ae27a0..06639c311cf 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2_pick.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_2_pick.result @@ -3,14 +3,14 @@ drop table if exists t; create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2; show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 0 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 2 NULL NULL BTREE +t 1 x 1 x A 2 NULL NULL YES BTREE insert into t values (1,1),(3,2),(5,3),(7,4); insert into t values (2,1),(4,1),(6,1); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 7 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE +t 1 x 1 x A 7 NULL NULL YES BTREE analyze table t; Table Op Msg_type Msg_text test.t analyze status OK diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db757_part_alter_analyze.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db757_part_alter_analyze.result index 21ce7704928..62337802688 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db757_part_alter_analyze.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db757_part_alter_analyze.result @@ -6,30 +6,30 @@ partition by range(id) insert into t values (1,1,1),(2,1,2),(3,1,3),(4,1,4); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 4 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE -t 1 y 1 y A NULL NULL NULL YES BTREE +t 0 PRIMARY 1 id A 5 NULL NULL BTREE +t 1 x 1 x A 5 NULL NULL YES BTREE +t 1 y 1 y A 5 NULL NULL YES BTREE alter table t analyze partition p0; Table Op Msg_type Msg_text test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 4 NULL NULL BTREE -t 1 x 1 x A 1 NULL NULL YES BTREE -t 1 y 1 y A 4 NULL NULL YES BTREE +t 0 PRIMARY 1 id A 5 NULL NULL BTREE +t 1 x 1 x A 5 NULL NULL YES BTREE +t 1 y 1 y A 5 NULL NULL YES BTREE alter table t analyze partition p1; Table Op Msg_type Msg_text test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t 0 PRIMARY 1 id A 4 NULL NULL BTREE -t 1 x 1 x A 1 NULL NULL YES BTREE -t 1 y 1 y A 4 NULL NULL YES BTREE +t 0 PRIMARY 1 id A 5 NULL NULL BTREE +t 1 x 1 x A 5 NULL NULL YES BTREE +t 1 y 1 y A 5 NULL NULL YES BTREE insert into t values (100,1,1),(200,2,1),(300,3,1),(400,4,1),(500,5,1); show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 9 NULL NULL BTREE -t 1 x 1 x A 2 NULL NULL YES BTREE +t 1 x 1 x A 9 NULL NULL YES BTREE t 1 y 1 y A 9 NULL NULL YES BTREE alter table t analyze partition p0; Table Op Msg_type Msg_text @@ -37,8 +37,8 @@ test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 9 NULL NULL BTREE -t 1 x 1 x A NULL NULL NULL YES BTREE -t 1 y 1 y A NULL NULL NULL YES BTREE +t 1 x 1 x A 9 NULL NULL YES BTREE +t 1 y 1 y A 9 NULL NULL YES BTREE alter table t analyze partition p1; Table Op Msg_type Msg_text test.t analyze status OK @@ -46,5 +46,5 @@ show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 9 NULL NULL BTREE t 1 x 1 x A 9 NULL NULL YES BTREE -t 1 y 1 y A 1 NULL NULL YES BTREE +t 1 y 1 y A 9 NULL NULL YES BTREE drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result new file mode 100644 index 00000000000..9c29033429e --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result @@ -0,0 +1,14 @@ +drop table if exists t1; +set @orig_table_open_cache = @@global.table_open_cache; +create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb); +lock tables t1 read; +set @@global.table_open_cache = 1; +begin; +insert into t1 values(1),(1); +select * from t1 where c like _ucs2 0x039C0025 collate ucs2_unicode_ci; +ERROR 42S22: Unknown column 'c' in 'where clause' +create table t1(c1 binary (1), c2 varbinary(1)); +ERROR 42S01: Table 't1' already exists +unlock tables; +drop table t1; +set @@global.table_open_cache = @orig_table_open_cache; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db938.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db938.result new file mode 100644 index 00000000000..779d458221b --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db938.result @@ -0,0 +1,35 @@ +set @orig_auto_analyze = @@session.tokudb_auto_analyze; +set @orig_in_background = @@session.tokudb_analyze_in_background; +set @orig_mode = @@session.tokudb_analyze_mode; +set @orig_throttle = @@session.tokudb_analyze_throttle; +set @orig_time = @@session.tokudb_analyze_time; +set @orig_scale_percent = @@global.tokudb_cardinality_scale_percent; +set @orig_default_storage_engine = @@session.default_storage_engine; +set @orig_pause_background_job_manager = @@global.tokudb_debug_pause_background_job_manager; +set session default_storage_engine = 'tokudb'; +set session tokudb_auto_analyze = 1; +set session tokudb_analyze_in_background = 1; +set session tokudb_analyze_mode = tokudb_analyze_standard; +set session tokudb_analyze_throttle = 0; +set session tokudb_analyze_time = 0; +set global tokudb_cardinality_scale_percent = DEFAULT; +set global tokudb_debug_pause_background_job_manager = TRUE; +create table t1 (a int not null auto_increment, b int, c int, primary key(a), key kb(b), key kc(c), key kabc(a,b,c), key kab(a,b), key kbc(b,c)); +insert into t1(b,c) values(0,0), (1,1), (2,2), (3,3); +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; +database_name table_name job_type job_params scheduler +test t1 TOKUDB_ANALYZE_MODE_STANDARD TOKUDB_ANALYZE_DELETE_FRACTION=1.000000; TOKUDB_ANALYZE_TIME=0; TOKUDB_ANALYZE_THROTTLE=0; AUTO +set DEBUG_SYNC = 'tokudb_after_truncate_all_dictionarys SIGNAL closed WAIT_FOR done'; +TRUNCATE TABLE t1; +set global tokudb_debug_pause_background_job_manager = FALSE; +set DEBUG_SYNC = 'now SIGNAL done'; +drop table t1; +set session tokudb_auto_analyze = @orig_auto_analyze; +set session tokudb_analyze_in_background = @orig_in_background; +set session tokudb_analyze_mode = @orig_mode; +set session tokudb_analyze_throttle = @orig_throttle; +set session tokudb_analyze_time = @orig_time; +set global tokudb_cardinality_scale_percent = @orig_scale_percent; +set session default_storage_engine = @orig_default_storage_engine; +set global tokudb_debug_pause_background_job_manager = @orig_pause_background_job_manager; +set DEBUG_SYNC='reset'; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db945.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db945.result new file mode 100644 index 00000000000..6b3c239d602 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db945.result @@ -0,0 +1,15 @@ +set default_storage_engine='tokudb'; +drop table if exists t1; +set session tokudb_auto_analyze = 1; +set session tokudb_analyze_in_background = true; +set session tokudb_analyze_mode = TOKUDB_ANALYZE_STANDARD; +set session tokudb_analyze_throttle = 0; +set session tokudb_analyze_time = 0; +create table t1(a int, b text(1), c text(1), filler text(1), primary key(a, b(1)), unique key (a, c(1))); +lock tables t1 write, t1 as a read, t1 as b read; +insert into t1(a) values(1); +Warnings: +Warning 1364 Field 'b' doesn't have a default value +alter table t1 drop key a; +unlock tables; +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt b/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt index 017432e797d..acad193fd76 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt @@ -1 +1 @@ ---tokudb-cache-size=1000000000 --innodb-buffer-pool-size=1000000000 +--loose-tokudb-cache-size=1000000000 --innodb-buffer-pool-size=1000000000 diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/5585.test b/storage/tokudb/mysql-test/tokudb_bugs/t/5585.test index bf0df681e7a..2489748dfa1 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/5585.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/5585.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc --source include/have_tokudb.inc +--source include/big_test.inc --disable_warnings drop table if exists t1, t2; @@ -18,12 +19,6 @@ insert into t1 select t1.file_id+40, t1.file_number+40 from t1; insert into t1 select t1.file_id+100, t1.file_number+100 from t1; insert into t1 select t1.file_id+200, t1.file_number+200 from t1; insert into t1 select t1.file_id+400, t1.file_number+400 from t1; -insert into t1 select t1.file_id+1000, t1.file_number+1000 from t1; -insert into t1 select t1.file_id+10000, t1.file_number+10000 from t1; -insert into t1 select t1.file_id+100000, t1.file_number+100000 from t1; -insert into t1 select t1.file_id+1000000, t1.file_number+1000000 from t1; -insert into t1 select t1.file_id+10000000, t1.file_number+10000000 from t1; -insert into t1 select t1.file_id+100000000, t1.file_number+100000000 from t1; create table t2 ( file_id bigint unsigned not null, @@ -64,4 +59,4 @@ select t1.file_id, (select hits from t2 where t2.file_id = t1.file_id and t2.insert_ts = date(date_sub(now(),interval 1 day))) as d from t1; -drop table if exists t1, t2; \ No newline at end of file +drop table if exists t1, t2; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db233.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db233.test new file mode 100644 index 00000000000..8e4c3b73c09 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db233.test @@ -0,0 +1,70 @@ +# This test for DB-233 tests that icp descending range scans stop properly once +# it fails to find a key match instead of continuing to scan all the way to the +# beginning of the index. + +-- source include/have_tokudb.inc +-- source include/have_debug.inc +-- source include/have_debug_sync.inc + +-- enable_query_log + +SET SESSION tokudb_auto_analyze = 0; +SET SESSION tokudb_analyze_in_background = 0; + +CREATE TABLE t1( + `id` int(10) unsigned NOT NULL, + `k` int(10) unsigned NOT NULL DEFAULT '0', + `c` char(120) NOT NULL DEFAULT '', + `pad` char(60) NOT NULL DEFAULT '', + KEY `xid` (`id`), + KEY `k` (`k`) +) ENGINE=TokuDB DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES(1, 1, '1', '1'), (2, 2, '2', '2'), (3, 3, '3', '3'), (4, 4, '4', '4'), +(5, 5, '5', '5'), (6, 6, '6', '6'), (6, 6, '6', '6'), (7, 7, '7', '7'), +(8, 8, '8', '8'), (9, 9, '9', '9'), (10, 10, '10', '10'), (11, 11, '11', '11'); + +ANALYZE TABLE t1; + +# lets flip to another connection +connect(conn1, localhost, root); + +# set up the DEBUG_SYNC point +set DEBUG_SYNC = 'tokudb_icp_desc_scan_invalidate SIGNAL hit1 WAIT_FOR done1'; + +# send the query +send SELECT c FROM t1 WHERE id BETWEEN 5 AND 8 ORDER BY id DESC; + +# back to default connection +connection default; + +# wait for the ICP reverse scan to invalidate +set DEBUG_SYNC = 'now WAIT_FOR hit1'; + +# lets release and clean up +set DEBUG_SYNC = 'now SIGNAL done1'; + +connection conn1; +reap; + +# set up the DEBUG_SYNC point again, but for the out of range +set DEBUG_SYNC = 'tokudb_icp_asc_scan_out_of_range SIGNAL hit2 WAIT_FOR done2'; + +# send the query +send SELECT c FROM t1 WHERE id BETWEEN 5 AND 8 ORDER BY id ASC; + +# back to default connection +connection default; + +# wait for the ICP reverse scan to invalidate +set DEBUG_SYNC = 'now WAIT_FOR hit2'; + +# lets release and clean up +set DEBUG_SYNC = 'now SIGNAL done2'; + +connection conn1; +reap; + +connection default; +disconnect conn1; +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db397_delete_trigger.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db397_delete_trigger.test index 00751ed2346..79043664607 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/db397_delete_trigger.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db397_delete_trigger.test @@ -28,7 +28,7 @@ start transaction; delete from t1 where col1 = 1; select col1,col2 from t1; select col1,action from t1_audit; -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; # note the locks on t1 and t1_audit commit; drop trigger t1_trigger; @@ -41,10 +41,10 @@ start transaction; delete from t1 where col1 = 2; select col1,col2 from t1; select col1,action from t1_audit; -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; # note the locks on t1 and t1_audit commit; drop trigger t1_trigger; drop table t1; -drop table t1_audit; \ No newline at end of file +drop table t1_audit; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db397_insert_trigger.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db397_insert_trigger.test index f32496e524d..ffe2face9f2 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/db397_insert_trigger.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db397_insert_trigger.test @@ -27,7 +27,7 @@ start transaction; insert into t1 (col1, col2) values (1,1); select col1,col2 from t1; select col1,action from t1_audit; -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; # note the locks on t1 and t1_audit commit; drop trigger t1_trigger; @@ -39,10 +39,10 @@ start transaction; insert into t1 (col1, col2) values (2,2); select col1,col2 from t1; select col1,action from t1_audit; -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; # note the locks on t1 and t1_audit commit; drop trigger t1_trigger; drop table t1; -drop table t1_audit; \ No newline at end of file +drop table t1_audit; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db397_update_trigger.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db397_update_trigger.test index f1407e6488a..063a88cb4ab 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/db397_update_trigger.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db397_update_trigger.test @@ -29,7 +29,7 @@ start transaction; update t1 set col2=1000 where col1 = 1; select col1,col2 from t1; select col1,action from t1_audit; -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; # check locks on t1 and t1_audit commit; drop trigger t1_trigger; @@ -43,7 +43,7 @@ start transaction; update t1 set col2=1001 where col1 = 2; select col1,col2 from t1; select col1,action from t1_audit; -select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks; +select locks_dname,locks_key_left,locks_key_right from information_schema.tokudb_locks order by locks_dname,locks_key_left,locks_key_right; # check locks on t1 and t1_audit commit; drop trigger t1_trigger; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test new file mode 100644 index 00000000000..ae94d7b30de --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test @@ -0,0 +1,23 @@ +# test DB-917 +# test that table/share open lock timeout does not crash the server on subsequent access +source include/have_partition.inc; +source include/have_tokudb.inc; +disable_warnings; +drop table if exists t1; +enable_warnings; +set @orig_table_open_cache = @@global.table_open_cache; +create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb); +lock tables t1 read; +set @@global.table_open_cache = 1; +begin; +insert into t1 values(1),(1); +# when the bug is present, this results in a lock wait timeout +--error ER_BAD_FIELD_ERROR +select * from t1 where c like _ucs2 0x039C0025 collate ucs2_unicode_ci; +# when the bug exists, this results in the assertion +# kc_info->cp_info[keynr] == NULL in tokudb/ha_tokudb.cc initialize_col_pack_info +--error ER_TABLE_EXISTS_ERROR +create table t1(c1 binary (1), c2 varbinary(1)); +unlock tables; +drop table t1; +set @@global.table_open_cache = @orig_table_open_cache; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db938.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db938.test new file mode 100644 index 00000000000..f56f93d1492 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db938.test @@ -0,0 +1,77 @@ +# This test for DB-938 tests a race condition where a scheduled background job +# (analyze) ends up operating on a set of DB* key_file[] in TOKUDB_SHARE that +# were set to NULL during a TRUNCATE TABLE operation. + +-- source include/have_tokudb.inc +-- source include/have_debug.inc +-- source include/have_debug_sync.inc + +-- enable_query_log + +set @orig_auto_analyze = @@session.tokudb_auto_analyze; +set @orig_in_background = @@session.tokudb_analyze_in_background; +set @orig_mode = @@session.tokudb_analyze_mode; +set @orig_throttle = @@session.tokudb_analyze_throttle; +set @orig_time = @@session.tokudb_analyze_time; +set @orig_scale_percent = @@global.tokudb_cardinality_scale_percent; +set @orig_default_storage_engine = @@session.default_storage_engine; +set @orig_pause_background_job_manager = @@global.tokudb_debug_pause_background_job_manager; + +# first, lets set up to auto analyze in the background with about any activity +set session default_storage_engine = 'tokudb'; +set session tokudb_auto_analyze = 1; +set session tokudb_analyze_in_background = 1; +set session tokudb_analyze_mode = tokudb_analyze_standard; +set session tokudb_analyze_throttle = 0; +set session tokudb_analyze_time = 0; +set global tokudb_cardinality_scale_percent = DEFAULT; + +# in debug build, we can prevent the background job manager from running, +# let's do it to hold a job from running until we get the TRUNCATE TABLE +# in action +set global tokudb_debug_pause_background_job_manager = TRUE; + +create table t1 (a int not null auto_increment, b int, c int, primary key(a), key kb(b), key kc(c), key kabc(a,b,c), key kab(a,b), key kbc(b,c)); + +insert into t1(b,c) values(0,0), (1,1), (2,2), (3,3); + +# insert above should have triggered an analyze, but since the bjm is paused, +# we will see it sitting in the queue +select database_name, table_name, job_type, job_params, scheduler from information_schema.tokudb_background_job_status; + +# lets flip to another connection +connect(conn1, localhost, root); + +# set up the DEBUG_SYNC point +set DEBUG_SYNC = 'tokudb_after_truncate_all_dictionarys SIGNAL closed WAIT_FOR done'; + +# send the truncat table +send TRUNCATE TABLE t1; + +# back to default connection +connection default; + +# release the bjm +set global tokudb_debug_pause_background_job_manager = FALSE; + +# if the bug is present, the bjm should crash here within 1/4 of a second +sleep 5; + +# lets release and clean up +set DEBUG_SYNC = 'now SIGNAL done'; + +connection conn1; +reap; +connection default; +disconnect conn1; +drop table t1; + +set session tokudb_auto_analyze = @orig_auto_analyze; +set session tokudb_analyze_in_background = @orig_in_background; +set session tokudb_analyze_mode = @orig_mode; +set session tokudb_analyze_throttle = @orig_throttle; +set session tokudb_analyze_time = @orig_time; +set global tokudb_cardinality_scale_percent = @orig_scale_percent; +set session default_storage_engine = @orig_default_storage_engine; +set global tokudb_debug_pause_background_job_manager = @orig_pause_background_job_manager; +set DEBUG_SYNC='reset'; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db945.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db945.test new file mode 100644 index 00000000000..27b0d284484 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db945.test @@ -0,0 +1,24 @@ +source include/have_tokudb.inc; +set default_storage_engine='tokudb'; +disable_warnings; +drop table if exists t1; +enable_warnings; + +set session tokudb_auto_analyze = 1; +set session tokudb_analyze_in_background = true; +set session tokudb_analyze_mode = TOKUDB_ANALYZE_STANDARD; +set session tokudb_analyze_throttle = 0; +set session tokudb_analyze_time = 0; + +create table t1(a int, b text(1), c text(1), filler text(1), primary key(a, b(1)), unique key (a, c(1))); +lock tables t1 write, t1 as a read, t1 as b read; +insert into t1(a) values(1); +alter table t1 drop key a; +unlock tables; + +# wait for the bjm queue to empty +-- disable_query_log +let $wait_condition=select count(*)=0 from information_schema.tokudb_background_job_status; +-- source include/wait_condition.inc + +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/disabled.def b/storage/tokudb/mysql-test/tokudb_bugs/t/disabled.def new file mode 100644 index 00000000000..8c755dde8f5 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/disabled.def @@ -0,0 +1,16 @@ +2952: tokutek not_5_5 +4472 : #4521 MDL for alter table in 5.5 prohibits this test from having any chance of working +fileops-2: tokutek not_5_5 +fileops-3: tokutek not_5_5 +fileops-4: tokutek not_5_5 +memcache_dirty: tokutek FB port +xa-2: tokutek not_5_5 +tokudb_drop_part_table_668: upgrade from tokudb 6.6.8 +tokudb_drop_simple_table_668: upgrade from tokudb 6.6.8 +checkpoint_lock_2: test can not work when the checkpoint_safe_lock is a fair rwlock +6053: tokudb is not the default storage engine +1883: tokutek's auto inc singleton patch missing +3083: no patch to find_shortest_key to prefer PK over CK +db768 : https://tokutek.atlassian.net/browse/DB-768 +dict_leak_3518 : https://tokutek.atlassian.net/browse/DB-635 +1872 : https://tokutek.atlassian.net/browse/DB-750 diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/suite.opt b/storage/tokudb/mysql-test/tokudb_bugs/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/xa-3.test b/storage/tokudb/mysql-test/tokudb_bugs/t/xa-3.test index 828cf03d2fd..e19291991b6 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/xa-3.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/xa-3.test @@ -1,6 +1,12 @@ -- source include/have_innodb.inc -- source include/have_tokudb.inc -- source include/have_debug.inc +# Valgrind would report memory leaks on the intentional crashes +-- source include/not_valgrind.inc +# Embedded server does not support crashing +-- source include/not_embedded.inc +# Avoid CrashReporter popup on Mac +-- source include/not_crashrep.inc --disable_warnings drop table if exists t1, t2; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/xa-4.test b/storage/tokudb/mysql-test/tokudb_bugs/t/xa-4.test index 1642cb7ca1b..f1f96711b89 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/xa-4.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/xa-4.test @@ -1,6 +1,12 @@ -- source include/have_innodb.inc -- source include/have_tokudb.inc -- source include/have_debug.inc +# Valgrind would report memory leaks on the intentional crashes +-- source include/not_valgrind.inc +# Embedded server does not support crashing +-- source include/not_embedded.inc +# Avoid CrashReporter popup on Mac +-- source include/not_crashrep.inc --disable_warnings drop table if exists t1, t2; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/xa-6.test b/storage/tokudb/mysql-test/tokudb_bugs/t/xa-6.test index 312c2d15cd2..c6c11f633e1 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/xa-6.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/xa-6.test @@ -1,5 +1,11 @@ --source include/have_tokudb.inc --source include/have_debug.inc +# Valgrind would report memory leaks on the intentional crashes +-- source include/not_valgrind.inc +# Embedded server does not support crashing +-- source include/not_embedded.inc +# Avoid CrashReporter popup on Mac +-- source include/not_crashrep.inc --disable_warnings drop table if exists t1; diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result b/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result index 625bb255755..086c4f4cc18 100644 --- a/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result +++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev5426.result @@ -1,6 +1,6 @@ CREATE TABLE t1 (i INT) ENGINE=TokuDB; EXPLAIN INSERT INTO t1 SELECT * FROM t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using temporary +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using temporary INSERT INTO t1 SELECT * FROM t1; DROP TABLE t1; diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result b/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result index 02ede175ce1..50e5b1940b0 100644 --- a/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result +++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result @@ -34,7 +34,7 @@ SELECT t3.task_id, t3.field FROM t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index PRIMARY,ymtasks_type ymtasks_type 2 NULL 2 Using where; Using index -1 SIMPLE t3 ref ymtasksoptions_task ymtasksoptions_task 4 test.t2.task_id 7 +1 SIMPLE t3 ref ymtasksoptions_task ymtasksoptions_task 4 test.t2.task_id 1 SELECT t3.task_id, t3.field FROM t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11); task_id field @@ -85,7 +85,7 @@ SELECT t3.task_id, t3.field FROM t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index PRIMARY,ymtasks_type ymtasks_type 2 NULL 2 Using where; Using index -1 SIMPLE t3 ref ymtasksoptions_task ymtasksoptions_task 4 test.t2.task_id 7 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ref ymtasksoptions_task ymtasksoptions_task 4 test.t2.task_id 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan SELECT t3.task_id, t3.field FROM t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11); task_id field diff --git a/storage/tokudb/mysql-test/tokudb_parts/disabled.def b/storage/tokudb/mysql-test/tokudb_parts/disabled.def index 582ca590166..3252a463176 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/disabled.def +++ b/storage/tokudb/mysql-test/tokudb_parts/disabled.def @@ -1,6 +1,3 @@ -partition_basic_symlink_tokudb : tokudb_file_per_table is not supported -partition_reorganize_tokudb : tokudb_file_per_table is not supported - partition_max_parts_hash_tokudb: 5.6 test not merged yet partition_max_parts_inv_tokudb: 5.6 test not merged yet partition_max_parts_key_tokudb: 5.6 test not merged yet 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_auto_increment_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result index 2101feaacb3..aadfaba3b7b 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result @@ -1,3 +1,6 @@ +SET @tokudb_prelock_empty_saved = @@GLOBAL.tokudb_prelock_empty; +SET GLOBAL tokudb_prelock_empty = 0; +SET SESSION tokudb_prelock_empty = 0; DROP TABLE IF EXISTS t1; # test without partitioning for reference CREATE TABLE t1 ( @@ -1107,3 +1110,4 @@ a 0 DROP TABLE t1; ############################################################################## +SET GLOBAL tokudb_prelock_empty = @tokudb_prelock_empty_saved; 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/tokudb/mysql-test/tokudb_parts/t/disabled.def b/storage/tokudb/mysql-test/tokudb_parts/t/disabled.def new file mode 100644 index 00000000000..90e599cd035 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_parts/t/disabled.def @@ -0,0 +1,2 @@ +partition_basic_symlink_tokudb : tokudb_file_per_table is not supported +partition_reorganize_tokudb : tokudb_file_per_table is not supported diff --git a/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb-master.opt b/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb-master.opt deleted file mode 100644 index 857da664d10..00000000000 --- a/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb-master.opt +++ /dev/null @@ -1 +0,0 @@ ---tokudb-prelock-empty=0 diff --git a/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb.test b/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb.test index a13ddf65d4b..ceec2fda9ee 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb.test +++ b/storage/tokudb/mysql-test/tokudb_parts/t/partition_auto_increment_tokudb.test @@ -29,7 +29,12 @@ let $engine= 'TokuDB'; --source include/have_tokudb.inc +SET @tokudb_prelock_empty_saved = @@GLOBAL.tokudb_prelock_empty; +SET GLOBAL tokudb_prelock_empty = 0; +SET SESSION tokudb_prelock_empty = 0; + #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines --source suite/parts/inc/partition_auto_increment.inc +SET GLOBAL tokudb_prelock_empty = @tokudb_prelock_empty_saved; diff --git a/storage/tokudb/mysql-test/tokudb_parts/t/suite.opt b/storage/tokudb/mysql-test/tokudb_parts/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_parts/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_rpl/r/rpl_rfr_disable_on_expl_pk_absence.result b/storage/tokudb/mysql-test/tokudb_rpl/r/rpl_rfr_disable_on_expl_pk_absence.result new file mode 100644 index 00000000000..981a833aea5 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_rpl/r/rpl_rfr_disable_on_expl_pk_absence.result @@ -0,0 +1,47 @@ +include/master-slave.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection master] +call mtr.add_suppression("read free replication is disabled for tokudb table"); +CREATE TABLE t (a int(11), b char(20)) ENGINE = TokuDB; +INSERT INTO t (a, b) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'); +SELECT * FROM t; +a b +1 a +2 b +3 c +4 d +5 e +UPDATE t SET a = a + 10 WHERE b = 'b'; +SELECT * FROM t; +a b +1 a +12 b +3 c +4 d +5 e +SELECT * FROM t; +a b +1 a +12 b +3 c +4 d +5 e +UPDATE t SET a = a + 10 WHERE b = 'b'; +SELECT * FROM t; +a b +1 a +22 b +3 c +4 d +5 e +SELECT * FROM t; +a b +1 a +22 b +3 c +4 d +5 e +DROP TABLE t; +include/rpl_end.inc diff --git a/storage/tokudb/mysql-test/tokudb_rpl/t/rpl_rfr_disable_on_expl_pk_absence-slave.opt b/storage/tokudb/mysql-test/tokudb_rpl/t/rpl_rfr_disable_on_expl_pk_absence-slave.opt new file mode 100644 index 00000000000..c87bbb62418 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_rpl/t/rpl_rfr_disable_on_expl_pk_absence-slave.opt @@ -0,0 +1 @@ +--read-only=true --loose-tokudb-rpl-unique-checks=false --loose-tokudb-rpl-lookup-rows=false diff --git a/storage/tokudb/mysql-test/tokudb_rpl/t/rpl_rfr_disable_on_expl_pk_absence.test b/storage/tokudb/mysql-test/tokudb_rpl/t/rpl_rfr_disable_on_expl_pk_absence.test new file mode 100644 index 00000000000..67e77c1511c --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_rpl/t/rpl_rfr_disable_on_expl_pk_absence.test @@ -0,0 +1,48 @@ +# Test case for bug#1536663 +# +# When read-free-replication is enabled for tokudb and there is no explicit +# pk for replicated table there can be dublicated records in the table on +# update operation. +# +# Consider this update operation: +# UPDATE t SET a = a + 10 WHERE b = 'b'; +# The master does rows lookup and updates the rows which values correspond to +# the condition. The update events are written to binary log with +# rows values from the master. As rows lookup is forbidden for slave +# the new rows are added instead of updating corresponding rows. +# +# Without the fix there will be several rows with b = 'b' in the table on slave +# instead of one updated row. +# + +--source include/have_tokudb.inc +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +call mtr.add_suppression("read free replication is disabled for tokudb table"); + +--connection master +CREATE TABLE t (a int(11), b char(20)) ENGINE = TokuDB; +INSERT INTO t (a, b) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'); + +--sync_slave_with_master +--sorted_result +SELECT * FROM t; + +--let $i = 2 +--while($i) { + --dec $i + --connection master + UPDATE t SET a = a + 10 WHERE b = 'b'; + --sorted_result + SELECT * FROM t; + --sync_slave_with_master + --sorted_result + SELECT * FROM t; +} + +--connection master +DROP TABLE t; +--sync_slave_with_master + +--source include/rpl_end.inc diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_delete_fraction.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_delete_fraction.result new file mode 100644 index 00000000000..41918883dd6 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_delete_fraction.result @@ -0,0 +1,73 @@ +SET @orig_global = @@global.tokudb_analyze_delete_fraction; +SELECT @orig_global; +@orig_global +1 +SET @orig_session = @@session.tokudb_analyze_delete_fraction; +SELECT @orig_session; +@orig_session +1 +SET GLOBAL tokudb_analyze_delete_fraction = .5; +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +0.500000 +SET GLOBAL tokudb_analyze_delete_fraction = 0; +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +0.000000 +SET GLOBAL tokudb_analyze_delete_fraction = DEFAULT; +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +1.000000 +SET GLOBAL tokudb_analyze_delete_fraction = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_delete_fraction' +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +1.000000 +SET GLOBAL tokudb_analyze_delete_fraction = 3.75; +Warnings: +Warning 1292 Truncated incorrect tokudb_analyze_delete_fraction value: '3.75' +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +1.000000 +SET SESSION tokudb_analyze_delete_fraction = .5; +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +0.500000 +SET SESSION tokudb_analyze_delete_fraction = 0; +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +0.000000 +SET SESSION tokudb_analyze_delete_fraction = DEFAULT; +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +1.000000 +SET SESSION tokudb_analyze_delete_fraction = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_delete_fraction' +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +1.000000 +SET SESSION tokudb_analyze_delete_fraction = 3.75; +Warnings: +Warning 1292 Truncated incorrect tokudb_analyze_delete_fraction value: '3.75' +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +1.000000 +SET GLOBAL tokudb_analyze_delete_fraction = .2; +SET SESSION tokudb_analyze_delete_fraction = .3; +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +0.200000 +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +0.300000 +SHOW VARIABLES LIKE 'tokudb_analyze_delete_fraction'; +Variable_name Value +tokudb_analyze_delete_fraction 0.300000 +SET SESSION tokudb_analyze_delete_fraction = @orig_session; +SELECT @@session.tokudb_analyze_delete_fraction; +@@session.tokudb_analyze_delete_fraction +1.000000 +SET GLOBAL tokudb_analyze_delete_fraction = @orig_global; +SELECT @@global.tokudb_analyze_delete_fraction; +@@global.tokudb_analyze_delete_fraction +1.000000 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_in_background_basic.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_in_background_basic.result new file mode 100644 index 00000000000..53e96810eda --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_in_background_basic.result @@ -0,0 +1,99 @@ +SET @orig_global = @@global.tokudb_analyze_in_background; +SELECT @orig_global; +@orig_global +0 +SET @orig_session = @@session.tokudb_analyze_in_background; +SELECT @orig_session; +@orig_session +0 +SET GLOBAL tokudb_analyze_in_background = 0; +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +0 +SET GLOBAL tokudb_analyze_in_background = 1; +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +1 +SET GLOBAL tokudb_analyze_in_background = DEFAULT; +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +0 +SET GLOBAL tokudb_analyze_in_background = -6; +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +1 +SET GLOBAL tokudb_analyze_in_background = 1.6; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_in_background' +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +1 +SET GLOBAL tokudb_analyze_in_background = "T"; +ERROR 42000: Variable 'tokudb_analyze_in_background' can't be set to the value of 'T' +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +1 +SET GLOBAL tokudb_analyze_in_background = "Y"; +ERROR 42000: Variable 'tokudb_analyze_in_background' can't be set to the value of 'Y' +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +1 +SET GLOBAL tokudb_analyze_in_background = 'foobar'; +ERROR 42000: Variable 'tokudb_analyze_in_background' can't be set to the value of 'foobar' +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = 0; +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +0 +SET SESSION tokudb_analyze_in_background = 1; +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = DEFAULT; +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = -6; +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = 1.6; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_in_background' +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = "T"; +ERROR 42000: Variable 'tokudb_analyze_in_background' can't be set to the value of 'T' +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = "Y"; +ERROR 42000: Variable 'tokudb_analyze_in_background' can't be set to the value of 'Y' +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET SESSION tokudb_analyze_in_background = 'foobar'; +ERROR 42000: Variable 'tokudb_analyze_in_background' can't be set to the value of 'foobar' +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SET GLOBAL tokudb_analyze_in_background = 0; +SET SESSION tokudb_analyze_in_background = 1; +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +0 +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +1 +SHOW VARIABLES LIKE 'tokudb_analyze_in_background'; +Variable_name Value +tokudb_analyze_in_background ON +SET SESSION tokudb_analyze_in_background = @orig_session; +SELECT @@session.tokudb_analyze_in_background; +@@session.tokudb_analyze_in_background +0 +SET GLOBAL tokudb_analyze_in_background = @orig_global; +SELECT @@global.tokudb_analyze_in_background; +@@global.tokudb_analyze_in_background +0 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_mode_basic.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_mode_basic.result new file mode 100644 index 00000000000..e2a3059a5aa --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_mode_basic.result @@ -0,0 +1,89 @@ +SET @orig_global = @@global.tokudb_analyze_mode; +SELECT @orig_global; +@orig_global +TOKUDB_ANALYZE_STANDARD +SET @orig_session = @@session.tokudb_analyze_mode; +SELECT @orig_session; +@orig_session +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_standard'; +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_recount_rows'; +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_RECOUNT_ROWS +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_cancel'; +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_CANCEL +SET GLOBAL tokudb_analyze_mode = DEFAULT; +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = ''; +ERROR 42000: Variable 'tokudb_analyze_mode' can't be set to the value of '' +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = 'foobar'; +ERROR 42000: Variable 'tokudb_analyze_mode' can't be set to the value of 'foobar' +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = 123; +ERROR 42000: Variable 'tokudb_analyze_mode' can't be set to the value of '123' +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_standard'; +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_recount_rows'; +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_RECOUNT_ROWS +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_cancel'; +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_CANCEL +SET SESSION tokudb_analyze_mode = DEFAULT; +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET SESSION tokudb_analyze_mode = ''; +ERROR 42000: Variable 'tokudb_analyze_mode' can't be set to the value of '' +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET SESSION tokudb_analyze_mode = 'foobar'; +ERROR 42000: Variable 'tokudb_analyze_mode' can't be set to the value of 'foobar' +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET SESSION tokudb_analyze_mode = 123; +ERROR 42000: Variable 'tokudb_analyze_mode' can't be set to the value of '123' +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_standard'; +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_recount_rows'; +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_RECOUNT_ROWS +SHOW VARIABLES LIKE 'tokudb_analyze_mode'; +Variable_name Value +tokudb_analyze_mode TOKUDB_ANALYZE_RECOUNT_ROWS +SET SESSION tokudb_analyze_mode = @orig_session; +SELECT @@session.tokudb_analyze_mode; +@@session.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD +SET GLOBAL tokudb_analyze_mode = @orig_global; +SELECT @@global.tokudb_analyze_mode; +@@global.tokudb_analyze_mode +TOKUDB_ANALYZE_STANDARD diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_throttle_basic.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_throttle_basic.result new file mode 100644 index 00000000000..34317c7cb7b --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_throttle_basic.result @@ -0,0 +1,61 @@ +SET @orig_global = @@global.tokudb_analyze_throttle; +SELECT @orig_global; +@orig_global +0 +SET @orig_session = @@session.tokudb_analyze_throttle; +SELECT @orig_session; +@orig_session +0 +SET GLOBAL tokudb_analyze_throttle = 10; +SELECT @@global.tokudb_analyze_throttle; +@@global.tokudb_analyze_throttle +10 +SET GLOBAL tokudb_analyze_throttle = 0; +SELECT @@global.tokudb_analyze_throttle; +@@global.tokudb_analyze_throttle +0 +SET GLOBAL tokudb_analyze_throttle = DEFAULT; +SELECT @@global.tokudb_analyze_throttle; +@@global.tokudb_analyze_throttle +0 +SET GLOBAL tokudb_analyze_throttle = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_throttle' +SELECT @@global.tokudb_analyze_throttle; +@@global.tokudb_analyze_throttle +0 +SET SESSION tokudb_analyze_throttle = 10; +SELECT @@session.tokudb_analyze_throttle; +@@session.tokudb_analyze_throttle +10 +SET SESSION tokudb_analyze_throttle = 0; +SELECT @@session.tokudb_analyze_throttle; +@@session.tokudb_analyze_throttle +0 +SET SESSION tokudb_analyze_throttle = DEFAULT; +SELECT @@session.tokudb_analyze_throttle; +@@session.tokudb_analyze_throttle +0 +SET SESSION tokudb_analyze_throttle = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_throttle' +SELECT @@session.tokudb_analyze_throttle; +@@session.tokudb_analyze_throttle +0 +SET GLOBAL tokudb_analyze_throttle = 12; +SET SESSION tokudb_analyze_throttle = 13; +SELECT @@global.tokudb_analyze_throttle; +@@global.tokudb_analyze_throttle +12 +SELECT @@session.tokudb_analyze_throttle; +@@session.tokudb_analyze_throttle +13 +SHOW VARIABLES LIKE 'tokudb_analyze_throttle'; +Variable_name Value +tokudb_analyze_throttle 13 +SET SESSION tokudb_analyze_throttle = @orig_session; +SELECT @@session.tokudb_analyze_throttle; +@@session.tokudb_analyze_throttle +0 +SET GLOBAL tokudb_analyze_throttle = @orig_global; +SELECT @@global.tokudb_analyze_throttle; +@@global.tokudb_analyze_throttle +0 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_time_basic.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_time_basic.result new file mode 100644 index 00000000000..2eac1fcc3a1 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_analyze_time_basic.result @@ -0,0 +1,61 @@ +SET @orig_global = @@global.tokudb_analyze_time; +SELECT @orig_global; +@orig_global +5 +SET @orig_session = @@session.tokudb_analyze_time; +SELECT @orig_session; +@orig_session +5 +SET GLOBAL tokudb_analyze_time = 10; +SELECT @@global.tokudb_analyze_time; +@@global.tokudb_analyze_time +10 +SET GLOBAL tokudb_analyze_time = 0; +SELECT @@global.tokudb_analyze_time; +@@global.tokudb_analyze_time +0 +SET GLOBAL tokudb_analyze_time = DEFAULT; +SELECT @@global.tokudb_analyze_time; +@@global.tokudb_analyze_time +5 +SET GLOBAL tokudb_analyze_time = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_time' +SELECT @@global.tokudb_analyze_time; +@@global.tokudb_analyze_time +5 +SET SESSION tokudb_analyze_time = 10; +SELECT @@session.tokudb_analyze_time; +@@session.tokudb_analyze_time +10 +SET SESSION tokudb_analyze_time = 0; +SELECT @@session.tokudb_analyze_time; +@@session.tokudb_analyze_time +0 +SET SESSION tokudb_analyze_time = DEFAULT; +SELECT @@session.tokudb_analyze_time; +@@session.tokudb_analyze_time +5 +SET SESSION tokudb_analyze_time = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_analyze_time' +SELECT @@session.tokudb_analyze_time; +@@session.tokudb_analyze_time +5 +SET GLOBAL tokudb_analyze_time = 12; +SET SESSION tokudb_analyze_time = 13; +SELECT @@global.tokudb_analyze_time; +@@global.tokudb_analyze_time +12 +SELECT @@session.tokudb_analyze_time; +@@session.tokudb_analyze_time +13 +SHOW VARIABLES LIKE 'tokudb_analyze_time'; +Variable_name Value +tokudb_analyze_time 13 +SET SESSION tokudb_analyze_time = @orig_session; +SELECT @@session.tokudb_analyze_time; +@@session.tokudb_analyze_time +5 +SET GLOBAL tokudb_analyze_time = @orig_global; +SELECT @@global.tokudb_analyze_time; +@@global.tokudb_analyze_time +5 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_auto_analyze.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_auto_analyze.result new file mode 100644 index 00000000000..5e22bc489cb --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_auto_analyze.result @@ -0,0 +1,61 @@ +SET @orig_global = @@global.tokudb_auto_analyze; +SELECT @orig_global; +@orig_global +0 +SET @orig_session = @@session.tokudb_auto_analyze; +SELECT @orig_session; +@orig_session +0 +SET GLOBAL tokudb_auto_analyze = 10; +SELECT @@global.tokudb_auto_analyze; +@@global.tokudb_auto_analyze +10 +SET GLOBAL tokudb_auto_analyze = 0; +SELECT @@global.tokudb_auto_analyze; +@@global.tokudb_auto_analyze +0 +SET GLOBAL tokudb_auto_analyze = DEFAULT; +SELECT @@global.tokudb_auto_analyze; +@@global.tokudb_auto_analyze +0 +SET GLOBAL tokudb_auto_analyze = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_auto_analyze' +SELECT @@global.tokudb_auto_analyze; +@@global.tokudb_auto_analyze +0 +SET SESSION tokudb_auto_analyze = 10; +SELECT @@session.tokudb_auto_analyze; +@@session.tokudb_auto_analyze +10 +SET SESSION tokudb_auto_analyze = 0; +SELECT @@session.tokudb_auto_analyze; +@@session.tokudb_auto_analyze +0 +SET SESSION tokudb_auto_analyze = DEFAULT; +SELECT @@session.tokudb_auto_analyze; +@@session.tokudb_auto_analyze +0 +SET SESSION tokudb_auto_analyze = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_auto_analyze' +SELECT @@session.tokudb_auto_analyze; +@@session.tokudb_auto_analyze +0 +SET GLOBAL tokudb_auto_analyze = 12; +SET SESSION tokudb_auto_analyze = 13; +SELECT @@global.tokudb_auto_analyze; +@@global.tokudb_auto_analyze +12 +SELECT @@session.tokudb_auto_analyze; +@@session.tokudb_auto_analyze +13 +SHOW VARIABLES LIKE 'tokudb_auto_analyze'; +Variable_name Value +tokudb_auto_analyze 13 +SET SESSION tokudb_auto_analyze = @orig_session; +SELECT @@session.tokudb_auto_analyze; +@@session.tokudb_auto_analyze +0 +SET GLOBAL tokudb_auto_analyze = @orig_global; +SELECT @@global.tokudb_auto_analyze; +@@global.tokudb_auto_analyze +0 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_cardinality_scale_percent_basic.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_cardinality_scale_percent_basic.result new file mode 100644 index 00000000000..cac5d8b0dc7 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_cardinality_scale_percent_basic.result @@ -0,0 +1,36 @@ +SET @orig_global = @@global.tokudb_cardinality_scale_percent; +SELECT @orig_global; +@orig_global +50 +SET GLOBAL tokudb_cardinality_scale_percent = 10; +SELECT @@global.tokudb_cardinality_scale_percent; +@@global.tokudb_cardinality_scale_percent +10 +SET GLOBAL tokudb_cardinality_scale_percent = 0; +SELECT @@global.tokudb_cardinality_scale_percent; +@@global.tokudb_cardinality_scale_percent +0 +SET GLOBAL tokudb_cardinality_scale_percent = DEFAULT; +SELECT @@global.tokudb_cardinality_scale_percent; +@@global.tokudb_cardinality_scale_percent +50 +SET GLOBAL tokudb_cardinality_scale_percent = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_cardinality_scale_percent' +SELECT @@global.tokudb_cardinality_scale_percent; +@@global.tokudb_cardinality_scale_percent +50 +SET GLOBAL tokudb_cardinality_scale_percent = 12; +SET SESSION tokudb_cardinality_scale_percent = 13; +ERROR HY000: Variable 'tokudb_cardinality_scale_percent' is a GLOBAL variable and should be set with SET GLOBAL +SELECT @@global.tokudb_cardinality_scale_percent; +@@global.tokudb_cardinality_scale_percent +12 +SELECT @@session.tokudb_cardinality_scale_percent; +ERROR HY000: Variable 'tokudb_cardinality_scale_percent' is a GLOBAL variable +SHOW VARIABLES LIKE 'tokudb_cardinality_scale_percent'; +Variable_name Value +tokudb_cardinality_scale_percent 12 +SET GLOBAL tokudb_cardinality_scale_percent = @orig_global; +SELECT @@global.tokudb_cardinality_scale_percent; +@@global.tokudb_cardinality_scale_percent +50 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_pk_insert_mode_basic.result b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_pk_insert_mode_basic.result new file mode 100644 index 00000000000..268c4032626 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/r/tokudb_pk_insert_mode_basic.result @@ -0,0 +1,85 @@ +SET @orig_global = @@global.tokudb_pk_insert_mode; +SELECT @orig_global; +@orig_global +1 +SET @orig_session = @@session.tokudb_pk_insert_mode; +SELECT @orig_session; +@orig_session +1 +SET GLOBAL tokudb_pk_insert_mode = 10; +Warnings: +Warning 1292 Truncated incorrect tokudb_pk_insert_mode value: '10' +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@global.tokudb_pk_insert_mode; +@@global.tokudb_pk_insert_mode +2 +SET GLOBAL tokudb_pk_insert_mode = 0; +Warnings: +Warning 131 Using tokudb_pk_insert_mode=0 is deprecated and the parameter may be removed in future releases. Only tokudb_pk_insert_mode=1|2 is allowed.Resettig the value to 1. +SELECT @@global.tokudb_pk_insert_mode; +@@global.tokudb_pk_insert_mode +1 +SET GLOBAL tokudb_pk_insert_mode = DEFAULT; +Warnings: +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@global.tokudb_pk_insert_mode; +@@global.tokudb_pk_insert_mode +1 +SET GLOBAL tokudb_pk_insert_mode = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_pk_insert_mode' +SELECT @@global.tokudb_pk_insert_mode; +@@global.tokudb_pk_insert_mode +1 +SET SESSION tokudb_pk_insert_mode = 10; +Warnings: +Warning 1292 Truncated incorrect tokudb_pk_insert_mode value: '10' +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@session.tokudb_pk_insert_mode; +@@session.tokudb_pk_insert_mode +2 +SET SESSION tokudb_pk_insert_mode = 0; +Warnings: +Warning 131 Using tokudb_pk_insert_mode=0 is deprecated and the parameter may be removed in future releases. Only tokudb_pk_insert_mode=1|2 is allowed.Resettig the value to 1. +SELECT @@session.tokudb_pk_insert_mode; +@@session.tokudb_pk_insert_mode +1 +SET SESSION tokudb_pk_insert_mode = DEFAULT; +Warnings: +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@session.tokudb_pk_insert_mode; +@@session.tokudb_pk_insert_mode +1 +SET SESSION tokudb_pk_insert_mode = 'foobar'; +ERROR 42000: Incorrect argument type to variable 'tokudb_pk_insert_mode' +SELECT @@session.tokudb_pk_insert_mode; +@@session.tokudb_pk_insert_mode +1 +SET GLOBAL tokudb_pk_insert_mode = 12; +Warnings: +Warning 1292 Truncated incorrect tokudb_pk_insert_mode value: '12' +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SET SESSION tokudb_pk_insert_mode = 13; +Warnings: +Warning 1292 Truncated incorrect tokudb_pk_insert_mode value: '13' +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@global.tokudb_pk_insert_mode; +@@global.tokudb_pk_insert_mode +2 +SELECT @@session.tokudb_pk_insert_mode; +@@session.tokudb_pk_insert_mode +2 +SHOW VARIABLES LIKE 'tokudb_pk_insert_mode'; +Variable_name Value +tokudb_pk_insert_mode 2 +SET SESSION tokudb_pk_insert_mode = @orig_session; +Warnings: +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@session.tokudb_pk_insert_mode; +@@session.tokudb_pk_insert_mode +1 +SET GLOBAL tokudb_pk_insert_mode = @orig_global; +Warnings: +Warning 131 Using tokudb_pk_insert_mode is deprecated and the parameter may be removed in future releases. +SELECT @@global.tokudb_pk_insert_mode; +@@global.tokudb_pk_insert_mode +1 diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/suite.opt b/storage/tokudb/mysql-test/tokudb_sys_vars/t/suite.opt new file mode 100644 index 00000000000..15acdf7397f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/suite.opt @@ -0,0 +1 @@ +$TOKUDB_OPT $TOKUDB_LOAD_ADD --loose-tokudb-check-jemalloc=0 --loose-tokudb-cache-size=512M --loose-tokudb-block-size=1M diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_delete_fraction.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_delete_fraction.test new file mode 100644 index 00000000000..d5bd382740f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_delete_fraction.test @@ -0,0 +1,56 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_analyze_delete_fraction; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_analyze_delete_fraction; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_analyze_delete_fraction = .5; +SELECT @@global.tokudb_analyze_delete_fraction; + +SET GLOBAL tokudb_analyze_delete_fraction = 0; +SELECT @@global.tokudb_analyze_delete_fraction; + +SET GLOBAL tokudb_analyze_delete_fraction = DEFAULT; +SELECT @@global.tokudb_analyze_delete_fraction; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_analyze_delete_fraction = 'foobar'; +SELECT @@global.tokudb_analyze_delete_fraction; + +SET GLOBAL tokudb_analyze_delete_fraction = 3.75; +SELECT @@global.tokudb_analyze_delete_fraction; + +# Test session +SET SESSION tokudb_analyze_delete_fraction = .5; +SELECT @@session.tokudb_analyze_delete_fraction; + +SET SESSION tokudb_analyze_delete_fraction = 0; +SELECT @@session.tokudb_analyze_delete_fraction; + +SET SESSION tokudb_analyze_delete_fraction = DEFAULT; +SELECT @@session.tokudb_analyze_delete_fraction; + +-- error ER_WRONG_TYPE_FOR_VAR +SET SESSION tokudb_analyze_delete_fraction = 'foobar'; +SELECT @@session.tokudb_analyze_delete_fraction; + +SET SESSION tokudb_analyze_delete_fraction = 3.75; +SELECT @@session.tokudb_analyze_delete_fraction; + +# both +SET GLOBAL tokudb_analyze_delete_fraction = .2; +SET SESSION tokudb_analyze_delete_fraction = .3; +SELECT @@global.tokudb_analyze_delete_fraction; +SELECT @@session.tokudb_analyze_delete_fraction; +SHOW VARIABLES LIKE 'tokudb_analyze_delete_fraction'; + +# Clean up +SET SESSION tokudb_analyze_delete_fraction = @orig_session; +SELECT @@session.tokudb_analyze_delete_fraction; + +SET GLOBAL tokudb_analyze_delete_fraction = @orig_global; +SELECT @@global.tokudb_analyze_delete_fraction; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_in_background_basic.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_in_background_basic.test new file mode 100644 index 00000000000..dfb2a0e416d --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_in_background_basic.test @@ -0,0 +1,80 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_analyze_in_background; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_analyze_in_background; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_analyze_in_background = 0; +SELECT @@global.tokudb_analyze_in_background; + +SET GLOBAL tokudb_analyze_in_background = 1; +SELECT @@global.tokudb_analyze_in_background; + +SET GLOBAL tokudb_analyze_in_background = DEFAULT; +SELECT @@global.tokudb_analyze_in_background; + +SET GLOBAL tokudb_analyze_in_background = -6; +SELECT @@global.tokudb_analyze_in_background; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_analyze_in_background = 1.6; +SELECT @@global.tokudb_analyze_in_background; + +-- error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL tokudb_analyze_in_background = "T"; +SELECT @@global.tokudb_analyze_in_background; + +-- error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL tokudb_analyze_in_background = "Y"; +SELECT @@global.tokudb_analyze_in_background; + +-- error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL tokudb_analyze_in_background = 'foobar'; +SELECT @@global.tokudb_analyze_in_background; + +# Test session +SET SESSION tokudb_analyze_in_background = 0; +SELECT @@session.tokudb_analyze_in_background; + +SET SESSION tokudb_analyze_in_background = 1; +SELECT @@session.tokudb_analyze_in_background; + +SET SESSION tokudb_analyze_in_background = DEFAULT; +SELECT @@session.tokudb_analyze_in_background; + +SET SESSION tokudb_analyze_in_background = -6; +SELECT @@session.tokudb_analyze_in_background; + +-- error ER_WRONG_TYPE_FOR_VAR +SET SESSION tokudb_analyze_in_background = 1.6; +SELECT @@session.tokudb_analyze_in_background; + +-- error ER_WRONG_VALUE_FOR_VAR +SET SESSION tokudb_analyze_in_background = "T"; +SELECT @@session.tokudb_analyze_in_background; + +-- error ER_WRONG_VALUE_FOR_VAR +SET SESSION tokudb_analyze_in_background = "Y"; +SELECT @@session.tokudb_analyze_in_background; + +-- error ER_WRONG_VALUE_FOR_VAR +SET SESSION tokudb_analyze_in_background = 'foobar'; +SELECT @@session.tokudb_analyze_in_background; + +# both +SET GLOBAL tokudb_analyze_in_background = 0; +SET SESSION tokudb_analyze_in_background = 1; +SELECT @@global.tokudb_analyze_in_background; +SELECT @@session.tokudb_analyze_in_background; +SHOW VARIABLES LIKE 'tokudb_analyze_in_background'; + +# Clean up +SET SESSION tokudb_analyze_in_background = @orig_session; +SELECT @@session.tokudb_analyze_in_background; + +SET GLOBAL tokudb_analyze_in_background = @orig_global; +SELECT @@global.tokudb_analyze_in_background; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_mode_basic.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_mode_basic.test new file mode 100644 index 00000000000..69def75bd3d --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_mode_basic.test @@ -0,0 +1,72 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_analyze_mode; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_analyze_mode; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_standard'; +SELECT @@global.tokudb_analyze_mode; + +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_recount_rows'; +SELECT @@global.tokudb_analyze_mode; + +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_cancel'; +SELECT @@global.tokudb_analyze_mode; + +SET GLOBAL tokudb_analyze_mode = DEFAULT; +SELECT @@global.tokudb_analyze_mode; + +-- error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL tokudb_analyze_mode = ''; +SELECT @@global.tokudb_analyze_mode; + +-- error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL tokudb_analyze_mode = 'foobar'; +SELECT @@global.tokudb_analyze_mode; + +-- error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL tokudb_analyze_mode = 123; +SELECT @@global.tokudb_analyze_mode; + +# Test session +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_standard'; +SELECT @@session.tokudb_analyze_mode; + +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_recount_rows'; +SELECT @@session.tokudb_analyze_mode; + +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_cancel'; +SELECT @@session.tokudb_analyze_mode; + +SET SESSION tokudb_analyze_mode = DEFAULT; +SELECT @@session.tokudb_analyze_mode; + +-- error ER_WRONG_VALUE_FOR_VAR +SET SESSION tokudb_analyze_mode = ''; +SELECT @@session.tokudb_analyze_mode; + +-- error ER_WRONG_VALUE_FOR_VAR +SET SESSION tokudb_analyze_mode = 'foobar'; +SELECT @@session.tokudb_analyze_mode; + +-- error ER_WRONG_VALUE_FOR_VAR +SET SESSION tokudb_analyze_mode = 123; +SELECT @@session.tokudb_analyze_mode; + +# both +SET GLOBAL tokudb_analyze_mode = 'tokudb_analyze_standard'; +SET SESSION tokudb_analyze_mode = 'tokudb_analyze_recount_rows'; +SELECT @@global.tokudb_analyze_mode; +SELECT @@session.tokudb_analyze_mode; +SHOW VARIABLES LIKE 'tokudb_analyze_mode'; + +# Clean up +SET SESSION tokudb_analyze_mode = @orig_session; +SELECT @@session.tokudb_analyze_mode; + +SET GLOBAL tokudb_analyze_mode = @orig_global; +SELECT @@global.tokudb_analyze_mode; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_throttle_basic.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_throttle_basic.test new file mode 100644 index 00000000000..a3660b0626a --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_throttle_basic.test @@ -0,0 +1,50 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_analyze_throttle; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_analyze_throttle; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_analyze_throttle = 10; +SELECT @@global.tokudb_analyze_throttle; + +SET GLOBAL tokudb_analyze_throttle = 0; +SELECT @@global.tokudb_analyze_throttle; + +SET GLOBAL tokudb_analyze_throttle = DEFAULT; +SELECT @@global.tokudb_analyze_throttle; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_analyze_throttle = 'foobar'; +SELECT @@global.tokudb_analyze_throttle; + +# Test session +SET SESSION tokudb_analyze_throttle = 10; +SELECT @@session.tokudb_analyze_throttle; + +SET SESSION tokudb_analyze_throttle = 0; +SELECT @@session.tokudb_analyze_throttle; + +SET SESSION tokudb_analyze_throttle = DEFAULT; +SELECT @@session.tokudb_analyze_throttle; + +-- error ER_WRONG_TYPE_FOR_VAR +SET SESSION tokudb_analyze_throttle = 'foobar'; +SELECT @@session.tokudb_analyze_throttle; + +# both +SET GLOBAL tokudb_analyze_throttle = 12; +SET SESSION tokudb_analyze_throttle = 13; +SELECT @@global.tokudb_analyze_throttle; +SELECT @@session.tokudb_analyze_throttle; +SHOW VARIABLES LIKE 'tokudb_analyze_throttle'; + +# Clean up +SET SESSION tokudb_analyze_throttle = @orig_session; +SELECT @@session.tokudb_analyze_throttle; + +SET GLOBAL tokudb_analyze_throttle = @orig_global; +SELECT @@global.tokudb_analyze_throttle; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_time_basic.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_time_basic.test new file mode 100644 index 00000000000..3098934ee8c --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_analyze_time_basic.test @@ -0,0 +1,50 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_analyze_time; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_analyze_time; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_analyze_time = 10; +SELECT @@global.tokudb_analyze_time; + +SET GLOBAL tokudb_analyze_time = 0; +SELECT @@global.tokudb_analyze_time; + +SET GLOBAL tokudb_analyze_time = DEFAULT; +SELECT @@global.tokudb_analyze_time; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_analyze_time = 'foobar'; +SELECT @@global.tokudb_analyze_time; + +# Test session +SET SESSION tokudb_analyze_time = 10; +SELECT @@session.tokudb_analyze_time; + +SET SESSION tokudb_analyze_time = 0; +SELECT @@session.tokudb_analyze_time; + +SET SESSION tokudb_analyze_time = DEFAULT; +SELECT @@session.tokudb_analyze_time; + +-- error ER_WRONG_TYPE_FOR_VAR +SET SESSION tokudb_analyze_time = 'foobar'; +SELECT @@session.tokudb_analyze_time; + +# both +SET GLOBAL tokudb_analyze_time = 12; +SET SESSION tokudb_analyze_time = 13; +SELECT @@global.tokudb_analyze_time; +SELECT @@session.tokudb_analyze_time; +SHOW VARIABLES LIKE 'tokudb_analyze_time'; + +# Clean up +SET SESSION tokudb_analyze_time = @orig_session; +SELECT @@session.tokudb_analyze_time; + +SET GLOBAL tokudb_analyze_time = @orig_global; +SELECT @@global.tokudb_analyze_time; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_auto_analyze.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_auto_analyze.test new file mode 100644 index 00000000000..d9998508ae1 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_auto_analyze.test @@ -0,0 +1,50 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_auto_analyze; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_auto_analyze; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_auto_analyze = 10; +SELECT @@global.tokudb_auto_analyze; + +SET GLOBAL tokudb_auto_analyze = 0; +SELECT @@global.tokudb_auto_analyze; + +SET GLOBAL tokudb_auto_analyze = DEFAULT; +SELECT @@global.tokudb_auto_analyze; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_auto_analyze = 'foobar'; +SELECT @@global.tokudb_auto_analyze; + +# Test session +SET SESSION tokudb_auto_analyze = 10; +SELECT @@session.tokudb_auto_analyze; + +SET SESSION tokudb_auto_analyze = 0; +SELECT @@session.tokudb_auto_analyze; + +SET SESSION tokudb_auto_analyze = DEFAULT; +SELECT @@session.tokudb_auto_analyze; + +-- error ER_WRONG_TYPE_FOR_VAR +SET SESSION tokudb_auto_analyze = 'foobar'; +SELECT @@session.tokudb_auto_analyze; + +# both +SET GLOBAL tokudb_auto_analyze = 12; +SET SESSION tokudb_auto_analyze = 13; +SELECT @@global.tokudb_auto_analyze; +SELECT @@session.tokudb_auto_analyze; +SHOW VARIABLES LIKE 'tokudb_auto_analyze'; + +# Clean up +SET SESSION tokudb_auto_analyze = @orig_session; +SELECT @@session.tokudb_auto_analyze; + +SET GLOBAL tokudb_auto_analyze = @orig_global; +SELECT @@global.tokudb_auto_analyze; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_cardinality_scale_percent_basic.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_cardinality_scale_percent_basic.test new file mode 100644 index 00000000000..83063f04248 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_cardinality_scale_percent_basic.test @@ -0,0 +1,32 @@ +--source include/have_tokudb.inc + +# Check the default value +SET @orig_global = @@global.tokudb_cardinality_scale_percent; +SELECT @orig_global; + +# Test global +SET GLOBAL tokudb_cardinality_scale_percent = 10; +SELECT @@global.tokudb_cardinality_scale_percent; + +SET GLOBAL tokudb_cardinality_scale_percent = 0; +SELECT @@global.tokudb_cardinality_scale_percent; + +SET GLOBAL tokudb_cardinality_scale_percent = DEFAULT; +SELECT @@global.tokudb_cardinality_scale_percent; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_cardinality_scale_percent = 'foobar'; +SELECT @@global.tokudb_cardinality_scale_percent; + +# both +SET GLOBAL tokudb_cardinality_scale_percent = 12; +-- error ER_GLOBAL_VARIABLE +SET SESSION tokudb_cardinality_scale_percent = 13; +SELECT @@global.tokudb_cardinality_scale_percent; +-- error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.tokudb_cardinality_scale_percent; +SHOW VARIABLES LIKE 'tokudb_cardinality_scale_percent'; + +# Clean up +SET GLOBAL tokudb_cardinality_scale_percent = @orig_global; +SELECT @@global.tokudb_cardinality_scale_percent; diff --git a/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_pk_insert_mode_basic.test b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_pk_insert_mode_basic.test new file mode 100644 index 00000000000..1669c7842a9 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_sys_vars/t/tokudb_pk_insert_mode_basic.test @@ -0,0 +1,51 @@ +--source include/have_tokudb.inc +--enable_warnings + +# Check the default value +SET @orig_global = @@global.tokudb_pk_insert_mode; +SELECT @orig_global; + +SET @orig_session = @@session.tokudb_pk_insert_mode; +SELECT @orig_session; + +# Test global +SET GLOBAL tokudb_pk_insert_mode = 10; +SELECT @@global.tokudb_pk_insert_mode; + +SET GLOBAL tokudb_pk_insert_mode = 0; +SELECT @@global.tokudb_pk_insert_mode; + +SET GLOBAL tokudb_pk_insert_mode = DEFAULT; +SELECT @@global.tokudb_pk_insert_mode; + +-- error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL tokudb_pk_insert_mode = 'foobar'; +SELECT @@global.tokudb_pk_insert_mode; + +# Test session +SET SESSION tokudb_pk_insert_mode = 10; +SELECT @@session.tokudb_pk_insert_mode; + +SET SESSION tokudb_pk_insert_mode = 0; +SELECT @@session.tokudb_pk_insert_mode; + +SET SESSION tokudb_pk_insert_mode = DEFAULT; +SELECT @@session.tokudb_pk_insert_mode; + +-- error ER_WRONG_TYPE_FOR_VAR +SET SESSION tokudb_pk_insert_mode = 'foobar'; +SELECT @@session.tokudb_pk_insert_mode; + +# both +SET GLOBAL tokudb_pk_insert_mode = 12; +SET SESSION tokudb_pk_insert_mode = 13; +SELECT @@global.tokudb_pk_insert_mode; +SELECT @@session.tokudb_pk_insert_mode; +SHOW VARIABLES LIKE 'tokudb_pk_insert_mode'; + +# Clean up +SET SESSION tokudb_pk_insert_mode = @orig_session; +SELECT @@session.tokudb_pk_insert_mode; + +SET GLOBAL tokudb_pk_insert_mode = @orig_global; +SELECT @@global.tokudb_pk_insert_mode; diff --git a/storage/tokudb/tokudb_background.cc b/storage/tokudb/tokudb_background.cc new file mode 100644 index 00000000000..d8ef54a5972 --- /dev/null +++ b/storage/tokudb/tokudb_background.cc @@ -0,0 +1,253 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "tokudb_background.h" +#include "tokudb_sysvars.h" + +namespace tokudb { +namespace background { + + +std::atomic job_manager_t::job_t::_next_id(1); + +job_manager_t::job_t::job_t(bool user_scheduled) : + _running(false), + _cancelled(false), + _id(_next_id++), + _user_scheduled(user_scheduled), + _scheduled_time(::time(0)), + _started_time(0) { +} +job_manager_t::job_t::~job_t() { +} +void* job_manager_t::operator new(size_t sz) { + return tokudb::memory::malloc(sz, MYF(MY_WME|MY_ZEROFILL|MY_FAE)); +} +void job_manager_t::operator delete(void* p) { + tokudb::memory::free(p); +} +job_manager_t::job_manager_t() : + _sem(0, 65535), + _shutdown(false) { +} +job_manager_t::~job_manager_t() { +} +void job_manager_t::initialize() { + int r = _thread.start(thread_func, this); + assert_always(r == 0); +} +void job_manager_t::destroy() { + assert_always(!_shutdown); + assert_always(_foreground_jobs.size() == 0); + _shutdown = true; + _sem.set_interrupt(); + + while (_background_jobs.size()) { + _mutex.lock(); + job_t* job = _background_jobs.front(); + cancel(job); + _background_jobs.pop_front(); + delete job; + _mutex.unlock(); + } + + void* result; + int r = _thread.join(&result); + assert_always(r == 0); +} +bool job_manager_t::run_job(job_t* newjob, bool background) { + bool ret = false; + const char* jobkey = newjob->key(); + + _mutex.lock(); + assert_always(!_shutdown); + + for (jobs_t::iterator it = _background_jobs.begin(); + it != _background_jobs.end(); + it++) { + job_t* job = *it; + if (!job->cancelled() && strcmp(job->key(), jobkey) == 0) { + // if this is a foreground job being run and + // there is an existing background job of the same type + // and it is not running yet, we can cancel the background job + // and just run this one in the foreground, might have different + // params, but that is up to the user to figure out. + if (!background && !job->running()) { + job->cancel(); + } else { + // can't schedule or run another job on the same key + goto cleanup; + } + } + } + for (jobs_t::iterator it = _foreground_jobs.begin(); + it != _foreground_jobs.end(); + it++) { + job_t* job = *it; + if (strcmp(job->key(), jobkey) == 0) { + // can't schedule or run another job on the same key + // as an existing foreground job + goto cleanup; + } + } + + if (background) { + _background_jobs.push_back(newjob); + _sem.signal(); + ret = true; + } else { + _foreground_jobs.push_back(newjob); + + run(newjob); + + for (jobs_t::iterator it = _foreground_jobs.begin(); + it != _foreground_jobs.end(); + it++) { + job_t* job = *it; + if (job == newjob) { + _foreground_jobs.erase(it); + delete job; + break; + } + } + ret = true; + } + +cleanup: + _mutex.unlock(); + return ret; +} +bool job_manager_t::cancel_job(const char* key) { + bool ret = false; + _mutex.lock(); + + for (jobs_t::iterator it = _background_jobs.begin(); + it != _background_jobs.end(); it++) { + job_t* job = *it; + + if (!job->cancelled() && + strcmp(job->key(), key) == 0) { + + cancel(job); + + ret = true; + } + } + + _mutex.unlock(); + return ret; +} +void job_manager_t::iterate_jobs(pfn_iterate_t callback, void* extra) const { + + char database[256], table[256], type[256], params[256], status[256]; + + _mutex.lock(); + + for (jobs_t::const_iterator it = _background_jobs.begin(); + it != _background_jobs.end(); + it++) { + job_t* job = *it; + if (!job->cancelled()) { + database[0] = table[0] = type[0] = params[0] = status[0] = '\0'; + job->status(database, table, type, params, status); + callback( + job->id(), + database, + table, + type, + params, + status, + job->user_scheduled(), + job->scheduled_time(), + job->started_time(), + extra); + } + } + + _mutex.unlock(); +} +void* job_manager_t::thread_func(void* v) { + return ((tokudb::background::job_manager_t*)v)->real_thread_func(); +} +void* job_manager_t::real_thread_func() { + while (_shutdown == false) { + tokudb::thread::semaphore_t::E_WAIT res = _sem.wait(); + if (res == tokudb::thread::semaphore_t::E_INTERRUPTED || _shutdown) { + break; + } else if (res == tokudb::thread::semaphore_t::E_SIGNALLED) { +#if TOKUDB_DEBUG + if (TOKUDB_UNLIKELY( + tokudb::sysvars::debug_pause_background_job_manager)) { + _sem.signal(); + tokudb::time::sleep_microsec(250000); + continue; + } +#endif // TOKUDB_DEBUG + + _mutex.lock(); + assert_debug(_background_jobs.size() > 0); + job_t* job = _background_jobs.front(); + run(job); + _background_jobs.pop_front(); + _mutex.unlock(); + delete job; + } + } + return NULL; +} +void job_manager_t::run(job_t* job) { + assert_debug(_mutex.is_owned_by_me()); + if (!job->cancelled()) { + _mutex.unlock(); + // do job + job->run(); + // done job + _mutex.lock(); + } + if (!job->cancelled()) { + job->destroy(); + } +} +void job_manager_t::cancel(job_t* job) { + assert_debug(_mutex.is_owned_by_me()); + job->cancel(); +} +job_manager_t* _job_manager = NULL; + +bool initialize() { + assert_always(_job_manager == NULL); + _job_manager = new job_manager_t; + _job_manager->initialize(); + return true; +} +bool destroy() { + _job_manager->destroy(); + delete _job_manager; + _job_manager = NULL; + return true; +} +} // namespace background +} // namespace tokudb diff --git a/storage/tokudb/tokudb_background.h b/storage/tokudb/tokudb_background.h new file mode 100644 index 00000000000..3786701fd0f --- /dev/null +++ b/storage/tokudb/tokudb_background.h @@ -0,0 +1,212 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_BACKGROUND_H +#define _TOKUDB_BACKGROUND_H + +#include "hatoku_hton.h" +#include +#include + +namespace tokudb { +namespace background { + +class job_manager_t { +public: + class job_t { + public: + // NO default constructor + job_t() = delete; + + job_t(bool user_scheduled); + + virtual ~job_t(); + + // method that runs the job + inline void run(); + + // method that tells the job to cancel ASAP + inline void cancel(); + + // method that tells the job to clean up/free resources on cancel + // or completion + inline void destroy(); + + // method that returns a 'key' string for finding a specific job + // (or jobs) usually used to find jobs to cancel + virtual const char* key() = 0; + + // method to get info for information schema, 255 chars per buffer + virtual void status( + char* database, + char* table, + char* type, + char* params, + char* status) = 0; + + inline bool running() const; + + inline bool cancelled() const; + + inline uint64_t id() const; + + inline bool user_scheduled() const; + + inline time_t scheduled_time() const; + + inline time_t started_time() const; + + protected: + // derived classed implement this to actually run their job + virtual void on_run() {}; + + // derived classes implement this to cancel their job + virtual void on_cancel() {}; + + // derived classes implement this to clean up/free resources + virtual void on_destroy() {}; + + private: + static std::atomic _next_id; + std::atomic _running; + std::atomic _cancelled; + uint64_t _id; + bool _user_scheduled; + time_t _scheduled_time; + time_t _started_time; + }; + + // pfn for iterate callback + typedef void (*pfn_iterate_t)( + uint64_t, + const char*, + const char*, + const char*, + const char*, + const char*, + bool, + time_t, + time_t, + void*); + +public: + void* operator new(size_t sz); + void operator delete(void* p); + + job_manager_t(); + + ~job_manager_t(); + + // creates/initializes a singleton bjm + void initialize(); + + // destroys a bjm singleton + // cancels all jobs abd frees all resources + void destroy(); + + // schedules or runs a job depending on the 'background' value + // job specifics all depend on the implementation od 'job' + // background jobs will be executed in a FIFO fashion + // two jobs with the same key can not run concurrently + // if a foreground job is attempted, any currently scheduled or running + // background jobs will be cancelled first + // if another foreground job is already running, a new foreground job with + // the same key will be rejected + bool run_job(job_t* newjob, bool background); + + // cancels any background job with a matching key + bool cancel_job(const char* key); + + // iterates currently pending and running background jobs, calling + // 'callback' with the 'extra' data provided and the original 'extra' + // data passed when the job was scheduled + void iterate_jobs(pfn_iterate_t callback, void* extra) const; + +private: + static void* thread_func(void* v); + + void* real_thread_func(); + + // _mutex MUST be held on entry, will release and reaquire on exit + void run(job_t* job); + + // _mutex MUST be held on entry + void cancel(job_t* job); +private: + typedef std::list jobs_t; + + mutable tokudb::thread::mutex_t _mutex; + mutable tokudb::thread::semaphore_t _sem; + mutable tokudb::thread::thread_t _thread; + jobs_t _background_jobs; + jobs_t _foreground_jobs; + std::atomic _shutdown; +}; + +extern job_manager_t* _job_manager; + +bool initialize(); +bool destroy(); + +inline void job_manager_t::job_t::run() { + if (!_cancelled) { + _running = true; + _started_time = ::time(0); + on_run(); + _running = false; + } +} +inline void job_manager_t::job_t::cancel() { + _cancelled = true; + if (_running) + on_cancel(); + while (_running) tokudb::time::sleep_microsec(500000); + destroy(); +} +void job_manager_t::job_t::destroy() { + on_destroy(); +} +inline bool job_manager_t::job_t::running() const { + return _running; +} +inline bool job_manager_t::job_t::cancelled() const { + return _cancelled; +} +inline uint64_t job_manager_t::job_t::id() const { + return _id; +} +inline bool job_manager_t::job_t::user_scheduled() const { + return _user_scheduled; +} +inline time_t job_manager_t::job_t::scheduled_time() const { + return _scheduled_time; +} +inline time_t job_manager_t::job_t::started_time() const { + return _started_time; +} +} // namespace background +} // namespace tokudb + +#endif // _TOKUDB_BACKGROUND_H diff --git a/storage/tokudb/tokudb_buffer.h b/storage/tokudb/tokudb_buffer.h index 1604ea61e2d..022f1b49643 100644 --- a/storage/tokudb/tokudb_buffer.h +++ b/storage/tokudb/tokudb_buffer.h @@ -23,38 +23,54 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." -#if !defined(_TOKUDB_BUFFER_H) +#ifndef _TOKUDB_BUFFER_H #define _TOKUDB_BUFFER_H +#include "hatoku_defines.h" +#include "tokudb_debug.h" +#include "tokudb_thread.h" #include "tokudb_vlq.h" namespace tokudb { -// A Buffer manages a contiguous chunk of memory and supports appending new data to the end of the buffer, and -// consuming chunks from the beginning of the buffer. The buffer will reallocate memory when appending -// new data to a full buffer. +// A Buffer manages a contiguous chunk of memory and supports appending new +// data to the end of the buffer, and consuming chunks from the beginning of +// the buffer. The buffer will reallocate memory when appending new data to +// a full buffer. class buffer { public: - buffer(void *the_data, size_t s, size_t l) : m_data(the_data), m_size(s), m_limit(l), m_is_static(true) { + inline buffer( + void* the_data, + size_t s, + size_t l) : + m_data(the_data), + m_size(s), + m_limit(l), + m_is_static(true) { } - buffer() : m_data(NULL), m_size(0), m_limit(0), m_is_static(false) { + inline buffer() : + m_data(NULL), + m_size(0), + m_limit(0), + m_is_static(false) { } virtual ~buffer() { if (!m_is_static) free(m_data); } - // Return a pointer to the end of the buffer suitable for appending a fixed number of bytes. - void *append_ptr(size_t s) { + // Return a pointer to the end of the buffer suitable for appending a + // fixed number of bytes. + void* append_ptr(size_t s) { maybe_realloc(s); - void *p = (char *) m_data + m_size; + void* p = (char*)m_data + m_size; m_size += s; return p; } // Append bytes to the buffer - void append(void *p, size_t s) { + void append(void* p, size_t s) { memcpy(append_ptr(s), p, s); } @@ -68,63 +84,70 @@ public: return s; } - // Return a pointer to the next location in the buffer where bytes are consumed from. - void *consume_ptr(size_t s) { + // Return a pointer to the next location in the buffer where bytes are + // consumed from. + void* consume_ptr(size_t s) { if (m_size + s > m_limit) return NULL; - void *p = (char *) m_data + m_size; + void* p = (char*)m_data + m_size; m_size += s; return p; } // Consume bytes from the buffer. - void consume(void *p, size_t s) { + void consume(void* p, size_t s) { memcpy(p, consume_ptr(s), s); } // Consume an unsigned int from the buffer. - // Returns 0 if the unsigned int could not be decoded, probably because the buffer is too short. - // Otherwise return the number of bytes consumed, and stuffs the decoded number in *p. - template size_t consume_ui(T *p) { - size_t s = tokudb::vlq_decode_ui(p, (char *) m_data + m_size, m_limit - m_size); + // Returns 0 if the unsigned int could not be decoded, probably because + // the buffer is too short. + // Otherwise return the number of bytes consumed, and stuffs the decoded + // number in *p. + template size_t consume_ui(T* p) { + size_t s = tokudb::vlq_decode_ui( + p, + (char*)m_data + m_size, + m_limit - m_size); m_size += s; return s; } // Write p_length bytes at an offset in the buffer - void write(void *p, size_t p_length, size_t offset) { - assert(offset + p_length <= m_size); - memcpy((char *)m_data + offset, p, p_length); + void write(void* p, size_t p_length, size_t offset) { + assert_always(offset + p_length <= m_size); + memcpy((char*)m_data + offset, p, p_length); } // Read p_length bytes at an offset in the buffer - void read(void *p, size_t p_length, size_t offset) { - assert(offset + p_length <= m_size); - memcpy(p, (char *)m_data + offset, p_length); + void read(void* p, size_t p_length, size_t offset) { + assert_always(offset + p_length <= m_size); + memcpy(p, (char*)m_data + offset, p_length); } - // Replace a field in the buffer with new data. If the new data size is different, then readjust the - // size of the buffer and move things around. - void replace(size_t offset, size_t old_s, void *new_p, size_t new_s) { - assert(offset + old_s <= m_size); + // Replace a field in the buffer with new data. If the new data size is + // different, then readjust the size of the buffer and move things around. + void replace(size_t offset, size_t old_s, void* new_p, size_t new_s) { + assert_always(offset + old_s <= m_size); if (new_s > old_s) maybe_realloc(new_s - old_s); - char *data_offset = (char *) m_data + offset; + char* data_offset = (char*)m_data + offset; if (new_s != old_s) { size_t n = m_size - (offset + old_s); - assert(offset + new_s + n <= m_limit && offset + old_s + n <= m_limit); + assert_always( + offset + new_s + n <= m_limit && offset + old_s + n <= m_limit); memmove(data_offset + new_s, data_offset + old_s, n); if (new_s > old_s) m_size += new_s - old_s; else m_size -= old_s - new_s; - assert(m_size <= m_limit); + assert_always(m_size <= m_limit); } memcpy(data_offset, new_p, new_s); } // Return a pointer to the data in the buffer - void *data() const { + void* data() const { return m_data; } @@ -145,15 +168,15 @@ private: size_t new_limit = m_limit * 2; if (new_limit < m_size + s) new_limit = m_size + s; - assert(!m_is_static); + assert_always(!m_is_static); void *new_data = realloc(m_data, new_limit); - assert(new_data != NULL); + assert_always(new_data != NULL); m_data = new_data; m_limit = new_limit; } } private: - void *m_data; + void* m_data; size_t m_size; size_t m_limit; bool m_is_static; diff --git a/storage/tokudb/tokudb_card.h b/storage/tokudb/tokudb_card.h index 04eac731aeb..f649c2d887f 100644 --- a/storage/tokudb/tokudb_card.h +++ b/storage/tokudb/tokudb_card.h @@ -27,48 +27,54 @@ namespace tokudb { uint compute_total_key_parts(TABLE_SHARE *table_share) { uint total_key_parts = 0; for (uint i = 0; i < table_share->keys; i++) { - total_key_parts += get_key_parts(&table_share->key_info[i]); + total_key_parts += table_share->key_info[i].user_defined_key_parts; } return total_key_parts; } - // Set the key_info cardinality counters for the table. - void set_card_in_key_info(TABLE *table, uint rec_per_keys, uint64_t rec_per_key[]) { - uint next_key_part = 0; - for (uint i = 0; i < table->s->keys; i++) { - bool is_unique_key = (i == table->s->primary_key) || (table->key_info[i].flags & HA_NOSAME); - uint num_key_parts = get_key_parts(&table->key_info[i]); - for (uint j = 0; j < num_key_parts; j++) { - assert(next_key_part < rec_per_keys); - ulong val = rec_per_key[next_key_part++]; - if (is_unique_key && j == num_key_parts-1) - val = 1; - table->key_info[i].rec_per_key[j] = val; - } - } - } - // Put the cardinality counters into the status dictionary. - int set_card_in_status(DB *status_db, DB_TXN *txn, uint rec_per_keys, uint64_t rec_per_key[]) { + int set_card_in_status( + DB* status_db, + DB_TXN* txn, + uint rec_per_keys, + const uint64_t rec_per_key[]) { + // encode cardinality into the buffer tokudb::buffer b; size_t s; s = b.append_ui(rec_per_keys); - assert(s > 0); + assert_always(s > 0); for (uint i = 0; i < rec_per_keys; i++) { s = b.append_ui(rec_per_key[i]); - assert(s > 0); + assert_always(s > 0); } // write cardinality to status - int error = write_to_status(status_db, hatoku_cardinality, b.data(), b.size(), txn); + int error = + tokudb::metadata::write( + status_db, + hatoku_cardinality, + b.data(), + b.size(), + txn); return error; } // Get the cardinality counters from the status dictionary. - int get_card_from_status(DB *status_db, DB_TXN *txn, uint rec_per_keys, uint64_t rec_per_key[]) { + int get_card_from_status( + DB* status_db, + DB_TXN* txn, + uint rec_per_keys, + uint64_t rec_per_key[]) { + // read cardinality from status - void *buf = 0; size_t buf_size = 0; - int error = get_status_realloc(status_db, txn, hatoku_cardinality, &buf, &buf_size); + void* buf = 0; size_t buf_size = 0; + int error = + tokudb::metadata::read_realloc( + status_db, + txn, + hatoku_cardinality, + &buf, + &buf_size); if (error == 0) { // decode cardinality from the buffer tokudb::buffer b(buf, 0, buf_size); @@ -93,12 +99,17 @@ namespace tokudb { } // Delete the cardinality counters from the status dictionary. - int delete_card_from_status(DB *status_db, DB_TXN *txn) { - int error = remove_from_status(status_db, hatoku_cardinality, txn); + int delete_card_from_status(DB* status_db, DB_TXN* txn) { + int error = + tokudb::metadata::remove(status_db, hatoku_cardinality, txn); return error; } - bool find_index_of_key(const char *key_name, TABLE_SHARE *table_share, uint *index_offset_ptr) { + bool find_index_of_key( + const char* key_name, + TABLE_SHARE* table_share, + uint* index_offset_ptr) { + for (uint i = 0; i < table_share->keys; i++) { if (strcmp(key_name, table_share->key_info[i].name) == 0) { *index_offset_ptr = i; @@ -113,16 +124,30 @@ namespace tokudb { dest[i] = src[i]; } - // Altered table cardinality = select cardinality data from current table cardinality for keys that exist + // Altered table cardinality = select cardinality data from current table + // cardinality for keys that exist // in the altered table and the current table. - int alter_card(DB *status_db, DB_TXN *txn, TABLE_SHARE *table_share, TABLE_SHARE *altered_table_share) { + int alter_card( + DB* status_db, + DB_TXN *txn, + TABLE_SHARE* table_share, + TABLE_SHARE* altered_table_share) { + int error; // read existing cardinality data from status - uint table_total_key_parts = tokudb::compute_total_key_parts(table_share); + uint table_total_key_parts = + tokudb::compute_total_key_parts(table_share); + uint64_t rec_per_key[table_total_key_parts]; - error = get_card_from_status(status_db, txn, table_total_key_parts, rec_per_key); + error = + get_card_from_status( + status_db, + txn, + table_total_key_parts, + rec_per_key); // set altered records per key to unknown - uint altered_table_total_key_parts = tokudb::compute_total_key_parts(altered_table_share); + uint altered_table_total_key_parts = + tokudb::compute_total_key_parts(altered_table_share); uint64_t altered_rec_per_key[altered_table_total_key_parts]; for (uint i = 0; i < altered_table_total_key_parts; i++) altered_rec_per_key[i] = 0; @@ -131,121 +156,37 @@ namespace tokudb { uint orig_key_parts = 0; for (uint i = 0; i < table_share->keys; i++) { orig_key_offset[i] = orig_key_parts; - orig_key_parts += get_key_parts(&table_share->key_info[i]); + orig_key_parts += table_share->key_info[i].user_defined_key_parts; } // if orig card data exists, then use it to compute new card data if (error == 0) { uint next_key_parts = 0; for (uint i = 0; error == 0 && i < altered_table_share->keys; i++) { - uint ith_key_parts = get_key_parts(&altered_table_share->key_info[i]); + uint ith_key_parts = + altered_table_share->key_info[i].user_defined_key_parts; uint orig_key_index; - if (find_index_of_key(altered_table_share->key_info[i].name, table_share, &orig_key_index)) { - copy_card(&altered_rec_per_key[next_key_parts], &rec_per_key[orig_key_offset[orig_key_index]], ith_key_parts); + if (find_index_of_key( + altered_table_share->key_info[i].name, + table_share, + &orig_key_index)) { + copy_card( + &altered_rec_per_key[next_key_parts], + &rec_per_key[orig_key_offset[orig_key_index]], + ith_key_parts); } next_key_parts += ith_key_parts; } } - if (error == 0) - error = set_card_in_status(status_db, txn, altered_table_total_key_parts, altered_rec_per_key); - else - error = delete_card_from_status(status_db, txn); - return error; - } - - struct analyze_card_cursor_callback_extra { - int (*analyze_progress)(void *extra, uint64_t rows); - void *analyze_extra; - uint64_t *rows; - uint64_t *deleted_rows; - }; - - bool analyze_card_cursor_callback(void *extra, uint64_t deleted_rows) { - analyze_card_cursor_callback_extra *a_extra = static_cast(extra); - *a_extra->deleted_rows += deleted_rows; - int r = a_extra->analyze_progress(a_extra->analyze_extra, *a_extra->rows); - sql_print_information("tokudb analyze_card_cursor_callback %u %" PRIu64 " %" PRIu64, r, *a_extra->deleted_rows, deleted_rows); - return r != 0; - } - - // Compute records per key for all key parts of the ith key of the table. - // For each key part, put records per key part in *rec_per_key_part[key_part_index]. - // Returns 0 if success, otherwise an error number. - // TODO statistical dives into the FT - int analyze_card(DB *db, DB_TXN *txn, bool is_unique, uint64_t num_key_parts, uint64_t *rec_per_key_part, - int (*key_compare)(DB *, const DBT *, const DBT *, uint), - int (*analyze_progress)(void *extra, uint64_t rows), void *progress_extra, - uint64_t *return_rows, uint64_t *return_deleted_rows) { - int error = 0; - uint64_t rows = 0; - uint64_t deleted_rows = 0; - uint64_t unique_rows[num_key_parts]; - if (is_unique && num_key_parts == 1) { - // dont compute for unique keys with a single part. we already know the answer. - rows = unique_rows[0] = 1; + if (error == 0) { + error = + set_card_in_status( + status_db, + txn, + altered_table_total_key_parts, + altered_rec_per_key); } else { - DBC *cursor = NULL; - error = db->cursor(db, txn, &cursor, 0); - if (error == 0) { - analyze_card_cursor_callback_extra e = { analyze_progress, progress_extra, &rows, &deleted_rows }; - cursor->c_set_check_interrupt_callback(cursor, analyze_card_cursor_callback, &e); - for (uint64_t i = 0; i < num_key_parts; i++) - unique_rows[i] = 1; - // stop looking when the entire dictionary was analyzed, or a cap on execution time was reached, or the analyze was killed. - DBT key = {}; key.flags = DB_DBT_REALLOC; - DBT prev_key = {}; prev_key.flags = DB_DBT_REALLOC; - while (1) { - error = cursor->c_get(cursor, &key, 0, DB_NEXT); - if (error != 0) { - if (error == DB_NOTFOUND || error == TOKUDB_INTERRUPTED) - error = 0; // not an error - break; - } - rows++; - // first row is a unique row, otherwise compare with the previous key - bool copy_key = false; - if (rows == 1) { - copy_key = true; - } else { - // compare this key with the previous key. ignore appended PK for SK's. - // TODO if a prefix is different, then all larger keys that include the prefix are also different. - // TODO if we are comparing the entire primary key or the entire unique secondary key, then the cardinality must be 1, - // so we can avoid computing it. - for (uint64_t i = 0; i < num_key_parts; i++) { - int cmp = key_compare(db, &prev_key, &key, i+1); - if (cmp != 0) { - unique_rows[i]++; - copy_key = true; - } - } - } - // prev_key = key - if (copy_key) { - prev_key.data = realloc(prev_key.data, key.size); - assert(prev_key.data); - prev_key.size = key.size; - memcpy(prev_key.data, key.data, prev_key.size); - } - // check for limit - if (analyze_progress && (rows % 1000) == 0) { - error = analyze_progress(progress_extra, rows); - if (error) - break; - } - } - // cleanup - free(key.data); - free(prev_key.data); - int close_error = cursor->c_close(cursor); - assert(close_error == 0); - } + error = delete_card_from_status(status_db, txn); } - // return cardinality - if (return_rows) - *return_rows = rows; - if (return_deleted_rows) - *return_deleted_rows = deleted_rows; - for (uint64_t i = 0; i < num_key_parts; i++) - rec_per_key_part[i] = rows / unique_rows[i]; return error; } } diff --git a/storage/tokudb/tokudb_debug.h b/storage/tokudb/tokudb_debug.h new file mode 100644 index 00000000000..46bd65c605a --- /dev/null +++ b/storage/tokudb/tokudb_debug.h @@ -0,0 +1,227 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_DEBUG_H +#define _TOKUDB_DEBUG_H + +#include "hatoku_defines.h" + +#define TOKU_INCLUDE_BACKTRACE 0 +#if TOKU_INCLUDE_BACKTRACE +static void tokudb_backtrace(void); +#endif + +// tokudb debug tracing for tokudb_debug declared in tokudb_sysvars.h/.cc +#define TOKUDB_DEBUG_INIT (1<<0) +#define TOKUDB_DEBUG_OPEN (1<<1) +#define TOKUDB_DEBUG_ENTER (1<<2) +#define TOKUDB_DEBUG_RETURN (1<<3) +#define TOKUDB_DEBUG_ERROR (1<<4) +#define TOKUDB_DEBUG_TXN (1<<5) +#define TOKUDB_DEBUG_AUTO_INCREMENT (1<<6) +#define TOKUDB_DEBUG_INDEX_KEY (1<<7) +#define TOKUDB_DEBUG_LOCK (1<<8) +#define TOKUDB_DEBUG_CHECK_KEY (1<<9) +#define TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS (1<<10) +#define TOKUDB_DEBUG_ALTER_TABLE (1<<11) +#define TOKUDB_DEBUG_UPSERT (1<<12) +#define TOKUDB_DEBUG_CHECK (1<<13) +#define TOKUDB_DEBUG_ANALYZE (1<<14) +#define TOKUDB_DEBUG_XA (1<<15) +#define TOKUDB_DEBUG_SHARE (1<<16) + +#define TOKUDB_TRACE(_fmt, ...) { \ + fprintf(stderr, "%u %s:%u %s " _fmt "\n", tokudb::thread::my_tid(), \ + __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ +} + +#define TOKUDB_DEBUG_FLAGS(_flags) \ + (tokudb::sysvars::debug & _flags) + +#define TOKUDB_TRACE_FOR_FLAGS(_flags, _fmt, ...) { \ + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(_flags))) { \ + TOKUDB_TRACE(_fmt, ##__VA_ARGS__); \ + } \ +} + +#define TOKUDB_DBUG_ENTER(_fmt, ...) { \ + if (TOKUDB_UNLIKELY(tokudb::sysvars::debug & TOKUDB_DEBUG_ENTER)) { \ + TOKUDB_TRACE(_fmt, ##__VA_ARGS__); \ + } \ +} \ + DBUG_ENTER(__FUNCTION__); + +#define TOKUDB_DBUG_RETURN(r) { \ + int rr = (r); \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN) || \ + (rr != 0 && (tokudb::sysvars::debug & TOKUDB_DEBUG_ERROR)))) { \ + TOKUDB_TRACE("return %d", rr); \ + } \ + DBUG_RETURN(rr); \ +} + +#define TOKUDB_HANDLER_TRACE(_fmt, ...) \ + fprintf(stderr, "%u %p %s:%u ha_tokudb::%s " _fmt "\n", \ + tokudb::thread::my_tid(), this, __FILE__, __LINE__, \ + __FUNCTION__, ##__VA_ARGS__); + +#define TOKUDB_HANDLER_TRACE_FOR_FLAGS(_flags, _fmt, ...) { \ + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(_flags))) { \ + TOKUDB_HANDLER_TRACE(_fmt, ##__VA_ARGS__); \ + } \ +} + + +#define TOKUDB_HANDLER_DBUG_ENTER(_fmt, ...) { \ + if (TOKUDB_UNLIKELY(tokudb::sysvars::debug & TOKUDB_DEBUG_ENTER)) { \ + TOKUDB_HANDLER_TRACE(_fmt, ##__VA_ARGS__); \ + } \ +} \ + DBUG_ENTER(__FUNCTION__); + +#define TOKUDB_HANDLER_DBUG_RETURN(r) { \ + int rr = (r); \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN) || \ + (rr != 0 && (tokudb::sysvars::debug & TOKUDB_DEBUG_ERROR)))) { \ + TOKUDB_HANDLER_TRACE("return %d", rr); \ + } \ + DBUG_RETURN(rr); \ +} + +#define TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(r) { \ + double rr = (r); \ + if (TOKUDB_UNLIKELY(tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN)) { \ + TOKUDB_HANDLER_TRACE("return %f", rr); \ + } \ + DBUG_RETURN(rr); \ +} + +#define TOKUDB_HANDLER_DBUG_RETURN_PTR(r) { \ + if (TOKUDB_UNLIKELY(tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN)) { \ + TOKUDB_HANDLER_TRACE("return 0x%p", r); \ + } \ + DBUG_RETURN(r); \ +} + +#define TOKUDB_HANDLER_DBUG_VOID_RETURN { \ + if (TOKUDB_UNLIKELY(tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN)) { \ + TOKUDB_HANDLER_TRACE("return"); \ + } \ + DBUG_VOID_RETURN; \ +} + +#define TOKUDB_SHARE_TRACE(_fmt, ...) \ + fprintf(stderr, "%u %p %s:%u TOUDB_SHARE::%s " _fmt "\n", \ + tokudb::thread::my_tid(), this, __FILE__, __LINE__, \ + __FUNCTION__, ##__VA_ARGS__); + +#define TOKUDB_SHARE_TRACE_FOR_FLAGS(_flags, _fmt, ...) { \ + if (TOKUDB_UNLIKELY(TOKUDB_DEBUG_FLAGS(_flags))) { \ + TOKUDB_SHARE_TRACE(_fmt, ##__VA_ARGS__); \ + } \ +} + +#define TOKUDB_SHARE_DBUG_ENTER(_fmt, ...) { \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_ENTER) || \ + (tokudb::sysvars::debug & TOKUDB_DEBUG_SHARE))) { \ + TOKUDB_SHARE_TRACE(_fmt, ##__VA_ARGS__); \ + } \ +} \ + DBUG_ENTER(__FUNCTION__); + +#define TOKUDB_SHARE_DBUG_RETURN(r) { \ + int rr = (r); \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN) || \ + (tokudb::sysvars::debug & TOKUDB_DEBUG_SHARE) || \ + (rr != 0 && (tokudb::sysvars::debug & TOKUDB_DEBUG_ERROR)))) { \ + TOKUDB_SHARE_TRACE("return %d", rr); \ + } \ + DBUG_RETURN(rr); \ +} + +#define TOKUDB_SHARE_DBUG_RETURN_DOUBLE(r) { \ + double rr = (r); \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN) || \ + (tokudb::sysvars::debug & TOKUDB_DEBUG_SHARE))) { \ + TOKUDB_SHARE_TRACE("return %f", rr); \ + } \ + DBUG_RETURN(rr); \ +} + +#define TOKUDB_SHARE_DBUG_RETURN_PTR(r) { \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN) || \ + (tokudb::sysvars::debug & TOKUDB_DEBUG_SHARE))) { \ + TOKUDB_SHARE_TRACE("return 0x%p", r); \ + } \ + DBUG_RETURN(r); \ +} + +#define TOKUDB_SHARE_DBUG_VOID_RETURN() { \ + if (TOKUDB_UNLIKELY((tokudb::sysvars::debug & TOKUDB_DEBUG_RETURN) || \ + (tokudb::sysvars::debug & TOKUDB_DEBUG_SHARE))) { \ + TOKUDB_SHARE_TRACE("return"); \ + } \ + DBUG_VOID_RETURN; \ +} + + +#define TOKUDB_DBUG_DUMP(s, p, len) \ +{ \ + TOKUDB_TRACE("%s", s); \ + uint i; \ + for (i=0; i. + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "hatoku_hton.h" +#include "tokudb_information_schema.h" +#include "sql_time.h" +#include "tokudb_background.h" + + +namespace tokudb { +namespace information_schema { + +static void field_store_time_t(Field* field, time_t time) { + MYSQL_TIME my_time; + struct tm tm_time; + + if (time) { + localtime_r(&time, &tm_time); + localtime_to_TIME(&my_time, &tm_time); + my_time.time_type = MYSQL_TIMESTAMP_DATETIME; +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + field->store_time(&my_time); +#else + field->store_time(&my_time, MYSQL_TIMESTAMP_DATETIME); +#endif + field->set_notnull(); + } else { + field->set_null(); + } +} + +st_mysql_information_schema trx_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + +ST_FIELD_INFO trx_field_info[] = { + {"trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"trx_mysql_thread_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"trx_time", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +struct trx_extra_t { + THD *thd; + TABLE *table; +}; + +int trx_callback( + DB_TXN* txn, + iterate_row_locks_callback iterate_locks, + void* locks_extra, + void *extra) { + + uint64_t txn_id = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); + uint64_t start_time = txn->get_start_time(txn); + trx_extra_t* e = reinterpret_cast(extra); + THD* thd = e->thd; + TABLE* table = e->table; + table->field[0]->store(txn_id, false); + table->field[1]->store(client_id, false); + uint64_t tnow = (uint64_t) ::time(NULL); + table->field[2]->store(tnow >= start_time ? tnow - start_time : 0, false); + int error = schema_table_store_record(thd, table); + if (!error && thd_killed(thd)) + error = ER_QUERY_INTERRUPTED; + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int trx_fill_table(THD* thd, TABLE_LIST* tables, Item* cond) { +#else +int trx_fill_table(THD* thd, TABLE_LIST* tables, COND* cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + trx_extra_t e = { thd, tables->table }; + error = db_env->iterate_live_transactions(db_env, trx_callback, &e); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int trx_init(void* p) { + ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE*) p; + schema->fields_info = trx_field_info; + schema->fill_table = trx_fill_table; + return 0; +} + +int trx_done(void* p) { + return 0; +} + +st_mysql_plugin trx = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &trx_information_schema, + "TokuDB_trx", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + trx_init, /* plugin init */ + trx_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + + + +st_mysql_information_schema lock_waits_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + +ST_FIELD_INFO lock_waits_field_info[] = { + {"requesting_trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"blocking_trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_dname", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_key_left", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_key_right", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_start_time", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"lock_waits_table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +struct lock_waits_extra_t { + THD* thd; + TABLE* table; +}; + +int lock_waits_callback( + DB* db, + uint64_t requesting_txnid, + const DBT* left_key, + const DBT* right_key, + uint64_t blocking_txnid, + uint64_t start_time, + void *extra) { + + lock_waits_extra_t* e = + reinterpret_cast(extra); + THD* thd = e->thd; + TABLE* table = e->table; + table->field[0]->store(requesting_txnid, false); + table->field[1]->store(blocking_txnid, false); + const char* dname = tokudb_get_index_name(db); + size_t dname_length = strlen(dname); + table->field[2]->store(dname, dname_length, system_charset_info); + String left_str; + tokudb_pretty_left_key(db, left_key, &left_str); + table->field[3]->store( + left_str.ptr(), + left_str.length(), + system_charset_info); + String right_str; + tokudb_pretty_right_key(db, right_key, &right_str); + table->field[4]->store( + right_str.ptr(), + right_str.length(), + system_charset_info); + table->field[5]->store(start_time, false); + + String database_name, table_name, dictionary_name; + tokudb_split_dname(dname, database_name, table_name, dictionary_name); + table->field[6]->store( + database_name.c_ptr(), + database_name.length(), + system_charset_info); + table->field[7]->store( + table_name.c_ptr(), + table_name.length(), + system_charset_info); + table->field[8]->store( + dictionary_name.c_ptr(), + dictionary_name.length(), + system_charset_info); + + int error = schema_table_store_record(thd, table); + + if (!error && thd_killed(thd)) + error = ER_QUERY_INTERRUPTED; + + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int lock_waits_fill_table(THD* thd, TABLE_LIST* tables, Item* cond) { +#else +int lock_waits_fill_table(THD* thd, TABLE_LIST* tables, COND* cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + lock_waits_extra_t e = { thd, tables->table }; + error = db_env->iterate_pending_lock_requests( + db_env, + lock_waits_callback, + &e); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int lock_waits_init(void* p) { + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*)p; + schema->fields_info = lock_waits_field_info; + schema->fill_table = lock_waits_fill_table; + return 0; +} + +int lock_waits_done(void *p) { + return 0; +} + +st_mysql_plugin lock_waits = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &lock_waits_information_schema, + "TokuDB_lock_waits", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + lock_waits_init, /* plugin init */ + lock_waits_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + + + +st_mysql_information_schema locks_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + + ST_FIELD_INFO locks_field_info[] = { + {"locks_trx_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_mysql_thread_id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_dname", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_key_left", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_key_right", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"locks_table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +struct locks_extra_t { + THD* thd; + TABLE* table; +}; + +int locks_callback( + DB_TXN* txn, + iterate_row_locks_callback iterate_locks, + void* locks_extra, + void* extra) { + + uint64_t txn_id = txn->id64(txn); + uint64_t client_id = txn->get_client_id(txn); + locks_extra_t* e = reinterpret_cast(extra); + THD* thd = e->thd; + TABLE* table = e->table; + int error = 0; + DB* db; + DBT left_key, right_key; + while (error == 0 && + iterate_locks(&db, &left_key, &right_key, locks_extra) == 0) { + table->field[0]->store(txn_id, false); + table->field[1]->store(client_id, false); + + const char* dname = tokudb_get_index_name(db); + size_t dname_length = strlen(dname); + table->field[2]->store(dname, dname_length, system_charset_info); + + String left_str; + tokudb_pretty_left_key(db, &left_key, &left_str); + table->field[3]->store( + left_str.ptr(), + left_str.length(), + system_charset_info); + + String right_str; + tokudb_pretty_right_key(db, &right_key, &right_str); + table->field[4]->store( + right_str.ptr(), + right_str.length(), + system_charset_info); + + String database_name, table_name, dictionary_name; + tokudb_split_dname(dname, database_name, table_name, dictionary_name); + table->field[5]->store( + database_name.c_ptr(), + database_name.length(), + system_charset_info); + table->field[6]->store( + table_name.c_ptr(), + table_name.length(), + system_charset_info); + table->field[7]->store( + dictionary_name.c_ptr(), + dictionary_name.length(), + system_charset_info); + + error = schema_table_store_record(thd, table); + + if (!error && thd_killed(thd)) + error = ER_QUERY_INTERRUPTED; + } + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int locks_fill_table(THD* thd, TABLE_LIST* tables, Item* cond) { +#else +int locks_fill_table(THD* thd, TABLE_LIST* tables, COND* cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + locks_extra_t e = { thd, tables->table }; + error = db_env->iterate_live_transactions(db_env, locks_callback, &e); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int locks_init(void* p) { + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*)p; + schema->fields_info = locks_field_info; + schema->fill_table = locks_fill_table; + return 0; +} + +int locks_done(void* p) { + return 0; +} + +st_mysql_plugin locks = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &locks_information_schema, + "TokuDB_locks", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + locks_init, /* plugin init */ + locks_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + + + +st_mysql_information_schema file_map_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + +ST_FIELD_INFO file_map_field_info[] = { + {"dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"internal_file_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +int report_file_map(TABLE* table, THD* thd) { + int error; + DB_TXN* txn = NULL; + DBC* tmp_cursor = NULL; + DBT curr_key; + DBT curr_val; + memset(&curr_key, 0, sizeof curr_key); + memset(&curr_val, 0, sizeof curr_val); + error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED, thd); + if (error) { + goto cleanup; + } + error = db_env->get_cursor_for_directory(db_env, txn, &tmp_cursor); + if (error) { + goto cleanup; + } + while (error == 0) { + error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); + if (!error) { + // We store the NULL terminator in the directory so it's included + // in the size. + // See #5789 + // Recalculate and check just to be safe. + const char *dname = (const char *) curr_key.data; + size_t dname_len = strlen(dname); + assert(dname_len == curr_key.size - 1); + table->field[0]->store(dname, dname_len, system_charset_info); + + const char *iname = (const char *) curr_val.data; + size_t iname_len = strlen(iname); + assert(iname_len == curr_val.size - 1); + table->field[1]->store(iname, iname_len, system_charset_info); + + // split the dname + String database_name, table_name, dictionary_name; + tokudb_split_dname( + dname, + database_name, + table_name, + dictionary_name); + table->field[2]->store( + database_name.c_ptr(), + database_name.length(), + system_charset_info); + table->field[3]->store( + table_name.c_ptr(), + table_name.length(), + system_charset_info); + table->field[4]->store( + dictionary_name.c_ptr(), + dictionary_name.length(), + system_charset_info); + + error = schema_table_store_record(thd, table); + } + if (!error && thd_killed(thd)) + error = ER_QUERY_INTERRUPTED; + } + if (error == DB_NOTFOUND) { + error = 0; + } +cleanup: + if (tmp_cursor) { + int r = tmp_cursor->c_close(tmp_cursor); + assert(r == 0); + } + if (txn) { + commit_txn(txn, 0); + } + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int file_map_fill_table(THD* thd, TABLE_LIST* tables, Item* cond) { +#else +int file_map_fill_table(THD* thd, TABLE_LIST* tables, COND* cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + TABLE* table = tables->table; + + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + error = report_file_map(table, thd); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int file_map_init(void* p) { + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*)p; + schema->fields_info = file_map_field_info; + schema->fill_table = file_map_fill_table; + return 0; +} + +int file_map_done(void* p) { + return 0; +} + +st_mysql_plugin file_map = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &file_map_information_schema, + "TokuDB_file_map", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + file_map_init, /* plugin init */ + file_map_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + + + +st_mysql_information_schema fractal_tree_info_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + +ST_FIELD_INFO fractal_tree_info_field_info[] = { + {"dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"internal_file_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"bt_num_blocks_allocated", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"bt_num_blocks_in_use", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"bt_size_allocated", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"bt_size_in_use", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +int report_fractal_tree_info_for_db( + const DBT* dname, + const DBT* iname, + TABLE* table, + THD* thd) { + + int error; + uint64_t bt_num_blocks_allocated; + uint64_t bt_num_blocks_in_use; + uint64_t bt_size_allocated; + uint64_t bt_size_in_use; + + DB *db = NULL; + error = db_create(&db, db_env, 0); + if (error) { + goto exit; + } + error = db->open(db, NULL, (char *)dname->data, NULL, DB_BTREE, 0, 0666); + if (error) { + goto exit; + } + error = db->get_fractal_tree_info64( + db, + &bt_num_blocks_allocated, + &bt_num_blocks_in_use, + &bt_size_allocated, + &bt_size_in_use); + if (error) { + goto exit; + } + + // We store the NULL terminator in the directory so it's included in the + // size. + // See #5789 + // Recalculate and check just to be safe. + { + size_t dname_len = strlen((const char*)dname->data); + assert(dname_len == dname->size - 1); + table->field[0]->store( + (char*)dname->data, + dname_len, + system_charset_info); + size_t iname_len = strlen((const char*)iname->data); + assert(iname_len == iname->size - 1); + table->field[1]->store( + (char*)iname->data, + iname_len, + system_charset_info); + } + table->field[2]->store(bt_num_blocks_allocated, false); + table->field[3]->store(bt_num_blocks_in_use, false); + table->field[4]->store(bt_size_allocated, false); + table->field[5]->store(bt_size_in_use, false); + + // split the dname + { + String database_name, table_name, dictionary_name; + tokudb_split_dname( + (const char*)dname->data, + database_name, + table_name, + dictionary_name); + table->field[6]->store( + database_name.c_ptr(), + database_name.length(), + system_charset_info); + table->field[7]->store( + table_name.c_ptr(), + table_name.length(), + system_charset_info); + table->field[8]->store( + dictionary_name.c_ptr(), + dictionary_name.length(), + system_charset_info); + } + error = schema_table_store_record(thd, table); + +exit: + if (db) { + int close_error = db->close(db, 0); + if (error == 0) + error = close_error; + } + return error; +} + +int report_fractal_tree_info(TABLE* table, THD* thd) { + int error; + DB_TXN* txn = NULL; + DBC* tmp_cursor = NULL; + DBT curr_key; + DBT curr_val; + memset(&curr_key, 0, sizeof curr_key); + memset(&curr_val, 0, sizeof curr_val); + error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED, thd); + if (error) { + goto cleanup; + } + error = db_env->get_cursor_for_directory(db_env, txn, &tmp_cursor); + if (error) { + goto cleanup; + } + while (error == 0) { + error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); + if (!error) { + error = report_fractal_tree_info_for_db( + &curr_key, + &curr_val, + table, + thd); + if (error) + error = 0; // ignore read uncommitted errors + } + if (!error && thd_killed(thd)) + error = ER_QUERY_INTERRUPTED; + } + if (error == DB_NOTFOUND) { + error = 0; + } +cleanup: + if (tmp_cursor) { + int r = tmp_cursor->c_close(tmp_cursor); + assert(r == 0); + } + if (txn) { + commit_txn(txn, 0); + } + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int fractal_tree_info_fill_table(THD* thd, TABLE_LIST* tables, Item* cond) { +#else +int fractal_tree_info_fill_table(THD* thd, TABLE_LIST* tables, COND* cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + TABLE* table = tables->table; + + // 3938: Get a read lock on the status flag, since we must + // read it before safely proceeding + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + error = report_fractal_tree_info(table, thd); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + //3938: unlock the status flag lock + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int fractal_tree_info_init(void* p) { + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*)p; + schema->fields_info = fractal_tree_info_field_info; + schema->fill_table = fractal_tree_info_fill_table; + return 0; +} + +int fractal_tree_info_done(void* p) { + return 0; +} + +st_mysql_plugin fractal_tree_info = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &fractal_tree_info_information_schema, + "TokuDB_fractal_tree_info", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + fractal_tree_info_init, /* plugin init */ + fractal_tree_info_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + + + +st_mysql_information_schema fractal_tree_block_map_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + +ST_FIELD_INFO fractal_tree_block_map_field_info[] = { + {"dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"internal_file_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"checkpoint_count", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"blocknum", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"offset", 0, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, NULL, SKIP_OPEN_TABLE }, + {"size", 0, MYSQL_TYPE_LONGLONG, 0, MY_I_S_MAYBE_NULL, NULL, SKIP_OPEN_TABLE }, + {"table_schema", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_dictionary_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +struct report_fractal_tree_block_map_iterator_extra_t { + int64_t num_rows; + int64_t i; + uint64_t* checkpoint_counts; + int64_t* blocknums; + int64_t* diskoffs; + int64_t* sizes; +}; + +// This iterator is called while holding the blocktable lock. +// We should be as quick as possible. +// We don't want to do one call to get the number of rows, release the +// blocktable lock, and then do another call to get all the rows because +// the number of rows may change if we don't hold the lock. +// As a compromise, we'll do some mallocs inside the lock on the first call, +// but everything else should be fast. +int report_fractal_tree_block_map_iterator( + uint64_t checkpoint_count, + int64_t num_rows, + int64_t blocknum, + int64_t diskoff, + int64_t size, + void* iter_extra) { + + struct report_fractal_tree_block_map_iterator_extra_t* e = + static_cast(iter_extra); + + assert(num_rows > 0); + if (e->num_rows == 0) { + e->checkpoint_counts = + (uint64_t*)tokudb::memory::malloc( + num_rows * (sizeof *e->checkpoint_counts), + MYF(MY_WME|MY_ZEROFILL|MY_FAE)); + e->blocknums = + (int64_t*)tokudb::memory::malloc( + num_rows * (sizeof *e->blocknums), + MYF(MY_WME|MY_ZEROFILL|MY_FAE)); + e->diskoffs = + (int64_t*)tokudb::memory::malloc( + num_rows * (sizeof *e->diskoffs), + MYF(MY_WME|MY_ZEROFILL|MY_FAE)); + e->sizes = + (int64_t*)tokudb::memory::malloc( + num_rows * (sizeof *e->sizes), + MYF(MY_WME|MY_ZEROFILL|MY_FAE)); + e->num_rows = num_rows; + } + + e->checkpoint_counts[e->i] = checkpoint_count; + e->blocknums[e->i] = blocknum; + e->diskoffs[e->i] = diskoff; + e->sizes[e->i] = size; + ++(e->i); + + return 0; +} + +int report_fractal_tree_block_map_for_db( + const DBT* dname, + const DBT* iname, + TABLE* table, + THD* thd) { + + int error; + DB* db; + // avoid struct initializers so that we can compile with older gcc versions + report_fractal_tree_block_map_iterator_extra_t e = {}; + + error = db_create(&db, db_env, 0); + if (error) { + goto exit; + } + error = db->open(db, NULL, (char *)dname->data, NULL, DB_BTREE, 0, 0666); + if (error) { + goto exit; + } + error = db->iterate_fractal_tree_block_map( + db, + report_fractal_tree_block_map_iterator, + &e); + { + int close_error = db->close(db, 0); + if (!error) { + error = close_error; + } + } + if (error) { + goto exit; + } + + // If not, we should have gotten an error and skipped this section of code + assert(e.i == e.num_rows); + for (int64_t i = 0; error == 0 && i < e.num_rows; ++i) { + // We store the NULL terminator in the directory so it's included in the size. + // See #5789 + // Recalculate and check just to be safe. + size_t dname_len = strlen((const char*)dname->data); + assert(dname_len == dname->size - 1); + table->field[0]->store( + (char*)dname->data, + dname_len, + system_charset_info); + + size_t iname_len = strlen((const char*)iname->data); + assert(iname_len == iname->size - 1); + table->field[1]->store( + (char*)iname->data, + iname_len, + system_charset_info); + + table->field[2]->store(e.checkpoint_counts[i], false); + table->field[3]->store(e.blocknums[i], false); + static const int64_t freelist_null = -1; + static const int64_t diskoff_unused = -2; + if (e.diskoffs[i] == diskoff_unused || e.diskoffs[i] == freelist_null) { + table->field[4]->set_null(); + } else { + table->field[4]->set_notnull(); + table->field[4]->store(e.diskoffs[i], false); + } + static const int64_t size_is_free = -1; + if (e.sizes[i] == size_is_free) { + table->field[5]->set_null(); + } else { + table->field[5]->set_notnull(); + table->field[5]->store(e.sizes[i], false); + } + + // split the dname + String database_name, table_name, dictionary_name; + tokudb_split_dname( + (const char*)dname->data, + database_name, + table_name, + dictionary_name); + table->field[6]->store( + database_name.c_ptr(), + database_name.length(), + system_charset_info); + table->field[7]->store( + table_name.c_ptr(), + table_name.length(), + system_charset_info); + table->field[8]->store( + dictionary_name.c_ptr(), + dictionary_name.length(), + system_charset_info); + + error = schema_table_store_record(thd, table); + } + +exit: + if (e.checkpoint_counts != NULL) { + tokudb::memory::free(e.checkpoint_counts); + e.checkpoint_counts = NULL; + } + if (e.blocknums != NULL) { + tokudb::memory::free(e.blocknums); + e.blocknums = NULL; + } + if (e.diskoffs != NULL) { + tokudb::memory::free(e.diskoffs); + e.diskoffs = NULL; + } + if (e.sizes != NULL) { + tokudb::memory::free(e.sizes); + e.sizes = NULL; + } + return error; +} + +int report_fractal_tree_block_map(TABLE* table, THD* thd) { + int error; + DB_TXN* txn = NULL; + DBC* tmp_cursor = NULL; + DBT curr_key; + DBT curr_val; + memset(&curr_key, 0, sizeof curr_key); + memset(&curr_val, 0, sizeof curr_val); + error = txn_begin(db_env, 0, &txn, DB_READ_UNCOMMITTED, thd); + if (error) { + goto cleanup; + } + error = db_env->get_cursor_for_directory(db_env, txn, &tmp_cursor); + if (error) { + goto cleanup; + } + while (error == 0) { + error = tmp_cursor->c_get(tmp_cursor, &curr_key, &curr_val, DB_NEXT); + if (!error) { + error = report_fractal_tree_block_map_for_db( + &curr_key, + &curr_val, + table, + thd); + } + if (!error && thd_killed(thd)) + error = ER_QUERY_INTERRUPTED; + } + if (error == DB_NOTFOUND) { + error = 0; + } +cleanup: + if (tmp_cursor) { + int r = tmp_cursor->c_close(tmp_cursor); + assert(r == 0); + } + if (txn) { + commit_txn(txn, 0); + } + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int fractal_tree_block_map_fill_table( + THD* thd, + TABLE_LIST* tables, + Item* cond) { +#else +int fractal_tree_block_map_fill_table( + THD* thd, + TABLE_LIST* tables, + COND* cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + TABLE* table = tables->table; + + // 3938: Get a read lock on the status flag, since we must + // read it before safely proceeding + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + error = report_fractal_tree_block_map(table, thd); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + //3938: unlock the status flag lock + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int fractal_tree_block_map_init(void* p) { + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*)p; + schema->fields_info = fractal_tree_block_map_field_info; + schema->fill_table = fractal_tree_block_map_fill_table; + return 0; +} + +int fractal_tree_block_map_done(void *p) { + return 0; +} + +st_mysql_plugin fractal_tree_block_map = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &fractal_tree_block_map_information_schema, + "TokuDB_fractal_tree_block_map", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + fractal_tree_block_map_init, /* plugin init */ + fractal_tree_block_map_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + + +st_mysql_information_schema background_job_status_information_schema = { + MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION +}; + +ST_FIELD_INFO background_job_status_field_info[] = { + {"id", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"database_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"job_type", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"job_params", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"scheduler", 32, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"scheduled_time", 0, MYSQL_TYPE_DATETIME, 0, 0, NULL, SKIP_OPEN_TABLE }, + {"started_time", 0, MYSQL_TYPE_DATETIME, 0, MY_I_S_MAYBE_NULL, NULL, SKIP_OPEN_TABLE }, + {"status", 256, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, SKIP_OPEN_TABLE }, + {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} +}; + +struct background_job_status_extra { + THD* thd; + TABLE* table; +}; + +void background_job_status_callback( + uint64_t id, + const char* database_name, + const char* table_name, + const char* type, + const char* params, + const char* status, + bool user_scheduled, + time_t scheduled_time, + time_t started_time, + void* extra) { + + background_job_status_extra* e = + reinterpret_cast(extra); + + THD* thd = e->thd; + TABLE* table = e->table; + + table->field[0]->store(id, false); + table->field[1]->store( + database_name, + strlen(database_name), + system_charset_info); + table->field[2]->store(table_name, strlen(table_name), system_charset_info); + table->field[3]->store(type, strlen(type), system_charset_info); + table->field[4]->store(params, strlen(params), system_charset_info); + if (user_scheduled) + table->field[5]->store("USER", strlen("USER"), system_charset_info); + else + table->field[5]->store("AUTO", strlen("AUTO"), system_charset_info); + + field_store_time_t(table->field[6], scheduled_time); + field_store_time_t(table->field[7], started_time); + if (status[0] != '\0') { + table->field[8]->store(status, strlen(status), system_charset_info); + table->field[8]->set_notnull(); + } else { + table->field[8]->store(NULL, 0, system_charset_info); + table->field[8]->set_null(); + } + + schema_table_store_record(thd, table); +} + +int report_background_job_status(TABLE *table, THD *thd) { + int error = 0; + background_job_status_extra extra = { + thd, + table + }; + tokudb::background::_job_manager->iterate_jobs( + background_job_status_callback, + &extra); + return error; +} + +#if MYSQL_VERSION_ID >= 50600 +int background_job_status_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) { +#else +int background_job_status_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { +#endif + TOKUDB_DBUG_ENTER(""); + int error; + TABLE* table = tables->table; + + tokudb_hton_initialized_lock.lock_read(); + + if (!tokudb_hton_initialized) { + error = ER_PLUGIN_IS_NOT_LOADED; + my_error(error, MYF(0), tokudb_hton_name); + } else { + error = report_background_job_status(table, thd); + if (error) + my_error(ER_GET_ERRNO, MYF(0), error, tokudb_hton_name); + } + + tokudb_hton_initialized_lock.unlock(); + TOKUDB_DBUG_RETURN(error); +} + +int background_job_status_init(void* p) { + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*)p; + schema->fields_info = background_job_status_field_info; + schema->fill_table = background_job_status_fill_table; + return 0; +} + +int background_job_status_done(void* p) { + return 0; +} + +st_mysql_plugin background_job_status = { + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &background_job_status_information_schema, + "TokuDB_background_job_status", + "Percona", + "Percona TokuDB Storage Engine with Fractal Tree(tm) Technology", + PLUGIN_LICENSE_GPL, + background_job_status_init, /* plugin init */ + background_job_status_done, /* plugin deinit */ + TOKUDB_PLUGIN_VERSION, + NULL, /* status variables */ + NULL, /* system variables */ +#ifdef MARIA_PLUGIN_INTERFACE_VERSION + tokudb::sysvars::version, + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ +#else + NULL, /* config options */ + 0, /* flags */ +#endif +}; + +} // namespace information_schema +} // namespace tokudb diff --git a/storage/tokudb/tokudb_information_schema.h b/storage/tokudb/tokudb_information_schema.h new file mode 100644 index 00000000000..b80e3f074ec --- /dev/null +++ b/storage/tokudb/tokudb_information_schema.h @@ -0,0 +1,50 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_INFORMATION_SCHEMA_H +#define _TOKUDB_INFORMATION_SCHEMA_H + +#include "hatoku_defines.h" + +namespace tokudb { +namespace information_schema { + +#ifdef MARIA_PLUGIN_INTERFACE_VERSION +#define st_mysql_plugin st_maria_plugin +#endif + +extern st_mysql_plugin trx; +extern st_mysql_plugin lock_waits; +extern st_mysql_plugin locks; +extern st_mysql_plugin file_map; +extern st_mysql_plugin fractal_tree_info; +extern st_mysql_plugin fractal_tree_block_map; +extern st_mysql_plugin background_job_status; + +} // namespace information_schema +} // namespace tokudb + +#endif // _TOKUDB_INFORMATION_SCHEMA_H diff --git a/storage/tokudb/tokudb_math.h b/storage/tokudb/tokudb_math.h index c49af2a6a21..0338bf3871e 100644 --- a/storage/tokudb/tokudb_math.h +++ b/storage/tokudb/tokudb_math.h @@ -32,30 +32,34 @@ namespace tokudb { // Overflow detection adapted from "Hackers Delight", Henry S. Warren // Return a bit mask for bits 0 .. length_bits-1 -static uint64_t uint_mask(uint length_bits) __attribute__((unused)); +TOKUDB_UNUSED(static uint64_t uint_mask(uint length_bits)); static uint64_t uint_mask(uint length_bits) { return length_bits == 64 ? ~0ULL : (1ULL< x; // check for overflow return s; } // Return the highest int with a given number of bits -static int64_t int_high_endpoint(uint length_bits) __attribute__((unused)); +TOKUDB_UNUSED(static int64_t int_high_endpoint(uint length_bits)); static int64_t int_high_endpoint(uint length_bits) { return (1ULL<<(length_bits-1))-1; } // Return the lowest int with a given number of bits -static int64_t int_low_endpoint(uint length_bits) __attribute__((unused)); +TOKUDB_UNUSED(static int64_t int_low_endpoint(uint length_bits)); static int64_t int_low_endpoint(uint length_bits) { int64_t mask = uint_mask(length_bits); return (1ULL<<(length_bits-1)) | ~mask; } // Sign extend to 64 bits an int with a given number of bits -static int64_t int_sign_extend(int64_t n, uint length_bits) __attribute__((unused)); +TOKUDB_UNUSED(static int64_t int_sign_extend(int64_t n, uint length_bits)); static int64_t int_sign_extend(int64_t n, uint length_bits) { if (n & (1ULL<<(length_bits-1))) n |= ~uint_mask(length_bits); @@ -99,7 +107,11 @@ static int64_t int_sign_extend(int64_t n, uint length_bits) { // depending on the sign bit. // Sign extend to 64 bits. // Return the sum and the overflow. -static int64_t int_add(int64_t x, int64_t y, uint length_bits, bool *over) __attribute__((unused)); +TOKUDB_UNUSED(static int64_t int_add( + int64_t x, + int64_t y, + uint length_bits, + bool* over)); static int64_t int_add(int64_t x, int64_t y, uint length_bits, bool *over) { int64_t mask = uint_mask(length_bits); int64_t n = (x + y) & mask; @@ -114,7 +126,11 @@ static int64_t int_add(int64_t x, int64_t y, uint length_bits, bool *over) { // depending on the sign bit. // Sign extend to 64 bits. // Return the sum and the overflow. -static int64_t int_sub(int64_t x, int64_t y, uint length_bits, bool *over) __attribute__((unused)); +TOKUDB_UNUSED(static int64_t int_sub( + int64_t x, + int64_t y, + uint length_bits, + bool* over)); static int64_t int_sub(int64_t x, int64_t y, uint length_bits, bool *over) { int64_t mask = uint_mask(length_bits); int64_t n = (x - y) & mask; diff --git a/storage/tokudb/tokudb_memory.h b/storage/tokudb/tokudb_memory.h new file mode 100644 index 00000000000..2687c1cda8e --- /dev/null +++ b/storage/tokudb/tokudb_memory.h @@ -0,0 +1,102 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_MEMORY_H +#define _TOKUDB_MEMORY_H + +#include "hatoku_defines.h" + +namespace tokudb { +namespace memory { + +void* malloc(size_t s, myf flags); +void* realloc(void* p, size_t s, myf flags); +void free(void* ptr); +char* strdup(const char* p, myf flags); +void* multi_malloc(myf myFlags, ...); + + +inline void* malloc(size_t s, myf flags) { +#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799 + return ::my_malloc(0, s, flags); +#else + return ::my_malloc(s, flags); +#endif +} +inline void* realloc(void* p, size_t s, myf flags) { + if (s == 0) + return p; +#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799 + return ::my_realloc(0, p, s, flags); +#else + return ::my_realloc(p, s, flags | MY_ALLOW_ZERO_PTR); +#endif +} +inline void free(void* ptr) { + if (ptr) + ::my_free(ptr); +} +inline char* strdup(const char* p, myf flags) { +#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799 + return ::my_strdup(0, p, flags); +#else + return ::my_strdup(p, flags); +#endif +} +inline void* multi_malloc(myf myFlags, ...) { + va_list args; + char** ptr; + char* start; + char* res; + size_t tot_length,length; + + va_start(args,myFlags); + tot_length = 0; + while ((ptr = va_arg(args, char**))) { + length = va_arg(args, uint); + tot_length += ALIGN_SIZE(length); + } + va_end(args); + + if (!(start = (char*)malloc(tot_length, myFlags))) { + return 0; + } + + va_start(args, myFlags); + res = start; + while ((ptr = va_arg(args, char**))) { + *ptr = res; + length = va_arg(args,uint); + res += ALIGN_SIZE(length); + } + va_end(args); + return start; +} + +} // namespace thread +} // namespace tokudb + +#endif // _TOKUDB_MEMORY_H diff --git a/storage/tokudb/tokudb_status.h b/storage/tokudb/tokudb_status.h index 4600e04596f..5cca54e52c9 100644 --- a/storage/tokudb/tokudb_status.h +++ b/storage/tokudb/tokudb_status.h @@ -43,118 +43,374 @@ typedef ulonglong HA_METADATA_KEY; #define status_dict_pagesize 1024 namespace tokudb { +namespace metadata { - // get the value for a given key in the status dictionary. copy the value to the supplied buffer. - // returns 0 if successful. - int get_status(DB *status_db, DB_TXN *txn, HA_METADATA_KEY k, void *p, size_t s, size_t *sp) { - DBT key = {}; key.data = &k; key.size = sizeof k; - DBT val = {}; val.data = p; val.ulen = (uint32_t) s; val.flags = DB_DBT_USERMEM; - int error = status_db->get(status_db, txn, &key, &val, 0); - if (error == 0) { - *sp = val.size; - } - return error; - } - - // get the value for a given key in the status dictionary. put the value in a realloced buffer. - // returns 0 if successful. - int get_status_realloc(DB *status_db, DB_TXN *txn, HA_METADATA_KEY k, void **pp, size_t *sp) { - DBT key = {}; key.data = &k; key.size = sizeof k; - DBT val = {}; val.data = *pp; val.size = (uint32_t) *sp; val.flags = DB_DBT_REALLOC; - int error = status_db->get(status_db, txn, &key, &val, 0); - if (error == 0) { - *pp = val.data; - *sp = val.size; - } - return error; - } - - // write a key value pair into the status dictionary, overwriting the previous value if any. - // auto create a txn if necessary. - // returns 0 if successful. - int write_metadata(DB *status_db, void *key_data, uint key_size, void* val_data, uint val_size, DB_TXN *txn) { - DBT key = {}; key.data = key_data; key.size = key_size; - DBT value = {}; value.data = val_data; value.size = val_size; - int error = status_db->put(status_db, txn, &key, &value, 0); - return error; - } - - // write a key value pair into the status dictionary, overwriting the previous value if any. - // the key must be a HA_METADATA_KEY. - // returns 0 if successful. - int write_to_status(DB *status_db, HA_METADATA_KEY curr_key_data, void *val, size_t val_size, DB_TXN *txn) { - return write_metadata(status_db, &curr_key_data, sizeof curr_key_data, val, val_size, txn); - } - - // remove a key from the status dictionary. - // auto create a txn if necessary. - // returns 0 if successful. - int remove_metadata(DB *status_db, void *key_data, uint key_size, DB_TXN *txn) { - DBT key = {}; key.data = key_data; key.size = key_size; - int error = status_db->del(status_db, txn, &key, DB_DELETE_ANY); - return error; - } - - // remove a key from the status dictionary. - // the key must be a HA_METADATA_KEY - // returns 0 if successful. - int remove_from_status(DB *status_db, HA_METADATA_KEY curr_key_data, DB_TXN *txn) { - return remove_metadata(status_db, &curr_key_data, sizeof curr_key_data, txn); - } - - int close_status(DB **status_db_ptr) { - int error = 0; - DB *status_db = *status_db_ptr; - if (status_db) { - error = status_db->close(status_db, 0); - if (error == 0) - *status_db_ptr = NULL; - } - return error; - } - - int create_status(DB_ENV *env, DB **status_db_ptr, const char *name, DB_TXN *txn) { - int error; - DB *status_db = NULL; - - error = db_create(&status_db, env, 0); - if (error == 0) { - error = status_db->set_pagesize(status_db, status_dict_pagesize); - } - if (error == 0) { - error = status_db->open(status_db, txn, name, NULL, DB_BTREE, DB_CREATE | DB_EXCL, 0); - } - if (error == 0) { - *status_db_ptr = status_db; - } else { - int r = close_status(&status_db); - assert(r == 0); - } - return error; - } - - int open_status(DB_ENV *env, DB **status_db_ptr, const char *name, DB_TXN *txn) { - int error = 0; - DB *status_db = NULL; - error = db_create(&status_db, env, 0); - if (error == 0) { - error = status_db->open(status_db, txn, name, NULL, DB_BTREE, DB_THREAD, 0); - } - if (error == 0) { - uint32_t pagesize = 0; - error = status_db->get_pagesize(status_db, &pagesize); - if (error == 0 && pagesize > status_dict_pagesize) { - error = status_db->change_pagesize(status_db, status_dict_pagesize); - } - } - if (error == 0) { - *status_db_ptr = status_db; - } else { - int r = close_status(&status_db); - assert(r == 0); - } - return error; +// get the value for a given key in the status dictionary. +// copy the value to the supplied buffer. +// returns 0 if successful. +int read( + DB* status_db, + DB_TXN* txn, + HA_METADATA_KEY k, + void* p, + size_t s, + size_t* sp) { + + DBT key = {}; + key.data = &k; + key.size = sizeof(k); + DBT val = {}; + val.data = p; + val.ulen = (uint32_t)s; + val.flags = DB_DBT_USERMEM; + int error = status_db->get(status_db, txn, &key, &val, 0); + if (error == 0) { + *sp = val.size; } + return error; } +// get the value for a given key in the status dictionary. +// put the value in a realloced buffer. +// returns 0 if successful. +int read_realloc( + DB* status_db, + DB_TXN* txn, + HA_METADATA_KEY k, + void** pp, + size_t* sp) { + + DBT key = {}; + key.data = &k; + key.size = sizeof(k); + DBT val = {}; + val.data = *pp; + val.size = (uint32_t)*sp; + val.flags = DB_DBT_REALLOC; + int error = status_db->get(status_db, txn, &key, &val, 0); + if (error == 0) { + *pp = val.data; + *sp = val.size; + } + return error; +} + +// write a key value pair into the status dictionary, +// overwriting the previous value if any. +// auto create a txn if necessary. +// returns 0 if successful. +int write_low( + DB* status_db, + void* key_data, + uint key_size, + void* val_data, + uint val_size, + DB_TXN *txn) { + + DBT key = {}; + key.data = key_data; + key.size = key_size; + DBT value = {}; + value.data = val_data; + value.size = val_size; + int error = status_db->put(status_db, txn, &key, &value, 0); + return error; +} + +// write a key value pair into the status dictionary, +// overwriting the previous value if any. +// the key must be a HA_METADATA_KEY. +// returns 0 if successful. +int write( + DB* status_db, + HA_METADATA_KEY curr_key_data, + void* val, + size_t val_size, + DB_TXN* txn) { + + return + tokudb::metadata::write_low( + status_db, + &curr_key_data, + sizeof(curr_key_data), + val, + val_size, + txn); +} + +// remove a key from the status dictionary. +// auto create a txn if necessary. +// returns 0 if successful. +int remove_low( + DB* status_db, + void* key_data, + uint key_size, + DB_TXN* txn) { + + DBT key = {}; + key.data = key_data; + key.size = key_size; + int error = status_db->del(status_db, txn, &key, DB_DELETE_ANY); + return error; +} + +// remove a key from the status dictionary. +// the key must be a HA_METADATA_KEY +// returns 0 if successful. +int remove( + DB* status_db, + HA_METADATA_KEY curr_key_data, + DB_TXN* txn) { + return + tokudb::metadata::remove_low( + status_db, + &curr_key_data, + sizeof(curr_key_data), + txn); +} + +int close(DB** status_db_ptr) { + int error = 0; + DB* status_db = *status_db_ptr; + if (status_db) { + error = status_db->close(status_db, 0); + if (error == 0) + *status_db_ptr = NULL; + } + return error; +} + +int create( + DB_ENV* env, + DB** status_db_ptr, + const char* name, + DB_TXN* txn) { + + int error; + DB *status_db = NULL; + + error = db_create(&status_db, env, 0); + if (error == 0) { + error = status_db->set_pagesize(status_db, status_dict_pagesize); + } + if (error == 0) { + error = + status_db->open( + status_db, + txn, + name, + NULL, + DB_BTREE, DB_CREATE | DB_EXCL, + 0); + } + if (error == 0) { + *status_db_ptr = status_db; + } else { + int r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + } + return error; +} + +int open( + DB_ENV* env, + DB** status_db_ptr, + const char* name, + DB_TXN* txn) { + + int error = 0; + DB* status_db = NULL; + error = db_create(&status_db, env, 0); + if (error == 0) { + error = + status_db->open( + status_db, + txn, + name, + NULL, + DB_BTREE, + DB_THREAD, + 0); + } + if (error == 0) { + uint32_t pagesize = 0; + error = status_db->get_pagesize(status_db, &pagesize); + if (error == 0 && pagesize > status_dict_pagesize) { + error = + status_db->change_pagesize(status_db, status_dict_pagesize); + } + } + if (error == 0) { + *status_db_ptr = status_db; + } else { + int r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + } + return error; +} + +int strip_frm_data(DB_ENV* env) { + int r; + DB_TXN* txn = NULL; + + fprintf(stderr, "TokuDB strip_frm_data : Beginning stripping process.\n"); + + r = db_env->txn_begin(env, NULL, &txn, 0); + assert_always(r == 0); + + DBC* c = NULL; + r = env->get_cursor_for_directory(env, txn, &c); + assert_always(r == 0); + + DBT key = { }; + key.flags = DB_DBT_REALLOC; + + DBT val = { }; + val.flags = DB_DBT_REALLOC; + while (1) { + r = c->c_get(c, &key, &val, DB_NEXT); + if (r == DB_NOTFOUND) + break; + const char* dname = (const char*) key.data; + const char* iname = (const char*) val.data; + assert_always(r == 0); + + if (strstr(iname, "_status_")) { + fprintf( + stderr, + "TokuDB strip_frm_data : stripping from dname=%s iname=%s\n", + dname, + iname); + + DB* status_db; + r = tokudb::metadata::open(db_env, &status_db, dname, txn); + if (r != 0) { + fprintf( + stderr, + "TokuDB strip_frm_data : unable to open status file %s, " + "error = %d\n", + dname, + r); + continue; + } + + // GOL : this is a godawful hack. The inventors of this did not + // think it would be a good idea to use some kind of magic + // identifier k/v pair so that you can in fact tell a proper status + // file from any other file that might have the string _status_ in + // it. Out in ha_tokudb::create, when the status file is initially + // created, it is immediately populated with: + // uint hatoku_new_version=HA_TOKU_VERSION=4 and + // uint hatoku_capabilities=HA_TOKU_CAP=0 + // Since I can't count on the fact that these values are/were + // _always_ 4 and 0, I can count on the fact that they _must_ be + // there and the _must_ be sizeof(uint). That will at least give us + // a much better idea that these are in fact status files. + void* p = NULL; + size_t sz; + r = + tokudb::metadata::read_realloc( + status_db, + txn, + hatoku_new_version, + &p, + &sz); + if (r != 0) { + fprintf( + stderr, + "TokuDB strip_frm_data : does not look like a real TokuDB " + "status file, new_verion is missing, leaving alone %s \n", + dname); + + r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + continue; + } else if (sz != sizeof(uint)) { + fprintf( + stderr, + "TokuDB strip_frm_data : does not look like a real TokuDB " + "status file, new_verion is the wrong size, " + "leaving alone %s \n", + dname); + + tokudb::memory::free(p); + r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + continue; + } + tokudb::memory::free(p); + p = NULL; + + r = + tokudb::metadata::read_realloc( + status_db, + txn, + hatoku_capabilities, + &p, + &sz); + if (r != 0) { + fprintf( + stderr, + "TokuDB strip_frm_data : does not look like a real TokuDB " + "status file, capabilities is missing, leaving alone %s \n", + dname); + + r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + continue; + } else if (sz != sizeof(uint)) { + fprintf( + stderr, + "TokuDB strip_frm_data : does not look like a real TokuDB " + "status file, capabilities is the wrong size, " + "leaving alone %s \n", + dname); + + tokudb::memory::free(p); + r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + continue; + } + tokudb::memory::free(p); + + // OK, st this point, it is probably a status file, not 100% but + // it looks like it :( + r = tokudb::metadata::remove(status_db, hatoku_frm_data, txn); + if (r != 0) { + fprintf( + stderr, + "TokuDB strip_frm_data : unable to find/strip frm data " + "from status file %s, error = %d\n", + dname, + r); + } + + r = tokudb::metadata::close(&status_db); + assert_always(r == 0); + } + } + tokudb::memory::free(key.data); + tokudb::memory::free(val.data); + + fprintf( + stderr, + "TokuDB strip_frm_data : Stripping process complete, beginning " + "commit, this may take some time.\n"); + + r = c->c_close(c); + assert_always(r == 0); + + r = txn->commit(txn, 0); + assert_always(r == 0); + + fprintf( + stderr, + "TokuDB strip_frm_data : Commit complete, resuming server init " + "process."); + + return 0; +} + +} // namespace metadata +} // namespace tokudb #endif diff --git a/storage/tokudb/tokudb_sysvars.cc b/storage/tokudb/tokudb_sysvars.cc new file mode 100644 index 00000000000..7cea749b4fb --- /dev/null +++ b/storage/tokudb/tokudb_sysvars.cc @@ -0,0 +1,1140 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "hatoku_hton.h" + +namespace tokudb { +namespace sysvars { + +//****************************************************************************** +// global variables +//****************************************************************************** +#ifdef TOKUDB_VERSION +#define tokudb_stringify_2(x) #x +#define tokudb_stringify(x) tokudb_stringify_2(x) +#define TOKUDB_VERSION_STR tokudb_stringify(TOKUDB_VERSION) +#else +#define TOKUDB_VERSION_STR NULL +#endif + +ulonglong cache_size = 0; +uint cachetable_pool_threads = 0; +int cardinality_scale_percent = 0; +my_bool checkpoint_on_flush_logs = FALSE; +uint checkpoint_pool_threads = 0; +uint checkpointing_period = 0; +ulong cleaner_iterations = 0; +ulong cleaner_period = 0; +uint client_pool_threads = 0; +my_bool compress_buffers_before_eviction = TRUE; +char* data_dir = NULL; +ulong debug = 0; +#if TOKUDB_DEBUG +// used to control background job manager +my_bool debug_pause_background_job_manager = FALSE; +#endif +my_bool directio = FALSE; +my_bool enable_partial_eviction = TRUE; +int fs_reserve_percent = 0; +uint fsync_log_period = 0; +char* log_dir = NULL; +ulonglong max_lock_memory = 0; +uint read_status_frequency = 0; +my_bool strip_frm_data = FALSE; +char* tmp_dir = NULL; +uint write_status_frequency = 0; +char* version = (char*) TOKUDB_VERSION_STR; + +// file system reserve as a percentage of total disk space +#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL +char* gdb_path = NULL; +my_bool gdb_on_fatal = FALSE; +#endif + +my_bool check_jemalloc = TRUE; + +static MYSQL_SYSVAR_ULONGLONG( + cache_size, + cache_size, + PLUGIN_VAR_READONLY, + "cache table size", + NULL, + NULL, + 0, + 0, + ~0ULL, + 0); + +static MYSQL_SYSVAR_UINT( + cachetable_pool_threads, + cachetable_pool_threads, + PLUGIN_VAR_READONLY, + "cachetable ops thread pool size", + NULL, + NULL, + 0, + 0, + 1024, + 0); + +static MYSQL_SYSVAR_INT( + cardinality_scale_percent, + cardinality_scale_percent, + 0, + "index cardinality scale percentage", + NULL, + NULL, + 50, + 0, + 100, + 0); + +static MYSQL_SYSVAR_BOOL( + checkpoint_on_flush_logs, + checkpoint_on_flush_logs, + 0, + "checkpoint on flush logs", + NULL, + NULL, + FALSE); + +static MYSQL_SYSVAR_UINT( + checkpoint_pool_threads, + checkpoint_pool_threads, + PLUGIN_VAR_READONLY, + "checkpoint ops thread pool size", + NULL, + NULL, + 0, + 0, + 1024, + 0); + +static void checkpointing_period_update( + THD* thd, + st_mysql_sys_var* sys_var, + void* var, + const void* save) { + + uint* cp = (uint*)var; + *cp = *(const uint*)save; + int r = db_env->checkpointing_set_period(db_env, *cp); + assert(r == 0); +} + +static MYSQL_SYSVAR_UINT( + checkpointing_period, + checkpointing_period, + 0, + "checkpointing period", + NULL, + checkpointing_period_update, + 60, + 0, + ~0U, + 0); + +static void cleaner_iterations_update( + THD* thd, + st_mysql_sys_var* sys_var, + void* var, + const void* save) { + + ulong* ci = (ulong*)var; + *ci = *(const ulong*)save; + int r = db_env->cleaner_set_iterations(db_env, *ci); + assert(r == 0); +} + +static MYSQL_SYSVAR_ULONG( + cleaner_iterations, + cleaner_iterations, + 0, + "cleaner_iterations", + NULL, + cleaner_iterations_update, + DEFAULT_TOKUDB_CLEANER_ITERATIONS, + 0, + ~0UL, + 0); + +static void cleaner_period_update( + THD* thd, + st_mysql_sys_var* sys_var, + void* var, + const void * save) { + + ulong* cp = (ulong*)var; + *cp = *(const ulong*)save; + int r = db_env->cleaner_set_period(db_env, *cp); + assert(r == 0); +} + +static MYSQL_SYSVAR_ULONG( + cleaner_period, + cleaner_period, + 0, + "cleaner_period", + NULL, + cleaner_period_update, + DEFAULT_TOKUDB_CLEANER_PERIOD, + 0, + ~0UL, + 0); + +static MYSQL_SYSVAR_UINT( + client_pool_threads, + client_pool_threads, + PLUGIN_VAR_READONLY, + "client ops thread pool size", + NULL, + NULL, + 0, + 0, + 1024, + 0); + +static MYSQL_SYSVAR_BOOL( + compress_buffers_before_eviction, + compress_buffers_before_eviction, + PLUGIN_VAR_READONLY, + "enable in-memory buffer compression before partial eviction", + NULL, + NULL, + TRUE); + +static MYSQL_SYSVAR_STR( + data_dir, + data_dir, + PLUGIN_VAR_READONLY, + "data directory", + NULL, + NULL, + NULL); + +static MYSQL_SYSVAR_ULONG( + debug, + debug, + 0, + "plugin debug mask", + NULL, + NULL, + 0, + 0, + ~0UL, + 0); + +#if TOKUDB_DEBUG +static MYSQL_SYSVAR_BOOL( + debug_pause_background_job_manager, + debug_pause_background_job_manager, + 0, + "debug : pause the background job manager", + NULL, + NULL, + FALSE); +#endif // TOKUDB_DEBUG + +static MYSQL_SYSVAR_BOOL( + directio, + directio, + PLUGIN_VAR_READONLY, "enable direct i/o ", + NULL, + NULL, + FALSE); + +static void enable_partial_eviction_update( + THD* thd, + st_mysql_sys_var* sys_var, + void* var, + const void* save) { + + my_bool* epe = (my_bool*)var; + *epe = *(const my_bool*)save; + int r = db_env->evictor_set_enable_partial_eviction(db_env, *epe); + assert(r == 0); +} + +static MYSQL_SYSVAR_BOOL( + enable_partial_eviction, + enable_partial_eviction, + 0, + "enable partial node eviction", + NULL, + enable_partial_eviction_update, + TRUE); + +static MYSQL_SYSVAR_INT( + fs_reserve_percent, + fs_reserve_percent, + PLUGIN_VAR_READONLY, + "file system space reserve (percent free required)", + NULL, + NULL, + 5, + 0, + 100, + 0); + +static void fsync_log_period_update( + THD* thd, + st_mysql_sys_var* sys_var, + void* var, + const void* save) { + + uint* flp = (uint*)var; + *flp = *(const uint*)save; + db_env->change_fsync_log_period(db_env, *flp); +} + +static MYSQL_SYSVAR_UINT( + fsync_log_period, + fsync_log_period, + 0, + "fsync log period", + NULL, + fsync_log_period_update, + 0, + 0, + ~0U, + 0); + +static MYSQL_SYSVAR_STR( + log_dir, + log_dir, + PLUGIN_VAR_READONLY, + "log directory", + NULL, + NULL, + NULL); + +static MYSQL_SYSVAR_ULONGLONG( + max_lock_memory, + max_lock_memory, + PLUGIN_VAR_READONLY, + "max memory for locks", + NULL, + NULL, + 0, + 0, + ~0ULL, + 0); + +static MYSQL_SYSVAR_UINT( + read_status_frequency, + read_status_frequency, + 0, + "frequency that show processlist updates status of reads", + NULL, + NULL, + 10000, + 0, + ~0U, + 0); + +static MYSQL_SYSVAR_BOOL( + strip_frm_data, + strip_frm_data, + PLUGIN_VAR_READONLY, + "strip .frm data from metadata file(s)", + NULL, + NULL, + FALSE); + +static MYSQL_SYSVAR_STR( + tmp_dir, + tmp_dir, + PLUGIN_VAR_READONLY, + "directory to use for temporary files", + NULL, + NULL, + NULL); + +static MYSQL_SYSVAR_STR( + version, + version, + PLUGIN_VAR_READONLY, + "plugin version", + NULL, + NULL, + NULL); + +static MYSQL_SYSVAR_UINT( + write_status_frequency, + write_status_frequency, + 0, + "frequency that show processlist updates status of writes", + NULL, + NULL, + 1000, + 0, + ~0U, + 0); + +#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL +static MYSQL_SYSVAR_STR( + gdb_path, + gdb_path, + PLUGIN_VAR_READONLY|PLUGIN_VAR_RQCMDARG, + "path to gdb for extra debug info on fatal signal", + NULL, + NULL, + "/usr/bin/gdb"); + +static MYSQL_SYSVAR_BOOL( + gdb_on_fatal, + gdb_on_fatal, + 0, + "enable gdb debug info on fatal signal", + NULL, + NULL, + true); +#endif + +static MYSQL_SYSVAR_BOOL( + check_jemalloc, + check_jemalloc, + PLUGIN_VAR_READONLY|PLUGIN_VAR_RQCMDARG, + "check if jemalloc is linked and transparent huge pages are disabled", + NULL, + NULL, + TRUE); + + +//****************************************************************************** +// session variables +//****************************************************************************** +static MYSQL_THDVAR_BOOL( + alter_print_error, + 0, + "print errors for alter table operations", + NULL, + NULL, + false); + +static MYSQL_THDVAR_DOUBLE( + analyze_delete_fraction, + 0, + "fraction of rows allowed to be deleted", + NULL, + NULL, + 1.0, + 0, + 1.0, + 1); + +static MYSQL_THDVAR_BOOL( + analyze_in_background, + 0, + "dispatch ANALYZE TABLE to background job.", + NULL, + NULL, + false); + +const char* srv_analyze_mode_names[] = { + "TOKUDB_ANALYZE_STANDARD", + "TOKUDB_ANALYZE_RECOUNT_ROWS", + "TOKUDB_ANALYZE_CANCEL", + NullS +}; + +static TYPELIB tokudb_analyze_mode_typelib = { + array_elements(srv_analyze_mode_names) - 1, + "tokudb_analyze_mode_typelib", + srv_analyze_mode_names, + NULL +}; + +static MYSQL_THDVAR_ENUM(analyze_mode, + PLUGIN_VAR_RQCMDARG, + "Controls the function of ANALYZE TABLE. Possible values are: " + "TOKUDB_ANALYZE_STANDARD perform standard table analysis (default); " + "TOKUDB_ANALYZE_RECOUNT_ROWS perform logical recount of table rows;" + "TOKUDB_ANALYZE_CANCEL terminate and cancel all scheduled background jobs " + "for a table", + NULL, + NULL, + TOKUDB_ANALYZE_STANDARD, + &tokudb_analyze_mode_typelib); + +static MYSQL_THDVAR_ULONGLONG( + analyze_throttle, + 0, + "analyze throttle (keys)", + NULL, + NULL, + 0, + 0, + ~0U, + 1); + +static MYSQL_THDVAR_UINT( + analyze_time, + 0, + "analyze time (seconds)", + NULL, + NULL, + 5, + 0, + ~0U, + 1); + +static MYSQL_THDVAR_ULONGLONG( + auto_analyze, + 0, + "auto analyze threshold (percent)", + NULL, + NULL, + 0, + 0, + ~0U, + 1); + +static MYSQL_THDVAR_UINT( + block_size, + 0, + "fractal tree block size", + NULL, + NULL, + 4<<20, + 4096, + ~0U, + 1); + +static MYSQL_THDVAR_BOOL( + bulk_fetch, + PLUGIN_VAR_THDLOCAL, + "enable bulk fetch", + NULL, + NULL, + true); + +static void checkpoint_lock_update( + THD* thd, + st_mysql_sys_var* var, + void* var_ptr, + const void* save) { + + my_bool* val = (my_bool*)var_ptr; + *val= *(my_bool*)save ? true : false; + if (*val) { + tokudb_checkpoint_lock(thd); + } else { + tokudb_checkpoint_unlock(thd); + } +} + +static MYSQL_THDVAR_BOOL( + checkpoint_lock, + 0, + "checkpoint lock", + NULL, + checkpoint_lock_update, + false); + +static MYSQL_THDVAR_BOOL( + commit_sync, + PLUGIN_VAR_THDLOCAL, + "sync on txn commit", + NULL, + NULL, + true); + +static MYSQL_THDVAR_BOOL( + create_index_online, + 0, + "if on, create index done online", + NULL, + NULL, + true); + +static MYSQL_THDVAR_BOOL( + disable_hot_alter, + 0, + "if on, hot alter table is disabled", + NULL, + NULL, + false); + +static MYSQL_THDVAR_BOOL( + disable_prefetching, + 0, + "if on, prefetching disabled", + NULL, + NULL, + false); + +static MYSQL_THDVAR_BOOL( + disable_slow_alter, + 0, + "if on, alter tables that require copy are disabled", + NULL, + NULL, + false); + +static const char *tokudb_empty_scan_names[] = { + "disabled", + "lr", + "rl", + NullS +}; + +static TYPELIB tokudb_empty_scan_typelib = { + array_elements(tokudb_empty_scan_names) - 1, + "tokudb_empty_scan_typelib", + tokudb_empty_scan_names, + NULL +}; + +static MYSQL_THDVAR_ENUM( + empty_scan, + PLUGIN_VAR_OPCMDARG, + "algorithm to check if the table is empty when opened", + NULL, + NULL, + TOKUDB_EMPTY_SCAN_RL, + &tokudb_empty_scan_typelib); + +static MYSQL_THDVAR_UINT( + fanout, + 0, + "fractal tree fanout", + NULL, + NULL, + 16, + 2, + 16*1024, + 1); + +static MYSQL_THDVAR_BOOL( + hide_default_row_format, + 0, + "hide the default row format", + NULL, + NULL, + true); + +static MYSQL_THDVAR_ULONGLONG( + killed_time, + 0, + "killed time", + NULL, + NULL, + DEFAULT_TOKUDB_KILLED_TIME, + 0, + ~0ULL, + 1); + +static MYSQL_THDVAR_STR( + last_lock_timeout, + PLUGIN_VAR_MEMALLOC, + "last lock timeout", + NULL, + NULL, + NULL); + +static MYSQL_THDVAR_BOOL( + load_save_space, + 0, + "compress intermediate bulk loader files to save space", + NULL, + NULL, + true); + +static MYSQL_THDVAR_ULONGLONG( + loader_memory_size, + 0, + "loader memory size", + NULL, + NULL, + 100*1000*1000, + 0, + ~0ULL, + 1); + +static MYSQL_THDVAR_ULONGLONG( + lock_timeout, + 0, + "lock timeout", + NULL, + NULL, + DEFAULT_TOKUDB_LOCK_TIMEOUT, + 0, + ~0ULL, + 1); + +static MYSQL_THDVAR_UINT( + lock_timeout_debug, + 0, + "lock timeout debug", + NULL, + NULL, + 1, + 0, + ~0U, + 1); + +static MYSQL_THDVAR_DOUBLE( + optimize_index_fraction, + 0, + "optimize index fraction (default 1.0 all)", + NULL, + NULL, + 1.0, + 0, + 1.0, + 1); + +static MYSQL_THDVAR_STR( + optimize_index_name, + PLUGIN_VAR_THDLOCAL + PLUGIN_VAR_MEMALLOC, + "optimize index name (default all indexes)", + NULL, + NULL, + NULL); + +static MYSQL_THDVAR_ULONGLONG( + optimize_throttle, + 0, + "optimize throttle (default no throttle)", + NULL, + NULL, + 0, + 0, + ~0ULL, + 1); + +static const char* deprecated_tokudb_pk_insert_mode = + "Using tokudb_pk_insert_mode is deprecated and the " + "parameter may be removed in future releases."; +static const char* deprecated_tokudb_pk_insert_mode_zero = + "Using tokudb_pk_insert_mode=0 is deprecated and the " + "parameter may be removed in future releases. " + "Only tokudb_pk_insert_mode=1|2 is allowed." + "Resettig the value to 1."; + +static void pk_insert_mode_update( + THD* thd, + st_mysql_sys_var* var, + void* var_ptr, + const void* save) { + const uint* new_pk_insert_mode = static_cast(save); + uint* pk_insert_mode = static_cast(var_ptr); + if (*new_pk_insert_mode == 0) { + push_warning( + thd, + Sql_condition::WARN_LEVEL_WARN, + HA_ERR_WRONG_COMMAND, + deprecated_tokudb_pk_insert_mode_zero); + *pk_insert_mode = 1; + } else { + push_warning( + thd, + Sql_condition::WARN_LEVEL_WARN, + HA_ERR_WRONG_COMMAND, + deprecated_tokudb_pk_insert_mode); + *pk_insert_mode = *new_pk_insert_mode; + } +} + +static MYSQL_THDVAR_UINT( + pk_insert_mode, + 0, + "set the primary key insert mode", + NULL, + pk_insert_mode_update, + 1, + 0, + 2, + 1); + +static MYSQL_THDVAR_BOOL( + prelock_empty, + 0, + "prelock empty table", + NULL, + NULL, + true); + +static MYSQL_THDVAR_UINT( + read_block_size, + 0, + "fractal tree read block size", + NULL, + NULL, + 64*1024, + 4096, + ~0U, + 1); + +static MYSQL_THDVAR_UINT( + read_buf_size, + 0, + "range query read buffer size", + NULL, + NULL, + 128*1024, + 0, + 1*1024*1024, + 1); + +static const char *tokudb_row_format_names[] = { + "tokudb_uncompressed", + "tokudb_zlib", + "tokudb_snappy", + "tokudb_quicklz", + "tokudb_lzma", + "tokudb_fast", + "tokudb_small", + "tokudb_default", + NullS +}; + +static TYPELIB tokudb_row_format_typelib = { + array_elements(tokudb_row_format_names) - 1, + "tokudb_row_format_typelib", + tokudb_row_format_names, + NULL +}; + +static MYSQL_THDVAR_ENUM( + row_format, + PLUGIN_VAR_OPCMDARG, + "Specifies the compression method for a table created during this session. " + "Possible values are TOKUDB_UNCOMPRESSED, TOKUDB_ZLIB, TOKUDB_SNAPPY, " + "TOKUDB_QUICKLZ, TOKUDB_LZMA, TOKUDB_FAST, TOKUDB_SMALL and TOKUDB_DEFAULT", + NULL, + NULL, + SRV_ROW_FORMAT_ZLIB, + &tokudb_row_format_typelib); + +static MYSQL_THDVAR_BOOL( + rpl_check_readonly, + PLUGIN_VAR_THDLOCAL, + "check if the slave is read only", + NULL, + NULL, + true); + +static MYSQL_THDVAR_BOOL( + rpl_lookup_rows, + PLUGIN_VAR_THDLOCAL, + "lookup a row on rpl slave", + NULL, + NULL, + true); + +static MYSQL_THDVAR_ULONGLONG( + rpl_lookup_rows_delay, + PLUGIN_VAR_THDLOCAL, + "time in milliseconds to add to lookups on replication slave", + NULL, + NULL, + 0, + 0, + ~0ULL, + 1); + +static MYSQL_THDVAR_BOOL( + rpl_unique_checks, + PLUGIN_VAR_THDLOCAL, + "enable unique checks on replication slave", + NULL, + NULL, + true); + +static MYSQL_THDVAR_ULONGLONG( + rpl_unique_checks_delay, + PLUGIN_VAR_THDLOCAL, + "time in milliseconds to add to unique checks test on replication slave", + NULL, + NULL, + 0, + 0, + ~0ULL, + 1); + +#if TOKU_INCLUDE_UPSERT +static MYSQL_THDVAR_BOOL( + disable_slow_update, + PLUGIN_VAR_THDLOCAL, + "disable slow update", + NULL, + NULL, + false); + +static MYSQL_THDVAR_BOOL( + disable_slow_upsert, + PLUGIN_VAR_THDLOCAL, + "disable slow upsert", + NULL, + NULL, + false); +#endif + +#if TOKU_INCLUDE_XA +static MYSQL_THDVAR_BOOL( + support_xa, + PLUGIN_VAR_OPCMDARG, + "Enable TokuDB support for the XA two-phase commit", + NULL, + NULL, + true); +#endif + + + +//****************************************************************************** +// all system variables +//****************************************************************************** +st_mysql_sys_var* system_variables[] = { + // global vars + MYSQL_SYSVAR(cache_size), + MYSQL_SYSVAR(checkpoint_on_flush_logs), + MYSQL_SYSVAR(cachetable_pool_threads), + MYSQL_SYSVAR(cardinality_scale_percent), + MYSQL_SYSVAR(checkpoint_pool_threads), + MYSQL_SYSVAR(checkpointing_period), + MYSQL_SYSVAR(cleaner_iterations), + MYSQL_SYSVAR(cleaner_period), + MYSQL_SYSVAR(client_pool_threads), + MYSQL_SYSVAR(compress_buffers_before_eviction), + MYSQL_SYSVAR(data_dir), + MYSQL_SYSVAR(debug), + MYSQL_SYSVAR(directio), + MYSQL_SYSVAR(enable_partial_eviction), + MYSQL_SYSVAR(fs_reserve_percent), + MYSQL_SYSVAR(fsync_log_period), + MYSQL_SYSVAR(log_dir), + MYSQL_SYSVAR(max_lock_memory), + MYSQL_SYSVAR(read_status_frequency), + MYSQL_SYSVAR(strip_frm_data), + MYSQL_SYSVAR(tmp_dir), + MYSQL_SYSVAR(version), + MYSQL_SYSVAR(write_status_frequency), + +#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL + MYSQL_SYSVAR(gdb_path), + MYSQL_SYSVAR(gdb_on_fatal), +#endif + + MYSQL_SYSVAR(check_jemalloc), + + // session vars + MYSQL_SYSVAR(alter_print_error), + MYSQL_SYSVAR(analyze_delete_fraction), + MYSQL_SYSVAR(analyze_in_background), + MYSQL_SYSVAR(analyze_mode), + MYSQL_SYSVAR(analyze_throttle), + MYSQL_SYSVAR(analyze_time), + MYSQL_SYSVAR(auto_analyze), + MYSQL_SYSVAR(block_size), + MYSQL_SYSVAR(bulk_fetch), + MYSQL_SYSVAR(checkpoint_lock), + MYSQL_SYSVAR(commit_sync), + MYSQL_SYSVAR(create_index_online), + MYSQL_SYSVAR(disable_hot_alter), + MYSQL_SYSVAR(disable_prefetching), + MYSQL_SYSVAR(disable_slow_alter), + MYSQL_SYSVAR(empty_scan), + MYSQL_SYSVAR(fanout), + MYSQL_SYSVAR(hide_default_row_format), + MYSQL_SYSVAR(killed_time), + MYSQL_SYSVAR(last_lock_timeout), + MYSQL_SYSVAR(load_save_space), + MYSQL_SYSVAR(loader_memory_size), + MYSQL_SYSVAR(lock_timeout), + MYSQL_SYSVAR(lock_timeout_debug), + MYSQL_SYSVAR(optimize_index_fraction), + MYSQL_SYSVAR(optimize_index_name), + MYSQL_SYSVAR(optimize_throttle), + MYSQL_SYSVAR(pk_insert_mode), + MYSQL_SYSVAR(prelock_empty), + MYSQL_SYSVAR(read_block_size), + MYSQL_SYSVAR(read_buf_size), + MYSQL_SYSVAR(row_format), + MYSQL_SYSVAR(rpl_check_readonly), + MYSQL_SYSVAR(rpl_lookup_rows), + MYSQL_SYSVAR(rpl_lookup_rows_delay), + MYSQL_SYSVAR(rpl_unique_checks), + MYSQL_SYSVAR(rpl_unique_checks_delay), + +#if TOKU_INCLUDE_UPSERT + MYSQL_SYSVAR(disable_slow_update), + MYSQL_SYSVAR(disable_slow_upsert), +#endif + +#if TOKU_INCLUDE_XA + MYSQL_SYSVAR(support_xa), +#endif + +#if TOKUDB_DEBUG + MYSQL_SYSVAR(debug_pause_background_job_manager), +#endif // TOKUDB_DEBUG + + NULL +}; + +my_bool alter_print_error(THD* thd) { + return (THDVAR(thd, alter_print_error) != 0); +} +double analyze_delete_fraction(THD* thd) { + return THDVAR(thd, analyze_delete_fraction); +} +my_bool analyze_in_background(THD* thd) { + return (THDVAR(thd, analyze_in_background) != 0); +} +analyze_mode_t analyze_mode(THD* thd) { + return (analyze_mode_t ) THDVAR(thd, analyze_mode); +} +ulonglong analyze_throttle(THD* thd) { + return THDVAR(thd, analyze_throttle); +} +ulonglong analyze_time(THD* thd) { + return THDVAR(thd, analyze_time); +} +ulonglong auto_analyze(THD* thd) { + return THDVAR(thd, auto_analyze); +} +my_bool bulk_fetch(THD* thd) { + return (THDVAR(thd, bulk_fetch) != 0); +} +uint block_size(THD* thd) { + return THDVAR(thd, block_size); +} +my_bool commit_sync(THD* thd) { + return (THDVAR(thd, commit_sync) != 0); +} +my_bool create_index_online(THD* thd) { + return (THDVAR(thd, create_index_online) != 0); +} +my_bool disable_hot_alter(THD* thd) { + return (THDVAR(thd, disable_hot_alter) != 0); +} +my_bool disable_prefetching(THD* thd) { + return (THDVAR(thd, disable_prefetching) != 0); +} +my_bool disable_slow_alter(THD* thd) { + return (THDVAR(thd, disable_slow_alter) != 0); +} +#if TOKU_INCLUDE_UPSERT +my_bool disable_slow_update(THD* thd) { + return (THDVAR(thd, disable_slow_update) != 0); +} +my_bool disable_slow_upsert(THD* thd) { + return (THDVAR(thd, disable_slow_upsert) != 0); +} +#endif +empty_scan_mode_t empty_scan(THD* thd) { + return (empty_scan_mode_t)THDVAR(thd, empty_scan); +} +uint fanout(THD* thd) { + return THDVAR(thd, fanout); +} +my_bool hide_default_row_format(THD* thd) { + return (THDVAR(thd, hide_default_row_format) != 0); +} +ulonglong killed_time(THD* thd) { + return THDVAR(thd, killed_time); +} +char* last_lock_timeout(THD* thd) { + return THDVAR(thd, last_lock_timeout); +} +void set_last_lock_timeout(THD* thd, char* last) { + THDVAR(thd, last_lock_timeout) = last; +} +my_bool load_save_space(THD* thd) { + return (THDVAR(thd, load_save_space) != 0); +} +ulonglong loader_memory_size(THD* thd) { + return THDVAR(thd, loader_memory_size); +} +ulonglong lock_timeout(THD* thd) { + return THDVAR(thd, lock_timeout); +} +uint lock_timeout_debug(THD* thd) { + return THDVAR(thd, lock_timeout_debug); +} +double optimize_index_fraction(THD* thd) { + return THDVAR(thd, optimize_index_fraction); +} +const char* optimize_index_name(THD* thd) { + return THDVAR(thd, optimize_index_name); +} +ulonglong optimize_throttle(THD* thd) { + return THDVAR(thd, optimize_throttle); +} +uint pk_insert_mode(THD* thd) { + return THDVAR(thd, pk_insert_mode); +} +void set_pk_insert_mode(THD* thd, uint mode) { + THDVAR(thd, pk_insert_mode) = mode; +} +my_bool prelock_empty(THD* thd) { + return (THDVAR(thd, prelock_empty) != 0); +} +uint read_block_size(THD* thd) { + return THDVAR(thd, read_block_size); +} +uint read_buf_size(THD* thd) { + return THDVAR(thd, read_buf_size); +} +row_format_t row_format(THD *thd) { + return (row_format_t) THDVAR(thd, row_format); +} +my_bool rpl_check_readonly(THD* thd) { + return (THDVAR(thd, rpl_check_readonly) != 0); +} +my_bool rpl_lookup_rows(THD* thd) { + return (THDVAR(thd, rpl_lookup_rows) != 0); +} +ulonglong rpl_lookup_rows_delay(THD* thd) { + return THDVAR(thd, rpl_lookup_rows_delay); +} +my_bool rpl_unique_checks(THD* thd) { + return (THDVAR(thd, rpl_unique_checks) != 0); +} +ulonglong rpl_unique_checks_delay(THD* thd) { + return THDVAR(thd, rpl_unique_checks_delay); +} +my_bool support_xa(THD* thd) { + return (THDVAR(thd, support_xa) != 0); +} + +#if TOKU_INCLUDE_OPTION_STRUCTS +ha_create_table_option tokudb_table_options[] = { + HA_TOPTION_SYSVAR("compression", row_format, row_format), + HA_TOPTION_END +}; + +ha_create_table_option tokudb_index_options[] = { + HA_IOPTION_BOOL("clustering", clustering, 0), + HA_IOPTION_END +}; +#endif + +} // namespace sysvars +} // namespace tokudb diff --git a/storage/tokudb/tokudb_sysvars.h b/storage/tokudb/tokudb_sysvars.h new file mode 100644 index 00000000000..3bd96f7c68d --- /dev/null +++ b/storage/tokudb/tokudb_sysvars.h @@ -0,0 +1,171 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_SYSVARS_H +#define _TOKUDB_SYSVARS_H + +#if TOKU_INCLUDE_OPTION_STRUCTS +struct ha_table_option_struct { + uint row_format; +}; + +struct ha_index_option_struct { + bool clustering; +}; + +static inline bool key_is_clustering(const KEY *key) { + return (key->flags & HA_CLUSTERING) || (key->option_struct && key->option_struct->clustering); +} + +#else + +static inline bool key_is_clustering(const KEY *key) { + return key->flags & HA_CLUSTERING; +} +#endif + +namespace tokudb { +namespace sysvars { + +enum analyze_mode_t { + TOKUDB_ANALYZE_STANDARD = 0, + TOKUDB_ANALYZE_RECOUNT_ROWS = 1, + TOKUDB_ANALYZE_CANCEL = 2 +}; + +enum empty_scan_mode_t { + TOKUDB_EMPTY_SCAN_DISABLED = 0, + TOKUDB_EMPTY_SCAN_LR = 1, + TOKUDB_EMPTY_SCAN_RL = 2, +}; + +enum row_format_t { + SRV_ROW_FORMAT_UNCOMPRESSED = 0, + SRV_ROW_FORMAT_ZLIB = 1, + SRV_ROW_FORMAT_SNAPPY = 2, + SRV_ROW_FORMAT_QUICKLZ = 3, + SRV_ROW_FORMAT_LZMA = 4, + SRV_ROW_FORMAT_FAST = 5, + SRV_ROW_FORMAT_SMALL = 6, + SRV_ROW_FORMAT_DEFAULT = 7 +}; + +#define DEFAULT_TOKUDB_CLEANER_ITERATIONS 5 +#define DEFAULT_TOKUDB_CLEANER_PERIOD 1 +#define DEFAULT_TOKUDB_KILLED_TIME 4000 // milliseconds +#define DEFAULT_TOKUDB_LOCK_TIMEOUT 4000 // milliseconds + + +// globals +extern ulonglong cache_size; +extern uint cachetable_pool_threads; +extern int cardinality_scale_percent; +extern my_bool checkpoint_on_flush_logs; +extern uint checkpoint_pool_threads; +extern uint checkpointing_period; +extern ulong cleaner_iterations; +extern ulong cleaner_period; +extern uint client_pool_threads; +extern my_bool compress_buffers_before_eviction; +extern char* data_dir; +extern ulong debug; +extern my_bool directio; +extern my_bool enable_partial_eviction; +extern int fs_reserve_percent; +extern uint fsync_log_period; +extern char* log_dir; +extern ulonglong max_lock_memory; +extern uint read_status_frequency; +extern my_bool strip_frm_data; +extern char* tmp_dir; +extern uint write_status_frequency; +extern char* version; + +#if TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL +extern char* gdb_path; +extern my_bool gdb_on_fatal; +#endif + +extern my_bool check_jemalloc; + +#if TOKUDB_DEBUG +// used to control background job manager +extern my_bool debug_pause_background_job_manager; +#endif // TOKUDB_DEBUG + +// session/thread +my_bool alter_print_error(THD* thd); +double analyze_delete_fraction(THD* thd); +my_bool analyze_in_background(THD* thd); +analyze_mode_t analyze_mode(THD* thd); +ulonglong analyze_throttle(THD* thd); +ulonglong analyze_time(THD* thd); +ulonglong auto_analyze(THD* thd); +uint block_size(THD* thd); +my_bool bulk_fetch(THD* thd); +my_bool commit_sync(THD* thd); +my_bool create_index_online(THD* thd); +my_bool disable_hot_alter(THD* thd); +my_bool disable_prefetching(THD* thd); +my_bool disable_slow_alter(THD* thd); +my_bool disable_slow_update(THD* thd); +my_bool disable_slow_upsert(THD* thd); +empty_scan_mode_t empty_scan(THD* thd); +uint fanout(THD* thd); +my_bool hide_default_row_format(THD* thd); +ulonglong killed_time(THD* thd); +my_bool load_save_space(THD* thd); +char* last_lock_timeout(THD* thd); +void set_last_lock_timeout(THD* thd, char* last); +ulonglong loader_memory_size(THD* thd); +ulonglong lock_timeout(THD* thd); +uint lock_timeout_debug(THD* thd); +double optimize_index_fraction(THD* thd); +const char* optimize_index_name(THD* thd); +ulonglong optimize_throttle(THD* thd); +uint pk_insert_mode(THD* thd); +void set_pk_insert_mode(THD* thd, uint mode); +my_bool prelock_empty(THD* thd); +uint read_block_size(THD* thd); +uint read_buf_size(THD* thd); +row_format_t row_format(THD *thd); +my_bool rpl_check_readonly(THD* thd); +my_bool rpl_lookup_rows(THD* thd); +ulonglong rpl_lookup_rows_delay(THD* thd); +my_bool rpl_unique_checks(THD* thd); +ulonglong rpl_unique_checks_delay(THD* thd); +my_bool support_xa(THD* thd); + +extern st_mysql_sys_var* system_variables[]; + +#if TOKU_INCLUDE_OPTION_STRUCTS +extern ha_create_table_option tokudb_table_options[]; +extern ha_create_table_option tokudb_index_options[]; +#endif + +} // namespace sysvars +} // namespace tokudb + +#endif // _TOKUDB_SYSVARS_H diff --git a/storage/tokudb/tokudb_thread.cc b/storage/tokudb/tokudb_thread.cc new file mode 100644 index 00000000000..f27e803a065 --- /dev/null +++ b/storage/tokudb/tokudb_thread.cc @@ -0,0 +1,35 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#include "tokudb_thread.h" + +namespace tokudb { +namespace thread { + +pthread_t mutex_t::_null_owner = 0; + +} // namespace thread +} // namespace tokudb diff --git a/storage/tokudb/tokudb_thread.h b/storage/tokudb/tokudb_thread.h new file mode 100644 index 00000000000..dcb1fd6ec63 --- /dev/null +++ b/storage/tokudb/tokudb_thread.h @@ -0,0 +1,597 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_SYNC_H +#define _TOKUDB_SYNC_H + +#include "hatoku_defines.h" +#include "tokudb_debug.h" +#include "tokudb_time.h" + +namespace tokudb { +namespace thread { + +#if (defined(__MACH__) || defined(__APPLE__)) && _POSIX_TIMERS <= 0 + +#define _x_min(a, b) ((a) < (b) ? (a) : (b)) + +#define timed_lock_define(timed_func_name, lock_type_name, lock_func_name) \ +inline int timed_func_name(lock_type_name *mutex, \ + const struct timespec *abs_timeout) { \ + int pthread_rc; \ + struct timespec remaining, slept, ts; \ + static const int sleep_step = 1000000; \ + \ + remaining = *abs_timeout; \ + while ((pthread_rc = lock_func_name(mutex)) == EBUSY) { \ + ts.tv_sec = 0; \ + ts.tv_nsec = (remaining.tv_sec > 0 ? \ + sleep_step : \ + _x_min(remaining.tv_nsec,sleep_step)); \ + nanosleep(&ts, &slept); \ + ts.tv_nsec -= slept.tv_nsec; \ + if (ts.tv_nsec <= remaining.tv_nsec) { \ + remaining.tv_nsec -= ts.tv_nsec; \ + } else { \ + remaining.tv_sec--; \ + remaining.tv_nsec = \ + (sleep_step - (ts.tv_nsec - remaining.tv_nsec)); \ + } \ + if (remaining.tv_sec < 0 || \ + (!remaining.tv_sec && remaining.tv_nsec <= 0)) { \ + return ETIMEDOUT; \ + } \ + } \ + \ + return pthread_rc; \ +} + +timed_lock_define(pthread_mutex_timedlock, + pthread_mutex_t, + pthread_mutex_trylock); + +timed_lock_define(pthread_rwlock_timedrdlock, + pthread_rwlock_t, + pthread_rwlock_tryrdlock); + +timed_lock_define(pthread_rwlock_timedwrlock, + pthread_rwlock_t, + pthread_rwlock_trywrlock); + +#endif //(defined(__MACH__) || defined(__APPLE__)) && _POSIX_TIMERS <= 0 + +uint my_tid(void); + +// Your basic mutex +class mutex_t { +public: + mutex_t(void); + ~mutex_t(void); + + void lock(void); + int lock(ulonglong microseconds); + void unlock(void); +#ifdef TOKUDB_DEBUG + bool is_owned_by_me(void) const; +#endif +private: + static pthread_t _null_owner; + pthread_mutex_t _mutex; +#ifdef TOKUDB_DEBUG + uint _owners; + pthread_t _owner; +#endif +}; + +// Simple read write lock +class rwlock_t { +public: + rwlock_t(void); + ~rwlock_t(void); + + void lock_read(void); + int lock_read(ulonglong microseconds); + void lock_write(void); + int lock_write(ulonglong microseconds); + void unlock(void); + +private: + rwlock_t(const rwlock_t&); + rwlock_t& operator=(const rwlock_t&); + + pthread_rwlock_t _rwlock; +}; + +// Simple event signal/wait class +class event_t { +public: + // create_signalled - create the event in a signalled state + // manual_reset - create an event that must be manually reset + // after signaling + event_t( + bool create_signalled = false, + bool manual_reset = false); + ~event_t(void); + + // wait for the event to become signalled + void wait(void); + int wait(ulonglong microseconds); + + // signal the event + void signal(void); + + // pulse the event (signal and free exactly one waiter) + void pulse(void); + + // is the event currently signalled + bool signalled(void); + + // unsignal/clear the event + void reset(void); + +private: + event_t(const event_t&); + event_t& operator=(const event_t&); + + pthread_mutex_t _mutex; + pthread_cond_t _cond; + bool _signalled; + bool _pulsed; + bool _manual_reset; +}; + +// Semaphore signal/wait class +class semaphore_t { +public: + // initial_count - the initial signal count of the semaphore + // max_count - the maximum signal count for the semaphore. + semaphore_t(int initial_count, int max_count); + ~semaphore_t(void); + + enum E_WAIT { + E_SIGNALLED = 0, + E_INTERRUPTED = 1, + E_TIMEDOUT = 2 + }; + + // wait for the semaphore to become signalled + E_WAIT wait(void); + E_WAIT wait(ulonglong microseconds); + + // signal the semaphore to increase the count + // return true if signalled, false if ignored due to count + bool signal(void); + + // what is the semaphore signal count + int signalled(void); + + // unsignal a signalled semaphore + void reset(void); + + // set to interrupt any waiters, as long as is set, + // waiters will return immediately with E_INTERRUPTED. + // the semaphore signal count and tracking will continue + // accepting signals and leave the signalled state intact + void set_interrupt(void); + void clear_interrupt(void); + +private: + semaphore_t(const semaphore_t&); + semaphore_t& operator=(const semaphore_t&); + + pthread_mutex_t _mutex; + pthread_cond_t _cond; + bool _interrupted; + int _signalled; + int _initial_count; + int _max_count; +}; + +// Thread class +class thread_t { +public: + thread_t(void); + ~thread_t(void); + + int start(void* (*pfn)(void*), void* arg); + int join(void** value_ptr); + int detach(void); + +private: + pthread_t _thread; +}; + + +inline uint my_tid(void) { + return (uint)toku_os_gettid(); +} + + +inline mutex_t::mutex_t(void) { + #ifdef TOKUDB_DEBUG + _owners = 0; + _owner = _null_owner; + #endif + int r = pthread_mutex_init(&_mutex, MY_MUTEX_INIT_FAST); + assert_debug(r == 0); +} +inline mutex_t::~mutex_t(void) { + #ifdef TOKUDB_DEBUG + assert_debug(_owners == 0); + #endif + int r = pthread_mutex_destroy(&_mutex); + assert_debug(r == 0); +} +inline void mutex_t::lock(void) { + assert_debug(is_owned_by_me() == false); + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + #ifdef TOKUDB_DEBUG + _owners++; + _owner = pthread_self(); + #endif +} +inline int mutex_t::lock(ulonglong microseconds) { + assert_debug(is_owned_by_me() == false); + timespec waittime = time::offset_timespec(microseconds); + int r = pthread_mutex_timedlock(&_mutex, &waittime); + #ifdef TOKUDB_DEBUG + if (r == 0) { + _owners++; + _owner = pthread_self(); + } + #endif + assert_debug(r == 0 || r == ETIMEDOUT); + return r; +} +inline void mutex_t::unlock(void) { + #ifdef TOKUDB_DEBUG + assert_debug(_owners > 0); + assert_debug(is_owned_by_me()); + _owners--; + _owner = _null_owner; + #endif + int r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); +} +#ifdef TOKUDB_DEBUG +inline bool mutex_t::is_owned_by_me(void) const { + return pthread_equal(pthread_self(), _owner) != 0 ? true : false; +} +#endif + + +inline rwlock_t::rwlock_t(void) { + int r = pthread_rwlock_init(&_rwlock, NULL); + assert_debug(r == 0); +} +inline rwlock_t::~rwlock_t(void) { + int r = pthread_rwlock_destroy(&_rwlock); + assert_debug(r == 0); +} +inline void rwlock_t::lock_read(void) { + int r; + while ((r = pthread_rwlock_rdlock(&_rwlock)) != 0) { + if (r == EBUSY || r == EAGAIN) { + time::sleep_microsec(1000); + continue; + } + break; + } + assert_debug(r == 0); +} +inline int rwlock_t::lock_read(ulonglong microseconds) { + int r; + timespec waittime = time::offset_timespec(microseconds); + while ((r = pthread_rwlock_timedrdlock(&_rwlock, &waittime)) != 0) { + if (r == EBUSY || r == EAGAIN) { + time::sleep_microsec(1000); + continue; + } else if (r == ETIMEDOUT) { + return ETIMEDOUT; + } + break; + } + assert_debug(r == 0); + return r; +} +inline void rwlock_t::lock_write(void) { + int r; + while ((r = pthread_rwlock_wrlock(&_rwlock)) != 0) { + if (r == EBUSY || r == EAGAIN) { + time::sleep_microsec(1000); + continue; + } + break; + } + assert_debug(r == 0); +} +inline int rwlock_t::lock_write(ulonglong microseconds) { + int r; + timespec waittime = time::offset_timespec(microseconds); + while ((r = pthread_rwlock_timedwrlock(&_rwlock, &waittime)) != 0) { + if (r == EBUSY || r == EAGAIN) { + time::sleep_microsec(1000); + continue; + } else if (r == ETIMEDOUT) { + return ETIMEDOUT; + } + break; + } + assert_debug(r == 0); + return r; +} +inline void rwlock_t::unlock(void) { + int r = pthread_rwlock_unlock(&_rwlock); + assert_debug(r == 0); +} +inline rwlock_t::rwlock_t(const rwlock_t&) { +} +inline rwlock_t& rwlock_t::operator=(const rwlock_t&) { + return *this; +} + + +inline event_t::event_t(bool create_signalled, bool manual_reset) : + _manual_reset(manual_reset) { + + int r = pthread_mutex_init(&_mutex, NULL); + assert_debug(r == 0); + r = pthread_cond_init(&_cond, NULL); + assert_debug(r == 0); + if (create_signalled) { + _signalled = true; + } else { + _signalled = false; + } + _pulsed = false; +} +inline event_t::~event_t(void) { + int r = pthread_mutex_destroy(&_mutex); + assert_debug(r == 0); + r = pthread_cond_destroy(&_cond); + assert_debug(r == 0); +} +inline void event_t::wait(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + while (_signalled == false && _pulsed == false) { + r = pthread_cond_wait(&_cond, &_mutex); + assert_debug(r == 0); + } + if (_manual_reset == false) + _signalled = false; + if (_pulsed) + _pulsed = false; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return; +} +inline int event_t::wait(ulonglong microseconds) { + timespec waittime = time::offset_timespec(microseconds); + int r = pthread_mutex_timedlock(&_mutex, &waittime); + if (r == ETIMEDOUT) return ETIMEDOUT; + assert_debug(r == 0); + while (_signalled == false && _pulsed == false) { + r = pthread_cond_timedwait(&_cond, &_mutex, &waittime); + if (r == ETIMEDOUT) { + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return ETIMEDOUT; + } + assert_debug(r == 0); + } + if (_manual_reset == false) + _signalled = false; + if (_pulsed) + _pulsed = false; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return 0; +} +inline void event_t::signal(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + _signalled = true; + if (_manual_reset) { + r = pthread_cond_broadcast(&_cond); + assert_debug(r == 0); + } else { + r = pthread_cond_signal(&_cond); + assert_debug(r == 0); + } + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); +} +inline void event_t::pulse(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + _pulsed = true; + r = pthread_cond_signal(&_cond); + assert_debug(r == 0); + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); +} +inline bool event_t::signalled(void) { + bool ret = false; + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + ret = _signalled; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return ret; +} +inline void event_t::reset(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + _signalled = false; + _pulsed = false; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return; +} +inline event_t::event_t(const event_t&) { +} +inline event_t& event_t::operator=(const event_t&) { + return *this; +} + + +inline semaphore_t::semaphore_t( + int initial_count, + int max_count) : + _interrupted(false), + _initial_count(initial_count), + _max_count(max_count) { + + int r = pthread_mutex_init(&_mutex, NULL); + assert_debug(r == 0); + r = pthread_cond_init(&_cond, NULL); + assert_debug(r == 0); + _signalled = _initial_count; +} +inline semaphore_t::~semaphore_t(void) { + int r = pthread_mutex_destroy(&_mutex); + assert_debug(r == 0); + r = pthread_cond_destroy(&_cond); + assert_debug(r == 0); +} +inline semaphore_t::E_WAIT semaphore_t::wait(void) { + E_WAIT ret; + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + while (_signalled == 0 && _interrupted == false) { + r = pthread_cond_wait(&_cond, &_mutex); + assert_debug(r == 0); + } + if (_interrupted) { + ret = E_INTERRUPTED; + } else { + _signalled--; + ret = E_SIGNALLED; + } + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return ret; +} +inline semaphore_t::E_WAIT semaphore_t::wait(ulonglong microseconds) { + E_WAIT ret; + timespec waittime = time::offset_timespec(microseconds); + int r = pthread_mutex_timedlock(&_mutex, &waittime); + if (r == ETIMEDOUT) return E_TIMEDOUT; + assert_debug(r == 0); + while (_signalled == 0 && _interrupted == false) { + r = pthread_cond_timedwait(&_cond, &_mutex, &waittime); + if (r == ETIMEDOUT) { + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return E_TIMEDOUT; + } + assert_debug(r == 0); + } + if (_interrupted) { + ret = E_INTERRUPTED; + } else { + _signalled--; + ret = E_SIGNALLED; + } + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return ret; +} +inline bool semaphore_t::signal(void) { + bool ret = false; + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + if (_signalled < _max_count) { + _signalled++; + ret = true; + } + r = pthread_cond_signal(&_cond); + assert_debug(r == 0); + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return ret; +} +inline int semaphore_t::signalled(void) { + int ret = 0; + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + ret = _signalled; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return ret; +} +inline void semaphore_t::reset(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + _signalled = 0; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); + return; +} +inline void semaphore_t::set_interrupt(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + _interrupted = true; + r = pthread_cond_broadcast(&_cond); + assert_debug(r == 0); + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); +} +inline void semaphore_t::clear_interrupt(void) { + int r = pthread_mutex_lock(&_mutex); + assert_debug(r == 0); + _interrupted = false; + r = pthread_mutex_unlock(&_mutex); + assert_debug(r == 0); +} +inline semaphore_t::semaphore_t(const semaphore_t&) { +} +inline semaphore_t& semaphore_t::operator=(const semaphore_t&) { + return *this; +} + + +inline thread_t::thread_t(void) : _thread(0) { +} +inline thread_t::~thread_t(void) { +} +inline int thread_t::start(void*(*pfn)(void*), void* arg) { + return pthread_create(&_thread, NULL, pfn, arg); +} +inline int thread_t::join(void** value_ptr) { + return pthread_join(_thread, value_ptr); +} +inline int thread_t::detach(void) { + return pthread_detach(_thread); +} + +} // namespace thread +} // namespace tokudb + + +#endif // _TOKUDB_SYNC_H diff --git a/storage/tokudb/tokudb_time.h b/storage/tokudb/tokudb_time.h new file mode 100644 index 00000000000..12baa0de24d --- /dev/null +++ b/storage/tokudb/tokudb_time.h @@ -0,0 +1,73 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_TIME_H +#define _TOKUDB_TIME_H + +#include "hatoku_defines.h" + +namespace tokudb { +namespace time { + +static const ulonglong MILLISECONDS = 1000; +static const ulonglong MICROSECONDS = 1000000; +static const ulonglong NANOSECONDS = 1000000000; + +// gets curent time of day in microseconds +ulonglong microsec(void); + +// gets a timespec in the future based on the current time and an offset forward +timespec offset_timespec(ulonglong offset); + +// sleep microseconds +void sleep_microsec(ulong tm); + + + +inline ulonglong microsec(void) { + timeval t; + gettimeofday(&t, NULL); + return t.tv_sec * (1UL * 1000 * 1000) + t.tv_usec; +} +inline timespec offset_timespec(ulonglong offset) { + timespec ret; + ulonglong tm = offset + microsec(); + ret.tv_sec = tm / MICROSECONDS; + ret.tv_nsec = (tm % MICROSECONDS) * 1000; + return ret; +} +inline void sleep_microsec(ulong tm) { + timeval t; + t.tv_sec = tm / MICROSECONDS; + t.tv_usec = tm % MICROSECONDS; + + select(0, NULL, NULL, NULL, &t); +} + +} // namespace time +} // namespace tokudb + +#endif // _TOKUDB_TIME_H diff --git a/storage/tokudb/tokudb_txn.h b/storage/tokudb/tokudb_txn.h new file mode 100644 index 00000000000..67bf591d088 --- /dev/null +++ b/storage/tokudb/tokudb_txn.h @@ -0,0 +1,155 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +/* -*- mode: C; c-basic-offset: 4 -*- */ +#ident "$Id$" +/*====== +This file is part of TokuDB + + +Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. + + TokuDBis is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, + as published by the Free Software Foundation. + + TokuDB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with TokuDB. If not, see . + +======= */ + +#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." + +#ifndef _TOKUDB_TXN_H +#define _TOKUDB_TXN_H + +#include "hatoku_defines.h" +#include "tokudb_debug.h" +#include "tokudb_sysvars.h" + +typedef enum { + hatoku_iso_not_set = 0, + hatoku_iso_read_uncommitted, + hatoku_iso_read_committed, + hatoku_iso_repeatable_read, + hatoku_iso_serializable +} HA_TOKU_ISO_LEVEL; + +typedef struct st_tokudb_stmt_progress { + ulonglong inserted; + ulonglong updated; + ulonglong deleted; + ulonglong queried; + bool using_loader; +} tokudb_stmt_progress; + +typedef struct st_tokudb_trx_data { + DB_TXN* all; + DB_TXN* stmt; + DB_TXN* sp_level; + DB_TXN* sub_sp_level; + uint tokudb_lock_count; + uint create_lock_count; + tokudb_stmt_progress stmt_progress; + bool checkpoint_lock_taken; + LIST* handlers; +} tokudb_trx_data; + +extern char* tokudb_data_dir; +extern const char* ha_tokudb_ext; + +inline void reset_stmt_progress(tokudb_stmt_progress* val) { + val->deleted = 0; + val->inserted = 0; + val->updated = 0; + val->queried = 0; +} + +inline int get_name_length(const char* name) { + int n = 0; + const char* newname = name; + n += strlen(newname); + n += strlen(ha_tokudb_ext); + return n; +} + +// +// returns maximum length of path to a dictionary +// +inline int get_max_dict_name_path_length(const char* tablename) { + int n = 0; + n += get_name_length(tablename); + n += 1; //for the '-' + n += MAX_DICT_NAME_LEN; + return n; +} + +inline void make_name( + char* newname, + size_t newname_len, + const char* tablename, + const char* dictname) { + + assert_always(tablename); + assert_always(dictname); + size_t real_size = snprintf( + newname, + newname_len, + "%s-%s", + tablename, + dictname); + assert_always(real_size < newname_len); +} + +inline int txn_begin( + DB_ENV* env, + DB_TXN* parent, + DB_TXN** txn, + uint32_t flags, + THD* thd) { + + *txn = NULL; + int r = env->txn_begin(env, parent, txn, flags); + if (r == 0 && thd) { + DB_TXN* this_txn = *txn; + this_txn->set_client_id(this_txn, thd_get_thread_id(thd)); + } + TOKUDB_TRACE_FOR_FLAGS( + TOKUDB_DEBUG_TXN, + "begin txn %p %p %u r=%d", + parent, + *txn, + flags, + r); + return r; +} + +inline void commit_txn(DB_TXN* txn, uint32_t flags) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "commit txn %p", txn); + int r = txn->commit(txn, flags); + if (r != 0) { + sql_print_error( + "tried committing transaction %p and got error code %d", + txn, + r); + } + assert_always(r == 0); +} + +inline void abort_txn(DB_TXN* txn) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_TXN, "abort txn %p", txn); + int r = txn->abort(txn); + if (r != 0) { + sql_print_error( + "tried aborting transaction %p and got error code %d", + txn, + r); + } + assert_always(r == 0); +} + +#endif // _TOKUDB_TXN_H diff --git a/storage/tokudb/tokudb_update_fun.cc b/storage/tokudb/tokudb_update_fun.cc index 4647c91880b..05149d17317 100644 --- a/storage/tokudb/tokudb_update_fun.cc +++ b/storage/tokudb/tokudb_update_fun.cc @@ -105,7 +105,8 @@ enum { // at most, 4 0's // So, upperbound is num_blobs(1+4+1+4) = num_columns*10 -// The expand varchar offsets message is used to expand the size of an offset from 1 to 2 bytes. Not VLQ coded. +// The expand varchar offsets message is used to expand the size of an offset +// from 1 to 2 bytes. Not VLQ coded. // uint8 operation = UPDATE_OP_EXPAND_VARIABLE_OFFSETS // uint32 number of offsets // uint32 starting offset of the variable length field offsets @@ -132,8 +133,8 @@ enum { // uint8 old lengths[N] // uint8 new lengths[N] -// Update and Upsert version 1 messages. Not VLQ coded. Not used anymore, but may be in the -// fractal tree from a previous build. +// Update and Upsert version 1 messages. Not VLQ coded. Not used anymore, but +// may be in the fractal tree from a previous build. // // Field descriptor: // Operations: @@ -143,8 +144,10 @@ enum { // x = x - k // field type 4 see field types above // unused 4 unused -// field null num 4 bit 31 is 1 if the field is nullible and the remaining bits contain the null bit number -// field offset 4 for fixed fields, this is the offset from begining of the row of the field +// field null num 4 bit 31 is 1 if the field is nullible and the +// remaining bits contain the null bit number +// field offset 4 for fixed fields, this is the offset from +// begining of the row of the field // value: // value length 4 == N, length of the value // value N value to add or subtract @@ -234,7 +237,11 @@ static inline bool is_overall_null_position_set(uchar* data, uint32_t pos) { // // sets the bit at index pos in data to 1 if is_null, 0 otherwise // -static inline void set_overall_null_position(uchar* data, uint32_t pos, bool is_null) { +static inline void set_overall_null_position( + uchar* data, + uint32_t pos, + bool is_null) { + uint32_t offset = pos/8; uchar remainder = pos%8; uchar null_bit = 1<size + extra->size + new_len_of_offsets + new_fixed_field_size; - new_val_data = (uchar *)tokudb_my_malloc( - max_num_bytes, - MYF(MY_FAE) - ); - if (new_val_data == NULL) { goto cleanup; } + max_num_bytes = + old_val->size + extra->size + new_len_of_offsets + new_fixed_field_size; + new_val_data = (uchar *)tokudb::memory::malloc( + max_num_bytes, + MYF(MY_FAE)); + if (new_val_data == NULL) { + error = ENOMEM; + goto cleanup; + } old_fixed_field_ptr = (uchar *) old_val->data; old_fixed_field_ptr += old_num_null_bytes; @@ -465,7 +486,7 @@ static int tokudb_hcad_update_fun( bool is_null_default = false; extra_pos++; - assert(op_type == COL_DROP || op_type == COL_ADD); + assert_always(op_type == COL_DROP || op_type == COL_ADD); bool nullable = (extra_pos[0] != 0); extra_pos++; if (nullable) { @@ -474,11 +495,10 @@ static int tokudb_hcad_update_fun( extra_pos += sizeof(uint32_t); uint32_t num_bits; if (op_type == COL_DROP) { - assert(curr_old_null_pos <= null_bit_position); + assert_always(curr_old_null_pos <= null_bit_position); num_bits = null_bit_position - curr_old_null_pos; - } - else { - assert(curr_new_null_pos <= null_bit_position); + } else { + assert_always(curr_new_null_pos <= null_bit_position); num_bits = null_bit_position - curr_new_null_pos; } copy_null_bits( @@ -486,22 +506,19 @@ static int tokudb_hcad_update_fun( curr_new_null_pos, num_bits, old_null_bytes, - new_null_bytes - ); + new_null_bytes); // update the positions curr_new_null_pos += num_bits; curr_old_null_pos += num_bits; if (op_type == COL_DROP) { curr_old_null_pos++; // account for dropped column - } - else { + } else { is_null_default = (extra_pos[0] != 0); extra_pos++; set_overall_null_position( new_null_bytes, null_bit_position, - is_null_default - ); + is_null_default); curr_new_null_pos++; //account for added column } } @@ -518,47 +535,44 @@ static int tokudb_hcad_update_fun( if (op_type == COL_DROP) { num_bytes_to_copy = col_offset - curr_old_fixed_offset; - } - else { + } else { num_bytes_to_copy = col_offset - curr_new_fixed_offset; } memcpy( new_fixed_field_ptr + curr_new_fixed_offset, - old_fixed_field_ptr + curr_old_fixed_offset, - num_bytes_to_copy - ); + old_fixed_field_ptr + curr_old_fixed_offset, + num_bytes_to_copy); curr_old_fixed_offset += num_bytes_to_copy; curr_new_fixed_offset += num_bytes_to_copy; if (op_type == COL_DROP) { - // move old_fixed_offset val to skip OVER column that is being dropped + // move old_fixed_offset val to skip OVER column that is + // being dropped curr_old_fixed_offset += col_size; - } - else { + } else { if (is_null_default) { // copy zeroes - memset(new_fixed_field_ptr + curr_new_fixed_offset, 0, col_size); - } - else { + memset( + new_fixed_field_ptr + curr_new_fixed_offset, + 0, + col_size); + } else { // copy data from extra_pos into new row memcpy( new_fixed_field_ptr + curr_new_fixed_offset, extra_pos, - col_size - ); + col_size); extra_pos += col_size; } curr_new_fixed_offset += col_size; } - } - else if (col_type == COL_VAR) { + } else if (col_type == COL_VAR) { uint32_t var_col_index; memcpy(&var_col_index, extra_pos, sizeof(uint32_t)); extra_pos += sizeof(uint32_t); if (op_type == COL_DROP) { num_var_fields_to_copy = var_col_index - curr_old_num_var_field; - } - else { + } else { num_var_fields_to_copy = var_col_index - curr_new_num_var_field; } copy_var_fields( @@ -568,20 +582,21 @@ static int tokudb_hcad_update_fun( old_num_offset_bytes, curr_new_var_field_data_ptr, curr_new_var_field_offset_ptr, - new_var_field_data_ptr, // pointer to beginning of var fields in new row - old_var_field_data_ptr, // pointer to beginning of var fields in old row - new_num_offset_bytes, // number of offset bytes used in new row + // pointer to beginning of var fields in new row + new_var_field_data_ptr, + // pointer to beginning of var fields in old row + old_var_field_data_ptr, + // number of offset bytes used in new row + new_num_offset_bytes, &num_data_bytes_written, - &num_offset_bytes_written - ); + &num_offset_bytes_written); curr_new_var_field_data_ptr += num_data_bytes_written; curr_new_var_field_offset_ptr += num_offset_bytes_written; curr_new_num_var_field += num_var_fields_to_copy; curr_old_num_var_field += num_var_fields_to_copy; if (op_type == COL_DROP) { curr_old_num_var_field++; // skip over dropped field - } - else { + } else { if (is_null_default) { curr_new_var_field_data_ptr = write_var_field( curr_new_var_field_offset_ptr, @@ -589,11 +604,9 @@ static int tokudb_hcad_update_fun( new_var_field_data_ptr, NULL, //copying no data 0, //copying 0 bytes - new_num_offset_bytes - ); + new_num_offset_bytes); curr_new_var_field_offset_ptr += new_num_offset_bytes; - } - else { + } else { uint32_t data_length; memcpy(&data_length, extra_pos, sizeof(data_length)); extra_pos += sizeof(data_length); @@ -603,20 +616,17 @@ static int tokudb_hcad_update_fun( new_var_field_data_ptr, extra_pos, //copying data from mutator data_length, //copying data_length bytes - new_num_offset_bytes - ); + new_num_offset_bytes); extra_pos += data_length; curr_new_var_field_offset_ptr += new_num_offset_bytes; } curr_new_num_var_field++; //account for added column } - } - else if (col_type == COL_BLOB) { + } else if (col_type == COL_BLOB) { // handle blob data later continue; - } - else { - assert(false); + } else { + assert_unreachable(); } } // finish copying the null stuff @@ -629,19 +639,17 @@ static int tokudb_hcad_update_fun( curr_new_null_pos, overall_null_bits_left, old_null_bytes, - new_null_bytes - ); + new_null_bytes); // finish copying fixed field stuff num_bytes_left = old_fixed_field_size - curr_old_fixed_offset; memcpy( new_fixed_field_ptr + curr_new_fixed_offset, old_fixed_field_ptr + curr_old_fixed_offset, - num_bytes_left - ); + num_bytes_left); curr_old_fixed_offset += num_bytes_left; curr_new_fixed_offset += num_bytes_left; // sanity check - assert(curr_new_fixed_offset == new_fixed_field_size); + assert_always(curr_new_fixed_offset == new_fixed_field_size); // finish copying var field stuff num_var_fields_to_copy = old_num_var_fields - curr_old_num_var_field; @@ -652,33 +660,34 @@ static int tokudb_hcad_update_fun( old_num_offset_bytes, curr_new_var_field_data_ptr, curr_new_var_field_offset_ptr, - new_var_field_data_ptr, // pointer to beginning of var fields in new row - old_var_field_data_ptr, // pointer to beginning of var fields in old row - new_num_offset_bytes, // number of offset bytes used in new row + // pointer to beginning of var fields in new row + new_var_field_data_ptr, + // pointer to beginning of var fields in old row + old_var_field_data_ptr, + // number of offset bytes used in new row + new_num_offset_bytes, &num_data_bytes_written, - &num_offset_bytes_written - ); + &num_offset_bytes_written); curr_new_var_field_offset_ptr += num_offset_bytes_written; curr_new_var_field_data_ptr += num_data_bytes_written; // sanity check - assert(curr_new_var_field_offset_ptr == new_var_field_data_ptr); + assert_always(curr_new_var_field_offset_ptr == new_var_field_data_ptr); // start handling blobs get_blob_field_info( &start_blob_offset, old_len_of_offsets, old_var_field_data_ptr, - old_num_offset_bytes - ); + old_num_offset_bytes); start_blob_ptr = old_var_field_data_ptr + start_blob_offset; - // if nothing else in extra, then there are no blobs to add or drop, so can copy blobs straight + // if nothing else in extra, then there are no blobs to add or drop, so + // can copy blobs straight if ((extra_pos - extra_pos_start) == extra->size) { num_blob_bytes = old_val->size - (start_blob_ptr - old_null_bytes); memcpy(curr_new_var_field_data_ptr, start_blob_ptr, num_blob_bytes); curr_new_var_field_data_ptr += num_blob_bytes; - } - // else, there is blob information to process - else { + } else { + // else, there is blob information to process uchar* len_bytes = NULL; uint32_t curr_old_blob = 0; uint32_t curr_new_blob = 0; @@ -696,11 +705,10 @@ static int tokudb_hcad_update_fun( uint32_t blob_index; memcpy(&blob_index, extra_pos, sizeof(blob_index)); extra_pos += sizeof(blob_index); - assert (op_type == COL_DROP || op_type == COL_ADD); + assert_always (op_type == COL_DROP || op_type == COL_ADD); if (op_type == COL_DROP) { num_blobs_to_copy = blob_index - curr_old_blob; - } - else { + } else { num_blobs_to_copy = blob_index - curr_new_blob; } for (uint32_t i = 0; i < num_blobs_to_copy; i++) { @@ -708,8 +716,7 @@ static int tokudb_hcad_update_fun( curr_new_var_field_data_ptr, curr_old_blob_ptr, len_bytes[curr_old_blob + i], - false - ); + false); curr_old_blob_ptr += num_bytes_written; curr_new_var_field_data_ptr += num_bytes_written; } @@ -721,12 +728,10 @@ static int tokudb_hcad_update_fun( NULL, curr_old_blob_ptr, len_bytes[curr_old_blob], - true - ); + true); curr_old_blob++; curr_old_blob_ptr += num_bytes; - } - else { + } else { // copy new data uint32_t new_len_bytes = extra_pos[0]; extra_pos++; @@ -734,8 +739,7 @@ static int tokudb_hcad_update_fun( curr_new_var_field_data_ptr, extra_pos, new_len_bytes, - false - ); + false); curr_new_blob++; curr_new_var_field_data_ptr += num_bytes; extra_pos += num_bytes; @@ -751,27 +755,27 @@ static int tokudb_hcad_update_fun( error = 0; cleanup: - tokudb_my_free(new_val_data); + tokudb::memory::free(new_val_data); return error; } -// Expand the variable offset array in the old row given the update mesage in the extra. +// Expand the variable offset array in the old row given the update mesage +// in the extra. static int tokudb_expand_variable_offsets( DB* db, - const DBT *key, - const DBT *old_val, - const DBT *extra, - void (*set_val)(const DBT *new_val, void *set_extra), - void *set_extra - ) -{ + const DBT* key, + const DBT* old_val, + const DBT* extra, + void (*set_val)(const DBT* new_val, void* set_extra), + void* set_extra) { + int error = 0; tokudb::buffer extra_val(extra->data, 0, extra->size); // decode the operation uint8_t operation; extra_val.consume(&operation, sizeof operation); - assert(operation == UPDATE_OP_EXPAND_VARIABLE_OFFSETS); + assert_always(operation == UPDATE_OP_EXPAND_VARIABLE_OFFSETS); // decode number of offsets uint32_t number_of_offsets; @@ -781,18 +785,20 @@ static int tokudb_expand_variable_offsets( uint32_t offset_start; extra_val.consume(&offset_start, sizeof offset_start); - assert(extra_val.size() == extra_val.limit()); + assert_always(extra_val.size() == extra_val.limit()); DBT new_val; memset(&new_val, 0, sizeof new_val); if (old_val != NULL) { - assert(offset_start + number_of_offsets <= old_val->size); + assert_always(offset_start + number_of_offsets <= old_val->size); // compute the new val from the old val - uchar *old_val_ptr = (uchar *)old_val->data; + uchar* old_val_ptr = (uchar*)old_val->data; // allocate space for the new val's data - uchar *new_val_ptr = (uchar *)tokudb_my_malloc(number_of_offsets + old_val->size, MYF(MY_FAE)); + uchar* new_val_ptr = (uchar*)tokudb::memory::malloc( + number_of_offsets + old_val->size, + MYF(MY_FAE)); if (!new_val_ptr) { error = ENOMEM; goto cleanup; @@ -819,8 +825,8 @@ static int tokudb_expand_variable_offsets( old_val_ptr += n; new_val.size = new_val_ptr - (uchar *)new_val.data; - assert(new_val_ptr == (uchar *)new_val.data + new_val.size); - assert(old_val_ptr == (uchar *)old_val->data + old_val->size); + assert_always(new_val_ptr == (uchar *)new_val.data + new_val.size); + assert_always(old_val_ptr == (uchar *)old_val->data + old_val->size); // set the new val set_val(&new_val, set_extra); @@ -829,46 +835,50 @@ static int tokudb_expand_variable_offsets( error = 0; cleanup: - tokudb_my_free(new_val.data); + tokudb::memory::free(new_val.data); return error; } // Expand an int field in a old row given the expand message in the extra. static int tokudb_expand_int_field( DB* db, - const DBT *key, - const DBT *old_val, - const DBT *extra, - void (*set_val)(const DBT *new_val, void *set_extra), - void *set_extra - ) -{ + const DBT* key, + const DBT* old_val, + const DBT* extra, + void (*set_val)(const DBT* new_val, void* set_extra), + void* set_extra) { + int error = 0; tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t operation; extra_val.consume(&operation, sizeof operation); - assert(operation == UPDATE_OP_EXPAND_INT || operation == UPDATE_OP_EXPAND_UINT); + assert_always( + operation == UPDATE_OP_EXPAND_INT || + operation == UPDATE_OP_EXPAND_UINT); uint32_t the_offset; extra_val.consume(&the_offset, sizeof the_offset); uint32_t old_length; extra_val.consume(&old_length, sizeof old_length); uint32_t new_length; extra_val.consume(&new_length, sizeof new_length); - assert(extra_val.size() == extra_val.limit()); + assert_always(extra_val.size() == extra_val.limit()); - assert(new_length >= old_length); // expand only + assert_always(new_length >= old_length); // expand only DBT new_val; memset(&new_val, 0, sizeof new_val); if (old_val != NULL) { - assert(the_offset + old_length <= old_val->size); // old field within the old val + // old field within the old val + assert_always(the_offset + old_length <= old_val->size); // compute the new val from the old val - uchar *old_val_ptr = (uchar *)old_val->data; + uchar* old_val_ptr = (uchar*)old_val->data; // allocate space for the new val's data - uchar *new_val_ptr = (uchar *)tokudb_my_malloc(old_val->size + (new_length - old_length), MYF(MY_FAE)); + uchar* new_val_ptr = (uchar*)tokudb::memory::malloc( + old_val->size + (new_length - old_length), + MYF(MY_FAE)); if (!new_val_ptr) { error = ENOMEM; goto cleanup; @@ -882,21 +892,27 @@ static int tokudb_expand_int_field( switch (operation) { case UPDATE_OP_EXPAND_INT: - // fill the entire new value with ones or zeros depending on the sign bit - // the encoding is little endian - memset(new_val_ptr, (old_val_ptr[old_length-1] & 0x80) ? 0xff : 0x00, new_length); - memcpy(new_val_ptr, old_val_ptr, old_length); // overlay the low bytes of the new value with the old value + // fill the entire new value with ones or zeros depending on the + // sign bit the encoding is little endian + memset( + new_val_ptr, + (old_val_ptr[old_length-1] & 0x80) ? 0xff : 0x00, + new_length); + // overlay the low bytes of the new value with the old value + memcpy(new_val_ptr, old_val_ptr, old_length); new_val_ptr += new_length; old_val_ptr += old_length; break; case UPDATE_OP_EXPAND_UINT: - memset(new_val_ptr, 0, new_length); // fill the entire new value with zeros - memcpy(new_val_ptr, old_val_ptr, old_length); // overlay the low bytes of the new value with the old value + // fill the entire new value with zeros + memset(new_val_ptr, 0, new_length); + // overlay the low bytes of the new value with the old value + memcpy(new_val_ptr, old_val_ptr, old_length); new_val_ptr += new_length; old_val_ptr += old_length; break; default: - assert(0); + assert_unreachable(); } // copy the rest @@ -906,8 +922,8 @@ static int tokudb_expand_int_field( old_val_ptr += n; new_val.size = new_val_ptr - (uchar *)new_val.data; - assert(new_val_ptr == (uchar *)new_val.data + new_val.size); - assert(old_val_ptr == (uchar *)old_val->data + old_val->size); + assert_always(new_val_ptr == (uchar *)new_val.data + new_val.size); + assert_always(old_val_ptr == (uchar *)old_val->data + old_val->size); // set the new val set_val(&new_val, set_extra); @@ -916,26 +932,27 @@ static int tokudb_expand_int_field( error = 0; cleanup: - tokudb_my_free(new_val.data); + tokudb::memory::free(new_val.data); return error; } // Expand a char field in a old row given the expand message in the extra. static int tokudb_expand_char_field( DB* db, - const DBT *key, - const DBT *old_val, - const DBT *extra, - void (*set_val)(const DBT *new_val, void *set_extra), - void *set_extra - ) -{ + const DBT* key, + const DBT* old_val, + const DBT* extra, + void (*set_val)(const DBT* new_val, void* set_extra), + void* set_extra) { + int error = 0; tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t operation; extra_val.consume(&operation, sizeof operation); - assert(operation == UPDATE_OP_EXPAND_CHAR || operation == UPDATE_OP_EXPAND_BINARY); + assert_always( + operation == UPDATE_OP_EXPAND_CHAR || + operation == UPDATE_OP_EXPAND_BINARY); uint32_t the_offset; extra_val.consume(&the_offset, sizeof the_offset); uint32_t old_length; @@ -944,20 +961,23 @@ static int tokudb_expand_char_field( extra_val.consume(&new_length, sizeof new_length); uchar pad_char; extra_val.consume(&pad_char, sizeof pad_char); - assert(extra_val.size() == extra_val.limit()); + assert_always(extra_val.size() == extra_val.limit()); - assert(new_length >= old_length); // expand only + assert_always(new_length >= old_length); // expand only DBT new_val; memset(&new_val, 0, sizeof new_val); if (old_val != NULL) { - assert(the_offset + old_length <= old_val->size); // old field within the old val + // old field within the old val + assert_always(the_offset + old_length <= old_val->size); // compute the new val from the old val - uchar *old_val_ptr = (uchar *)old_val->data; + uchar* old_val_ptr = (uchar*)old_val->data; // allocate space for the new val's data - uchar *new_val_ptr = (uchar *)tokudb_my_malloc(old_val->size + (new_length - old_length), MYF(MY_FAE)); + uchar* new_val_ptr = (uchar*)tokudb::memory::malloc( + old_val->size + (new_length - old_length), + MYF(MY_FAE)); if (!new_val_ptr) { error = ENOMEM; goto cleanup; @@ -972,13 +992,15 @@ static int tokudb_expand_char_field( switch (operation) { case UPDATE_OP_EXPAND_CHAR: case UPDATE_OP_EXPAND_BINARY: - memset(new_val_ptr, pad_char, new_length); // fill the entire new value with the pad char - memcpy(new_val_ptr, old_val_ptr, old_length); // overlay the low bytes of the new value with the old value + // fill the entire new value with the pad char + memset(new_val_ptr, pad_char, new_length); + // overlay the low bytes of the new value with the old value + memcpy(new_val_ptr, old_val_ptr, old_length); new_val_ptr += new_length; old_val_ptr += old_length; break; default: - assert(0); + assert_unreachable(); } // copy the rest @@ -988,8 +1010,8 @@ static int tokudb_expand_char_field( old_val_ptr += n; new_val.size = new_val_ptr - (uchar *)new_val.data; - assert(new_val_ptr == (uchar *)new_val.data + new_val.size); - assert(old_val_ptr == (uchar *)old_val->data + old_val->size); + assert_always(new_val_ptr == (uchar *)new_val.data + new_val.size); + assert_always(old_val_ptr == (uchar *)old_val->data + old_val->size); // set the new val set_val(&new_val, set_extra); @@ -998,7 +1020,7 @@ static int tokudb_expand_char_field( error = 0; cleanup: - tokudb_my_free(new_val.data); + tokudb::memory::free(new_val.data); return error; } @@ -1006,17 +1028,25 @@ namespace tokudb { class var_fields { public: - var_fields() { + inline var_fields() { } - void init_var_fields(uint32_t var_offset, uint32_t offset_bytes, uint32_t bytes_per_offset, tokudb::buffer *val_buffer) { - assert(bytes_per_offset == 0 || bytes_per_offset == 1 || bytes_per_offset == 2); + inline void init_var_fields( + uint32_t var_offset, + uint32_t offset_bytes, + uint32_t bytes_per_offset, + tokudb::buffer* val_buffer) { + + assert_always( + bytes_per_offset == 0 || + bytes_per_offset == 1 || + bytes_per_offset == 2); m_var_offset = var_offset; m_val_offset = m_var_offset + offset_bytes; m_bytes_per_offset = bytes_per_offset; if (bytes_per_offset > 0) { m_num_fields = offset_bytes / bytes_per_offset; } else { - assert(offset_bytes == 0); + assert_always(offset_bytes == 0); m_num_fields = 0; } m_val_buffer = val_buffer; @@ -1025,7 +1055,10 @@ public: uint32_t value_length(uint32_t var_index); void update_offsets(uint32_t var_index, uint32_t old_s, uint32_t new_s); uint32_t end_offset(); - void replace(uint32_t var_index, void *new_val_ptr, uint32_t new_val_length); + void replace( + uint32_t var_index, + void* new_val_ptr, + uint32_t new_val_length); private: uint32_t read_offset(uint32_t var_index); void write_offset(uint32_t var_index, uint32_t v); @@ -1034,24 +1067,28 @@ private: uint32_t m_val_offset; uint32_t m_bytes_per_offset; uint32_t m_num_fields; - tokudb::buffer *m_val_buffer; + tokudb::buffer* m_val_buffer; }; // Return the ith variable length offset uint32_t var_fields::read_offset(uint32_t var_index) { uint32_t offset = 0; - m_val_buffer->read(&offset, m_bytes_per_offset, m_var_offset + var_index * m_bytes_per_offset); + m_val_buffer->read( + &offset, m_bytes_per_offset, m_var_offset + var_index * m_bytes_per_offset); return offset; } // Write the ith variable length offset with a new offset. void var_fields::write_offset(uint32_t var_index, uint32_t new_offset) { - m_val_buffer->write(&new_offset, m_bytes_per_offset, m_var_offset + var_index * m_bytes_per_offset); + m_val_buffer->write( + &new_offset, + m_bytes_per_offset, + m_var_offset + var_index * m_bytes_per_offset); } // Return the offset of the ith variable length field uint32_t var_fields::value_offset(uint32_t var_index) { - assert(var_index < m_num_fields); + assert_always(var_index < m_num_fields); if (var_index == 0) return m_val_offset; else @@ -1060,16 +1097,21 @@ uint32_t var_fields::value_offset(uint32_t var_index) { // Return the length of the ith variable length field uint32_t var_fields::value_length(uint32_t var_index) { - assert(var_index < m_num_fields); + assert_always(var_index < m_num_fields); if (var_index == 0) return read_offset(0); else return read_offset(var_index) - read_offset(var_index-1); } -// The length of the ith variable length fields changed. Update all of the subsequent offsets. -void var_fields::update_offsets(uint32_t var_index, uint32_t old_s, uint32_t new_s) { - assert(var_index < m_num_fields); +// The length of the ith variable length fields changed. +// Update all of the subsequent offsets. +void var_fields::update_offsets( + uint32_t var_index, + uint32_t old_s, + uint32_t new_s) { + + assert_always(var_index < m_num_fields); if (old_s == new_s) return; for (uint i = var_index; i < m_num_fields; i++) { @@ -1088,7 +1130,11 @@ uint32_t var_fields::end_offset() { return m_val_offset + read_offset(m_num_fields-1); } -void var_fields::replace(uint32_t var_index, void *new_val_ptr, uint32_t new_val_length) { +void var_fields::replace( + uint32_t var_index, + void* new_val_ptr, + uint32_t new_val_length) { + // replace the new val with the extra val uint32_t the_offset = value_offset(var_index); uint32_t old_s = value_length(var_index); @@ -1103,15 +1149,23 @@ class blob_fields { public: blob_fields() { } - void init_blob_fields(uint32_t num_blobs, const uint8_t *blob_lengths, tokudb::buffer *val_buffer) { - m_num_blobs = num_blobs; m_blob_lengths = blob_lengths; m_val_buffer = val_buffer; + void init_blob_fields( + uint32_t num_blobs, + const uint8_t* blob_lengths, + tokudb::buffer* val_buffer) { + m_num_blobs = num_blobs; + m_blob_lengths = blob_lengths; + m_val_buffer = val_buffer; } void start_blobs(uint32_t offset) { m_blob_offset = offset; } void replace(uint32_t blob_index, uint32_t length, void *p); - void expand_length(uint32_t blob_index, uint8_t old_length_length, uint8_t new_length_length); + void expand_length( + uint32_t blob_index, + uint8_t old_length_length, + uint8_t new_length_length); private: uint32_t read_length(uint32_t offset, size_t size); void write_length(uint32_t offset, size_t size, uint32_t new_length); @@ -1129,12 +1183,15 @@ uint32_t blob_fields::read_length(uint32_t offset, size_t blob_length) { return length; } -void blob_fields::write_length(uint32_t offset, size_t size, uint32_t new_length) { +void blob_fields::write_length( + uint32_t offset, + size_t size, + uint32_t new_length) { m_val_buffer->write(&new_length, size, offset); } uint32_t blob_fields::blob_offset(uint32_t blob_index) { - assert(blob_index < m_num_blobs); + assert_always(blob_index < m_num_blobs); uint32_t offset = m_blob_offset; for (uint i = 0; i < blob_index; i++) { uint32_t blob_length = m_blob_lengths[i]; @@ -1144,8 +1201,12 @@ uint32_t blob_fields::blob_offset(uint32_t blob_index) { return offset; } -void blob_fields::replace(uint32_t blob_index, uint32_t new_length, void *new_value) { - assert(blob_index < m_num_blobs); +void blob_fields::replace( + uint32_t blob_index, + uint32_t new_length, + void* new_value) { + + assert_always(blob_index < m_num_blobs); // compute the ith blob offset uint32_t offset = blob_offset(blob_index); @@ -1155,15 +1216,23 @@ void blob_fields::replace(uint32_t blob_index, uint32_t new_length, void *new_va uint32_t old_length = read_length(offset, blob_length); // replace the data - m_val_buffer->replace(offset + blob_length, old_length, new_value, new_length); + m_val_buffer->replace( + offset + blob_length, + old_length, + new_value, + new_length); // write the new length write_length(offset, blob_length, new_length); } -void blob_fields::expand_length(uint32_t blob_index, uint8_t old_length_length, uint8_t new_length_length) { - assert(blob_index < m_num_blobs); - assert(old_length_length == m_blob_lengths[blob_index]); +void blob_fields::expand_length( + uint32_t blob_index, + uint8_t old_length_length, + uint8_t new_length_length) { + + assert_always(blob_index < m_num_blobs); + assert_always(old_length_length == m_blob_lengths[blob_index]); // compute the ith blob offset uint32_t offset = blob_offset(blob_index); @@ -1172,7 +1241,11 @@ void blob_fields::expand_length(uint32_t blob_index, uint8_t old_length_length, uint32_t blob_length = read_length(offset, old_length_length); // expand the length - m_val_buffer->replace(offset, old_length_length, &blob_length, new_length_length); + m_val_buffer->replace( + offset, + old_length_length, + &blob_length, + new_length_length); } class value_map { @@ -1180,8 +1253,16 @@ public: value_map(tokudb::buffer *val_buffer) : m_val_buffer(val_buffer) { } - void init_var_fields(uint32_t var_offset, uint32_t offset_bytes, uint32_t bytes_per_offset) { - m_var_fields.init_var_fields(var_offset, offset_bytes, bytes_per_offset, m_val_buffer); + void init_var_fields( + uint32_t var_offset, + uint32_t offset_bytes, + uint32_t bytes_per_offset) { + + m_var_fields.init_var_fields( + var_offset, + offset_bytes, + bytes_per_offset, + m_val_buffer); } void init_blob_fields(uint32_t num_blobs, const uint8_t *blob_lengths) { @@ -1189,31 +1270,63 @@ public: } // Replace the value of a fixed length field - void replace_fixed(uint32_t the_offset, uint32_t field_null_num, void *new_val_ptr, uint32_t new_val_length) { - m_val_buffer->replace(the_offset, new_val_length, new_val_ptr, new_val_length); + void replace_fixed( + uint32_t the_offset, + uint32_t field_null_num, + void* new_val_ptr, + uint32_t new_val_length) { + + m_val_buffer->replace( + the_offset, + new_val_length, + new_val_ptr, + new_val_length); maybe_clear_null(field_null_num); } // Replace the value of a variable length field - void replace_varchar(uint32_t var_index, uint32_t field_null_num, void *new_val_ptr, uint32_t new_val_length) { + void replace_varchar( + uint32_t var_index, + uint32_t field_null_num, + void* new_val_ptr, + uint32_t new_val_length) { + m_var_fields.replace(var_index, new_val_ptr, new_val_length); maybe_clear_null(field_null_num); } // Replace the value of a blob field - void replace_blob(uint32_t blob_index, uint32_t field_null_num, void *new_val_ptr, uint32_t new_val_length) { + void replace_blob( + uint32_t blob_index, + uint32_t field_null_num, + void* new_val_ptr, + uint32_t new_val_length) { + m_blob_fields.start_blobs(m_var_fields.end_offset()); m_blob_fields.replace(blob_index, new_val_length, new_val_ptr); maybe_clear_null(field_null_num); } - void expand_blob_lengths(uint32_t num_blob, const uint8_t *old_length, const uint8_t *new_length); + void expand_blob_lengths( + uint32_t num_blob, + const uint8_t* old_length, + const uint8_t* new_length); - void int_op(uint32_t operation, uint32_t the_offset, uint32_t length, uint32_t field_null_num, - tokudb::buffer &old_val, void *extra_val); + void int_op( + uint32_t operation, + uint32_t the_offset, + uint32_t length, + uint32_t field_null_num, + tokudb::buffer& old_val, + void* extra_val); - void uint_op(uint32_t operation, uint32_t the_offset, uint32_t length, uint32_t field_null_num, - tokudb::buffer &old_val, void *extra_val); + void uint_op( + uint32_t operation, + uint32_t the_offset, + uint32_t length, + uint32_t field_null_num, + tokudb::buffer& old_val, + void* extra_val); private: bool is_null(uint32_t null_num, uchar *null_bytes) { @@ -1234,7 +1347,10 @@ private: null_num &= ~(1<<31); else null_num -= 1; - set_overall_null_position((uchar *) m_val_buffer->data(), null_num, false); + set_overall_null_position( + (uchar*)m_val_buffer->data(), + null_num, + false); } } @@ -1245,11 +1361,19 @@ private: }; // Update an int field: signed newval@offset = old_val@offset OP extra_val -void value_map::int_op(uint32_t operation, uint32_t the_offset, uint32_t length, uint32_t field_null_num, - tokudb::buffer &old_val, void *extra_val) { - assert(the_offset + length <= m_val_buffer->size()); - assert(the_offset + length <= old_val.size()); - assert(length == 1 || length == 2 || length == 3 || length == 4 || length == 8); +void value_map::int_op( + uint32_t operation, + uint32_t the_offset, + uint32_t length, + uint32_t field_null_num, + tokudb::buffer &old_val, + void* extra_val) { + + assert_always(the_offset + length <= m_val_buffer->size()); + assert_always(the_offset + length <= old_val.size()); + assert_always( + length == 1 || length == 2 || length == 3 || + length == 4 || length == 8); uchar *old_val_ptr = (uchar *) old_val.data(); bool field_is_null = is_null(field_null_num, old_val_ptr); @@ -1287,16 +1411,24 @@ void value_map::int_op(uint32_t operation, uint32_t the_offset, uint32_t length, } break; default: - assert(0); + assert_unreachable(); } } // Update an unsigned field: unsigned newval@offset = old_val@offset OP extra_val -void value_map::uint_op(uint32_t operation, uint32_t the_offset, uint32_t length, uint32_t field_null_num, - tokudb::buffer &old_val, void *extra_val) { - assert(the_offset + length <= m_val_buffer->size()); - assert(the_offset + length <= old_val.size()); - assert(length == 1 || length == 2 || length == 3 || length == 4 || length == 8); +void value_map::uint_op( + uint32_t operation, + uint32_t the_offset, + uint32_t length, + uint32_t field_null_num, + tokudb::buffer& old_val, + void* extra_val) { + + assert_always(the_offset + length <= m_val_buffer->size()); + assert_always(the_offset + length <= old_val.size()); + assert_always( + length == 1 || length == 2 || length == 3 || + length == 4 || length == 8); uchar *old_val_ptr = (uchar *) old_val.data(); bool field_is_null = is_null(field_null_num, old_val_ptr); @@ -1326,16 +1458,23 @@ void value_map::uint_op(uint32_t operation, uint32_t the_offset, uint32_t length } break; default: - assert(0); + assert_unreachable(); } } -void value_map::expand_blob_lengths(uint32_t num_blob, const uint8_t *old_length, const uint8_t *new_length) { +void value_map::expand_blob_lengths( + uint32_t num_blob, + const uint8_t* old_length, + const uint8_t* new_length) { + uint8_t current_length[num_blob]; memcpy(current_length, old_length, num_blob); for (uint32_t i = 0; i < num_blob; i++) { if (new_length[i] > current_length[i]) { - m_blob_fields.init_blob_fields(num_blob, current_length, m_val_buffer); + m_blob_fields.init_blob_fields( + num_blob, + current_length, + m_val_buffer); m_blob_fields.start_blobs(m_var_fields.end_offset()); m_blob_fields.expand_length(i, current_length[i], new_length[i]); current_length[i] = new_length[i]; @@ -1348,30 +1487,29 @@ void value_map::expand_blob_lengths(uint32_t num_blob, const uint8_t *old_length static uint32_t consume_uint32(tokudb::buffer &b) { uint32_t n; size_t s = b.consume_ui(&n); - assert(s > 0); + assert_always(s > 0); return n; } static uint8_t *consume_uint8_array(tokudb::buffer &b, uint32_t array_size) { uint8_t *p = (uint8_t *) b.consume_ptr(array_size); - assert(p); + assert_always(p); return p; } static int tokudb_expand_blobs( DB* db, - const DBT *key_dbt, - const DBT *old_val_dbt, - const DBT *extra, - void (*set_val)(const DBT *new_val_dbt, void *set_extra), - void *set_extra - ) -{ + const DBT* key_dbt, + const DBT* old_val_dbt, + const DBT* extra, + void (*set_val)(const DBT* new_val_dbt, void* set_extra), + void* set_extra) { + tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t operation; extra_val.consume(&operation, sizeof operation); - assert(operation == UPDATE_OP_EXPAND_BLOB); + assert_always(operation == UPDATE_OP_EXPAND_BLOB); if (old_val_dbt != NULL) { // new val = old val @@ -1384,13 +1522,18 @@ static int tokudb_expand_blobs( uint32_t var_field_offset = consume_uint32(extra_val); uint32_t var_offset_bytes = consume_uint32(extra_val); uint32_t bytes_per_offset = consume_uint32(extra_val); - vd.init_var_fields(var_field_offset, var_offset_bytes, bytes_per_offset); + vd.init_var_fields( + var_field_offset, + var_offset_bytes, + bytes_per_offset); // decode blob info uint32_t num_blob = consume_uint32(extra_val); - const uint8_t *old_blob_length = consume_uint8_array(extra_val, num_blob); - const uint8_t *new_blob_length = consume_uint8_array(extra_val, num_blob); - assert(extra_val.size() == extra_val.limit()); + const uint8_t* old_blob_length = + consume_uint8_array(extra_val, num_blob); + const uint8_t* new_blob_length = + consume_uint8_array(extra_val, num_blob); + assert_always(extra_val.size() == extra_val.limit()); // expand blob lengths vd.expand_blob_lengths(num_blob, old_blob_length, new_blob_length); @@ -1404,8 +1547,14 @@ static int tokudb_expand_blobs( return 0; } -// Decode and apply a sequence of update operations defined in the extra to the old value and put the result in the new value. -static void apply_1_updates(tokudb::value_map &vd, tokudb::buffer &new_val, tokudb::buffer &old_val, tokudb::buffer &extra_val) { +// Decode and apply a sequence of update operations defined in the extra to +// the old value and put the result in the new value. +static void apply_1_updates( + tokudb::value_map& vd, + tokudb::buffer& new_val, + tokudb::buffer& old_val, + tokudb::buffer& extra_val) { + uint32_t num_updates; extra_val.consume(&num_updates, sizeof num_updates); for ( ; num_updates > 0; num_updates--) { @@ -1428,46 +1577,70 @@ static void apply_1_updates(tokudb::value_map &vd, tokudb::buffer &new_val, toku switch (field_type) { case UPDATE_TYPE_INT: if (update_operation == '=') - vd.replace_fixed(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_fixed( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - vd.int_op(update_operation, the_offset, extra_val_length, field_null_num, old_val, extra_val_ptr); + vd.int_op( + update_operation, + the_offset, + extra_val_length, + field_null_num, + old_val, + extra_val_ptr); break; case UPDATE_TYPE_UINT: if (update_operation == '=') - vd.replace_fixed(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_fixed( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - vd.uint_op(update_operation, the_offset, extra_val_length, field_null_num, old_val, extra_val_ptr); + vd.uint_op( + update_operation, + the_offset, + extra_val_length, + field_null_num, + old_val, + extra_val_ptr); break; case UPDATE_TYPE_CHAR: case UPDATE_TYPE_BINARY: if (update_operation == '=') - vd.replace_fixed(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_fixed( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - assert(0); + assert_unreachable(); break; default: - assert(0); + assert_unreachable(); break; } } - assert(extra_val.size() == extra_val.limit()); + assert_always(extra_val.size() == extra_val.limit()); } -// Simple update handler. Decode the update message, apply the update operations to the old value, and set the new value. +// Simple update handler. Decode the update message, apply the update operations +// to the old value, and set the new value. static int tokudb_update_1_fun( DB* db, - const DBT *key_dbt, - const DBT *old_val_dbt, - const DBT *extra, - void (*set_val)(const DBT *new_val_dbt, void *set_extra), - void *set_extra - ) -{ + const DBT* key_dbt, + const DBT* old_val_dbt, + const DBT* extra, + void (*set_val)(const DBT* new_val_dbt, void* set_extra), + void* set_extra) { + tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t operation; extra_val.consume(&operation, sizeof operation); - assert(operation == UPDATE_OP_UPDATE_1); + assert_always(operation == UPDATE_OP_UPDATE_1); if (old_val_dbt != NULL) { // get the simple descriptor @@ -1480,14 +1653,20 @@ static int tokudb_update_1_fun( uint32_t m_bytes_per_offset; extra_val.consume(&m_bytes_per_offset, sizeof m_bytes_per_offset); - tokudb::buffer old_val(old_val_dbt->data, old_val_dbt->size, old_val_dbt->size); + tokudb::buffer old_val( + old_val_dbt->data, + old_val_dbt->size, + old_val_dbt->size); // new val = old val tokudb::buffer new_val; new_val.append(old_val_dbt->data, old_val_dbt->size); tokudb::value_map vd(&new_val); - vd.init_var_fields(m_var_field_offset, m_var_offset_bytes, m_bytes_per_offset); + vd.init_var_fields( + m_var_field_offset, + m_var_offset_bytes, + m_bytes_per_offset); // apply updates to new val apply_1_updates(vd, new_val, old_val, extra_val); @@ -1502,22 +1681,23 @@ static int tokudb_update_1_fun( return 0; } -// Simple upsert handler. Decode the upsert message. If the key does not exist, then insert a new value from the extra. -// Otherwise, apply the update operations to the old value, and then set the new value. +// Simple upsert handler. Decode the upsert message. If the key does not exist, +// then insert a new value from the extra. +// Otherwise, apply the update operations to the old value, and then set the +// new value. static int tokudb_upsert_1_fun( DB* db, - const DBT *key_dbt, - const DBT *old_val_dbt, - const DBT *extra, - void (*set_val)(const DBT *new_val_dbt, void *set_extra), - void *set_extra - ) -{ + const DBT* key_dbt, + const DBT* old_val_dbt, + const DBT* extra, + void (*set_val)(const DBT* new_val_dbt, void* set_extra), + void* set_extra) { + tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t operation; extra_val.consume(&operation, sizeof operation); - assert(operation == UPDATE_OP_UPSERT_1); + assert_always(operation == UPDATE_OP_UPSERT_1); uint32_t insert_length; extra_val.consume(&insert_length, sizeof insert_length); @@ -1540,14 +1720,20 @@ static int tokudb_upsert_1_fun( uint32_t m_bytes_per_offset; extra_val.consume(&m_bytes_per_offset, sizeof m_bytes_per_offset); - tokudb::buffer old_val(old_val_dbt->data, old_val_dbt->size, old_val_dbt->size); + tokudb::buffer old_val( + old_val_dbt->data, + old_val_dbt->size, + old_val_dbt->size); // new val = old val tokudb::buffer new_val; new_val.append(old_val_dbt->data, old_val_dbt->size); tokudb::value_map vd(&new_val); - vd.init_var_fields(m_var_field_offset, m_var_offset_bytes, m_bytes_per_offset); + vd.init_var_fields( + m_var_field_offset, + m_var_offset_bytes, + m_bytes_per_offset); // apply updates to new val apply_1_updates(vd, new_val, old_val, extra_val); @@ -1562,8 +1748,14 @@ static int tokudb_upsert_1_fun( return 0; } -// Decode and apply a sequence of update operations defined in the extra to the old value and put the result in the new value. -static void apply_2_updates(tokudb::value_map &vd, tokudb::buffer &new_val, tokudb::buffer &old_val, tokudb::buffer &extra_val) { +// Decode and apply a sequence of update operations defined in the extra to the +// old value and put the result in the new value. +static void apply_2_updates( + tokudb::value_map& vd, + tokudb::buffer& new_val, + tokudb::buffer& old_val, + tokudb::buffer& extra_val) { + uint32_t num_updates = consume_uint32(extra_val); for (uint32_t i = 0; i < num_updates; i++) { uint32_t update_operation = consume_uint32(extra_val); @@ -1571,79 +1763,118 @@ static void apply_2_updates(tokudb::value_map &vd, tokudb::buffer &new_val, toku uint32_t var_field_offset = consume_uint32(extra_val); uint32_t var_offset_bytes = consume_uint32(extra_val); uint32_t bytes_per_offset = consume_uint32(extra_val); - vd.init_var_fields(var_field_offset, var_offset_bytes, bytes_per_offset); + vd.init_var_fields( + var_field_offset, + var_offset_bytes, + bytes_per_offset); } else if (update_operation == 'b') { uint32_t num_blobs = consume_uint32(extra_val); - const uint8_t *blob_lengths = consume_uint8_array(extra_val, num_blobs); + const uint8_t* blob_lengths = + consume_uint8_array(extra_val, num_blobs); vd.init_blob_fields(num_blobs, blob_lengths); } else { uint32_t field_type = consume_uint32(extra_val); uint32_t field_null_num = consume_uint32(extra_val); uint32_t the_offset = consume_uint32(extra_val); uint32_t extra_val_length = consume_uint32(extra_val); - void *extra_val_ptr = extra_val.consume_ptr(extra_val_length); assert(extra_val_ptr); + void* extra_val_ptr = extra_val.consume_ptr(extra_val_length); + assert_always(extra_val_ptr); switch (field_type) { case UPDATE_TYPE_INT: if (update_operation == '=') - vd.replace_fixed(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_fixed( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - vd.int_op(update_operation, the_offset, extra_val_length, field_null_num, old_val, extra_val_ptr); + vd.int_op( + update_operation, + the_offset, + extra_val_length, + field_null_num, + old_val, + extra_val_ptr); break; case UPDATE_TYPE_UINT: if (update_operation == '=') - vd.replace_fixed(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_fixed( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - vd.uint_op(update_operation, the_offset, extra_val_length, field_null_num, old_val, extra_val_ptr); + vd.uint_op( + update_operation, + the_offset, + extra_val_length, + field_null_num, + old_val, + extra_val_ptr); break; case UPDATE_TYPE_CHAR: case UPDATE_TYPE_BINARY: if (update_operation == '=') - vd.replace_fixed(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_fixed( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - assert(0); + assert_unreachable(); break; case UPDATE_TYPE_VARBINARY: case UPDATE_TYPE_VARCHAR: if (update_operation == '=') - vd.replace_varchar(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_varchar( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - assert(0); + assert_unreachable(); break; case UPDATE_TYPE_TEXT: case UPDATE_TYPE_BLOB: if (update_operation == '=') - vd.replace_blob(the_offset, field_null_num, extra_val_ptr, extra_val_length); + vd.replace_blob( + the_offset, + field_null_num, + extra_val_ptr, + extra_val_length); else - assert(0); + assert_unreachable(); break; default: - assert(0); - break; + assert_unreachable(); } } } - assert(extra_val.size() == extra_val.limit()); + assert_always(extra_val.size() == extra_val.limit()); } -// Simple update handler. Decode the update message, apply the update operations to the old value, and set the new value. +// Simple update handler. Decode the update message, apply the update +// operations to the old value, and set the new value. static int tokudb_update_2_fun( DB* db, - const DBT *key_dbt, - const DBT *old_val_dbt, - const DBT *extra, - void (*set_val)(const DBT *new_val_dbt, void *set_extra), - void *set_extra - ) -{ + const DBT* key_dbt, + const DBT* old_val_dbt, + const DBT* extra, + void (*set_val)(const DBT* new_val_dbt, void* set_extra), + void* set_extra) { + tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t op; extra_val.consume(&op, sizeof op); - assert(op == UPDATE_OP_UPDATE_2); + assert_always(op == UPDATE_OP_UPDATE_2); if (old_val_dbt != NULL) { - tokudb::buffer old_val(old_val_dbt->data, old_val_dbt->size, old_val_dbt->size); + tokudb::buffer old_val( + old_val_dbt->data, + old_val_dbt->size, + old_val_dbt->size); // new val = old val tokudb::buffer new_val; @@ -1664,26 +1895,28 @@ static int tokudb_update_2_fun( return 0; } -// Simple upsert handler. Decode the upsert message. If the key does not exist, then insert a new value from the extra. -// Otherwise, apply the update operations to the old value, and then set the new value. +// Simple upsert handler. Decode the upsert message. If the key does not exist, +// then insert a new value from the extra. +// Otherwise, apply the update operations to the old value, and then set the +// new value. static int tokudb_upsert_2_fun( DB* db, - const DBT *key_dbt, - const DBT *old_val_dbt, - const DBT *extra, - void (*set_val)(const DBT *new_val_dbt, void *set_extra), - void *set_extra - ) -{ + const DBT* key_dbt, + const DBT* old_val_dbt, + const DBT* extra, + void (*set_val)(const DBT* new_val_dbt, void* set_extra), + void* set_extra) { + tokudb::buffer extra_val(extra->data, 0, extra->size); uint8_t op; extra_val.consume(&op, sizeof op); - assert(op == UPDATE_OP_UPSERT_2); + assert_always(op == UPDATE_OP_UPSERT_2); uint32_t insert_length = consume_uint32(extra_val); - assert(insert_length < extra_val.limit()); - void *insert_row = extra_val.consume_ptr(insert_length); assert(insert_row); + assert_always(insert_length < extra_val.limit()); + void* insert_row = extra_val.consume_ptr(insert_length); + assert_always(insert_row); if (old_val_dbt == NULL) { // insert a new row @@ -1692,7 +1925,10 @@ static int tokudb_upsert_2_fun( new_val_dbt.data = insert_row; set_val(&new_val_dbt, set_extra); } else { - tokudb::buffer old_val(old_val_dbt->data, old_val_dbt->size, old_val_dbt->size); + tokudb::buffer old_val( + old_val_dbt->data, + old_val_dbt->size, + old_val_dbt->size); // new val = old val tokudb::buffer new_val; @@ -1713,56 +1949,107 @@ static int tokudb_upsert_2_fun( return 0; } -// This function is the update callback function that is registered with the YDB environment. -// It uses the first byte in the update message to identify the update message type and call -// the handler for that message. +// This function is the update callback function that is registered with the +// YDB environment. It uses the first byte in the update message to identify +// the update message type and call the handler for that message. int tokudb_update_fun( DB* db, - const DBT *key, - const DBT *old_val, - const DBT *extra, - void (*set_val)(const DBT *new_val, void *set_extra), - void *set_extra - ) -{ - assert(extra->size > 0); - uint8_t *extra_pos = (uchar *)extra->data; + const DBT* key, + const DBT* old_val, + const DBT* extra, + void (*set_val)(const DBT* new_val, void* set_extra), + void* set_extra) { + + assert_always(extra->size > 0); + uint8_t* extra_pos = (uchar*)extra->data; uint8_t operation = extra_pos[0]; int error; switch (operation) { case UPDATE_OP_COL_ADD_OR_DROP: - error = tokudb_hcad_update_fun(db, key, old_val, extra, set_val, set_extra); + error = tokudb_hcad_update_fun( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_EXPAND_VARIABLE_OFFSETS: - error = tokudb_expand_variable_offsets(db, key, old_val, extra, set_val, set_extra); + error = tokudb_expand_variable_offsets( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_EXPAND_INT: case UPDATE_OP_EXPAND_UINT: - error = tokudb_expand_int_field(db, key, old_val, extra, set_val, set_extra); + error = tokudb_expand_int_field( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_EXPAND_CHAR: case UPDATE_OP_EXPAND_BINARY: - error = tokudb_expand_char_field(db, key, old_val, extra, set_val, set_extra); + error = tokudb_expand_char_field( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_EXPAND_BLOB: - error = tokudb_expand_blobs(db, key, old_val, extra, set_val, set_extra); + error = tokudb_expand_blobs( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_UPDATE_1: - error = tokudb_update_1_fun(db, key, old_val, extra, set_val, set_extra); + error = tokudb_update_1_fun( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_UPSERT_1: - error = tokudb_upsert_1_fun(db, key, old_val, extra, set_val, set_extra); + error = tokudb_upsert_1_fun( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_UPDATE_2: - error = tokudb_update_2_fun(db, key, old_val, extra, set_val, set_extra); + error = tokudb_update_2_fun( + db, + key, + old_val, + extra, + set_val, + set_extra); break; case UPDATE_OP_UPSERT_2: - error = tokudb_upsert_2_fun(db, key, old_val, extra, set_val, set_extra); + error = tokudb_upsert_2_fun( + db, + key, + old_val, + extra, + set_val, + set_extra); break; default: - assert(0); - error = EINVAL; - break; + assert_unreachable(); } return error; } diff --git a/storage/xtradb/btr/btr0btr.cc b/storage/xtradb/btr/btr0btr.cc index caa35d31109..00a04e75c49 100644 --- a/storage/xtradb/btr/btr0btr.cc +++ b/storage/xtradb/btr/btr0btr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2014, 2015, MariaDB Corporation @@ -1146,7 +1146,7 @@ that the caller has made the reservation for free extents! @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) buf_block_t* btr_page_alloc_low( /*===============*/ @@ -2217,7 +2217,8 @@ btr_parse_page_reorganize( { ulint level; - ut_ad(ptr && end_ptr); + ut_ad(ptr != NULL); + ut_ad(end_ptr != NULL); /* If dealing with a compressed page the record has the compression level used during original compression written in @@ -2689,7 +2690,7 @@ func_exit: Returns TRUE if the insert fits on the appropriate half-page with the chosen split_rec. @return true if fits */ -static __attribute__((nonnull(1,3,4,6), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,3,4,6), warn_unused_result)) bool btr_page_insert_fits( /*=================*/ @@ -2832,7 +2833,7 @@ btr_insert_on_non_leaf_level_func( /**************************************************************//** Attaches the halves of an index page on the appropriate level in an index tree. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void btr_attach_half_pages( /*==================*/ @@ -2968,7 +2969,7 @@ btr_attach_half_pages( /*************************************************************//** Determine if a tuple is smaller than any record on the page. @return TRUE if smaller */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool btr_page_tuple_smaller( /*===================*/ @@ -3560,7 +3561,8 @@ btr_level_list_remove_func( ulint prev_page_no; ulint next_page_no; - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(space == page_get_space_id(page)); /* Get the previous and next page numbers of page */ diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc index 5bb94dfce2a..0d117e644d0 100644 --- a/storage/xtradb/btr/btr0cur.cc +++ b/storage/xtradb/btr/btr0cur.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. Copyright (c) 2015, MariaDB Corporation. @@ -1237,7 +1237,7 @@ This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). @return pointer to inserted record if succeed, else NULL */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) rec_t* btr_cur_insert_if_possible( /*=======================*/ @@ -1280,7 +1280,7 @@ btr_cur_insert_if_possible( /*************************************************************//** For an insert, checks the locks and does the undo logging if desired. @return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */ -UNIV_INLINE __attribute__((warn_unused_result, nonnull(2,3,5,6))) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result, nonnull(2,3,5,6))) dberr_t btr_cur_ins_lock_and_undo( /*======================*/ @@ -1843,7 +1843,7 @@ btr_cur_pessimistic_insert( /*************************************************************//** For an update, checks the locks and does the undo logging. @return DB_SUCCESS, DB_WAIT_LOCK, or error number */ -UNIV_INLINE __attribute__((warn_unused_result, nonnull(2,3,6,7))) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result, nonnull(2,3,6,7))) dberr_t btr_cur_upd_lock_and_undo( /*======================*/ @@ -1862,7 +1862,7 @@ btr_cur_upd_lock_and_undo( const rec_t* rec; dberr_t err; - ut_ad(thr || (flags & BTR_NO_LOCKING_FLAG)); + ut_ad((thr != NULL) || (flags & BTR_NO_LOCKING_FLAG)); if (UNIV_UNLIKELY(thr && thr_get_trx(thr)->fake_changes)) { /* skip LOCK, UNDO */ @@ -3208,7 +3208,7 @@ btr_cur_del_mark_set_clust_rec( ut_ad(page_is_leaf(page_align(rec))); #ifdef UNIV_DEBUG - if (btr_cur_print_record_ops && thr) { + if (btr_cur_print_record_ops && (thr != NULL)) { btr_cur_trx_report(thr_get_trx(thr)->id, index, "del mark "); rec_print_new(stderr, rec, offsets); } @@ -3366,7 +3366,7 @@ btr_cur_del_mark_set_sec_rec( rec = btr_cur_get_rec(cursor); #ifdef UNIV_DEBUG - if (btr_cur_print_record_ops && thr) { + if (btr_cur_print_record_ops && (thr != NULL)) { btr_cur_trx_report(thr_get_trx(thr)->id, cursor->index, "del mark "); rec_print(stderr, rec, cursor->index); @@ -5340,7 +5340,7 @@ btr_free_externally_stored_field( ulint i, /*!< in: field number of field_ref; ignored if rec == NULL */ enum trx_rb_ctx rb_ctx, /*!< in: rollback context */ - mtr_t* local_mtr __attribute__((unused))) /*!< in: mtr + mtr_t* local_mtr MY_ATTRIBUTE((unused))) /*!< in: mtr containing the latch to data an an X-latch to the index tree */ { diff --git a/storage/xtradb/btr/btr0sea.cc b/storage/xtradb/btr/btr0sea.cc index ac5e9aec67b..78cb9dfd6e0 100644 --- a/storage/xtradb/btr/btr0sea.cc +++ b/storage/xtradb/btr/btr0sea.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -512,7 +512,7 @@ btr_search_update_block_hash_info( /*==============================*/ btr_search_t* info, /*!< in: search info */ buf_block_t* block, /*!< in: buffer block */ - btr_cur_t* cursor __attribute__((unused))) + btr_cur_t* cursor MY_ATTRIBUTE((unused))) /*!< in: cursor */ { #ifdef UNIV_SYNC_DEBUG diff --git a/storage/xtradb/buf/buf0buddy.cc b/storage/xtradb/buf/buf0buddy.cc index 8f6be0cf2af..8cb880c1169 100644 --- a/storage/xtradb/buf/buf0buddy.cc +++ b/storage/xtradb/buf/buf0buddy.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -112,7 +112,7 @@ buf_buddy_mem_invalid( /**********************************************************************//** Check if a buddy is stamped free. @return whether the buddy is free */ -UNIV_INLINE __attribute__((warn_unused_result)) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) bool buf_buddy_stamp_is_free( /*====================*/ @@ -225,7 +225,7 @@ Checks if a buf is free i.e.: in the zip_free[]. @retval BUF_BUDDY_STATE_FREE if fully free @retval BUF_BUDDY_STATE_USED if currently in use @retval BUF_BUDDY_STATE_PARTIALLY_USED if partially in use. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) buf_buddy_state_t buf_buddy_is_free( /*==============*/ diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 556096ca7e4..a81d21a04b5 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. @@ -706,7 +706,7 @@ buf_page_is_corrupted( "InnoDB: " REFMAN "forcing-innodb-recovery.html\n" "InnoDB: for more information.\n", - (ulong) mach_read_from_4( + (ulint) mach_read_from_4( read_buf + FIL_PAGE_OFFSET), (lsn_t) mach_read_from_8( read_buf + FIL_PAGE_LSN), @@ -904,7 +904,7 @@ buf_page_print( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", - (ulong) size); + size); ut_print_buf(stderr, read_buf, size); fputs("\nInnoDB: End of page dump\n", stderr); } @@ -1544,6 +1544,7 @@ buf_pool_free_instance( buf_chunk_t* chunk; buf_chunk_t* chunks; buf_page_t* bpage; + ulint i; bpage = UT_LIST_GET_LAST(buf_pool->LRU); while (bpage != NULL) { @@ -1567,10 +1568,29 @@ buf_pool_free_instance( mem_free(buf_pool->watch); buf_pool->watch = NULL; + for (i = BUF_FLUSH_LRU; i < BUF_FLUSH_N_TYPES; i++) { + os_event_free(buf_pool->no_flush[i]); + } + mutex_free(&buf_pool->LRU_list_mutex); + mutex_free(&buf_pool->free_list_mutex); + mutex_free(&buf_pool->zip_free_mutex); + mutex_free(&buf_pool->zip_hash_mutex); + mutex_free(&buf_pool->zip_mutex); + mutex_free(&buf_pool->flush_state_mutex); + mutex_free(&buf_pool->flush_list_mutex); + chunks = buf_pool->chunks; chunk = chunks + buf_pool->n_chunks; while (--chunk >= chunks) { + buf_block_t* block = chunk->blocks; + for (i = 0; i < chunk->size; i++, block++) { + mutex_free(&block->mutex); + rw_lock_free(&block->lock); +#ifdef UNIV_SYNC_DEBUG + rw_lock_free(&block->debug_latch); +#endif + } os_mem_free_large(chunk->mem, chunk->mem_size); } @@ -2480,9 +2500,9 @@ buf_zip_decompress( } fprintf(stderr, - "InnoDB: unable to decompress space %lu page %lu\n", - (ulong) block->page.space, - (ulong) block->page.offset); + "InnoDB: unable to decompress space %u page %u\n", + block->page.space, + block->page.offset); return(FALSE); case FIL_PAGE_TYPE_ALLOCATED: @@ -3818,7 +3838,7 @@ buf_page_init_low( /********************************************************************//** Inits a page to the buffer buf_pool. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void buf_page_init( /*==========*/ @@ -3889,8 +3909,8 @@ buf_page_init( fprintf(stderr, "InnoDB: Error: page %lu %lu already found" " in the hash table: %p, %p\n", - (ulong) space, - (ulong) offset, + space, + offset, (const void*) hash_page, (const void*) block); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(&block->mutex); @@ -4258,7 +4278,7 @@ buf_page_create( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, "Creating space %lu page %lu to buffer\n", - (ulong) space, (ulong) offset); + space, offset); } #endif /* UNIV_DEBUG */ @@ -4666,10 +4686,10 @@ buf_page_io_complete( ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Error: reading page %lu\n" + " InnoDB: Error: reading page %u\n" "InnoDB: which is in the" " doublewrite buffer!\n", - (ulong) bpage->offset); + bpage->offset); } else if (!read_space_id && !read_page_no) { /* This is likely an uninitialized page. */ } else if ((bpage->space @@ -4685,10 +4705,11 @@ buf_page_io_complete( " InnoDB: Error: space id and page n:o" " stored in the page\n" "InnoDB: read in are %lu:%lu," - " should be %lu:%lu!\n", - (ulong) read_space_id, (ulong) read_page_no, - (ulong) bpage->space, - (ulong) bpage->offset); + " should be %u:%u!\n", + read_space_id, + read_page_no, + bpage->space, + bpage->offset); } if (UNIV_LIKELY(!bpage->is_corrupt || @@ -4722,10 +4743,10 @@ corrupt: "Database page corruption on disk" " or a failed"); ib_logf(IB_LOG_LEVEL_ERROR, - "Space %lu file %s read of page %lu.", - (ulint)bpage->space, + "Space %u file %s read of page %u.", + bpage->space, space ? space->name : "NULL", - (ulong) bpage->offset); + bpage->offset); ib_logf(IB_LOG_LEVEL_ERROR, "You may have to recover" " from a backup."); @@ -4953,8 +4974,8 @@ retry_mutex: if (buf_debug_prints) { fprintf(stderr, "Has %s page space %lu page no %lu\n", io_type == BUF_IO_READ ? "read" : "written", - (ulong) buf_page_get_space(bpage), - (ulong) buf_page_get_page_no(bpage)); + buf_page_get_space(bpage), + buf_page_get_page_no(bpage)); } #endif /* UNIV_DEBUG */ @@ -4989,11 +5010,21 @@ buf_all_freed_instance( mutex_exit(&buf_pool->LRU_list_mutex); if (UNIV_LIKELY_NULL(block)) { - if (block->page.key_version == 0) { - fprintf(stderr, - "Page %lu %lu still fixed or dirty\n", - (ulong) block->page.space, - (ulong) block->page.offset); + if (block->page.key_version == 0) { + fil_space_t* space = fil_space_get(block->page.space); + ib_logf(IB_LOG_LEVEL_ERROR, + "Page %u %u still fixed or dirty.", + block->page.space, + block->page.offset); + ib_logf(IB_LOG_LEVEL_ERROR, + "Page oldest_modification %lu fix_count %d io_fix %d.", + block->page.oldest_modification, + block->page.buf_fix_count, + buf_page_get_io_fix(&block->page)); + ib_logf(IB_LOG_LEVEL_ERROR, + "Page space_id %u name %s.", + block->page.space, + (space && space->name) ? space->name : "NULL"); ut_error; } } @@ -5286,8 +5317,8 @@ buf_pool_validate_instance( if (n_lru + n_free > buf_pool->curr_size + n_zip) { fprintf(stderr, "n LRU %lu, n free %lu, pool %lu zip %lu\n", - (ulong) n_lru, (ulong) n_free, - (ulong) buf_pool->curr_size, (ulong) n_zip); + n_lru, n_free, + buf_pool->curr_size, n_zip); ut_error; } @@ -5297,8 +5328,8 @@ buf_pool_validate_instance( if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { fprintf(stderr, "Free list len %lu, free blocks %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) n_free); + UT_LIST_GET_LEN(buf_pool->free), + n_free); ut_error; } @@ -5379,20 +5410,20 @@ buf_print_instance( "n pending flush LRU %lu list %lu single page %lu\n" "pages made young %lu, not young %lu\n" "pages read %lu, created %lu, written %lu\n", - (ulong) size, - (ulong) UT_LIST_GET_LEN(buf_pool->LRU), - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), - (ulong) buf_pool->n_pend_unzip, - (ulong) buf_pool->n_pend_reads, - (ulong) buf_pool->n_flush[BUF_FLUSH_LRU], - (ulong) buf_pool->n_flush[BUF_FLUSH_LIST], - (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], - (ulong) buf_pool->stat.n_pages_made_young, - (ulong) buf_pool->stat.n_pages_not_made_young, - (ulong) buf_pool->stat.n_pages_read, - (ulong) buf_pool->stat.n_pages_created, - (ulong) buf_pool->stat.n_pages_written); + (ulint) size, + (ulint) UT_LIST_GET_LEN(buf_pool->LRU), + (ulint) UT_LIST_GET_LEN(buf_pool->free), + (ulint) UT_LIST_GET_LEN(buf_pool->flush_list), + (ulint) buf_pool->n_pend_unzip, + (ulint) buf_pool->n_pend_reads, + (ulint) buf_pool->n_flush[BUF_FLUSH_LRU], + (ulint) buf_pool->n_flush[BUF_FLUSH_LIST], + (ulint) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], + (ulint) buf_pool->stat.n_pages_made_young, + (ulint) buf_pool->stat.n_pages_not_made_young, + (ulint) buf_pool->stat.n_pages_read, + (ulint) buf_pool->stat.n_pages_created, + (ulint) buf_pool->stat.n_pages_written); /* Count the number of blocks belonging to each index in the buffer */ @@ -5443,7 +5474,7 @@ buf_print_instance( fprintf(stderr, "Block count for index %llu in buffer is about %lu", (ullint) index_ids[i], - (ulong) counts[i]); + (ulint) counts[i]); if (index) { putc(' ', stderr); @@ -5897,10 +5928,10 @@ buf_print_io_instance( fprintf(file, "Buffer pool hit rate %lu / 1000," " young-making rate %lu / 1000 not %lu / 1000\n", - (ulong) hit_rate, - (ulong) (1000 * pool_info->young_making_delta + (ulint) hit_rate, + (ulint) (1000 * pool_info->young_making_delta / pool_info->n_page_get_delta), - (ulong) (1000 * pool_info->not_young_making_delta + (ulint) (1000 * pool_info->not_young_making_delta / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n", diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index a68bb8a1344..114c96cec98 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -105,7 +105,7 @@ SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; or by: SHOW STATUS LIKE 'innodb_buffer_pool_dump_status'; */ -static __attribute__((nonnull, format(printf, 2, 3))) +static MY_ATTRIBUTE((nonnull, format(printf, 2, 3))) void buf_dump_status( /*============*/ @@ -137,7 +137,7 @@ SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_LOAD_STATUS'; or by: SHOW STATUS LIKE 'innodb_buffer_pool_load_status'; */ -static __attribute__((nonnull, format(printf, 2, 3))) +static MY_ATTRIBUTE((nonnull, format(printf, 2, 3))) void buf_load_status( /*============*/ @@ -684,7 +684,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(buf_dump_thread)( /*============================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { ut_ad(!srv_read_only_mode); diff --git a/storage/xtradb/buf/buf0flu.cc b/storage/xtradb/buf/buf0flu.cc index 2440637ccca..a5ce3f3f983 100644 --- a/storage/xtradb/buf/buf0flu.cc +++ b/storage/xtradb/buf/buf0flu.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates -Copyright (c) 2013, 2015, MariaDB +Copyright (c) 1995, 2016, Oracle and/or its affiliates +Copyright (c) 2013, 2016, MariaDB Copyright (c) 2013, 2014, Fusion-io This program is free software; you can redistribute it and/or modify it under @@ -1506,7 +1506,7 @@ It attempts to make 'max' blocks available in the free list. Note that it is a best effort attempt and it is not guaranteed that after a call to this function there will be 'max' blocks in the free list. @return number of blocks for which the write request was queued. */ -__attribute__((nonnull)) +MY_ATTRIBUTE((nonnull)) static void buf_flush_LRU_list_batch( @@ -1652,7 +1652,7 @@ Whether LRU or unzip_LRU is used depends on the state of the system. @return number of blocks for which either the write request was queued or in case of unzip_LRU the number of blocks actually moved to the free list */ -__attribute__((nonnull)) +MY_ATTRIBUTE((nonnull)) static void buf_do_LRU_batch( @@ -1772,7 +1772,7 @@ pages: to avoid deadlocks, this function must be written so that it cannot end up waiting for these latches! NOTE 2: in the case of a flush list flush, the calling thread is not allowed to own any latches on pages! @return number of blocks for which the write request was queued */ -__attribute__((nonnull)) +MY_ATTRIBUTE((nonnull)) void buf_flush_batch( /*============*/ @@ -1969,7 +1969,7 @@ list. NOTE: The calling thread is not allowed to own any latches on pages! @return true if a batch was queued successfully. false if another batch of same type was already running. */ -__attribute__((nonnull)) +MY_ATTRIBUTE((nonnull)) static bool buf_flush_LRU( @@ -2642,7 +2642,7 @@ page_cleaner_sleep_if_needed( /*********************************************************************//** Returns the aggregate free list length over all buffer pool instances. @return total free list length. */ -__attribute__((warn_unused_result)) +MY_ATTRIBUTE((warn_unused_result)) static ulint buf_get_total_free_list_length(void) @@ -2660,7 +2660,7 @@ buf_get_total_free_list_length(void) /*********************************************************************//** Adjust the desired page cleaner thread sleep time for LRU flushes. */ -__attribute__((nonnull)) +MY_ATTRIBUTE((nonnull)) static void page_cleaner_adapt_lru_sleep_time( @@ -2699,7 +2699,7 @@ page_cleaner_adapt_lru_sleep_time( /*********************************************************************//** Get the desired page cleaner thread sleep time for flush list flushes. @return desired sleep time */ -__attribute__((warn_unused_result)) +MY_ATTRIBUTE((warn_unused_result)) static ulint page_cleaner_adapt_flush_sleep_time(void) @@ -2726,7 +2726,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner_thread)( /*==========================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -2878,7 +2878,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(buf_flush_lru_manager_thread)( /*==========================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { diff --git a/storage/xtradb/buf/buf0lru.cc b/storage/xtradb/buf/buf0lru.cc index b36136e4079..579166753c4 100644 --- a/storage/xtradb/buf/buf0lru.cc +++ b/storage/xtradb/buf/buf0lru.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -143,7 +143,7 @@ If a compressed page is freed other compressed pages may be relocated. caller needs to free the page to the free list @retval false if BUF_BLOCK_ZIP_PAGE was removed from page_hash. In this case the block is already returned to the buddy allocator. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool buf_LRU_block_remove_hashed( /*========================*/ @@ -368,7 +368,7 @@ want to hog the CPU and resources. Release the buffer pool and block mutex and try to force a context switch. Then reacquire the same mutexes. The current page is "fixed" before the release of the mutexes and then "unfixed" again once we have reacquired the mutexes. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void buf_flush_yield( /*============*/ @@ -407,7 +407,7 @@ If we have hogged the resources for too long then release the buffer pool and flush list mutex and do a thread yield. Set the current page to "sticky" so that it is not relocated during the yield. @return true if yielded */ -static __attribute__((nonnull(1), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1), warn_unused_result)) bool buf_flush_try_yield( /*================*/ @@ -476,7 +476,7 @@ buf_flush_try_yield( Removes a single page from a given tablespace inside a specific buffer pool instance. @return true if page was removed. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool buf_flush_or_remove_page( /*=====================*/ @@ -578,7 +578,7 @@ the list as they age towards the tail of the LRU. @retval DB_SUCCESS if all freed @retval DB_FAIL if not all freed @retval DB_INTERRUPTED if the transaction was interrupted */ -static __attribute__((nonnull(1), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1), warn_unused_result)) dberr_t buf_flush_or_remove_pages( /*======================*/ @@ -607,6 +607,7 @@ rescan: bpage != NULL; bpage = prev) { + ut_ad(!must_restart); ut_a(buf_page_in_file(bpage)); /* Save the previous link because once we free the @@ -624,9 +625,6 @@ rescan: /* Remove was unsuccessful, we have to try again by scanning the entire list from the end. - This also means that we never released the - flush list mutex. Therefore we can trust the prev - pointer. buf_flush_or_remove_page() released the flush list mutex but not the LRU list mutex. Therefore it is possible that a new page was @@ -643,6 +641,11 @@ rescan: iteration. */ all_freed = false; + if (UNIV_UNLIKELY(must_restart)) { + + /* Cannot trust the prev pointer */ + break; + } } else if (flush) { /* The processing was successful. And during the @@ -650,12 +653,9 @@ rescan: when calling buf_page_flush(). We cannot trust prev pointer. */ goto rescan; - } else if (UNIV_UNLIKELY(must_restart)) { - - ut_ad(!all_freed); - break; } + ut_ad(!must_restart); ++processed; /* Yield if we have hogged the CPU and mutexes for too long. */ @@ -666,6 +666,11 @@ rescan: /* Reset the batch size counter if we had to yield. */ processed = 0; + } else if (UNIV_UNLIKELY(must_restart)) { + + /* Cannot trust the prev pointer */ + all_freed = false; + break; } #ifdef DBUG_OFF @@ -694,7 +699,7 @@ Remove or flush all the dirty pages that belong to a given tablespace inside a specific buffer pool instance. The pages will remain in the LRU list and will be evicted from the LRU list as they age and move towards the tail of the LRU list. */ -static __attribute__((nonnull(1))) +static MY_ATTRIBUTE((nonnull(1))) void buf_flush_dirty_pages( /*==================*/ @@ -734,7 +739,7 @@ buf_flush_dirty_pages( /******************************************************************//** Remove all pages that belong to a given tablespace inside a specific buffer pool instance when we are DISCARDing the tablespace. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void buf_LRU_remove_all_pages( /*=====================*/ @@ -890,7 +895,7 @@ buffer pool instance when we are deleting the data file(s) of that tablespace. The pages still remain a part of LRU and are evicted from the list as they age towards the tail of the LRU only if buf_remove is BUF_REMOVE_FLUSH_NO_WRITE. */ -static __attribute__((nonnull(1))) +static MY_ATTRIBUTE((nonnull(1))) void buf_LRU_remove_pages( /*=================*/ diff --git a/storage/xtradb/data/data0data.cc b/storage/xtradb/data/data0data.cc index 179de79b69f..593af089b00 100644 --- a/storage/xtradb/data/data0data.cc +++ b/storage/xtradb/data/data0data.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -67,7 +67,8 @@ dtuple_coll_cmp( ulint n_fields; ulint i; - ut_ad(tuple1 && tuple2); + ut_ad(tuple1 != NULL); + ut_ad(tuple2 != NULL); ut_ad(tuple1->magic_n == DATA_TUPLE_MAGIC_N); ut_ad(tuple2->magic_n == DATA_TUPLE_MAGIC_N); ut_ad(dtuple_check_typed(tuple1)); @@ -715,7 +716,7 @@ UNIV_INTERN void dtuple_convert_back_big_rec( /*========================*/ - dict_index_t* index __attribute__((unused)), /*!< in: index */ + dict_index_t* index MY_ATTRIBUTE((unused)), /*!< in: index */ dtuple_t* entry, /*!< in: entry whose data was put to vector */ big_rec_t* vector) /*!< in, own: big rec vector; it is freed in this function */ diff --git a/storage/xtradb/dict/dict0crea.cc b/storage/xtradb/dict/dict0crea.cc index 68cbde8c342..870e452e5f2 100644 --- a/storage/xtradb/dict/dict0crea.cc +++ b/storage/xtradb/dict/dict0crea.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -246,7 +246,7 @@ dict_create_sys_columns_tuple( /***************************************************************//** Builds a table definition to insert. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_build_table_def_step( /*======================*/ @@ -574,7 +574,7 @@ dict_create_search_tuple( /***************************************************************//** Builds an index definition row to insert. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_build_index_def_step( /*======================*/ @@ -649,7 +649,7 @@ dict_build_field_def_step( /***************************************************************//** Creates an index tree for the index if it is not a member of a cluster. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_create_index_tree_step( /*========================*/ @@ -1369,7 +1369,7 @@ dict_create_or_check_foreign_constraint_tables(void) ib_logf(IB_LOG_LEVEL_WARN, "Dropping incompletely created " "SYS_FOREIGN table."); - row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE); } if (sys_foreign_cols_err == DB_CORRUPTION) { @@ -1377,7 +1377,7 @@ dict_create_or_check_foreign_constraint_tables(void) "Dropping incompletely created " "SYS_FOREIGN_COLS table."); - row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE); } ib_logf(IB_LOG_LEVEL_WARN, @@ -1431,8 +1431,8 @@ dict_create_or_check_foreign_constraint_tables(void) ut_ad(err == DB_OUT_OF_FILE_SPACE || err == DB_TOO_MANY_CONCURRENT_TRXS); - row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE); - row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE); + row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE); if (err == DB_OUT_OF_FILE_SPACE) { err = DB_MUST_GET_MORE_FILE_SPACE; @@ -1468,7 +1468,7 @@ dict_create_or_check_foreign_constraint_tables(void) /****************************************************************//** Evaluate the given foreign key SQL statement. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_foreign_eval_sql( /*==================*/ @@ -1534,7 +1534,7 @@ dict_foreign_eval_sql( Add a single foreign key field definition to the data dictionary tables in the database. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t dict_create_add_foreign_field_to_dictionary( /*========================================*/ @@ -1856,7 +1856,7 @@ dict_create_or_check_sys_tablespace(void) ib_logf(IB_LOG_LEVEL_WARN, "Dropping incompletely created " "SYS_TABLESPACES table."); - row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE); + row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE); } if (sys_datafiles_err == DB_CORRUPTION) { @@ -1864,7 +1864,7 @@ dict_create_or_check_sys_tablespace(void) "Dropping incompletely created " "SYS_DATAFILES table."); - row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE); + row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE); } ib_logf(IB_LOG_LEVEL_INFO, @@ -1900,8 +1900,8 @@ dict_create_or_check_sys_tablespace(void) ut_a(err == DB_OUT_OF_FILE_SPACE || err == DB_TOO_MANY_CONCURRENT_TRXS); - row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE); - row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE); + row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE); + row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE); if (err == DB_OUT_OF_FILE_SPACE) { err = DB_MUST_GET_MORE_FILE_SPACE; diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc index a147fbbc671..86ec720d24e 100644 --- a/storage/xtradb/dict/dict0dict.cc +++ b/storage/xtradb/dict/dict0dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -6309,7 +6309,7 @@ dict_set_corrupted_index_cache_only( dict_index_t* index, /*!< in/out: index */ dict_table_t* table) /*!< in/out: table */ { - ut_ad(index); + ut_ad(index != NULL); ut_ad(mutex_own(&dict_sys->mutex)); ut_ad(!dict_table_is_comp(dict_sys->sys_tables)); ut_ad(!dict_table_is_comp(dict_sys->sys_indexes)); @@ -6319,8 +6319,9 @@ dict_set_corrupted_index_cache_only( if (dict_index_is_clust(index)) { dict_table_t* corrupt_table; - corrupt_table = table ? table : index->table; - ut_ad(!index->table || !table || index->table == table); + corrupt_table = (table != NULL) ? table : index->table; + ut_ad((index->table != NULL) || (table != NULL) + || index->table == table); if (corrupt_table) { corrupt_table->corrupted = TRUE; @@ -6438,11 +6439,6 @@ dict_table_get_index_on_name( { dict_index_t* index; - /* If name is NULL, just return */ - if (!name) { - return(NULL); - } - index = dict_table_get_first_index(table); while (index != NULL) { diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc index 3d3a35e5c8e..3dcdfc7c61a 100644 --- a/storage/xtradb/dict/dict0load.cc +++ b/storage/xtradb/dict/dict0load.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -1751,7 +1751,7 @@ err_len: goto err_len; } type = mach_read_from_4(field); - if (type & (~0 << DICT_IT_BITS)) { + if (type & (~0U << DICT_IT_BITS)) { return("unknown SYS_INDEXES.TYPE bits"); } @@ -1791,7 +1791,7 @@ Loads definitions for table indexes. Adds them to the data dictionary cache. @return DB_SUCCESS if ok, DB_CORRUPTION if corruption of dictionary table or DB_UNSUPPORTED if table has unknown index type */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t dict_load_indexes( /*==============*/ @@ -2539,6 +2539,7 @@ func_exit: /* the table->fts could be created in dict_load_column when a user defined FTS_DOC_ID is present, but no FTS */ + fts_optimize_remove_table(table); fts_free(table); } else { fts_optimize_add_table(table); @@ -2604,14 +2605,13 @@ dict_load_table_on_id( btr_pcur_open_on_user_rec(sys_table_ids, tuple, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr); -check_rec: rec = btr_pcur_get_rec(&pcur); if (page_rec_is_user_rec(rec)) { /*---------------------------------------------------*/ /* Now we have the record in the secondary index containing the table ID and NAME */ - +check_rec: field = rec_get_nth_field_old( rec, DICT_FLD__SYS_TABLE_IDS__ID, &len); ut_ad(len == 8); @@ -2621,12 +2621,14 @@ check_rec: if (rec_get_deleted_flag(rec, 0)) { /* Until purge has completed, there may be delete-marked duplicate records - for the same SYS_TABLES.ID. - Due to Bug #60049, some delete-marked - records may survive the purge forever. */ - if (btr_pcur_move_to_next(&pcur, &mtr)) { + for the same SYS_TABLES.ID, but different + SYS_TABLES.NAME. */ + while (btr_pcur_move_to_next(&pcur, &mtr)) { + rec = btr_pcur_get_rec(&pcur); - goto check_rec; + if (page_rec_is_user_rec(rec)) { + goto check_rec; + } } } else { /* Now we get the table name from the record */ @@ -2888,7 +2890,7 @@ dict_load_foreign_cols( /***********************************************************************//** Loads a foreign key constraint to the dictionary cache. @return DB_SUCCESS or error code */ -static __attribute__((nonnull(1), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1), warn_unused_result)) dberr_t dict_load_foreign( /*==============*/ diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index a4f6cd6c91f..bde72b83c54 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -306,7 +306,7 @@ dict_mem_table_add_col( /**********************************************************************//** Renames a column of a table in the data dictionary cache. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void dict_mem_table_col_rename_low( /*==========================*/ diff --git a/storage/xtradb/dict/dict0stats_bg.cc b/storage/xtradb/dict/dict0stats_bg.cc index e7842d3da9a..5f24bb2b742 100644 --- a/storage/xtradb/dict/dict0stats_bg.cc +++ b/storage/xtradb/dict/dict0stats_bg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -528,7 +528,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(dict_stats_thread)( /*==============================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { ut_a(!srv_read_only_mode); @@ -549,14 +549,6 @@ DECLARE_THREAD(dict_stats_thread)( break; } -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - if (srv_ibuf_disable_background_merge) { - usleep(100000); - os_event_reset(dict_stats_event); - continue; - } -#endif - dict_stats_process_entry_from_recalc_pool(); while (defrag_pool.size()) diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 9fad34257b8..58e08f11778 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under @@ -1432,6 +1432,28 @@ fil_space_free( return(TRUE); } +/*******************************************************************//** +Returns a pointer to the file_space_t that is in the memory cache +associated with a space id. +@return file_space_t pointer, NULL if space not found */ +fil_space_t* +fil_space_get( +/*==========*/ + ulint id) /*!< in: space id */ +{ + fil_space_t* space; + + ut_ad(fil_system); + + mutex_enter(&fil_system->mutex); + + space = fil_space_get_by_id(id); + + mutex_exit(&fil_system->mutex); + + return (space); +} + /*******************************************************************//** Returns a pointer to the file_space_t that is in the memory cache associated with a space id. The caller must lock fil_system->mutex. @@ -1852,7 +1874,7 @@ fil_set_max_space_id_if_bigger( Writes the flushed lsn and the latest archived log number to the page header of the first page of a data file of the system tablespace (space 0), which is uncompressed. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) dberr_t fil_write_lsn_and_arch_no_to_file( /*==============================*/ @@ -1860,7 +1882,7 @@ fil_write_lsn_and_arch_no_to_file( ulint sum_of_sizes, /*!< in: combined size of previous files in space, in database pages */ lsn_t lsn, /*!< in: lsn to write */ - ulint arch_log_no __attribute__((unused))) + ulint arch_log_no MY_ATTRIBUTE((unused))) /*!< in: archived log number to write */ { byte* buf1; @@ -1948,7 +1970,7 @@ Checks the consistency of the first data page of a tablespace at database startup. @retval NULL on success, or if innodb_force_recovery is set @return pointer to an error message string */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) const char* fil_check_first_page( /*=================*/ @@ -5292,7 +5314,7 @@ retry: if (posix_fallocate(node->handle, start_offset, len) == -1) { ib_logf(IB_LOG_LEVEL_ERROR, "preallocating file " "space for file \'%s\' failed. Current size " - INT64PF ", desired size " INT64PF "\n", + INT64PF ", desired size " INT64PF, node->name, start_offset, len+start_offset); os_file_handle_error_no_exit(node->name, "posix_fallocate", FALSE, __FILE__, __LINE__); success = FALSE; @@ -6454,10 +6476,7 @@ fil_close(void) { fil_space_crypt_cleanup(); -#ifndef UNIV_HOTBACKUP - /* The mutex should already have been freed. */ - ut_ad(fil_system->mutex.magic_n == 0); -#endif /* !UNIV_HOTBACKUP */ + mutex_free(&fil_system->mutex); hash_table_free(fil_system->spaces); @@ -7106,27 +7125,6 @@ fil_mtr_rename_log( /************************************************************************* functions to access is_corrupt flag of fil_space_t*/ -ibool -fil_space_is_corrupt( -/*=================*/ - ulint space_id) -{ - fil_space_t* space; - ibool ret = FALSE; - - mutex_enter(&fil_system->mutex); - - space = fil_space_get_by_id(space_id); - - if (UNIV_UNLIKELY(space && space->is_corrupt)) { - ret = TRUE; - } - - mutex_exit(&fil_system->mutex); - - return(ret); -} - void fil_space_set_corrupt( /*==================*/ diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index 790232edb66..4acfd134c1f 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -94,7 +94,7 @@ fseg_n_reserved_pages_low( /********************************************************************//** Marks a page used. The page must reside within the extents of the given segment. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fseg_mark_page_used( /*================*/ @@ -133,7 +133,7 @@ fsp_fill_free_list( ulint space, /*!< in: space */ fsp_header_t* header, /*!< in/out: space header */ mtr_t* mtr) /*!< in/out: mini-transaction */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space @@ -162,7 +162,7 @@ fseg_alloc_free_page_low( in which the page should be initialized. If init_mtr!=mtr, but the page is already latched in mtr, do not initialize the page. */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -429,7 +429,7 @@ descriptor resides is x-locked. This function no longer extends the data file. @return pointer to the extent descriptor, NULL if the page does not exist in the space or if the offset is >= the free limit */ -UNIV_INLINE __attribute__((nonnull, warn_unused_result)) +UNIV_INLINE MY_ATTRIBUTE((nonnull, warn_unused_result)) xdes_t* xdes_get_descriptor_with_space_hdr( /*===============================*/ @@ -488,7 +488,7 @@ descriptor resides is x-locked. This function no longer extends the data file. @return pointer to the extent descriptor, NULL if the page does not exist in the space or if the offset exceeds the free limit */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) xdes_t* xdes_get_descriptor( /*================*/ @@ -618,7 +618,7 @@ byte* fsp_parse_init_file_page( /*=====================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ buf_block_t* block) /*!< in: block or NULL */ { ut_ad(ptr && end_ptr); @@ -859,7 +859,7 @@ fsp_header_get_tablespace_size(void) Tries to extend a single-table tablespace so that a page would fit in the data file. @return TRUE if success */ -static UNIV_COLD __attribute__((nonnull, warn_unused_result)) +static UNIV_COLD MY_ATTRIBUTE((nonnull, warn_unused_result)) ibool fsp_try_extend_data_file_with_pages( /*================================*/ @@ -891,7 +891,7 @@ fsp_try_extend_data_file_with_pages( /***********************************************************************//** Tries to extend the last data file of a tablespace if it is auto-extending. @return FALSE if not auto-extending */ -static UNIV_COLD __attribute__((nonnull)) +static UNIV_COLD MY_ATTRIBUTE((nonnull)) ibool fsp_try_extend_data_file( /*=====================*/ @@ -1073,7 +1073,8 @@ fsp_fill_free_list( ulint i; mtr_t ibuf_mtr; - ut_ad(header && mtr); + ut_ad(header != NULL); + ut_ad(mtr != NULL); ut_ad(page_offset(header) == FSP_HEADER_OFFSET); /* Check if we can fill free list from above the free list limit */ @@ -1245,7 +1246,7 @@ fsp_alloc_free_extent( /**********************************************************************//** Allocates a single free page from a space. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fsp_alloc_from_free_frag( /*=====================*/ @@ -1336,7 +1337,7 @@ Allocates a single free page from a space. The page is marked as used. @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) buf_block_t* fsp_alloc_free_page( /*================*/ @@ -1585,9 +1586,9 @@ fsp_seg_inode_page_get_nth_inode( /*=============================*/ page_t* page, /*!< in: segment inode page */ ulint i, /*!< in: inode index on page */ - ulint zip_size __attribute__((unused)), + ulint zip_size MY_ATTRIBUTE((unused)), /*!< in: compressed page size, or 0 */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in/out: mini-transaction */ { ut_ad(i < FSP_SEG_INODES_PER_PAGE(zip_size)); @@ -1892,7 +1893,7 @@ fseg_get_nth_frag_page_no( /*======================*/ fseg_inode_t* inode, /*!< in: segment inode */ ulint n, /*!< in: slot index */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in/out: mini-transaction */ { ut_ad(inode && mtr); @@ -2986,7 +2987,7 @@ fsp_get_available_space_in_free_extents( /********************************************************************//** Marks a page used. The page must reside within the extents of the given segment. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fseg_mark_page_used( /*================*/ @@ -3058,7 +3059,8 @@ fseg_free_page_low( ib_id_t seg_id; ulint i; - ut_ad(seg_inode && mtr); + ut_ad(seg_inode != NULL); + ut_ad(mtr != NULL); ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); @@ -3273,7 +3275,8 @@ fseg_free_extent( ulint descr_n_used; ulint i; - ut_ad(seg_inode && mtr); + ut_ad(seg_inode != NULL); + ut_ad(mtr != NULL); descr = xdes_get_descriptor(space, zip_size, page, mtr); diff --git a/storage/xtradb/fts/fts0blex.cc b/storage/xtradb/fts/fts0blex.cc index 7d0acb00a3b..2d71934fa0e 100644 --- a/storage/xtradb/fts/fts0blex.cc +++ b/storage/xtradb/fts/fts0blex.cc @@ -305,9 +305,9 @@ YY_BUFFER_STATE fts0b_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner YY_BUFFER_STATE fts0b_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE fts0b_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -void *fts0balloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void *fts0brealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void fts0bfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0balloc (yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void *fts0brealloc (void *,yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void fts0bfree (void * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); #define yy_new_buffer fts0b_create_buffer @@ -347,7 +347,7 @@ typedef int yy_state_type; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -451,7 +451,7 @@ static yyconst flex_int16_t yy_chk[32] = #line 1 "fts0blex.l" /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -579,11 +579,11 @@ extern int fts0bwrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifndef YY_NO_INPUT @@ -1609,7 +1609,7 @@ YY_BUFFER_STATE fts0b_scan_bytes (yyconst char * yybytes, int _yybytes_len , y #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -1910,7 +1910,7 @@ int fts0blex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int i; for ( i = 0; i < n; ++i ) @@ -1919,7 +1919,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yys #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int n; for ( n = 0; s[n]; ++n ) @@ -1929,12 +1929,12 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __at } #endif -void *fts0balloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0balloc (yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { return (void *) malloc( size ); } -void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -1946,7 +1946,7 @@ void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner return (void *) realloc( (char *) ptr, size ); } -void fts0bfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void fts0bfree (void * ptr , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { free( (char *) ptr ); /* see fts0brealloc() for (char *) cast */ } diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 712dfa264d4..5e008b37b8d 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -260,16 +260,18 @@ static const char* fts_config_table_insert_values_sql = "INSERT INTO \"%s\" VALUES ('" FTS_TABLE_STATE "', '0');\n"; -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the +/** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. -@return DB_SUCCESS if all OK */ +@param[in,out] sync sync state +@param[in] unlock_cache whether unlock cache lock when write node +@param[in] wait whether wait when a sync is in progress +@return DB_SUCCESS if all OK */ static dberr_t fts_sync( -/*=====*/ - fts_sync_t* sync) /*!< in: sync state */ - __attribute__((nonnull)); + fts_sync_t* sync, + bool unlock_cache, + bool wait); /****************************************************************//** Release all resources help by the words rb tree e.g., the node ilist. */ @@ -278,7 +280,7 @@ void fts_words_free( /*===========*/ ib_rbt_t* words) /*!< in: rb tree of words */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef FTS_CACHE_SIZE_DEBUG /****************************************************************//** Read the max cache size parameter from the config table. */ @@ -300,7 +302,7 @@ fts_add_doc_by_id( /*==============*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ doc_id_t doc_id, /*!< in: doc id */ - ib_vector_t* fts_indexes __attribute__((unused))); + ib_vector_t* fts_indexes MY_ATTRIBUTE((unused))); /*!< in: affected fts indexes */ #ifdef FTS_DOC_STATS_DEBUG /****************************************************************//** @@ -315,7 +317,7 @@ fts_is_word_in_index( fts_table_t* fts_table, /*!< in: table instance */ const fts_string_t* word, /*!< in: the word to check */ ibool* found) /*!< out: TRUE if exists */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* FTS_DOC_STATS_DEBUG */ /******************************************************************//** @@ -330,7 +332,7 @@ fts_update_sync_doc_id( const char* table_name, /*!< in: table name, or NULL */ doc_id_t doc_id, /*!< in: last document id */ trx_t* trx) /*!< in: update trx, or NULL */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /****************************************************************//** This function loads the default InnoDB stopword list */ @@ -653,6 +655,7 @@ fts_cache_create( mem_heap_zalloc(heap, sizeof(fts_sync_t))); cache->sync->table = table; + cache->sync->event = os_event_create(); /* Create the index cache vector that will hold the inverted indexes. */ cache->indexes = ib_vector_create( @@ -1072,13 +1075,12 @@ fts_words_free( } } -/*********************************************************************//** -Clear cache. */ +/** Clear cache. +@param[in,out] cache fts cache */ UNIV_INTERN void fts_cache_clear( -/*============*/ - fts_cache_t* cache) /*!< in: cache */ + fts_cache_t* cache) { ulint i; @@ -1207,6 +1209,7 @@ fts_cache_destroy( mutex_free(&cache->optimize_lock); mutex_free(&cache->deleted_lock); mutex_free(&cache->doc_id_lock); + os_event_free(cache->sync->event); if (cache->stopword_info.cached_stopword) { rbt_free(cache->stopword_info.cached_stopword); @@ -1435,7 +1438,7 @@ fts_cache_add_doc( ib_vector_last(word->nodes)); } - if (fts_node == NULL + if (fts_node == NULL || fts_node->synced || fts_node->ilist_size > FTS_ILIST_MAX_SIZE || doc_id < fts_node->last_doc_id) { @@ -1473,7 +1476,7 @@ fts_cache_add_doc( /****************************************************************//** Drops a table. If the table can't be found we return a SUCCESS code. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_drop_table( /*===========*/ @@ -1515,7 +1518,7 @@ fts_drop_table( /****************************************************************//** Rename a single auxiliary table due to database name change. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_rename_one_aux_table( /*=====================*/ @@ -1624,7 +1627,7 @@ Drops the common ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have been called before this. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_drop_common_tables( /*===================*/ @@ -1751,7 +1754,7 @@ Drops FTS ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have been called before this. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_drop_all_index_tables( /*======================*/ @@ -1915,7 +1918,7 @@ func_exit: trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(table->name, trx, FALSE); + row_drop_table_for_mysql(table->name, trx, FALSE, TRUE); trx->error_state = DB_SUCCESS; } @@ -2067,7 +2070,7 @@ fts_create_index_tables_low( trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE, TRUE); trx->error_state = DB_SUCCESS; } @@ -2659,7 +2662,7 @@ fts_get_next_doc_id( This function fetch the Doc ID from CONFIG table, and compare with the Doc ID supplied. And store the larger one to the CONFIG table. @return DB_SUCCESS if OK */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_cmp_set_sync_doc_id( /*====================*/ @@ -2886,41 +2889,34 @@ fts_doc_ids_free( } /*********************************************************************//** -Do commit-phase steps necessary for the insertion of a new row. -@return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) -dberr_t +Do commit-phase steps necessary for the insertion of a new row. */ +void fts_add( /*====*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ fts_trx_row_t* row) /*!< in: row */ { dict_table_t* table = ftt->table; - dberr_t error = DB_SUCCESS; doc_id_t doc_id = row->doc_id; ut_a(row->state == FTS_INSERT || row->state == FTS_MODIFY); fts_add_doc_by_id(ftt, doc_id, row->fts_indexes); - if (error == DB_SUCCESS) { - mutex_enter(&table->fts->cache->deleted_lock); - ++table->fts->cache->added; - mutex_exit(&table->fts->cache->deleted_lock); + mutex_enter(&table->fts->cache->deleted_lock); + ++table->fts->cache->added; + mutex_exit(&table->fts->cache->deleted_lock); - if (!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID) - && doc_id >= table->fts->cache->next_doc_id) { - table->fts->cache->next_doc_id = doc_id + 1; - } + if (!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID) + && doc_id >= table->fts->cache->next_doc_id) { + table->fts->cache->next_doc_id = doc_id + 1; } - - return(error); } /*********************************************************************//** Do commit-phase steps necessary for the deletion of a row. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_delete( /*=======*/ @@ -3011,7 +3007,7 @@ fts_delete( /*********************************************************************//** Do commit-phase steps necessary for the modification of a row. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_modify( /*=======*/ @@ -3025,7 +3021,7 @@ fts_modify( error = fts_delete(ftt, row); if (error == DB_SUCCESS) { - error = fts_add(ftt, row); + fts_add(ftt, row); } return(error); @@ -3082,7 +3078,7 @@ fts_create_doc_id( The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_commit_table( /*=============*/ @@ -3114,7 +3110,7 @@ fts_commit_table( switch (row->state) { case FTS_INSERT: - error = fts_add(ftt, row); + fts_add(ftt, row); break; case FTS_MODIFY: @@ -3416,7 +3412,7 @@ fts_add_doc_by_id( /*==============*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ doc_id_t doc_id, /*!< in: doc id */ - ib_vector_t* fts_indexes __attribute__((unused))) + ib_vector_t* fts_indexes MY_ATTRIBUTE((unused))) /*!< in: affected fts indexes */ { mtr_t mtr; @@ -3536,7 +3532,7 @@ fts_add_doc_by_id( get_doc, clust_index, doc_pcur, offsets, &doc); if (doc.found) { - ibool success __attribute__((unused)); + ibool success MY_ATTRIBUTE((unused)); btr_pcur_store_position(doc_pcur, &mtr); mtr_commit(&mtr); @@ -3554,16 +3550,34 @@ fts_add_doc_by_id( get_doc->index_cache, doc_id, doc.tokens); + bool need_sync = false; + if ((cache->total_size > fts_max_cache_size / 10 + || fts_need_sync) + && !cache->sync->in_progress) { + need_sync = true; + } + rw_lock_x_unlock(&table->fts->cache->lock); DBUG_EXECUTE_IF( "fts_instrument_sync", - fts_sync(cache->sync); + fts_optimize_request_sync_table(table); + os_event_wait(cache->sync->event); ); - if (cache->total_size > fts_max_cache_size - || fts_need_sync) { - fts_sync(cache->sync); + DBUG_EXECUTE_IF( + "fts_instrument_sync_debug", + fts_sync(cache->sync, true, true); + ); + + DEBUG_SYNC_C("fts_instrument_sync_request"); + DBUG_EXECUTE_IF( + "fts_instrument_sync_request", + fts_optimize_request_sync_table(table); + ); + + if (need_sync) { + fts_optimize_request_sync_table(table); } mtr_start(&mtr); @@ -3627,7 +3641,7 @@ fts_get_max_doc_id( dict_table_t* table) /*!< in: user table */ { dict_index_t* index; - dict_field_t* dfield __attribute__((unused)) = NULL; + dict_field_t* dfield MY_ATTRIBUTE((unused)) = NULL; doc_id_t doc_id = 0; mtr_t mtr; btr_pcur_t pcur; @@ -3885,7 +3899,7 @@ fts_write_node( /*********************************************************************//** Add rows to the DELETED_CACHE table. @return DB_SUCCESS if all went well else error code*/ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_add_deleted_cache( /*=======================*/ @@ -3934,16 +3948,17 @@ fts_sync_add_deleted_cache( return(error); } -/*********************************************************************//** -Write the words and ilist to disk. +/** Write the words and ilist to disk. +@param[in,out] trx transaction +@param[in] index_cache index cache +@param[in] unlock_cache whether unlock cache when write node @return DB_SUCCESS if all went well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_write_words( -/*=================*/ - trx_t* trx, /*!< in: transaction */ - fts_index_cache_t* - index_cache) /*!< in: index cache */ + trx_t* trx, + fts_index_cache_t* index_cache, + bool unlock_cache) { fts_table_t fts_table; ulint n_nodes = 0; @@ -3951,8 +3966,8 @@ fts_sync_write_words( const ib_rbt_node_t* rbt_node; dberr_t error = DB_SUCCESS; ibool print_error = FALSE; -#ifdef FTS_DOC_STATS_DEBUG dict_table_t* table = index_cache->index->table; +#ifdef FTS_DOC_STATS_DEBUG ulint n_new_words = 0; #endif /* FTS_DOC_STATS_DEBUG */ @@ -3965,7 +3980,7 @@ fts_sync_write_words( since we want to free the memory used during caching. */ for (rbt_node = rbt_first(index_cache->words); rbt_node; - rbt_node = rbt_first(index_cache->words)) { + rbt_node = rbt_next(index_cache->words, rbt_node)) { ulint i; ulint selected; @@ -3998,27 +4013,47 @@ fts_sync_write_words( } #endif /* FTS_DOC_STATS_DEBUG */ - n_nodes += ib_vector_size(word->nodes); - - /* We iterate over all the nodes even if there was an error, - this is to free the memory of the fts_node_t elements. */ + /* We iterate over all the nodes even if there was an error */ for (i = 0; i < ib_vector_size(word->nodes); ++i) { fts_node_t* fts_node = static_cast( ib_vector_get(word->nodes, i)); + if (fts_node->synced) { + continue; + } else { + fts_node->synced = true; + } + + /*FIXME: we need to handle the error properly. */ if (error == DB_SUCCESS) { + if (unlock_cache) { + rw_lock_x_unlock( + &table->fts->cache->lock); + } error = fts_write_node( trx, &index_cache->ins_graph[selected], &fts_table, &word->text, fts_node); - } - ut_free(fts_node->ilist); - fts_node->ilist = NULL; + DEBUG_SYNC_C("fts_write_node"); + DBUG_EXECUTE_IF("fts_write_node_crash", + DBUG_SUICIDE();); + + DBUG_EXECUTE_IF("fts_instrument_sync_sleep", + os_thread_sleep(1000000); + ); + + if (unlock_cache) { + rw_lock_x_lock( + &table->fts->cache->lock); + } + } } + n_nodes += ib_vector_size(word->nodes); + if (error != DB_SUCCESS && !print_error) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error (%s) writing " @@ -4027,9 +4062,6 @@ fts_sync_write_words( print_error = TRUE; } - - /* NOTE: We are responsible for free'ing the node */ - ut_free(rbt_remove_node(index_cache->words, rbt_node)); } #ifdef FTS_DOC_STATS_DEBUG @@ -4057,7 +4089,7 @@ fts_sync_write_words( /*********************************************************************//** Write a single documents statistics to disk. @return DB_SUCCESS if all went well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_write_doc_stat( /*====================*/ @@ -4311,7 +4343,7 @@ fts_sync_begin( Run SYNC on the table, i.e., write out data from the index specific cache to the FTS aux INDEX table and FTS aux doc id stats table. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_index( /*===========*/ @@ -4330,7 +4362,7 @@ fts_sync_index( ut_ad(rbt_validate(index_cache->words)); - error = fts_sync_write_words(trx, index_cache); + error = fts_sync_write_words(sync->trx, index_cache, sync->unlock_cache); #ifdef FTS_DOC_STATS_DEBUG /* FTS_RESOLVE: the word counter info in auxiliary table "DOC_ID" @@ -4346,10 +4378,40 @@ fts_sync_index( return(error); } +/** Check if index cache has been synced completely +@param[in,out] sync sync state +@param[in,out] index_cache index cache +@return true if index is synced, otherwise false. */ +static +bool +fts_sync_index_check( + fts_sync_t* sync, + fts_index_cache_t* index_cache) +{ + const ib_rbt_node_t* rbt_node; + + for (rbt_node = rbt_first(index_cache->words); + rbt_node != NULL; + rbt_node = rbt_next(index_cache->words, rbt_node)) { + + fts_tokenizer_word_t* word; + word = rbt_value(fts_tokenizer_word_t, rbt_node); + + fts_node_t* fts_node; + fts_node = static_cast(ib_vector_last(word->nodes)); + + if (!fts_node->synced) { + return(false); + } + } + + return(true); +} + /*********************************************************************//** Commit the SYNC, change state of processed doc ids etc. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_sync_commit( /*============*/ @@ -4411,32 +4473,63 @@ fts_sync_commit( return(error); } -/*********************************************************************//** -Rollback a sync operation */ +/** Rollback a sync operation +@param[in,out] sync sync state */ static void fts_sync_rollback( -/*==============*/ - fts_sync_t* sync) /*!< in: sync state */ + fts_sync_t* sync) { trx_t* trx = sync->trx; fts_cache_t* cache = sync->table->fts->cache; + for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) { + ulint j; + fts_index_cache_t* index_cache; + + index_cache = static_cast( + ib_vector_get(cache->indexes, i)); + + for (j = 0; fts_index_selector[j].value; ++j) { + + if (index_cache->ins_graph[j] != NULL) { + + fts_que_graph_free_check_lock( + NULL, index_cache, + index_cache->ins_graph[j]); + + index_cache->ins_graph[j] = NULL; + } + + if (index_cache->sel_graph[j] != NULL) { + + fts_que_graph_free_check_lock( + NULL, index_cache, + index_cache->sel_graph[j]); + + index_cache->sel_graph[j] = NULL; + } + } + } + rw_lock_x_unlock(&cache->lock); fts_sql_rollback(trx); trx_free_for_background(trx); } -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the +/** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] sync sync state +@param[in] unlock_cache whether unlock cache lock when write node +@param[in] wait whether wait when a sync is in progress @return DB_SUCCESS if all OK */ static dberr_t fts_sync( -/*=====*/ - fts_sync_t* sync) /*!< in: sync state */ + fts_sync_t* sync, + bool unlock_cache, + bool wait) { ulint i; dberr_t error = DB_SUCCESS; @@ -4444,8 +4537,35 @@ fts_sync( rw_lock_x_lock(&cache->lock); + /* Check if cache is being synced. + Note: we release cache lock in fts_sync_write_words() to + avoid long wait for the lock by other threads. */ + while (sync->in_progress) { + rw_lock_x_unlock(&cache->lock); + + if (wait) { + os_event_wait(sync->event); + } else { + return(DB_SUCCESS); + } + + rw_lock_x_lock(&cache->lock); + } + + sync->unlock_cache = unlock_cache; + sync->in_progress = true; + + DEBUG_SYNC_C("fts_sync_begin"); fts_sync_begin(sync); +begin_sync: + if (cache->total_size > fts_max_cache_size) { + /* Avoid the case: sync never finish when + insert/update keeps comming. */ + ut_ad(sync->unlock_cache); + sync->unlock_cache = false; + } + for (i = 0; i < ib_vector_size(cache->indexes); ++i) { fts_index_cache_t* index_cache; @@ -4460,21 +4580,43 @@ fts_sync( if (error != DB_SUCCESS && !sync->interrupted) { - break; + goto end_sync; } } DBUG_EXECUTE_IF("fts_instrument_sync_interrupted", sync->interrupted = true; error = DB_INTERRUPTED; + goto end_sync; ); + /* Make sure all the caches are synced. */ + for (i = 0; i < ib_vector_size(cache->indexes); ++i) { + fts_index_cache_t* index_cache; + + index_cache = static_cast( + ib_vector_get(cache->indexes, i)); + + if (index_cache->index->to_be_dropped + || fts_sync_index_check(sync, index_cache)) { + continue; + } + + goto begin_sync; + } + +end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); } else { fts_sync_rollback(sync); } + rw_lock_x_lock(&cache->lock); + sync->in_progress = false; + os_event_set(sync->event); + rw_lock_x_unlock(&cache->lock); + /* We need to check whether an optimize is required, for that we make copies of the two variables that control the trigger. These variables can change behind our back and we don't want to hold the @@ -4489,21 +4631,25 @@ fts_sync( return(error); } -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the -FTS auxiliary INDEX table and clear the cache at the end. */ +/** Run SYNC on the table, i.e., write out data from the cache to the +FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] table fts table +@param[in] unlock_cache whether unlock cache when write node +@param[in] wait whether wait for existing sync to finish +@return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( -/*===========*/ - dict_table_t* table) /*!< in: table */ + dict_table_t* table, + bool unlock_cache, + bool wait) { dberr_t err = DB_SUCCESS; ut_ad(table->fts); if (!dict_table_is_discarded(table) && table->fts->cache) { - err = fts_sync(table->fts->cache->sync); + err = fts_sync(table->fts->cache->sync, unlock_cache, wait); } return(err); @@ -6022,7 +6168,7 @@ fts_update_hex_format_flag( /*********************************************************************//** Rename an aux table to HEX format. It's called when "%016llu" is used to format an object id in table name, which only happens in Windows. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_rename_one_aux_table_to_hex_format( /*===================================*/ @@ -6113,7 +6259,7 @@ Note the ids in tables are correct but the names are old ambiguous ones. This function should make sure that either all the parent table and aux tables are set DICT_TF2_FTS_AUX_HEX_NAME with flags2 or none of them are set */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_rename_aux_tables_to_hex_format_low( /*====================================*/ @@ -6267,7 +6413,7 @@ fts_fake_hex_to_dec( { ib_id_t dec_id = 0; char tmp_id[FTS_AUX_MIN_TABLE_ID_LENGTH]; - int ret __attribute__((unused)); + int ret MY_ATTRIBUTE((unused)); ret = sprintf(tmp_id, UINT64PFx, id); ut_ad(ret == 16); @@ -6589,7 +6735,7 @@ fts_drop_aux_table_from_vector( Check and drop all orphaned FTS auxiliary tables, those that don't have a parent table or FTS index defined on them. @return DB_SUCCESS or error code */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void fts_check_and_drop_orphaned_tables( /*===============================*/ diff --git a/storage/xtradb/fts/fts0opt.cc b/storage/xtradb/fts/fts0opt.cc index 00b3b4682c3..d9f2532578e 100644 --- a/storage/xtradb/fts/fts0opt.cc +++ b/storage/xtradb/fts/fts0opt.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -87,6 +87,7 @@ enum fts_msg_type_t { FTS_MSG_DEL_TABLE, /*!< Remove a table from the optimize threads work queue */ + FTS_MSG_SYNC_TABLE /*!< Sync fts cache of a table */ }; /** Compressed list of words that have been read from FTS INDEX @@ -796,7 +797,7 @@ fts_zip_deflate_end( Read the words from the FTS INDEX. @return DB_SUCCESS if all OK, DB_TABLE_NOT_FOUND if no more indexes to search else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_index_fetch_words( /*==================*/ @@ -1130,7 +1131,7 @@ fts_optimize_lookup( /**********************************************************************//** Encode the word pos list into the node @return DB_SUCCESS or error code*/ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_optimize_encode_node( /*=====================*/ @@ -1219,7 +1220,7 @@ fts_optimize_encode_node( /**********************************************************************//** Optimize the data contained in a node. @return DB_SUCCESS or error code*/ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_optimize_node( /*==============*/ @@ -1317,7 +1318,7 @@ test_again: /**********************************************************************//** Determine the starting pos within the deleted doc id vector for a word. @return delete position */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int fts_optimize_deleted_pos( /*=====================*/ @@ -1446,7 +1447,7 @@ fts_optimize_word( /**********************************************************************//** Update the FTS index table. This is a delete followed by an insert. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_write_word( /*====================*/ @@ -1549,7 +1550,7 @@ fts_word_free( /**********************************************************************//** Optimize the word ilist and rewrite data to the FTS index. @return status one of RESTART, EXIT, ERROR */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_compact( /*=================*/ @@ -1644,7 +1645,7 @@ fts_optimize_create( /**********************************************************************//** Get optimize start time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_get_index_start_time( /*==============================*/ @@ -1660,7 +1661,7 @@ fts_optimize_get_index_start_time( /**********************************************************************//** Set the optimize start time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_set_index_start_time( /*==============================*/ @@ -1676,7 +1677,7 @@ fts_optimize_set_index_start_time( /**********************************************************************//** Get optimize end time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_get_index_end_time( /*============================*/ @@ -1691,7 +1692,7 @@ fts_optimize_get_index_end_time( /**********************************************************************//** Set the optimize end time of an FTS index. @return DB_SUCCESS if all OK else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_set_index_end_time( /*============================*/ @@ -1911,7 +1912,7 @@ fts_optimize_set_next_word( Optimize is complete. Set the completion time, and reset the optimize start string for this FTS index to "". @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_index_completed( /*=========================*/ @@ -1951,7 +1952,7 @@ fts_optimize_index_completed( Read the list of words from the FTS auxiliary index that will be optimized in this pass. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_index_read_words( /*==========================*/ @@ -2008,7 +2009,7 @@ fts_optimize_index_read_words( Run OPTIMIZE on the given FTS index. Note: this can take a very long time (hours). @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_index( /*===============*/ @@ -2079,7 +2080,7 @@ fts_optimize_index( /**********************************************************************//** Delete the document ids in the delete, and delete cache tables. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_purge_deleted_doc_ids( /*===============================*/ @@ -2148,7 +2149,7 @@ fts_optimize_purge_deleted_doc_ids( /**********************************************************************//** Delete the document ids in the pending delete, and delete tables. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_purge_deleted_doc_id_snapshot( /*=======================================*/ @@ -2198,7 +2199,7 @@ Copy the deleted doc ids that will be purged during this optimize run to the being deleted FTS auxiliary tables. The transaction is committed upon successfull copy and rolled back on DB_DUPLICATE_KEY error. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_create_deleted_doc_id_snapshot( /*========================================*/ @@ -2236,7 +2237,7 @@ fts_optimize_create_deleted_doc_id_snapshot( Read in the document ids that are to be purged during optimize. The transaction is committed upon successfully read. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_read_deleted_doc_id_snapshot( /*======================================*/ @@ -2273,7 +2274,7 @@ Optimze all the FTS indexes, skipping those that have already been optimized, since the FTS auxiliary indexes are not guaranteed to be of the same cardinality. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_indexes( /*=================*/ @@ -2343,7 +2344,7 @@ fts_optimize_indexes( /*********************************************************************//** Cleanup the snapshot tables and the master deleted table. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_purge_snapshot( /*========================*/ @@ -2372,7 +2373,7 @@ fts_optimize_purge_snapshot( /*********************************************************************//** Reset the start time to 0 so that a new optimize can be started. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_optimize_reset_start_time( /*==========================*/ @@ -2411,7 +2412,7 @@ fts_optimize_reset_start_time( /*********************************************************************//** Run OPTIMIZE on the given table by a background thread. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t fts_optimize_table_bk( /*==================*/ @@ -2652,6 +2653,39 @@ fts_optimize_remove_table( os_event_free(event); } +/** Send sync fts cache for the table. +@param[in] table table to sync */ +UNIV_INTERN +void +fts_optimize_request_sync_table( + dict_table_t* table) +{ + fts_msg_t* msg; + table_id_t* table_id; + + /* if the optimize system not yet initialized, return */ + if (!fts_optimize_wq) { + return; + } + + /* FTS optimizer thread is already exited */ + if (fts_opt_start_shutdown) { + ib_logf(IB_LOG_LEVEL_INFO, + "Try to sync table %s after FTS optimize" + " thread exiting.", table->name); + return; + } + + msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, NULL); + + table_id = static_cast( + mem_heap_alloc(msg->heap, sizeof(table_id_t))); + *table_id = table->id; + msg->ptr = table_id; + + ib_wqueue_add(fts_optimize_wq, msg, msg->heap); +} + /**********************************************************************//** Find the slot for a particular table. @return slot if found else NULL. */ @@ -2723,6 +2757,7 @@ fts_optimize_new_table( empty_slot = i; } else if (slot->table->id == table->id) { /* Already exists in our optimize queue. */ + ut_ad(slot->table_id = table->id); return(FALSE); } } @@ -2932,6 +2967,34 @@ fts_optimize_need_sync( } #endif +/** Sync fts cache of a table +@param[in] table_id table id */ +void +fts_optimize_sync_table( + table_id_t table_id) +{ + dict_table_t* table = NULL; + + /* Prevent DROP INDEX etc. from running when we are syncing + cache in background. */ + if (!rw_lock_s_lock_nowait(&dict_operation_lock, __FILE__, __LINE__)) { + /* Exit when fail to get dict operation lock. */ + return; + } + + table = dict_table_open_on_id(table_id, FALSE, DICT_TABLE_OP_NORMAL); + + if (table) { + if (dict_table_has_fts_index(table) && table->fts->cache) { + fts_sync_table(table, true, false); + } + + dict_table_close(table, FALSE, FALSE); + } + + rw_lock_s_unlock(&dict_operation_lock); +} + /**********************************************************************//** Optimize all FTS tables. @return Dummy return */ @@ -3053,6 +3116,11 @@ fts_optimize_thread( ((fts_msg_del_t*) msg->ptr)->event); break; + case FTS_MSG_SYNC_TABLE: + fts_optimize_sync_table( + *static_cast(msg->ptr)); + break; + default: ut_error; } @@ -3079,26 +3147,7 @@ fts_optimize_thread( ib_vector_get(tables, i)); if (slot->state != FTS_STATE_EMPTY) { - dict_table_t* table = NULL; - - /*slot->table may be freed, so we try to open - table by slot->table_id.*/ - table = dict_table_open_on_id( - slot->table_id, FALSE, - DICT_TABLE_OP_NORMAL); - - if (table) { - - if (dict_table_has_fts_index(table)) { - fts_sync_table(table); - } - - if (table->fts) { - fts_free(table); - } - - dict_table_close(table, FALSE, FALSE); - } + fts_optimize_sync_table(slot->table_id); } } } diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index 66060439215..2e335c1c255 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -287,7 +287,7 @@ fts_expand_query( dict_index_t* index, /*!< in: FTS index to search */ fts_query_t* query) /*!< in: query result, to be freed by the client */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** This function finds documents that contain all words in a phrase or proximity search. And if proximity search, verify @@ -1128,7 +1128,7 @@ cont_search: /*****************************************************************//** Set difference. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_difference( /*=================*/ @@ -1220,7 +1220,7 @@ fts_query_difference( /*****************************************************************//** Intersect the token doc ids with the current set. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_intersect( /*================*/ @@ -1398,7 +1398,7 @@ fts_query_cache( /*****************************************************************//** Set union. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_union( /*============*/ @@ -2015,7 +2015,7 @@ fts_query_select( Read the rows from the FTS index, that match word and where the doc id is between first and last doc id. @return DB_SUCCESS if all go well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_find_term( /*================*/ @@ -2155,7 +2155,7 @@ fts_query_sum( /******************************************************************** Calculate the total documents that contain a particular word (term). @return DB_SUCCESS if all go well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_total_docs_containing_term( /*=================================*/ @@ -2234,7 +2234,7 @@ fts_query_total_docs_containing_term( /******************************************************************** Get the total number of words in a documents. @return DB_SUCCESS if all go well else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_terms_in_document( /*========================*/ @@ -2315,7 +2315,7 @@ fts_query_terms_in_document( /*****************************************************************//** Retrieve the document and match the phrase tokens. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_match_document( /*=====================*/ @@ -2361,7 +2361,7 @@ fts_query_match_document( This function fetches the original documents and count the words in between matching words to see that is in specified distance @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool fts_query_is_in_proximity_range( /*============================*/ @@ -2416,7 +2416,7 @@ fts_query_is_in_proximity_range( Iterate over the matched document ids and search the for the actual phrase in the text. @return DB_SUCCESS if all OK */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_search_phrase( /*====================*/ @@ -2504,7 +2504,7 @@ func_exit: /*****************************************************************//** Text/Phrase search. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_phrase_search( /*====================*/ @@ -2755,7 +2755,7 @@ func_exit: /*****************************************************************//** Find the word and evaluate. @return DB_SUCCESS if all go well */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_query_execute( /*==============*/ @@ -4124,7 +4124,7 @@ words in documents found in the first search pass will be used as search arguments to search the document again, thus "expand" the search result set. @return DB_SUCCESS if success, otherwise the error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t fts_expand_query( /*=============*/ diff --git a/storage/xtradb/fts/fts0tlex.cc b/storage/xtradb/fts/fts0tlex.cc index b744fbf0763..d4d9b4c48d1 100644 --- a/storage/xtradb/fts/fts0tlex.cc +++ b/storage/xtradb/fts/fts0tlex.cc @@ -305,9 +305,9 @@ YY_BUFFER_STATE fts0t_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner YY_BUFFER_STATE fts0t_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE fts0t_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -void *fts0talloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void *fts0trealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void fts0tfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0talloc (yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void *fts0trealloc (void *,yy_size_t , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); +void fts0tfree (void * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); #define yy_new_buffer fts0t_create_buffer @@ -347,7 +347,7 @@ typedef int yy_state_type; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -447,7 +447,7 @@ static yyconst flex_int16_t yy_chk[29] = #line 1 "fts0tlex.l" /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -575,11 +575,11 @@ extern int fts0twrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))); #endif #ifndef YY_NO_INPUT @@ -1602,7 +1602,7 @@ YY_BUFFER_STATE fts0t_scan_bytes (yyconst char * yybytes, int _yybytes_len , y #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -1903,7 +1903,7 @@ int fts0tlex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int i; for ( i = 0; i < n; ++i ) @@ -1912,7 +1912,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yys #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { register int n; for ( n = 0; s[n]; ++n ) @@ -1922,12 +1922,12 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __at } #endif -void *fts0talloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0talloc (yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { return (void *) malloc( size ); } -void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -1939,7 +1939,7 @@ void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner return (void *) realloc( (char *) ptr, size ); } -void fts0tfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void fts0tfree (void * ptr , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { free( (char *) ptr ); /* see fts0trealloc() for (char *) cast */ } diff --git a/storage/xtradb/fts/make_parser.sh b/storage/xtradb/fts/make_parser.sh index 2c072914c8b..52b63eff674 100755 --- a/storage/xtradb/fts/make_parser.sh +++ b/storage/xtradb/fts/make_parser.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -22,15 +22,15 @@ make -f Makefile.query echo '#include "univ.i"' > $TMPF # This is to avoid compiler warning about unused parameters. -# FIXME: gcc extension "__attribute__" causing compilation errors on windows +# FIXME: gcc extension "MY_ATTRIBUTE" causing compilation errors on windows # platform. Quote them out for now. sed -e ' -s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; +s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; ' < fts0blex.cc >> $TMPF mv $TMPF fts0blex.cc @@ -38,12 +38,12 @@ mv $TMPF fts0blex.cc echo '#include "univ.i"' > $TMPF sed -e ' -s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; -s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 __attribute__((unused))/; +s/^\(static.*void.*yy_fatal_error.*msg.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*void.*yy_flex_strncpy.*n.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(static.*int.*yy_flex_strlen.*s.*,\)\(.*yyscanner\)/\1 \2 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]alloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]realloc.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; +s/^\(\(static\|void\).*fts0[bt]free.*,\)\(.*yyscanner\)/\1 \3 MY_ATTRIBUTE((unused))/; ' < fts0tlex.cc >> $TMPF mv $TMPF fts0tlex.cc diff --git a/storage/xtradb/ha/ha0ha.cc b/storage/xtradb/ha/ha0ha.cc index b79ae922045..3674260f173 100644 --- a/storage/xtradb/ha/ha0ha.cc +++ b/storage/xtradb/ha/ha0ha.cc @@ -155,11 +155,15 @@ ha_clear( switch (table->type) { case HASH_TABLE_SYNC_MUTEX: + for (ulint i = 0; i < table->n_sync_obj; i++) + mutex_free(table->sync_obj.mutexes + i); mem_free(table->sync_obj.mutexes); table->sync_obj.mutexes = NULL; break; case HASH_TABLE_SYNC_RW_LOCK: + for (ulint i = 0; i < table->n_sync_obj; i++) + rw_lock_free(table->sync_obj.rw_locks + i); mem_free(table->sync_obj.rw_locks); table->sync_obj.rw_locks = NULL; break; diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 2406ed96716..5ffd8b6e129 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2015, Oracle and/or its affiliates. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2013, 2016, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. @@ -2045,7 +2045,7 @@ thd_flush_log_at_trx_commit( /********************************************************************//** Obtain the InnoDB transaction of a MySQL thread. @return reference to transaction pointer */ -__attribute__((warn_unused_result, nonnull)) +MY_ATTRIBUTE((warn_unused_result, nonnull)) static inline trx_t*& thd_to_trx( @@ -2081,8 +2081,8 @@ static int innobase_release_temporary_latches( /*===============================*/ - handlerton* hton __attribute__((unused)), /*!< in: handlerton */ - THD* thd __attribute__((unused))) /*!< in: MySQL thread */ + handlerton* hton MY_ATTRIBUTE((unused)), /*!< in: handlerton */ + THD* thd MY_ATTRIBUTE((unused))) /*!< in: MySQL thread */ { #ifdef UNIV_DEBUG DBUG_ASSERT(hton == innodb_hton_ptr); @@ -4256,6 +4256,16 @@ innobase_change_buffering_inited_ok: innobase_open_files = tc_size; } } + + if (innobase_open_files > (long) open_files_limit) { + fprintf(stderr, + "innodb_open_files should not be greater" + " than the open_files_limit.\n"); + if (innobase_open_files > (long) tc_size) { + innobase_open_files = tc_size; + } + } + srv_max_n_open_files = (ulint) innobase_open_files; srv_innodb_status = (ibool) innobase_create_status_file; @@ -4445,7 +4455,7 @@ int innobase_end( /*=========*/ handlerton* hton, /*!< in/out: InnoDB handlerton */ - ha_panic_function type __attribute__((unused))) + ha_panic_function type MY_ATTRIBUTE((unused))) /*!< in: ha_panic() parameter */ { int err= 0; @@ -4540,7 +4550,7 @@ static my_bool innobase_is_fake_change( /*====================*/ - handlerton *hton __attribute__((unused)), + handlerton *hton MY_ATTRIBUTE((unused)), /*!< in: InnoDB handlerton */ THD* thd) /*!< in: MySQL thread handle of the user for whom the transaction is being committed */ @@ -11245,7 +11255,7 @@ create_table_check_doc_id_col( /*****************************************************************//** Creates a table definition to an InnoDB database. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int create_table_def( /*=============*/ @@ -12929,6 +12939,25 @@ ha_innobase::discard_or_import_tablespace( /* Commit the transaction in order to release the table lock. */ trx_commit_for_mysql(prebuilt->trx); + if (err == DB_SUCCESS && !discard + && dict_stats_is_persistent_enabled(dict_table)) { + dberr_t ret; + + /* Adjust the persistent statistics. */ + ret = dict_stats_update(dict_table, + DICT_STATS_RECALC_PERSISTENT); + + if (ret != DB_SUCCESS) { + push_warning_printf( + ha_thd(), + Sql_condition::WARN_LEVEL_WARN, + ER_ALTER_INFO, + "Error updating stats for table '%s'" + " after table rebuild: %s", + dict_table->name, ut_strerr(ret)); + } + } + DBUG_RETURN(convert_error_code_to_mysql(err, dict_table->flags, NULL)); } @@ -13080,7 +13109,8 @@ ha_innobase::delete_table( /* Drop the table in InnoDB */ err = row_drop_table_for_mysql( - norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB); + norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB, + FALSE); if (err == DB_TABLE_NOT_FOUND @@ -13111,7 +13141,8 @@ ha_innobase::delete_table( #endif err = row_drop_table_for_mysql( par_case_name, trx, - thd_sql_command(thd) == SQLCOM_DROP_DB); + thd_sql_command(thd) == SQLCOM_DROP_DB, + FALSE); } } @@ -13311,7 +13342,7 @@ innobase_drop_database( /*********************************************************************//** Renames an InnoDB table. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t innobase_rename_table( /*==================*/ @@ -14436,7 +14467,7 @@ ha_innobase::optimize( if (innodb_optimize_fulltext_only) { if (prebuilt->table->fts && prebuilt->table->fts->cache && !dict_table_is_discarded(prebuilt->table)) { - fts_sync_table(prebuilt->table); + fts_sync_table(prebuilt->table, false, true); fts_optimize_table(prebuilt->table); } return(HA_ADMIN_OK); @@ -14498,6 +14529,34 @@ ha_innobase::check( DBUG_RETURN(HA_ADMIN_CORRUPT); } + if (prebuilt->table->corrupted) { + char index_name[MAX_FULL_NAME_LEN + 1]; + /* If some previous operation has marked the table as + corrupted in memory, and has not propagated such to + clustered index, we will do so here */ + index = dict_table_get_first_index(prebuilt->table); + + if (!dict_index_is_corrupted(index)) { + row_mysql_lock_data_dictionary(prebuilt->trx); + dict_set_corrupted(index, prebuilt->trx, "CHECK TABLE"); + row_mysql_unlock_data_dictionary(prebuilt->trx); + } + + innobase_format_name(index_name, sizeof index_name, + index->name, TRUE); + + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + HA_ERR_INDEX_CORRUPT, + "InnoDB: Index %s is marked as" + " corrupted", index_name); + + /* Now that the table is already marked as corrupted, + there is no need to check any index of this table */ + prebuilt->trx->op_info = ""; + + DBUG_RETURN(HA_ADMIN_CORRUPT); + } + prebuilt->trx->op_info = "checking table"; old_isolation_level = prebuilt->trx->isolation_level; @@ -14581,6 +14640,15 @@ ha_innobase::check( prebuilt->index_usable = row_merge_is_index_usable( prebuilt->trx, prebuilt->index); + DBUG_EXECUTE_IF( + "dict_set_index_corrupted", + if (!dict_index_is_clust(index)) { + prebuilt->index_usable = FALSE; + row_mysql_lock_data_dictionary(prebuilt->trx); + dict_set_corrupted(index, prebuilt->trx, "dict_set_index_corrupted");; + row_mysql_unlock_data_dictionary(prebuilt->trx); + }); + if (UNIV_UNLIKELY(!prebuilt->index_usable)) { innobase_format_name( index_name, sizeof index_name, @@ -18406,7 +18474,7 @@ static char* srv_buffer_pool_evict; Evict all uncompressed pages of compressed tables from the buffer pool. Keep the compressed pages in the buffer pool. @return whether all uncompressed pages were evicted */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) bool innodb_buffer_pool_evict_uncompressed(void) /*=======================================*/ @@ -19029,13 +19097,13 @@ void purge_run_now_set( /*==============*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -19052,13 +19120,13 @@ void purge_stop_now_set( /*===============*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -19074,13 +19142,13 @@ void checkpoint_now_set( /*===============*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -19101,13 +19169,13 @@ void buf_flush_list_now_set( /*===================*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system - variable */ - __attribute__((unused)), + variable */ + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal - string goes */ - __attribute__((unused)), + string goes */ + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -19124,13 +19192,13 @@ void track_redo_log_now_set( /*===================*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { @@ -19239,13 +19307,13 @@ void buffer_pool_dump_now( /*=================*/ THD* thd /*!< in: thread handle */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), struct st_mysql_sys_var* var /*!< in: pointer to system variable */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), void* var_ptr /*!< out: where the formal string goes */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const void* save) /*!< in: immediate result from check function */ { diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index ea4be1fb2e0..7b0d20aec72 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -466,7 +466,7 @@ enum durability_properties thd_get_durability_property(const MYSQL_THD thd); @return True if sql_mode has strict mode (all or trans), false otherwise. */ bool thd_is_strict_mode(const MYSQL_THD thd) -__attribute__((nonnull)); +MY_ATTRIBUTE((nonnull)); } /* extern "C" */ /** Get the file name and position of the MySQL binlog corresponding to the @@ -528,7 +528,7 @@ innobase_index_name_is_reserved( const KEY* key_info, /*!< in: Indexes to be created */ ulint num_of_keys) /*!< in: Number of indexes to be created. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** #ifdef WITH_WSREP @@ -548,7 +548,7 @@ innobase_table_flags( outside system tablespace */ ulint* flags, /*!< out: DICT_TF flags */ ulint* flags2) /*!< out: DICT_TF2 flags */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Validates the create options. We may build on this function @@ -565,7 +565,7 @@ create_options_are_invalid( columns and indexes */ HA_CREATE_INFO* create_info, /*!< in: create info. */ bool use_tablespace) /*!< in: srv_file_per_table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Retrieve the FTS Relevance Ranking result for doc with doc_id @@ -595,7 +595,7 @@ void innobase_fts_close_ranking( /*=======================*/ FT_INFO* fts_hdl) /*!< in: FTS handler */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*****************************************************************//** Initialize the table FTS stopword list @return TRUE if success */ @@ -606,7 +606,7 @@ innobase_fts_load_stopword( dict_table_t* table, /*!< in: Table has the FTS */ trx_t* trx, /*!< in: transaction */ THD* thd) /*!< in: current thread */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /** Some defines for innobase_fts_check_doc_id_index() return value */ enum fts_doc_id_index_enum { @@ -628,7 +628,7 @@ innobase_fts_check_doc_id_index( that is being altered */ ulint* fts_doc_col_no) /*!< out: The column number for Doc ID */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME @@ -641,7 +641,7 @@ innobase_fts_check_doc_id_index_in_def( /*===================================*/ ulint n_key, /*!< in: Number of keys */ const KEY* key_info) /*!< in: Key definitions */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************** @return version of the extended FTS API */ diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 1e57f6c5293..71bcfd31831 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 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 @@ -105,7 +105,7 @@ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ALTER_NOREBUILD | Alter_inplace_info::ALTER_COLUMN_NAME; /* Report an InnoDB error to the client by invoking my_error(). */ -static UNIV_COLD __attribute__((nonnull)) +static UNIV_COLD MY_ATTRIBUTE((nonnull)) void my_error_innodb( /*============*/ @@ -207,7 +207,7 @@ Determine if ALTER TABLE needs to rebuild the table. @param ha_alter_info the DDL operation @param altered_table MySQL original table @return whether it is necessary to rebuild the table */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_need_rebuild( /*==================*/ @@ -234,7 +234,7 @@ innobase_need_rebuild( & Alter_inplace_info::ADD_INDEX) || (ha_alter_info->handler_flags & Alter_inplace_info::ADD_FOREIGN_KEY))) { - for (ulint i = 0; i < ha_alter_info->key_count; i++) { + for (ulint i = 0; i < ha_alter_info->index_add_count; i++) { const KEY* key = &ha_alter_info->key_info_buffer[ ha_alter_info->index_add_buffer[i]]; @@ -245,13 +245,13 @@ innobase_need_rebuild( /* Field used on added index is renamed on this same alter table. We need table rebuild. */ - if (field->flags & FIELD_IS_RENAMED) { + if (field && field->flags & FIELD_IS_RENAMED) { return (true); } } } } - + return(!!(ha_alter_info->handler_flags & INNOBASE_ALTER_REBUILD)); } @@ -651,7 +651,7 @@ ha_innobase::check_if_supported_inplace_alter( /*************************************************************//** Initialize the dict_foreign_t structure with supplied info @return true if added, false if duplicate foreign->id */ -static __attribute__((nonnull(1,3,5,7))) +static MY_ATTRIBUTE((nonnull(1,3,5,7))) bool innobase_init_foreign( /*==================*/ @@ -740,7 +740,7 @@ innobase_init_foreign( /*************************************************************//** Check whether the foreign key options is legit @return true if it is */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_check_fk_option( /*=====================*/ @@ -772,7 +772,7 @@ innobase_check_fk_option( /*************************************************************//** Set foreign key options @return true if successfully set */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_set_foreign_key_option( /*============================*/ @@ -817,7 +817,7 @@ innobase_set_foreign_key_option( Check if a foreign key constraint can make use of an index that is being created. @return useable index, or NULL if none found */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const KEY* innobase_find_equiv_index( /*======================*/ @@ -873,7 +873,7 @@ no_match: Find an index whose first fields are the columns in the array in the same order and is not marked for deletion @return matching index, NULL if not found */ -static __attribute__((nonnull(1,2,6), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,6), warn_unused_result)) dict_index_t* innobase_find_fk_index( /*===================*/ @@ -920,7 +920,7 @@ next_rec: Create InnoDB foreign key structure from MySQL alter_info @retval true if successful @retval false on error (will call my_error()) */ -static __attribute__((nonnull(1,2,3,7,8), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,7,8), warn_unused_result)) bool innobase_get_foreign_key_info( /*==========================*/ @@ -1419,7 +1419,7 @@ innobase_rec_reset( /*******************************************************************//** This function checks that index keys are sensible. @return 0 or error number */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int innobase_check_index_keys( /*======================*/ @@ -1540,7 +1540,7 @@ name_ok: /*******************************************************************//** Create index field definition for key part */ -static __attribute__((nonnull(2,3))) +static MY_ATTRIBUTE((nonnull(2,3))) void innobase_create_index_field_def( /*============================*/ @@ -1589,7 +1589,7 @@ innobase_create_index_field_def( /*******************************************************************//** Create index definition for key */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_create_index_def( /*======================*/ @@ -1880,7 +1880,7 @@ ELSE ENDIF @return key definitions */ -static __attribute__((nonnull, warn_unused_result, malloc)) +static MY_ATTRIBUTE((nonnull, warn_unused_result, malloc)) index_def_t* innobase_create_key_defs( /*=====================*/ @@ -2104,7 +2104,7 @@ created_clustered: /*******************************************************************//** Check each index column size, make sure they do not exceed the max limit @return true if index column size exceeds limit */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_check_column_length( /*=========================*/ @@ -2254,7 +2254,7 @@ online_retry_drop_indexes_low( /********************************************************************//** Drop any indexes that we were not able to free previously due to open table handles. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void online_retry_drop_indexes( /*======================*/ @@ -2284,7 +2284,7 @@ online_retry_drop_indexes( /********************************************************************//** Commit a dictionary transaction and drop any indexes that we were not able to free previously due to open table handles. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void online_retry_drop_indexes_with_trx( /*===============================*/ @@ -2313,7 +2313,7 @@ online_retry_drop_indexes_with_trx( @param drop_fk constraints being dropped @param n_drop_fk number of constraints that are being dropped @return whether the constraint is being dropped */ -inline __attribute__((pure, nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) bool innobase_dropping_foreign( /*======================*/ @@ -2340,7 +2340,7 @@ column that is being dropped or modified to NOT NULL. @retval true Not allowed (will call my_error()) @retval false Allowed */ -static __attribute__((pure, nonnull, warn_unused_result)) +static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) bool innobase_check_foreigns_low( /*========================*/ @@ -2440,7 +2440,7 @@ column that is being dropped or modified to NOT NULL. @retval true Not allowed (will call my_error()) @retval false Allowed */ -static __attribute__((pure, nonnull, warn_unused_result)) +static MY_ATTRIBUTE((pure, nonnull, warn_unused_result)) bool innobase_check_foreigns( /*====================*/ @@ -2485,7 +2485,7 @@ innobase_check_foreigns( @param dfield InnoDB data field to copy to @param field MySQL value for the column @param comp nonzero if in compact format */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_build_col_map_add( /*=======================*/ @@ -2519,7 +2519,7 @@ adding columns. @param heap Memory heap where allocated @return array of integers, mapping column numbers in the table to column numbers in altered_table */ -static __attribute__((nonnull(1,2,3,4,5,7), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,4,5,7), warn_unused_result)) const ulint* innobase_build_col_map( /*===================*/ @@ -2669,7 +2669,7 @@ innobase_drop_fts_index_table( @param user_table InnoDB table as it is before the ALTER operation @param heap Memory heap for the allocation @return array of new column names in rebuilt_table, or NULL if not renamed */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const char** innobase_get_col_names( Alter_inplace_info* ha_alter_info, @@ -2732,7 +2732,7 @@ while preparing ALTER TABLE. @retval true Failure @retval false Success */ -static __attribute__((warn_unused_result, nonnull(1,2,3,4))) +static MY_ATTRIBUTE((warn_unused_result, nonnull(1,2,3,4))) bool prepare_inplace_alter_table_dict( /*=============================*/ @@ -3392,7 +3392,7 @@ err_exit: /* Check whether an index is needed for the foreign key constraint. If so, if it is dropped, is there an equivalent index can play its role. @return true if the index is needed and can't be dropped */ -static __attribute__((nonnull(1,2,3,5), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,5), warn_unused_result)) bool innobase_check_foreign_key_index( /*=============================*/ @@ -3940,6 +3940,24 @@ check_if_can_drop_indexes: drop_index = NULL; } + /* Check if any of the existing indexes are marked as corruption + and if they are, refuse adding more indexes. */ + if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) { + for (dict_index_t* index = dict_table_get_first_index(indexed_table); + index != NULL; index = dict_table_get_next_index(index)) { + + if (!index->to_be_dropped && dict_index_is_corrupted(index)) { + char index_name[MAX_FULL_NAME_LEN + 1]; + + innobase_format_name(index_name, sizeof index_name, + index->name, TRUE); + + my_error(ER_INDEX_CORRUPT, MYF(0), index_name); + DBUG_RETURN(true); + } + } + } + n_add_fk = 0; if (ha_alter_info->handler_flags @@ -4310,7 +4328,7 @@ temparary index prefix @param locked TRUE=table locked, FALSE=may need to do a lazy drop @param trx the transaction */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_rollback_sec_index( /*========================*/ @@ -4344,7 +4362,7 @@ during prepare, but might not be during commit). @retval true Failure @retval false Success */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool rollback_inplace_alter_table( /*=========================*/ @@ -4476,7 +4494,7 @@ func_exit: @param foreign_id Foreign key constraint identifier @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_drop_foreign_try( /*======================*/ @@ -4533,7 +4551,7 @@ innobase_drop_foreign_try( @param new_clustered whether the table has been rebuilt @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_rename_column_try( /*=======================*/ @@ -4742,7 +4760,7 @@ rename_foreign: @param table_name Table name in MySQL @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_rename_columns_try( /*========================*/ @@ -4792,7 +4810,7 @@ as part of commit_cache_norebuild(). @param ha_alter_info Data used during in-place alter. @param table the TABLE @param user_table InnoDB table that was being altered */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void innobase_rename_columns_cache( /*==========================*/ @@ -4836,7 +4854,7 @@ processed_field: @param altered_table MySQL table that is being altered @param old_table MySQL table as it is before the ALTER operation @return the next auto-increment value (0 if not present) */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulonglong commit_get_autoinc( /*===============*/ @@ -4920,7 +4938,7 @@ but do not touch the data dictionary cache. @retval true Failure @retval false Success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool innobase_update_foreign_try( /*========================*/ @@ -5004,7 +5022,7 @@ after the changes to data dictionary tables were committed. @param ctx In-place ALTER TABLE context @param user_thd MySQL connection @return InnoDB error code (should always be DB_SUCCESS) */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t innobase_update_foreign_cache( /*==========================*/ @@ -5089,7 +5107,7 @@ when rebuilding the table. @retval true Failure @retval false Success */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool commit_try_rebuild( /*===============*/ @@ -5251,7 +5269,7 @@ commit_try_rebuild( /** Apply the changes made during commit_try_rebuild(), to the data dictionary cache and the file system. @param ctx In-place ALTER TABLE context */ -inline __attribute__((nonnull)) +inline MY_ATTRIBUTE((nonnull)) void commit_cache_rebuild( /*=================*/ @@ -5348,7 +5366,7 @@ when not rebuilding the table. @retval true Failure @retval false Success */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool commit_try_norebuild( /*=================*/ @@ -5458,7 +5476,7 @@ after a successful commit_try_norebuild() call. @param trx Data dictionary transaction object (will be started and committed) @return whether all replacements were found for dropped indexes */ -inline __attribute__((nonnull, warn_unused_result)) +inline MY_ATTRIBUTE((nonnull, warn_unused_result)) bool commit_cache_norebuild( /*===================*/ diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc index bac2a92dd0b..dc6ad49838e 100644 --- a/storage/xtradb/ibuf/ibuf0ibuf.cc +++ b/storage/xtradb/ibuf/ibuf0ibuf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -711,7 +711,7 @@ byte* ibuf_parse_bitmap_init( /*===================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ buf_block_t* block, /*!< in: block or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ { @@ -2554,7 +2554,7 @@ ibuf_get_merge_page_nos_func( /*******************************************************************//** Get the matching records for space id. @return current rec or NULL */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const rec_t* ibuf_get_user_rec( /*===============*/ @@ -2576,7 +2576,7 @@ ibuf_get_user_rec( Reads page numbers for a space id from an ibuf tree. @return a lower limit for the combined volume of records which will be merged */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint ibuf_get_merge_pages( /*=================*/ @@ -2684,40 +2684,22 @@ ibuf_merge_pages( } /*********************************************************************//** -Get the table instance from the table id. -@return table instance */ -static __attribute__((warn_unused_result)) -dict_table_t* -ibuf_get_table( -/*===========*/ - table_id_t table_id) /*!< in: valid table id */ -{ - rw_lock_s_lock_func(&dict_operation_lock, 0, __FILE__, __LINE__); - - dict_table_t* table = dict_table_open_on_id( - table_id, FALSE, DICT_TABLE_OP_NORMAL); - - rw_lock_s_unlock_gen(&dict_operation_lock, 0); - - return(table); -} - -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. -@return a lower limit for the combined size in bytes of entries which -will be merged from ibuf trees to the pages read, 0 if ibuf is -empty */ -static +Contracts insert buffer trees by reading pages referring to space_id +to the buffer pool. +@returns number of pages merged.*/ +UNIV_INTERN ulint ibuf_merge_space( /*=============*/ - ulint space, /*!< in: tablespace id to merge */ - ulint* n_pages)/*!< out: number of pages to which merged */ + ulint space) /*!< in: tablespace id to merge */ { mtr_t mtr; btr_pcur_t pcur; mem_heap_t* heap = mem_heap_create(512); dtuple_t* tuple = ibuf_search_tuple_build(space, 0, heap); + ulint n_pages = 0; + + ut_ad(space < SRV_LOG_SPACE_FIRST_ID); ibuf_mtr_start(&mtr); @@ -2749,52 +2731,46 @@ ibuf_merge_space( } else { sum_sizes = ibuf_get_merge_pages( - &pcur, space, IBUF_MAX_N_PAGES_MERGED, - &pages[0], &spaces[0], &versions[0], n_pages, - &mtr); - - if (*n_pages > 0) { - ++sum_sizes; - } + &pcur, space, IBUF_MAX_N_PAGES_MERGED, + &pages[0], &spaces[0], &versions[0], &n_pages, + &mtr); + ib_logf(IB_LOG_LEVEL_INFO,"\n Size of pages merged %lu" + ,sum_sizes); } ibuf_mtr_commit(&mtr); btr_pcur_close(&pcur); - if (sum_sizes > 0) { - - ut_a(*n_pages > 0 || sum_sizes == 1); + if (n_pages > 0) { #ifdef UNIV_DEBUG - ut_ad(*n_pages <= UT_ARR_SIZE(pages)); + ut_ad(n_pages <= UT_ARR_SIZE(pages)); - for (ulint i = 0; i < *n_pages; ++i) { + for (ulint i = 0; i < n_pages; ++i) { ut_ad(spaces[i] == space); ut_ad(i == 0 || versions[i] == versions[i - 1]); } #endif /* UNIV_DEBUG */ buf_read_ibuf_merge_pages( - true, spaces, versions, pages, *n_pages); + true, spaces, versions, pages, n_pages); } - return(sum_sizes); + return(n_pages); } -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[out] n_pages number of pages merged +@param[in] sync whether the caller waits for +the issued reads to complete @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint ibuf_merge( /*=======*/ - table_id_t table_id, /*!< in: if merge should be - done only for a specific - table, for all tables this - should be 0 */ ulint* n_pages, /*!< out: number of pages to which merged */ bool sync) /*!< in: TRUE if the caller @@ -2802,8 +2778,6 @@ ibuf_merge( read with the highest tablespace address to complete */ { - dict_table_t* table; - *n_pages = 0; /* We perform a dirty read of ibuf->empty, without latching @@ -2817,55 +2791,45 @@ ibuf_merge( } else if (ibuf_debug) { return(0); #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - } else if (table_id == 0) { + } else { return(ibuf_merge_pages(n_pages, sync)); - } else if ((table = ibuf_get_table(table_id)) == 0) { - /* Table has been dropped. */ - return(0); } - - ulint volume = ibuf_merge_space(table->space, n_pages); - - dict_table_close(table, FALSE, FALSE); - - return(volume); } -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[in] sync whether the caller waits for +the issued reads to complete @return a lower limit for the combined size in bytes of entries which -will be merged from ibuf trees to the pages read, 0 if ibuf is -empty */ +will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ static ulint ibuf_contract( /*==========*/ - ibool sync) /*!< in: TRUE if the caller wants to wait for the + bool sync) /*!< in: TRUE if the caller wants to wait for the issued read with the highest tablespace address to complete */ { ulint n_pages; - return(ibuf_merge(0, &n_pages, sync)); + return(ibuf_merge_pages(&n_pages, sync)); } -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[in] full If true, do a full contraction based +on PCT_IO(100). If false, the size of contract batch is determined +based on the current size of the change buffer. @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ UNIV_INTERN ulint -ibuf_contract_in_background( -/*========================*/ - table_id_t table_id, /*!< in: if merge should be done only - for a specific table, for all tables - this should be 0 */ - ibool full) /*!< in: TRUE if the caller wants to - do a full contract based on PCT_IO(100). - If FALSE then the size of contract - batch is determined based on the - current size of the ibuf tree. */ +ibuf_merge_in_background( +/*=====================*/ + bool full) /*!< in: TRUE if the caller wants to + do a full contract based on PCT_IO(100). + If FALSE then the size of contract + batch is determined based on the + current size of the ibuf tree. */ { ulint sum_bytes = 0; ulint sum_pages = 0; @@ -2873,7 +2837,7 @@ ibuf_contract_in_background( ulint n_pages; #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - if (srv_ibuf_disable_background_merge && table_id == 0) { + if (srv_ibuf_disable_background_merge) { return(0); } #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ @@ -2908,7 +2872,7 @@ ibuf_contract_in_background( while (sum_pages < n_pages) { ulint n_bytes; - n_bytes = ibuf_merge(table_id, &n_pag2, FALSE); + n_bytes = ibuf_merge(&n_pag2, false); if (n_bytes == 0) { return(sum_bytes); @@ -2917,7 +2881,7 @@ ibuf_contract_in_background( sum_bytes += n_bytes; sum_pages += n_pag2; - srv_inc_activity_count(); + srv_inc_activity_count(true); } return(sum_bytes); @@ -3514,7 +3478,7 @@ ibuf_get_entry_counter_func( Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible. @return DB_SUCCESS, DB_STRONG_FAIL or other error */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t ibuf_insert_low( /*============*/ @@ -3583,8 +3547,7 @@ ibuf_insert_low( #ifdef UNIV_IBUF_DEBUG fputs("Ibuf too big\n", stderr); #endif - /* Use synchronous contract (== TRUE) */ - ibuf_contract(TRUE); + ibuf_contract(true); return(DB_STRONG_FAIL); } @@ -4007,7 +3970,7 @@ skip_watch: During merge, inserts to an index page a secondary index entry extracted from the insert buffer. @return newly inserted record */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) rec_t* ibuf_insert_to_index_page_low( /*==========================*/ @@ -4438,7 +4401,7 @@ ibuf_delete( /*********************************************************************//** Restores insert buffer tree cursor position @return TRUE if the position was restored; FALSE if not */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) ibool ibuf_restore_pos( /*=============*/ @@ -4493,7 +4456,7 @@ Deletes from ibuf the record on which pcur is positioned. If we have to resort to a pessimistic delete, this function commits mtr and closes the cursor. @return TRUE if mtr was committed and pcur closed in this operation */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool ibuf_delete_rec( /*============*/ diff --git a/storage/xtradb/include/api0api.h b/storage/xtradb/include/api0api.h index e4c9c941de5..500bf4fe3b2 100644 --- a/storage/xtradb/include/api0api.h +++ b/storage/xtradb/include/api0api.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -36,7 +36,7 @@ InnoDB Native API #endif #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER) -#define UNIV_NO_IGNORE __attribute__ ((warn_unused_result)) +#define UNIV_NO_IGNORE MY_ATTRIBUTE ((warn_unused_result)) #else #define UNIV_NO_IGNORE #endif /* __GNUC__ && __GNUC__ > 2 && !__INTEL_COMPILER */ diff --git a/storage/xtradb/include/btr0btr.h b/storage/xtradb/include/btr0btr.h index 36aaf676ccf..5047d1b2d4e 100644 --- a/storage/xtradb/include/btr0btr.h +++ b/storage/xtradb/include/btr0btr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2014, 2015, MariaDB Corporation. All Rights Reserved. @@ -118,7 +118,7 @@ btr_corruption_report( /*==================*/ const buf_block_t* block, /*!< in: corrupted block */ const dict_index_t* index) /*!< in: index tree */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /** Assert that a B-tree page is not corrupted. @param block buffer block containing a B-tree page @@ -160,7 +160,7 @@ btr_blob_dbg_add_blob( ulint page_no, /*!< in: start page of the column */ dict_index_t* index, /*!< in/out: index tree */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Display the references to off-page columns. This function is to be called from a debugger, @@ -170,7 +170,7 @@ void btr_blob_dbg_print( /*===============*/ const dict_index_t* index) /*!< in: index tree */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Check that there are no references to off-page columns from or to the given page. Invoked when freeing or clearing a page. @@ -181,7 +181,7 @@ btr_blob_dbg_is_empty( /*==================*/ dict_index_t* index, /*!< in: index */ ulint page_no) /*!< in: page number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Modify the 'deleted' flag of a record. */ @@ -193,7 +193,7 @@ btr_blob_dbg_set_deleted_flag( dict_index_t* index, /*!< in/out: index */ const ulint* offsets,/*!< in: rec_get_offs(rec, index) */ ibool del) /*!< in: TRUE=deleted, FALSE=exists */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Change the ownership of an off-page column. */ UNIV_INTERN @@ -205,7 +205,7 @@ btr_blob_dbg_owner( const ulint* offsets,/*!< in: rec_get_offs(rec, index) */ ulint i, /*!< in: ith field in rec */ ibool own) /*!< in: TRUE=owned, FALSE=disowned */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Assert that there are no BLOB references to or from the given page. */ # define btr_blob_dbg_assert_empty(index, page_no) \ ut_a(btr_blob_dbg_is_empty(index, page_no)) @@ -225,7 +225,7 @@ btr_root_get( /*=========*/ const dict_index_t* index, /*!< in: index tree */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Checks and adjusts the root node of a tree during IMPORT TABLESPACE. @@ -235,7 +235,7 @@ dberr_t btr_root_adjust_on_import( /*======================*/ const dict_index_t* index) /*!< in: index tree */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Gets the height of the B-tree (the level of the root, when the leaf @@ -248,7 +248,7 @@ btr_height_get( /*===========*/ dict_index_t* index, /*!< in: index tree */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Gets a buffer page and declares its latching order level. */ UNIV_INLINE @@ -310,7 +310,7 @@ index_id_t btr_page_get_index_id( /*==================*/ const page_t* page) /*!< in: index page */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #ifndef UNIV_HOTBACKUP /********************************************************//** Gets the node level field in an index page. @@ -320,7 +320,7 @@ ulint btr_page_get_level_low( /*===================*/ const page_t* page) /*!< in: index page */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #define btr_page_get_level(page, mtr) btr_page_get_level_low(page) /********************************************************//** Gets the next index page number. @@ -331,7 +331,7 @@ btr_page_get_next( /*==============*/ const page_t* page, /*!< in: index page */ mtr_t* mtr) /*!< in: mini-transaction handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************//** Gets the previous index page number. @return prev page number */ @@ -341,7 +341,7 @@ btr_page_get_prev( /*==============*/ const page_t* page, /*!< in: index page */ mtr_t* mtr) /*!< in: mini-transaction handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Gets pointer to the previous user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor. @@ -353,7 +353,7 @@ btr_get_prev_user_rec( rec_t* rec, /*!< in: record on leaf level */ mtr_t* mtr) /*!< in: mtr holding a latch on the page, and if needed, also to the previous page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Gets pointer to the next user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor. @@ -365,7 +365,7 @@ btr_get_next_user_rec( rec_t* rec, /*!< in: record on leaf level */ mtr_t* mtr) /*!< in: mtr holding a latch on the page, and if needed, also to the next page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Releases the latch on a leaf page and bufferunfixes it. */ UNIV_INLINE @@ -376,7 +376,7 @@ btr_leaf_page_release( ulint latch_mode, /*!< in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Gets the child node file address in a node pointer. NOTE: the offsets array must contain all offsets for the record since @@ -390,7 +390,7 @@ btr_node_ptr_get_child_page_no( /*===========================*/ const rec_t* rec, /*!< in: node pointer record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /************************************************************//** Creates the root node for a new index tree. @return page number of the created root, FIL_NULL if did not succeed */ @@ -405,7 +405,7 @@ btr_create( index_id_t index_id,/*!< in: index id */ dict_index_t* index, /*!< in: index */ mtr_t* mtr) /*!< in: mini-transaction handle */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Frees a B-tree except the root page, which MUST be freed after this by calling btr_free_root. */ @@ -428,7 +428,7 @@ btr_free_root( or 0 for uncompressed pages */ ulint root_page_no, /*!< in: root page number */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. @@ -477,7 +477,7 @@ btr_page_reorganize_low( page_cur_t* cursor, /*!< in/out: page cursor */ dict_index_t* index, /*!< in: the index tree of the page */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Reorganizes an index page. @@ -496,7 +496,7 @@ btr_page_reorganize( page_cur_t* cursor, /*!< in/out: page cursor */ dict_index_t* index, /*!< in: the index tree of the page */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Decides if the page should be split at the convergence point of inserts converging to left. @@ -509,7 +509,7 @@ btr_page_get_split_rec_to_left( rec_t** split_rec)/*!< out: if split recommended, the first record on upper half page, or NULL if tuple should be first */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Decides if the page should be split at the convergence point of inserts converging to right. @@ -522,7 +522,7 @@ btr_page_get_split_rec_to_right( rec_t** split_rec)/*!< out: if split recommended, the first record on upper half page, or NULL if tuple should be first */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is @@ -561,7 +561,7 @@ btr_insert_on_non_leaf_level_func( const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); # define btr_insert_on_non_leaf_level(f,i,l,t,m) \ btr_insert_on_non_leaf_level_func(f,i,l,t,__FILE__,__LINE__,m) #endif /* !UNIV_HOTBACKUP */ @@ -573,7 +573,7 @@ btr_set_min_rec_mark( /*=================*/ rec_t* rec, /*!< in/out: record */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /*************************************************************//** Deletes on the upper level the node pointer to a page. */ @@ -584,7 +584,7 @@ btr_node_ptr_delete( dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: page whose node pointer is deleted */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /************************************************************//** Checks that the node pointer to a page is appropriate. @@ -596,7 +596,7 @@ btr_check_node_ptr( dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: index page */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /*************************************************************//** Tries to merge the page first to the left immediate brother if such a @@ -619,7 +619,7 @@ btr_compress( ibool adjust, /*!< in: TRUE if should adjust the cursor position even if compression occurs */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Discards a page from a B-tree. This is used to remove the last record from a B-tree page: the whole page must be removed at the same time. This cannot @@ -631,7 +631,7 @@ btr_discard_page( btr_cur_t* cursor, /*!< in: cursor on the page to discard: not on the root page */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /****************************************************************//** Parses the redo log record for setting an index record as the predefined @@ -646,7 +646,7 @@ btr_parse_set_min_rec_mark( ulint comp, /*!< in: nonzero=compact page format */ page_t* page, /*!< in: page or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ - __attribute__((nonnull(1,2), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2), warn_unused_result)); /***********************************************************//** Parses a redo log record of reorganizing a page. @return end of log record or NULL */ @@ -660,7 +660,7 @@ btr_parse_page_reorganize( bool compressed,/*!< in: true if compressed page */ buf_block_t* block, /*!< in: page to be reorganized, or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ - __attribute__((nonnull(1,2,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3), warn_unused_result)); #ifndef UNIV_HOTBACKUP /**************************************************************//** Gets the number of pages in a B-tree. @@ -673,7 +673,7 @@ btr_get_size( ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ mtr_t* mtr) /*!< in/out: mini-transaction where index is s-latched */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Gets the number of reserved and used pages in a B-tree. @return number of pages reserved, or ULINT_UNDEFINED if the index @@ -711,7 +711,7 @@ btr_page_alloc( mtr_t* init_mtr) /*!< in/out: mini-transaction for x-latching and initializing the page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Frees a file page used in an index tree. NOTE: cannot free field external storage pages because the page must contain info on its level. */ @@ -722,7 +722,7 @@ btr_page_free( dict_index_t* index, /*!< in: index tree */ buf_block_t* block, /*!< in: block to be freed, x-latched */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Frees a file page used in an index tree. Can be used also to BLOB external storage pages, because the page level 0 can be given as an @@ -772,7 +772,7 @@ void btr_print_size( /*===========*/ dict_index_t* index) /*!< in: index tree */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Prints directories and other info of all nodes in the index. */ UNIV_INTERN @@ -782,7 +782,7 @@ btr_print_index( dict_index_t* index, /*!< in: index */ ulint width) /*!< in: print this many entries from start and end */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* UNIV_BTR_PRINT */ /************************************************************//** Checks the size and number of fields in a record based on the definition of @@ -797,7 +797,7 @@ btr_index_rec_validate( ibool dump_on_error) /*!< in: TRUE if the function should print hex dump of record and page on error */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Checks the consistency of an index tree. @return DB_SUCCESS if ok, error code if not */ @@ -807,7 +807,7 @@ btr_validate_index( /*===============*/ dict_index_t* index, /*!< in: index */ const trx_t* trx) /*!< in: transaction or 0 */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); #ifdef UNIV_SYNC_DEBUG /*************************************************************//** diff --git a/storage/xtradb/include/btr0btr.ic b/storage/xtradb/include/btr0btr.ic index 5fc621f469d..8c9c3bead09 100644 --- a/storage/xtradb/include/btr0btr.ic +++ b/storage/xtradb/include/btr0btr.ic @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2016, MariaDB Corporation. 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 @@ -165,10 +165,11 @@ ulint btr_page_get_next( /*==============*/ const page_t* page, /*!< in: index page */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); #ifndef UNIV_INNOCHECKSUM ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX) || mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX)); @@ -188,7 +189,8 @@ btr_page_set_next( ulint next, /*!< in: next page number */ mtr_t* mtr) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); if (page_zip) { mach_write_to_4(page + FIL_PAGE_NEXT, next); @@ -206,9 +208,10 @@ ulint btr_page_get_prev( /*==============*/ const page_t* page, /*!< in: index page */ - mtr_t* mtr __attribute__((unused))) /*!< in: mini-transaction handle */ + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); return(mach_read_from_4(page + FIL_PAGE_PREV)); } @@ -225,7 +228,8 @@ btr_page_set_prev( ulint prev, /*!< in: previous page number */ mtr_t* mtr) /*!< in: mini-transaction handle */ { - ut_ad(page && mtr); + ut_ad(page != NULL); + ut_ad(mtr != NULL); if (page_zip) { mach_write_to_4(page + FIL_PAGE_PREV, prev); diff --git a/storage/xtradb/include/btr0cur.h b/storage/xtradb/include/btr0cur.h index 2c60f3ad64c..f485d072c4c 100644 --- a/storage/xtradb/include/btr0cur.h +++ b/storage/xtradb/include/btr0cur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -186,7 +186,7 @@ btr_cur_open_at_index_side_func( const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define btr_cur_open_at_index_side(f,i,l,c,lv,m) \ btr_cur_open_at_index_side_func(f,i,l,c,lv,__FILE__,__LINE__,m) /**********************************************************************//** @@ -235,7 +235,7 @@ btr_cur_optimistic_insert( compressed tablespace, the caller must mtr_commit(mtr) before latching any further pages */ - __attribute__((nonnull(2,3,4,5,6,7,10), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3,4,5,6,7,10), warn_unused_result)); /*************************************************************//** Performs an insert on a page of an index tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the insert is @@ -266,7 +266,7 @@ btr_cur_pessimistic_insert( ulint n_ext, /*!< in: number of externally stored columns */ que_thr_t* thr, /*!< in: query thread or NULL */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull(2,3,4,5,6,7,10), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3,4,5,6,7,10), warn_unused_result)); /*************************************************************//** See if there is enough place in the page modification log to log an update-in-place. @@ -295,9 +295,9 @@ btr_cur_update_alloc_zip_func( mtr_t* mtr, /*!< in/out: mini-transaction */ trx_t* trx) /*!< in: NULL or transaction */ #ifdef UNIV_DEBUG - __attribute__((nonnull (1, 2, 3, 4, 7), warn_unused_result)); + MY_ATTRIBUTE((nonnull (1, 2, 3, 4, 7), warn_unused_result)); #else - __attribute__((nonnull (1, 2, 3, 6), warn_unused_result)); + MY_ATTRIBUTE((nonnull (1, 2, 3, 6), warn_unused_result)); #endif #ifdef UNIV_DEBUG @@ -331,7 +331,7 @@ btr_cur_update_in_place( is a secondary index, the caller must mtr_commit(mtr) before latching any further pages */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /***********************************************************//** Writes a redo log record of updating a record in-place. */ UNIV_INTERN @@ -345,7 +345,7 @@ btr_cur_update_in_place_log( trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr, /*!< in: roll ptr */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Tries to update a record on a page in an index tree. It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too @@ -377,7 +377,7 @@ btr_cur_optimistic_update( is a secondary index, the caller must mtr_commit(mtr) before latching any further pages */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /*************************************************************//** Performs an update of a record on a page of a tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the @@ -411,7 +411,7 @@ btr_cur_pessimistic_update( trx_id_t trx_id, /*!< in: transaction id */ mtr_t* mtr) /*!< in/out: mini-transaction; must be committed before latching any further pages */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /***********************************************************//** Marks a clustered index record deleted. Writes an undo log record to undo log on this delete marking. Writes in the trx id field the id @@ -428,7 +428,7 @@ btr_cur_del_mark_set_clust_rec( const ulint* offsets,/*!< in: rec_get_offsets(rec) */ que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************//** Sets a secondary index record delete mark to TRUE or FALSE. @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ @@ -441,7 +441,7 @@ btr_cur_del_mark_set_sec_rec( ibool val, /*!< in: value to set */ que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Tries to compress a page of the tree if it seems useful. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid @@ -459,7 +459,7 @@ btr_cur_compress_if_useful( ibool adjust, /*!< in: TRUE if should adjust the cursor position even if compression occurs */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************//** Removes the record on which the tree cursor is positioned. It is assumed that the mtr has an x-latch on the page where the cursor is positioned, @@ -480,7 +480,7 @@ btr_cur_optimistic_delete_func( TRUE on a leaf page of a secondary index, the mtr must be committed before latching any further pages */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # ifdef UNIV_DEBUG # define btr_cur_optimistic_delete(cursor, flags, mtr) \ btr_cur_optimistic_delete_func(cursor, flags, mtr) @@ -516,7 +516,7 @@ btr_cur_pessimistic_delete( ulint flags, /*!< in: BTR_CREATE_FLAG or 0 */ enum trx_rb_ctx rb_ctx, /*!< in: rollback context */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Parses a redo log record of updating a record in-place. @@ -610,7 +610,7 @@ btr_cur_disown_inherited_fields( const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ const upd_t* update, /*!< in: update vector */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull(2,3,4,5,6))); + MY_ATTRIBUTE((nonnull(2,3,4,5,6))); /** Operation code for btr_store_big_rec_extern_fields(). */ enum blob_op { @@ -630,7 +630,7 @@ ibool btr_blob_op_is_update( /*==================*/ enum blob_op op) /*!< in: operation */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** Stores the fields in big_rec_vec to the tablespace and puts pointers to @@ -655,7 +655,7 @@ btr_store_big_rec_extern_fields( mtr_t* btr_mtr, /*!< in: mtr containing the latches to the clustered index */ enum blob_op op) /*! in: operation code */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Frees the space in an externally stored field to the file space @@ -752,7 +752,7 @@ btr_push_update_extern_fields( dtuple_t* tuple, /*!< in/out: data tuple */ const upd_t* update, /*!< in: update vector */ mem_heap_t* heap) /*!< in: memory heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Sets a secondary index record's delete mark to the given value. This function is only used by the insert buffer merge mechanism. */ diff --git a/storage/xtradb/include/btr0pcur.h b/storage/xtradb/include/btr0pcur.h index d8e7cf6b283..dafe14ce556 100644 --- a/storage/xtradb/include/btr0pcur.h +++ b/storage/xtradb/include/btr0pcur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -155,7 +155,7 @@ btr_pcur_open_at_index_side( ulint level, /*!< in: level to search for (0=leaf) */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Gets the up_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if diff --git a/storage/xtradb/include/btr0sea.h b/storage/xtradb/include/btr0sea.h index d40094461ff..8f438bf640e 100644 --- a/storage/xtradb/include/btr0sea.h +++ b/storage/xtradb/include/btr0sea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -69,7 +69,7 @@ btr_search_t* btr_search_get_info( /*================*/ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*****************************************************************//** Creates and initializes a search info struct. @return own: search info struct */ @@ -200,7 +200,7 @@ hash_table_t* btr_search_get_hash_table( /*======================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((pure,warn_unused_result)); + MY_ATTRIBUTE((pure,warn_unused_result)); /********************************************************************//** Returns the adaptive hash index latch for a given index key. @@ -210,7 +210,7 @@ prio_rw_lock_t* btr_search_get_latch( /*=================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((pure,warn_unused_result)); + MY_ATTRIBUTE((pure,warn_unused_result)); /*********************************************************************//** Returns the AHI partition number corresponding to a given index ID. */ @@ -219,7 +219,7 @@ ulint btr_search_get_key( /*===============*/ index_id_t index_id) /*!< in: index ID */ - __attribute__((pure,warn_unused_result)); + MY_ATTRIBUTE((pure,warn_unused_result)); /*********************************************************************//** Initializes AHI-related fields in a newly created index. */ @@ -228,7 +228,7 @@ void btr_search_index_init( /*===============*/ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Latches all adaptive hash index latches in exclusive mode. */ @@ -256,7 +256,7 @@ bool btr_search_own_all( /*===============*/ ulint lock_type) - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Checks if the thread owns any adaptive hash latches in either S or X mode. @return true if the thread owns at least one latch in any mode. */ @@ -264,7 +264,7 @@ UNIV_INLINE bool btr_search_own_any(void) /*=====================*/ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /** The search info struct in an index */ diff --git a/storage/xtradb/include/btr0types.h b/storage/xtradb/include/btr0types.h index cd0392e7951..4bc9c72eccc 100644 --- a/storage/xtradb/include/btr0types.h +++ b/storage/xtradb/include/btr0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -82,7 +82,7 @@ btr_blob_dbg_rbt_insert( dict_index_t* index, /*!< in/out: index tree */ const btr_blob_dbg_t* b, /*!< in: the reference */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Remove from index->blobs a reference to an off-page column. @param index the index tree @@ -95,7 +95,7 @@ btr_blob_dbg_rbt_delete( dict_index_t* index, /*!< in/out: index tree */ const btr_blob_dbg_t* b, /*!< in: the reference */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Add to index->blobs any references to off-page columns from a record. @@ -108,7 +108,7 @@ btr_blob_dbg_add_rec( dict_index_t* index, /*!< in/out: index */ const ulint* offsets,/*!< in: offsets */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Remove from index->blobs any references to off-page columns from a record. @return number of references removed */ @@ -120,7 +120,7 @@ btr_blob_dbg_remove_rec( dict_index_t* index, /*!< in/out: index */ const ulint* offsets,/*!< in: offsets */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Count and add to index->blobs any references to off-page columns from records on a page. @@ -132,7 +132,7 @@ btr_blob_dbg_add( const page_t* page, /*!< in: rewritten page */ dict_index_t* index, /*!< in/out: index */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Count and remove from index->blobs any references to off-page columns from records on a page. @@ -145,7 +145,7 @@ btr_blob_dbg_remove( const page_t* page, /*!< in: b-tree page */ dict_index_t* index, /*!< in/out: index */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Restore in index->blobs any references to off-page columns Used when page reorganize fails due to compressed page overflow. */ @@ -157,7 +157,7 @@ btr_blob_dbg_restore( const page_t* page, /*!< in: copy of original page */ dict_index_t* index, /*!< in/out: index */ const char* ctx) /*!< in: context (for logging) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Operation that processes the BLOB references of an index record @param[in] rec record on index page @@ -181,7 +181,7 @@ btr_blob_dbg_op( dict_index_t* index, /*!< in/out: index */ const char* ctx, /*!< in: context (for logging) */ const btr_blob_dbg_op_f op) /*!< in: operation on records */ - __attribute__((nonnull(1,3,4,5))); + MY_ATTRIBUTE((nonnull(1,3,4,5))); #else /* UNIV_BLOB_DEBUG */ # define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0) # define btr_blob_dbg_add(page, index, ctx) ((void) 0) diff --git a/storage/xtradb/include/buf0buddy.h b/storage/xtradb/include/buf0buddy.h index a86fc87e3d3..09768dda92f 100644 --- a/storage/xtradb/include/buf0buddy.h +++ b/storage/xtradb/include/buf0buddy.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -54,7 +54,7 @@ buf_buddy_alloc( storage was allocated from the LRU list and buf_pool->LRU_list_mutex was temporarily released */ - __attribute__((malloc, nonnull)); + MY_ATTRIBUTE((malloc, nonnull)); /**********************************************************************//** Deallocate a block. */ @@ -68,7 +68,7 @@ buf_buddy_free( be pointed to by the buffer pool */ ulint size) /*!< in: block size, up to UNIV_PAGE_SIZE */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_NONINL # include "buf0buddy.ic" diff --git a/storage/xtradb/include/buf0buddy.ic b/storage/xtradb/include/buf0buddy.ic index 020442016d0..9bc8e9e8762 100644 --- a/storage/xtradb/include/buf0buddy.ic +++ b/storage/xtradb/include/buf0buddy.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -50,7 +50,7 @@ buf_buddy_alloc_low( allocated from the LRU list and buf_pool->LRU_list_mutex was temporarily released */ - __attribute__((malloc, nonnull)); + MY_ATTRIBUTE((malloc, nonnull)); /**********************************************************************//** Deallocate a block. */ @@ -63,7 +63,7 @@ buf_buddy_free_low( pointed to by the buffer pool */ ulint i) /*!< in: index of buf_pool->zip_free[], or BUF_BUDDY_SIZES */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Get the index of buf_pool->zip_free[] for a given block size. diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index c25cd406498..f599997be02 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2015, MariaDB Corporation. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation. 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 @@ -244,7 +244,7 @@ buf_relocate( buf_page_get_state(bpage) must be BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */ buf_page_t* dpage) /*!< in/out: destination control block */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the current size of buffer buf_pool in bytes. @return size in bytes */ @@ -284,7 +284,7 @@ UNIV_INLINE buf_page_t* buf_page_alloc_descriptor(void) /*===========================*/ - __attribute__((malloc)); + MY_ATTRIBUTE((malloc)); /********************************************************************//** Free a buf_page_t descriptor. */ UNIV_INLINE @@ -292,7 +292,7 @@ void buf_page_free_descriptor( /*=====================*/ buf_page_t* bpage) /*!< in: bpage descriptor to free. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Allocates a buffer block. @@ -533,7 +533,7 @@ ulint buf_page_get_freed_page_clock( /*==========================*/ const buf_page_t* bpage) /*!< in: block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /********************************************************************//** Reads the freed_page_clock of a buffer block. @return freed_page_clock */ @@ -542,7 +542,7 @@ ulint buf_block_get_freed_page_clock( /*===========================*/ const buf_block_t* block) /*!< in: block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /********************************************************************//** Tells if a block is still close enough to the MRU end of the LRU list @@ -605,7 +605,7 @@ buf_block_buf_fix_inc_func( ulint line, /*!< in: line */ # endif /* UNIV_SYNC_DEBUG */ buf_block_t* block) /*!< in/out: block to bufferfix */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Increments the bufferfix count. */ @@ -651,7 +651,7 @@ buf_page_is_corrupted( const byte* read_buf, /*!< in: a database page */ ulint zip_size) /*!< in: size of compressed page; 0 for uncompressed pages */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Checks if a page is all zeroes. @return TRUE if the page is all zeroes */ @@ -681,7 +681,7 @@ ulint buf_block_get_lock_hash_val( /*========================*/ const buf_block_t* block) /*!< in: block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #ifdef UNIV_DEBUG /*********************************************************************//** Finds a block in the buffer pool that points to a @@ -739,10 +739,10 @@ buf_page_print( const byte* read_buf, /*!< in: a database page */ ulint zip_size, /*!< in: compressed page size, or 0 for uncompressed pages */ - ulint flags); /*!< in: 0 or + ulint flags) /*!< in: 0 or BUF_PAGE_PRINT_NO_CRASH or BUF_PAGE_PRINT_NO_FULL */ - + UNIV_COLD MY_ATTRIBUTE((nonnull)); /********************************************************************//** Decompress a block. @return TRUE if successful */ @@ -879,7 +879,7 @@ enum buf_page_state buf_block_get_state( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Sets the state of a block. */ UNIV_INLINE @@ -904,7 +904,7 @@ ibool buf_page_in_file( /*=============*/ const buf_page_t* bpage) /*!< in: pointer to control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** Determines if a block should be on unzip_LRU list. @@ -914,7 +914,7 @@ ibool buf_page_belongs_to_unzip_LRU( /*==========================*/ const buf_page_t* bpage) /*!< in: pointer to control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the mutex of a block. @@ -924,7 +924,7 @@ ib_mutex_t* buf_page_get_mutex( /*===============*/ const buf_page_t* bpage) /*!< in: pointer to control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Get the flush type of a page. @@ -934,7 +934,7 @@ buf_flush_t buf_page_get_flush_type( /*====================*/ const buf_page_t* bpage) /*!< in: buffer page */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Set the flush type of a page. */ UNIV_INLINE @@ -960,7 +960,7 @@ enum buf_io_fix buf_page_get_io_fix( /*================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the io_fix state of a block. @return io_fix state */ @@ -969,7 +969,7 @@ enum buf_io_fix buf_block_get_io_fix( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the io_fix state of a block. Does not assert that the buf_page_get_mutex() mutex is held, to be used in the cases where it is safe @@ -980,7 +980,7 @@ enum buf_io_fix buf_page_get_io_fix_unlocked( /*=========================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Sets the io_fix state of a block. */ UNIV_INLINE @@ -1026,7 +1026,7 @@ ibool buf_page_can_relocate( /*==================*/ const buf_page_t* bpage) /*!< control block being relocated */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Determine if a block has been flagged old. @@ -1036,7 +1036,7 @@ ibool buf_page_is_old( /*============*/ const buf_page_t* bpage) /*!< in: control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Flag a block old. */ UNIV_INLINE @@ -1053,7 +1053,7 @@ unsigned buf_page_is_accessed( /*=================*/ const buf_page_t* bpage) /*!< in: control block */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*********************************************************************//** Flag a block accessed. */ UNIV_INLINE @@ -1061,7 +1061,7 @@ void buf_page_set_accessed( /*==================*/ buf_page_t* bpage) /*!< in/out: control block */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the buf_block_t handle of a buffered file block if an uncompressed page frame exists, or NULL. Note: even though bpage is not declared a @@ -1072,7 +1072,7 @@ buf_block_t* buf_page_get_block( /*===============*/ buf_page_t* bpage) /*!< in: control block, or NULL */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG /*********************************************************************//** @@ -1083,7 +1083,7 @@ buf_frame_t* buf_block_get_frame( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); # define buf_block_get_frame_fast(block) buf_block_get_frame(block) #else /* UNIV_DEBUG */ # define buf_block_get_frame(block) (block ? (block)->frame : 0) @@ -1097,7 +1097,7 @@ ulint buf_page_get_space( /*===============*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the space id of a block. @return space id */ @@ -1106,7 +1106,7 @@ ulint buf_block_get_space( /*================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the page number of a block. @return page number */ @@ -1115,7 +1115,7 @@ ulint buf_page_get_page_no( /*=================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the page number of a block. @return page number */ @@ -1124,7 +1124,7 @@ ulint buf_block_get_page_no( /*==================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the compressed page size of a block. @return compressed page size, or 0 */ @@ -1133,7 +1133,7 @@ ulint buf_page_get_zip_size( /*==================*/ const buf_page_t* bpage) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the compressed page size of a block. @return compressed page size, or 0 */ @@ -1142,7 +1142,7 @@ ulint buf_block_get_zip_size( /*===================*/ const buf_block_t* block) /*!< in: pointer to the control block */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /*********************************************************************//** Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ @@ -1231,7 +1231,7 @@ buf_page_address_fold( /*==================*/ ulint space, /*!< in: space id */ ulint offset) /*!< in: offset of the page within space */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************************//** Calculates the index of a buffer pool to the buf_pool[] array. @return the position of the buffer pool in buf_pool[] */ @@ -1240,7 +1240,7 @@ ulint buf_pool_index( /*===========*/ const buf_pool_t* buf_pool) /*!< in: buffer pool */ - __attribute__((nonnull, const)); + MY_ATTRIBUTE((nonnull, const)); /******************************************************************//** Returns the buffer pool instance given a page instance @return buf_pool */ @@ -1380,7 +1380,7 @@ buf_pool_watch_is_sentinel( /*=======================*/ buf_pool_t* buf_pool, /*!< buffer pool instance */ const buf_page_t* bpage) /*!< in: block */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** Add watch for the given page to be read in. Caller must have appropriate hash_lock for the bpage and hold the LRU list mutex to avoid a race @@ -1394,7 +1394,7 @@ buf_pool_watch_set( ulint space, /*!< in: space id */ ulint offset, /*!< in: page number */ ulint fold) /*!< in: buf_page_address_fold(space, offset) */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /****************************************************************//** Stop watching if the page has been read in. buf_pool_watch_set(space,offset) must have returned NULL before. */ @@ -1415,7 +1415,7 @@ buf_pool_watch_occurred( /*====================*/ ulint space, /*!< in: space id */ ulint offset) /*!< in: page number */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Get total buffer pool statistics. */ UNIV_INTERN @@ -1473,7 +1473,7 @@ bool buf_own_zip_mutex_for_page( /*=======================*/ const buf_page_t* bpage) - __attribute__((nonnull,warn_unused_result)); + MY_ATTRIBUTE((nonnull,warn_unused_result)); #endif /* UNIV_DEBUG */ /********************************************************************//** diff --git a/storage/xtradb/include/buf0buf.ic b/storage/xtradb/include/buf0buf.ic index f7e51231471..7b1c66f2a05 100644 --- a/storage/xtradb/include/buf0buf.ic +++ b/storage/xtradb/include/buf0buf.ic @@ -305,6 +305,20 @@ buf_page_set_state( ut_a(state == BUF_BLOCK_NOT_USED); break; case BUF_BLOCK_FILE_PAGE: + if (!(state == BUF_BLOCK_NOT_USED + || state == BUF_BLOCK_REMOVE_HASH)) { + const char *old_state_name = buf_get_state_name((buf_block_t*)bpage); + bpage->state = state; + + fprintf(stderr, + "InnoDB: Error: block old state %d (%s) " + " new state %d (%s) not correct\n", + old_state, + old_state_name, + state, + buf_get_state_name((buf_block_t*)bpage)); + } + ut_a(state == BUF_BLOCK_NOT_USED || state == BUF_BLOCK_REMOVE_HASH); break; diff --git a/storage/xtradb/include/buf0flu.h b/storage/xtradb/include/buf0flu.h index c8a329251fa..af50a5498ef 100644 --- a/storage/xtradb/include/buf0flu.h +++ b/storage/xtradb/include/buf0flu.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,7 +96,7 @@ buf_flush_page_try( /*===============*/ buf_pool_t* buf_pool, /*!< in/out: buffer pool instance */ buf_block_t* block) /*!< in/out: buffer control block */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ /*******************************************************************//** This utility flushes dirty blocks from the end of the flush list of @@ -277,7 +277,7 @@ buf_flush_ready_for_flush( buf_page_t* bpage, /*!< in: buffer control block, must be buf_page_in_file(bpage) */ buf_flush_t flush_type)/*!< in: type of flush */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG /******************************************************************//** @@ -310,7 +310,7 @@ UNIV_INLINE bool buf_flush_flush_list_in_progress(void) /*==================================*/ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /** If LRU list of a buf_pool is less than this size then LRU eviction should not happen. This is because when we do LRU flushing we also put diff --git a/storage/xtradb/include/buf0lru.h b/storage/xtradb/include/buf0lru.h index f421e329bf0..f056c6c4116 100644 --- a/storage/xtradb/include/buf0lru.h +++ b/storage/xtradb/include/buf0lru.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -97,7 +97,7 @@ buf_LRU_free_page( buf_page_t* bpage, /*!< in: block to be freed */ bool zip) /*!< in: true if should remove also the compressed page of an uncompressed page */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Try to free a replaceable block. @return TRUE if found and freed */ @@ -109,7 +109,7 @@ buf_LRU_scan_and_free_block( ibool scan_all) /*!< in: scan whole LRU list if TRUE, otherwise scan only 'old' blocks. */ - __attribute__((nonnull,warn_unused_result)); + MY_ATTRIBUTE((nonnull,warn_unused_result)); /******************************************************************//** Returns a free block from the buf_pool. The block is taken off the free list. If it is empty, returns NULL. @@ -150,7 +150,7 @@ buf_block_t* buf_LRU_get_free_block( /*===================*/ buf_pool_t* buf_pool) /*!< in/out: buffer pool instance */ - __attribute__((nonnull,warn_unused_result)); + MY_ATTRIBUTE((nonnull,warn_unused_result)); /******************************************************************//** Determines if the unzip_LRU list should be used for evicting a victim instead of the general LRU list. @@ -233,7 +233,7 @@ buf_LRU_free_one_page( buf_page_t* bpage) /*!< in/out: block, must contain a file page and be in a state where it can be freed; there may or may not be a hash index to the page */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** diff --git a/storage/xtradb/include/data0data.h b/storage/xtradb/include/data0data.h index a548c7b89b3..1d954bfc07c 100644 --- a/storage/xtradb/include/data0data.h +++ b/storage/xtradb/include/data0data.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -46,7 +46,7 @@ dtype_t* dfield_get_type( /*============*/ const dfield_t* field) /*!< in: SQL data field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets pointer to the data in a field. @return pointer to data */ @@ -55,7 +55,7 @@ void* dfield_get_data( /*============*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ # define dfield_get_type(field) (&(field)->type) # define dfield_get_data(field) ((field)->data) @@ -68,7 +68,7 @@ dfield_set_type( /*============*/ dfield_t* field, /*!< in: SQL data field */ const dtype_t* type) /*!< in: pointer to data type struct */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets length of field data. @return length of data; UNIV_SQL_NULL if SQL null data */ @@ -77,7 +77,7 @@ ulint dfield_get_len( /*===========*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets length in a field. */ UNIV_INLINE @@ -86,7 +86,7 @@ dfield_set_len( /*===========*/ dfield_t* field, /*!< in: field */ ulint len) /*!< in: length or UNIV_SQL_NULL */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Determines if a field is SQL NULL @return nonzero if SQL null data */ @@ -95,7 +95,7 @@ ulint dfield_is_null( /*===========*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Determines if a field is externally stored @return nonzero if externally stored */ @@ -104,7 +104,7 @@ ulint dfield_is_ext( /*==========*/ const dfield_t* field) /*!< in: field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets the "external storage" flag */ UNIV_INLINE @@ -112,7 +112,7 @@ void dfield_set_ext( /*===========*/ dfield_t* field) /*!< in/out: field */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Sets pointer to the data and length in a field. */ UNIV_INLINE @@ -122,7 +122,7 @@ dfield_set_data( dfield_t* field, /*!< in: field */ const void* data, /*!< in: data */ ulint len) /*!< in: length or UNIV_SQL_NULL */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*********************************************************************//** Sets a data field to SQL NULL. */ UNIV_INLINE @@ -130,7 +130,7 @@ void dfield_set_null( /*============*/ dfield_t* field) /*!< in/out: field */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Writes an SQL null field full of zeros. */ UNIV_INLINE @@ -139,7 +139,7 @@ data_write_sql_null( /*================*/ byte* data, /*!< in: pointer to a buffer of size len */ ulint len) /*!< in: SQL null size in bytes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies the data and len fields. */ UNIV_INLINE @@ -148,7 +148,7 @@ dfield_copy_data( /*=============*/ dfield_t* field1, /*!< out: field to copy to */ const dfield_t* field2) /*!< in: field to copy from */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies a data field to another. */ UNIV_INLINE @@ -157,7 +157,7 @@ dfield_copy( /*========*/ dfield_t* field1, /*!< out: field to copy to */ const dfield_t* field2) /*!< in: field to copy from */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies the data pointed to by a data field. */ UNIV_INLINE @@ -166,7 +166,7 @@ dfield_dup( /*=======*/ dfield_t* field, /*!< in/out: data field */ mem_heap_t* heap) /*!< in: memory heap where allocated */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** Tests if two data fields are equal. @@ -181,7 +181,7 @@ dfield_datas_are_binary_equal( const dfield_t* field2, /*!< in: field */ ulint len) /*!< in: maximum prefix to compare, or 0 to compare the whole field length */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Tests if dfield data length and content is equal to the given. @return TRUE if equal */ @@ -192,7 +192,7 @@ dfield_data_is_binary_equal( const dfield_t* field, /*!< in: field */ ulint len, /*!< in: data length or UNIV_SQL_NULL */ const byte* data) /*!< in: data */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************************//** Gets number of fields in a data tuple. @@ -202,7 +202,7 @@ ulint dtuple_get_n_fields( /*================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG /*********************************************************************//** Gets nth field of a tuple. @@ -224,7 +224,7 @@ ulint dtuple_get_info_bits( /*=================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets info bits in a data tuple. */ UNIV_INLINE @@ -233,7 +233,7 @@ dtuple_set_info_bits( /*=================*/ dtuple_t* tuple, /*!< in: tuple */ ulint info_bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets number of fields used in record comparisons. @return number of fields used in comparisons in rem0cmp.* */ @@ -242,7 +242,7 @@ ulint dtuple_get_n_fields_cmp( /*====================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets number of fields used in record comparisons. */ UNIV_INLINE @@ -252,7 +252,7 @@ dtuple_set_n_fields_cmp( dtuple_t* tuple, /*!< in: tuple */ ulint n_fields_cmp) /*!< in: number of fields used in comparisons in rem0cmp.* */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /* Estimate the number of bytes that are going to be allocated when creating a new dtuple_t object */ @@ -272,7 +272,7 @@ dtuple_create_from_mem( void* buf, /*!< in, out: buffer to use */ ulint buf_size, /*!< in: buffer size */ ulint n_fields) /*!< in: number of fields */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Creates a data tuple to a memory heap. The default value for number @@ -286,7 +286,7 @@ dtuple_create( is created, DTUPLE_EST_ALLOC(n_fields) bytes will be allocated from this heap */ ulint n_fields)/*!< in: number of fields */ - __attribute__((nonnull, malloc)); + MY_ATTRIBUTE((nonnull, malloc)); /*********************************************************************//** Sets number of fields used in a tuple. Normally this is set in @@ -297,7 +297,7 @@ dtuple_set_n_fields( /*================*/ dtuple_t* tuple, /*!< in: tuple */ ulint n_fields) /*!< in: number of fields */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Copies a data tuple to another. This is a shallow copy; if a deep copy is desired, dfield_dup() will have to be invoked on each field. @@ -309,7 +309,7 @@ dtuple_copy( const dtuple_t* tuple, /*!< in: tuple to copy from */ mem_heap_t* heap) /*!< in: memory heap where the tuple is created */ - __attribute__((nonnull, malloc)); + MY_ATTRIBUTE((nonnull, malloc)); /**********************************************************//** The following function returns the sum of data lengths of a tuple. The space occupied by the field structs or the tuple struct is not counted. @@ -320,7 +320,7 @@ dtuple_get_data_size( /*=================*/ const dtuple_t* tuple, /*!< in: typed data tuple */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Computes the number of externally stored fields in a data tuple. @return number of fields */ @@ -329,7 +329,7 @@ ulint dtuple_get_n_ext( /*=============*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Compare two data tuples, respecting the collation of character fields. @return 1, 0 , -1 if tuple1 is greater, equal, less, respectively, @@ -340,7 +340,7 @@ dtuple_coll_cmp( /*============*/ const dtuple_t* tuple1, /*!< in: tuple 1 */ const dtuple_t* tuple2) /*!< in: tuple 2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Folds a prefix given as the number of fields of a tuple. @return the folded value */ @@ -353,7 +353,7 @@ dtuple_fold( ulint n_bytes,/*!< in: number of bytes to fold in an incomplete last field */ index_id_t tree_id)/*!< in: index tree id */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /*******************************************************************//** Sets types of fields binary in a tuple. */ UNIV_INLINE @@ -362,7 +362,7 @@ dtuple_set_types_binary( /*====================*/ dtuple_t* tuple, /*!< in: data tuple */ ulint n) /*!< in: number of fields to set */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Checks if a dtuple contains an SQL null value. @return TRUE if some field is SQL null */ @@ -371,7 +371,7 @@ ibool dtuple_contains_null( /*=================*/ const dtuple_t* tuple) /*!< in: dtuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Checks that a data field is typed. Asserts an error if not. @return TRUE if ok */ @@ -380,7 +380,7 @@ ibool dfield_check_typed( /*===============*/ const dfield_t* field) /*!< in: data field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Checks that a data tuple is typed. Asserts an error if not. @return TRUE if ok */ @@ -389,7 +389,7 @@ ibool dtuple_check_typed( /*===============*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Checks that a data tuple is typed. @return TRUE if ok */ @@ -398,7 +398,7 @@ ibool dtuple_check_typed_no_assert( /*=========================*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG /**********************************************************//** Validates the consistency of a tuple which must be complete, i.e, @@ -409,7 +409,7 @@ ibool dtuple_validate( /*============*/ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /*************************************************************//** Pretty prints a dfield value according to its data type. */ @@ -418,7 +418,7 @@ void dfield_print( /*=========*/ const dfield_t* dfield) /*!< in: dfield */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Pretty prints a dfield value according to its data type. Also the hex string is printed if a string contains non-printable characters. */ @@ -427,7 +427,7 @@ void dfield_print_also_hex( /*==================*/ const dfield_t* dfield) /*!< in: dfield */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************//** The following function prints the contents of a tuple. */ UNIV_INTERN @@ -436,7 +436,7 @@ dtuple_print( /*=========*/ FILE* f, /*!< in: output stream */ const dtuple_t* tuple) /*!< in: tuple */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Moves parts of long fields in entry to the big record vector so that the size of tuple drops below the maximum record size allowed in the @@ -453,7 +453,7 @@ dtuple_convert_big_rec( dtuple_t* entry, /*!< in/out: index entry */ ulint* n_ext) /*!< in/out: number of externally stored columns */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /**************************************************************//** Puts back to entry the data stored in vector. Note that to ensure the fields in entry can accommodate the data, vector must have been created @@ -466,7 +466,7 @@ dtuple_convert_back_big_rec( dtuple_t* entry, /*!< in: entry whose data was put to vector */ big_rec_t* vector) /*!< in, own: big rec vector; it is freed in this function */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Frees the memory in a big rec vector. */ UNIV_INLINE @@ -475,7 +475,7 @@ dtuple_big_rec_free( /*================*/ big_rec_t* vector) /*!< in, own: big rec vector; it is freed in this function */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*######################################################################*/ diff --git a/storage/xtradb/include/data0data.ic b/storage/xtradb/include/data0data.ic index 6937d55d211..11499ab928c 100644 --- a/storage/xtradb/include/data0data.ic +++ b/storage/xtradb/include/data0data.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -56,7 +56,8 @@ dfield_set_type( dfield_t* field, /*!< in: SQL data field */ const dtype_t* type) /*!< in: pointer to data type struct */ { - ut_ad(field && type); + ut_ad(field != NULL); + ut_ad(type != NULL); field->type = *type; } @@ -194,7 +195,8 @@ dfield_copy_data( dfield_t* field1, /*!< out: field to copy to */ const dfield_t* field2) /*!< in: field to copy from */ { - ut_ad(field1 && field2); + ut_ad(field1 != NULL); + ut_ad(field2 != NULL); field1->data = field2->data; field1->len = field2->len; diff --git a/storage/xtradb/include/dict0boot.h b/storage/xtradb/include/dict0boot.h index a994c9d8ff1..477e1150f43 100644 --- a/storage/xtradb/include/dict0boot.h +++ b/storage/xtradb/include/dict0boot.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -95,7 +95,7 @@ UNIV_INTERN dberr_t dict_boot(void) /*===========*/ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*****************************************************************//** Creates and initializes the data dictionary at the server bootstrap. @@ -104,7 +104,7 @@ UNIV_INTERN dberr_t dict_create(void) /*=============*/ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Check if a table id belongs to system table. @@ -114,7 +114,7 @@ bool dict_is_sys_table( /*==============*/ table_id_t id) /*!< in: table id to check */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /* Space id and page no where the dictionary header resides */ #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */ diff --git a/storage/xtradb/include/dict0crea.h b/storage/xtradb/include/dict0crea.h index 3b746fcf83c..77627c9bf67 100644 --- a/storage/xtradb/include/dict0crea.h +++ b/storage/xtradb/include/dict0crea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -137,7 +137,7 @@ dict_create_add_foreign_id( incremented if used */ const char* name, /*!< in: table name */ dict_foreign_t* foreign)/*!< in/out: foreign key */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Adds the given set of foreign key objects to the dictionary tables in the database. This function does not modify the dictionary cache. The @@ -156,7 +156,7 @@ dict_create_add_foreigns_to_dictionary( const dict_foreign_set& local_fk_set, const dict_table_t* table, trx_t* trx) - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** Creates the tablespaces and datafiles system tables inside InnoDB at server bootstrap or server start if they are not found or are @@ -192,7 +192,7 @@ dict_create_add_foreign_to_dictionary( const char* name, /*!< in: table name */ const dict_foreign_t* foreign,/*!< in: foreign key */ trx_t* trx) /*!< in/out: dictionary transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /* Table create node structure */ struct tab_node_t{ diff --git a/storage/xtradb/include/dict0crea.ic b/storage/xtradb/include/dict0crea.ic index 2d0d9dcb858..1cbaa47032b 100644 --- a/storage/xtradb/include/dict0crea.ic +++ b/storage/xtradb/include/dict0crea.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -33,7 +33,7 @@ UNIV_INTERN bool row_is_mysql_tmp_table_name( /*========================*/ - const char* name) __attribute__((warn_unused_result)); + const char* name) MY_ATTRIBUTE((warn_unused_result)); /*!< in: table name in the form 'database/tablename' */ diff --git a/storage/xtradb/include/dict0dict.h b/storage/xtradb/include/dict0dict.h index 2b73efaabc7..e843d63e717 100644 --- a/storage/xtradb/include/dict0dict.h +++ b/storage/xtradb/include/dict0dict.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -59,7 +59,7 @@ void dict_casedn_str( /*============*/ char* a) /*!< in/out: string to put in lower case */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Get the database name length in a table name. @return database name length */ @@ -69,7 +69,7 @@ dict_get_db_name_len( /*=================*/ const char* name) /*!< in: table name in the form dbname '/' tablename */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table. @@ -113,7 +113,7 @@ dict_remove_db_name( /*================*/ const char* name) /*!< in: table name in the form dbname '/' tablename */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Operation to perform when opening a table */ enum dict_table_op_t { @@ -161,7 +161,7 @@ dict_table_close( ibool try_drop) /*!< in: TRUE=try to drop any orphan indexes after an aborted online index creation */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Inits the data dictionary module. */ UNIV_INTERN @@ -186,7 +186,7 @@ ulint dict_col_get_mbminlen( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the maximum number of bytes per character. @return maximum multi-byte char size, in bytes */ @@ -195,7 +195,7 @@ ulint dict_col_get_mbmaxlen( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets the minimum and maximum number of bytes per character. */ UNIV_INLINE @@ -207,7 +207,7 @@ dict_col_set_mbminmaxlen( character size, in bytes */ ulint mbmaxlen) /*!< in: minimum multi-byte character size, in bytes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the column data type. */ UNIV_INLINE @@ -216,7 +216,7 @@ dict_col_copy_type( /*===============*/ const dict_col_t* col, /*!< in: column */ dtype_t* type) /*!< out: data type */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Determine bytes of column prefix to be stored in the undo log. Please note if the table format is UNIV_FORMAT_A (< UNIV_FORMAT_B), no prefix @@ -229,7 +229,7 @@ dict_max_field_len_store_undo( dict_table_t* table, /*!< in: table */ const dict_col_t* col) /*!< in: column which index prefix is based on */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG /*********************************************************************//** @@ -241,7 +241,7 @@ dict_col_type_assert_equal( /*=======================*/ const dict_col_t* col, /*!< in: column */ const dtype_t* type) /*!< in: data type */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ #ifndef UNIV_HOTBACKUP /***********************************************************************//** @@ -252,7 +252,7 @@ ulint dict_col_get_min_size( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Returns the maximum size of the column. @return maximum size */ @@ -261,7 +261,7 @@ ulint dict_col_get_max_size( /*==================*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Returns the size of a fixed size column, 0 if not a fixed size column. @return fixed size, or 0 */ @@ -271,7 +271,7 @@ dict_col_get_fixed_size( /*====================*/ const dict_col_t* col, /*!< in: column */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column. For fixed length types it is the fixed length of the type, otherwise 0. @@ -282,7 +282,7 @@ dict_col_get_sql_null_size( /*=======================*/ const dict_col_t* col, /*!< in: column */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the column number. @return col->ind, table column position (starting from 0) */ @@ -291,7 +291,7 @@ ulint dict_col_get_no( /*============*/ const dict_col_t* col) /*!< in: column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the column position in the clustered index. */ UNIV_INLINE @@ -300,7 +300,7 @@ dict_col_get_clust_pos( /*===================*/ const dict_col_t* col, /*!< in: table column */ const dict_index_t* clust_index) /*!< in: clustered index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** If the given column name is reserved for InnoDB system columns, return TRUE. @@ -310,7 +310,7 @@ ibool dict_col_name_is_reserved( /*======================*/ const char* name) /*!< in: column name */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Acquire the autoinc lock. */ UNIV_INTERN @@ -318,7 +318,7 @@ void dict_table_autoinc_lock( /*====================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Unconditionally set the autoinc counter. */ UNIV_INTERN @@ -327,7 +327,7 @@ dict_table_autoinc_initialize( /*==========================*/ dict_table_t* table, /*!< in/out: table */ ib_uint64_t value) /*!< in: next value to assign to a row */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Store autoinc value when the table is evicted. @param[in] table table evicted */ @@ -352,7 +352,7 @@ ib_uint64_t dict_table_autoinc_read( /*====================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Updates the autoinc counter if the value supplied is greater than the current value. */ @@ -363,7 +363,7 @@ dict_table_autoinc_update_if_greater( dict_table_t* table, /*!< in/out: table */ ib_uint64_t value) /*!< in: value which was assigned to a row */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Release the autoinc lock. */ UNIV_INTERN @@ -371,7 +371,7 @@ void dict_table_autoinc_unlock( /*======================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** Adds system columns to a table object. */ @@ -381,7 +381,7 @@ dict_table_add_system_columns( /*==========================*/ dict_table_t* table, /*!< in/out: table */ mem_heap_t* heap) /*!< in: temporary heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Adds a table object to the dictionary cache. */ @@ -392,7 +392,7 @@ dict_table_add_to_cache( dict_table_t* table, /*!< in: table */ ibool can_be_evicted, /*!< in: TRUE if can be evicted*/ mem_heap_t* heap) /*!< in: temporary heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Removes a table object from the dictionary cache. */ UNIV_INTERN @@ -400,7 +400,7 @@ void dict_table_remove_from_cache( /*=========================*/ dict_table_t* table) /*!< in, own: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Removes a table object from the dictionary cache. */ UNIV_INTERN @@ -423,7 +423,7 @@ dict_table_rename_in_cache( /*!< in: in ALTER TABLE we want to preserve the original table name in constraints which reference it */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Removes an index from the dictionary cache. */ UNIV_INTERN @@ -432,7 +432,7 @@ dict_index_remove_from_cache( /*=========================*/ dict_table_t* table, /*!< in/out: table */ dict_index_t* index) /*!< in, own: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Change the id of a table object in the dictionary cache. This is used in DISCARD TABLESPACE. */ @@ -442,7 +442,7 @@ dict_table_change_id_in_cache( /*==========================*/ dict_table_t* table, /*!< in/out: table object already in cache */ table_id_t new_id) /*!< in: new id to set */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Removes a foreign constraint struct from the dictionary cache. */ UNIV_INTERN @@ -450,7 +450,7 @@ void dict_foreign_remove_from_cache( /*===========================*/ dict_foreign_t* foreign) /*!< in, own: foreign constraint */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. @@ -471,7 +471,7 @@ dict_foreign_add_to_cache( compatibility */ dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); /*********************************************************************//** Checks if a table is referenced by foreign keys. @return TRUE if table is referenced by a foreign key */ @@ -480,7 +480,7 @@ ibool dict_table_is_referenced_by_foreign_key( /*====================================*/ const dict_table_t* table) /*!< in: InnoDB table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Replace the index passed in with another equivalent index in the foreign key lists of the table. @@ -494,7 +494,7 @@ dict_foreign_replace_index( /*!< in: column names, or NULL to use table->col_names */ const dict_index_t* index) /*!< in: index to be replaced */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /**********************************************************************//** Determines whether a string starts with the specified keyword. @return TRUE if str starts with keyword */ @@ -505,7 +505,7 @@ dict_str_starts_with_keyword( THD* thd, /*!< in: MySQL thread handle */ const char* str, /*!< in: string to scan for keyword */ const char* keyword) /*!< in: keyword to look for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function @@ -534,7 +534,7 @@ dict_create_foreign_constraints( ibool reject_fks) /*!< in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. @return DB_SUCCESS or DB_CANNOT_DROP_CONSTRAINT if syntax error or the @@ -551,7 +551,7 @@ dict_foreign_parse_drop_constraints( to drop */ const char*** constraints_to_drop) /*!< out: id's of the constraints to drop */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Returns a table object and increments its open handle count. NOTE! This is a high-level function to be used mainly from outside the @@ -570,7 +570,7 @@ dict_table_open_on_name( dict_err_ignore_t ignore_err) /*!< in: error to be ignored when loading the table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Tries to find an index whose first fields are the columns in the array, @@ -606,7 +606,7 @@ dict_foreign_find_index( dict_index_t** err_index) /*!< out: index where error happened */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); /**********************************************************************//** Returns a column's name. @return column name. NOTE: not guaranteed to stay valid if table is @@ -617,7 +617,7 @@ dict_table_get_col_name( /*====================*/ const dict_table_t* table, /*!< in: table */ ulint col_nr) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Returns a column's name. @return column name. NOTE: not guaranteed to stay valid if table is @@ -636,7 +636,7 @@ void dict_table_print( /*=============*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Outputs info on foreign keys of a table. */ UNIV_INTERN @@ -668,7 +668,7 @@ dict_index_name_print( FILE* file, /*!< in: output stream */ const trx_t* trx, /*!< in: transaction */ const dict_index_t* index) /*!< in: index to print */ - __attribute__((nonnull(1,3))); + MY_ATTRIBUTE((nonnull(1,3))); /*********************************************************************//** Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same @@ -705,7 +705,7 @@ dict_foreign_qualify_index( /*!< out: index where error happened */ - __attribute__((nonnull(1,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,3), warn_unused_result)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the first index on the table (the clustered index). @@ -715,7 +715,7 @@ dict_index_t* dict_table_get_first_index( /*=======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the last index on the table. @return index, NULL if none exists */ @@ -724,7 +724,7 @@ dict_index_t* dict_table_get_last_index( /*=======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the next index on the table. @return index, NULL if none left */ @@ -733,7 +733,7 @@ dict_index_t* dict_table_get_next_index( /*======================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ # define dict_table_get_first_index(table) UT_LIST_GET_FIRST((table)->indexes) # define dict_table_get_last_index(table) UT_LIST_GET_LAST((table)->indexes) @@ -762,7 +762,7 @@ ulint dict_index_is_clust( /*================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is unique. @return nonzero for unique index, zero for other indexes */ @@ -771,7 +771,7 @@ ulint dict_index_is_unique( /*=================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ @@ -780,7 +780,7 @@ ulint dict_index_is_ibuf( /*===============*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is a secondary index or the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ @@ -789,7 +789,7 @@ ulint dict_index_is_sec_or_ibuf( /*======================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /************************************************************************ Gets the all the FTS indexes for the table. NOTE: must not be called for @@ -801,7 +801,7 @@ dict_table_get_all_fts_indexes( /* out: number of indexes collected */ dict_table_t* table, /* in: table */ ib_vector_t* indexes)/* out: vector for collecting FTS indexes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Gets the number of user-defined columns in a table in the dictionary cache. @@ -811,7 +811,7 @@ ulint dict_table_get_n_user_cols( /*=======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of system columns in a table in the dictionary cache. @return number of system (e.g., ROW_ID) columns of a table */ @@ -820,7 +820,7 @@ ulint dict_table_get_n_sys_cols( /*======================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of all columns (also system) in a table in the dictionary cache. @@ -830,7 +830,7 @@ ulint dict_table_get_n_cols( /*==================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the approximately estimated number of rows in the table. @return estimated number of rows */ @@ -839,7 +839,7 @@ ib_uint64_t dict_table_get_n_rows( /*==================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Increment the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is @@ -849,7 +849,7 @@ void dict_table_n_rows_inc( /*==================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Decrement the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is @@ -859,7 +859,7 @@ void dict_table_n_rows_dec( /*==================*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the nth column of a table. @@ -870,7 +870,7 @@ dict_table_get_nth_col( /*===================*/ const dict_table_t* table, /*!< in: table */ ulint pos) /*!< in: position of column */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the given system column of a table. @return pointer to column object */ @@ -880,7 +880,7 @@ dict_table_get_sys_col( /*===================*/ const dict_table_t* table, /*!< in: table */ ulint sys) /*!< in: DATA_ROW_ID, ... */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ #define dict_table_get_nth_col(table, pos) \ ((table)->cols + (pos)) @@ -896,7 +896,7 @@ dict_table_get_sys_col_no( /*======================*/ const dict_table_t* table, /*!< in: table */ ulint sys) /*!< in: DATA_ROW_ID, ... */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /********************************************************************//** Returns the minimum data size of an index record. @@ -906,7 +906,7 @@ ulint dict_index_get_min_size( /*====================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /********************************************************************//** Check whether the table uses the compact page format. @@ -916,7 +916,7 @@ ibool dict_table_is_comp( /*===============*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Determine the file format of a table. @return file format version */ @@ -925,7 +925,7 @@ ulint dict_table_get_format( /*==================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Determine the file format from a dict_table_t::flags. @return file format version */ @@ -934,7 +934,7 @@ ulint dict_tf_get_format( /*===============*/ ulint flags) /*!< in: dict_table_t::flags */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Set the various values in a dict_table_t::flags pointer. */ UNIV_INLINE @@ -969,7 +969,7 @@ ulint dict_tf_to_fsp_flags( /*=================*/ ulint flags) /*!< in: dict_table_t::flags */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************************//** Extract the compressed page size from table flags. @return compressed page size, or 0 if not compressed */ @@ -978,7 +978,7 @@ ulint dict_tf_get_zip_size( /*=================*/ ulint flags) /*!< in: flags */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************************//** Check whether the table uses the compressed compact page format. @return compressed page size, or 0 if not compressed */ @@ -987,7 +987,7 @@ ulint dict_table_zip_size( /*================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** Obtain exclusive locks on all index trees of the table. This is to prevent @@ -998,7 +998,7 @@ void dict_table_x_lock_indexes( /*======================*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Release the exclusive locks on all index tree. */ UNIV_INLINE @@ -1006,7 +1006,7 @@ void dict_table_x_unlock_indexes( /*========================*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. @@ -1017,7 +1017,7 @@ dict_table_col_in_clustered_key( /*============================*/ const dict_table_t* table, /*!< in: table */ ulint n) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Check if the table has an FTS index. @return TRUE if table has an FTS index */ @@ -1026,7 +1026,7 @@ ibool dict_table_has_fts_index( /*=====================*/ dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should @@ -1037,7 +1037,7 @@ dict_table_copy_types( /*==================*/ dtuple_t* tuple, /*!< in/out: data tuple */ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************** Wait until all the background threads of the given table have exited, i.e., bg_threads == 0. Note: bg_threads_mutex must be reserved when @@ -1049,7 +1049,7 @@ dict_table_wait_for_bg_threads_to_exit( dict_table_t* table, /* in: table */ ulint delay) /* in: time in microseconds to wait between checks of bg_threads. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like @@ -1060,7 +1060,7 @@ dict_index_t* dict_index_find_on_id_low( /*======================*/ index_id_t id) /*!< in: index id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /**********************************************************************//** Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user @@ -1086,7 +1086,7 @@ dict_index_add_to_cache( ibool strict) /*!< in: TRUE=refuse to create the index if records could be too big to fit in an B-tree page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Removes an index from the dictionary cache. */ UNIV_INTERN @@ -1095,7 +1095,7 @@ dict_index_remove_from_cache( /*=========================*/ dict_table_t* table, /*!< in/out: table */ dict_index_t* index) /*!< in, own: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /********************************************************************//** Gets the number of fields in the internal representation of an index, @@ -1108,7 +1108,7 @@ dict_index_get_n_fields( const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of fields in the internal representation of an index that uniquely determine the position of an index entry in the index, if @@ -1121,7 +1121,7 @@ dict_index_get_n_unique( /*====================*/ const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of fields in the internal representation of an index which uniquely determine the position of an index entry in the index, if @@ -1133,7 +1133,7 @@ dict_index_get_n_unique_in_tree( /*============================*/ const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of user-defined ordering fields in the index. In the internal representation we add the row id to the ordering fields to make all indexes @@ -1146,7 +1146,7 @@ dict_index_get_n_ordering_defined_by_user( /*======================================*/ const dict_index_t* index) /*!< in: an internal representation of index (in the dictionary cache) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the nth field of an index. @@ -1157,7 +1157,7 @@ dict_index_get_nth_field( /*=====================*/ const dict_index_t* index, /*!< in: index */ ulint pos) /*!< in: position of field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #else /* UNIV_DEBUG */ # define dict_index_get_nth_field(index, pos) ((index)->fields + (pos)) #endif /* UNIV_DEBUG */ @@ -1170,7 +1170,7 @@ dict_index_get_nth_col( /*===================*/ const dict_index_t* index, /*!< in: index */ ulint pos) /*!< in: position of the field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the column number of the nth field in an index. @return column number */ @@ -1180,7 +1180,7 @@ dict_index_get_nth_col_no( /*======================*/ const dict_index_t* index, /*!< in: index */ ulint pos) /*!< in: position of the field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Looks for column n in an index. @return position in internal representation of the index; @@ -1217,7 +1217,7 @@ dict_index_contains_col_or_prefix( /*==============================*/ const dict_index_t* index, /*!< in: index */ ulint n) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Looks for a matching field in an index. The column has to be the same. The column in index must be complete, or must contain a prefix longer than the @@ -1232,7 +1232,7 @@ dict_index_get_nth_field_pos( const dict_index_t* index, /*!< in: index from which to search */ const dict_index_t* index2, /*!< in: index */ ulint n) /*!< in: field number in index2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Looks for column n position in the clustered index. @return position in internal representation of the clustered index */ @@ -1242,7 +1242,7 @@ dict_table_get_nth_col_pos( /*=======================*/ const dict_table_t* table, /*!< in: table */ ulint n) /*!< in: column number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Returns the position of a system column in an index. @return position, ULINT_UNDEFINED if not contained */ @@ -1252,7 +1252,7 @@ dict_index_get_sys_col_pos( /*=======================*/ const dict_index_t* index, /*!< in: index */ ulint type) /*!< in: DATA_ROW_ID, ... */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Adds a column to index. */ UNIV_INTERN @@ -1263,7 +1263,7 @@ dict_index_add_col( const dict_table_t* table, /*!< in: table */ dict_col_t* col, /*!< in: column */ ulint prefix_len) /*!< in: column prefix length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /*******************************************************************//** Copies types of fields contained in index to tuple. */ @@ -1275,7 +1275,7 @@ dict_index_copy_types( const dict_index_t* index, /*!< in: index */ ulint n_fields) /*!< in: number of field types to copy */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************************//** Gets the field column. @@ -1285,7 +1285,7 @@ const dict_col_t* dict_field_get_col( /*===============*/ const dict_field_t* field) /*!< in: index field */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Returns an index object if it is found in the dictionary cache. @@ -1296,7 +1296,7 @@ dict_index_t* dict_index_get_if_in_cache_low( /*===========================*/ index_id_t index_id) /*!< in: index id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** Returns an index object if it is found in the dictionary cache. @@ -1306,7 +1306,7 @@ dict_index_t* dict_index_get_if_in_cache( /*=======================*/ index_id_t index_id) /*!< in: index id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #ifdef UNIV_DEBUG /**********************************************************************//** @@ -1319,7 +1319,7 @@ dict_index_check_search_tuple( /*==========================*/ const dict_index_t* index, /*!< in: index tree */ const dtuple_t* tuple) /*!< in: tuple used in a search */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Whether and when to allow temporary index names */ enum check_name { /** Require all indexes to be complete. */ @@ -1339,7 +1339,7 @@ dict_table_check_for_dup_indexes( in this table */ enum check_name check) /*!< in: whether and when to allow temporary index names */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* UNIV_DEBUG */ /**********************************************************************//** Builds a node pointer out of a physical record and a page number. @@ -1357,7 +1357,7 @@ dict_index_build_node_ptr( created */ ulint level) /*!< in: level of rec in tree: 0 means leaf level */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Copies an initial segment of a physical record, long enough to specify an index entry uniquely. @@ -1373,7 +1373,7 @@ dict_index_copy_rec_order_prefix( byte** buf, /*!< in/out: memory buffer for the copied prefix, or NULL */ ulint* buf_size)/*!< in/out: buffer size */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Builds a typed data tuple out of a physical record. @return own: data tuple */ @@ -1385,7 +1385,7 @@ dict_index_build_data_tuple( rec_t* rec, /*!< in: record for which to build data tuple */ ulint n_fields,/*!< in: number of data fields */ mem_heap_t* heap) /*!< in: memory heap where tuple created */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the space id of the root of the index tree. @return space id */ @@ -1394,7 +1394,7 @@ ulint dict_index_get_space( /*=================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets the space id of the root of the index tree. */ UNIV_INLINE @@ -1403,7 +1403,7 @@ dict_index_set_space( /*=================*/ dict_index_t* index, /*!< in/out: index */ ulint space) /*!< in: space id */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Gets the page number of the root of the index tree. @return page number */ @@ -1412,7 +1412,7 @@ ulint dict_index_get_page( /*================*/ const dict_index_t* tree) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Gets the read-write lock of the index tree. @return read-write lock */ @@ -1421,7 +1421,7 @@ prio_rw_lock_t* dict_index_get_lock( /*================*/ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Returns free space reserved for future updates of records. This is relevant only in the case of many consecutive inserts, as updates @@ -1441,7 +1441,7 @@ enum online_index_status dict_index_get_online_status( /*=========================*/ const dict_index_t* index) /*!< in: secondary index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Sets the status of online index creation. */ UNIV_INLINE @@ -1450,7 +1450,7 @@ dict_index_set_online_status( /*=========================*/ dict_index_t* index, /*!< in/out: index */ enum online_index_status status) /*!< in: status */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications @@ -1464,7 +1464,7 @@ bool dict_index_is_online_ddl( /*=====================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Calculates the minimum record length in an index. */ UNIV_INTERN @@ -1472,7 +1472,7 @@ ulint dict_index_calc_min_rec_len( /*========================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Reserves the dictionary system mutex for MySQL. */ UNIV_INTERN @@ -1540,7 +1540,7 @@ dict_tables_have_same_db( dbname '/' tablename */ const char* name2) /*!< in: table name in the form dbname '/' tablename */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Removes an index from the cache */ UNIV_INTERN @@ -1549,7 +1549,7 @@ dict_index_remove_from_cache( /*=========================*/ dict_table_t* table, /*!< in/out: table */ dict_index_t* index) /*!< in, own: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Get index by name @return index, NULL if does not exist */ @@ -1559,7 +1559,7 @@ dict_table_get_index_on_name( /*=========================*/ dict_table_t* table, /*!< in: table */ const char* name) /*!< in: name of the index to find */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Looks for an index with the given id given a table instance. @return index or NULL */ @@ -1580,7 +1580,7 @@ dict_table_get_index_on_name_and_min_id( /*====================================*/ dict_table_t* table, /*!< in: table */ const char* name) /*!< in: name of the index to find */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************** Check whether a column exists in an FTS index. */ UNIV_INLINE @@ -1591,7 +1591,7 @@ dict_table_is_fts_column( the offset within the vector */ ib_vector_t* indexes,/* in: vector containing only FTS indexes */ ulint col_no) /* in: col number to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Move a table to the non LRU end of the LRU list. */ UNIV_INTERN @@ -1599,7 +1599,7 @@ void dict_table_move_from_lru_to_non_lru( /*================================*/ dict_table_t* table) /*!< in: table to move from LRU to non-LRU */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Move a table to the LRU list from the non-LRU list. */ UNIV_INTERN @@ -1607,7 +1607,7 @@ void dict_table_move_from_non_lru_to_lru( /*================================*/ dict_table_t* table) /*!< in: table to move from non-LRU to LRU */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Move to the most recently used segment of the LRU list. */ UNIV_INTERN @@ -1615,7 +1615,7 @@ void dict_move_to_mru( /*=============*/ dict_table_t* table) /*!< in: table to move to MRU */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Maximum number of columns in a foreign key constraint. Please Note MySQL has a much lower limit on the number of columns allowed in a foreign key @@ -1739,7 +1739,7 @@ dict_table_schema_check( != DB_TABLE_NOT_FOUND is returned */ size_t errstr_sz) /*!< in: errstr size */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /* @} */ /*********************************************************************//** @@ -1757,7 +1757,7 @@ dict_fs2utf8( size_t db_utf8_size, /*!< in: dbname_utf8 size */ char* table_utf8, /*!< out: table name, e.g. aюbØc */ size_t table_utf8_size)/*!< in: table_utf8 size */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Closes the data dictionary module. */ @@ -1774,7 +1774,7 @@ ulint dict_table_is_corrupted( /*====================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Check whether the index is corrupted. @@ -1784,7 +1784,7 @@ ulint dict_index_is_corrupted( /*====================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -1797,7 +1797,7 @@ dict_set_corrupted( dict_index_t* index, /*!< in/out: index */ trx_t* trx, /*!< in/out: transaction */ const char* ctx) /*!< in: context */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Flags an index corrupted in the data dictionary cache only. This @@ -1809,7 +1809,7 @@ dict_set_corrupted_index_cache_only( /*================================*/ dict_index_t* index, /*!< in/out: index */ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Flags a table with specified space_id corrupted in the table dictionary @@ -1829,7 +1829,7 @@ bool dict_tf_is_valid( /*=============*/ ulint flags) /*!< in: table flags */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /********************************************************************//** Check if the tablespace for the table has been discarded. @@ -1839,7 +1839,7 @@ bool dict_table_is_discarded( /*====================*/ const dict_table_t* table) /*!< in: table to check */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************//** Check if it is a temporary table. @@ -1849,7 +1849,7 @@ bool dict_table_is_temporary( /*====================*/ const dict_table_t* table) /*!< in: table to check */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #ifndef UNIV_HOTBACKUP /*********************************************************************//** @@ -1860,7 +1860,7 @@ void dict_index_zip_success( /*===================*/ dict_index_t* index) /*!< in/out: index to be updated. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** This function should be called whenever a page compression attempt fails. Updates the compression padding information. */ @@ -1869,7 +1869,7 @@ void dict_index_zip_failure( /*===================*/ dict_index_t* index) /*!< in/out: index to be updated. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Return the optimal page size, for which page will likely compress. @return page size beyond which page may not compress*/ @@ -1879,7 +1879,7 @@ dict_index_zip_pad_optimal_page_size( /*=================================*/ dict_index_t* index) /*!< in: index for which page size is requested */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Convert table flag to row format string. @return row format name */ diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic index 2f9fc3bcfe6..d9d40b809d1 100644 --- a/storage/xtradb/include/dict0dict.ic +++ b/storage/xtradb/include/dict0dict.ic @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2015, MariaDB +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB 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 @@ -81,7 +81,8 @@ dict_col_copy_type( const dict_col_t* col, /*!< in: column */ dtype_t* type) /*!< out: data type */ { - ut_ad(col && type); + ut_ad(col != NULL); + ut_ad(type != NULL); type->mtype = col->mtype; type->prtype = col->prtype; @@ -358,7 +359,7 @@ UNIV_INLINE ulint dict_table_get_n_sys_cols( /*======================*/ - const dict_table_t* table __attribute__((unused))) /*!< in: table */ + const dict_table_t* table MY_ATTRIBUTE((unused))) /*!< in: table */ { ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); diff --git a/storage/xtradb/include/dict0load.h b/storage/xtradb/include/dict0load.h index 030190b1a8e..dcbc3de8e94 100644 --- a/storage/xtradb/include/dict0load.h +++ b/storage/xtradb/include/dict0load.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -243,7 +243,7 @@ dict_load_foreigns( bool check_charsets, /*!< in: whether to check charset compatibility */ dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); /********************************************************************//** Prints to the standard output information on all tables found in the data dictionary system table. */ diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index a55d5316969..24219ac8799 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2016, MariaDB Corporation. @@ -199,19 +199,19 @@ DEFAULT=0, ON = 1, OFF = 2 /** Bit mask of the COMPACT field */ #define DICT_TF_MASK_COMPACT \ - ((~(~0 << DICT_TF_WIDTH_COMPACT)) \ + ((~(~0U << DICT_TF_WIDTH_COMPACT)) \ << DICT_TF_POS_COMPACT) /** Bit mask of the ZIP_SSIZE field */ #define DICT_TF_MASK_ZIP_SSIZE \ - ((~(~0 << DICT_TF_WIDTH_ZIP_SSIZE)) \ + ((~(~0U << DICT_TF_WIDTH_ZIP_SSIZE)) \ << DICT_TF_POS_ZIP_SSIZE) /** Bit mask of the ATOMIC_BLOBS field */ #define DICT_TF_MASK_ATOMIC_BLOBS \ - ((~(~0 << DICT_TF_WIDTH_ATOMIC_BLOBS)) \ + ((~(~0U << DICT_TF_WIDTH_ATOMIC_BLOBS)) \ << DICT_TF_POS_ATOMIC_BLOBS) /** Bit mask of the DATA_DIR field */ #define DICT_TF_MASK_DATA_DIR \ - ((~(~0 << DICT_TF_WIDTH_DATA_DIR)) \ + ((~(~0U << DICT_TF_WIDTH_DATA_DIR)) \ << DICT_TF_POS_DATA_DIR) /** Bit mask of the PAGE_COMPRESSION field */ #define DICT_TF_MASK_PAGE_COMPRESSION \ @@ -246,7 +246,7 @@ DEFAULT=0, ON = 1, OFF = 2 #define DICT_TF_HAS_ATOMIC_BLOBS(flags) \ ((flags & DICT_TF_MASK_ATOMIC_BLOBS) \ >> DICT_TF_POS_ATOMIC_BLOBS) -/** Return the value of the ATOMIC_BLOBS field */ +/** Return the value of the DATA_DIR field */ #define DICT_TF_HAS_DATA_DIR(flags) \ ((flags & DICT_TF_MASK_DATA_DIR) \ >> DICT_TF_POS_DATA_DIR) @@ -291,7 +291,7 @@ for unknown bits in order to protect backward incompatibility. */ /* @{ */ /** Total number of bits in table->flags2. */ #define DICT_TF2_BITS 7 -#define DICT_TF2_BIT_MASK ~(~0 << DICT_TF2_BITS) +#define DICT_TF2_BIT_MASK ~(~0U << DICT_TF2_BITS) /** TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE. */ #define DICT_TF2_TEMPORARY 1 @@ -379,7 +379,7 @@ dict_mem_table_add_col( ulint mtype, /*!< in: main datatype */ ulint prtype, /*!< in: precise type */ ulint len) /*!< in: precision */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /**********************************************************************//** Renames a column of a table in the data dictionary cache. */ UNIV_INTERN @@ -390,7 +390,7 @@ dict_mem_table_col_rename( unsigned nth_col,/*!< in: column index */ const char* from, /*!< in: old column name */ const char* to) /*!< in: new column name */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** This function populates a dict_col_t memory structure with supplied information. */ diff --git a/storage/xtradb/include/dict0stats.h b/storage/xtradb/include/dict0stats.h index abf56b2f0c7..72501bf9429 100644 --- a/storage/xtradb/include/dict0stats.h +++ b/storage/xtradb/include/dict0stats.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2009, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2009, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -77,7 +77,7 @@ dict_stats_set_persistent( dict_table_t* table, /*!< in/out: table */ ibool ps_on, /*!< in: persistent stats explicitly enabled */ ibool ps_off) /*!< in: persistent stats explicitly disabled */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Check whether persistent statistics is enabled for a given table. @@ -87,7 +87,7 @@ ibool dict_stats_is_persistent_enabled( /*=============================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Set the auto recalc flag for a given table (only honored for a persistent @@ -127,7 +127,7 @@ void dict_stats_deinit( /*==============*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Calculates new estimates for table and index statistics. The statistics @@ -179,7 +179,7 @@ void dict_stats_update_for_index( /*========================*/ dict_index_t* index) /*!< in/out: index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Renames a table in InnoDB persistent stats storage. diff --git a/storage/xtradb/include/dict0stats_bg.h b/storage/xtradb/include/dict0stats_bg.h index 32fac3015e8..34dc4657829 100644 --- a/storage/xtradb/include/dict0stats_bg.h +++ b/storage/xtradb/include/dict0stats_bg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,7 +96,7 @@ bool dict_stats_stop_bg( /*===============*/ dict_table_t* table) /*!< in/out: table */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*****************************************************************//** Wait until background stats thread has stopped using the specified table. diff --git a/storage/xtradb/include/dyn0dyn.h b/storage/xtradb/include/dyn0dyn.h index 7f23302d1ff..1bd10b6bf58 100644 --- a/storage/xtradb/include/dyn0dyn.h +++ b/storage/xtradb/include/dyn0dyn.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -48,7 +48,7 @@ dyn_array_create( /*=============*/ dyn_array_t* arr) /*!< in/out memory buffer of size sizeof(dyn_array_t) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Frees a dynamic array. */ UNIV_INLINE @@ -56,7 +56,7 @@ void dyn_array_free( /*===========*/ dyn_array_t* arr) /*!< in,own: dyn array */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Makes room on top of a dyn array and returns a pointer to a buffer in it. After copying the elements, the caller must close the buffer using @@ -69,7 +69,7 @@ dyn_array_open( dyn_array_t* arr, /*!< in: dynamic array */ ulint size) /*!< in: size in bytes of the buffer; MUST be smaller than DYN_ARRAY_DATA_SIZE! */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Closes the buffer returned by dyn_array_open. */ UNIV_INLINE @@ -78,7 +78,7 @@ dyn_array_close( /*============*/ dyn_array_t* arr, /*!< in: dynamic array */ const byte* ptr) /*!< in: end of used space */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Makes room on top of a dyn array and returns a pointer to the added element. The caller must copy the element to @@ -90,7 +90,7 @@ dyn_array_push( /*===========*/ dyn_array_t* arr, /*!< in/out: dynamic array */ ulint size) /*!< in: size in bytes of the element */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Returns pointer to an element in dyn array. @return pointer to element */ @@ -101,7 +101,7 @@ dyn_array_get_element( const dyn_array_t* arr, /*!< in: dyn array */ ulint pos) /*!< in: position of element in bytes from array start */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Returns the size of stored data in a dyn array. @return data size in bytes */ @@ -110,7 +110,7 @@ ulint dyn_array_get_data_size( /*====================*/ const dyn_array_t* arr) /*!< in: dyn array */ - __attribute__((nonnull, warn_unused_result, pure)); + MY_ATTRIBUTE((nonnull, warn_unused_result, pure)); /************************************************************//** Gets the first block in a dyn array. @param arr dyn array @@ -144,7 +144,7 @@ ulint dyn_block_get_used( /*===============*/ const dyn_block_t* block) /*!< in: dyn array block */ - __attribute__((nonnull, warn_unused_result, pure)); + MY_ATTRIBUTE((nonnull, warn_unused_result, pure)); /********************************************************************//** Gets pointer to the start of data in a dyn array block. @return pointer to data */ @@ -153,7 +153,7 @@ byte* dyn_block_get_data( /*===============*/ const dyn_block_t* block) /*!< in: dyn array block */ - __attribute__((nonnull, warn_unused_result, pure)); + MY_ATTRIBUTE((nonnull, warn_unused_result, pure)); /********************************************************//** Pushes n bytes to a dyn array. */ UNIV_INLINE @@ -163,7 +163,7 @@ dyn_push_string( dyn_array_t* arr, /*!< in/out: dyn array */ const byte* str, /*!< in: string to write */ ulint len) /*!< in: string length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*#################################################################*/ diff --git a/storage/xtradb/include/dyn0dyn.ic b/storage/xtradb/include/dyn0dyn.ic index 0296554e2ee..f18f2e6dff9 100644 --- a/storage/xtradb/include/dyn0dyn.ic +++ b/storage/xtradb/include/dyn0dyn.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -36,7 +36,7 @@ dyn_block_t* dyn_array_add_block( /*================*/ dyn_array_t* arr) /*!< in/out: dyn array */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Gets the number of used bytes in a dyn array block. diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 973882a50b4..20e8303f764 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -436,7 +436,7 @@ fil_node_create( ulint id, /*!< in: space id where to append */ ibool is_raw) /*!< in: TRUE if a raw device or a raw disk partition */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifdef UNIV_LOG_ARCHIVE /****************************************************************//** Drops files from the start of a file space, so that its size is cut by @@ -697,7 +697,7 @@ dberr_t fil_discard_tablespace( /*===================*/ ulint id) /*!< in: space id */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /** Test if a tablespace file can be renamed to a new filepath by checking @@ -1212,7 +1212,7 @@ fil_tablespace_iterate( dict_table_t* table, ulint n_io_buffers, PageCallback& callback) - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Checks if a single-table tablespace for a given table name exists in the @@ -1236,7 +1236,7 @@ fil_get_space_names( /*================*/ space_name_list_t& space_name_list) /*!< in/out: Vector for collecting the names. */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /** Generate redo log for swapping two .ibd files @param[in] old_table old table @@ -1251,7 +1251,7 @@ fil_mtr_rename_log( const dict_table_t* new_table, const char* tmp_name, mtr_t* mtr) - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Finds the given page_no of the given space id from the double write buffer, @@ -1265,6 +1265,14 @@ fil_user_tablespace_restore_page( ulint page_no); /* in: page_no to obtain from double write buffer */ +/*******************************************************************//** +Returns a pointer to the file_space_t that is in the memory cache +associated with a space id. +@return file_space_t pointer, NULL if space not found */ +fil_space_t* +fil_space_get( +/*==========*/ + ulint id); /*!< in: space id */ #endif /* !UNIV_INNOCHECKSUM */ /************************************************************************* @@ -1281,11 +1289,6 @@ fil_system_hash_nodes(void); /************************************************************************* functions to access is_corrupt flag of fil_space_t*/ -ibool -fil_space_is_corrupt( -/*=================*/ - ulint space_id); - void fil_space_set_corrupt( /*==================*/ diff --git a/storage/xtradb/include/fsp0fsp.h b/storage/xtradb/include/fsp0fsp.h index 839aed80418..9212328f724 100644 --- a/storage/xtradb/include/fsp0fsp.h +++ b/storage/xtradb/include/fsp0fsp.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under @@ -108,23 +108,23 @@ dictionary */ /** Bit mask of the POST_ANTELOPE field */ #define FSP_FLAGS_MASK_POST_ANTELOPE \ - ((~(~0 << FSP_FLAGS_WIDTH_POST_ANTELOPE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_POST_ANTELOPE)) \ << FSP_FLAGS_POS_POST_ANTELOPE) /** Bit mask of the ZIP_SSIZE field */ #define FSP_FLAGS_MASK_ZIP_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_ZIP_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_ZIP_SSIZE)) \ << FSP_FLAGS_POS_ZIP_SSIZE) /** Bit mask of the ATOMIC_BLOBS field */ #define FSP_FLAGS_MASK_ATOMIC_BLOBS \ - ((~(~0 << FSP_FLAGS_WIDTH_ATOMIC_BLOBS)) \ + ((~(~0U << FSP_FLAGS_WIDTH_ATOMIC_BLOBS)) \ << FSP_FLAGS_POS_ATOMIC_BLOBS) /** Bit mask of the PAGE_SSIZE field */ #define FSP_FLAGS_MASK_PAGE_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ << FSP_FLAGS_POS_PAGE_SSIZE) /** Bit mask of the DATA_DIR field */ #define FSP_FLAGS_MASK_DATA_DIR \ - ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \ + ((~(~0U << FSP_FLAGS_WIDTH_DATA_DIR)) \ << FSP_FLAGS_POS_DATA_DIR) /** Bit mask of the DATA_DIR field */ #define FSP_FLAGS_MASK_DATA_DIR_ORACLE \ @@ -581,7 +581,7 @@ fseg_alloc_free_page_general( in which the page should be initialized. If init_mtr!=mtr, but the page is already latched in mtr, do not initialize the page. */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /**********************************************************************//** Reserves free pages from a tablespace. All mini-transactions which may use several pages from the tablespace should call this function beforehand @@ -650,7 +650,7 @@ fseg_page_is_free( fseg_header_t* seg_header, /*!< in: segment header */ ulint space, /*!< in: space id */ ulint page) /*!< in: page offset */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************************//** Frees part of a segment. This function can be used to free a segment by repeatedly calling this function in different mini-transactions. @@ -746,7 +746,7 @@ bool fsp_flags_is_valid( /*===============*/ ulint flags) /*!< in: tablespace flags */ - __attribute__((warn_unused_result, const)); + MY_ATTRIBUTE((warn_unused_result, const)); /********************************************************************//** Determine if the tablespace is compressed from dict_table_t::flags. @return TRUE if compressed, FALSE if not compressed */ diff --git a/storage/xtradb/include/fts0ast.h b/storage/xtradb/include/fts0ast.h index b2380f78b39..50f62063893 100644 --- a/storage/xtradb/include/fts0ast.h +++ b/storage/xtradb/include/fts0ast.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -200,7 +200,7 @@ fts_ast_visit( and ignored processing an operator, currently we only ignore FTS_IGNORE operator */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Process (nested) sub-expression, create a new result set to store the sub-expression result by processing nodes under current sub-expression @@ -213,7 +213,7 @@ fts_ast_visit_sub_exp( fts_ast_node_t* node, /*!< in: instance to traverse*/ fts_ast_callback visitor, /*!< in: callback */ void* arg) /*!< in: callback arg */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************** Create a lex instance.*/ UNIV_INTERN @@ -223,7 +223,7 @@ fts_lexer_create( ibool boolean_mode, /*!< in: query type */ const byte* query, /*!< in: query string */ ulint query_len) /*!< in: query string len */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /******************************************************************** Free an fts_lexer_t instance.*/ UNIV_INTERN @@ -232,7 +232,7 @@ fts_lexer_free( /*===========*/ fts_lexer_t* fts_lexer) /*!< in: lexer instance to free */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Create an ast string object, with NUL-terminator, so the string diff --git a/storage/xtradb/include/fts0fts.h b/storage/xtradb/include/fts0fts.h index d54ed281d9a..68d4d333245 100644 --- a/storage/xtradb/include/fts0fts.h +++ b/storage/xtradb/include/fts0fts.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -94,7 +94,10 @@ those defined in mysql file ft_global.h */ /** Threshold where our optimize thread automatically kicks in */ #define FTS_OPTIMIZE_THRESHOLD 10000000 -#define FTS_DOC_ID_MAX_STEP 10000 +/** Threshold to avoid exhausting of doc ids. Consecutive doc id difference +should not exceed FTS_DOC_ID_MAX_STEP */ +#define FTS_DOC_ID_MAX_STEP 65535 + /** Variable specifying the FTS parallel sort degree */ extern ulong fts_sort_pll_degree; @@ -408,7 +411,7 @@ fts_get_next_doc_id( /*================*/ const dict_table_t* table, /*!< in: table */ doc_id_t* doc_id) /*!< out: new document id */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Update the next and last Doc ID in the CONFIG table to be the input "doc_id" value (+ 1). We would do so after each FTS index build or @@ -421,7 +424,7 @@ fts_update_next_doc_id( const dict_table_t* table, /*!< in: table */ const char* table_name, /*!< in: table name, or NULL */ doc_id_t doc_id) /*!< in: DOC ID to set */ - __attribute__((nonnull(2))); + MY_ATTRIBUTE((nonnull(2))); /******************************************************************//** Create a new document id . @@ -437,7 +440,7 @@ fts_create_doc_id( current row that is being inserted. */ mem_heap_t* heap) /*!< in: heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Create a new fts_doc_ids_t. @return new fts_doc_ids_t. */ @@ -466,7 +469,7 @@ fts_trx_add_op( fts_row_state state, /*!< in: state of the row */ ib_vector_t* fts_indexes) /*!< in: FTS indexes affected (NULL=all) */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /******************************************************************//** Free an FTS trx. */ @@ -491,7 +494,7 @@ fts_create_common_tables( index */ const char* name, /*!< in: table name */ bool skip_doc_id_index) /*!< in: Skip index on doc id */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Wrapper function of fts_create_index_tables_low(), create auxiliary tables for an FTS index @@ -503,7 +506,7 @@ fts_create_index_tables( trx_t* trx, /*!< in: transaction handle */ const dict_index_t* index) /*!< in: the FTS index instance */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Creates the column specific ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have @@ -519,7 +522,7 @@ fts_create_index_tables_low( instance */ const char* table_name, /*!< in: the table name */ table_id_t table_id) /*!< in: the table id */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Add the FTS document id hidden column. */ UNIV_INTERN @@ -528,7 +531,7 @@ fts_add_doc_id_column( /*==================*/ dict_table_t* table, /*!< in/out: Table with FTS index */ mem_heap_t* heap) /*!< in: temporary memory heap, or NULL */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*********************************************************************//** Drops the ancillary tables needed for supporting an FTS index on the @@ -542,7 +545,7 @@ fts_drop_tables( trx_t* trx, /*!< in: transaction */ dict_table_t* table) /*!< in: table has the FTS index */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @@ -552,7 +555,7 @@ dberr_t fts_commit( /*=======*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** FTS Query entry point. @@ -569,7 +572,7 @@ fts_query( in bytes */ fts_result_t** result) /*!< out: query result, to be freed by the caller.*/ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Retrieve the FTS Relevance Ranking result for doc with doc_id @@ -687,7 +690,7 @@ dberr_t fts_optimize_table( /*===============*/ dict_table_t* table) /*!< in: table to optimiza */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Startup the optimize thread and create the work queue. */ @@ -713,7 +716,7 @@ fts_drop_index_tables( /*==================*/ trx_t* trx, /*!< in: transaction */ dict_index_t* index) /*!< in: Index to drop */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Remove the table from the OPTIMIZER's list. We do wait for @@ -724,6 +727,13 @@ fts_optimize_remove_table( /*======================*/ dict_table_t* table); /*!< in: table to remove */ +/** Send sync fts cache for the table. +@param[in] table table to sync */ +UNIV_INTERN +void +fts_optimize_request_sync_table( + dict_table_t* table); + /**********************************************************************//** Signal the optimize thread to prepare for shutdown. */ UNIV_INTERN @@ -747,7 +757,7 @@ fts_savepoint_take( trx_t* trx, /*!< in: transaction */ fts_trx_t* fts_trx, /*!< in: fts transaction */ const char* name) /*!< in: savepoint name */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Refresh last statement savepoint. */ UNIV_INTERN @@ -755,7 +765,7 @@ void fts_savepoint_laststmt_refresh( /*===========================*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Release the savepoint data identified by name. */ UNIV_INTERN @@ -773,13 +783,12 @@ fts_cache_destroy( /*==============*/ fts_cache_t* cache); /*!< in: cache*/ -/*********************************************************************//** -Clear cache. */ +/** Clear cache. +@param[in,out] cache fts cache */ UNIV_INTERN void fts_cache_clear( -/*============*/ - fts_cache_t* cache); /*!< in: cache */ + fts_cache_t* cache); /*********************************************************************//** Initialize things in cache. */ @@ -824,17 +833,20 @@ fts_drop_index_split_tables( /*========================*/ trx_t* trx, /*!< in: transaction */ dict_index_t* index) /*!< in: fts instance */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the -FTS auxiliary INDEX table and clear the cache at the end. */ +/** Run SYNC on the table, i.e., write out data from the cache to the +FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] table fts table +@param[in] unlock_cache whether unlock cache when write node +@param[in] wait whether wait for existing sync to finish +@return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( -/*===========*/ - dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + dict_table_t* table, + bool unlock_cache, + bool wait); /****************************************************************//** Free the query graph but check whether dict_sys->mutex is already @@ -1013,7 +1025,7 @@ fts_drop_index( dict_table_t* table, /*!< in: Table where indexes are dropped */ dict_index_t* index, /*!< in: Index to be dropped */ trx_t* trx) /*!< in: Transaction for the drop */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Rename auxiliary tables for all fts index for a table diff --git a/storage/xtradb/include/fts0priv.h b/storage/xtradb/include/fts0priv.h index b4d9e1d41ec..2d4e9d88fd1 100644 --- a/storage/xtradb/include/fts0priv.h +++ b/storage/xtradb/include/fts0priv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -121,7 +121,7 @@ fts_parse_sql( fts_table_t* fts_table, /*!< in: FTS aux table */ pars_info_t* info, /*!< in: info struct, or NULL */ const char* sql) /*!< in: SQL string to evaluate */ - __attribute__((nonnull(3), malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull(3), malloc, warn_unused_result)); /******************************************************************//** Evaluate a parsed SQL statement @return DB_SUCCESS or error code */ @@ -131,7 +131,7 @@ fts_eval_sql( /*=========*/ trx_t* trx, /*!< in: transaction */ que_t* graph) /*!< in: Parsed statement */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Construct the name of an ancillary FTS table for the given table. @return own: table name, must be freed with mem_free() */ @@ -141,7 +141,7 @@ fts_get_table_name( /*===============*/ const fts_table_t* fts_table) /*!< in: FTS aux table info */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /******************************************************************//** Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table. Adds the necessary bound @@ -164,7 +164,7 @@ fts_get_select_columns_str( dict_index_t* index, /*!< in: FTS index */ pars_info_t* info, /*!< in/out: parser info */ mem_heap_t* heap) /*!< in: memory heap */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** define for fts_doc_fetch_by_doc_id() "option" value, defines whether we want to get Doc whose ID is equal to or greater or smaller than supplied @@ -191,7 +191,7 @@ fts_doc_fetch_by_doc_id( callback, /*!< in: callback to read records */ void* arg) /*!< in: callback arg */ - __attribute__((nonnull(6))); + MY_ATTRIBUTE((nonnull(6))); /*******************************************************************//** Callback function for fetch that stores the text of an FTS document, @@ -203,7 +203,7 @@ fts_query_expansion_fetch_doc( /*==========================*/ void* row, /*!< in: sel_node_t* */ void* user_arg) /*!< in: fts_doc_t* */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************** Write out a single word's data as new entry/entries in the INDEX table. @return DB_SUCCESS if all OK. */ @@ -216,7 +216,7 @@ fts_write_node( fts_table_t* fts_table, /*!< in: the FTS aux index */ fts_string_t* word, /*!< in: word in UTF-8 */ fts_node_t* node) /*!< in: node columns */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Tokenize a document. */ UNIV_INTERN @@ -227,7 +227,7 @@ fts_tokenize_document( tokenize */ fts_doc_t* result) /*!< out: if provided, save result tokens here */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*******************************************************************//** Continue to tokenize a document. */ @@ -241,7 +241,7 @@ fts_tokenize_document_next( tokens from this tokenization */ fts_doc_t* result) /*!< out: if provided, save result tokens here */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /******************************************************************//** Initialize a document. */ UNIV_INTERN @@ -249,7 +249,7 @@ void fts_doc_init( /*=========*/ fts_doc_t* doc) /*!< in: doc to initialize */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Do a binary search for a doc id in the array @@ -263,7 +263,7 @@ fts_bsearch( int lower, /*!< in: lower bound of array*/ int upper, /*!< in: upper bound of array*/ doc_id_t doc_id) /*!< in: doc id to lookup */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Free document. */ UNIV_INTERN @@ -271,7 +271,7 @@ void fts_doc_free( /*=========*/ fts_doc_t* doc) /*!< in: document */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Free fts_optimizer_word_t instanace.*/ UNIV_INTERN @@ -279,7 +279,7 @@ void fts_word_free( /*==========*/ fts_word_t* word) /*!< in: instance to free.*/ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Read the rows from the FTS inde @return DB_SUCCESS or error code */ @@ -293,7 +293,7 @@ fts_index_fetch_nodes( const fts_string_t* word, /*!< in: the word to fetch */ fts_fetch_t* fetch) /*!< in: fetch callback.*/ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Create a fts_optimizer_word_t instance. @return new instance */ @@ -304,7 +304,7 @@ fts_word_init( fts_word_t* word, /*!< in: word to initialize */ byte* utf8, /*!< in: UTF-8 string */ ulint len) /*!< in: length of string in bytes */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Compare two fts_trx_table_t instances, we actually compare the table id's here. @@ -315,7 +315,7 @@ fts_trx_table_cmp( /*==============*/ const void* v1, /*!< in: id1 */ const void* v2) /*!< in: id2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Compare a table id with a trx_table_t table id. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ @@ -325,7 +325,7 @@ fts_trx_table_id_cmp( /*=================*/ const void* p1, /*!< in: id1 */ const void* p2) /*!< in: id2 */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Commit a transaction. @return DB_SUCCESS if all OK */ @@ -334,7 +334,7 @@ dberr_t fts_sql_commit( /*===========*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Rollback a transaction. @return DB_SUCCESS if all OK */ @@ -343,7 +343,7 @@ dberr_t fts_sql_rollback( /*=============*/ trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Parse an SQL string. %s is replaced with the table's id. Don't acquire the dict mutex @@ -355,7 +355,7 @@ fts_parse_sql_no_dict_lock( fts_table_t* fts_table, /*!< in: table with FTS index */ pars_info_t* info, /*!< in: parser info */ const char* sql) /*!< in: SQL string to evaluate */ - __attribute__((nonnull(3), malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull(3), malloc, warn_unused_result)); /******************************************************************//** Get value from config table. The caller must ensure that enough space is allocated for value to hold the column contents @@ -370,7 +370,7 @@ fts_config_get_value( this parameter name */ fts_string_t* value) /*!< out: value read from config table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Get value specific to an FTS index from the config table. The caller must ensure that enough space is allocated for value to hold the @@ -386,7 +386,7 @@ fts_config_get_index_value( this parameter name */ fts_string_t* value) /*!< out: value read from config table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Set the value in the config table for name. @return DB_SUCCESS or error code */ @@ -400,7 +400,7 @@ fts_config_set_value( this parameter name */ const fts_string_t* value) /*!< in: value to update */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Set an ulint value in the config table. @return DB_SUCCESS if all OK else error code */ @@ -412,7 +412,7 @@ fts_config_set_ulint( fts_table_t* fts_table, /*!< in: the indexed FTS table */ const char* name, /*!< in: param name */ ulint int_value) /*!< in: value */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Set the value specific to an FTS index in the config table. @return DB_SUCCESS or error code */ @@ -426,7 +426,7 @@ fts_config_set_index_value( this parameter name */ fts_string_t* value) /*!< out: value read from config table */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Increment the value in the config table for column name. @return DB_SUCCESS or error code */ @@ -439,7 +439,7 @@ fts_config_increment_value( const char* name, /*!< in: increment config value for this parameter name */ ulint delta) /*!< in: increment by this much */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Increment the per index value in the config table for column name. @return DB_SUCCESS or error code */ @@ -452,7 +452,7 @@ fts_config_increment_index_value( const char* name, /*!< in: increment config value for this parameter name */ ulint delta) /*!< in: increment by this much */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Get an ulint value from the config table. @return DB_SUCCESS or error code */ @@ -464,7 +464,7 @@ fts_config_get_index_ulint( dict_index_t* index, /*!< in: FTS index */ const char* name, /*!< in: param name */ ulint* int_value) /*!< out: value */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Set an ulint value int the config table. @return DB_SUCCESS or error code */ @@ -476,7 +476,7 @@ fts_config_set_index_ulint( dict_index_t* index, /*!< in: FTS index */ const char* name, /*!< in: param name */ ulint int_value) /*!< in: value */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Get an ulint value from the config table. @return DB_SUCCESS or error code */ @@ -488,7 +488,7 @@ fts_config_get_ulint( fts_table_t* fts_table, /*!< in: the indexed FTS table */ const char* name, /*!< in: param name */ ulint* int_value) /*!< out: value */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Search cache for word. @return the word node vector if found else NULL */ @@ -500,7 +500,7 @@ fts_cache_find_word( index_cache, /*!< in: cache to search */ const fts_string_t* text) /*!< in: word to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Check cache for deleted doc id. @return TRUE if deleted */ @@ -511,7 +511,7 @@ fts_cache_is_deleted_doc_id( const fts_cache_t* cache, /*!< in: cache ito search */ doc_id_t doc_id) /*!< in: doc id to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Append deleted doc ids to vector and sort the vector. */ UNIV_INTERN @@ -546,7 +546,7 @@ fts_get_total_word_count( trx_t* trx, /*!< in: transaction */ dict_index_t* index, /*!< in: for this index */ ulint* total) /*!< out: total words */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /******************************************************************//** Search the index specific cache for a particular FTS index. @@ -559,7 +559,7 @@ fts_find_index_cache( cache, /*!< in: cache to search */ const dict_index_t* index) /*!< in: index to search for */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Write the table id to the given buffer (including final NUL). Buffer must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long. @@ -570,10 +570,10 @@ fts_write_object_id( /*================*/ ib_id_t id, /*!< in: a table/index id */ char* str, /*!< in: buffer to write the id to */ - bool hex_format __attribute__((unused))) + bool hex_format MY_ATTRIBUTE((unused))) /*!< in: true for fixed hex format, false for old ambiguous format */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Read the table id from the string generated by fts_write_object_id(). @return TRUE if parse successful */ @@ -583,7 +583,7 @@ fts_read_object_id( /*===============*/ ib_id_t* id, /*!< out: a table id */ const char* str) /*!< in: buffer to read from */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Get the table id. @return number of bytes written */ @@ -596,7 +596,7 @@ fts_get_table_id( char* table_id) /*!< out: table id, must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Add the table to add to the OPTIMIZER's list. */ UNIV_INTERN @@ -604,7 +604,7 @@ void fts_optimize_add_table( /*===================*/ dict_table_t* table) /*!< in: table to add */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Optimize a table. */ UNIV_INTERN @@ -612,7 +612,7 @@ void fts_optimize_do_table( /*==================*/ dict_table_t* table) /*!< in: table to optimize */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Construct the prefix name of an FTS table. @return own: table name, must be freed with mem_free() */ @@ -622,7 +622,7 @@ fts_get_table_name_prefix( /*======================*/ const fts_table_t* fts_table) /*!< in: Auxiliary table type */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); /******************************************************************//** Add node positions. */ UNIV_INTERN @@ -633,7 +633,7 @@ fts_cache_node_add_positions( fts_node_t* node, /*!< in: word node */ doc_id_t doc_id, /*!< in: doc id */ ib_vector_t* positions) /*!< in: fts_token_t::positions */ - __attribute__((nonnull(2,4))); + MY_ATTRIBUTE((nonnull(2,4))); /******************************************************************//** Create the config table name for retrieving index specific value. @@ -644,7 +644,7 @@ fts_config_create_index_param_name( /*===============================*/ const char* param, /*!< in: base name of param */ const dict_index_t* index) /*!< in: index for config */ - __attribute__((nonnull, malloc, warn_unused_result)); + MY_ATTRIBUTE((nonnull, malloc, warn_unused_result)); #ifndef UNIV_NONINL #include "fts0priv.ic" diff --git a/storage/xtradb/include/fts0priv.ic b/storage/xtradb/include/fts0priv.ic index ec61691870b..88f2d67c7b8 100644 --- a/storage/xtradb/include/fts0priv.ic +++ b/storage/xtradb/include/fts0priv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -33,7 +33,7 @@ fts_write_object_id( /*================*/ ib_id_t id, /* in: a table/index id */ char* str, /* in: buffer to write the id to */ - bool hex_format __attribute__((unused))) + bool hex_format MY_ATTRIBUTE((unused))) /* in: true for fixed hex format, false for old ambiguous format */ { diff --git a/storage/xtradb/include/fts0types.h b/storage/xtradb/include/fts0types.h index 64677428331..e495fe72a60 100644 --- a/storage/xtradb/include/fts0types.h +++ b/storage/xtradb/include/fts0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -122,7 +122,11 @@ struct fts_sync_t { doc_id_t max_doc_id; /*!< The doc id at which the cache was noted as being full, we use this to set the upper_limit field */ - ib_time_t start_time; /*!< SYNC start time */ + ib_time_t start_time; /*!< SYNC start time */ + bool in_progress; /*!< flag whether sync is in progress.*/ + bool unlock_cache; /*!< flag whether unlock cache when + write fts node */ + os_event_t event; /*!< sync finish event */ }; /** The cache for the FTS system. It is a memory-based inverted index @@ -165,7 +169,6 @@ struct fts_cache_t { objects, they are recreated after a SYNC is completed */ - ib_alloc_t* self_heap; /*!< This heap is the heap out of which an instance of the cache itself was created. Objects created using @@ -212,6 +215,7 @@ struct fts_node_t { ulint ilist_size_alloc; /*!< Allocated size of ilist in bytes */ + bool synced; /*!< flag whether the node is synced */ }; /** A tokenizer word. Contains information about one word. */ diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h index 212a47a7a9b..dbb23d81eec 100644 --- a/storage/xtradb/include/ha_prototypes.h +++ b/storage/xtradb/include/ha_prototypes.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -143,7 +143,7 @@ enum durability_properties thd_requested_durability( /*=====================*/ const THD* thd) /*!< in: thread handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Returns true if the transaction this thread is processing has edited @@ -195,7 +195,7 @@ innobase_mysql_cmp( const unsigned char* b, /*!< in: data field */ unsigned int b_length) /*!< in: data field length, not UNIV_SQL_NULL */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**************************************************************//** Converts a MySQL type to an InnoDB type. Note that this function returns the 'mtype' of InnoDB. InnoDB differentiates between MySQL's old <= 4.1 @@ -211,7 +211,7 @@ get_innobase_type_from_mysql_type( and unsigned integer types are 'unsigned types' */ const void* field) /*!< in: MySQL Field */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Get the variable length bounds of the given character set. */ @@ -295,8 +295,10 @@ innobase_casedn_str( #ifdef WITH_WSREP UNIV_INTERN int -wsrep_innobase_kill_one_trx(void *thd_ptr, - const trx_t *bf_trx, trx_t *victim_trx, ibool signal); +wsrep_innobase_kill_one_trx(void * const thd_ptr, + const trx_t * const bf_trx, + trx_t *victim_trx, + ibool signal); int wsrep_innobase_mysql_sort(int mysql_type, uint charset_number, unsigned char* str, unsigned int str_length, unsigned int buf_length); @@ -318,7 +320,7 @@ innobase_get_stmt( /*==============*/ THD* thd, /*!< in: MySQL thread handle */ size_t* length) /*!< out: length of the SQL statement */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** This function is used to find the storage length in bytes of the first n characters for prefix indexes using a multibyte character set. The function @@ -344,7 +346,7 @@ enum icp_result innobase_index_cond( /*================*/ void* file) /*!< in/out: pointer to ha_innobase */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Returns true if the thread supports XA, global value of innodb_supports_xa if thd is NULL. @@ -497,7 +499,7 @@ innobase_format_name( const char* name, /*!< in: index or table name to format */ ibool is_index_name) /*!< in: index name */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Corresponds to Sql_condition:enum_warning_level. */ enum ib_log_level_t { @@ -527,7 +529,7 @@ ib_errf( ib_uint32_t code, /*!< MySQL error code */ const char* format, /*!< printf format */ ...) /*!< Args */ - __attribute__((format(printf, 4, 5))); + MY_ATTRIBUTE((format(printf, 4, 5))); /******************************************************************//** Use this when the args are passed to the format string from @@ -558,7 +560,7 @@ ib_logf( ib_log_level_t level, /*!< in: warning level */ const char* format, /*!< printf format */ ...) /*!< Args */ - __attribute__((format(printf, 2, 3))); + MY_ATTRIBUTE((format(printf, 2, 3))); /******************************************************************//** Returns the NUL terminated value of glob_hostname. @@ -604,7 +606,7 @@ innobase_next_autoinc( ulonglong step, /*!< in: AUTOINC increment step */ ulonglong offset, /*!< in: AUTOINC offset */ ulonglong max_value) /*!< in: max value for type */ - __attribute__((pure, warn_unused_result)); + MY_ATTRIBUTE((pure, warn_unused_result)); /********************************************************************//** Get the upper limit of the MySQL integral and floating-point type. @@ -614,7 +616,7 @@ ulonglong innobase_get_int_col_max_value( /*===========================*/ const Field* field) /*!< in: MySQL field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /********************************************************************** Check if the length of the identifier exceeds the maximum allowed. diff --git a/storage/xtradb/include/handler0alter.h b/storage/xtradb/include/handler0alter.h index 66b963ae39a..3dd6c99eb6d 100644 --- a/storage/xtradb/include/handler0alter.h +++ b/storage/xtradb/include/handler0alter.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -32,7 +32,7 @@ innobase_rec_to_mysql( const dict_index_t* index, /*!< in: index */ const ulint* offsets)/*!< in: rec_get_offsets( rec, index, ...) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Copies an InnoDB index entry to table->record[0]. */ @@ -43,7 +43,7 @@ innobase_fields_to_mysql( struct TABLE* table, /*!< in/out: MySQL table */ const dict_index_t* index, /*!< in: InnoDB index */ const dfield_t* fields) /*!< in: InnoDB index fields */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Copies an InnoDB row to table->record[0]. */ @@ -54,7 +54,7 @@ innobase_row_to_mysql( struct TABLE* table, /*!< in/out: MySQL table */ const dict_table_t* itab, /*!< in: InnoDB table */ const dtuple_t* row) /*!< in: InnoDB row */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Resets table->record[0]. */ @@ -63,7 +63,7 @@ void innobase_rec_reset( /*===============*/ struct TABLE* table) /*!< in/out: MySQL table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /** Generate the next autoinc based on a snapshot of the session auto_increment_increment and auto_increment_offset variables. */ diff --git a/storage/xtradb/include/ibuf0ibuf.h b/storage/xtradb/include/ibuf0ibuf.h index 3c8fa874dcf..0b325b68a84 100644 --- a/storage/xtradb/include/ibuf0ibuf.h +++ b/storage/xtradb/include/ibuf0ibuf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -120,7 +120,7 @@ void ibuf_mtr_start( /*===========*/ mtr_t* mtr) /*!< out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Commits an insert buffer mini-transaction. */ UNIV_INLINE @@ -128,7 +128,7 @@ void ibuf_mtr_commit( /*============*/ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Initializes an ibuf bitmap page. */ UNIV_INTERN @@ -254,7 +254,7 @@ ibool ibuf_inside( /*========*/ const mtr_t* mtr) /*!< in: mini-transaction */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /***********************************************************************//** Checks if a page address is an ibuf bitmap page (level 3 page) address. @return TRUE if a bitmap page */ @@ -287,7 +287,7 @@ ibuf_page_low( is not one of the fixed address ibuf pages, or NULL, in which case a new transaction is created. */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG /** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. Must not be called when recv_no_ibuf_operations==TRUE. @@ -366,23 +366,31 @@ void ibuf_delete_for_discarded_space( /*============================*/ ulint space); /*!< in: space id */ -/*********************************************************************//** -Contracts insert buffer trees by reading pages to the buffer pool. +/** Contract the change buffer by reading pages to the buffer pool. +@param[in] full If true, do a full contraction based +on PCT_IO(100). If false, the size of contract batch is determined +based on the current size of the change buffer. @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ UNIV_INTERN ulint -ibuf_contract_in_background( -/*========================*/ - table_id_t table_id, /*!< in: if merge should be done only - for a specific table, for all tables - this should be 0 */ - ibool full); /*!< in: TRUE if the caller wants to - do a full contract based on PCT_IO(100). - If FALSE then the size of contract - batch is determined based on the - current size of the ibuf tree. */ +ibuf_merge_in_background( + bool full); /*!< in: TRUE if the caller wants to + do a full contract based on PCT_IO(100). + If FALSE then the size of contract + batch is determined based on the + current size of the ibuf tree. */ + +/** Contracts insert buffer trees by reading pages referring to space_id +to the buffer pool. +@returns number of pages merged.*/ +UNIV_INTERN +ulint +ibuf_merge_space( +/*=============*/ + ulint space); /*!< in: space id */ + #endif /* !UNIV_HOTBACKUP */ /*********************************************************************//** Parses a redo log record of an ibuf bitmap page init. @@ -463,7 +471,7 @@ ibuf_check_bitmap_on_import( /*========================*/ const trx_t* trx, /*!< in: transaction */ ulint space_id) /*!< in: tablespace identifier */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO #define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO diff --git a/storage/xtradb/include/lock0lock.h b/storage/xtradb/include/lock0lock.h index 7858e5de2db..b6100d470cc 100644 --- a/storage/xtradb/include/lock0lock.h +++ b/storage/xtradb/include/lock0lock.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -280,7 +280,7 @@ lock_rec_expl_exist_on_page( /*========================*/ ulint space, /*!< in: space id */ ulint page_no)/*!< in: page number */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Checks if locks of other transactions prevent an immediate insert of a record. If they do, first tests if the query thread should anyway @@ -303,7 +303,7 @@ lock_rec_insert_check_and_lock( inserted record maybe should inherit LOCK_GAP type locks from the successor record */ - __attribute__((nonnull(2,3,4,6,7), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3,4,6,7), warn_unused_result)); /*********************************************************************//** Checks if locks of other transactions prevent an immediate modify (update, delete mark, or delete unmark) of a clustered index record. If they do, @@ -324,7 +324,7 @@ lock_clust_rec_modify_check_and_lock( dict_index_t* index, /*!< in: clustered index */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /*********************************************************************//** Checks if locks of other transactions prevent an immediate modify (delete mark or delete unmark) of a secondary index record. @@ -345,7 +345,7 @@ lock_sec_rec_modify_check_and_lock( que_thr_t* thr, /*!< in: query thread (can be NULL if BTR_NO_LOCKING_FLAG) */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((warn_unused_result, nonnull(2,3,4,6))); + MY_ATTRIBUTE((warn_unused_result, nonnull(2,3,4,6))); /*********************************************************************//** Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record. @@ -432,7 +432,7 @@ lock_clust_rec_read_check_and_lock_alt( ulint gap_mode,/*!< in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Checks that a record is seen in a consistent read. @return true if sees, or false if an earlier version of the record @@ -464,7 +464,7 @@ lock_sec_rec_cons_read_sees( should be read or passed over by a read cursor */ const read_view_t* view) /*!< in: consistent read view */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Locks the specified database table in the mode given. If the lock cannot be granted immediately, the query thread is put to wait. @@ -479,7 +479,7 @@ lock_table( in dictionary cache */ enum lock_mode mode, /*!< in: lock mode */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Creates a table IX lock object for a resurrected transaction. */ UNIV_INTERN @@ -544,7 +544,7 @@ lock_rec_fold( /*==========*/ ulint space, /*!< in: space */ ulint page_no)/*!< in: page number */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*********************************************************************//** Calculates the hash value of a page file address: used in inserting or searching for a lock in the hash table. @@ -594,7 +594,7 @@ lock_is_table_exclusive( /*====================*/ const dict_table_t* table, /*!< in: table */ const trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Checks if a lock request lock1 has to wait for request lock2. @return TRUE if lock1 has to wait for lock2 to be removed */ @@ -618,7 +618,7 @@ lock_report_trx_id_insanity( dict_index_t* index, /*!< in: index */ const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */ trx_id_t max_trx_id) /*!< in: trx_sys_get_max_trx_id() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Prints info of a table lock. */ UNIV_INTERN @@ -645,7 +645,7 @@ lock_print_info_summary( /*====================*/ FILE* file, /*!< in: file where to print */ ibool nowait) /*!< in: whether to wait for the lock mutex */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock @@ -665,7 +665,7 @@ ulint lock_number_of_rows_locked( /*=======================*/ const trx_lock_t* trx_lock) /*!< in: transaction locks */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Gets the type of a lock. Non-inline version for using outside of the @@ -833,7 +833,7 @@ dberr_t lock_trx_handle_wait( /*=================*/ trx_t* trx) /*!< in/out: trx lock state */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Get the number of locks on a table. @return number of locks */ @@ -842,7 +842,7 @@ ulint lock_table_get_n_locks( /*===================*/ const dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /*********************************************************************//** Checks that a transaction id is sensible, i.e., not in the future. @@ -855,7 +855,7 @@ lock_check_trx_id_sanity( const rec_t* rec, /*!< in: user record */ dict_index_t* index, /*!< in: index */ const ulint* offsets) /*!< in: rec_get_offsets(rec, index) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Check if the transaction holds any locks on the sys tables or its records. @@ -865,7 +865,7 @@ const lock_t* lock_trx_has_sys_table_locks( /*=========================*/ const trx_t* trx) /*!< in: transaction to check */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** Check if the transaction holds an exclusive lock on a record. @@ -878,7 +878,7 @@ lock_trx_has_rec_x_lock( const dict_table_t* table, /*!< in: table to check */ const buf_block_t* block, /*!< in: buffer block of the record */ ulint heap_no)/*!< in: record heap number */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /** Lock modes and types */ diff --git a/storage/xtradb/include/lock0priv.h b/storage/xtradb/include/lock0priv.h index 90d5dc994a4..7a74cbdc2e3 100644 --- a/storage/xtradb/include/lock0priv.h +++ b/storage/xtradb/include/lock0priv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under @@ -115,7 +115,7 @@ lock_clust_rec_some_has_impl( const rec_t* rec, /*!< in: user record */ const dict_index_t* index, /*!< in: clustered index */ const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_NONINL #include "lock0priv.ic" diff --git a/storage/xtradb/include/log0log.h b/storage/xtradb/include/log0log.h index 69bc2705733..470274761fc 100644 --- a/storage/xtradb/include/log0log.h +++ b/storage/xtradb/include/log0log.h @@ -352,17 +352,6 @@ log_archive_do( ulint* n_bytes);/*!< out: archive log buffer size, 0 if nothing to archive */ /****************************************************************//** -Writes the log contents to the archive up to the lsn when this function was -called, and stops the archiving. When archiving is started again, the archived -log file numbers start from a number one higher, so that the archiving will -not write again to the archived log files which exist when this function -returns. -@return DB_SUCCESS or DB_ERROR */ -UNIV_INTERN -ulint -log_archive_stop(void); -/*==================*/ -/****************************************************************//** Starts again archiving which has been stopped. @return DB_SUCCESS or DB_ERROR */ UNIV_INTERN @@ -624,25 +613,14 @@ log_mem_free(void); /*==============*/ /****************************************************************//** -Safely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, otherwise this field is protected with the log system -mutex. The writer counterpart function is log_set_tracked_lsn() in -log0online.c. +Safely reads the log_sys->tracked_lsn value. The writer counterpart function +is log_set_tracked_lsn() in log0online.c. @return log_sys->tracked_lsn value. */ UNIV_INLINE lsn_t log_get_tracked_lsn(void); /*=====================*/ -/****************************************************************//** -Unsafely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, or use dirty read. Use for printing only. - -@return log_sys->tracked_lsn value. */ -UNIV_INLINE -lsn_t -log_get_tracked_lsn_peek(void); -/*==========================*/ extern log_t* log_sys; diff --git a/storage/xtradb/include/log0log.ic b/storage/xtradb/include/log0log.ic index ff5a83be249..70458fa546b 100644 --- a/storage/xtradb/include/log0log.ic +++ b/storage/xtradb/include/log0log.ic @@ -553,37 +553,15 @@ log_free_check(void) #endif /* !UNIV_HOTBACKUP */ /****************************************************************//** -Unsafely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, or use dirty read. Use for printing only. +Safely reads the log_sys->tracked_lsn value. The writer counterpart function +is log_set_tracked_lsn() in log0online.c. -@return log_sys->tracked_lsn value. */ -UNIV_INLINE -lsn_t -log_get_tracked_lsn_peek(void) -/*==========================*/ -{ -#ifdef HAVE_ATOMIC_BUILTINS_64 - return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0); -#else - return log_sys->tracked_lsn; -#endif -} - -/****************************************************************//** -Safely reads the log_sys->tracked_lsn value. Uses atomic operations -if available, otherwise this field is protected with the log system -mutex. The writer counterpart function is log_set_tracked_lsn() in -log0online.c. @return log_sys->tracked_lsn value. */ UNIV_INLINE lsn_t log_get_tracked_lsn(void) /*=====================*/ { -#ifdef HAVE_ATOMIC_BUILTINS_64 - return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0); -#else - ut_ad(mutex_own(&(log_sys->mutex))); + os_rmb; return log_sys->tracked_lsn; -#endif } diff --git a/storage/xtradb/include/log0online.h b/storage/xtradb/include/log0online.h index 1ef4df7d6da..5706f3af4b0 100644 --- a/storage/xtradb/include/log0online.h +++ b/storage/xtradb/include/log0online.h @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA *****************************************************************************/ @@ -73,20 +73,7 @@ UNIV_INTERN ibool log_online_purge_changed_page_bitmaps( /*==================================*/ - ib_uint64_t lsn); /*!(signal_count()) < count_mask); + count_and_set++; + } + + /** Return how many times this event has been signalled */ + ib_int64_t signal_count(void) const + { + return (count_and_set & count_mask); + } }; /** Denotes an infinite delay for os_event_wait_time() */ @@ -115,8 +160,7 @@ struct os_event { /** Operating system mutex handle */ typedef struct os_mutex_t* os_ib_mutex_t; -/** Mutex protecting counts and the event and OS 'slow' mutex lists */ -extern os_ib_mutex_t os_sync_mutex; +// All the os_*_count variables are accessed atomically /** This is incremented by 1 in os_thread_create and decremented by 1 in os_thread_exit */ @@ -132,12 +176,15 @@ UNIV_INTERN void os_sync_init(void); /*==============*/ -/*********************************************************//** -Frees created events and OS 'slow' mutexes. */ + +/** Create an event semaphore, i.e., a semaphore which may just have two +states: signaled and nonsignaled. The created event is manual reset: it must be +reset explicitly by calling sync_os_reset_event. +@param[in,out] event memory block where to create the event */ UNIV_INTERN void -os_sync_free(void); -/*==============*/ +os_event_create(os_event_t event); + /*********************************************************//** Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled. The created event is manual reset: it must be reset @@ -173,7 +220,10 @@ UNIV_INTERN void os_event_free( /*==========*/ - os_event_t event); /*!< in: event to free */ + os_event_t event, /*!< in: event to free */ + bool free_memory = true); + /*!< in: if true, deallocate the event memory + block too */ /**********************************************************//** Waits for an event object until it is in the signaled state. @@ -467,7 +517,29 @@ amount to decrement. */ # define os_atomic_decrement_uint64(ptr, amount) \ os_atomic_decrement(ptr, amount) -# if defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) +# if defined(HAVE_ATOMIC_BUILTINS) + +/** Do an atomic test and set. +@param[in,out] ptr Memory location to set to non-zero +@return the previous value */ +inline +lock_word_t +os_atomic_test_and_set(volatile lock_word_t* ptr) +{ + return(__sync_lock_test_and_set(ptr, 1)); +} + +/** Do an atomic release. +@param[in,out] ptr Memory location to write to +@return the previous value */ +inline +void +os_atomic_clear(volatile lock_word_t* ptr) +{ + __sync_lock_release(ptr); +} + +# elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) /** Do an atomic test-and-set. @param[in,out] ptr Memory location to set to non-zero @@ -488,35 +560,6 @@ os_atomic_clear(volatile lock_word_t* ptr) __atomic_clear(ptr, __ATOMIC_RELEASE); } -# elif defined(HAVE_ATOMIC_BUILTINS) - -/** Do an atomic test and set. -@param[in,out] ptr Memory location to set to non-zero -@return the previous value */ -inline -lock_word_t -os_atomic_test_and_set(volatile lock_word_t* ptr) -{ - return(__sync_lock_test_and_set(ptr, 1)); -} - -/** Do an atomic release. - -In theory __sync_lock_release should be used to release the lock. -Unfortunately, it does not work properly alone. The workaround is -that more conservative __sync_lock_test_and_set is used instead. - -Performance regression was observed at some conditions for Intel -architecture. Disable release barrier on Intel architecture for now. -@param[in,out] ptr Memory location to write to -@return the previous value */ -inline -lock_word_t -os_atomic_clear(volatile lock_word_t* ptr) -{ - return(__sync_lock_test_and_set(ptr, 0)); -} - # else # error "Unsupported platform" @@ -857,15 +900,7 @@ for synchronization */ } while (0); /** barrier definitions for memory ordering */ -#ifdef IB_STRONG_MEMORY_MODEL -/* Performance regression was observed at some conditions for Intel -architecture. Disable memory barrier for Intel architecture for now. */ -# define os_rmb do { } while(0) -# define os_wmb do { } while(0) -# define os_isync do { } while(0) -# define IB_MEMORY_BARRIER_STARTUP_MSG \ - "Memory barrier is not used" -#elif defined(HAVE_IB_GCC_ATOMIC_THREAD_FENCE) +#if defined(HAVE_IB_GCC_ATOMIC_THREAD_FENCE) # define HAVE_MEMORY_BARRIER # define os_rmb __atomic_thread_fence(__ATOMIC_ACQUIRE) # define os_wmb __atomic_thread_fence(__ATOMIC_RELEASE) diff --git a/storage/xtradb/include/os0thread.h b/storage/xtradb/include/os0thread.h index dcf809eec0d..815faf97319 100644 --- a/storage/xtradb/include/os0thread.h +++ b/storage/xtradb/include/os0thread.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -139,7 +139,7 @@ os_thread_exit( /*===========*/ void* exit_value) /*!< in: exit value; in Windows this void* is cast as a DWORD */ - UNIV_COLD __attribute__((noreturn)); + UNIV_COLD MY_ATTRIBUTE((noreturn)); /*****************************************************************//** Returns the thread identifier of current thread. @return current thread identifier */ diff --git a/storage/xtradb/include/page0cur.h b/storage/xtradb/include/page0cur.h index b1ad49b4915..f04667ff29c 100644 --- a/storage/xtradb/include/page0cur.h +++ b/storage/xtradb/include/page0cur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -180,7 +180,7 @@ page_cur_tuple_insert( mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ ulint n_ext, /*!< in: number of externally stored columns */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ - __attribute__((nonnull(1,2,3,4,5), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4,5), warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Inserts a record next to page cursor. Returns pointer to inserted record if @@ -218,7 +218,7 @@ page_cur_insert_rec_low( const rec_t* rec, /*!< in: pointer to a physical record */ ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ - __attribute__((nonnull(1,2,3,4), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /***********************************************************//** Inserts a record next to page cursor on a compressed and uncompressed page. Returns pointer to inserted record if succeed, i.e., @@ -240,7 +240,7 @@ page_cur_insert_rec_zip( const rec_t* rec, /*!< in: pointer to a physical record */ ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ - __attribute__((nonnull(1,2,3,4), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /*************************************************************//** Copies records from page to a newly created page, from a given record onward, including that record. Infimum and supremum records are not copied. diff --git a/storage/xtradb/include/page0page.h b/storage/xtradb/include/page0page.h index 2da5d793fa9..cb43c937757 100644 --- a/storage/xtradb/include/page0page.h +++ b/storage/xtradb/include/page0page.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -169,7 +169,7 @@ page_t* page_align( /*=======*/ const void* ptr) /*!< in: pointer to page frame */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** Gets the offset within a page. @return offset from the start of the page */ @@ -178,7 +178,7 @@ ulint page_offset( /*========*/ const void* ptr) /*!< in: pointer to page frame */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*************************************************************//** Returns the max trx id field value. */ UNIV_INLINE @@ -236,7 +236,7 @@ page_header_get_offs( /*=================*/ const page_t* page, /*!< in: page */ ulint field) /*!< in: PAGE_FREE, ... */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /*************************************************************//** Returns the pointer stored in the given header field, or NULL. */ @@ -296,7 +296,7 @@ page_rec_get_nth_const( /*===================*/ const page_t* page, /*!< in: page */ ulint nth) /*!< in: nth record */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /************************************************************//** Returns the nth record of the record list. This is the inverse function of page_rec_get_n_recs_before(). @@ -307,7 +307,7 @@ page_rec_get_nth( /*=============*/ page_t* page, /*< in: page */ ulint nth) /*!< in: nth record */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_HOTBACKUP /************************************************************//** @@ -320,7 +320,7 @@ rec_t* page_get_middle_rec( /*================*/ page_t* page) /*!< in: page */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*************************************************************//** Compares a data tuple to a physical record. Differs from the function cmp_dtuple_rec_with_match in the way that the record must reside on an @@ -528,7 +528,7 @@ bool page_is_leaf( /*=========*/ const page_t* page) /*!< in: page */ - __attribute__((pure)); + MY_ATTRIBUTE((nonnull, pure)); /************************************************************//** Determine whether the page is empty. @return true if the page is empty (PAGE_N_RECS = 0) */ @@ -537,7 +537,7 @@ bool page_is_empty( /*==========*/ const page_t* page) /*!< in: page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /************************************************************//** Determine whether the page contains garbage. @return true if the page contains garbage (PAGE_GARBAGE is not 0) */ @@ -546,7 +546,7 @@ bool page_has_garbage( /*=============*/ const page_t* page) /*!< in: page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /************************************************************//** Gets the pointer to the next record on the page. @return pointer to next record */ @@ -618,7 +618,7 @@ ibool page_rec_is_user_rec_low( /*=====================*/ ulint offset) /*!< in: record offset on page */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the supremum record on a page. @return TRUE if the supremum record */ @@ -627,7 +627,7 @@ ibool page_rec_is_supremum_low( /*=====================*/ ulint offset) /*!< in: record offset on page */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the infimum record on a page. @return TRUE if the infimum record */ @@ -636,7 +636,7 @@ ibool page_rec_is_infimum_low( /*====================*/ ulint offset) /*!< in: record offset on page */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is a user record on the page. @@ -646,7 +646,7 @@ ibool page_rec_is_user_rec( /*=================*/ const rec_t* rec) /*!< in: record */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the supremum record on a page. @return TRUE if the supremum record */ @@ -655,7 +655,7 @@ ibool page_rec_is_supremum( /*=================*/ const rec_t* rec) /*!< in: record */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /************************************************************//** TRUE if the record is the infimum record on a page. @@ -665,7 +665,7 @@ ibool page_rec_is_infimum( /*================*/ const rec_t* rec) /*!< in: record */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /***************************************************************//** Looks for the record which owns the given record. @return the owner record */ @@ -685,7 +685,7 @@ page_rec_write_field( ulint i, /*!< in: index of the field to update */ ulint val, /*!< in: value to write */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /************************************************************//** Returns the maximum combined size of records which can be inserted on top @@ -715,7 +715,7 @@ ulint page_get_free_space_of_empty( /*=========================*/ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************//** Returns the base extra size of a physical record. This is the size of the fixed header, independent of the record size. @@ -801,7 +801,7 @@ page_create_zip( ulint level, /*!< in: the B-tree level of the page */ trx_id_t max_trx_id, /*!< in: PAGE_MAX_TRX_ID */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************//** Empty a previously created B-tree index page. */ UNIV_INTERN @@ -811,7 +811,7 @@ page_create_empty( buf_block_t* block, /*!< in/out: B-tree block */ dict_index_t* index, /*!< in: the index of the page */ mtr_t* mtr) /*!< in/out: mini-transaction */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /*************************************************************//** Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. @@ -850,7 +850,7 @@ page_copy_rec_list_end( rec_t* rec, /*!< in: record on page */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Copies records from page to new_page, up to the given record, NOT including that record. Infimum and supremum records are not copied. @@ -872,7 +872,7 @@ page_copy_rec_list_start( rec_t* rec, /*!< in: record on page */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Deletes records from a page from a given record onward, including that record. The infimum and supremum records are not deleted. */ @@ -889,7 +889,7 @@ page_delete_rec_list_end( records in the end of the chain to delete, or ULINT_UNDEFINED if not known */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Deletes records from page, up to the given record, NOT including that record. Infimum and supremum records are not deleted. */ @@ -901,7 +901,7 @@ page_delete_rec_list_start( buf_block_t* block, /*!< in: buffer block of the page */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*************************************************************//** Moves record list end to another page. Moved records include split_rec. @@ -922,7 +922,7 @@ page_move_rec_list_end( rec_t* split_rec, /*!< in: first record to move */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull(1, 2, 4, 5))); + MY_ATTRIBUTE((nonnull(1, 2, 4, 5))); /*************************************************************//** Moves record list start to another page. Moved records do not include split_rec. @@ -942,7 +942,7 @@ page_move_rec_list_start( rec_t* split_rec, /*!< in: first record not to move */ dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ - __attribute__((nonnull(1, 2, 4, 5))); + MY_ATTRIBUTE((nonnull(1, 2, 4, 5))); /****************************************************************//** Splits a directory slot which owns too many records. */ UNIV_INTERN @@ -953,7 +953,7 @@ page_dir_split_slot( page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed part will be written, or NULL */ ulint slot_no)/*!< in: the directory slot */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*************************************************************//** Tries to balance the given directory slot with too few records with the upper neighbor, so that there are at least the minimum number @@ -966,7 +966,7 @@ page_dir_balance_slot( page_t* page, /*!< in/out: index page */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ ulint slot_no)/*!< in: the directory slot */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /**********************************************************//** Parses a log record of a record list end or start deletion. @return end of log record or NULL */ diff --git a/storage/xtradb/include/page0types.h b/storage/xtradb/include/page0types.h index 74ad6f72f7e..3b53de6cc2b 100644 --- a/storage/xtradb/include/page0types.h +++ b/storage/xtradb/include/page0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -133,7 +133,7 @@ page_zip_rec_set_deleted( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Write the "owned" flag of a record on a compressed page. The n_owned field @@ -145,7 +145,7 @@ page_zip_rec_set_owned( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the owned flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Shift the dense page directory when a record is deleted. */ @@ -158,7 +158,7 @@ page_zip_dir_delete( dict_index_t* index, /*!< in: index of rec */ const ulint* offsets,/*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ - __attribute__((nonnull(1,2,3,4))); + MY_ATTRIBUTE((nonnull(1,2,3,4))); /**********************************************************************//** Add a slot to the dense page directory. */ @@ -169,5 +169,5 @@ page_zip_dir_add_slot( page_zip_des_t* page_zip, /*!< in/out: compressed page */ ulint is_clustered) /*!< in: nonzero for clustered index, zero for others */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif diff --git a/storage/xtradb/include/page0zip.h b/storage/xtradb/include/page0zip.h index 41eb1e35d78..81068e7bd29 100644 --- a/storage/xtradb/include/page0zip.h +++ b/storage/xtradb/include/page0zip.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -63,7 +63,7 @@ ulint page_zip_get_size( /*==============*/ const page_zip_des_t* page_zip) /*!< in: compressed page */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /**********************************************************************//** Set the size of a compressed page in bytes. */ UNIV_INLINE @@ -86,7 +86,7 @@ page_zip_rec_needs_ext( ulint n_fields, /*!< in: number of fields in the record; ignored if zip_size == 0 */ ulint zip_size) /*!< in: compressed page size in bytes, or 0 */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************************//** Determine the guaranteed free space on an empty page. @@ -97,7 +97,7 @@ page_zip_empty_size( /*================*/ ulint n_fields, /*!< in: number of columns in the index */ ulint zip_size) /*!< in: compressed page size in bytes */ - __attribute__((const)); + MY_ATTRIBUTE((const)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -132,7 +132,7 @@ page_zip_compress( dict_index_t* index, /*!< in: index of the B-tree node */ ulint level, /*!< in: compression level */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,3))); + MY_ATTRIBUTE((nonnull(1,2,3))); /**********************************************************************//** Decompress a page. This function should tolerate errors on the compressed @@ -150,7 +150,7 @@ page_zip_decompress( FALSE=verify but do not copy some page header fields that should not change after page creation */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); #ifdef UNIV_DEBUG /**********************************************************************//** @@ -179,7 +179,7 @@ page_zip_validate_low( const dict_index_t* index, /*!< in: index of the page, if known */ ibool sloppy) /*!< in: FALSE=strict, TRUE=ignore the MIN_REC_FLAG */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Check that the compressed and decompressed pages match. */ UNIV_INTERN @@ -189,7 +189,7 @@ page_zip_validate( const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_t* page, /*!< in: uncompressed page */ const dict_index_t* index) /*!< in: index of the page, if known */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); #endif /* UNIV_ZIP_DEBUG */ #ifndef UNIV_INNOCHECKSUM @@ -203,7 +203,7 @@ page_zip_max_ins_size( /*==================*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ ibool is_clust)/*!< in: TRUE if clustered index */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /**********************************************************************//** Determine if enough space is available in the modification log. @@ -217,7 +217,7 @@ page_zip_available( ulint length, /*!< in: combined size of the record */ ulint create) /*!< in: nonzero=add the record to the heap */ - __attribute__((nonnull, pure)); + MY_ATTRIBUTE((nonnull, pure)); /**********************************************************************//** Write data to the uncompressed header portion of a page. The data must @@ -230,7 +230,7 @@ page_zip_write_header( const byte* str, /*!< in: address on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Write an entire record on the compressed page. The data must already @@ -244,7 +244,7 @@ page_zip_write_rec( dict_index_t* index, /*!< in: the index the record belongs to */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint create) /*!< in: nonzero=insert, zero=update */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Parses a log record of writing a BLOB pointer of a record. @@ -273,7 +273,7 @@ page_zip_write_blob_ptr( ulint n, /*!< in: column index */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL if no logging is needed */ - __attribute__((nonnull(1,2,3,4))); + MY_ATTRIBUTE((nonnull(1,2,3,4))); /***********************************************************//** Parses a log record of writing the node pointer of a record. @@ -298,7 +298,7 @@ page_zip_write_node_ptr( ulint size, /*!< in: data size of rec */ ulint ptr, /*!< in: node pointer */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ @@ -312,7 +312,7 @@ page_zip_write_trx_id_and_roll_ptr( ulint trx_id_col,/*!< in: column number of TRX_ID in rec */ trx_id_t trx_id, /*!< in: transaction identifier */ roll_ptr_t roll_ptr)/*!< in: roll_ptr */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Write the "deleted" flag of a record on a compressed page. The flag must @@ -324,7 +324,7 @@ page_zip_rec_set_deleted( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Write the "owned" flag of a record on a compressed page. The n_owned field @@ -336,7 +336,7 @@ page_zip_rec_set_owned( page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the owned flag (nonzero=TRUE) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Insert a record to the dense page directory. */ @@ -363,7 +363,7 @@ page_zip_dir_delete( const ulint* offsets, /*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ - __attribute__((nonnull(1,2,3,4))); + MY_ATTRIBUTE((nonnull(1,2,3,4))); /**********************************************************************//** Add a slot to the dense page directory. */ @@ -374,7 +374,7 @@ page_zip_dir_add_slot( page_zip_des_t* page_zip, /*!< in/out: compressed page */ ulint is_clustered) /*!< in: nonzero for clustered index, zero for others */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Parses a log record of writing to the header of a page. @@ -402,7 +402,7 @@ page_zip_write_header( const byte* str, /*!< in: address on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Reorganize and compress a page. This is a low-level operation for @@ -425,7 +425,7 @@ page_zip_reorganize( m_start, m_end, m_nonempty */ dict_index_t* index, /*!< in: index of the B-tree node */ mtr_t* mtr) /*!< in: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Copy the records of a page byte for byte. Do not copy the page header @@ -444,7 +444,7 @@ page_zip_copy_recs( const page_t* src, /*!< in: page */ dict_index_t* index, /*!< in: index of the B-tree */ mtr_t* mtr) /*!< in: mini-transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** @@ -458,7 +458,7 @@ page_zip_parse_compress( byte* end_ptr,/*!< in: buffer end */ page_t* page, /*!< out: uncompressed page */ page_zip_des_t* page_zip)/*!< out: compressed page */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); #endif /* !UNIV_INNOCHECKSUM */ @@ -472,7 +472,7 @@ page_zip_calc_checksum( const void* data, /*!< in: compressed page */ ulint size, /*!< in: size of compressed page */ srv_checksum_algorithm_t algo) /*!< in: algorithm to use */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Verify a compressed page's checksum. @@ -509,7 +509,7 @@ page_zip_parse_compress_no_data( page_t* page, /*!< in: uncompressed page */ page_zip_des_t* page_zip, /*!< out: compressed page */ dict_index_t* index) /*!< in: index */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Reset the counters used for filling diff --git a/storage/xtradb/include/pars0pars.h b/storage/xtradb/include/pars0pars.h index 65ff7533828..73585c78a6a 100644 --- a/storage/xtradb/include/pars0pars.h +++ b/storage/xtradb/include/pars0pars.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -472,7 +472,7 @@ pars_complete_graph_for_exec( query graph, or NULL for dummy graph */ trx_t* trx, /*!< in: transaction handle */ mem_heap_t* heap) /*!< in: memory heap from which allocated */ - __attribute__((nonnull(2,3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(2,3), warn_unused_result)); /****************************************************************//** Create parser info struct. @@ -628,7 +628,7 @@ pars_info_bind_ull_literal( pars_info_t* info, /*!< in: info struct */ const char* name, /*!< in: name */ const ib_uint64_t* val) /*!< in: value */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Add bound id. */ diff --git a/storage/xtradb/include/read0read.h b/storage/xtradb/include/read0read.h index 0352f129c30..2d6885884f7 100644 --- a/storage/xtradb/include/read0read.h +++ b/storage/xtradb/include/read0read.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -116,7 +116,7 @@ read_view_sees_trx_id( /*==================*/ const read_view_t* view, /*!< in: read view */ trx_id_t trx_id) /*!< in: trx id */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Prints a read view to file. */ UNIV_INTERN diff --git a/storage/xtradb/include/rem0cmp.h b/storage/xtradb/include/rem0cmp.h index cb3c85ac2c8..65116229fdc 100644 --- a/storage/xtradb/include/rem0cmp.h +++ b/storage/xtradb/include/rem0cmp.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -174,7 +174,7 @@ cmp_dtuple_rec_with_match_low( bytes within the first field not completely matched; when function returns, contains the value for current comparison */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define cmp_dtuple_rec_with_match(tuple,rec,offsets,fields,bytes) \ cmp_dtuple_rec_with_match_low( \ tuple,rec,offsets,dtuple_get_n_fields_cmp(tuple),fields,bytes) @@ -218,7 +218,7 @@ cmp_rec_rec_simple( struct TABLE* table) /*!< in: MySQL table, for reporting duplicate key value if applicable, or NULL */ - __attribute__((nonnull(1,2,3,4), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4), warn_unused_result)); /*************************************************************//** This function is used to compare two physical records. Only the common first fields are compared, and if an externally stored field is diff --git a/storage/xtradb/include/rem0rec.h b/storage/xtradb/include/rem0rec.h index 51c09bdc3ec..d72f2760a8c 100644 --- a/storage/xtradb/include/rem0rec.h +++ b/storage/xtradb/include/rem0rec.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -98,7 +98,7 @@ rec_get_next_ptr_const( /*===================*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the pointer of the next chained record on the same page. @@ -109,7 +109,7 @@ rec_get_next_ptr( /*=============*/ rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the offset of the next chained record on the same page. @@ -120,7 +120,7 @@ rec_get_next_offs( /*==============*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the next record offset field of an old-style record. */ @@ -130,7 +130,7 @@ rec_set_next_offs_old( /*==================*/ rec_t* rec, /*!< in: old-style physical record */ ulint next) /*!< in: offset of the next record */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to set the next record offset field of a new-style record. */ @@ -140,7 +140,7 @@ rec_set_next_offs_new( /*==================*/ rec_t* rec, /*!< in/out: new-style physical record */ ulint next) /*!< in: offset of the next record */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to get the number of fields in an old-style record. @@ -150,7 +150,7 @@ ulint rec_get_n_fields_old( /*=================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the number of fields in a record. @@ -161,7 +161,7 @@ rec_get_n_fields( /*=============*/ const rec_t* rec, /*!< in: physical record */ const dict_index_t* index) /*!< in: record descriptor */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the number of records owned by the previous directory record. @@ -171,7 +171,7 @@ ulint rec_get_n_owned_old( /*================*/ const rec_t* rec) /*!< in: old-style physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the number of owned records. */ UNIV_INLINE @@ -180,7 +180,7 @@ rec_set_n_owned_old( /*================*/ rec_t* rec, /*!< in: old-style physical record */ ulint n_owned) /*!< in: the number of owned */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to get the number of records owned by the previous directory record. @@ -190,7 +190,7 @@ ulint rec_get_n_owned_new( /*================*/ const rec_t* rec) /*!< in: new-style physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the number of owned records. */ UNIV_INLINE @@ -200,7 +200,7 @@ rec_set_n_owned_new( rec_t* rec, /*!< in/out: new-style physical record */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ ulint n_owned)/*!< in: the number of owned */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /******************************************************//** The following function is used to retrieve the info bits of a record. @@ -211,7 +211,7 @@ rec_get_info_bits( /*==============*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the info bits of a record. */ UNIV_INLINE @@ -220,7 +220,7 @@ rec_set_info_bits_old( /*==================*/ rec_t* rec, /*!< in: old-style physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to set the info bits of a record. */ UNIV_INLINE @@ -229,7 +229,7 @@ rec_set_info_bits_new( /*==================*/ rec_t* rec, /*!< in/out: new-style physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function retrieves the status bits of a new-style record. @return status bits */ @@ -238,7 +238,7 @@ ulint rec_get_status( /*===========*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the status bits of a new-style record. */ @@ -248,7 +248,7 @@ rec_set_status( /*===========*/ rec_t* rec, /*!< in/out: physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to retrieve the info and status @@ -260,7 +260,7 @@ rec_get_info_and_status_bits( /*=========================*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the info and status bits of a record. (Only compact records have status bits.) */ @@ -270,7 +270,7 @@ rec_set_info_and_status_bits( /*=========================*/ rec_t* rec, /*!< in/out: compact physical record */ ulint bits) /*!< in: info bits */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function tells if record is delete marked. @@ -281,7 +281,7 @@ rec_get_deleted_flag( /*=================*/ const rec_t* rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the deleted bit. */ UNIV_INLINE @@ -290,7 +290,7 @@ rec_set_deleted_flag_old( /*=====================*/ rec_t* rec, /*!< in: old-style physical record */ ulint flag) /*!< in: nonzero if delete marked */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to set the deleted bit. */ UNIV_INLINE @@ -300,7 +300,7 @@ rec_set_deleted_flag_new( rec_t* rec, /*!< in/out: new-style physical record */ page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */ ulint flag) /*!< in: nonzero if delete marked */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /******************************************************//** The following function tells if a new-style record is a node pointer. @return TRUE if node pointer */ @@ -309,7 +309,7 @@ ibool rec_get_node_ptr_flag( /*==================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to get the order number of an old-style record in the heap of the index page. @@ -319,7 +319,7 @@ ulint rec_get_heap_no_old( /*================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the heap number field in an old-style record. */ @@ -329,7 +329,7 @@ rec_set_heap_no_old( /*================*/ rec_t* rec, /*!< in: physical record */ ulint heap_no)/*!< in: the heap number */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to get the order number of a new-style record in the heap of the index page. @@ -339,7 +339,7 @@ ulint rec_get_heap_no_new( /*================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the heap number field in a new-style record. */ @@ -349,7 +349,7 @@ rec_set_heap_no_new( /*================*/ rec_t* rec, /*!< in/out: physical record */ ulint heap_no)/*!< in: the heap number */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** The following function is used to test whether the data offsets in the record are stored in one-byte or two-byte format. @@ -359,7 +359,7 @@ ibool rec_get_1byte_offs_flag( /*====================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** The following function is used to set the 1-byte offsets flag. */ @@ -369,7 +369,7 @@ rec_set_1byte_offs_flag( /*====================*/ rec_t* rec, /*!< in: physical record */ ibool flag) /*!< in: TRUE if 1byte form */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** Returns the offset of nth field end if the record is stored in the 1-byte @@ -382,7 +382,7 @@ rec_1_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: field index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns the offset of nth field end if the record is stored in the 2-byte @@ -396,7 +396,7 @@ rec_2_get_field_end_info( /*=====================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: field index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns nonzero if the field is stored off-page. @@ -408,7 +408,7 @@ rec_2_is_field_extern( /*==================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: field index */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Determine how many of the first n columns in a compact @@ -421,7 +421,7 @@ rec_get_n_extern_new( const rec_t* rec, /*!< in: compact physical record */ const dict_index_t* index, /*!< in: record descriptor */ ulint n) /*!< in: number of columns to scan */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** The following function determines the offsets to each field @@ -446,9 +446,9 @@ rec_get_offsets_func( #endif /* UNIV_DEBUG */ mem_heap_t** heap) /*!< in/out: memory heap */ #ifdef UNIV_DEBUG - __attribute__((nonnull(1,2,5,7),warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,5,7),warn_unused_result)); #else /* UNIV_DEBUG */ - __attribute__((nonnull(1,2,5),warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,5),warn_unused_result)); #endif /* UNIV_DEBUG */ #ifdef UNIV_DEBUG @@ -475,7 +475,7 @@ rec_get_offsets_reverse( 0=leaf node */ ulint* offsets)/*!< in/out: array consisting of offsets[0] allocated elements */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /************************************************************//** Validates offsets returned by rec_get_offsets(). @@ -488,7 +488,7 @@ rec_offs_validate( const dict_index_t* index, /*!< in: record descriptor or NULL */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull(3), warn_unused_result)); + MY_ATTRIBUTE((nonnull(3), warn_unused_result)); /************************************************************//** Updates debug data in offsets, in order to avoid bogus rec_offs_validate() failures. */ @@ -500,7 +500,7 @@ rec_offs_make_valid( const dict_index_t* index, /*!< in: record descriptor */ ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #else # define rec_offs_make_valid(rec, index, offsets) ((void) 0) #endif /* UNIV_DEBUG */ @@ -517,7 +517,7 @@ rec_get_nth_field_offs_old( ulint n, /*!< in: index of the field */ ulint* len) /*!< out: length of the field; UNIV_SQL_NULL if SQL null */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define rec_get_nth_field_old(rec, n, len) \ ((rec) + rec_get_nth_field_offs_old(rec, n, len)) /************************************************************//** @@ -531,7 +531,7 @@ rec_get_nth_field_size( /*===================*/ const rec_t* rec, /*!< in: record */ ulint n) /*!< in: index of the field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /************************************************************//** The following function is used to get an offset to the nth data field in a record. @@ -544,7 +544,7 @@ rec_get_nth_field_offs( ulint n, /*!< in: index of the field */ ulint* len) /*!< out: length of the field; UNIV_SQL_NULL if SQL null */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define rec_get_nth_field(rec, offsets, n, len) \ ((rec) + rec_get_nth_field_offs(offsets, n, len)) /******************************************************//** @@ -556,7 +556,7 @@ ulint rec_offs_comp( /*==========*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Determine if the offsets are for a record containing externally stored columns. @@ -566,7 +566,7 @@ ulint rec_offs_any_extern( /*================*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Determine if the offsets are for a record containing null BLOB pointers. @return first field containing a null BLOB pointer, or NULL if none found */ @@ -576,7 +576,7 @@ rec_offs_any_null_extern( /*=====================*/ const rec_t* rec, /*!< in: record */ const ulint* offsets) /*!< in: rec_get_offsets(rec) */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns nonzero if the extern bit is set in nth field of rec. @return nonzero if externally stored */ @@ -586,7 +586,7 @@ rec_offs_nth_extern( /*================*/ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns nonzero if the SQL NULL bit is set in nth field of rec. @return nonzero if SQL NULL */ @@ -596,7 +596,7 @@ rec_offs_nth_sql_null( /*==================*/ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Gets the physical size of a field. @return length of field */ @@ -606,7 +606,7 @@ rec_offs_nth_size( /*==============*/ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /******************************************************//** Returns the number of extern bits set in a record. @@ -616,7 +616,7 @@ ulint rec_offs_n_extern( /*==============*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /***********************************************************//** This is used to modify the value of an already existing field in a record. The previous value must have exactly the same size as the new value. If len @@ -636,7 +636,7 @@ rec_set_nth_field( length as the previous value. If SQL null, previous value must be SQL null. */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************//** The following function returns the data size of an old-style physical record, that is the sum of field lengths. SQL null fields @@ -648,7 +648,7 @@ ulint rec_get_data_size_old( /*==================*/ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** The following function returns the number of allocated elements for an array of offsets. @@ -658,7 +658,7 @@ ulint rec_offs_get_n_alloc( /*=================*/ const ulint* offsets)/*!< in: array for rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** The following function sets the number of allocated elements for an array of offsets. */ @@ -669,7 +669,7 @@ rec_offs_set_n_alloc( ulint* offsets, /*!< out: array for rec_get_offsets(), must be allocated */ ulint n_alloc) /*!< in: number of elements */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #define rec_offs_init(offsets) \ rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets) /**********************************************************//** @@ -680,7 +680,7 @@ ulint rec_offs_n_fields( /*==============*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** The following function returns the data size of a physical record, that is the sum of field lengths. SQL null fields @@ -692,7 +692,7 @@ ulint rec_offs_data_size( /*===============*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** Returns the total size of record minus data size of record. The value returned by the function is the distance from record @@ -703,7 +703,7 @@ ulint rec_offs_extra_size( /*================*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** Returns the total size of a physical record. @return size */ @@ -712,7 +712,7 @@ ulint rec_offs_size( /*==========*/ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #ifdef UNIV_DEBUG /**********************************************************//** Returns a pointer to the start of the record. @@ -723,7 +723,7 @@ rec_get_start( /*==========*/ const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); /**********************************************************//** Returns a pointer to the end of the record. @return pointer to end */ @@ -733,7 +733,7 @@ rec_get_end( /*========*/ const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #else /* UNIV_DEBUG */ # define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets)) # define rec_get_end(rec, offsets) ((rec) + rec_offs_data_size(offsets)) @@ -748,7 +748,7 @@ rec_copy( void* buf, /*!< in: buffer */ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /**********************************************************//** Determines the size of a data tuple prefix in a temporary file. @@ -761,7 +761,7 @@ rec_get_converted_size_temp( const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields,/*!< in: number of data fields */ ulint* extra) /*!< out: extra size */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /******************************************************//** Determine the offset to each field in temporary file. @@ -774,7 +774,7 @@ rec_init_offsets_temp( const dict_index_t* index, /*!< in: record descriptor */ ulint* offsets)/*!< in/out: array of offsets; in: n=rec_offs_n_fields(offsets) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************//** Builds a temporary file record out of a data tuple. @@ -787,7 +787,7 @@ rec_convert_dtuple_to_temp( const dict_index_t* index, /*!< in: record descriptor */ const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields) /*!< in: number of fields */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**************************************************************//** Copies the first n fields of a physical record to a new physical record in @@ -805,7 +805,7 @@ rec_copy_prefix_to_buf( for the copied prefix, or NULL */ ulint* buf_size) /*!< in/out: buffer size */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /************************************************************//** Folds a prefix of a physical record to a ulint. @return the folded value */ @@ -821,7 +821,7 @@ rec_fold( ulint n_bytes, /*!< in: number of bytes to fold in an incomplete last field */ index_id_t tree_id) /*!< in: index tree id */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************//** Builds a physical record out of a data tuple and @@ -837,7 +837,7 @@ rec_convert_dtuple_to_rec( const dtuple_t* dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /**********************************************************//** Returns the extra size of an old-style physical record if we know its data size and number of fields. @@ -849,7 +849,7 @@ rec_get_converted_extra_size( ulint data_size, /*!< in: data size */ ulint n_fields, /*!< in: number of fields */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************//** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ @@ -861,7 +861,7 @@ rec_get_converted_size_comp_prefix( const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields,/*!< in: number of data fields */ ulint* extra) /*!< out: extra size */ - __attribute__((warn_unused_result, nonnull(1,2))); + MY_ATTRIBUTE((warn_unused_result, nonnull(1,2))); /**********************************************************//** Determines the size of a data tuple in ROW_FORMAT=COMPACT. @return total size */ @@ -877,7 +877,7 @@ rec_get_converted_size_comp( const dfield_t* fields, /*!< in: array of data fields */ ulint n_fields,/*!< in: number of data fields */ ulint* extra) /*!< out: extra size */ - __attribute__((nonnull(1,3))); + MY_ATTRIBUTE((nonnull(1,3))); /**********************************************************//** The following function returns the size of a data tuple when converted to a physical record. @@ -889,7 +889,7 @@ rec_get_converted_size( dict_index_t* index, /*!< in: record descriptor */ const dtuple_t* dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); #ifndef UNIV_HOTBACKUP /**************************************************************//** Copies the first n fields of a physical record to a data tuple. @@ -904,7 +904,7 @@ rec_copy_prefix_to_dtuple( ulint n_fields, /*!< in: number of fields to copy */ mem_heap_t* heap) /*!< in: memory heap */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***************************************************************//** Validates the consistency of a physical record. @@ -915,7 +915,7 @@ rec_validate( /*=========*/ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints an old-style physical record. */ UNIV_INTERN @@ -924,7 +924,7 @@ rec_print_old( /*==========*/ FILE* file, /*!< in: file where to print */ const rec_t* rec) /*!< in: physical record */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_HOTBACKUP /***************************************************************//** Prints a physical record in ROW_FORMAT=COMPACT. Ignores the @@ -936,7 +936,7 @@ rec_print_comp( FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints a physical record. */ UNIV_INTERN @@ -946,7 +946,7 @@ rec_print_new( FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Prints a physical record. */ UNIV_INTERN @@ -956,7 +956,7 @@ rec_print( FILE* file, /*!< in: file where to print */ const rec_t* rec, /*!< in: physical record */ const dict_index_t* index) /*!< in: record descriptor */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); # ifdef UNIV_DEBUG /************************************************************//** @@ -968,7 +968,7 @@ rec_get_trx_id( /*===========*/ const rec_t* rec, /*!< in: record */ const dict_index_t* index) /*!< in: clustered index */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # endif /* UNIV_DEBUG */ #endif /* UNIV_HOTBACKUP */ diff --git a/storage/xtradb/include/rem0rec.ic b/storage/xtradb/include/rem0rec.ic index a539320dd2a..5811a77a48b 100644 --- a/storage/xtradb/include/rem0rec.ic +++ b/storage/xtradb/include/rem0rec.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1540,7 +1540,8 @@ rec_copy( ulint extra_len; ulint data_len; - ut_ad(rec && buf); + ut_ad(rec != NULL); + ut_ad(buf != NULL); ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(rec_validate(rec, offsets)); diff --git a/storage/xtradb/include/row0ftsort.h b/storage/xtradb/include/row0ftsort.h index eeef10f3397..7c9ed23645c 100644 --- a/storage/xtradb/include/row0ftsort.h +++ b/storage/xtradb/include/row0ftsort.h @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2010, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2016, MariaDB Corporation. 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 @@ -193,7 +193,7 @@ row_fts_psort_info_init( instantiated */ fts_psort_t** merge) /*!< out: parallel merge info to be instantiated */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Clean up and deallocate FTS parallel sort structures, and close temparary merge sort files */ @@ -281,5 +281,5 @@ row_fts_merge_insert( fts_psort_t* psort_info, /*!< parallel sort info */ ulint id) /* !< in: which auxiliary table's data to insert to */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* row0ftsort_h */ diff --git a/storage/xtradb/include/row0import.h b/storage/xtradb/include/row0import.h index aa46fdb7c27..a821c230a3b 100644 --- a/storage/xtradb/include/row0import.h +++ b/storage/xtradb/include/row0import.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -46,7 +46,7 @@ row_import_for_mysql( dict_table_t* table, /*!< in/out: table */ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Update the DICT_TF2_DISCARDED flag in SYS_TABLES. @@ -64,7 +64,7 @@ row_import_update_discarded_flag( bool dict_locked) /*!< in: Set to true if the caller already owns the dict_sys_t:: mutex. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Update the (space, root page) of a table's indexes from the values @@ -83,7 +83,7 @@ row_import_update_index_root( bool dict_locked) /*!< in: Set to true if the caller already owns the dict_sys_t:: mutex. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_NONINL #include "row0import.ic" #endif diff --git a/storage/xtradb/include/row0ins.h b/storage/xtradb/include/row0ins.h index 2a892d2f5df..71ee39070ef 100644 --- a/storage/xtradb/include/row0ins.h +++ b/storage/xtradb/include/row0ins.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -53,7 +53,7 @@ row_ins_check_foreign_constraint( table, else the referenced table */ dtuple_t* entry, /*!< in: index entry for index */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Creates an insert node struct. @return own: insert node struct */ @@ -98,7 +98,7 @@ row_ins_clust_index_entry_low( dtuple_t* entry, /*!< in/out: index entry to insert */ ulint n_ext, /*!< in: number of externally stored columns */ que_thr_t* thr) /*!< in: query thread or NULL */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***************************************************************//** Tries to insert an entry into a secondary index. If a record with exactly the same fields is found, the other record is necessarily marked deleted. @@ -123,7 +123,7 @@ row_ins_sec_index_entry_low( trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during row_log_table_apply(), or 0 */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***************************************************************//** Tries to insert the externally stored fields (off-page columns) of a clustered index entry. @@ -142,7 +142,7 @@ row_ins_index_entry_big_rec_func( const void* thd, /*!< in: connection, or NULL */ #endif /* DBUG_OFF */ ulint line) /*!< in: line number of caller */ - __attribute__((nonnull(1,2,3,4,5,6), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,4,5,6), warn_unused_result)); #ifdef DBUG_OFF # define row_ins_index_entry_big_rec(e,big,ofs,heap,index,thd,file,line) \ row_ins_index_entry_big_rec_func(e,big,ofs,heap,index,file,line) @@ -164,7 +164,7 @@ row_ins_clust_index_entry( dtuple_t* entry, /*!< in/out: index entry to insert */ que_thr_t* thr, /*!< in: query thread */ ulint n_ext) /*!< in: number of externally stored columns */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***************************************************************//** Inserts an entry into a secondary index. Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough @@ -178,7 +178,7 @@ row_ins_sec_index_entry( dict_index_t* index, /*!< in: secondary index */ dtuple_t* entry, /*!< in/out: index entry to insert */ que_thr_t* thr) /*!< in: query thread */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************//** Inserts a row to a table. This is a high-level function used in SQL execution graphs. diff --git a/storage/xtradb/include/row0log.h b/storage/xtradb/include/row0log.h index e127504c484..5ff148ff045 100644 --- a/storage/xtradb/include/row0log.h +++ b/storage/xtradb/include/row0log.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -58,7 +58,7 @@ row_log_allocate( const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ const char* path) /*!< in: where to create temporary file */ - __attribute__((nonnull(1), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1), warn_unused_result)); /******************************************************//** Free the row log for an index that was being created online. */ @@ -67,7 +67,7 @@ void row_log_free( /*=========*/ row_log_t*& log) /*!< in,own: row log */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** Free the row log for an index on which online creation was aborted. */ @@ -76,7 +76,7 @@ void row_log_abort_sec( /*==============*/ dict_index_t* index) /*!< in/out: index (x-latched) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************//** Try to log an operation to a secondary index that is @@ -91,7 +91,7 @@ row_log_online_op_try( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Logs an operation to a secondary index that is (or was) being created. */ UNIV_INTERN @@ -102,7 +102,7 @@ row_log_online_op( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Gets the error status of the online index rebuild log. @@ -113,7 +113,7 @@ row_log_table_get_error( /*====================*/ const dict_index_t* index) /*!< in: clustered index of a table that is being rebuilt online */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Logs a delete operation to a table that is being rebuilt. @@ -129,7 +129,7 @@ row_log_table_delete( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const byte* sys) /*!< in: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec */ - UNIV_COLD __attribute__((nonnull(1,2,3))); + UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); /******************************************************//** Logs an update operation to a table that is being rebuilt. @@ -145,7 +145,7 @@ row_log_table_update( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const dtuple_t* old_pk) /*!< in: row_log_table_get_pk() before the update */ - UNIV_COLD __attribute__((nonnull(1,2,3))); + UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); /******************************************************//** Constructs the old PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR @@ -165,7 +165,7 @@ row_log_table_get_pk( byte* sys, /*!< out: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL */ mem_heap_t** heap) /*!< in/out: memory heap where allocated */ - UNIV_COLD __attribute__((nonnull(1,2,5), warn_unused_result)); + UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,5), warn_unused_result)); /******************************************************//** Logs an insert to a table that is being rebuilt. @@ -179,7 +179,7 @@ row_log_table_insert( dict_index_t* index, /*!< in/out: clustered index, S-latched or X-latched */ const ulint* offsets)/*!< in: rec_get_offsets(rec,index) */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Notes that a BLOB is being freed during online ALTER TABLE. */ UNIV_INTERN @@ -188,7 +188,7 @@ row_log_table_blob_free( /*====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Notes that a BLOB is being allocated during online ALTER TABLE. */ UNIV_INTERN @@ -197,7 +197,7 @@ row_log_table_blob_alloc( /*=====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /******************************************************//** Apply the row_log_table log to a table upon completing rebuild. @return DB_SUCCESS, or error code on failure */ @@ -210,7 +210,7 @@ row_log_table_apply( /*!< in: old table */ struct TABLE* table) /*!< in/out: MySQL table (for reporting duplicates) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Get the latest transaction ID that has invoked row_log_online_op() @@ -221,7 +221,7 @@ trx_id_t row_log_get_max_trx( /*================*/ dict_index_t* index) /*!< in: index, must be locked */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************//** Merge the row log to the index upon completing index creation. @@ -235,7 +235,7 @@ row_log_apply( dict_index_t* index, /*!< in/out: secondary index */ struct TABLE* table) /*!< in/out: MySQL table (for reporting duplicates) */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #ifndef UNIV_NONINL #include "row0log.ic" diff --git a/storage/xtradb/include/row0merge.h b/storage/xtradb/include/row0merge.h index 53164b5197f..04d4010ad48 100644 --- a/storage/xtradb/include/row0merge.h +++ b/storage/xtradb/include/row0merge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -144,7 +144,7 @@ row_merge_dup_report( /*=================*/ row_merge_dup_t* dup, /*!< in/out: for reporting duplicates */ const dfield_t* entry) /*!< in: duplicate index entry */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Sets an exclusive lock on a table, for the duration of creating indexes. @return error code or DB_SUCCESS */ @@ -155,7 +155,7 @@ row_merge_lock_table( trx_t* trx, /*!< in/out: transaction */ dict_table_t* table, /*!< in: table to lock */ enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Drop indexes that were created before an error occurred. The data dictionary must have been locked exclusively by the caller, @@ -166,7 +166,7 @@ row_merge_drop_indexes_dict( /*========================*/ trx_t* trx, /*!< in/out: dictionary transaction */ table_id_t table_id)/*!< in: table identifier */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Drop those indexes which were created before an error occurred. The data dictionary must have been locked exclusively by the caller, @@ -179,7 +179,7 @@ row_merge_drop_indexes( dict_table_t* table, /*!< in/out: table containing the indexes */ ibool locked) /*!< in: TRUE=table locked, FALSE=may need to do a lazy drop */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Drop all partially created indexes during crash recovery. */ UNIV_INTERN @@ -195,7 +195,7 @@ UNIV_INTERN int row_merge_file_create_low( const char* path) - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /*********************************************************************//** Destroy a merge file. And de-register the file from Performance Schema if UNIV_PFS_IO is defined. */ @@ -231,7 +231,7 @@ row_merge_rename_tables_dict( old_table->name */ const char* tmp_name, /*!< in: new name for old_table */ trx_t* trx) /*!< in/out: dictionary transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Rename an index in the dictionary that was created. The data @@ -245,7 +245,7 @@ row_merge_rename_index_to_add( trx_t* trx, /*!< in/out: transaction */ table_id_t table_id, /*!< in: table identifier */ index_id_t index_id) /*!< in: index identifier */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Rename an index in the dictionary that is to be dropped. The data dictionary must have been locked exclusively by the caller, because @@ -258,7 +258,7 @@ row_merge_rename_index_to_drop( trx_t* trx, /*!< in/out: transaction */ table_id_t table_id, /*!< in: table identifier */ index_id_t index_id) /*!< in: index identifier */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Create the index and load in to the dictionary. @return index, or NULL on error */ @@ -294,7 +294,7 @@ row_merge_drop_table( /*=================*/ trx_t* trx, /*!< in: transaction */ dict_table_t* table) /*!< in: table instance to drop */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Build indexes on a table by reading a clustered index, creating a temporary file containing index entries, merge sorting @@ -327,7 +327,7 @@ row_merge_build_indexes( AUTO_INCREMENT column, or ULINT_UNDEFINED if none is added */ ib_sequence_t& sequence) /*!< in/out: autoinc sequence */ - __attribute__((nonnull(1,2,3,5,6,8), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2,3,5,6,8), warn_unused_result)); /********************************************************************//** Write a buffer to a block. */ UNIV_INTERN @@ -337,7 +337,7 @@ row_merge_buf_write( const row_merge_buf_t* buf, /*!< in: sorted buffer */ const merge_file_t* of, /*!< in: output file */ row_merge_block_t* block) /*!< out: buffer for writing to file */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Sort a buffer. */ UNIV_INTERN @@ -347,7 +347,7 @@ row_merge_buf_sort( row_merge_buf_t* buf, /*!< in/out: sort buffer */ row_merge_dup_t* dup) /*!< in/out: reporter of duplicates (NULL if non-unique index) */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /********************************************************************//** Write a merge block to the file system. @return TRUE if request was successful, FALSE if fail */ @@ -371,7 +371,7 @@ row_merge_buf_t* row_merge_buf_empty( /*================*/ row_merge_buf_t* buf) /*!< in,own: sort buffer */ - __attribute__((warn_unused_result, nonnull)); + MY_ATTRIBUTE((warn_unused_result, nonnull)); /** Create a merge file in the given location. @param[out] merge_file merge file structure @@ -412,7 +412,7 @@ row_merge_buf_t* row_merge_buf_create( /*=================*/ dict_index_t* index) /*!< in: secondary index */ - __attribute__((warn_unused_result, nonnull, malloc)); + MY_ATTRIBUTE((warn_unused_result, nonnull, malloc)); /*********************************************************************//** Deallocate a sort buffer. */ UNIV_INTERN @@ -420,7 +420,7 @@ void row_merge_buf_free( /*===============*/ row_merge_buf_t* buf) /*!< in,own: sort buffer to be freed */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Destroy a merge file. */ UNIV_INTERN @@ -428,7 +428,7 @@ void row_merge_file_destroy( /*===================*/ merge_file_t* merge_file) /*!< in/out: merge file structure */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /********************************************************************//** Read a merge block from the file system. @return TRUE if request was successful, FALSE if fail */ diff --git a/storage/xtradb/include/row0mysql.h b/storage/xtradb/include/row0mysql.h index a0ff6cdad15..52e82da668d 100644 --- a/storage/xtradb/include/row0mysql.h +++ b/storage/xtradb/include/row0mysql.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -168,7 +168,7 @@ row_mysql_handle_errors( trx_t* trx, /*!< in: transaction */ que_thr_t* thr, /*!< in: query thread, or NULL */ trx_savept_t* savept) /*!< in: savepoint, or NULL */ - __attribute__((nonnull(1,2))); + MY_ATTRIBUTE((nonnull(1,2))); /********************************************************************//** Create a prebuilt struct for a MySQL table handle. @return own: a prebuilt struct */ @@ -210,7 +210,7 @@ row_lock_table_autoinc_for_mysql( /*=============================*/ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in the MySQL table handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Sets a table lock on the table mentioned in prebuilt. @return error code or DB_SUCCESS */ @@ -226,7 +226,7 @@ row_lock_table_for_mysql( prebuilt->select_lock_type */ ulint mode) /*!< in: lock mode of table (ignored if table==NULL) */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*********************************************************************//** Does an insert for MySQL. @return error code or DB_SUCCESS */ @@ -237,7 +237,7 @@ row_insert_for_mysql( byte* mysql_rec, /*!< in: row in the MySQL format */ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Builds a dummy query graph used in selects. */ UNIV_INTERN @@ -277,7 +277,7 @@ row_update_for_mysql( the MySQL format */ row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** This can only be used when srv_locks_unsafe_for_binlog is TRUE or this session is using a READ COMMITTED or READ UNCOMMITTED isolation level. @@ -298,7 +298,7 @@ row_unlock_for_mysql( the records under pcur and clust_pcur, and we do not need to reposition the cursors. */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*********************************************************************//** Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @@ -307,7 +307,7 @@ UNIV_INTERN bool row_is_mysql_tmp_table_name( /*========================*/ - const char* name) __attribute__((warn_unused_result)); + const char* name) MY_ATTRIBUTE((warn_unused_result)); /*!< in: table name in the form 'database/tablename' */ @@ -332,7 +332,7 @@ row_update_cascade_for_mysql( upd_node_t* node, /*!< in: update node used in the cascade or set null operation */ dict_table_t* table) /*!< in: table where we do the operation */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation. */ @@ -409,7 +409,7 @@ row_create_index_for_mysql( index columns, which are then checked for not being too large. */ - __attribute__((nonnull(1,2), warn_unused_result)); + MY_ATTRIBUTE((nonnull(1,2), warn_unused_result)); /*********************************************************************//** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function @@ -435,7 +435,7 @@ row_table_add_foreign_constraints( ibool reject_fks) /*!< in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found. */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended. Such lazy @@ -464,7 +464,7 @@ row_mysql_lock_table( dict_table_t* table, /*!< in: table to lock */ enum lock_mode mode, /*!< in: LOCK_X or LOCK_S */ const char* op_info) /*!< in: string for trx->op_info */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Truncates a table for MySQL. @@ -475,7 +475,7 @@ row_truncate_table_for_mysql( /*=========================*/ dict_table_t* table, /*!< in: table handle */ trx_t* trx) /*!< in: transaction handle */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*********************************************************************//** Drops a table for MySQL. If the name of the dropped table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", @@ -491,10 +491,13 @@ row_drop_table_for_mysql( const char* name, /*!< in: table name */ trx_t* trx, /*!< in: dictionary transaction handle */ bool drop_db,/*!< in: true=dropping whole database */ + ibool create_failed,/*!wait_ex_event); + os_event_set(&lock->wait_ex_event); sync_array_object_signalled(); } @@ -642,7 +642,7 @@ rw_lock_s_unlock_func( /* A waiting next-writer exists, either high priority or regular, sharing the same wait event. */ - os_event_set(lock->base_lock.wait_ex_event); + os_event_set(&lock->base_lock.wait_ex_event); sync_array_object_signalled(); } else if (lock_word == X_LOCK_DECR) { @@ -653,7 +653,7 @@ rw_lock_s_unlock_func( if (lock->base_lock.waiters) { rw_lock_reset_waiter_flag(&lock->base_lock); - os_event_set(lock->base_lock.event); + os_event_set(&lock->base_lock.event); sync_array_object_signalled(); } } @@ -735,7 +735,7 @@ rw_lock_x_unlock_func( if (lock->waiters) { rw_lock_reset_waiter_flag(lock); - os_event_set(lock->event); + os_event_set(&lock->event); sync_array_object_signalled(); } } @@ -778,16 +778,16 @@ rw_lock_x_unlock_func( if (lock->high_priority_x_waiters) { - os_event_set(lock->high_priority_x_event); + os_event_set(&lock->high_priority_x_event); sync_array_object_signalled(); } else if (lock->high_priority_s_waiters) { - os_event_set(lock->high_priority_s_event); + os_event_set(&lock->high_priority_s_event); sync_array_object_signalled(); } else if (lock->base_lock.waiters) { rw_lock_reset_waiter_flag(&lock->base_lock); - os_event_set(lock->base_lock.event); + os_event_set(&lock->base_lock.event); sync_array_object_signalled(); } } diff --git a/storage/xtradb/include/sync0sync.h b/storage/xtradb/include/sync0sync.h index 88fe4644a07..af445aeb84c 100644 --- a/storage/xtradb/include/sync0sync.h +++ b/storage/xtradb/include/sync0sync.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. @@ -569,7 +569,7 @@ ibool mutex_own( /*======*/ const ib_mutex_t* mutex) /*!< in: mutex */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /******************************************************************//** Checks that the current thread owns the priority mutex. Works only in the debug version. @@ -579,7 +579,7 @@ ibool mutex_own( /*======*/ const ib_prio_mutex_t* mutex) /*!< in: priority mutex */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG */ #ifdef UNIV_SYNC_DEBUG /******************************************************************//** @@ -594,7 +594,7 @@ sync_thread_add_level( ulint level, /*!< in: level in the latching order; if SYNC_LEVEL_VARYING, nothing is done */ ibool relock) /*!< in: TRUE if re-entering an x-lock */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /******************************************************************//** Removes a latch from the thread level array if it is found there. @return TRUE if found in the array; it is no error if the latch is @@ -624,7 +624,7 @@ sync_thread_levels_nonempty_gen( /*============================*/ ibool dict_mutex_allowed) /*!< in: TRUE if dictionary mutex is allowed to be owned by the thread */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /******************************************************************//** Checks if the level array for the current thread is empty, except for data dictionary latches. */ @@ -641,7 +641,7 @@ sync_thread_levels_nonempty_trx( ibool has_search_latch) /*!< in: TRUE if and only if the thread is supposed to hold btr_search_latch */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); /******************************************************************//** Gets the debug information for a reserved mutex. */ @@ -926,7 +926,7 @@ implementation of a mutual exclusion semaphore. */ /** InnoDB mutex */ struct ib_mutex_t { - os_event_t event; /*!< Used by sync0arr.cc for the wait queue */ + struct os_event event; /*!< Used by sync0arr.cc for the wait queue */ volatile lock_word_t lock_word; /*!< lock_word is the target of the atomic test-and-set instruction when atomic operations are enabled. */ @@ -974,14 +974,13 @@ struct ib_mutex_t { struct ib_prio_mutex_t { ib_mutex_t base_mutex; /* The regular mutex provides the lock word etc. for the priority mutex */ - os_event_t high_priority_event; /* High priority wait array + struct os_event high_priority_event; /* High priority wait array event */ volatile ulint high_priority_waiters; /* Number of threads that asked for this mutex to be acquired with high priority in the global wait array waiting for this mutex to be released. */ - UT_LIST_NODE_T(ib_prio_mutex_t) list; }; /** Constant determining how long spin wait is continued before suspending diff --git a/storage/xtradb/include/sync0sync.ic b/storage/xtradb/include/sync0sync.ic index fa0724d7996..fb24c0ec244 100644 --- a/storage/xtradb/include/sync0sync.ic +++ b/storage/xtradb/include/sync0sync.ic @@ -181,6 +181,11 @@ mutex_exit_func( to wake up possible hanging threads if they are missed in mutex_signal_object. */ + /* We add a memory barrier to prevent reading of the + number of waiters before releasing the lock. */ + + os_mb; + if (mutex_get_waiters(mutex) != 0) { mutex_signal_object(mutex); @@ -224,7 +229,7 @@ mutex_exit_func( /* Wake up any high priority waiters first. */ if (mutex->high_priority_waiters != 0) { - os_event_set(mutex->high_priority_event); + os_event_set(&mutex->high_priority_event); sync_array_object_signalled(); } else if (mutex_get_waiters(&mutex->base_mutex) != 0) { diff --git a/storage/xtradb/include/trx0rec.h b/storage/xtradb/include/trx0rec.h index 96e7d595035..359937e3583 100644 --- a/storage/xtradb/include/trx0rec.h +++ b/storage/xtradb/include/trx0rec.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -86,7 +86,7 @@ ulint trx_undo_rec_get_offset( /*====================*/ undo_no_t undo_no) /*!< in: undo no read from node */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /**********************************************************************//** Returns the start of the undo record data area. */ @@ -109,7 +109,7 @@ trx_undo_rec_get_pars( externally stored fild */ undo_no_t* undo_no, /*!< out: undo log record number */ table_id_t* table_id) /*!< out: table id */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Builds a row reference from an undo log record. @return pointer to remaining part of undo record */ @@ -201,7 +201,7 @@ trx_undo_rec_get_partial_row( only in the assertion. */ mem_heap_t* heap) /*!< in: memory heap from which the memory needed is allocated */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /***********************************************************************//** Writes information to an undo log about an insert, update, or a delete marking of a clustered index record. This information is used in a rollback of the @@ -233,7 +233,7 @@ trx_undo_report_row_operation( inserted undo log record, 0 if BTR_NO_UNDO_LOG flag was specified */ - __attribute__((nonnull(4,10), warn_unused_result)); + MY_ATTRIBUTE((nonnull(3,4,10), warn_unused_result)); /******************************************************************//** Copies an undo record to heap. This function can be called if we know that the undo log record exists. @@ -244,7 +244,7 @@ trx_undo_get_undo_rec_low( /*======================*/ roll_ptr_t roll_ptr, /*!< in: roll pointer to record */ mem_heap_t* heap) /*!< in: memory heap where copied */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Build a previous version of a clustered index record. The caller must hold a latch on the index page of the clustered index record. @@ -268,7 +268,7 @@ trx_undo_prev_version_build( rec_t** old_vers)/*!< out, own: previous version, or NULL if rec is the first inserted version, or if history data has been deleted */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Parses a redo log record of adding an undo log record. diff --git a/storage/xtradb/include/trx0roll.h b/storage/xtradb/include/trx0roll.h index 629b41569f6..b2e9d8a077f 100644 --- a/storage/xtradb/include/trx0roll.h +++ b/storage/xtradb/include/trx0roll.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -126,7 +126,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(trx_rollback_or_clean_all_recovered)( /*================================================*/ - void* arg __attribute__((unused))); + void* arg MY_ATTRIBUTE((unused))); /*!< in: a dummy parameter required by os_thread_create */ /*********************************************************************//** @@ -153,7 +153,7 @@ dberr_t trx_rollback_for_mysql( /*===================*/ trx_t* trx) /*!< in/out: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Rollback the latest SQL statement for MySQL. @return error code or DB_SUCCESS */ @@ -162,7 +162,7 @@ dberr_t trx_rollback_last_sql_stat_for_mysql( /*=================================*/ trx_t* trx) /*!< in/out: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Rollback a transaction to a given savepoint or do a complete rollback. @return error code or DB_SUCCESS */ @@ -174,7 +174,7 @@ trx_rollback_to_savepoint( trx_savept_t* savept) /*!< in: pointer to savepoint undo number, if partial rollback requested, or NULL for complete rollback */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /*******************************************************************//** Rolls back a transaction back to a named savepoint. Modifications after the savepoint are undone but InnoDB does NOT release the corresponding locks @@ -196,7 +196,7 @@ trx_rollback_to_savepoint_for_mysql( information to remove the binlog entries of the queries executed after the savepoint */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Creates a named savepoint. If the transaction is not yet started, starts it. If there is already a savepoint of the same name, this call erases that old @@ -213,7 +213,7 @@ trx_savepoint_for_mysql( position corresponding to this connection at the time of the savepoint */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /*******************************************************************//** Releases a named savepoint. Savepoints which were set after this savepoint are deleted. @@ -225,7 +225,7 @@ trx_release_savepoint_for_mysql( /*============================*/ trx_t* trx, /*!< in: transaction handle */ const char* savepoint_name) /*!< in: savepoint name */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /*******************************************************************//** Frees savepoint structs starting from savep. */ UNIV_INTERN diff --git a/storage/xtradb/include/trx0sys.h b/storage/xtradb/include/trx0sys.h index 7892fdd0bf1..e4956c6a822 100644 --- a/storage/xtradb/include/trx0sys.h +++ b/storage/xtradb/include/trx0sys.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -291,7 +291,7 @@ ibool trx_in_trx_list( /*============*/ const trx_t* in_trx) /*!< in: transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG /***********************************************************//** @@ -302,7 +302,7 @@ ibool trx_assert_recovered( /*=================*/ trx_id_t trx_id) /*!< in: transaction identifier */ - __attribute__((warn_unused_result)); + MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ /*****************************************************************//** Updates the offset information about the end of the MySQL binlog entry diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h index d3b1b89e706..ec810405b5a 100644 --- a/storage/xtradb/include/trx0trx.h +++ b/storage/xtradb/include/trx0trx.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under @@ -52,7 +52,7 @@ UNIV_INLINE void trx_search_latch_release_if_reserved( /*=================================*/ - trx_t* trx __attribute__((unused))); /*!< in: transaction */ + trx_t* trx MY_ATTRIBUTE((unused))); /*!< in: transaction */ /******************************************************************//** Set detailed error message for the transaction. */ UNIV_INTERN @@ -106,7 +106,7 @@ void trx_free_prepared( /*==============*/ trx_t* trx) /*!< in, own: trx object */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); /********************************************************************//** Frees a transaction object for MySQL. */ UNIV_INTERN @@ -172,7 +172,7 @@ trx_start_for_ddl_low( /*==================*/ trx_t* trx, /*!< in/out: transaction */ trx_dict_op_t op) /*!< in: dictionary operation type */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG #define trx_start_for_ddl(t, o) \ @@ -194,7 +194,7 @@ void trx_commit( /*=======*/ trx_t* trx) /*!< in/out: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /****************************************************************//** Commits a transaction and a mini-transaction. */ UNIV_INTERN @@ -204,7 +204,7 @@ trx_commit_low( trx_t* trx, /*!< in/out: transaction */ mtr_t* mtr) /*!< in/out: mini-transaction (will be committed), or NULL if trx made no modifications */ - __attribute__((nonnull(1))); + MY_ATTRIBUTE((nonnull(1))); /****************************************************************//** Cleans up a transaction at database startup. The cleanup is needed if the transaction already got to the middle of a commit when the database @@ -258,7 +258,7 @@ void trx_commit_complete_for_mysql( /*==========================*/ trx_t* trx) /*!< in/out: transaction */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Marks the latest SQL statement ended. */ UNIV_INTERN @@ -286,7 +286,7 @@ trx_clone_read_view( /*================*/ trx_t* trx, /*!< in: receiver transaction */ trx_t* from_trx) /*!< in: donor transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /****************************************************************//** Prepares a transaction for commit/rollback. */ UNIV_INTERN @@ -331,7 +331,7 @@ trx_print_low( /*!< in: length of trx->lock.trx_locks */ ulint heap_size) /*!< in: mem_heap_get_size(trx->lock.lock_heap) */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Prints info about a transaction. @@ -345,7 +345,7 @@ trx_print_latched( const trx_t* trx, /*!< in: transaction */ ulint max_query_len) /*!< in: max query length to print, or 0 to use the default max length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Prints info about a transaction. @@ -358,7 +358,7 @@ trx_print( const trx_t* trx, /*!< in: transaction */ ulint max_query_len) /*!< in: max query length to print, or 0 to use the default max length */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Determine if a transaction is a dictionary operation. @@ -368,7 +368,7 @@ enum trx_dict_op_t trx_get_dict_operation( /*===================*/ const trx_t* trx) /*!< in: transaction */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /**********************************************************************//** Flag a transaction a dictionary operation. */ UNIV_INLINE @@ -397,7 +397,7 @@ trx_state_eq( if state != TRX_STATE_NOT_STARTED asserts that trx->state != TRX_STATE_NOT_STARTED */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # ifdef UNIV_DEBUG /**********************************************************************//** Asserts that a transaction has been started. @@ -408,7 +408,7 @@ ibool trx_assert_started( /*===============*/ const trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); # endif /* UNIV_DEBUG */ /**********************************************************************//** diff --git a/storage/xtradb/include/trx0trx.ic b/storage/xtradb/include/trx0trx.ic index 787931dc4b6..8582b63f806 100644 --- a/storage/xtradb/include/trx0trx.ic +++ b/storage/xtradb/include/trx0trx.ic @@ -171,7 +171,7 @@ UNIV_INLINE void trx_search_latch_release_if_reserved( /*=================================*/ - trx_t* trx __attribute__((unused))) /*!< in: transaction */ + trx_t* trx MY_ATTRIBUTE((unused))) /*!< in: transaction */ { ut_ad(!trx->has_search_latch); } diff --git a/storage/xtradb/include/trx0undo.h b/storage/xtradb/include/trx0undo.h index 660551961a6..190308112ba 100644 --- a/storage/xtradb/include/trx0undo.h +++ b/storage/xtradb/include/trx0undo.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -73,7 +73,7 @@ bool trx_undo_trx_id_is_insert( /*======================*/ const byte* trx_id) /*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */ - __attribute__((nonnull, pure, warn_unused_result)); + MY_ATTRIBUTE((nonnull, pure, warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ /*****************************************************************//** Writes a roll ptr to an index page. In case that the size changes in @@ -214,7 +214,7 @@ trx_undo_add_page( mtr_t* mtr) /*!< in: mtr which does not have a latch to any undo log page; the caller must have reserved the rollback segment mutex */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /********************************************************************//** Frees the last undo log page. The caller must hold the rollback segment mutex. */ @@ -229,7 +229,7 @@ trx_undo_free_last_page_func( mtr_t* mtr) /*!< in/out: mini-transaction which does not have a latch to any undo log page or which has allocated the undo log page */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG # define trx_undo_free_last_page(trx,undo,mtr) \ trx_undo_free_last_page_func(trx,undo,mtr) @@ -249,7 +249,7 @@ trx_undo_truncate_end( trx_undo_t* undo, /*!< in/out: undo log */ undo_no_t limit) /*!< in: all undo records with undo number >= this value should be truncated */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); /***********************************************************************//** Truncates an undo log from the start. This function is used during a purge @@ -291,7 +291,7 @@ trx_undo_assign_undo( /*=================*/ trx_t* trx, /*!< in: transaction */ ulint type) /*!< in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************//** Sets the state of the undo log segment at a transaction finish. @return undo log segment header page, x-latched */ @@ -341,7 +341,7 @@ void trx_undo_free_prepared( /*===================*/ trx_t* trx) /*!< in/out: PREPARED transaction */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); #endif /* !UNIV_HOTBACKUP */ /***********************************************************//** Parses the redo log entry of an undo log page initialization. diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index b0fe3f020d2..5320776c042 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2013, 2015, MariaDB Corporation. @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 29 +#define INNODB_VERSION_BUGFIX 31 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 76.2 +#define PERCONA_INNODB_VERSION 77.0 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ @@ -261,8 +261,9 @@ operations (very slow); also UNIV_DEBUG must be defined */ that are only referenced from within InnoDB, not from MySQL. We disable the GCC visibility directive on all Sun operating systems because there is no easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ +#define MY_ATTRIBUTE __attribute__ #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(sun) || defined(__INTEL_COMPILER) -# define UNIV_INTERN __attribute__((visibility ("hidden"))) +# define UNIV_INTERN MY_ATTRIBUTE((visibility ("hidden"))) #else # define UNIV_INTERN #endif @@ -277,7 +278,7 @@ appears close together improving code locality of non-cold parts of program. The paths leading to call of cold functions within code are marked as unlikely by the branch prediction mechanism. optimize a rarely invoked function for size instead for speed. */ -# define UNIV_COLD __attribute__((cold)) +# define UNIV_COLD MY_ATTRIBUTE((cold)) #else # define UNIV_COLD /* empty */ #endif @@ -583,7 +584,7 @@ contains the sum of the following flag and the locally stored len. */ #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER) #define HAVE_GCC_GT_2 /* Tell the compiler that variable/function is unused. */ -# define UNIV_UNUSED __attribute__ ((unused)) +# define UNIV_UNUSED MY_ATTRIBUTE ((unused)) #else # define UNIV_UNUSED #endif /* CHECK FOR GCC VER_GT_2 */ diff --git a/storage/xtradb/include/ut0byte.h b/storage/xtradb/include/ut0byte.h index 5bdd553ca80..4893ab9f9af 100644 --- a/storage/xtradb/include/ut0byte.h +++ b/storage/xtradb/include/ut0byte.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -39,7 +39,7 @@ ut_ull_create( /*==========*/ ulint high, /*!< in: high-order 32 bits */ ulint low) /*!< in: low-order 32 bits */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /********************************************************//** Rounds a 64-bit integer downward to a multiple of a power of 2. @@ -80,7 +80,7 @@ ut_align_down( /*==========*/ const void* ptr, /*!< in: pointer */ ulint align_no) /*!< in: align by this number */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*********************************************************//** The following function computes the offset of a pointer from the nearest aligned address. @@ -91,7 +91,7 @@ ut_align_offset( /*============*/ const void* ptr, /*!< in: pointer */ ulint align_no) /*!< in: align by this number */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*****************************************************************//** Gets the nth bit of a ulint. @return TRUE if nth bit is 1; 0th bit is defined to be the least significant */ diff --git a/storage/xtradb/include/ut0dbg.h b/storage/xtradb/include/ut0dbg.h index 6a4afe99597..3f5baef0a3c 100644 --- a/storage/xtradb/include/ut0dbg.h +++ b/storage/xtradb/include/ut0dbg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -59,7 +59,7 @@ ut_dbg_assertion_failed( const char* expr, /*!< in: the failed assertion */ const char* file, /*!< in: source file containing the assertion */ ulint line) /*!< in: line number of the assertion */ - UNIV_COLD __attribute__((nonnull(2))); + UNIV_COLD MY_ATTRIBUTE((nonnull(2))); /** Abort the execution. */ # define UT_DBG_PANIC abort() diff --git a/storage/xtradb/include/ut0mem.h b/storage/xtradb/include/ut0mem.h index af7eb4e9b1d..81470358f2f 100644 --- a/storage/xtradb/include/ut0mem.h +++ b/storage/xtradb/include/ut0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -87,7 +87,7 @@ ut_malloc_low( ulint n, /*!< in: number of bytes to allocate */ ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if the memory cannot be allocated */ - __attribute__((malloc)); + MY_ATTRIBUTE((malloc)); /**********************************************************************//** Allocates memory. */ #define ut_malloc(n) ut_malloc_low(n, TRUE) diff --git a/storage/xtradb/include/ut0rnd.h b/storage/xtradb/include/ut0rnd.h index 53b769849a5..6ed3ee3b2e5 100644 --- a/storage/xtradb/include/ut0rnd.h +++ b/storage/xtradb/include/ut0rnd.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,7 +96,7 @@ ulint ut_fold_ull( /*========*/ ib_uint64_t d) /*!< in: 64-bit integer */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*************************************************************//** Folds a character string ending in the null character. @return folded value */ @@ -105,7 +105,7 @@ ulint ut_fold_string( /*===========*/ const char* str) /*!< in: null-terminated string */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); /***********************************************************//** Looks for a prime number slightly greater than the given argument. The prime is chosen so that it is not near any power of 2. @@ -115,7 +115,7 @@ ulint ut_find_prime( /*==========*/ ulint n) /*!< in: positive number > 100 */ - __attribute__((const)); + MY_ATTRIBUTE((const)); #endif /* !UNIV_INNOCHECKSUM */ @@ -128,7 +128,7 @@ ut_fold_ulint_pair( /*===============*/ ulint n1, /*!< in: ulint */ ulint n2) /*!< in: ulint */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /*************************************************************//** Folds a binary string. @return folded value */ @@ -138,7 +138,7 @@ ut_fold_binary( /*===========*/ const byte* str, /*!< in: string of bytes */ ulint len) /*!< in: length */ - __attribute__((pure)); + MY_ATTRIBUTE((pure)); #ifndef UNIV_NONINL diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index 980ac337002..2df6bf58e6a 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -236,7 +236,7 @@ ulint ut_2_power_up( /*==========*/ ulint n) /*!< in: number != 0 */ - __attribute__((const)); + MY_ATTRIBUTE((const)); /** Determine how many bytes (groups of 8 bits) are needed to store the given number of bits. @@ -316,7 +316,7 @@ void ut_print_timestamp( /*===============*/ FILE* file) /*!< in: file where to print */ - UNIV_COLD __attribute__((nonnull)); + UNIV_COLD MY_ATTRIBUTE((nonnull)); #ifndef UNIV_INNOCHECKSUM @@ -516,7 +516,7 @@ ut_ulint_sort( ulint* aux_arr, /*!< in/out: aux array to use in sort */ ulint low, /*!< in: lower bound */ ulint high) /*!< in: upper bound */ - __attribute__((nonnull)); + MY_ATTRIBUTE((nonnull)); #ifndef UNIV_NONINL #include "ut0ut.ic" diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 7364c10c08e..8650cdd106a 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2014, 2015, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under @@ -429,7 +429,7 @@ ibool lock_rec_validate_page( /*===================*/ const buf_block_t* block) /*!< in: buffer block */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /* The lock system */ @@ -513,7 +513,7 @@ Checks that a transaction id is sensible, i.e., not in the future. #ifdef UNIV_DEBUG UNIV_INTERN #else -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) #endif bool lock_check_trx_id_sanity( @@ -661,6 +661,17 @@ lock_sys_close(void) mutex_free(&lock_sys->mutex); mutex_free(&lock_sys->wait_mutex); + os_event_free(lock_sys->timeout_event); + + for (srv_slot_t* slot = lock_sys->waiting_threads; + slot < lock_sys->waiting_threads + OS_THREAD_MAX_N; slot++) { + + ut_ad(!slot->in_use); + ut_ad(!slot->thr); + if (slot->event != NULL) + os_event_free(slot->event); + } + mem_free(lock_stack); mem_free(lock_sys); @@ -1630,7 +1641,7 @@ lock_rec_discard(lock_t* in_lock); /*********************************************************************//** Checks if some other transaction has a lock request in the queue. @return lock or NULL */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const lock_t* lock_rec_other_has_expl_req( /*========================*/ @@ -1681,6 +1692,10 @@ wsrep_kill_victim( { ut_ad(lock_mutex_own()); ut_ad(trx_mutex_own(lock->trx)); + + /* quit for native mysql */ + if (!wsrep_on(trx->mysql_thd)) return; + my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); @@ -1767,9 +1782,11 @@ lock_rec_other_has_conflicting( #ifdef WITH_WSREP if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { - trx_mutex_enter(lock->trx); - wsrep_kill_victim((trx_t *)trx, (lock_t *)lock); - trx_mutex_exit(lock->trx); + if (wsrep_on(trx->mysql_thd)) { + trx_mutex_enter(lock->trx); + wsrep_kill_victim(trx, lock); + trx_mutex_exit(lock->trx); + } #else if (lock_rec_has_to_wait(trx, mode, lock, is_supremum)) { #endif /* WITH_WSREP */ @@ -2075,7 +2092,9 @@ lock_rec_create( ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); #ifdef WITH_WSREP - if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + if (c_lock && + wsrep_on(trx->mysql_thd) && + wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; @@ -4044,7 +4063,7 @@ lock_get_next_lock( ut_ad(heap_no == ULINT_UNDEFINED); ut_ad(lock_get_type_low(lock) == LOCK_TABLE); - lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock); + lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock); } } while (lock != NULL && lock->trx->lock.deadlock_mark > ctx->mark_start); @@ -4094,7 +4113,8 @@ lock_get_first_lock( } else { *heap_no = ULINT_UNDEFINED; ut_ad(lock_get_type_low(lock) == LOCK_TABLE); - lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock); + dict_table_t* table = lock->un_member.tab_lock.table; + lock = UT_LIST_GET_FIRST(table->locks); } ut_a(lock != NULL); @@ -4566,8 +4586,6 @@ lock_deadlock_check_and_resolve( } #endif /* WITH_WSREP */ - MONITOR_INC(MONITOR_DEADLOCK); - } else if (victim_trx_id != 0 && victim_trx_id != trx->id) { ut_ad(victim_trx_id == ctx.wait_lock->trx->id); @@ -4576,14 +4594,15 @@ lock_deadlock_check_and_resolve( lock_deadlock_found = TRUE; MONITOR_INC(MONITOR_DEADLOCK); + srv_stats.lock_deadlock_count.inc(); } - } while (victim_trx_id != 0 && victim_trx_id != trx->id); /* If the joining transaction was selected as the victim. */ if (victim_trx_id != 0) { ut_a(victim_trx_id == trx->id); + MONITOR_INC(MONITOR_DEADLOCK); srv_stats.lock_deadlock_count.inc(); lock_deadlock_fputs("*** WE ROLL BACK TRANSACTION (2)\n"); @@ -4700,10 +4719,10 @@ lock_table_create( trx_mutex_exit(c_lock->trx); } } else { - UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); - } -#else +#endif /* WITH_WSREP */ UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); +#ifdef WITH_WSREP + } #endif /* WITH_WSREP */ if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) { @@ -5036,7 +5055,8 @@ lock_table( dberr_t err; const lock_t* wait_for; - ut_ad(table && thr); + ut_ad(table != NULL); + ut_ad(thr != NULL); if (flags & BTR_NO_LOCKING_FLAG) { @@ -6484,7 +6504,7 @@ lock_validate_table_locks( /*********************************************************************//** Validate record locks up to a limit. @return lock at limit or NULL if no more locks in the hash bucket */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const lock_t* lock_rec_validate( /*==============*/ diff --git a/storage/xtradb/lock/lock0wait.cc b/storage/xtradb/lock/lock0wait.cc index a87adcf94c0..c7bd223c491 100644 --- a/storage/xtradb/lock/lock0wait.cc +++ b/storage/xtradb/lock/lock0wait.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -512,7 +512,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(lock_wait_timeout_thread)( /*=====================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /* in: a dummy parameter required by os_thread_create */ { diff --git a/storage/xtradb/log/log0log.cc b/storage/xtradb/log/log0log.cc index 36531f3c6f4..0b5d27b8fd1 100644 --- a/storage/xtradb/log/log0log.cc +++ b/storage/xtradb/log/log0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved. @@ -1086,8 +1086,7 @@ log_group_init( ulint space_id, /*!< in: space id of the file space which contains the log files of this group */ - ulint archive_space_id __attribute__((unused))) - /*!< in: space id of the file space + ulint archive_space_id) /*!< in: space id of the file space which contains some archived log files for this group; currently, only for the first log group this is @@ -2642,7 +2641,7 @@ log_archived_file_name_gen( /*=======================*/ char* buf, /*!< in: buffer where to write */ ulint buf_len,/*!< in: buffer length */ - ulint id __attribute__((unused)), + ulint id MY_ATTRIBUTE((unused)), /*!< in: group id; currently we only archive the first group */ lsn_t file_no)/*!< in: file number */ @@ -3304,10 +3303,9 @@ log_archive_close_groups( Writes the log contents to the archive up to the lsn when this function was called, and stops the archiving. When archiving is started again, the archived log file numbers start from 2 higher, so that the archiving will not write -again to the archived log files which exist when this function returns. -@return DB_SUCCESS or DB_ERROR */ -UNIV_INTERN -ulint +again to the archived log files which exist when this function returns. */ +static +void log_archive_stop(void) /*==================*/ { @@ -3315,13 +3313,7 @@ log_archive_stop(void) mutex_enter(&(log_sys->mutex)); - if (log_sys->archiving_state != LOG_ARCH_ON) { - - mutex_exit(&(log_sys->mutex)); - - return(DB_ERROR); - } - + ut_ad(log_sys->archiving_state == LOG_ARCH_ON); log_sys->archiving_state = LOG_ARCH_STOPPING; mutex_exit(&(log_sys->mutex)); @@ -3363,8 +3355,6 @@ log_archive_stop(void) log_sys->archiving_state = LOG_ARCH_STOPPED; mutex_exit(&(log_sys->mutex)); - - return(DB_SUCCESS); } /****************************************************************//** @@ -4013,7 +4003,7 @@ log_print( "Log tracking enabled\n" "Log tracked up to " LSN_PF "\n" "Max tracked LSN age " LSN_PF "\n", - log_get_tracked_lsn_peek(), + log_get_tracked_lsn(), log_sys->max_checkpoint_age); } @@ -4110,6 +4100,7 @@ log_shutdown(void) rw_lock_free(&log_sys->checkpoint_lock); mutex_free(&log_sys->mutex); + mutex_free(&log_sys->log_flush_order_mutex); #ifdef UNIV_LOG_ARCHIVE rw_lock_free(&log_sys->archive_lock); diff --git a/storage/xtradb/log/log0online.cc b/storage/xtradb/log/log0online.cc index 51a9fa8f6c5..63f1ef39568 100644 --- a/storage/xtradb/log/log0online.cc +++ b/storage/xtradb/log/log0online.cc @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA *****************************************************************************/ @@ -290,7 +290,7 @@ log_online_read_bitmap_page( /* The following call prints an error message */ os_file_get_last_error(TRUE); ib_logf(IB_LOG_LEVEL_WARN, - "failed reading changed page bitmap file \'%s\'\n", + "failed reading changed page bitmap file \'%s\'", bitmap_file->name); return FALSE; } @@ -350,7 +350,7 @@ log_online_read_last_tracked_lsn(void) ib_logf(IB_LOG_LEVEL_WARN, "corruption detected in \'%s\' at offset " - UINT64PF "\n", + UINT64PF, log_bmp_sys->out.name, read_offset); } }; @@ -364,7 +364,7 @@ log_online_read_last_tracked_lsn(void) log_bmp_sys->out.offset)) { ib_logf(IB_LOG_LEVEL_WARN, "failed truncating changed page bitmap file \'%s\' to " - UINT64PF " bytes\n", + UINT64PF " bytes", log_bmp_sys->out.name, log_bmp_sys->out.offset); result = 0; } @@ -382,16 +382,8 @@ log_set_tracked_lsn( /*================*/ lsn_t tracked_lsn) /*!tracked_lsn, 0); - (void) os_atomic_increment_uint64(&log_sys->tracked_lsn, - tracked_lsn - old_value); -#else - mutex_enter(&log_sys->mutex); log_sys->tracked_lsn = tracked_lsn; - mutex_exit(&log_sys->mutex); -#endif + os_wmb; } /*********************************************************************//** @@ -416,7 +408,7 @@ log_online_can_track_missing( ib_logf(IB_LOG_LEVEL_ERROR, "last tracked LSN " LSN_PF " is ahead of tracking " "start LSN " LSN_PF ". This can be caused by " - "mismatched bitmap files.\n", + "mismatched bitmap files.", last_tracked_lsn, tracking_start_lsn); exit(1); } @@ -444,7 +436,7 @@ log_online_track_missing_on_startup( ib_logf(IB_LOG_LEVEL_WARN, "last tracked LSN in \'%s\' is " LSN_PF ", but the last checkpoint LSN is " LSN_PF ". This might be " - "due to a server crash or a very fast shutdown. ", + "due to a server crash or a very fast shutdown.", log_bmp_sys->out.name, last_tracked_lsn, tracking_start_lsn); /* See if we can fully recover the missing interval */ @@ -452,7 +444,7 @@ log_online_track_missing_on_startup( tracking_start_lsn)) { ib_logf(IB_LOG_LEVEL_INFO, - "reading the log to advance the last tracked LSN.\n"); + "reading the log to advance the last tracked LSN."); log_bmp_sys->start_lsn = ut_max(last_tracked_lsn, MIN_TRACKED_LSN); @@ -463,22 +455,22 @@ log_online_track_missing_on_startup( ut_ad(log_bmp_sys->end_lsn >= tracking_start_lsn); ib_logf(IB_LOG_LEVEL_INFO, - "continuing tracking changed pages from LSN " LSN_PF - "\n", log_bmp_sys->end_lsn); + "continuing tracking changed pages from LSN " LSN_PF, + log_bmp_sys->end_lsn); } else { ib_logf(IB_LOG_LEVEL_WARN, "the age of last tracked LSN exceeds log capacity, " "tracking-based incremental backups will work only " - "from the higher LSN!\n"); + "from the higher LSN!"); log_bmp_sys->end_lsn = log_bmp_sys->start_lsn = tracking_start_lsn; log_set_tracked_lsn(log_bmp_sys->start_lsn); ib_logf(IB_LOG_LEVEL_INFO, - "starting tracking changed pages from LSN " LSN_PF - "\n", log_bmp_sys->end_lsn); + "starting tracking changed pages from LSN " LSN_PF, + log_bmp_sys->end_lsn); } } @@ -546,7 +538,7 @@ log_online_start_bitmap_file(void) /* The following call prints an error message */ os_file_get_last_error(TRUE); ib_logf(IB_LOG_LEVEL_ERROR, - "cannot create \'%s\'\n", log_bmp_sys->out.name); + "cannot create \'%s\'", log_bmp_sys->out.name); return FALSE; } @@ -682,7 +674,7 @@ log_online_read_init(void) if (os_file_closedir(bitmap_dir)) { os_file_get_last_error(TRUE); - ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'\n", + ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'", log_bmp_sys->bmp_file_home); exit(1); } @@ -722,7 +714,7 @@ log_online_read_init(void) ib_logf(IB_LOG_LEVEL_WARN, "truncated block detected in \'%s\' at offset " - UINT64PF "\n", + UINT64PF, log_bmp_sys->out.name, log_bmp_sys->out.offset); log_bmp_sys->out.offset -= @@ -760,14 +752,14 @@ log_online_read_init(void) "last tracked LSN is " LSN_PF ", but the last " "checkpoint LSN is " LSN_PF ". The " "tracking-based incremental backups will work " - "only from the latter LSN!\n", + "only from the latter LSN!", last_tracked_lsn, tracking_start_lsn); } } ib_logf(IB_LOG_LEVEL_INFO, "starting tracking changed pages from LSN " - LSN_PF "\n", tracking_start_lsn); + LSN_PF, tracking_start_lsn); log_bmp_sys->start_lsn = tracking_start_lsn; log_set_tracked_lsn(tracking_start_lsn); } @@ -911,7 +903,7 @@ log_online_is_valid_log_seg( ib_logf(IB_LOG_LEVEL_ERROR, "log block checksum mismatch: expected " ULINTPF ", " - "calculated checksum " ULINTPF "\n", + "calculated checksum " ULINTPF, log_block_get_checksum(log_block), log_block_calc_checksum(log_block)); } @@ -1110,7 +1102,7 @@ log_online_write_bitmap_page( /* The following call prints an error message */ os_file_get_last_error(TRUE); ib_logf(IB_LOG_LEVEL_ERROR, "failed writing changed page " - "bitmap file \'%s\'\n", log_bmp_sys->out.name); + "bitmap file \'%s\'", log_bmp_sys->out.name); return FALSE; } @@ -1120,7 +1112,7 @@ log_online_write_bitmap_page( /* The following call prints an error message */ os_file_get_last_error(TRUE); ib_logf(IB_LOG_LEVEL_ERROR, "failed flushing changed page " - "bitmap file \'%s\'\n", log_bmp_sys->out.name); + "bitmap file \'%s\'", log_bmp_sys->out.name); return FALSE; } @@ -1267,8 +1259,7 @@ log_online_diagnose_inconsistent_dir( ib_logf(IB_LOG_LEVEL_WARN, "InnoDB: Warning: inconsistent bitmap file " "directory for a " - "INFORMATION_SCHEMA.INNODB_CHANGED_PAGES query" - "\n"); + "INFORMATION_SCHEMA.INNODB_CHANGED_PAGES query"); free(bitmap_files->files); } @@ -1310,7 +1301,7 @@ log_online_setup_bitmap_file_range( if (UNIV_UNLIKELY(!bitmap_dir)) { ib_logf(IB_LOG_LEVEL_ERROR, - "failed to open bitmap directory \'%s\'\n", + "failed to open bitmap directory \'%s\'", srv_data_home); return FALSE; } @@ -1360,7 +1351,7 @@ log_online_setup_bitmap_file_range( if (UNIV_UNLIKELY(os_file_closedir(bitmap_dir))) { os_file_get_last_error(TRUE); - ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'\n", + ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'", srv_data_home); return FALSE; } @@ -1381,7 +1372,7 @@ log_online_setup_bitmap_file_range( if (UNIV_UNLIKELY(!bitmap_dir)) { ib_logf(IB_LOG_LEVEL_ERROR, - "failed to open bitmap directory \'%s\'\n", + "failed to open bitmap directory \'%s\'", srv_data_home); return FALSE; } @@ -1432,7 +1423,7 @@ log_online_setup_bitmap_file_range( if (UNIV_UNLIKELY(os_file_closedir(bitmap_dir))) { os_file_get_last_error(TRUE); - ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'\n", + ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'", srv_data_home); free(bitmap_files->files); return FALSE; @@ -1507,7 +1498,7 @@ log_online_open_bitmap_file_read_only( /* Here and below assume that bitmap file names do not contain apostrophes, thus no need for ut_print_filename(). */ ib_logf(IB_LOG_LEVEL_WARN, - "error opening the changed page bitmap \'%s\'\n", + "error opening the changed page bitmap \'%s\'", bitmap_file->name); return FALSE; } @@ -1553,7 +1544,7 @@ log_online_diagnose_bitmap_eof( ib_logf(IB_LOG_LEVEL_WARN, "junk at the end of changed page bitmap file " - "\'%s\'.\n", bitmap_file->name); + "\'%s\'.", bitmap_file->name); } if (UNIV_UNLIKELY(!last_page_in_run)) { @@ -1564,7 +1555,7 @@ log_online_diagnose_bitmap_eof( for the whole server */ ib_logf(IB_LOG_LEVEL_WARN, "changed page bitmap file \'%s\' does not " - "contain a complete run at the end.\n", + "contain a complete run at the end.", bitmap_file->name); return FALSE; } @@ -1757,7 +1748,7 @@ log_online_bitmap_iterator_next( os_file_get_last_error(TRUE); ib_logf(IB_LOG_LEVEL_WARN, "failed reading changed page bitmap file " - "\'%s\'\n", i->in_files.files[i->in_i].name); + "\'%s\'", i->in_files.files[i->in_i].name); i->failed = TRUE; return FALSE; } diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index 23ca8b1381f..759687e3fe5 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. @@ -90,10 +90,6 @@ UNIV_INTERN recv_sys_t* recv_sys = NULL; otherwise. Note that this is FALSE while a background thread is rolling back incomplete transactions. */ UNIV_INTERN ibool recv_recovery_on; -#ifdef UNIV_LOG_ARCHIVE -/** TRUE when applying redo log records from an archived log file */ -UNIV_INTERN ibool recv_recovery_from_backup_on; -#endif /* UNIV_LOG_ARCHIVE */ #ifndef UNIV_HOTBACKUP /** TRUE when recv_init_crash_recovery() has been called. */ @@ -306,10 +302,6 @@ recv_sys_var_init(void) recv_recovery_on = FALSE; -#ifdef UNIV_LOG_ARCHIVE - recv_recovery_from_backup_on = FALSE; -#endif /* UNIV_LOG_ARCHIVE */ - recv_needed_recovery = FALSE; recv_lsn_checks_on = FALSE; @@ -341,7 +333,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(recv_writer_thread)( /*===============================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -760,7 +752,7 @@ recv_check_cp_is_consistent( /********************************************************//** Looks for the maximum consistent checkpoint from the log groups. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t recv_find_max_checkpoint( /*=====================*/ @@ -783,8 +775,38 @@ recv_find_max_checkpoint( buf = log_sys->checkpoint_buf; while (group) { + + ulint log_hdr_log_block_size; + group->state = LOG_GROUP_CORRUPTED; + /* Assert that we can reuse log_sys->checkpoint_buf to read the + part of the header that contains the log block size. */ + ut_ad(LOG_FILE_OS_FILE_LOG_BLOCK_SIZE + 4 + < OS_FILE_LOG_BLOCK_SIZE); + + fil_io(OS_FILE_READ | OS_FILE_LOG, true, group->space_id, 0, + 0, 0, OS_FILE_LOG_BLOCK_SIZE, + log_sys->checkpoint_buf, NULL, NULL); + log_hdr_log_block_size + = mach_read_from_4(log_sys->checkpoint_buf + + LOG_FILE_OS_FILE_LOG_BLOCK_SIZE); + if (log_hdr_log_block_size == 0) { + /* 0 means default value */ + log_hdr_log_block_size = 512; + } + if (UNIV_UNLIKELY(log_hdr_log_block_size + != srv_log_block_size)) { + fprintf(stderr, + "InnoDB: Error: The block size of ib_logfile " + "%lu is not equal to innodb_log_block_size " + "%lu.\n" + "InnoDB: Error: Suggestion - Recreate log " + "files.\n", + log_hdr_log_block_size, srv_log_block_size); + return(DB_ERROR); + } + for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { @@ -3105,7 +3127,6 @@ recv_recovery_from_checkpoint_start_func( log_group_t* group; log_group_t* max_cp_group; ulint max_cp_field; - ulint log_hdr_log_block_size; lsn_t checkpoint_lsn; ib_uint64_t checkpoint_no; lsn_t group_scanned_lsn = 0; @@ -3212,21 +3233,6 @@ recv_recovery_from_checkpoint_start_func( log_hdr_buf, max_cp_group, 0); } - log_hdr_log_block_size - = mach_read_from_4(log_hdr_buf + LOG_FILE_OS_FILE_LOG_BLOCK_SIZE); - if (log_hdr_log_block_size == 0) { - /* 0 means default value */ - log_hdr_log_block_size = 512; - } - if (UNIV_UNLIKELY(log_hdr_log_block_size != srv_log_block_size)) { - fprintf(stderr, - "InnoDB: Error: The block size of ib_logfile (" ULINTPF - ") is not equal to innodb_log_block_size.\n" - "InnoDB: Error: Suggestion - Recreate log files.\n", - log_hdr_log_block_size); - return(DB_ERROR); - } - #ifdef UNIV_LOG_ARCHIVE group = UT_LIST_GET_FIRST(log_sys->log_groups); @@ -3779,332 +3785,6 @@ recv_reset_log_files_for_backup( } #endif /* UNIV_HOTBACKUP */ -#ifdef UNIV_LOG_ARCHIVE -/******************************************************//** -Reads from the archive of a log group and performs recovery. -@return TRUE if no more complete consistent archive files */ -static -ibool -log_group_recover_from_archive_file( -/*================================*/ - log_group_t* group) /*!< in: log group */ -{ - os_file_t file_handle; - ib_uint64_t start_lsn; - ib_uint64_t file_end_lsn; - ib_uint64_t dummy_lsn; - ib_uint64_t scanned_lsn; - ulint len; - ibool ret; - byte* buf; - os_offset_t read_offset; - os_offset_t file_size; - int input_char; - char name[OS_FILE_MAX_PATH]; - dberr_t err; - - ut_a(0); - -try_open_again: - buf = log_sys->buf; - - /* Add the file to the archive file space; open the file */ - - log_archived_file_name_gen(name, sizeof(name), - group->id, group->archived_file_no); - - file_handle = os_file_create(innodb_file_log_key, - name, OS_FILE_OPEN, - OS_FILE_LOG, OS_FILE_AIO, &ret, FALSE); - - if (ret == FALSE) { -ask_again: - fprintf(stderr, - "InnoDB: Do you want to copy additional" - " archived log files\n" - "InnoDB: to the directory\n"); - fprintf(stderr, - "InnoDB: or were these all the files needed" - " in recovery?\n"); - fprintf(stderr, - "InnoDB: (Y == copy more files; N == this is all)?"); - - input_char = getchar(); - - if (input_char == (int) 'N') { - - return(TRUE); - } else if (input_char == (int) 'Y') { - - goto try_open_again; - } else { - goto ask_again; - } - } - - file_size = os_file_get_size(file_handle); - ut_a(file_size != (os_offset_t) -1); - - fprintf(stderr, "InnoDB: Opened archived log file %s\n", name); - - ret = os_file_close(file_handle); - - if (file_size < LOG_FILE_HDR_SIZE) { - fprintf(stderr, - "InnoDB: Archive file header incomplete %s\n", name); - - return(TRUE); - } - - ut_a(ret); - - /* Add the archive file as a node to the space */ - - ut_a(fil_node_create(name, 1 + file_size / UNIV_PAGE_SIZE, - group->archive_space_id, FALSE)); - ut_a(RECV_SCAN_SIZE >= LOG_FILE_HDR_SIZE); - - /* Read the archive file header */ - fil_io(OS_FILE_READ | OS_FILE_LOG, true, group->archive_space_id, 0, - 0, 0, - LOG_FILE_HDR_SIZE, buf, NULL, 0); - - /* Check if the archive file header is consistent */ - - if (mach_read_from_4(buf + LOG_GROUP_ID) != group->id - || mach_read_from_8(buf + LOG_FILE_START_LSN) - != group->archived_file_no) { - fprintf(stderr, - "InnoDB: Archive file header inconsistent %s\n", name); - - return(TRUE); - } - - if (!mach_read_from_4(buf + LOG_FILE_ARCH_COMPLETED)) { - fprintf(stderr, - "InnoDB: Archive file not completely written %s\n", - name); - - return(TRUE); - } - - start_lsn = mach_read_from_8(buf + LOG_FILE_START_LSN); - file_end_lsn = mach_read_from_8(buf + LOG_FILE_END_LSN); - - if (!recv_sys->scanned_lsn) { - - if (recv_sys->parse_start_lsn < start_lsn) { - fprintf(stderr, - "InnoDB: Archive log file %s" - " starts from too big a lsn\n", - name); - return(TRUE); - } - - recv_sys->scanned_lsn = start_lsn; - } - - if (recv_sys->scanned_lsn != start_lsn) { - - fprintf(stderr, - "InnoDB: Archive log file %s starts from" - " a wrong lsn\n", - name); - return(TRUE); - } - - read_offset = LOG_FILE_HDR_SIZE; - - for (;;) { - len = RECV_SCAN_SIZE; - - if (read_offset + len > file_size) { - len = ut_calc_align_down(file_size - read_offset, - OS_FILE_LOG_BLOCK_SIZE); - } - - if (len == 0) { - - break; - } - -#ifdef UNIV_DEBUG - if (log_debug_writes) { - fprintf(stderr, - "InnoDB: Archive read starting at" - " lsn " LSN_PF ", len %lu from file %s\n", - start_lsn, - (ulong) len, name); - } -#endif /* UNIV_DEBUG */ - - fil_io(OS_FILE_READ | OS_FILE_LOG, true, - group->archive_space_id, 0, - read_offset / UNIV_PAGE_SIZE, - read_offset % UNIV_PAGE_SIZE, len, buf, NULL, 0); - - ret = recv_scan_log_recs( - (buf_pool_get_n_pages() - - (recv_n_pool_free_frames * srv_buf_pool_instances)) - * UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn, - &dummy_lsn, &scanned_lsn, &err); - - if (err != DB_SUCCESS) { - return(FALSE); - } - - if (scanned_lsn == file_end_lsn) { - - return(FALSE); - } - - if (ret) { - fprintf(stderr, - "InnoDB: Archive log file %s" - " does not scan right\n", - name); - return(TRUE); - } - - read_offset += len; - start_lsn += len; - - ut_ad(start_lsn == scanned_lsn); - } - - return(FALSE); -} - -/********************************************************//** -Recovers from archived log files, and also from log files, if they exist. -@return error code or DB_SUCCESS */ -UNIV_INTERN -dberr_t -recv_recovery_from_archive_start( -/*=============================*/ - ib_uint64_t min_flushed_lsn,/*!< in: min flushed lsn field from the - data files */ - ib_uint64_t limit_lsn, /*!< in: recover up to this lsn if - possible */ - lsn_t first_log_no) /*!< in: number of the first archived - log file to use in the recovery; the - file will be searched from - INNOBASE_LOG_ARCH_DIR specified in - server config file */ -{ - log_group_t* group; - ulint group_id; - ulint trunc_len; - ibool ret; - dberr_t err; - - ut_a(0); - - recv_sys_create(); - recv_sys_init(buf_pool_get_curr_size()); - - recv_recovery_on = TRUE; - recv_recovery_from_backup_on = TRUE; - - recv_sys->limit_lsn = limit_lsn; - - group_id = 0; - - group = UT_LIST_GET_FIRST(log_sys->log_groups); - - while (group) { - if (group->id == group_id) { - - break; - } - - group = UT_LIST_GET_NEXT(log_groups, group); - } - - if (!group) { - fprintf(stderr, - "InnoDB: There is no log group defined with id %lu!\n", - (ulong) group_id); - return(DB_ERROR); - } - - group->archived_file_no = first_log_no; - - recv_sys->parse_start_lsn = min_flushed_lsn; - - recv_sys->scanned_lsn = 0; - recv_sys->scanned_checkpoint_no = 0; - recv_sys->recovered_lsn = recv_sys->parse_start_lsn; - - recv_sys->archive_group = group; - - ret = FALSE; - - mutex_enter(&(log_sys->mutex)); - - while (!ret) { - ret = log_group_recover_from_archive_file(group); - - /* Close and truncate a possible processed archive file - from the file space */ - - trunc_len = UNIV_PAGE_SIZE - * fil_space_get_size(group->archive_space_id); - if (trunc_len > 0) { - fil_space_truncate_start(group->archive_space_id, - trunc_len); - } - - group->archived_file_no += group->file_size - LOG_FILE_HDR_SIZE; - } - - if (recv_sys->recovered_lsn < limit_lsn) { - - if (!recv_sys->scanned_lsn) { - - recv_sys->scanned_lsn = recv_sys->parse_start_lsn; - } - - mutex_exit(&(log_sys->mutex)); - - err = recv_recovery_from_checkpoint_start(LOG_ARCHIVE, - limit_lsn, - LSN_MAX, - LSN_MAX); - if (err != DB_SUCCESS) { - - return(err); - } - - mutex_enter(&(log_sys->mutex)); - } - - if (limit_lsn != LSN_MAX) { - - recv_apply_hashed_log_recs(FALSE); - - recv_reset_logs(0, FALSE, recv_sys->recovered_lsn); - } - - mutex_exit(&(log_sys->mutex)); - - return(DB_SUCCESS); -} - -/********************************************************//** -Completes recovery from archive. */ -UNIV_INTERN -void -recv_recovery_from_archive_finish(void) -/*===================================*/ -{ - recv_recovery_from_checkpoint_finish(); - - recv_recovery_from_backup_on = FALSE; -} -#endif /* UNIV_LOG_ARCHIVE */ - - void recv_dblwr_t::add(byte* page) { pages.push_back(page); diff --git a/storage/xtradb/mem/mem0dbg.cc b/storage/xtradb/mem/mem0dbg.cc index 308c2979551..a77785a369a 100644 --- a/storage/xtradb/mem/mem0dbg.cc +++ b/storage/xtradb/mem/mem0dbg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -248,7 +248,7 @@ void mem_field_erase( /*============*/ byte* buf, /*!< in: memory field */ - ulint n __attribute__((unused))) + ulint n MY_ATTRIBUTE((unused))) /*!< in: how many bytes the user requested */ { byte* usr_buf; @@ -450,7 +450,7 @@ void mem_heap_validate_or_print( /*=======================*/ mem_heap_t* heap, /*!< in: memory heap */ - byte* top __attribute__((unused)), + byte* top MY_ATTRIBUTE((unused)), /*!< in: calculate and validate only until this top pointer in the heap is reached, if this pointer is NULL, ignored */ diff --git a/storage/xtradb/mem/mem0pool.cc b/storage/xtradb/mem/mem0pool.cc index fe9a84d21fa..42d0417c768 100644 --- a/storage/xtradb/mem/mem0pool.cc +++ b/storage/xtradb/mem/mem0pool.cc @@ -280,6 +280,7 @@ mem_pool_free( /*==========*/ mem_pool_t* pool) /*!< in, own: memory pool */ { + mutex_free(&pool->mutex); ut_free(pool->buf); ut_free(pool); } diff --git a/storage/xtradb/mtr/mtr0mtr.cc b/storage/xtradb/mtr/mtr0mtr.cc index 4010fcce7ed..a1d7261e43c 100644 --- a/storage/xtradb/mtr/mtr0mtr.cc +++ b/storage/xtradb/mtr/mtr0mtr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -59,7 +59,7 @@ mtr_block_dirtied( /*****************************************************************//** Releases the item in the slot given. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void mtr_memo_slot_release_func( /*=======================*/ @@ -106,7 +106,7 @@ mtr_memo_slot_release_func( Releases the mlocks and other objects stored in an mtr memo. They are released in the order opposite to which they were pushed to the memo. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void mtr_memo_pop_all( /*=============*/ @@ -398,7 +398,7 @@ mtr_read_ulint( /*===========*/ const byte* ptr, /*!< in: pointer from where to read */ ulint type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ - mtr_t* mtr __attribute__((unused))) + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { ut_ad(mtr->state == MTR_ACTIVE); diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index 4010ef10359..007b100285d 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2016, MariaDB Corporation. @@ -553,6 +553,42 @@ PIMAGE_TLS_CALLBACK p_thread_callback_base = win_tls_thread_exit; } #endif /*_WIN32 */ +/***********************************************************************//** +For an EINVAL I/O error, prints a diagnostic message if innodb_flush_method +== ALL_O_DIRECT. +@return true if the diagnostic message was printed +@return false if the diagnostic message does not apply */ +static +bool +os_diagnose_all_o_direct_einval( +/*============================*/ + ulint err) /*!< in: C error code */ +{ + if ((err == EINVAL) + && (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT)) { + ib_logf(IB_LOG_LEVEL_INFO, + "The error might be caused by redo log I/O not " + "satisfying innodb_flush_method=ALL_O_DIRECT " + "requirements by the underlying file system."); + if (srv_log_block_size != 512) + ib_logf(IB_LOG_LEVEL_INFO, + "This might be caused by an incompatible " + "non-default innodb_log_block_size value %lu.", + srv_log_block_size); + ib_logf(IB_LOG_LEVEL_INFO, + "Please file a bug at https://bugs.percona.com and " + "include this error message, my.cnf settings, and " + "information about the file system where the redo log " + "resides."); + ib_logf(IB_LOG_LEVEL_INFO, + "A possible workaround is to change " + "innodb_flush_method value to something else " + "than ALL_O_DIRECT."); + return(true); + } + return(false); +} + /***********************************************************************//** Retrieves the last error number if an error occurs in a file io function. The number should be retrieved before any other OS calls (because they may @@ -717,7 +753,7 @@ os_file_get_last_error_low( "InnoDB: Error trying to enable atomic writes on " "non-supported destination!\n"); } - } else { + } else if (!os_diagnose_all_o_direct_einval(err)) { if (strerror(err) != NULL) { fprintf(stderr, "InnoDB: Error number %d" @@ -974,7 +1010,7 @@ os_file_lock( #ifndef UNIV_HOTBACKUP /****************************************************************//** Creates the seek mutexes used in positioned reads and writes. */ -UNIV_INTERN +static void os_io_init_simple(void) /*===================*/ @@ -1781,11 +1817,11 @@ void os_file_set_nocache( /*================*/ os_file_t fd /*!< in: file descriptor to alter */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), const char* file_name /*!< in: used in the diagnostic message */ - __attribute__((unused)), - const char* operation_name __attribute__((unused))) + MY_ATTRIBUTE((unused)), + const char* operation_name MY_ATTRIBUTE((unused))) /*!< in: "open" or "create"; used in the diagnostic message */ { @@ -1837,14 +1873,14 @@ short_warning: Tries to enable the atomic write feature, if available, for the specified file handle. @return TRUE if success */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool os_file_set_atomic_writes( /*======================*/ const char* name /*!< in: name of the file */ - __attribute__((unused)), + MY_ATTRIBUTE((unused)), os_file_t file /*!< in: handle to the file */ - __attribute__((unused))) + MY_ATTRIBUTE((unused))) { #ifdef DFS_IOCTL_ATOMIC_WRITE_SET @@ -2528,7 +2564,7 @@ os_file_set_size( ib_logf(IB_LOG_LEVEL_ERROR, "preallocating file " "space for file \'%s\' failed. Current size " - INT64PF ", desired size " INT64PF "\n", + INT64PF ", desired size " INT64PF, name, current_size, size); os_file_handle_error_no_exit (name, "posix_fallocate", FALSE, __FILE__, __LINE__); @@ -2790,7 +2826,7 @@ os_file_flush_func( /*******************************************************************//** Does a synchronous read operation in Posix. @return number of bytes read, -1 if error */ -static __attribute__((nonnull(2), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(2), warn_unused_result)) ssize_t os_file_pread( /*==========*/ @@ -2953,7 +2989,7 @@ os_file_pread( /*******************************************************************//** Does a synchronous write operation in Posix. @return number of bytes written, -1 if error */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ssize_t os_file_pwrite( /*===========*/ @@ -2998,6 +3034,9 @@ os_file_pwrite( /* Handle partial writes and signal interruptions correctly */ for (ret = 0; ret < (ssize_t) n; ) { n_written = pwrite(file, buf, (ssize_t)n - ret, offs); + DBUG_EXECUTE_IF("xb_simulate_all_o_direct_write_failure", + n_written = -1; + errno = EINVAL;); if (n_written >= 0) { ret += n_written; offs += n_written; @@ -3143,6 +3182,10 @@ try_again: try_again: ret = os_file_pread(file, buf, n, offset, trx); + DBUG_EXECUTE_IF("xb_simulate_all_o_direct_read_failure", + ret = -1; + errno = EINVAL;); + if ((ulint) ret == n) { return(TRUE); } else if (ret == -1) { @@ -3472,6 +3515,8 @@ retry: "InnoDB: " REFMAN "operating-system-error-codes.html\n"); + os_diagnose_all_o_direct_einval(errno); + os_has_said_disk_full = TRUE; } @@ -4439,6 +4484,14 @@ os_aio_free(void) os_event_free(os_aio_segment_wait_events[i]); } +#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8 + os_mutex_free(os_file_count_mutex); +#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */ + + for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) { + os_mutex_free(os_file_seek_mutexes[i]); + } + ut_free(os_aio_segment_wait_events); os_aio_segment_wait_events = 0; os_aio_n_segments = 0; @@ -6126,7 +6179,7 @@ os_aio_print( srv_io_thread_function[i]); #ifndef __WIN__ - if (os_aio_segment_wait_events[i]->is_set) { + if (os_aio_segment_wait_events[i]->is_set()) { fprintf(file, " ev set"); } #endif /* __WIN__ */ diff --git a/storage/xtradb/os/os0sync.cc b/storage/xtradb/os/os0sync.cc index 03c53848832..a494be537d9 100644 --- a/storage/xtradb/os/os0sync.cc +++ b/storage/xtradb/os/os0sync.cc @@ -47,27 +47,14 @@ struct os_mutex_t{ do not assume that the OS mutex supports recursive locking, though NT seems to do that */ - UT_LIST_NODE_T(os_mutex_t) os_mutex_list; - /* list of all 'slow' OS mutexes created */ }; -/** Mutex protecting counts and the lists of OS mutexes and events */ -UNIV_INTERN os_ib_mutex_t os_sync_mutex; -/** TRUE if os_sync_mutex has been initialized */ -static ibool os_sync_mutex_inited = FALSE; -/** TRUE when os_sync_free() is being executed */ -static ibool os_sync_free_called = FALSE; +// All the os_*_count variables are accessed atomically /** This is incremented by 1 in os_thread_create and decremented by 1 in -os_thread_exit */ +os_thread_exit. */ UNIV_INTERN ulint os_thread_count = 0; -/** The list of all events created */ -static UT_LIST_BASE_NODE_T(os_event) os_event_list; - -/** The list of all OS 'slow' mutexes */ -static UT_LIST_BASE_NODE_T(os_mutex_t) os_mutex_list; - UNIV_INTERN ulint os_event_count = 0; UNIV_INTERN ulint os_mutex_count = 0; UNIV_INTERN ulint os_fast_mutex_count = 0; @@ -80,11 +67,6 @@ UNIV_INTERN mysql_pfs_key_t event_os_mutex_key; UNIV_INTERN mysql_pfs_key_t os_mutex_key; #endif -/* Because a mutex is embedded inside an event and there is an -event embedded inside a mutex, on free, this generates a recursive call. -This version of the free event function doesn't acquire the global lock */ -static void os_event_free_internal(os_event_t event); - /* On Windows (Vista and later), load function pointers for condition variable handling. Those functions are not available in prior versions, so we have to use them via runtime loading, as long as we support XP. */ @@ -289,55 +271,43 @@ void os_sync_init(void) /*==============*/ { - UT_LIST_INIT(os_event_list); - UT_LIST_INIT(os_mutex_list); - - os_sync_mutex = NULL; - os_sync_mutex_inited = FALSE; - /* Now for Windows only */ os_cond_module_init(); - - os_sync_mutex = os_mutex_create(); - - os_sync_mutex_inited = TRUE; } -/*********************************************************//** -Frees created events and OS 'slow' mutexes. */ +/** Create an event semaphore, i.e., a semaphore which may just have two +states: signaled and nonsignaled. The created event is manual reset: it must be +reset explicitly by calling sync_os_reset_event. +@param[in,out] event memory block where to create the event */ UNIV_INTERN void -os_sync_free(void) -/*==============*/ +os_event_create(os_event_t event) { - os_event_t event; - os_ib_mutex_t mutex; +#ifdef __WIN__ + if(!srv_use_native_conditions) { - os_sync_free_called = TRUE; - event = UT_LIST_GET_FIRST(os_event_list); - - while (event) { - - os_event_free(event); - - event = UT_LIST_GET_FIRST(os_event_list); - } - - mutex = UT_LIST_GET_FIRST(os_mutex_list); - - while (mutex) { - if (mutex == os_sync_mutex) { - /* Set the flag to FALSE so that we do not try to - reserve os_sync_mutex any more in remaining freeing - operations in shutdown */ - os_sync_mutex_inited = FALSE; + event->handle = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!event->handle) { + fprintf(stderr, + "InnoDB: Could not create a Windows event" + " semaphore; Windows error %lu\n", + (ulong) GetLastError()); } + } else /* Windows with condition variables */ +#endif + { +#ifndef PFS_SKIP_EVENT_MUTEX + os_fast_mutex_init(event_os_mutex_key, &event->os_mutex); +#else + os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &event->os_mutex); +#endif - os_mutex_free(mutex); + os_cond_init(&(event->cond_var)); - mutex = UT_LIST_GET_FIRST(os_mutex_list); + event->init_count_and_set(); } - os_sync_free_called = FALSE; + + os_atomic_increment_ulint(&os_event_count, 1); } /*********************************************************//** @@ -350,59 +320,9 @@ os_event_t os_event_create(void) /*==================*/ { - os_event_t event; + os_event_t event = static_cast(ut_malloc(sizeof(*event))); -#ifdef __WIN__ - if(!srv_use_native_conditions) { - - event = static_cast(ut_malloc(sizeof(*event))); - - event->handle = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!event->handle) { - fprintf(stderr, - "InnoDB: Could not create a Windows event" - " semaphore; Windows error %lu\n", - (ulong) GetLastError()); - } - } else /* Windows with condition variables */ -#endif - { - event = static_cast(ut_malloc(sizeof *event)); - -#ifndef PFS_SKIP_EVENT_MUTEX - os_fast_mutex_init(event_os_mutex_key, &event->os_mutex); -#else - os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &event->os_mutex); -#endif - - os_cond_init(&(event->cond_var)); - - event->is_set = FALSE; - - /* We return this value in os_event_reset(), which can then be - be used to pass to the os_event_wait_low(). The value of zero - is reserved in os_event_wait_low() for the case when the - caller does not want to pass any signal_count value. To - distinguish between the two cases we initialize signal_count - to 1 here. */ - event->signal_count = 1; - } - - /* The os_sync_mutex can be NULL because during startup an event - can be created [ because it's embedded in the mutex/rwlock ] before - this module has been initialized */ - if (os_sync_mutex != NULL) { - os_mutex_enter(os_sync_mutex); - } - - /* Put to the list of events */ - UT_LIST_ADD_FIRST(os_event_list, os_event_list, event); - - os_event_count++; - - if (os_sync_mutex != NULL) { - os_mutex_exit(os_sync_mutex); - } + os_event_create(event); return(event); } @@ -427,11 +347,11 @@ os_event_set( os_fast_mutex_lock(&(event->os_mutex)); - if (event->is_set) { + if (UNIV_UNLIKELY(event->is_set())) { /* Do nothing */ } else { - event->is_set = TRUE; - event->signal_count += 1; + event->set(); + event->inc_signal_count(); os_cond_broadcast(&(event->cond_var)); } @@ -465,55 +385,26 @@ os_event_reset( os_fast_mutex_lock(&(event->os_mutex)); - if (!event->is_set) { + if (UNIV_UNLIKELY(!event->is_set())) { /* Do nothing */ } else { - event->is_set = FALSE; + event->reset(); } - ret = event->signal_count; + ret = event->signal_count(); os_fast_mutex_unlock(&(event->os_mutex)); return(ret); } -/**********************************************************//** -Frees an event object, without acquiring the global lock. */ -static -void -os_event_free_internal( -/*===================*/ - os_event_t event) /*!< in: event to free */ -{ -#ifdef __WIN__ - if(!srv_use_native_conditions) { - ut_a(event); - ut_a(CloseHandle(event->handle)); - } else -#endif - { - ut_a(event); - - /* This is to avoid freeing the mutex twice */ - os_fast_mutex_free(&(event->os_mutex)); - - os_cond_destroy(&(event->cond_var)); - } - - /* Remove from the list of events */ - UT_LIST_REMOVE(os_event_list, os_event_list, event); - - os_event_count--; - - ut_free(event); -} - /**********************************************************//** Frees an event object. */ UNIV_INTERN void os_event_free( /*==========*/ - os_event_t event) /*!< in: event to free */ + os_event_t event, /*!< in: event to free */ + bool free_memory)/*!< in: if true, deallocate the event + memory block too */ { ut_a(event); @@ -528,16 +419,10 @@ os_event_free( os_cond_destroy(&(event->cond_var)); } - /* Remove from the list of events */ - os_mutex_enter(os_sync_mutex); + os_atomic_decrement_ulint(&os_event_count, 1); - UT_LIST_REMOVE(os_event_list, os_event_list, event); - - os_event_count--; - - os_mutex_exit(os_sync_mutex); - - ut_free(event); + if (free_memory) + ut_free(event); } /**********************************************************//** @@ -585,10 +470,10 @@ os_event_wait_low( os_fast_mutex_lock(&event->os_mutex); if (!reset_sig_count) { - reset_sig_count = event->signal_count; + reset_sig_count = event->signal_count(); } - while (!event->is_set && event->signal_count == reset_sig_count) { + while (!event->is_set() && event->signal_count() == reset_sig_count) { os_cond_wait(&(event->cond_var), &(event->os_mutex)); /* Solaris manual said that spurious wakeups may occur: we @@ -686,11 +571,12 @@ os_event_wait_time_low( os_fast_mutex_lock(&event->os_mutex); if (!reset_sig_count) { - reset_sig_count = event->signal_count; + reset_sig_count = event->signal_count(); } do { - if (event->is_set || event->signal_count != reset_sig_count) { + if (event->is_set() + || event->signal_count() != reset_sig_count) { break; } @@ -734,18 +620,7 @@ os_mutex_create(void) mutex_str->count = 0; mutex_str->event = os_event_create(); - if (UNIV_LIKELY(os_sync_mutex_inited)) { - /* When creating os_sync_mutex itself we cannot reserve it */ - os_mutex_enter(os_sync_mutex); - } - - UT_LIST_ADD_FIRST(os_mutex_list, os_mutex_list, mutex_str); - - os_mutex_count++; - - if (UNIV_LIKELY(os_sync_mutex_inited)) { - os_mutex_exit(os_sync_mutex); - } + os_atomic_increment_ulint(&os_mutex_count, 1); return(mutex_str); } @@ -791,21 +666,9 @@ os_mutex_free( { ut_a(mutex); - if (UNIV_LIKELY(!os_sync_free_called)) { - os_event_free_internal(mutex->event); - } + os_event_free(mutex->event); - if (UNIV_LIKELY(os_sync_mutex_inited)) { - os_mutex_enter(os_sync_mutex); - } - - UT_LIST_REMOVE(os_mutex_list, os_mutex_list, mutex); - - os_mutex_count--; - - if (UNIV_LIKELY(os_sync_mutex_inited)) { - os_mutex_exit(os_sync_mutex); - } + os_atomic_decrement_ulint(&os_mutex_count, 1); os_fast_mutex_free(static_cast(mutex->handle)); ut_free(mutex->handle); @@ -827,18 +690,7 @@ os_fast_mutex_init_func( #else ut_a(0 == pthread_mutex_init(fast_mutex, MY_MUTEX_INIT_FAST)); #endif - if (UNIV_LIKELY(os_sync_mutex_inited)) { - /* When creating os_sync_mutex itself (in Unix) we cannot - reserve it */ - - os_mutex_enter(os_sync_mutex); - } - - os_fast_mutex_count++; - - if (UNIV_LIKELY(os_sync_mutex_inited)) { - os_mutex_exit(os_sync_mutex); - } + os_atomic_increment_ulint(&os_fast_mutex_count, 1); } /**********************************************************//** @@ -919,17 +771,6 @@ os_fast_mutex_free_func( putc('\n', stderr); } #endif - if (UNIV_LIKELY(os_sync_mutex_inited)) { - /* When freeing the last mutexes, we have - already freed os_sync_mutex */ - os_mutex_enter(os_sync_mutex); - } - - ut_ad(os_fast_mutex_count > 0); - os_fast_mutex_count--; - - if (UNIV_LIKELY(os_sync_mutex_inited)) { - os_mutex_exit(os_sync_mutex); - } + os_atomic_decrement_ulint(&os_fast_mutex_count, 1); } diff --git a/storage/xtradb/os/os0thread.cc b/storage/xtradb/os/os0thread.cc index 8420a94787b..aabdd06d76b 100644 --- a/storage/xtradb/os/os0thread.cc +++ b/storage/xtradb/os/os0thread.cc @@ -145,9 +145,7 @@ os_thread_create_func( os_thread_t thread; DWORD win_thread_id; - os_mutex_enter(os_sync_mutex); - os_thread_count++; - os_mutex_exit(os_sync_mutex); + os_atomic_increment_ulint(&os_thread_count, 1); thread = CreateThread(NULL, /* no security attributes */ 0, /* default size stack */ @@ -186,9 +184,8 @@ os_thread_create_func( exit(1); } #endif - os_mutex_enter(os_sync_mutex); - os_thread_count++; - os_mutex_exit(os_sync_mutex); + ulint new_count = os_atomic_increment_ulint(&os_thread_count, 1); + ut_a(new_count <= OS_THREAD_MAX_N); #ifdef UNIV_HPUX10 ret = pthread_create(&pthread, pthread_attr_default, func, arg); @@ -205,8 +202,6 @@ os_thread_create_func( pthread_attr_destroy(&attr); #endif - ut_a(os_thread_count <= OS_THREAD_MAX_N); - if (thread_id) { *thread_id = pthread; } @@ -233,9 +228,7 @@ os_thread_exit( pfs_delete_thread(); #endif - os_mutex_enter(os_sync_mutex); - os_thread_count--; - os_mutex_exit(os_sync_mutex); + os_atomic_decrement_ulint(&os_thread_count, 1); #ifdef __WIN__ ExitThread((DWORD) exit_value); diff --git a/storage/xtradb/page/page0cur.cc b/storage/xtradb/page/page0cur.cc index 97405261392..76e4c2aed9b 100644 --- a/storage/xtradb/page/page0cur.cc +++ b/storage/xtradb/page/page0cur.cc @@ -1055,6 +1055,26 @@ use_heap: insert_rec = rec_copy(insert_buf, rec, offsets); rec_offs_make_valid(insert_rec, index, offsets); + /* This is because assertion below is debug assertion */ +#ifdef UNIV_DEBUG + if (UNIV_UNLIKELY(current_rec == insert_rec)) { + ulint extra_len, data_len; + extra_len = rec_offs_extra_size(offsets); + data_len = rec_offs_data_size(offsets); + + fprintf(stderr, "InnoDB: Error: current_rec == insert_rec " + " extra_len %lu data_len %lu insert_buf %p rec %p\n", + extra_len, data_len, insert_buf, rec); + fprintf(stderr, "InnoDB; Physical record: \n"); + rec_print(stderr, rec, index); + fprintf(stderr, "InnoDB: Inserted record: \n"); + rec_print(stderr, insert_rec, index); + fprintf(stderr, "InnoDB: Current record: \n"); + rec_print(stderr, current_rec, index); + ut_a(current_rec != insert_rec); + } +#endif /* UNIV_DEBUG */ + /* 4. Insert the record in the linked list of records */ ut_ad(current_rec != insert_rec); diff --git a/storage/xtradb/page/page0page.cc b/storage/xtradb/page/page0page.cc index 6adbdeb95a4..a6fba4074ef 100644 --- a/storage/xtradb/page/page0page.cc +++ b/storage/xtradb/page/page0page.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -309,7 +309,7 @@ byte* page_parse_create( /*==============*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ ulint comp, /*!< in: nonzero=compact page format */ buf_block_t* block, /*!< in: block or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc index 09da6ac6a50..63d6fe225c2 100644 --- a/storage/xtradb/page/page0zip.cc +++ b/storage/xtradb/page/page0zip.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2014, SkySQL Ab. All Rights Reserved. @@ -135,7 +135,7 @@ Compare at most sizeof(field_ref_zero) bytes. independently of any UNIV_ debugging conditions. */ #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG # include -__attribute__((format (printf, 1, 2))) +MY_ATTRIBUTE((format (printf, 1, 2))) /**********************************************************************//** Report a failure to decompress or compress. @return number of characters printed */ @@ -755,8 +755,8 @@ static void page_zip_free( /*==========*/ - void* opaque __attribute__((unused)), /*!< in: memory heap */ - void* address __attribute__((unused)))/*!< in: object to free */ + void* opaque MY_ATTRIBUTE((unused)), /*!< in: memory heap */ + void* address MY_ATTRIBUTE((unused)))/*!< in: object to free */ { } @@ -4814,7 +4814,8 @@ page_zip_parse_compress( ulint size; ulint trailer_size; - ut_ad(ptr && end_ptr); + ut_ad(ptr != NULL); + ut_ad(end_ptr != NULL); ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) { diff --git a/storage/xtradb/pars/lexyy.cc b/storage/xtradb/pars/lexyy.cc index 07476320e03..62122bb9f6f 100644 --- a/storage/xtradb/pars/lexyy.cc +++ b/storage/xtradb/pars/lexyy.cc @@ -295,7 +295,7 @@ static int yy_start = 0; /* start state number */ static int yy_did_buffer_switch_on_eof; void yyrestart (FILE *input_file ); -__attribute__((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +MY_ATTRIBUTE((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); static YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); void yy_delete_buffer (YY_BUFFER_STATE b ); void yy_flush_buffer (YY_BUFFER_STATE b ); @@ -916,7 +916,7 @@ char *yytext; #line 1 "pars0lex.l" /***************************************************************************** -Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1027,7 +1027,7 @@ static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -__attribute__((unused)) static int yylex_destroy (void ); +MY_ATTRIBUTE((unused)) static int yylex_destroy (void ); int yyget_debug (void ); @@ -2664,7 +2664,7 @@ static int yy_get_next_buffer (void) * @param new_buffer The new input buffer. * */ - __attribute__((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + MY_ATTRIBUTE((unused)) static void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body @@ -3042,7 +3042,7 @@ static int yy_init_globals (void) } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -__attribute__((unused)) static int yylex_destroy (void) +MY_ATTRIBUTE((unused)) static int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ diff --git a/storage/xtradb/pars/make_flex.sh b/storage/xtradb/pars/make_flex.sh index 581fc2342aa..c3db8aea298 100755 --- a/storage/xtradb/pars/make_flex.sh +++ b/storage/xtradb/pars/make_flex.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -33,15 +33,15 @@ sed -e ' s/'"$TMPFILE"'/'"$OUTFILE"'/; s/\(int offset = \)\((yy_c_buf_p) - (yytext_ptr)\);/\1(int)(\2);/; s/\(void yy\(restart\|_\(delete\|flush\)_buffer\)\)/static \1/; -s/\(void yy_switch_to_buffer\)/__attribute__((unused)) static \1/; -s/\(void yy\(push\|pop\)_buffer_state\)/__attribute__((unused)) static \1/; +s/\(void yy_switch_to_buffer\)/MY_ATTRIBUTE((unused)) static \1/; +s/\(void yy\(push\|pop\)_buffer_state\)/MY_ATTRIBUTE((unused)) static \1/; s/\(YY_BUFFER_STATE yy_create_buffer\)/static \1/; -s/\(\(int\|void\) yy[gs]et_\)/__attribute__((unused)) static \1/; +s/\(\(int\|void\) yy[gs]et_\)/MY_ATTRIBUTE((unused)) static \1/; s/\(void \*\?yy\(\(re\)\?alloc\|free\)\)/static \1/; s/\(extern \)\?\(int yy\(leng\|lineno\|_flex_debug\)\)/static \2/; -s/\(int yylex_destroy\)/__attribute__((unused)) static \1/; +s/\(int yylex_destroy\)/MY_ATTRIBUTE((unused)) static \1/; s/\(extern \)\?\(int yylex \)/UNIV_INTERN \2/; -s/^\(\(FILE\|char\) *\* *yyget\)/__attribute__((unused)) static \1/; +s/^\(\(FILE\|char\) *\* *yyget\)/MY_ATTRIBUTE((unused)) static \1/; s/^\(extern \)\?\(\(FILE\|char\) *\* *yy\)/static \2/; ' < $TMPFILE >> $OUTFILE diff --git a/storage/xtradb/pars/pars0pars.cc b/storage/xtradb/pars/pars0pars.cc index da08939d78a..e6af3d25e86 100644 --- a/storage/xtradb/pars/pars0pars.cc +++ b/storage/xtradb/pars/pars0pars.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1926,7 +1926,7 @@ pars_create_table( sym_node_t* column_defs, /*!< in: list of column names */ sym_node_t* compact, /* in: non-NULL if COMPACT table. */ sym_node_t* block_size, /* in: block size (can be NULL) */ - void* not_fit_in_memory __attribute__((unused))) + void* not_fit_in_memory MY_ATTRIBUTE((unused))) /*!< in: a non-NULL pointer means that this is a table which in simulations should be simulated as not fitting @@ -2143,7 +2143,7 @@ UNIV_INTERN que_fork_t* pars_stored_procedure_call( /*=======================*/ - sym_node_t* sym_node __attribute__((unused))) + sym_node_t* sym_node MY_ATTRIBUTE((unused))) /*!< in: stored procedure name */ { ut_error; @@ -2203,7 +2203,7 @@ UNIV_INTERN void yyerror( /*====*/ - const char* s __attribute__((unused))) + const char* s MY_ATTRIBUTE((unused))) /*!< in: error message string */ { ut_ad(s); diff --git a/storage/xtradb/rem/rem0cmp.cc b/storage/xtradb/rem/rem0cmp.cc index 426cf9e3ac5..616ef322fb5 100644 --- a/storage/xtradb/rem/rem0cmp.cc +++ b/storage/xtradb/rem/rem0cmp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -75,7 +75,7 @@ cmp_debug_dtuple_rec_with_match( completely matched fields; when function returns, contains the value for current comparison */ - __attribute__((nonnull, warn_unused_result)); + MY_ATTRIBUTE((nonnull, warn_unused_result)); #endif /* UNIV_DEBUG */ /*************************************************************//** This function is used to compare two data fields for which the data type @@ -659,7 +659,10 @@ cmp_dtuple_rec_with_match_low( in current field */ int ret; /* return value */ - ut_ad(dtuple && rec && matched_fields && matched_bytes); + ut_ad(dtuple != NULL); + ut_ad(rec != NULL); + ut_ad(matched_fields != NULL); + ut_ad(matched_bytes != NULL); ut_ad(dtuple_check_typed(dtuple)); ut_ad(rec_offs_validate(rec, NULL, offsets)); @@ -920,7 +923,7 @@ Compare two physical record fields. @retval 1 if rec1 field is greater than rec2 @retval -1 if rec1 field is less than rec2 @retval 0 if rec1 field equals to rec2 */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) int cmp_rec_rec_simple_field( /*=====================*/ @@ -1139,7 +1142,9 @@ cmp_rec_rec_with_match( int ret = 0; /* return value */ ulint comp; - ut_ad(rec1 && rec2 && index); + ut_ad(rec1 != NULL); + ut_ad(rec2 != NULL); + ut_ad(index != NULL); ut_ad(rec_offs_validate(rec1, index, offsets1)); ut_ad(rec_offs_validate(rec2, index, offsets2)); ut_ad(rec_offs_comp(offsets1) == rec_offs_comp(offsets2)); @@ -1375,7 +1380,9 @@ cmp_debug_dtuple_rec_with_match( int ret; /* return value */ ulint cur_field; /* current field number */ - ut_ad(dtuple && rec && matched_fields); + ut_ad(dtuple != NULL); + ut_ad(rec != NULL); + ut_ad(matched_fields != NULL); ut_ad(dtuple_check_typed(dtuple)); ut_ad(rec_offs_validate(rec, NULL, offsets)); diff --git a/storage/xtradb/rem/rem0rec.cc b/storage/xtradb/rem/rem0rec.cc index 4231309f10f..80dc7557ec7 100644 --- a/storage/xtradb/rem/rem0rec.cc +++ b/storage/xtradb/rem/rem0rec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -244,7 +244,7 @@ rec_get_n_extern_new( Determine the offset to each field in a leaf-page record in ROW_FORMAT=COMPACT. This is a special case of rec_init_offsets() and rec_get_offsets_func(). */ -UNIV_INLINE __attribute__((nonnull)) +UNIV_INLINE MY_ATTRIBUTE((nonnull)) void rec_init_offsets_comp_ordinary( /*===========================*/ @@ -788,7 +788,7 @@ rec_get_nth_field_offs_old( /**********************************************************//** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ -UNIV_INLINE __attribute__((warn_unused_result, nonnull(1,2))) +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result, nonnull(1,2))) ulint rec_get_converted_size_comp_prefix_low( /*===================================*/ @@ -1133,7 +1133,7 @@ rec_convert_dtuple_to_rec_old( /*********************************************************//** Builds a ROW_FORMAT=COMPACT record out of a data tuple. */ -UNIV_INLINE __attribute__((nonnull)) +UNIV_INLINE MY_ATTRIBUTE((nonnull)) void rec_convert_dtuple_to_rec_comp( /*===========================*/ @@ -1341,7 +1341,9 @@ rec_convert_dtuple_to_rec( { rec_t* rec; - ut_ad(buf && index && dtuple); + ut_ad(buf != NULL); + ut_ad(index != NULL); + ut_ad(dtuple != NULL); ut_ad(dtuple_validate(dtuple)); ut_ad(dtuple_check_typed(dtuple)); diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc index ac0dc844b1b..a3a00620a6d 100644 --- a/storage/xtradb/row/row0ftsort.cc +++ b/storage/xtradb/row/row0ftsort.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -560,8 +560,18 @@ row_merge_fts_doc_tokenize( dfield_dup(field, buf->heap); /* One variable length column, word with its lenght less than - fts_max_token_size, add one extra size and one extra byte */ - cur_len += 2; + fts_max_token_size, add one extra size and one extra byte. + + Since the max length for FTS token now is larger than 255, + so we will need to signify length byte itself, so only 1 to 128 + bytes can be used for 1 bytes, larger than that 2 bytes. */ + if (t_str.f_len < 128) { + /* Extra size is one byte. */ + cur_len += 2; + } else { + /* Extra size is two bytes. */ + cur_len += 3; + } /* Reserve one byte for the end marker of row_merge_block_t and we have reserved ROW_MERGE_RESERVE_SIZE (= 4) for @@ -1045,7 +1055,7 @@ row_fts_start_parallel_merge( /********************************************************************//** Insert processed FTS data to auxillary index tables. @return DB_SUCCESS if insertion runs fine */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t row_merge_write_fts_word( /*=====================*/ diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc index 893ffcab3da..4c7cb7d33b5 100644 --- a/storage/xtradb/row/row0import.cc +++ b/storage/xtradb/row/row0import.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, MariaDB Corporation. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2016, MariaDB Corporation. 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 @@ -1336,12 +1336,15 @@ row_import::match_schema( THD* thd) UNIV_NOTHROW { /* Do some simple checks. */ + const unsigned relevant_flags = m_flags & ~DICT_TF_MASK_DATA_DIR; + const unsigned relevant_table_flags + = m_table->flags & ~DICT_TF_MASK_DATA_DIR; - if (m_flags != m_table->flags) { + if (relevant_flags != relevant_table_flags) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Table flags don't match, server table has 0x%lx " - "and the meta-data file has 0x%lx", - (ulong) m_table->n_cols, (ulong) m_flags); + "Table flags don't match, server table has 0x%x " + "and the meta-data file has 0x%x", + relevant_table_flags, relevant_flags); return(DB_ERROR); } else if (m_table->n_cols != m_n_cols) { @@ -2181,7 +2184,7 @@ PageConverter::operator() ( Clean up after import tablespace failure, this function will acquire the dictionary latches on behalf of the transaction if the transaction hasn't already acquired them. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_import_discard_changes( /*=======================*/ @@ -2232,7 +2235,7 @@ row_import_discard_changes( /*****************************************************************//** Clean up after import tablespace. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_cleanup( /*===============*/ @@ -2267,7 +2270,7 @@ row_import_cleanup( /*****************************************************************//** Report error during tablespace import. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_error( /*=============*/ @@ -2295,7 +2298,7 @@ row_import_error( Adjust the root page index node and leaf node segment headers, update with the new space id. For all the table's secondary indexes. @return error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_adjust_root_pages_of_secondary_indexes( /*==============================================*/ @@ -2411,7 +2414,7 @@ row_import_adjust_root_pages_of_secondary_indexes( /*****************************************************************//** Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). @return error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_set_sys_max_row_id( /*==========================*/ @@ -2561,7 +2564,7 @@ row_import_cfg_read_string( /*********************************************************************//** Write the meta data (index user fields) config file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_cfg_read_index_fields( /*=============================*/ @@ -2644,7 +2647,7 @@ row_import_cfg_read_index_fields( Read the index names and root page numbers of the indexes and set the values. Row format [root_page_no, len of str, str ... ] @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_index_data( /*=======================*/ @@ -2839,7 +2842,7 @@ row_import_read_indexes( /*********************************************************************//** Read the meta data (table columns) config file. Deserialise the contents of dict_col_t structure, along with the column name. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_columns( /*====================*/ @@ -2964,7 +2967,7 @@ row_import_read_columns( /*****************************************************************//** Read the contents of the .cfg file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_v1( /*===============*/ @@ -3130,7 +3133,7 @@ row_import_read_v1( /** Read the contents of the .cfg file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_meta_data( /*======================*/ @@ -3173,7 +3176,7 @@ row_import_read_meta_data( /** Read the contents of the .cfg file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_import_read_cfg( /*================*/ diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index d02e1796f8a..8dbf093a17d 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -224,7 +224,7 @@ Does an insert operation by updating a delete-marked existing record in the index. This situation can occur if the delete-marked record is kept in the index for consistent reads. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_sec_index_entry_by_modify( /*==============================*/ @@ -325,7 +325,7 @@ Does an insert operation by delete unmarking and updating a delete marked existing record in the index. This situation can occur if the delete marked record is kept in the index for consistent reads. @return DB_SUCCESS, DB_FAIL, or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_clust_index_entry_by_modify( /*================================*/ @@ -433,7 +433,7 @@ row_ins_cascade_ancestor_updates_table( Returns the number of ancestor UPDATE or DELETE nodes of a cascaded update/delete node. @return number of ancestors */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint row_ins_cascade_n_ancestors( /*========================*/ @@ -459,7 +459,7 @@ a cascaded update. can also be 0 if no foreign key fields changed; the returned value is ULINT_UNDEFINED if the column type in the child table is too short to fit the new value in the parent table: that means the update fails */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ulint row_ins_cascade_calc_update_vec( /*============================*/ @@ -948,7 +948,7 @@ Perform referential actions or checks when a parent row is deleted or updated and the constraint had an ON DELETE or ON UPDATE condition which was not RESTRICT. @return DB_SUCCESS, DB_LOCK_WAIT, or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_foreign_check_on_constraint( /*================================*/ @@ -1802,7 +1802,7 @@ Otherwise does searches to the indexes of referenced tables and sets shared locks which lock either the success or the failure of a constraint. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_check_foreign_constraints( /*==============================*/ @@ -1943,7 +1943,7 @@ Scans a unique non-clustered index at a given index entry to determine whether a uniqueness violation has occurred for the key value of the entry. Set shared locks on possible duplicate records. @return DB_SUCCESS, DB_DUPLICATE_KEY, or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_scan_sec_index_for_duplicate( /*=================================*/ @@ -2085,7 +2085,7 @@ end_scan: @retval DB_SUCCESS_LOCKED_REC when rec is an exact match of entry or a newer version of entry (the entry should not be inserted) @retval DB_DUPLICATE_KEY when entry is a duplicate of rec */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_duplicate_online( /*=====================*/ @@ -2126,7 +2126,7 @@ row_ins_duplicate_online( @retval DB_SUCCESS_LOCKED_REC when rec is an exact match of entry or a newer version of entry (the entry should not be inserted) @retval DB_DUPLICATE_KEY when entry is a duplicate of rec */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_duplicate_error_in_clust_online( /*====================================*/ @@ -2169,7 +2169,7 @@ for a clustered index! record @retval DB_SUCCESS_LOCKED_REC if an exact match of the record was found in online table rebuild (flags & (BTR_KEEP_SYS_FLAG | BTR_NO_LOCKING_FLAG)) */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_duplicate_error_in_clust( /*=============================*/ @@ -2625,7 +2625,7 @@ func_exit: /***************************************************************//** Starts a mini-transaction and checks if the index will be dropped. @return true if the index is to be dropped */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_ins_sec_mtr_start_trx_and_check_if_aborted( /*=======================================*/ @@ -3105,7 +3105,7 @@ row_ins_index_entry( /***********************************************************//** Sets the values of the dtuple fields in entry from the values of appropriate columns in row. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_ins_index_entry_set_vals( /*=========================*/ @@ -3158,7 +3158,7 @@ row_ins_index_entry_set_vals( Inserts a single index entry to the table. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins_index_entry_step( /*=====================*/ @@ -3281,7 +3281,7 @@ row_ins_get_row_from_select( Inserts a row to a table. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_ins( /*====*/ diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index f0b200459dd..53e375023fb 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -205,7 +205,7 @@ struct row_log_t { /** Create the file or online log if it does not exist. @param[in,out] log online rebuild log @return file descriptor. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_log_tmpfile( row_log_t* log) @@ -221,7 +221,7 @@ row_log_tmpfile( /** Allocate the memory for the log buffer. @param[in,out] log_buf Buffer used for log operation @return TRUE if success, false if not */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) bool row_log_block_allocate( row_log_buf_t& log_buf) @@ -411,7 +411,7 @@ row_log_table_get_error( /******************************************************//** Starts logging an operation to a table that is being rebuilt. @return pointer to log, or NULL if no logging is necessary */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) byte* row_log_table_open( /*===============*/ @@ -446,7 +446,7 @@ err_exit: /******************************************************//** Stops logging an operation to a table that is being rebuilt. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_log_table_close_func( /*=====================*/ @@ -820,7 +820,7 @@ row_log_table_low_redundant( /******************************************************//** Logs an insert or update to a table that is being rebuilt. */ -static __attribute__((nonnull(1,2,3))) +static MY_ATTRIBUTE((nonnull(1,2,3))) void row_log_table_low( /*==============*/ @@ -1320,7 +1320,7 @@ row_log_table_blob_alloc( /******************************************************//** Converts a log record to a table row. @return converted row, or NULL if the conversion fails */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const dtuple_t* row_log_table_apply_convert_mrec( /*=============================*/ @@ -1474,7 +1474,7 @@ blob_done: /******************************************************//** Replays an insert operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_insert_low( /*===========================*/ @@ -1556,7 +1556,7 @@ row_log_table_apply_insert_low( /******************************************************//** Replays an insert operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_insert( /*=======================*/ @@ -1608,7 +1608,7 @@ row_log_table_apply_insert( /******************************************************//** Deletes a record from a table that is being rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull(1, 2, 4, 5), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1, 2, 4, 5), warn_unused_result)) dberr_t row_log_table_apply_delete_low( /*===========================*/ @@ -1706,7 +1706,7 @@ flag_ok: /******************************************************//** Replays a delete operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull(1, 3, 4, 5, 6, 7), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1, 3, 4, 5, 6, 7), warn_unused_result)) dberr_t row_log_table_apply_delete( /*=======================*/ @@ -1828,7 +1828,7 @@ all_done: /******************************************************//** Replays an update operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_update( /*=======================*/ @@ -2191,7 +2191,7 @@ func_exit_committed: Applies an operation to a table that was rebuilt. @return NULL on failure (mrec corruption) or when out of data; pointer to next record on success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const mrec_t* row_log_table_apply_op( /*===================*/ @@ -2482,7 +2482,7 @@ row_log_table_apply_op( /******************************************************//** Applies operations to a table was rebuilt. @return DB_SUCCESS, or error code on failure */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_ops( /*====================*/ @@ -2979,7 +2979,7 @@ row_log_get_max_trx( /******************************************************//** Applies an operation to a secondary index that was being created. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_log_apply_op_low( /*=================*/ @@ -3206,7 +3206,7 @@ func_exit: Applies an operation to a secondary index that was being created. @return NULL on failure (mrec corruption) or when out of data; pointer to next record on success */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) const mrec_t* row_log_apply_op( /*=============*/ @@ -3331,7 +3331,7 @@ corrupted: /******************************************************//** Applies operations to a secondary index that was being created. @return DB_SUCCESS, or error code on failure */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) dberr_t row_log_apply_ops( /*==============*/ diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index b45c7f2171b..f5967ede3e7 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -164,7 +164,7 @@ row_merge_decrypt_buf( #ifdef UNIV_DEBUG /******************************************************//** Display a merge tuple. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_merge_tuple_print( /*==================*/ @@ -199,7 +199,7 @@ row_merge_tuple_print( /******************************************************//** Encode an index record. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_merge_buf_encode( /*=================*/ @@ -236,7 +236,7 @@ row_merge_buf_encode( /******************************************************//** Allocate a sort buffer. @return own: sort buffer */ -static __attribute__((malloc, nonnull)) +static MY_ATTRIBUTE((malloc, nonnull)) row_merge_buf_t* row_merge_buf_create_low( /*=====================*/ @@ -738,7 +738,7 @@ row_merge_dup_report( /*************************************************************//** Compare two tuples. @return 1, 0, -1 if a is greater, equal, less, respectively, than b */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_merge_tuple_cmp( /*================*/ @@ -817,7 +817,7 @@ UT_SORT_FUNCTION_BODY(). /**********************************************************************//** Merge sort the tuple buffer in main memory. */ -static __attribute__((nonnull(4,5))) +static MY_ATTRIBUTE((nonnull(4,5))) void row_merge_tuple_sort( /*=================*/ @@ -1393,7 +1393,7 @@ row_merge_write_eof( @param[in,out] tmpfd temporary file handle @param[in] path path to create temporary file @return file descriptor, or -1 on failure */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_merge_tmpfile_if_needed( int* tmpfd, @@ -1412,7 +1412,7 @@ row_merge_tmpfile_if_needed( @param[in] nrec number of records in the file @param[in] path path to create temporary files @return file descriptor, or -1 on failure */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) int row_merge_file_create_if_needed( merge_file_t* file, @@ -1458,7 +1458,7 @@ containing the index entries for the indexes to be built. @param[in,out] block file buffer @param[in,out] tmpfd temporary file handle return DB_SUCCESS or error */ -static __attribute__((nonnull(1,2,3,4,6,9,10,16), warn_unused_result)) +static MY_ATTRIBUTE((nonnull(1,2,3,4,6,9,10,16), warn_unused_result)) dberr_t row_merge_read_clustered_index( trx_t* trx, @@ -2176,7 +2176,8 @@ wait_again: if (max_doc_id && err == DB_SUCCESS) { /* Sync fts cache for other fts indexes to keep all fts indexes consistent in sync_doc_id. */ - err = fts_sync_table(const_cast(new_table)); + err = fts_sync_table(const_cast(new_table), + false, true); if (err == DB_SUCCESS) { fts_update_next_doc_id( @@ -2679,7 +2680,7 @@ row_merge_sort( /*************************************************************//** Copy externally stored columns to the data tuple. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_merge_copy_blobs( /*=================*/ @@ -3761,7 +3762,7 @@ row_merge_rename_tables_dict( /*********************************************************************//** Create and execute a query graph for creating an index. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_merge_create_index_graph( /*=========================*/ @@ -3913,7 +3914,7 @@ row_merge_drop_table( /* There must be no open transactions on the table. */ ut_a(table->n_ref_count == 0); - return(row_drop_table_for_mysql(table->name, trx, false, false)); + return(row_drop_table_for_mysql(table->name, trx, false, false, false)); } /*********************************************************************//** diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 9427b20daf9..ba2e0047fe9 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1432,9 +1432,12 @@ error_exit: } /* Difference between Doc IDs are restricted within - 4 bytes integer. See fts_get_encoded_len() */ + 4 bytes integer. See fts_get_encoded_len(). Consecutive + doc_ids difference should not exceed + FTS_DOC_ID_MAX_STEP value. */ - if (doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { + if (next_doc_id > 1 + && doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { fprintf(stderr, "InnoDB: Doc ID " UINT64PF " is too" " big. Its difference with largest" @@ -1704,7 +1707,8 @@ row_update_for_mysql( trx_t* trx = prebuilt->trx; ulint fk_depth = 0; - ut_ad(prebuilt && trx); + ut_ad(prebuilt != NULL); + ut_ad(trx != NULL); UT_NOT_USED(mysql_rec); if (prebuilt->table->ibd_file_missing) { @@ -1926,7 +1930,8 @@ row_unlock_for_mysql( btr_pcur_t* clust_pcur = &prebuilt->clust_pcur; trx_t* trx = prebuilt->trx; - ut_ad(prebuilt && trx); + ut_ad(prebuilt != NULL); + ut_ad(trx != NULL); if (UNIV_UNLIKELY (!srv_locks_unsafe_for_binlog @@ -2419,7 +2424,7 @@ err_exit: dict_table_close(table, TRUE, FALSE); - row_drop_table_for_mysql(table->name, trx, FALSE); + row_drop_table_for_mysql(table->name, trx, FALSE, TRUE); if (commit) { trx_commit_for_mysql(trx); @@ -2579,7 +2584,7 @@ error_handling: trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE, TRUE); trx_commit_for_mysql(trx); @@ -2656,7 +2661,7 @@ row_table_add_foreign_constraints( trx_rollback_to_savepoint(trx, NULL); - row_drop_table_for_mysql(name, trx, FALSE); + row_drop_table_for_mysql(name, trx, FALSE, TRUE); trx_commit_for_mysql(trx); @@ -2697,7 +2702,7 @@ row_drop_table_for_mysql_in_background( /* Try to drop the table in InnoDB */ - error = row_drop_table_for_mysql(name, trx, FALSE); + error = row_drop_table_for_mysql(name, trx, FALSE, FALSE); /* Flush the log to reduce probability that the .frm files and the InnoDB data dictionary get out-of-sync if the user runs @@ -3844,6 +3849,9 @@ row_drop_table_for_mysql( const char* name, /*!< in: table name */ trx_t* trx, /*!< in: transaction handle */ bool drop_db,/*!< in: true=dropping whole database */ + ibool create_failed,/*!foreign_table_name_lookup); - if (foreign->foreign_table != table && !ref_ok) { + /* We should allow dropping a referenced table if creating + that referenced table has failed for some reason. For example + if referenced table is created but it column types that are + referenced do not match. */ + if (foreign->foreign_table != table && + !create_failed && !ref_ok) { FILE* ef = dict_foreign_err_file; @@ -4593,7 +4606,7 @@ row_mysql_drop_temp_tables(void) table = dict_table_get_low(table_name); if (table) { - row_drop_table_for_mysql(table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE, FALSE); trx_commit_for_mysql(trx); } @@ -4613,7 +4626,7 @@ row_mysql_drop_temp_tables(void) Drop all foreign keys in a database, see Bug#18942. Called at the end of row_drop_database_for_mysql(). @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t drop_all_foreign_keys_in_db( /*========================*/ @@ -4762,7 +4775,7 @@ loop: goto loop; } - err = row_drop_table_for_mysql(table_name, trx, TRUE); + err = row_drop_table_for_mysql(table_name, trx, TRUE, FALSE); trx_commit_for_mysql(trx); if (err != DB_SUCCESS) { @@ -4805,7 +4818,7 @@ loop: Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @return true if temporary table */ -UNIV_INTERN __attribute__((warn_unused_result)) +UNIV_INTERN MY_ATTRIBUTE((warn_unused_result)) bool row_is_mysql_tmp_table_name( /*========================*/ @@ -4819,7 +4832,7 @@ row_is_mysql_tmp_table_name( /****************************************************************//** Delete a single constraint. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_delete_constraint_low( /*======================*/ @@ -4842,7 +4855,7 @@ row_delete_constraint_low( /****************************************************************//** Delete a single constraint. @return error code or DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_delete_constraint( /*==================*/ diff --git a/storage/xtradb/row/row0purge.cc b/storage/xtradb/row/row0purge.cc index b26ba971a95..bc2e0b0e1cb 100644 --- a/storage/xtradb/row/row0purge.cc +++ b/storage/xtradb/row/row0purge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -69,7 +69,8 @@ row_purge_node_create( { purge_node_t* node; - ut_ad(parent && heap); + ut_ad(parent != NULL); + ut_ad(heap != NULL); node = static_cast( mem_heap_zalloc(heap, sizeof(*node))); @@ -120,7 +121,7 @@ row_purge_reposition_pcur( Removes a delete marked clustered index record if possible. @retval true if the row was not found, or it was successfully removed @retval false if the row was modified after the delete marking */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_remove_clust_if_poss_low( /*===============================*/ @@ -202,7 +203,7 @@ marking. @retval true if the row was not found, or it was successfully removed @retval false the purge needs to be suspended because of running out of file space. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_remove_clust_if_poss( /*===========================*/ @@ -274,7 +275,7 @@ row_purge_poss_sec( Removes a secondary index entry if possible, by modifying the index tree. Does not try to buffer the delete. @return TRUE if success or if not found */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) ibool row_purge_remove_sec_if_poss_tree( /*==============================*/ @@ -396,7 +397,7 @@ Removes a secondary index entry without modifying the index tree, if possible. @retval true if success or if not found @retval false if row_purge_remove_sec_if_poss_tree() should be invoked */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_remove_sec_if_poss_leaf( /*==============================*/ @@ -507,7 +508,7 @@ row_purge_remove_sec_if_poss_leaf( /***********************************************************//** Removes a secondary index entry if possible. */ -UNIV_INLINE __attribute__((nonnull(1,2))) +UNIV_INLINE MY_ATTRIBUTE((nonnull(1,2))) void row_purge_remove_sec_if_poss( /*=========================*/ @@ -554,7 +555,7 @@ Purges a delete marking of a record. @retval true if the row was not found, or it was successfully removed @retval false the purge needs to be suspended because of running out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_del_mark( /*===============*/ @@ -745,7 +746,8 @@ row_purge_parse_undo_rec( ulint info_bits; ulint type; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); ptr = trx_undo_rec_get_pars( undo_rec, &type, &node->cmpl_info, @@ -830,7 +832,7 @@ err_exit: /***********************************************************//** Purges the parsed record. @return true if purged, false if skipped */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool row_purge_record_func( /*==================*/ @@ -895,7 +897,7 @@ row_purge_record_func( Fetches an undo log record and does the purge for the recorded operation. If none left, or the current purge completed, returns the control to the parent node, which is always a query thread node. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_purge( /*======*/ diff --git a/storage/xtradb/row/row0quiesce.cc b/storage/xtradb/row/row0quiesce.cc index ecd6f47947b..583fbe60fb3 100644 --- a/storage/xtradb/row/row0quiesce.cc +++ b/storage/xtradb/row/row0quiesce.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -37,7 +37,7 @@ Created 2012-02-08 by Sunny Bains. /*********************************************************************//** Write the meta data (index user fields) config file. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_index_fields( /*===========================*/ @@ -97,7 +97,7 @@ row_quiesce_write_index_fields( /*********************************************************************//** Write the meta data config file index information. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_indexes( /*======================*/ @@ -210,7 +210,7 @@ Write the meta data (table columns) config file. Serialise the contents of dict_col_t structure, along with the column name. All fields are serialized as ib_uint32_t. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_table( /*====================*/ @@ -293,7 +293,7 @@ row_quiesce_write_table( /*********************************************************************//** Write the meta data config file header. @return DB_SUCCESS or error code. */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_header( /*=====================*/ @@ -415,7 +415,7 @@ row_quiesce_write_header( /*********************************************************************//** Write the table meta data after quiesce. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_cfg( /*==================*/ @@ -530,10 +530,8 @@ row_quiesce_table_start( trx_purge_stop(); } - ut_a(table->id > 0); - for (ulint count = 0; - ibuf_contract_in_background(table->id, TRUE) != 0 + ibuf_merge_space(table->space) != 0 && !trx_is_interrupted(trx); ++count) { if (!(count % 20)) { diff --git a/storage/xtradb/row/row0row.cc b/storage/xtradb/row/row0row.cc index be786f954fb..96d25e15777 100644 --- a/storage/xtradb/row/row0row.cc +++ b/storage/xtradb/row/row0row.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -240,7 +240,9 @@ row_build( ulint offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs_init(offsets_); - ut_ad(index && rec && heap); + ut_ad(index != NULL); + ut_ad(rec != NULL); + ut_ad(heap != NULL); ut_ad(dict_index_is_clust(index)); ut_ad(!mutex_own(&trx_sys->mutex)); ut_ad(!col_map || col_table); @@ -409,7 +411,9 @@ row_rec_to_index_entry_low( ulint len; ulint rec_len; - ut_ad(rec && heap && index); + ut_ad(rec != NULL); + ut_ad(heap != NULL); + ut_ad(index != NULL); /* Because this function may be invoked by row0merge.cc on a record whose header is in different format, the check rec_offs_validate(rec, index, offsets) must be avoided here. */ @@ -464,7 +468,9 @@ row_rec_to_index_entry( byte* buf; const rec_t* copy_rec; - ut_ad(rec && heap && index); + ut_ad(rec != NULL); + ut_ad(heap != NULL); + ut_ad(index != NULL); ut_ad(rec_offs_validate(rec, index, offsets)); /* Take a copy of rec to heap */ @@ -523,7 +529,9 @@ row_build_row_ref( ulint* offsets = offsets_; rec_offs_init(offsets_); - ut_ad(index && rec && heap); + ut_ad(index != NULL); + ut_ad(rec != NULL); + ut_ad(heap != NULL); ut_ad(!dict_index_is_clust(index)); offsets = rec_get_offsets(rec, index, offsets, diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc index 2bebfb7a0f1..9732a5f9400 100644 --- a/storage/xtradb/row/row0sel.cc +++ b/storage/xtradb/row/row0sel.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2015, MariaDB Corporation. @@ -679,7 +679,7 @@ sel_enqueue_prefetched_row( /*********************************************************************//** Builds a previous version of a clustered index record for a consistent read @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_build_prev_vers( /*====================*/ @@ -714,7 +714,7 @@ row_sel_build_prev_vers( /*********************************************************************//** Builds the last committed version of a clustered index record for a semi-consistent read. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_sel_build_committed_vers_for_mysql( /*===================================*/ @@ -812,7 +812,7 @@ row_sel_test_other_conds( Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_get_clust_rec( /*==================*/ @@ -1316,7 +1316,7 @@ func_exit: /*********************************************************************//** Performs a select step. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel( /*====*/ @@ -2564,7 +2564,7 @@ row_sel_store_row_id_to_prebuilt( /**************************************************************//** Stores a non-SQL-NULL field in the MySQL format. The counterpart of this function is row_mysql_store_col_in_innobase_format() in row0mysql.cc. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_sel_field_store_in_mysql_format_func( /*=====================================*/ @@ -2753,7 +2753,7 @@ row_sel_field_store_in_mysql_format_func( #endif /* UNIV_DEBUG */ /**************************************************************//** Convert a field in the Innobase format to a field in the MySQL format. */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool row_sel_store_mysql_field_func( /*===========================*/ @@ -2906,7 +2906,7 @@ Note that the template in prebuilt may advise us to copy only a few columns to mysql_rec, other columns are left blank. All columns may not be needed in the query. @return TRUE on success, FALSE if not all columns could be retrieved */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool row_sel_store_mysql_rec( /*====================*/ @@ -2973,7 +2973,7 @@ row_sel_store_mysql_rec( /*********************************************************************//** Builds a previous version of a clustered index record for a consistent read @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_build_prev_vers_for_mysql( /*==============================*/ @@ -3010,7 +3010,7 @@ Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. Used in the MySQL interface. @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_sel_get_clust_rec_for_mysql( /*============================*/ diff --git a/storage/xtradb/row/row0uins.cc b/storage/xtradb/row/row0uins.cc index 849bf096492..651042fb820 100644 --- a/storage/xtradb/row/row0uins.cc +++ b/storage/xtradb/row/row0uins.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -61,7 +61,7 @@ introduced where a call to log_free_check() is bypassed. */ Removes a clustered index record. The pcur in node was positioned on the record, now it is detached. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_clust_rec( /*==========================*/ @@ -176,7 +176,7 @@ func_exit: /***************************************************************//** Removes a secondary index entry if found. @return DB_SUCCESS, DB_FAIL, or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_sec_low( /*========================*/ @@ -251,7 +251,7 @@ func_exit_no_pcur: Removes a secondary index entry from the index if found. Tries first optimistic, then pessimistic descent down the tree. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_sec( /*====================*/ @@ -350,7 +350,7 @@ close_table: /***************************************************************//** Removes secondary index records. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_ins_remove_sec_rec( /*========================*/ diff --git a/storage/xtradb/row/row0umod.cc b/storage/xtradb/row/row0umod.cc index 675d4fa3632..19576d976bd 100644 --- a/storage/xtradb/row/row0umod.cc +++ b/storage/xtradb/row/row0umod.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -72,7 +72,7 @@ introduced where a call to log_free_check() is bypassed. */ /***********************************************************//** Undoes a modify in a clustered index record. @return DB_SUCCESS, DB_FAIL, or error code: we may run out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_clust_low( /*===================*/ @@ -154,7 +154,7 @@ This is attempted when the record was inserted by updating a delete-marked record and there no longer exist transactions that would see the delete-marked record. @return DB_SUCCESS, DB_FAIL, or error code: we may run out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_remove_clust_low( /*==========================*/ @@ -243,7 +243,7 @@ row_undo_mod_remove_clust_low( Undoes a modify in a clustered index record. Sets also the node state for the next round of undo. @return DB_SUCCESS or error code: we may run out of file space */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_clust( /*===============*/ @@ -387,7 +387,7 @@ row_undo_mod_clust( /***********************************************************//** Delete marks or removes a secondary index entry if found. @return DB_SUCCESS, DB_FAIL, or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_mark_or_remove_sec_low( /*====================================*/ @@ -523,7 +523,7 @@ not cause problems because in row0sel.cc, in queries we always retrieve the clustered index record or an earlier version of it, if the secondary index record through which we do the search is delete-marked. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_mark_or_remove_sec( /*================================*/ @@ -556,7 +556,7 @@ fields but alphabetically they stayed the same, e.g., 'abc' -> 'aBc'. @retval DB_OUT_OF_FILE_SPACE when running out of tablespace @retval DB_DUPLICATE_KEY if the value was missing and an insert would lead to a duplicate exists */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_unmark_sec_and_undo_update( /*========================================*/ @@ -752,7 +752,7 @@ func_exit_no_pcur: /***********************************************************//** Flags a secondary index corrupted. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_undo_mod_sec_flag_corrupted( /*============================*/ @@ -784,7 +784,7 @@ row_undo_mod_sec_flag_corrupted( /***********************************************************//** Undoes a modify in secondary indexes when undo record type is UPD_DEL. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_upd_del_sec( /*=====================*/ @@ -851,7 +851,7 @@ row_undo_mod_upd_del_sec( /***********************************************************//** Undoes a modify in secondary indexes when undo record type is DEL_MARK. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_del_mark_sec( /*======================*/ @@ -919,7 +919,7 @@ row_undo_mod_del_mark_sec( /***********************************************************//** Undoes a modify in secondary indexes when undo record type is UPD_EXIST. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo_mod_upd_exist_sec( /*=======================*/ @@ -1035,7 +1035,7 @@ row_undo_mod_upd_exist_sec( /***********************************************************//** Parses the row reference and other info in a modify undo log record. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void row_undo_mod_parse_undo_rec( /*========================*/ @@ -1112,7 +1112,8 @@ row_undo_mod( dberr_t err; ibool dict_locked; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); ut_ad(node->state == UNDO_NODE_MODIFY); dict_locked = thr_get_trx(thr)->dict_operation_lock_mode == RW_X_LATCH; diff --git a/storage/xtradb/row/row0undo.cc b/storage/xtradb/row/row0undo.cc index 9977a1e8f04..149dc671930 100644 --- a/storage/xtradb/row/row0undo.cc +++ b/storage/xtradb/row/row0undo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -245,7 +245,7 @@ Fetches an undo log record and does the undo for the recorded operation. If none left, or a partial rollback completed, returns control to the parent node, which is always a query thread node. @return DB_SUCCESS if operation successfully completed, else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_undo( /*=====*/ @@ -257,7 +257,8 @@ row_undo( roll_ptr_t roll_ptr; ibool locked_data_dict; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); trx = node->trx; diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 725ba6f990b..924b4ccca0d 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -221,7 +221,7 @@ NOTE that this function will temporarily commit mtr and lose the pcur position! @return DB_SUCCESS or an error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_check_references_constraints( /*=================================*/ @@ -415,7 +415,7 @@ wsrep_row_upd_check_foreign_constraints( dict_table_open_on_name( foreign->referenced_table_name_lookup, FALSE, FALSE, DICT_ERR_IGNORE_NONE); - opened = TRUE; + opened = (foreign->referenced_table) ? TRUE : FALSE; } if (foreign->referenced_table) { @@ -438,7 +438,7 @@ wsrep_row_upd_check_foreign_constraints( ->n_foreign_key_checks_running); if (opened == TRUE) { - dict_table_close(foreign->referenced_table, TRUE, FALSE); + dict_table_close(foreign->referenced_table, FALSE, FALSE); opened = FALSE; } } @@ -778,7 +778,7 @@ row_upd_write_sys_vals_to_log( roll_ptr_t roll_ptr,/*!< in: roll ptr of the undo log record */ byte* log_ptr,/*!< pointer to a buffer of size > 20 opened in mlog */ - mtr_t* mtr __attribute__((unused))) /*!< in: mtr */ + mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mtr */ { ut_ad(dict_index_is_clust(index)); ut_ad(mtr); @@ -1813,7 +1813,7 @@ row_upd_store_row( Updates a secondary index entry of a row. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_sec_index_entry( /*====================*/ @@ -2055,7 +2055,7 @@ Updates the secondary index record if it is changed in the row update or deletes it if this is a delete. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_sec_step( /*=============*/ @@ -2088,7 +2088,7 @@ updated. We must mark them as inherited in entry, so that they are not freed in a rollback. A limited version of this function used to be called btr_cur_mark_dtuple_inherited_extern(). @return TRUE if any columns were inherited */ -static __attribute__((warn_unused_result)) +static MY_ATTRIBUTE((warn_unused_result)) ibool row_upd_clust_rec_by_insert_inherit_func( /*=====================================*/ @@ -2167,7 +2167,7 @@ fields of the clustered index record change. This should be quite rare in database applications. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_clust_rec_by_insert( /*========================*/ @@ -2329,7 +2329,7 @@ Updates a clustered index record of a row when the ordering fields do not change. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_clust_rec( /*==============*/ @@ -2491,7 +2491,7 @@ func_exit: /***********************************************************//** Delete marks a clustered index record. @return DB_SUCCESS if operation successfully completed, else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_del_mark_clust_rec( /*=======================*/ @@ -2584,7 +2584,7 @@ row_upd_del_mark_clust_rec( Updates the clustered index record. @return DB_SUCCESS if operation successfully completed, DB_LOCK_WAIT in case of a lock wait, else error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd_clust_step( /*===============*/ @@ -2813,7 +2813,7 @@ to this node, we assume that we have a persistent cursor which was on a record, and the position of the cursor is stored in the cursor. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_upd( /*====*/ @@ -2822,7 +2822,8 @@ row_upd( { dberr_t err = DB_SUCCESS; - ut_ad(node && thr); + ut_ad(node != NULL); + ut_ad(thr != NULL); if (UNIV_LIKELY(node->in_mysql_interface)) { diff --git a/storage/xtradb/srv/srv0conc.cc b/storage/xtradb/srv/srv0conc.cc index c4cf1b9ab7b..b070a8289df 100644 --- a/storage/xtradb/srv/srv0conc.cc +++ b/storage/xtradb/srv/srv0conc.cc @@ -165,6 +165,10 @@ srv_conc_free(void) { #ifndef HAVE_ATOMIC_BUILTINS os_fast_mutex_free(&srv_conc_mutex); + + for (ulint i = 0; i < OS_THREAD_MAX_N; i++) + os_event_free(srv_conc_slots[i].event); + mem_free(srv_conc_slots); srv_conc_slots = NULL; #endif /* !HAVE_ATOMIC_BUILTINS */ diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index c98bfc85086..58b442e1aa8 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -372,8 +372,6 @@ UNIV_INTERN ulong srv_read_ahead_threshold = 56; #ifdef UNIV_LOG_ARCHIVE UNIV_INTERN ibool srv_log_archive_on = FALSE; -UNIV_INTERN ibool srv_archive_recovery = 0; -UNIV_INTERN ib_uint64_t srv_archive_recovery_limit_lsn; #endif /* UNIV_LOG_ARCHIVE */ /* This parameter is used to throttle the number of insert buffers that are @@ -585,16 +583,16 @@ UNIV_INTERN ib_uint64_t srv_index_page_decompressed = 0; #else #define CACHE_LINE_SIZE 64 #endif -#define CACHE_ALIGNED __attribute__ ((aligned (CACHE_LINE_SIZE))) +#define CACHE_ALIGNED MY_ATTRIBUTE((aligned (CACHE_LINE_SIZE))) UNIV_INTERN byte -counters_pad_start[CACHE_LINE_SIZE] __attribute__((unused)) = {0}; +counters_pad_start[CACHE_LINE_SIZE] MY_ATTRIBUTE((unused)) = {0}; UNIV_INTERN ulint srv_read_views_memory CACHE_ALIGNED = 0; UNIV_INTERN ulint srv_descriptors_memory CACHE_ALIGNED = 0; UNIV_INTERN byte -counters_pad_end[CACHE_LINE_SIZE] __attribute__((unused)) = {0}; +counters_pad_end[CACHE_LINE_SIZE] MY_ATTRIBUTE((unused)) = {0}; /* Set the following to 0 if you want InnoDB to write messages on stderr on startup/shutdown. */ @@ -810,6 +808,10 @@ struct srv_sys_t{ srv_stats_t::ulint_ctr_1_t activity_count; /*!< For tracking server activity */ + srv_stats_t::ulint_ctr_1_t + ibuf_merge_activity_count;/*!< For tracking change + buffer merge activity, a subset + of overall server activity */ }; #ifndef HAVE_ATOMIC_BUILTINS @@ -1200,8 +1202,9 @@ srv_init(void) srv_checkpoint_completed_event = os_event_create(); + srv_redo_log_tracked_event = os_event_create(); + if (srv_track_changed_pages) { - srv_redo_log_tracked_event = os_event_create(); os_event_set(srv_redo_log_tracked_event); } @@ -1251,17 +1254,34 @@ srv_free(void) { srv_conc_free(); - /* The mutexes srv_sys->mutex and srv_sys->tasks_mutex should have - been freed by sync_close() already. */ + if (!srv_read_only_mode) { + + for (ulint i = 0; i < srv_sys->n_sys_threads; i++) + os_event_free(srv_sys->sys_threads[i].event); + + os_event_free(srv_error_event); + os_event_free(srv_monitor_event); + os_event_free(srv_buf_dump_event); + os_event_free(srv_checkpoint_completed_event); + os_event_free(srv_redo_log_tracked_event); + mutex_free(&srv_sys->mutex); + mutex_free(&srv_sys->tasks_mutex); + } + +#ifdef WITH_INNODB_DISALLOW_WRITES + os_event_free(srv_allow_writes_event); +#endif /* WITH_INNODB_DISALLOW_WRITES */ + +#ifndef HAVE_ATOMIC_BUILTINS + mutex_free(&server_mutex); +#endif + mutex_free(&srv_innodb_monitor_mutex); + mutex_free(&page_zip_stat_per_index_mutex); + mem_free(srv_sys); srv_sys = NULL; trx_i_s_cache_free(trx_i_s_cache); - - if (!srv_read_only_mode) { - os_event_free(srv_buf_dump_event); - srv_buf_dump_event = NULL; - } } /*********************************************************************//** @@ -2073,7 +2093,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_monitor_thread)( /*===============================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -2250,7 +2270,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_error_monitor_thread)( /*=====================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -2320,7 +2340,7 @@ loop: if (sync_array_print_long_waits(&waiter, &sema) && sema == old_sema && os_thread_eq(waiter, old_waiter)) { #if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES) - if (srv_allow_writes_event->is_set) { + if (srv_allow_writes_event->is_set()) { #endif /* WITH_WSREP */ fatal_cnt++; #if defined(WITH_WSREP) && defined(WITH_INNODB_DISALLOW_WRITES) @@ -2408,10 +2428,15 @@ rescan_idle: Increment the server activity count. */ UNIV_INTERN void -srv_inc_activity_count(void) -/*========================*/ +srv_inc_activity_count( +/*===================*/ + bool ibuf_merge_activity) /*!< whether this activity bump + is caused by the background + change buffer merge */ { srv_sys->activity_count.inc(); + if (ibuf_merge_activity) + srv_sys->ibuf_merge_activity_count.inc(); } /**********************************************************************//** @@ -2498,7 +2523,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_redo_log_follow_thread)( /*=======================================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { @@ -2531,7 +2556,7 @@ DECLARE_THREAD(srv_redo_log_follow_thread)( /* TODO: sync with I_S log tracking status? */ ib_logf(IB_LOG_LEVEL_ERROR, "log tracking bitmap write failed, " - "stopping log tracking thread!\n"); + "stopping log tracking thread!"); break; } os_event_set(srv_redo_log_tracked_event); @@ -2573,7 +2598,7 @@ purge_archived_logs( if (!dir) { ib_logf(IB_LOG_LEVEL_WARN, "opening archived log directory %s failed. " - "Purge archived logs are not available\n", + "Purge archived logs are not available", srv_arch_dir); /* failed to open directory */ return(DB_ERROR); @@ -2661,7 +2686,7 @@ purge_archived_logs( archived_log_filename)) { ib_logf(IB_LOG_LEVEL_WARN, - "can't delete archived log file %s.\n", + "can't delete archived log file %s.", archived_log_filename); mutex_exit(&log_sys->mutex); @@ -2769,16 +2794,49 @@ srv_get_activity_count(void) return(srv_sys->activity_count); } +/** Get current server ibuf merge activity count. +@return ibuf merge activity count */ +static +ulint +srv_get_ibuf_merge_activity_count(void) +{ + return(srv_sys->ibuf_merge_activity_count); +} + /*******************************************************************//** -Check if there has been any activity. +Check if there has been any activity. Considers background change buffer +merge as regular server activity unless a non-default +old_ibuf_merge_activity_count value is passed, in which case the merge will be +treated as keeping server idle. @return FALSE if no change in activity counter. */ UNIV_INTERN ibool srv_check_activity( /*===============*/ - ulint old_activity_count) /*!< in: old activity count */ + ulint old_activity_count, /*!< in: old activity count */ + /*!< old change buffer merge + activity count, or + ULINT_UNDEFINED */ + ulint old_ibuf_merge_activity_count) { - return(srv_sys->activity_count != old_activity_count); + ulint new_activity_count = srv_sys->activity_count; + if (old_ibuf_merge_activity_count == ULINT_UNDEFINED) + return(new_activity_count != old_activity_count); + + /* If we care about ibuf merge activity, then the server is considered + idle if all activity, if any, was due to ibuf merge. */ + ulint new_ibuf_merge_activity_count + = srv_sys->ibuf_merge_activity_count; + + ut_ad(new_ibuf_merge_activity_count <= new_activity_count); + ut_ad(new_ibuf_merge_activity_count >= old_ibuf_merge_activity_count); + ut_ad(new_activity_count >= old_activity_count); + + ulint ibuf_merge_activity_delta = + new_ibuf_merge_activity_count - old_ibuf_merge_activity_count; + ulint activity_delta = new_activity_count - old_activity_count; + + return (activity_delta > ibuf_merge_activity_delta); } /********************************************************************//** @@ -2913,7 +2971,7 @@ srv_master_do_active_tasks(void) /* Do an ibuf merge */ srv_main_thread_op_info = "doing insert buffer merge"; counter_time = ut_time_us(NULL); - ibuf_contract_in_background(0, FALSE); + ibuf_merge_in_background(false); MONITOR_INC_TIME_IN_MICRO_SECS( MONITOR_SRV_IBUF_MERGE_MICROSECOND, counter_time); @@ -3008,7 +3066,7 @@ srv_master_do_idle_tasks(void) /* Do an ibuf merge */ counter_time = ut_time_us(NULL); srv_main_thread_op_info = "doing insert buffer merge"; - ibuf_contract_in_background(0, TRUE); + ibuf_merge_in_background(true); MONITOR_INC_TIME_IN_MICRO_SECS( MONITOR_SRV_IBUF_MERGE_MICROSECOND, counter_time); @@ -3096,7 +3154,7 @@ srv_master_do_shutdown_tasks( /* Do an ibuf merge */ srv_main_thread_op_info = "doing insert buffer merge"; - n_bytes_merged = ibuf_contract_in_background(0, TRUE); + n_bytes_merged = ibuf_merge_in_background(true); /* Flush logs if needed */ srv_sync_log_buffer_in_background(); @@ -3136,12 +3194,14 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_master_thread)( /*==============================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { srv_slot_t* slot; ulint old_activity_count = srv_get_activity_count(); + ulint old_ibuf_merge_activity_count + = srv_get_ibuf_merge_activity_count(); ib_time_t last_print_time; ut_ad(!srv_read_only_mode); @@ -3179,8 +3239,12 @@ loop: srv_current_thread_priority = srv_master_thread_priority; - if (srv_check_activity(old_activity_count)) { + if (srv_check_activity(old_activity_count, + old_ibuf_merge_activity_count)) { + old_activity_count = srv_get_activity_count(); + old_ibuf_merge_activity_count + = srv_get_ibuf_merge_activity_count(); srv_master_do_active_tasks(); } else { srv_master_do_idle_tasks(); @@ -3290,7 +3354,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_worker_thread)( /*==============================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { srv_slot_t* slot; @@ -3558,7 +3622,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(srv_purge_coordinator_thread)( /*=========================================*/ - void* arg __attribute__((unused))) /*!< in: a dummy parameter + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { srv_slot_t* slot; diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index 2455dc1c9a9..ca1eb194b00 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2015, MariaDB Corporation @@ -562,7 +562,7 @@ UNIV_INTERN void srv_normalize_path_for_win( /*=======================*/ - char* str __attribute__((unused))) /*!< in/out: null-terminated + char* str MY_ATTRIBUTE((unused))) /*!< in/out: null-terminated character string */ { #ifdef __WIN__ @@ -579,7 +579,7 @@ srv_normalize_path_for_win( /*********************************************************************//** Creates a log file. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t create_log_file( /*============*/ @@ -797,7 +797,7 @@ create_log_files_rename( /*********************************************************************//** Opens a log file. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t open_log_file( /*==========*/ @@ -825,7 +825,7 @@ open_log_file( /*********************************************************************//** Creates or opens database data files and closes them. @return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t open_or_create_data_files( /*======================*/ @@ -2483,40 +2483,6 @@ files_checked: create_log_files_rename(logfilename, dirnamelen, max_flushed_lsn, logfile0); -#ifdef UNIV_LOG_ARCHIVE - } else if (srv_archive_recovery) { - - ib_logf(IB_LOG_LEVEL_INFO, - " Starting archive recovery from a backup..."); - - err = recv_recovery_from_archive_start( - min_flushed_lsn, srv_archive_recovery_limit_lsn, - min_arch_log_no); - if (err != DB_SUCCESS) { - - return(DB_ERROR); - } - /* Since ibuf init is in dict_boot, and ibuf is needed - in any disk i/o, first call dict_boot */ - - err = dict_boot(); - - if (err != DB_SUCCESS) { - return(err); - } - - ib_bh = trx_sys_init_at_db_start(); - n_recovered_trx = UT_LIST_GET_LEN(trx_sys->rw_trx_list); - - /* The purge system needs to create the purge view and - therefore requires that the trx_sys is inited. */ - - trx_purge_sys_create(srv_n_purge_threads, ib_bh); - - srv_startup_is_before_trx_rollback_phase = FALSE; - - recv_recovery_from_archive_finish(); -#endif /* UNIV_LOG_ARCHIVE */ } else { /* Check if we support the max format that is stamped @@ -3213,15 +3179,13 @@ innobase_shutdown_for_mysql(void) logs_empty_and_mark_files_at_shutdown() and should have already quit or is quitting right now. */ - if (srv_use_mtflush) { /* g. Exit the multi threaded flush threads */ buf_mtflu_io_thread_exit(); } - os_mutex_enter(os_sync_mutex); - + os_rmb; if (os_thread_count == 0) { /* All the threads have exited or are just exiting; NOTE that the threads may not have completed their @@ -3231,15 +3195,11 @@ innobase_shutdown_for_mysql(void) os_thread_exit(). Now we just sleep 0.1 seconds and hope that is enough! */ - os_mutex_exit(os_sync_mutex); - os_thread_sleep(100000); break; } - os_mutex_exit(os_sync_mutex); - os_thread_sleep(100000); } @@ -3348,26 +3308,23 @@ innobase_shutdown_for_mysql(void) que_close(); row_mysql_close(); srv_mon_free(); - sync_close(); srv_free(); fil_close(); - /* 4. Free the os_conc_mutex and all os_events and os_mutexes */ - - os_sync_free(); - - /* 5. Free all allocated memory */ + /* 4. Free all allocated memory */ pars_lexer_close(); log_mem_free(); buf_pool_free(srv_buf_pool_instances); mem_close(); + sync_close(); /* ut_free_all_mem() frees all allocated memory not freed yet in shutdown, and it will also free the ut_list_mutex, so it should be the last one for all operation */ ut_free_all_mem(); + os_rmb; if (os_thread_count != 0 || os_event_count != 0 || os_mutex_count != 0 diff --git a/storage/xtradb/sync/sync0arr.cc b/storage/xtradb/sync/sync0arr.cc index d881c5de2f5..c311d2cbd7d 100644 --- a/storage/xtradb/sync/sync0arr.cc +++ b/storage/xtradb/sync/sync0arr.cc @@ -336,21 +336,21 @@ sync_cell_get_event( ulint type = cell->request_type; if (type == SYNC_MUTEX) { - return(((ib_mutex_t*) cell->wait_object)->event); + return(&((ib_mutex_t*) cell->wait_object)->event); } else if (type == SYNC_PRIO_MUTEX) { - return(((ib_prio_mutex_t*) cell->wait_object) + return(&((ib_prio_mutex_t*) cell->wait_object) ->high_priority_event); } else if (type == RW_LOCK_WAIT_EX) { - return(((rw_lock_t*) cell->wait_object)->wait_ex_event); + return(&((rw_lock_t*) cell->wait_object)->wait_ex_event); } else if (type == PRIO_RW_LOCK_SHARED) { - return(((prio_rw_lock_t *) cell->wait_object) + return(&((prio_rw_lock_t *) cell->wait_object) ->high_priority_s_event); } else if (type == PRIO_RW_LOCK_EX) { - return(((prio_rw_lock_t *) cell->wait_object) + return(&((prio_rw_lock_t *) cell->wait_object) ->high_priority_x_event); } else { /* RW_LOCK_SHARED and RW_LOCK_EX wait on the same event */ ut_ad(type == RW_LOCK_SHARED || type == RW_LOCK_EX); - return(((rw_lock_t*) cell->wait_object)->event); + return(&((rw_lock_t*) cell->wait_object)->event); } } diff --git a/storage/xtradb/sync/sync0rw.cc b/storage/xtradb/sync/sync0rw.cc index 00fb5e511a4..729f510013d 100644 --- a/storage/xtradb/sync/sync0rw.cc +++ b/storage/xtradb/sync/sync0rw.cc @@ -261,8 +261,8 @@ rw_lock_create_func( lock->last_x_file_name = "not yet reserved"; lock->last_s_line = 0; lock->last_x_line = 0; - lock->event = os_event_create(); - lock->wait_ex_event = os_event_create(); + os_event_create(&lock->event); + os_event_create(&lock->wait_ex_event); mutex_enter(&rw_lock_list_mutex); @@ -304,9 +304,9 @@ rw_lock_create_func( cline); lock->high_priority_s_waiters = 0; - lock->high_priority_s_event = os_event_create(); + os_event_create(&lock->high_priority_s_event); lock->high_priority_x_waiters = 0; - lock->high_priority_x_event = os_event_create(); + os_event_create(&lock->high_priority_x_event); lock->high_priority_wait_ex_waiter = 0; } @@ -334,9 +334,9 @@ rw_lock_free_func( mutex = rw_lock_get_mutex(lock); #endif /* !INNODB_RW_LOCKS_USE_ATOMICS */ - os_event_free(lock->event); + os_event_free(&lock->event, false); - os_event_free(lock->wait_ex_event); + os_event_free(&lock->wait_ex_event, false); ut_ad(UT_LIST_GET_PREV(list, lock) == NULL || UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N); @@ -366,8 +366,8 @@ rw_lock_free_func( /*==============*/ prio_rw_lock_t* lock) /*!< in: rw-lock */ { - os_event_free(lock->high_priority_s_event); - os_event_free(lock->high_priority_x_event); + os_event_free(&lock->high_priority_s_event, false); + os_event_free(&lock->high_priority_x_event, false); rw_lock_free_func(&lock->base_lock); } diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc index 702dd240f16..7458a052224 100644 --- a/storage/xtradb/sync/sync0sync.cc +++ b/storage/xtradb/sync/sync0sync.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -212,10 +212,7 @@ UNIV_INTERN mysql_pfs_key_t sync_thread_mutex_key; /** Global list of database mutexes (not OS mutexes) created. */ UNIV_INTERN ut_list_base_node_t mutex_list; -/** Global list of priority mutexes. A subset of mutex_list */ -UNIV_INTERN UT_LIST_BASE_NODE_T(ib_prio_mutex_t) prio_mutex_list; - -/** Mutex protecting the mutex_list and prio_mutex_list variables */ +/** Mutex protecting the mutex_list variable */ UNIV_INTERN ib_mutex_t mutex_list_mutex; #ifdef UNIV_PFS_MUTEX @@ -280,7 +277,7 @@ mutex_create_func( os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &mutex->os_fast_mutex); mutex->lock_word = 0; #endif - mutex->event = os_event_create(); + os_event_create(&mutex->event); mutex_set_waiters(mutex, 0); #ifdef UNIV_DEBUG mutex->magic_n = MUTEX_MAGIC_N; @@ -349,11 +346,7 @@ mutex_create_func( cline, cmutex_name); mutex->high_priority_waiters = 0; - mutex->high_priority_event = os_event_create(); - - mutex_enter(&mutex_list_mutex); - UT_LIST_ADD_FIRST(list, prio_mutex_list, mutex); - mutex_exit(&mutex_list_mutex); + os_event_create(&mutex->high_priority_event); } /******************************************************************//** @@ -400,7 +393,7 @@ mutex_free_func( mutex_exit(&mutex_list_mutex); } - os_event_free(mutex->event); + os_event_free(&mutex->event, false); #ifdef UNIV_MEM_DEBUG func_exit: #endif /* UNIV_MEM_DEBUG */ @@ -427,12 +420,8 @@ mutex_free_func( /*============*/ ib_prio_mutex_t* mutex) /*!< in: mutex */ { - mutex_enter(&mutex_list_mutex); - UT_LIST_REMOVE(list, prio_mutex_list, mutex); - mutex_exit(&mutex_list_mutex); - ut_a(mutex->high_priority_waiters == 0); - os_event_free(mutex->high_priority_event); + os_event_free(&mutex->high_priority_event, false); mutex_free_func(&mutex->base_mutex); } @@ -446,10 +435,10 @@ ulint mutex_enter_nowait_func( /*====================*/ ib_mutex_t* mutex, /*!< in: pointer to mutex */ - const char* file_name __attribute__((unused)), + const char* file_name MY_ATTRIBUTE((unused)), /*!< in: file name where mutex requested */ - ulint line __attribute__((unused))) + ulint line MY_ATTRIBUTE((unused))) /*!< in: line where requested */ { ut_ad(mutex_validate(mutex)); @@ -722,7 +711,7 @@ mutex_signal_object( /* The memory order of resetting the waiters field and signaling the object is important. See LEMMA 1 above. */ - os_event_set(mutex->event); + os_event_set(&mutex->event); sync_array_object_signalled(); } @@ -1555,7 +1544,6 @@ sync_init(void) /* Init the mutex list and create the mutex to protect it. */ UT_LIST_INIT(mutex_list); - UT_LIST_INIT(prio_mutex_list); mutex_create(mutex_list_mutex_key, &mutex_list_mutex, SYNC_NO_ORDER_CHECK); #ifdef UNIV_SYNC_DEBUG @@ -1602,22 +1590,17 @@ sync_thread_level_arrays_free(void) #endif /* UNIV_SYNC_DEBUG */ /******************************************************************//** -Frees the resources in InnoDB's own synchronization data structures. Use -os_sync_free() after calling this. */ +Frees the resources in InnoDB's own synchronization data structures. */ UNIV_INTERN void sync_close(void) /*===========*/ { ib_mutex_t* mutex; - ib_prio_mutex_t* prio_mutex; sync_array_close(); - for (prio_mutex = UT_LIST_GET_FIRST(prio_mutex_list); prio_mutex;) { - mutex_free(prio_mutex); - prio_mutex = UT_LIST_GET_FIRST(prio_mutex_list); - } + mutex_free(&rw_lock_list_mutex); for (mutex = UT_LIST_GET_FIRST(mutex_list); mutex != NULL; @@ -1635,7 +1618,6 @@ sync_close(void) mutex = UT_LIST_GET_FIRST(mutex_list); } - mutex_free(&mutex_list_mutex); #ifdef UNIV_SYNC_DEBUG mutex_free(&sync_thread_mutex); @@ -1646,6 +1628,8 @@ sync_close(void) os_fast_mutex_free(&rw_lock_debug_mutex); #endif /* UNIV_SYNC_DEBUG */ + mutex_free(&mutex_list_mutex); + sync_initialized = FALSE; } diff --git a/storage/xtradb/trx/trx0i_s.cc b/storage/xtradb/trx/trx0i_s.cc index 3230ac8308c..eacd9212d2f 100644 --- a/storage/xtradb/trx/trx0i_s.cc +++ b/storage/xtradb/trx/trx0i_s.cc @@ -1466,6 +1466,8 @@ trx_i_s_cache_free( /*===============*/ trx_i_s_cache_t* cache) /*!< in, own: cache to free */ { + rw_lock_free(&cache->rw_lock); + mutex_free(&cache->last_read_mutex); hash_table_free(cache->locks_hash); ha_storage_free(cache->storage); table_cache_free(&cache->innodb_trx); diff --git a/storage/xtradb/trx/trx0purge.cc b/storage/xtradb/trx/trx0purge.cc index 9d9fe73de6e..d9e40c5d6f5 100644 --- a/storage/xtradb/trx/trx0purge.cc +++ b/storage/xtradb/trx/trx0purge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -917,7 +917,7 @@ Fetches the next undo log record from the history list to purge. It must be released with the corresponding release function. @return copy of an undo log record or pointer to trx_purge_dummy_rec, if the whole undo log can skipped in purge; NULL if none left */ -static __attribute__((warn_unused_result, nonnull)) +static MY_ATTRIBUTE((warn_unused_result, nonnull)) trx_undo_rec_t* trx_purge_fetch_next_rec( /*=====================*/ diff --git a/storage/xtradb/trx/trx0rec.cc b/storage/xtradb/trx/trx0rec.cc index fa3fe0904b8..74a63b60286 100644 --- a/storage/xtradb/trx/trx0rec.cc +++ b/storage/xtradb/trx/trx0rec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1133,7 +1133,7 @@ trx_undo_rec_get_partial_row( /***********************************************************************//** Erases the unused undo log page end. @return TRUE if the page contained something, FALSE if it was empty */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) ibool trx_undo_erase_page_end( /*====================*/ @@ -1159,7 +1159,7 @@ byte* trx_undo_parse_erase_page_end( /*==========================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ page_t* page, /*!< in: page or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ { @@ -1442,7 +1442,7 @@ NOTE: the caller must have latches on the clustered index page. @retval true if the undo log has been truncated and we cannot fetch the old version @retval false if the undo log record is available */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool trx_undo_get_undo_rec( /*==================*/ @@ -1470,7 +1470,7 @@ trx_undo_get_undo_rec( #ifdef UNIV_DEBUG #define ATTRIB_USED_ONLY_IN_DEBUG #else /* UNIV_DEBUG */ -#define ATTRIB_USED_ONLY_IN_DEBUG __attribute__((unused)) +#define ATTRIB_USED_ONLY_IN_DEBUG MY_ATTRIBUTE((unused)) #endif /* UNIV_DEBUG */ /*******************************************************************//** diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc index 67f63d08303..4618cf653f0 100644 --- a/storage/xtradb/trx/trx0roll.cc +++ b/storage/xtradb/trx/trx0roll.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -341,7 +341,7 @@ the row, these locks are naturally released in the rollback. Savepoints which were set after this savepoint are deleted. @return if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t trx_rollback_to_savepoint_for_mysql_low( /*====================================*/ @@ -653,7 +653,7 @@ trx_rollback_active( "in recovery", table->name, trx->table_id); - err = row_drop_table_for_mysql(table->name, trx, TRUE); + err = row_drop_table_for_mysql(table->name, trx, TRUE, FALSE); trx_commit_for_mysql(trx); ut_a(err == DB_SUCCESS); @@ -808,7 +808,7 @@ extern "C" UNIV_INTERN os_thread_ret_t DECLARE_THREAD(trx_rollback_or_clean_all_recovered)( /*================================================*/ - void* arg __attribute__((unused))) + void* arg MY_ATTRIBUTE((unused))) /*!< in: a dummy parameter required by os_thread_create */ { diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index a3342ee36df..41f8c166190 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1179,7 +1179,7 @@ trx_serialisation_number_get( /****************************************************************//** Assign the transaction its history serialisation number and write the update UNDO log record to the assigned rollback segment. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_write_serialisation_history( /*============================*/ @@ -1266,7 +1266,7 @@ trx_write_serialisation_history( /******************************************************************** Finalize a transaction containing updates for a FTS table. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_finalize_for_fts_table( /*=======================*/ @@ -1299,7 +1299,7 @@ trx_finalize_for_fts_table( /******************************************************************//** Finalize a transaction containing updates to FTS tables. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_finalize_for_fts( /*=================*/ @@ -1374,7 +1374,7 @@ trx_flush_log_if_needed_low( /**********************************************************************//** If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_flush_log_if_needed( /*====================*/ @@ -1389,7 +1389,7 @@ trx_flush_log_if_needed( /****************************************************************//** Commits a transaction in memory. */ -static __attribute__((nonnull)) +static MY_ATTRIBUTE((nonnull)) void trx_commit_in_memory( /*=================*/ @@ -2441,7 +2441,7 @@ which is in the prepared state @return trx on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) trx_t* trx_get_trx_by_xid_low( /*===================*/ diff --git a/storage/xtradb/trx/trx0undo.cc b/storage/xtradb/trx/trx0undo.cc index edb85a89c17..cdd23726f2e 100644 --- a/storage/xtradb/trx/trx0undo.cc +++ b/storage/xtradb/trx/trx0undo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -419,11 +419,11 @@ trx_undo_page_init( Creates a new undo log segment in file. @return DB_SUCCESS if page creation OK possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t trx_undo_seg_create( /*================*/ - trx_rseg_t* rseg __attribute__((unused)),/*!< in: rollback segment */ + trx_rseg_t* rseg MY_ATTRIBUTE((unused)),/*!< in: rollback segment */ trx_rsegf_t* rseg_hdr,/*!< in: rollback segment header, page x-latched */ ulint type, /*!< in: type of the segment: TRX_UNDO_INSERT or @@ -443,7 +443,9 @@ trx_undo_seg_create( ibool success; dberr_t err = DB_SUCCESS; - ut_ad(mtr && id && rseg_hdr); + ut_ad(mtr != NULL); + ut_ad(id != NULL); + ut_ad(rseg_hdr != NULL); ut_ad(mutex_own(&(rseg->mutex))); /* fputs(type == TRX_UNDO_INSERT @@ -827,7 +829,7 @@ byte* trx_undo_parse_discard_latest( /*==========================*/ byte* ptr, /*!< in: buffer */ - byte* end_ptr __attribute__((unused)), /*!< in: buffer end */ + byte* end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ page_t* page, /*!< in: page or NULL */ mtr_t* mtr) /*!< in: mtr or NULL */ { @@ -1555,7 +1557,7 @@ Creates a new undo log. @return DB_SUCCESS if successful in creating the new undo lob object, possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_OUT_OF_MEMORY */ -static __attribute__((nonnull, warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t trx_undo_create( /*============*/ diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 8a092e8f085..eef5c950684 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6539,7 +6539,8 @@ MY_UCA_INFO my_uca_v400= 0, /* nitems */ NULL, /* item */ NULL /* flags */ - } + }, + 0 /* levelno */ }, }, @@ -30084,7 +30085,8 @@ MY_UCA_INFO my_uca_v520_th= THAI_CONTRACTIONS, /* nitems */ thai_contractions, /* item */ NULL /* flags */ - } + }, + 0 /* levelno */ }, { 0x10FFFF, /* maxchar */ @@ -30094,7 +30096,8 @@ MY_UCA_INFO my_uca_v520_th= THAI_CONTRACTIONS_W2, /* nitems */ thai_contractions_w2, /* item */ NULL /* flags */ - } + }, + 1 /* levelno */ }, }, @@ -30127,8 +30130,9 @@ MY_UCA_INFO my_uca_v520= { /* Contractions: */ 0, /* nitems */ NULL, /* item */ - NULL /* flags */ - } + NULL /* flags */ + }, + 0 /* levelno */ }, }, @@ -31529,37 +31533,108 @@ my_uca_previous_context_find(my_uca_scanner *scanner, /****************************************************************/ +/** + Implicit weights for a code CP are constructed as follows: + [.AAAA.0020.0002][.BBBB.0000.0000] + + where: + AAAA= BASE + (CP >> 15); + BBBB= (CP & 0x7FFF) | 0x8000; + + There are two weights in the primary level (AAAA followed by BBBB). + There is one weight on other levels: + - 0020 on the secondary level + - 0002 on the tertiary level +*/ + /** - Return implicit UCA weight + Return BASE for an implicit weight on the primary level + + According to UCA, BASE is calculated as follows: + - FB40 for Unified_Ideograph=True AND + ((Block=CJK_Unified_Ideograph) OR + (Block=CJK_Compatibility_Ideographs)) + - FB80 for Unified_Ideograph=True AND NOT + ((Block=CJK_Unified_Ideograph) OR + (Block=CJK_Compatibility_Ideographs)) + - FBC0 for any other code point + TODO: it seems we're not handling BASE correctly: + - check what are those blocks + - there are more Unified Ideograph blocks in the latest Unicode versions +*/ +static inline uint16 +my_uca_implicit_weight_base(my_wc_t code) +{ + if (code >= 0x3400 && code <= 0x4DB5) + return 0xFB80; + if (code >= 0x4E00 && code <= 0x9FA5) + return 0xFB40; + return 0xFBC0; +} + + +static inline void +my_uca_implicit_weight_put(uint16 *to, my_wc_t code, uint level) +{ + switch (level) { + case 1: to[0]= 0x0020; to[1]= 0; break; /* Secondary level */ + case 2: to[0]= 0x0002; to[1]= 0; break; /* Tertiary level */ + case 3: to[0]= 0x0001; to[1]= 0; break; /* Quaternary level */ + default: + DBUG_ASSERT(0); + case 0: + break; + } + /* Primary level */ + to[0]= (code >> 15) + my_uca_implicit_weight_base(code); + to[1]= (code & 0x7FFF) | 0x8000; + to[2]= 0; +} + +/****************************************************************/ + +/** + Return an implicit UCA weight for the primary level. Used for characters that do not have assigned UCA weights. @param scanner UCA weight scanner @return The leading implicit weight. + + The second weight is stored in scanner->implicit[0] + and is later returned on the next my_uca_scanner_next_any() call. */ static inline int -my_uca_scanner_next_implicit(my_uca_scanner *scanner) +my_uca_scanner_next_implicit_primary(my_uca_scanner *scanner) { - scanner->code= (scanner->page << 8) + scanner->code; - scanner->implicit[0]= (scanner->code & 0x7FFF) | 0x8000; - scanner->implicit[1]= 0; + my_wc_t wc= (scanner->page << 8) + scanner->code; + scanner->implicit[0]= (wc & 0x7FFF) | 0x8000; /* The second weight */ + scanner->implicit[1]= 0; /* 0 terminator */ scanner->wbeg= scanner->implicit; - - scanner->page= scanner->page >> 7; - - if (scanner->code >= 0x3400 && scanner->code <= 0x4DB5) - scanner->page+= 0xFB80; - else if (scanner->code >= 0x4E00 && scanner->code <= 0x9FA5) - scanner->page+= 0xFB40; - else - scanner->page+= 0xFBC0; - - return scanner->page; + return my_uca_implicit_weight_base(wc) + (wc >> 15); } +/** + Return an implicit weight for the current level + (according to scanner->level->levelno). + +*/ +static inline int +my_uca_scanner_next_implicit(my_uca_scanner *scanner) +{ + switch (scanner->level->levelno) { + case 0: return my_uca_scanner_next_implicit_primary(scanner);/* Primary level*/ + case 1: scanner->wbeg= nochar; return 0x0020; /* Secondary level */ + case 2: scanner->wbeg= nochar; return 0x0002; /* Tertiary level */ + default: scanner->wbeg= nochar; break; + } + DBUG_ASSERT(0); + return 0; +} + /* The same two functions for any character set */ @@ -33528,6 +33603,7 @@ my_char_weight_put(MY_UCA_WEIGHT_LEVEL *dst, { size_t chlen; const uint16 *from= NULL; + uint16 implicit_weights[3]; for (chlen= len; chlen > 1; chlen--) { @@ -33542,6 +33618,11 @@ my_char_weight_put(MY_UCA_WEIGHT_LEVEL *dst, if (!from) { from= my_char_weight_addr(dst, *str); + if (!from) + { + from= implicit_weights; + my_uca_implicit_weight_put(implicit_weights, *str, dst->levelno); + } str++; len--; } @@ -33594,6 +33675,25 @@ my_uca_copy_page(MY_CHARSET_LOADER *loader, } +static my_bool +my_uca_generate_implicit_page(MY_CHARSET_LOADER *loader, + MY_UCA_WEIGHT_LEVEL *dst, + uint page) +{ + uint chc, size= 256 * dst->lengths[page] * sizeof(uint16); + if (!(dst->weights[page]= (uint16 *) (loader->once_alloc)(size))) + return TRUE; + + memset(dst->weights[page], 0, size); + for (chc= 0 ; chc < 256; chc++) + { + uint16 *w= dst->weights[page] + chc * dst->lengths[page]; + my_uca_implicit_weight_put(w, (page << 8) + chc, dst->levelno); + } + return FALSE; +} + + static my_bool apply_shift(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, MY_COLL_RULE *r, int level, @@ -33711,7 +33811,7 @@ my_uca_init_one_contraction(MY_CONTRACTIONS *contractions, static my_bool apply_one_rule(MY_CHARSET_LOADER *loader, - MY_COLL_RULES *rules, MY_COLL_RULE *r, int level, + MY_COLL_RULES *rules, MY_COLL_RULE *r, MY_UCA_WEIGHT_LEVEL *dst) { size_t nweights; @@ -33787,7 +33887,7 @@ apply_one_rule(MY_CHARSET_LOADER *loader, } /* Apply level difference. */ - return apply_shift(loader, rules, r, level, to, nweights); + return apply_shift(loader, rules, r, dst->levelno, to, nweights); } @@ -33820,8 +33920,92 @@ check_rules(MY_CHARSET_LOADER *loader, } +/** + Calculates how many weights are needed on the given page. + + In case of implicit weights, the functions returns 3: + two implicit weights plus trailing 0. + + Implicit weights can appear if we do something like this: + \u3400 + a + I.e. we reset to a character that does not have an explicit weight (U+3400), + and then reorder another character relatively to it. +*/ +static uint my_weight_size_on_page(const MY_UCA_WEIGHT_LEVEL *src, uint page) +{ + return src->lengths[page] ? src->lengths[page] : 3; +} + + +/** + Generate default weights for a page: + - copy default weights from "src", or + - generate implicit weights algorithmically. + Note, some of these default weights will change later, + during a apply_one_rule() call. +*/ static my_bool -init_weight_level(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, int level, +my_uca_generate_page(MY_CHARSET_LOADER *loader, + MY_UCA_WEIGHT_LEVEL *dst, const MY_UCA_WEIGHT_LEVEL *src, + uint pageno) +{ + DBUG_ASSERT(dst->levelno == src->levelno); + return src->lengths[pageno] ? + /* + A page with explicit weights and some special rules. + Copy all weights from the page in "src". + */ + my_uca_copy_page(loader, src, dst, pageno) : + /* + A page with implicit weights and some special rules. + Generate default weights for all characters on this page + algorithmically now, at initialization time. + */ + my_uca_generate_implicit_page(loader, dst, pageno); +} + + +/** + Find all pages that we have special rules on and + populate default (explicit or implicit) weights for these pages. +*/ +static my_bool +my_uca_generate_pages(MY_CHARSET_LOADER *loader, + MY_UCA_WEIGHT_LEVEL *dst, + const MY_UCA_WEIGHT_LEVEL *src, + uint npages) +{ + uint page; + for (page= 0; page < npages; page++) + { + if (dst->weights[page]) + { + /* A page with explicit weights with no special rules */ + continue; + } + + if (!dst->lengths[page]) + { + /* + A page with implicit weights with no special rules. + Keep dst->weights[page]==NULL and dst->lengths[page]==0. + Weights for this page will be generated at run time algorithmically, + using my_uca_scanner_next_implicit(). + */ + continue; + } + + /* Found a page with some special rules. */ + if (my_uca_generate_page(loader, dst, src, page)) + return TRUE; + } + return FALSE; +} + + +static my_bool +init_weight_level(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, MY_UCA_WEIGHT_LEVEL *dst, const MY_UCA_WEIGHT_LEVEL *src) { MY_COLL_RULE *r, *rlast; @@ -33829,6 +34013,7 @@ init_weight_level(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, int level, size_t i, npages= (src->maxchar + 1) / 256; dst->maxchar= src->maxchar; + dst->levelno= src->levelno; if (check_rules(loader, rules, dst, src)) return TRUE; @@ -33860,9 +34045,15 @@ init_weight_level(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, int level, } else { - uint pageb= (r->base[0] >> 8); - if (dst->lengths[pagec] < src->lengths[pageb]) - dst->lengths[pagec]= src->lengths[pageb]; + /* + Not an expansion and not a contraction. + The page correspoding to r->curr[0] in "dst" + will need at least the same amount of weights + that r->base[0] has in "src". + */ + uint wsize= my_weight_size_on_page(src, r->base[0] >> 8); + if (dst->lengths[pagec] < wsize) + dst->lengths[pagec]= wsize; } dst->weights[pagec]= NULL; /* Mark that we'll overwrite this page */ } @@ -33872,18 +34063,8 @@ init_weight_level(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, int level, ncontractions += src->contractions.nitems; - /* Allocate pages that we'll overwrite and copy default weights */ - for (i= 0; i < npages; i++) - { - my_bool rc; - /* - Don't touch pages with lengths[i]==0, they have implicit weights - calculated algorithmically. - */ - if (!dst->weights[i] && dst->lengths[i] && - (rc= my_uca_copy_page(loader, src, dst, i))) - return rc; - } + if ((my_uca_generate_pages(loader, dst, src, npages))) + return TRUE; if (ncontractions) { @@ -33901,7 +34082,7 @@ init_weight_level(MY_CHARSET_LOADER *loader, MY_COLL_RULES *rules, int level, */ for (r= rules->rule; r < rlast; r++) { - if (apply_one_rule(loader, rules, r, level, dst)) + if (apply_one_rule(loader, rules, r, dst)) return TRUE; } @@ -33984,7 +34165,7 @@ create_tailoring(struct charset_info_st *cs, cs->caseinfo= &my_unicase_default; } - if ((rc= init_weight_level(loader, &rules, 0, + if ((rc= init_weight_level(loader, &rules, &new_uca.level[0], &src_uca->level[0]))) goto ex; @@ -34047,7 +34228,7 @@ create_tailoring_multilevel(struct charset_info_st *cs, for (i= 0; i != num_level; i++) { - if ((rc= init_weight_level(loader, &rules, i, + if ((rc= init_weight_level(loader, &rules, &new_uca.level[i], &src_uca->level[i]))) goto ex; } diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index b18674bea46..15f41c6377f 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -45,9 +45,32 @@ Group=mysql # To allow memlock to be used as non-root user if set in configuration CapabilityBoundingSet=CAP_IPC_LOCK +# Prevent writes to /usr, /boot, and /etc +ProtectSystem=full + +# Doesn't yet work properly with SELinux enabled +# NoNewPrivileges=true + +PrivateDevices=true + +# Prevent accessing /home, /root and /run/user +ProtectHome=true + # Execute pre and post scripts as root, otherwise it does it as User= PermissionsStartOnly=true +@SYSTEMD_EXECSTARTPRE@ + +# Perform automatic wsrep recovery. When server is started without wsrep, +# galera_recovery simply returns an empty string. In any case, however, +# the script is not expected to return with a non-zero status. +# It is always safe to unset _WSREP_START_POSITION environment variable. +# Do not panic if galera_recovery script is not available. (MDEV-10538) +ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" +ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \ + VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] \ + && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1" + # Needed to create system tables etc. # ExecStartPre=/usr/bin/mysql_install_db -u mysql @@ -56,10 +79,12 @@ PermissionsStartOnly=true # Use the [service] section and Environment="MYSQLD_OPTS=...". # This isn't a replacement for my.cnf. # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster -@SYSTEMD_EXECSTARTPRE@ -ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER +ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION @SYSTEMD_EXECSTARTPOST@ +# Unset _WSREP_START_POSITION environment variable. +ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" + KillMode=process KillSignal=SIGTERM diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index fb3b4b5f41d..e941f21526e 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -52,9 +52,38 @@ Group=mysql # To allow memlock to be used as non-root user if set in configuration CapabilityBoundingSet=CAP_IPC_LOCK +# Prevent writes to /usr, /boot, and /etc +ProtectSystem=full + +# Doesn't yet work properly with SELinux enabled +# NoNewPrivileges=true + +PrivateDevices=true + +# Prevent accessing /home, /root and /run/user +ProtectHome=true + # Execute pre and post scripts as root, otherwise it does it as User= PermissionsStartOnly=true +# Perform automatic wsrep recovery. When server is started without wsrep, +# galera_recovery simply returns an empty string. In any case, however, +# the script is not expected to return with a non-zero status. +# It is always safe to unset _WSREP_START_POSITION%I environment variable. +# Do not panic if galera_recovery script is not available. (MDEV-10538) +ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I" + +ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \ + VAR=`/usr/bin/galera_recovery --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf`; [ $? -eq 0 ] \ + && systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1" + +# Alternate: (remove ConditionPathExists above) +# use [mysqld.INSTANCENAME] as sections in my.cnf +# +#ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \ +# VAR=`/usr/bin/galera_recovery --defaults-group-suffix=%I`; [ $? -eq 0 ] \ +# && systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1" + # Needed to create system tables etc. # ExecStartPre=/usr/bin/mysql_install_db -u mysql @@ -64,11 +93,18 @@ PermissionsStartOnly=true # This isn't a replacement for my.cnf. # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster -ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf +# Note: Place $MYSQLD_OPTS at the very end for its options to take precedence. + +ExecStart=/usr/sbin/mysqld --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf \ + $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS # Alternate: (remove ConditionPathExists above) # use [mysqld.INSTANCENAME] as sections in my.cnf # -# ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS --defaults-group-suffix=%I +# ExecStart=/usr/sbin/mysqld --defaults-group-suffix=%I \ +# $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS + +# Unset _WSREP_START_POSITION environment variable. +ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I" KillMode=process KillSignal=SIGTERM diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 62bf1a57d13..b95127f954f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18507,6 +18507,7 @@ static void test_bug58036() /* Part1: try to connect with ucs2 client character set */ conn= mysql_client_init(NULL); mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2"); + if (mysql_real_connect(conn, opt_host, opt_user, opt_password, opt_db ? opt_db : "test", opt_port, opt_unix_socket, 0)) @@ -18557,7 +18558,6 @@ static void test_bug58036() printf("Got mysql_change_user() error (expected): %s (%d)\n", mysql_error(conn), mysql_errno(conn)); mysql_close(conn); - DBUG_VOID_RETURN; } @@ -19413,6 +19413,7 @@ static void test_big_packet() opt_password, current_db, opt_port, opt_unix_socket, 0))) { + mysql_close(mysql_local); fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } diff --git a/vio/viosocket.c b/vio/viosocket.c index e724165612c..e11460dd4b2 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -190,6 +190,12 @@ size_t vio_read(Vio *vio, uchar *buf, size_t size) { DBUG_PRINT("vio_error", ("Got error %d during read", errno)); } +#ifndef DEBUG_DATA_PACKETS + else + { + DBUG_DUMP("read_data", buf, ret); + } +#endif /* DEBUG_DATA_PACKETS */ #endif /* DBUG_OFF */ DBUG_PRINT("exit", ("%d", (int) ret)); DBUG_RETURN(ret); @@ -416,6 +422,13 @@ int vio_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode) DBUG_RETURN(r); } +/* + Check if vio is blocking + + @retval 0 is not blocking + @retval 1 is blocking +*/ + my_bool vio_is_blocking(Vio * vio) { @@ -570,7 +583,9 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive) my_bool vio_should_retry(Vio *vio) { - return (vio_errno(vio) == SOCKET_EINTR); + DBUG_ENTER("vio_should_retry"); + DBUG_PRINT("info", ("vio_errno: %d", vio_errno(vio))); + DBUG_RETURN(vio_errno(vio) == SOCKET_EINTR); } @@ -595,8 +610,9 @@ int vio_close(Vio *vio) { int r=0; DBUG_ENTER("vio_close"); + DBUG_PRINT("enter", ("sd: %d", mysql_socket_getfd(vio->mysql_socket))); - if (vio->type != VIO_CLOSED) + if (vio->type != VIO_CLOSED) { DBUG_ASSERT(vio->type == VIO_TYPE_TCPIP || vio->type == VIO_TYPE_SOCKET || @@ -927,6 +943,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout) my_socket sd= mysql_socket_getfd(vio->mysql_socket); MYSQL_SOCKET_WAIT_VARIABLES(locker, state) /* no ';' */ DBUG_ENTER("vio_io_wait"); + DBUG_PRINT("enter", ("timeout: %d", timeout)); /* Note that if zero timeout, then we will not block, so we do not need to @@ -938,7 +955,10 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout) PSI_SOCKET_SELECT, timeout); ret= my_io_wait_async(vio->async_context, event, timeout); if (ret == 0) + { + DBUG_PRINT("info", ("timeout")); errno= SOCKET_ETIMEDOUT; + } END_SOCKET_WAIT(locker,timeout); DBUG_RETURN(ret); } @@ -972,6 +992,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout) switch ((ret= poll(&pfd, 1, timeout))) { case -1: + DBUG_PRINT("error", ("poll returned -1")); /* On error, -1 is returned. */ break; case 0: @@ -979,6 +1000,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout) Set errno to indicate a timeout error. (This is not compiled in on WIN32.) */ + DBUG_PRINT("info", ("poll timeout")); errno= SOCKET_ETIMEDOUT; break; default: diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 3117cdf82ae..52b624d3376 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2011, 2015, MariaDB +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2011, 2016, MariaDB 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 @@ -213,7 +213,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file, } /* Load certs from the trusted ca */ - if (SSL_CTX_load_verify_locations(ssl_fd->ssl_context, ca_file, ca_path) == 0) + if (SSL_CTX_load_verify_locations(ssl_fd->ssl_context, ca_file, ca_path) <= 0) { DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed")); if (ca_file || ca_path) diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp index 3cb8520b65d..56df4ae791e 100644 --- a/win/packaging/ca/CustomAction.cpp +++ b/win/packaging/ca/CustomAction.cpp @@ -886,11 +886,11 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall) (QUERY_SERVICE_CONFIGW*)(void *)config_buffer; DWORD needed; BOOL ok= QueryServiceConfigW(service, config,sizeof(config_buffer), - &needed); + &needed) && (config->dwStartType != SERVICE_DISABLED); CloseServiceHandle(service); if (ok) { - mysqld_service_properties props; + mysqld_service_properties props; if (get_mysql_service_properties(config->lpBinaryPathName, &props)) continue; /* diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index 978a5c9c90d..befe070b404 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -66,6 +66,7 @@ + @@ -463,7 +464,7 @@ Key='SOFTWARE\Monty Program AB\@CPACK_WIX_PACKAGE_NAME@' Name='DATADIR' Value='[DATADIR]' Type='string' KeyPath='yes'/> - + @@ -851,6 +852,7 @@ + + + + = 600)]]> diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index dfde0cc53b3..bf9433ca34f 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_9.1_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_9.3_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) diff --git a/wsrep/wsrep_dummy.c b/wsrep/wsrep_dummy.c index fa726877fcf..eae084f1979 100644 --- a/wsrep/wsrep_dummy.c +++ b/wsrep/wsrep_dummy.c @@ -84,8 +84,15 @@ static wsrep_status_t dummy_options_set( static char* dummy_options_get (wsrep_t* w) { - WSREP_DBUG_ENTER(w); - return WSREP_DUMMY(w)->options; + char *options; + + WSREP_DBUG_ENTER(w); + options= WSREP_DUMMY(w)->options; + + if (options) + options= strdup(WSREP_DUMMY(w)->options); + + return options; } static wsrep_status_t dummy_connect( diff --git a/wsrep/wsrep_loader.c b/wsrep/wsrep_loader.c index 5c4e61e1832..f4d5991339e 100644 --- a/wsrep/wsrep_loader.c +++ b/wsrep/wsrep_loader.c @@ -37,6 +37,22 @@ static wsrep_log_cb_t logger = default_logger; * Library loader **************************************************************************/ +static int wsrep_check_iface_version(const char* found, const char* iface_ver) +{ + const size_t msg_len = 128; + char msg[128]; + + if (strcmp(found, iface_ver)) { + snprintf (msg, msg_len, + "provider interface version mismatch: need '%s', found '%s'", + iface_ver, found); + logger (WSREP_LOG_ERROR, msg); + return EINVAL; + } + + return 0; +} + static int verify(const wsrep_t *wh, const char *iface_ver) { char msg[128]; @@ -50,13 +66,8 @@ static int verify(const wsrep_t *wh, const char *iface_ver) VERIFY(wh); VERIFY(wh->version); - if (strcmp(wh->version, iface_ver)) { - snprintf (msg, sizeof(msg), - "provider interface version mismatch: need '%s', found '%s'", - iface_ver, wh->version); - logger (WSREP_LOG_ERROR, msg); + if (wsrep_check_iface_version(wh->version, iface_ver)) return EINVAL; - } VERIFY(wh->init); VERIFY(wh->options_set); @@ -107,6 +118,15 @@ static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym) return alias.dlfun; } +static int wsrep_check_version_symbol(void *dlh) +{ + char** dlversion = NULL; + dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); + if (dlversion == NULL) + return 0; + return wsrep_check_iface_version(*dlversion, WSREP_INTERFACE_VERSION); +} + extern int wsrep_dummy_loader(wsrep_t *w); int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) @@ -152,6 +172,11 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) goto out; } + if (wsrep_check_version_symbol(dlh) != 0) { + ret = EINVAL; + goto out; + } + if ((ret = (*dlfun)(*hptr)) != 0) { snprintf(msg, sizeof(msg)-1, "wsrep_load(): loader failed: %s", strerror(ret));