diff --git a/client/mysql.cc b/client/mysql.cc index db0780cba74..6e8089ea20b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2021, MariaDB Corporation. + Copyright (c) 2009, 2022, 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 @@ -3666,7 +3666,6 @@ print_table_data(MYSQL_RES *result) { String separator(256); MYSQL_ROW cur; - MYSQL_FIELD *field; bool *num_flag; num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result)); @@ -3678,7 +3677,7 @@ print_table_data(MYSQL_RES *result) mysql_field_seek(result,0); } separator.copy("+",1,charset_info); - while ((field = mysql_fetch_field(result))) + while (MYSQL_FIELD *field= mysql_fetch_field(result)) { uint length= column_names ? field->name_length : 0; if (quick) @@ -3700,7 +3699,7 @@ print_table_data(MYSQL_RES *result) { mysql_field_seek(result,0); (void) tee_fputs("|", PAGER); - for (uint off=0; (field = mysql_fetch_field(result)) ; off++) + while (MYSQL_FIELD *field= mysql_fetch_field(result)) { size_t name_length= (uint) strlen(field->name); size_t numcells= charset_info->numcells(field->name, @@ -3742,7 +3741,7 @@ print_table_data(MYSQL_RES *result) data_length= (uint) lengths[off]; } - field= mysql_fetch_field(result); + MYSQL_FIELD *field= mysql_fetch_field(result); field_max_length= field->max_length; /* diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 480308aa015..5a5c28f4032 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB + Copyright (c) 2010, 2012, 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 @@ -1060,7 +1060,6 @@ static void print_result() char prev[(NAME_LEN+9)*3+2]; char prev_alter[MAX_ALTER_STR_SIZE]; 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"); @@ -1069,7 +1068,7 @@ static void print_result() prev[0] = '\0'; prev_alter[0]= 0; - for (i = 0; (row = mysql_fetch_row(res)); i++) + while ((row = mysql_fetch_row(res))) { int changed = strcmp(prev, row[0]); my_bool status = !strcmp(row[2], "status"); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 58131077321..720616c5d5a 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB + Copyright (c) 2010, 2022, 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 @@ -1897,12 +1897,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) pthread_handler_t run_task(void *p) { - ulonglong counter= 0, queries; + ulonglong queries; ulonglong detach_counter; unsigned int commit_counter; MYSQL *mysql; MYSQL_RES *result; - MYSQL_ROW row; statement *ptr; thread_context *con= (thread_context *)p; @@ -2023,8 +2022,7 @@ limit_not_met: my_progname, mysql_errno(mysql), mysql_error(mysql)); else { - while ((row= mysql_fetch_row(result))) - counter++; + while (mysql_fetch_row(result)) {} mysql_free_result(result); } } @@ -2034,7 +2032,7 @@ limit_not_met: if (commit_rate && (++commit_counter == commit_rate)) { commit_counter= 0; - run_query(mysql, "COMMIT", strlen("COMMIT")); + run_query(mysql, C_STRING_WITH_LEN("COMMIT")); } if (con->limit && queries == con->limit) @@ -2046,7 +2044,7 @@ limit_not_met: end: if (commit_rate) - run_query(mysql, "COMMIT", strlen("COMMIT")); + run_query(mysql, C_STRING_WITH_LEN("COMMIT")); mysql_close(mysql); diff --git a/dbug/my_main.c b/dbug/my_main.c index 2b3e92b53cc..80db4d82e06 100644 --- a/dbug/my_main.c +++ b/dbug/my_main.c @@ -7,9 +7,7 @@ #include #include -int main (argc, argv) -int argc; -char *argv[]; +int main (int argc, char **argv) { register int result, ix; extern int factorial(int); diff --git a/extra/replace.c b/extra/replace.c index 7e94bfc36c3..8b20f812be0 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -148,9 +148,7 @@ int main(int argc, char *argv[]) /* reads options */ /* Initiates DEBUG - but no debugging here ! */ -static int static_get_options(argc,argv) -register int *argc; -register char **argv[]; +static int static_get_options(int *argc, char***argv) { int help,version; char *pos; @@ -218,10 +216,9 @@ register char **argv[]; } /* static_get_options */ -static int get_replace_strings(argc,argv,from_array,to_array) -register int *argc; -register char **argv[]; -POINTER_ARRAY *from_array,*to_array; +static int get_replace_strings(int *argc, char ***argv, + POINTER_ARRAY *from_array, + POINTER_ARRAY *to_array) { char *pos; @@ -974,9 +971,7 @@ static void free_buffer() bytes read from disk. */ -static int fill_buffer_retaining(fd,n) -File fd; -int n; +static int fill_buffer_retaining(File fd, int n) { int i; @@ -1019,9 +1014,7 @@ int n; /* Return 0 if convert is ok */ /* Global variable update is set if something was changed */ -static int convert_pipe(rep,in,out) -REPLACE *rep; -FILE *in,*out; +static int convert_pipe(REPLACE *rep, FILE *in, FILE *out) { int retain,error; uint length; diff --git a/libmariadb b/libmariadb index 5e94e7c27ff..485a3ad68c9 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 5e94e7c27ffad7e76665b1333a67975316b9c3c2 +Subproject commit 485a3ad68c93fd43acde8a0fe39a348292f1cf2d diff --git a/mysql-test/main/information_schema_tables.test b/mysql-test/main/information_schema_tables.test index bc4f269a3fb..ee277276b52 100644 --- a/mysql-test/main/information_schema_tables.test +++ b/mysql-test/main/information_schema_tables.test @@ -37,7 +37,9 @@ SELECT v.* FROM v JOIN INFORMATION_SCHEMA.TABLES WHERE DATA_LENGTH = -1; --eval KILL $conid --disconnect con1 --connection default +--disable_warnings DROP VIEW IF EXISTS vv; +--enable_warnings DROP VIEW v; DROP FUNCTION f; DROP TABLE t; diff --git a/mysql-test/suite/innodb/r/instant_alter_import.result b/mysql-test/suite/innodb/r/instant_alter_import.result index 5c6497b5939..2b2cd8bf796 100644 --- a/mysql-test/suite/innodb/r/instant_alter_import.result +++ b/mysql-test/suite/innodb/r/instant_alter_import.result @@ -130,3 +130,32 @@ UNLOCK TABLES; ALTER TABLE t2 IMPORT TABLESPACE; ERROR HY000: Index for table 't2' is corrupt; try to repair it DROP TABLE t1, t2; +# +# MDEV-28919 Assertion `(((core_null) + 7) >> 3) == +# oindex.n_core_null_bytes || !not_redundant()' failed +# +call mtr.add_suppression(" InnoDB: Tablespace for table `test`.`t` is set as discarded"); +CREATE TABLE t (a INTEGER, b INTEGER as (a) VIRTUAL, +c INTEGER)engine=innodb; +ALTER TABLE t DISCARD TABLESPACE; +FLUSH TABLES; +ALTER TABLE t DROP COLUMN b, algorithm=instant; +Warnings: +Warning 1814 Tablespace has been discarded for table `t` +ALTER TABLE t DROP COLUMN c, algorithm=instant; +Warnings: +Warning 1814 Tablespace has been discarded for table `t` +CREATE TABLE t1(a INTEGER)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +FLUSH TABLE t1 FOR EXPORT; +unlock tables; +ALTER TABLE t IMPORT tablespace; +Warnings: +Warning 1814 Tablespace has been discarded for table `t` +check table t; +Table Op Msg_type Msg_text +test.t check status OK +select * from t; +a +1 +DROP TABLE t, t1; diff --git a/mysql-test/suite/innodb/t/alter_copy.test b/mysql-test/suite/innodb/t/alter_copy.test index 6b6a0151de4..90f2171d10b 100644 --- a/mysql-test/suite/innodb/t/alter_copy.test +++ b/mysql-test/suite/innodb/t/alter_copy.test @@ -2,8 +2,7 @@ --source include/have_debug.inc --source include/have_debug_sync.inc --source include/not_embedded.inc -# Valgrind gives leaks from the first shutdown which confuses mtr -#--source include/not_valgrind.inc +--source include/no_valgrind_without_big.inc --echo # --echo # MDEV-11415 AVOID INTERMEDIATE COMMIT WHILE DOING diff --git a/mysql-test/suite/innodb/t/blob-crash.test b/mysql-test/suite/innodb/t/blob-crash.test index beb500553ea..5d529059742 100644 --- a/mysql-test/suite/innodb/t/blob-crash.test +++ b/mysql-test/suite/innodb/t/blob-crash.test @@ -1,5 +1,6 @@ --source include/maybe_debug.inc --source include/innodb_page_size_small.inc +--source include/no_valgrind_without_big.inc --echo # --echo # Bug #16963396 INNODB: USE OF LARGE EXTERNALLY-STORED FIELDS MAKES diff --git a/mysql-test/suite/innodb/t/instant_alter_import.test b/mysql-test/suite/innodb/t/instant_alter_import.test index 5504cee4dce..87a36186150 100644 --- a/mysql-test/suite/innodb/t/instant_alter_import.test +++ b/mysql-test/suite/innodb/t/instant_alter_import.test @@ -208,3 +208,28 @@ UNLOCK TABLES; ALTER TABLE t2 IMPORT TABLESPACE; DROP TABLE t1, t2; + +--echo # +--echo # MDEV-28919 Assertion `(((core_null) + 7) >> 3) == +--echo # oindex.n_core_null_bytes || !not_redundant()' failed +--echo # +call mtr.add_suppression(" InnoDB: Tablespace for table `test`.`t` is set as discarded"); +CREATE TABLE t (a INTEGER, b INTEGER as (a) VIRTUAL, + c INTEGER)engine=innodb; +ALTER TABLE t DISCARD TABLESPACE; +FLUSH TABLES; +# Table does reload +ALTER TABLE t DROP COLUMN b, algorithm=instant; +ALTER TABLE t DROP COLUMN c, algorithm=instant; + +CREATE TABLE t1(a INTEGER)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +FLUSH TABLE t1 FOR EXPORT; +--let $MYSQLD_DATADIR= `select @@datadir` +--move_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t.cfg +--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t.ibd +unlock tables; +ALTER TABLE t IMPORT tablespace; +check table t; +select * from t; +DROP TABLE t, t1; diff --git a/mysql-test/suite/innodb/t/log_file_name_debug.test b/mysql-test/suite/innodb/t/log_file_name_debug.test index d90be6d8916..239606b121b 100644 --- a/mysql-test/suite/innodb/t/log_file_name_debug.test +++ b/mysql-test/suite/innodb/t/log_file_name_debug.test @@ -2,6 +2,7 @@ # Embedded server does not support restarting --source include/not_embedded.inc --source include/have_debug.inc +--source include/no_valgrind_without_big.inc --echo # --echo # Bug#19685095 DO NOT CARE ABOUT UNRESOLVED MLOG_FILE_NAME diff --git a/mysql-test/suite/innodb/t/read_only_recover_committed.test b/mysql-test/suite/innodb/t/read_only_recover_committed.test index 6252c774a25..1d2270315c5 100644 --- a/mysql-test/suite/innodb/t/read_only_recover_committed.test +++ b/mysql-test/suite/innodb/t/read_only_recover_committed.test @@ -3,6 +3,7 @@ --source include/have_debug_sync.inc # need to restart server --source include/not_embedded.inc +--source include/no_valgrind_without_big.inc --disable_query_log # Ignore messages from the innodb_force_recovery=5 startup. diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test index 380052b9db6..d36e71b797a 100644 --- a/mysql-test/suite/innodb/t/table_flags.test +++ b/mysql-test/suite/innodb/t/table_flags.test @@ -1,6 +1,7 @@ --source include/innodb_page_size.inc # Embedded server tests do not support restarting --source include/not_embedded.inc +--source include/no_valgrind_without_big.inc --disable_query_log call mtr.add_suppression("InnoDB: Table `mysql`\\.`innodb_table_stats` not found"); diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test index 7a67cd8e8b7..cfb82240187 100644 --- a/mysql-test/suite/innodb/t/xa_recovery.test +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -1,6 +1,7 @@ --source include/have_innodb.inc # Embedded server does not support restarting. --source include/not_embedded.inc +--source include/no_valgrind_without_big.inc # MDEV-8841 - close tables opened by previous tests, # so they don't get marked crashed when the server gets crashed diff --git a/mysql-test/suite/innodb_fts/r/crash_recovery.result b/mysql-test/suite/innodb_fts/r/crash_recovery.result index e8305cbb2f1..83e5ddaea90 100644 --- a/mysql-test/suite/innodb_fts/r/crash_recovery.result +++ b/mysql-test/suite/innodb_fts/r/crash_recovery.result @@ -157,5 +157,18 @@ id title body 1 MySQL Tutorial DBMS stands for Database... 2 MariaDB Tutorial DB means Database ... DROP TABLE mdev19073, mdev19073_2; +# +# MDEV-28706 Redundant InnoDB table fails during alter +# +SET @@global.innodb_file_per_table = 0; +CREATE TABLE t1 ( +col_int INTEGER, col_text TEXT, +col_text_1 TEXT +) ENGINE = InnoDB ROW_FORMAT = Redundant ; +ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ; +INSERT INTO t1 VALUES ( 1255, "mariadb", "InnoDB"); +# restart +ALTER TABLE t1 ADD FULLTEXT(col_text_1); +DROP TABLE t1; SELECT * FROM information_schema.innodb_sys_tables WHERE name LIKE 'test/%'; TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE diff --git a/mysql-test/suite/innodb_fts/r/fulltext2.result b/mysql-test/suite/innodb_fts/r/fulltext2.result index b210b3bd874..7ec2df8ee46 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext2.result +++ b/mysql-test/suite/innodb_fts/r/fulltext2.result @@ -272,3 +272,10 @@ fts_doc_id first_name last_name score 6 Ned Flanders 0 7 Nelson Muntz 0 DROP TABLE t1; +CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL; +ALTER TABLE t1 ADD d INT NULL; +ALTER TABLE t1 ADD FULLTEXT(b); +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/crash_recovery.test b/mysql-test/suite/innodb_fts/t/crash_recovery.test index 702aaefad83..b8da55a8ba6 100644 --- a/mysql-test/suite/innodb_fts/t/crash_recovery.test +++ b/mysql-test/suite/innodb_fts/t/crash_recovery.test @@ -255,4 +255,21 @@ SELECT * FROM mdev19073_2 WHERE MATCH (title, body) AGAINST ('Database' IN NATURAL LANGUAGE MODE); DROP TABLE mdev19073, mdev19073_2; +let $shutdown_timeout=; + +--echo # +--echo # MDEV-28706 Redundant InnoDB table fails during alter +--echo # + +SET @@global.innodb_file_per_table = 0; +CREATE TABLE t1 ( + col_int INTEGER, col_text TEXT, + col_text_1 TEXT +) ENGINE = InnoDB ROW_FORMAT = Redundant ; +ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ; +INSERT INTO t1 VALUES ( 1255, "mariadb", "InnoDB"); +--source include/restart_mysqld.inc +ALTER TABLE t1 ADD FULLTEXT(col_text_1); +DROP TABLE t1; + SELECT * FROM information_schema.innodb_sys_tables WHERE name LIKE 'test/%'; diff --git a/mysql-test/suite/innodb_fts/t/fulltext2.test b/mysql-test/suite/innodb_fts/t/fulltext2.test index 4dd2c78827f..1e3894644a0 100644 --- a/mysql-test/suite/innodb_fts/t/fulltext2.test +++ b/mysql-test/suite/innodb_fts/t/fulltext2.test @@ -257,3 +257,14 @@ INSERT INTO t1 (id, first_name, last_name) VALUES analyze table t1; SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1; DROP TABLE t1; + +# +# MDEV-28912 NON-UNIQUE FTS_DOC_ID mistaken as FTS_DOC_ID_INDEX +# +CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL; +ALTER TABLE t1 ADD d INT NULL; +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1 ADD FULLTEXT(b); +DROP TABLE t1; diff --git a/mysql-test/suite/multi_source/multi_parallel.test b/mysql-test/suite/multi_source/multi_parallel.test index a1385198b61..2bbb344378c 100644 --- a/mysql-test/suite/multi_source/multi_parallel.test +++ b/mysql-test/suite/multi_source/multi_parallel.test @@ -2,6 +2,7 @@ # Slave_non_transactional_groups, Slave_transactional_groups --source include/not_embedded.inc --source include/have_innodb.inc +--source include/no_valgrind_without_big.inc --let $rpl_server_count= 0 --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc index b9746ec110f..b19a8cd7749 100644 --- a/mysql-test/suite/parts/inc/partition_auto_increment.inc +++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc @@ -873,6 +873,8 @@ SELECT LAST_INSERT_ID(); SELECT * FROM t1; DROP TABLE t1; } +--echo ############################################################################## +} if (!$skip_update) { @@ -880,13 +882,13 @@ if (!$skip_update) --echo # MDEV-19622 Assertion failures in --echo # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table --echo # -CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); +eval CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=$engine PARTITION BY HASH(a); INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; } -if (!$skip_update) +if (!$skip_delete) { --echo # --echo # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' @@ -897,5 +899,14 @@ REPLACE INTO t1 PARTITION (p0) VALUES (3); DROP TABLE t1; } ---echo ############################################################################## +if (!$skip_truncate) +{ +--echo # +--echo # MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | +--echo # Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed. +--echo # +eval CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE=$engine PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t1 TRUNCATE PARTITION p1; +INSERT INTO t1 PARTITION (p1) (c) SELECT 1; +DROP TABLE t1; } diff --git a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result index 0276385dc29..c017aadcbab 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result @@ -695,3 +695,26 @@ PARTITIONS 2 SELECT * FROM t1 ORDER BY c1; c1 DROP TABLE t1; +# +# MDEV-19622 Assertion failures in +# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table +# +CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Blackhole' PARTITION BY HASH(a); +INSERT INTO t1 VALUES (1,1),(2,2); +UPDATE t1 SET pk = 0; +DROP TABLE t1; +# +# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' +# ha_partition::set_auto_increment_if_higher +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Blackhole' PARTITION BY HASH (a) PARTITIONS 3; +REPLACE INTO t1 PARTITION (p0) VALUES (3); +DROP TABLE t1; +# +# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | +# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed. +# +CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Blackhole' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t1 TRUNCATE PARTITION p1; +INSERT INTO t1 PARTITION (p1) (c) SELECT 1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result index ce1e3562d4c..f0f0ff21824 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result @@ -1116,11 +1116,12 @@ SELECT * FROM t1; a 0 DROP TABLE t1; +############################################################################## # # MDEV-19622 Assertion failures in # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # -CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); +CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='InnoDB' PARTITION BY HASH(a); INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; @@ -1131,4 +1132,11 @@ DROP TABLE t1; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='InnoDB' PARTITION BY HASH (a) PARTITIONS 3; REPLACE INTO t1 PARTITION (p0) VALUES (3); DROP TABLE t1; -############################################################################## +# +# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | +# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed. +# +CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='InnoDB' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t1 TRUNCATE PARTITION p1; +INSERT INTO t1 PARTITION (p1) (c) SELECT 1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_maria.result b/mysql-test/suite/parts/r/partition_auto_increment_maria.result index ad041735ebb..8c063958b27 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_maria.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_maria.result @@ -1148,11 +1148,12 @@ SELECT * FROM t1; a 0 DROP TABLE t1; +############################################################################## # # MDEV-19622 Assertion failures in # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # -CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); +CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Aria' PARTITION BY HASH(a); INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; @@ -1163,4 +1164,11 @@ DROP TABLE t1; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Aria' PARTITION BY HASH (a) PARTITIONS 3; REPLACE INTO t1 PARTITION (p0) VALUES (3); DROP TABLE t1; -############################################################################## +# +# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | +# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed. +# +CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Aria' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t1 TRUNCATE PARTITION p1; +INSERT INTO t1 PARTITION (p1) (c) SELECT 1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_memory.result b/mysql-test/suite/parts/r/partition_auto_increment_memory.result index d2d1fb6831c..3461f8b13c5 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result @@ -1129,11 +1129,12 @@ SELECT * FROM t1; a 0 DROP TABLE t1; +############################################################################## # # MDEV-19622 Assertion failures in # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # -CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); +CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Memory' PARTITION BY HASH(a); INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; @@ -1144,4 +1145,11 @@ DROP TABLE t1; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Memory' PARTITION BY HASH (a) PARTITIONS 3; REPLACE INTO t1 PARTITION (p0) VALUES (3); DROP TABLE t1; -############################################################################## +# +# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | +# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed. +# +CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Memory' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t1 TRUNCATE PARTITION p1; +INSERT INTO t1 PARTITION (p1) (c) SELECT 1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result index f92a6ed18c6..525f47bdbd7 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result @@ -1148,11 +1148,12 @@ SELECT * FROM t1; a 0 DROP TABLE t1; +############################################################################## # # MDEV-19622 Assertion failures in # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table # -CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a); +CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='MyISAM' PARTITION BY HASH(a); INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; @@ -1163,4 +1164,11 @@ DROP TABLE t1; CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='MyISAM' PARTITION BY HASH (a) PARTITIONS 3; REPLACE INTO t1 PARTITION (p0) VALUES (3); DROP TABLE t1; -############################################################################## +# +# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | +# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed. +# +CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='MyISAM' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t1 TRUNCATE PARTITION p1; +INSERT INTO t1 PARTITION (p1) (c) SELECT 1; +DROP TABLE t1; diff --git a/scripts/comp_sql.c b/scripts/comp_sql.c index 1ce7889a90f..f72fdcb0ae3 100644 --- a/scripts/comp_sql.c +++ b/scripts/comp_sql.c @@ -1,5 +1,5 @@ /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. - Copyright (c) 2012, 2014, Monty Program Ab + Copyright (c) 2012, 2022, 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 @@ -84,7 +84,7 @@ static void print_query(FILE *out, const char *query) fprintf(out, "\""); while (*ptr) { - if(column >= MAX_COLUMN) + if (column >= MAX_COLUMN) { /* Wrap to the next line, tabulated. */ fprintf(out, "\"\n \""); diff --git a/sql/field.cc b/sql/field.cc index 0cb3a90849a..d12ff37fba8 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2021, MariaDB + Copyright (c) 2008, 2022, 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 @@ -9967,7 +9967,7 @@ int Field_bit::cmp_prefix(const uchar *a, const uchar *b, } -int Field_bit::key_cmp(const uchar *str, uint length) const +int Field_bit::key_cmp(const uchar *str, uint) const { if (bit_len) { @@ -9976,7 +9976,6 @@ int Field_bit::key_cmp(const uchar *str, uint length) const if ((flag= (int) (bits - *str))) return flag; str++; - length--; } return memcmp(ptr, str, bytes_in_rec); } diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 50abf976656..e0a02c0c7b5 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2447,7 +2447,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to) char *name_buffer_ptr; const char *from_path; const char *to_path= NULL; - uint i; handler **file, **abort_file; THD *thd= ha_thd(); DBUG_ENTER("ha_partition::del_ren_table"); @@ -2487,7 +2486,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to) from_path= get_canonical_filename(*file, from, from_lc_buff); if (to != NULL) to_path= get_canonical_filename(*file, to, to_lc_buff); - i= 0; do { if (unlikely((error= create_partition_name(from_buff, sizeof(from_buff), @@ -2512,7 +2510,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to) name_buffer_ptr= strend(name_buffer_ptr) + 1; if (unlikely(error)) save_error= error; - i++; } while (*(++file)); if (to != NULL) { diff --git a/sql/ha_partition.h b/sql/ha_partition.h index ce29f73d646..c064f7662ce 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1413,7 +1413,8 @@ private: unless we already did it. */ if (!part_share->auto_inc_initialized && - (ha_thd()->lex->sql_command == SQLCOM_INSERT || + (ha_thd()->lex->sql_command == SQLCOM_INSERT || + ha_thd()->lex->sql_command == SQLCOM_INSERT_SELECT || ha_thd()->lex->sql_command == SQLCOM_REPLACE) && table->found_next_number_field) bitmap_set_all(&m_part_info->read_partitions); diff --git a/sql/mdl.cc b/sql/mdl.cc index bd5d6aa7db3..ce6e64791b7 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2007, 2012, Oracle and/or its affiliates. - Copyright (c) 2020, MariaDB + Copyright (c) 2020, 2022, 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 @@ -247,25 +247,32 @@ private: Print a list of all locks to DBUG trace to help with debugging */ +const char *dbug_print_mdl(MDL_ticket *mdl_ticket) +{ + thread_local char buffer[256]; + MDL_key *mdl_key= mdl_ticket->get_key(); + my_snprintf(buffer, sizeof(buffer) - 1, "%.*s/%.*s (%s)", + (int) mdl_key->db_name_length(), mdl_key->db_name(), + (int) mdl_key->name_length(), mdl_key->name(), + mdl_ticket->get_type_name()->str); + return buffer; +} + + static int mdl_dbug_print_lock(MDL_ticket *mdl_ticket, void *arg, bool granted) { String *tmp= (String*) arg; - char buffer[128]; - MDL_key *mdl_key= mdl_ticket->get_key(); - size_t length; - length= my_snprintf(buffer, sizeof(buffer)-1, - "\nname: %s db: %.*s key_name: %.*s (%s)", - mdl_ticket->get_type_name()->str, - (int) mdl_key->db_name_length(), mdl_key->db_name(), - (int) mdl_key->name_length(), mdl_key->name(), - granted ? "granted" : "waiting"); + char buffer[256]; + size_t length= my_snprintf(buffer, sizeof(buffer) - 1, + "\n %s (%s)", dbug_print_mdl(mdl_ticket), + granted ? "granted" : "waiting"); tmp->append(buffer, length); return 0; } const char *mdl_dbug_print_locks() { - static String tmp; + thread_local String tmp; mdl_iterate(mdl_dbug_print_lock, (void*) &tmp); return tmp.c_ptr(); } @@ -2269,13 +2276,19 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) MDL_ticket *ticket; MDL_wait::enum_wait_status wait_status; DBUG_ENTER("MDL_context::acquire_lock"); +#ifndef DBUG_OFF + const char *mdl_lock_name= get_mdl_lock_name( + mdl_request->key.mdl_namespace(), mdl_request->type)->str; +#endif DBUG_PRINT("enter", ("lock_type: %s timeout: %f", - get_mdl_lock_name(mdl_request->key.mdl_namespace(), - mdl_request->type)->str, + mdl_lock_name, lock_wait_timeout)); if (try_acquire_lock_impl(mdl_request, &ticket)) + { + DBUG_PRINT("mdl", ("OOM: %s", mdl_lock_name)); DBUG_RETURN(TRUE); + } if (mdl_request->ticket) { @@ -2285,9 +2298,14 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) accordingly, so we can simply return success. */ DBUG_PRINT("info", ("Got lock without waiting")); + DBUG_PRINT("mdl", ("Seized: %s", dbug_print_mdl(mdl_request->ticket))); DBUG_RETURN(FALSE); } +#ifndef DBUG_OFF + const char *ticket_msg= dbug_print_mdl(ticket); +#endif + /* Our attempt to acquire lock without waiting has failed. As a result of this attempt we got MDL_ticket with m_lock @@ -2298,6 +2316,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) if (lock_wait_timeout == 0) { + DBUG_PRINT("mdl", ("Nowait: %s", ticket_msg)); mysql_prlock_unlock(&lock->m_rwlock); MDL_ticket::destroy(ticket); my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); @@ -2344,6 +2363,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) locker= PSI_CALL_start_metadata_wait(&state, ticket->m_psi, __FILE__, __LINE__); #endif + DBUG_PRINT("mdl", ("Waiting: %s", ticket_msg)); will_wait_for(ticket); /* There is a shared or exclusive lock on the object. */ @@ -2401,15 +2421,16 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) switch (wait_status) { case MDL_wait::VICTIM: - DBUG_LOCK_FILE; - DBUG_PRINT("mdl_locks", ("%s", mdl_dbug_print_locks())); - DBUG_UNLOCK_FILE; + DBUG_PRINT("mdl", ("Deadlock: %s", ticket_msg)); + DBUG_PRINT("mdl_locks", ("Existing locks:%s", mdl_dbug_print_locks())); my_error(ER_LOCK_DEADLOCK, MYF(0)); break; case MDL_wait::TIMEOUT: + DBUG_PRINT("mdl", ("Timeout: %s", ticket_msg)); my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); break; case MDL_wait::KILLED: + DBUG_PRINT("mdl", ("Killed: %s", ticket_msg)); get_thd()->send_kill_message(); break; default: @@ -2433,6 +2454,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) mysql_mdl_set_status(ticket->m_psi, MDL_ticket::GRANTED); + DBUG_PRINT("mdl", ("Acquired: %s", ticket_msg)); DBUG_RETURN(FALSE); } @@ -2854,6 +2876,7 @@ void MDL_context::release_lock(enum_mdl_duration duration, MDL_ticket *ticket) lock->key.db_name(), lock->key.name())); DBUG_ASSERT(this == ticket->get_ctx()); + DBUG_PRINT("mdl", ("Released: %s", dbug_print_mdl(ticket))); lock->remove_ticket(m_pins, &MDL_lock::m_granted, ticket); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index ecec944c444..3eb73b5e16a 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2006, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2020, MariaDB Corporation. + Copyright (c) 2010, 2022, 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 @@ -1526,7 +1526,6 @@ bool partition_info::set_up_charset_field_preps(THD *thd) uchar **char_ptrs; unsigned i; size_t size; - uint tot_fields= 0; uint tot_part_fields= 0; uint tot_subpart_fields= 0; DBUG_ENTER("set_up_charset_field_preps"); @@ -1538,13 +1537,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd) ptr= part_field_array; /* Set up arrays and buffers for those fields */ while ((field= *(ptr++))) - { if (field_is_partition_charset(field)) - { tot_part_fields++; - tot_fields++; - } - } size= tot_part_fields * sizeof(char*); if (!(char_ptrs= (uchar**)thd->calloc(size))) goto error; @@ -1578,13 +1572,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd) /* Set up arrays and buffers for those fields */ ptr= subpart_field_array; while ((field= *(ptr++))) - { if (field_is_partition_charset(field)) - { tot_subpart_fields++; - tot_fields++; - } - } size= tot_subpart_fields * sizeof(char*); if (!(char_ptrs= (uchar**) thd->calloc(size))) goto error; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 934e7e7e7e0..f351210a862 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2811,7 +2811,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd, uchar quote_char) { CHARSET_INFO *const cs= thd->charset(); - uint double_quotes= 0; uchar c; DBUG_ASSERT(m_ptr == m_tok_start + 1); @@ -2836,7 +2835,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd, if (yyPeek() != quote_char) break; c= yyGet(); - double_quotes++; continue; } } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 1f034f490c8..3c5e3859939 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2009 MySQL AB - Copyright (c) 2019, 2020, MariaDB Corporation. + Copyright (c) 2019, 2022, 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 @@ -2516,7 +2516,6 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index) { int rc= 0; KEY *key_info= &table->key_info[index]; - ha_rows rows= 0; DBUG_ENTER("collect_statistics_for_index"); @@ -2551,7 +2550,6 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index) if (rc) break; - rows++; index_prefix_calc.add(); rc= table->file->ha_index_next(table->record[0]); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 304df0b35c0..d30f7b91ced 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1155,7 +1155,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, StringBuffer<160> unknown_tables(system_charset_info); DDL_LOG_STATE local_ddl_log_state; const char *comment_start; - uint not_found_errors= 0, table_count= 0, non_temp_tables_count= 0; + uint table_count= 0, non_temp_tables_count= 0; int error= 0; uint32 comment_len; bool trans_tmp_table_deleted= 0, non_trans_tmp_table_deleted= 0; @@ -1286,7 +1286,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, unknown_tables.append(&table_name); unknown_tables.append(','); error= ENOENT; - not_found_errors++; continue; } @@ -1369,7 +1368,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, unknown_tables.append(&table_name); unknown_tables.append(','); error= ENOENT; - not_found_errors++; continue; } @@ -1615,7 +1613,6 @@ report_error: } else { - not_found_errors++; if (unknown_tables.append(tbl_name) || unknown_tables.append(',')) { error= 1; @@ -2807,7 +2804,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, List_iterator key_iterator(alter_info->key_list); List_iterator key_iterator2(alter_info->key_list); - uint key_parts=0, fk_key_count=0; + uint key_parts=0; bool primary_key=0,unique_key=0; Key *key, *key2; uint tmp, key_number; @@ -2823,7 +2820,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, "(none)" , key->type)); if (key->type == Key::FOREIGN_KEY) { - fk_key_count++; Foreign_key *fk_key= (Foreign_key*) key; if (fk_key->validate(alter_info->create_list)) DBUG_RETURN(TRUE); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 9f9ef6335f3..6dedd5e85be 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -699,11 +699,9 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, if (lex->view_list.elements) { List_iterator_fast names(lex->view_list); - LEX_CSTRING *name; - int i; - + buff.append('('); - for (i= 0; (name= names++); i++) + while (LEX_CSTRING *name= names++) { append_identifier(thd, &buff, name); buff.append(", ", 2); diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 7af5f862aab..c56df29cbbc 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -370,7 +370,6 @@ inline void PageBulk::finishPage() ut_ad((fmt != REDUNDANT) == m_is_comp); ulint count= 0; - ulint n_recs= 0; byte *slot= my_assume_aligned<2>(m_page + srv_page_size - (PAGE_DIR + PAGE_DIR_SLOT_SIZE)); const page_dir_slot_t *const slot0 = slot; @@ -386,7 +385,6 @@ inline void PageBulk::finishPage() ut_ad(offset >= PAGE_NEW_SUPREMUM); ut_ad(offset < page_offset(slot)); count++; - n_recs++; if (count == (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2) { @@ -440,7 +438,6 @@ inline void PageBulk::finishPage() while (insert_rec != m_page + PAGE_OLD_SUPREMUM) { count++; - n_recs++; if (count == (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2) { diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 967e82b90a8..c53997086bb 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -816,7 +816,10 @@ void buf_page_print(const byte *read_buf, ulint zip_size) byte row[64]; for (byte *r= row; r != &row[64]; r+= 2, read_buf++) - r[0]= hex_to_ascii(*read_buf >> 4), r[1]= hex_to_ascii(*read_buf & 15); + { + r[0]= hex_to_ascii(byte(*read_buf >> 4)); + r[1]= hex_to_ascii(*read_buf & 15); + } sql_print_information("InnoDB: %.*s", 64, row); } diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index eda6c5180d6..097921b3f61 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -1356,6 +1356,7 @@ dict_load_columns( if (table->fts == NULL) { table->fts = fts_create(table); table->fts->cache = fts_cache_create(table); + DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME); } ut_a(table->fts->doc_col == ULINT_UNDEFINED); @@ -2099,8 +2100,11 @@ next_rec: ut_ad(table->fts_doc_id_index == NULL); if (table->fts != NULL) { - table->fts_doc_id_index = dict_table_get_index_on_name( + dict_index_t *idx = dict_table_get_index_on_name( table, FTS_DOC_ID_INDEX_NAME); + if (idx && dict_index_is_unique(idx)) { + table->fts_doc_id_index = idx; + } } /* If the table contains FTS indexes, populate table->fts->indexes */ diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 828af7cc24a..ffd49d4e6e9 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -227,7 +227,7 @@ inline void dict_table_t::prepare_instant(const dict_table_t& old, If that is the case, the instant ALTER TABLE would keep the InnoDB table in its current format. */ - const dict_index_t& oindex = *old.indexes.start; + dict_index_t& oindex = *old.indexes.start; dict_index_t& index = *indexes.start; first_alter_pos = 0; @@ -373,6 +373,15 @@ found_j: goto found_nullable; } } + + /* In case of discarded tablespace, InnoDB can't + read the root page. So assign the null bytes based + on nullabled fields */ + if (!oindex.table->space) { + oindex.n_core_null_bytes = static_cast( + UT_BITS_IN_BYTES(unsigned(oindex.n_nullable))); + } + /* The n_core_null_bytes only matters for ROW_FORMAT=COMPACT and ROW_FORMAT=DYNAMIC tables. */ ut_ad(UT_BITS_IN_BYTES(core_null) == oindex.n_core_null_bytes @@ -9216,16 +9225,14 @@ innobase_rename_columns_try( const char* table_name) { uint i = 0; - ulint num_v = 0; DBUG_ASSERT(ctx->need_rebuild()); DBUG_ASSERT(ha_alter_info->handler_flags & ALTER_COLUMN_NAME); for (Field** fp = table->field; *fp; fp++, i++) { - const bool is_virtual = !(*fp)->stored_in_db(); if (!((*fp)->flags & FIELD_IS_RENAMED)) { - goto processed_field; + continue; } for (const Create_field& cf : @@ -9243,10 +9250,6 @@ innobase_rename_columns_try( ut_error; processed_field: - if (is_virtual) { - num_v++; - } - continue; } diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index d4115f7be16..3c67de2f6e5 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -57,6 +57,7 @@ Created July 18, 2007 Vasil Dimov #include "dict0crea.h" #include "fts0vlc.h" #include "scope.h" +#include "log.h" /** The latest successfully looked up innodb_fts_aux_table */ table_id_t innodb_ft_aux_table_id; @@ -168,19 +169,37 @@ time_t MYSQL_TYPE_DATETIME --------------------------------- */ -/*******************************************************************//** +/** Common function to fill any of the dynamic tables: INFORMATION_SCHEMA.innodb_trx INFORMATION_SCHEMA.innodb_locks INFORMATION_SCHEMA.innodb_lock_waits -@return 0 on success */ -static -int -trx_i_s_common_fill_table( -/*======================*/ - THD* thd, /*!< in: thread */ - TABLE_LIST* tables, /*!< in/out: tables to fill */ - Item* ); /*!< in: condition (not used) */ +@retval false if access to the table is blocked +@retval true if something should be filled in */ +static bool trx_i_s_common_fill_table(THD *thd, TABLE_LIST *tables) +{ + DBUG_ENTER("trx_i_s_common_fill_table"); + + /* deny access to non-superusers */ + if (check_global_access(thd, PROCESS_ACL)) + DBUG_RETURN(false); + + RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str); + + /* update the cache */ + trx_i_s_cache_start_write(trx_i_s_cache); + trx_i_s_possibly_fetch_data_into_cache(trx_i_s_cache); + trx_i_s_cache_end_write(trx_i_s_cache); + + if (trx_i_s_cache_is_truncated(trx_i_s_cache)) + sql_print_warning("InnoDB: Data in %.*s truncated due to memory limit" + " of %u bytes", + int(tables->schema_table_name.length), + tables->schema_table_name.str, + TRX_I_S_MEM_LIMIT); + + DBUG_RETURN(true); +} /*******************************************************************//** Unbind a dynamic INFORMATION_SCHEMA table. @@ -343,26 +362,29 @@ static ST_FIELD_INFO innodb_trx_fields_info[]= /*******************************************************************//** Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx table with it. -@return 0 on success */ -static -int -fill_innodb_trx_from_cache( -/*=======================*/ - trx_i_s_cache_t* cache, /*!< in: cache to read from */ - THD* thd, /*!< in: used to call - schema_table_store_record() */ - TABLE* table) /*!< in/out: fill this table */ +@retval 0 on success +@retval 1 on failure */ +static int fill_innodb_trx_from_cache(THD *thd, TABLE_LIST *tables, Item*) { - Field** fields; ulint rows_num; char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; ulint i; DBUG_ENTER("fill_innodb_trx_from_cache"); - fields = table->field; + if (!trx_i_s_common_fill_table(thd, tables)) { + DBUG_RETURN(0); + } - rows_num = trx_i_s_cache_get_rows_used(cache, + struct cache + { + cache() { trx_i_s_cache_start_read(trx_i_s_cache); } + ~cache() { trx_i_s_cache_end_read(trx_i_s_cache); } + } c; + + Field** fields = tables->table->field; + + rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache, I_S_INNODB_TRX); for (i = 0; i < rows_num; i++) { @@ -371,7 +393,7 @@ fill_innodb_trx_from_cache( row = (i_s_trx_row_t*) trx_i_s_cache_get_nth_row( - cache, I_S_INNODB_TRX, i); + trx_i_s_cache, I_S_INNODB_TRX, i); /* trx_id */ OK(fields[IDX_TRX_ID]->store(row->trx_id, true)); @@ -480,7 +502,7 @@ fill_innodb_trx_from_cache( OK(fields[IDX_TRX_AUTOCOMMIT_NON_LOCKING]->store( row->trx_is_autocommit_non_locking, true)); - OK(schema_table_store_record(thd, table)); + OK(schema_table_store_record(thd, tables->table)); } DBUG_RETURN(0); @@ -502,7 +524,7 @@ innodb_trx_init( schema = (ST_SCHEMA_TABLE*) p; schema->fields_info = Show::innodb_trx_fields_info; - schema->fill_table = trx_i_s_common_fill_table; + schema->fill_table = fill_innodb_trx_from_cache; DBUG_RETURN(0); } @@ -629,20 +651,29 @@ static int fill_innodb_locks_from_cache( /*=========================*/ - trx_i_s_cache_t* cache, /*!< in: cache to read from */ THD* thd, /*!< in: MySQL client connection */ - TABLE* table) /*!< in/out: fill this table */ + TABLE_LIST* tables, /*!< in/out: fill this table */ + Item*) { - Field** fields; ulint rows_num; char lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; ulint i; DBUG_ENTER("fill_innodb_locks_from_cache"); - fields = table->field; + if (!trx_i_s_common_fill_table(thd, tables)) { + DBUG_RETURN(0); + } - rows_num = trx_i_s_cache_get_rows_used(cache, + struct cache + { + cache() { trx_i_s_cache_start_read(trx_i_s_cache); } + ~cache() { trx_i_s_cache_end_read(trx_i_s_cache); } + } c; + + Field** fields = tables->table->field; + + rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache, I_S_INNODB_LOCKS); for (i = 0; i < rows_num; i++) { @@ -653,7 +684,7 @@ fill_innodb_locks_from_cache( row = (i_s_locks_row_t*) trx_i_s_cache_get_nth_row( - cache, I_S_INNODB_LOCKS, i); + trx_i_s_cache, I_S_INNODB_LOCKS, i); /* lock_id */ trx_i_s_create_lock_id(row, lock_id, sizeof(lock_id)); @@ -700,7 +731,7 @@ fill_innodb_locks_from_cache( fields[IDX_LOCK_DATA]->set_null(); } - OK(schema_table_store_record(thd, table)); + OK(schema_table_store_record(thd, tables->table)); } DBUG_RETURN(0); @@ -722,7 +753,7 @@ innodb_locks_init( schema = (ST_SCHEMA_TABLE*) p; schema->fields_info = Show::innodb_locks_fields_info; - schema->fill_table = trx_i_s_common_fill_table; + schema->fill_table = fill_innodb_locks_from_cache; DBUG_RETURN(0); } @@ -804,12 +835,11 @@ static int fill_innodb_lock_waits_from_cache( /*==============================*/ - trx_i_s_cache_t* cache, /*!< in: cache to read from */ THD* thd, /*!< in: used to call schema_table_store_record() */ - TABLE* table) /*!< in/out: fill this table */ + TABLE_LIST* tables, /*!< in/out: fill this table */ + Item*) { - Field** fields; ulint rows_num; char requested_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; char blocking_lock_id[TRX_I_S_LOCK_ID_MAX_LEN + 1]; @@ -817,9 +847,19 @@ fill_innodb_lock_waits_from_cache( DBUG_ENTER("fill_innodb_lock_waits_from_cache"); - fields = table->field; + if (!trx_i_s_common_fill_table(thd, tables)) { + DBUG_RETURN(0); + } - rows_num = trx_i_s_cache_get_rows_used(cache, + struct cache + { + cache() { trx_i_s_cache_start_read(trx_i_s_cache); } + ~cache() { trx_i_s_cache_end_read(trx_i_s_cache); } + } c; + + Field** fields = tables->table->field; + + rows_num = trx_i_s_cache_get_rows_used(trx_i_s_cache, I_S_INNODB_LOCK_WAITS); for (i = 0; i < rows_num; i++) { @@ -828,7 +868,7 @@ fill_innodb_lock_waits_from_cache( row = (i_s_lock_waits_row_t*) trx_i_s_cache_get_nth_row( - cache, I_S_INNODB_LOCK_WAITS, i); + trx_i_s_cache, I_S_INNODB_LOCK_WAITS, i); /* requesting_trx_id */ OK(fields[IDX_REQUESTING_TRX_ID]->store( @@ -854,7 +894,7 @@ fill_innodb_lock_waits_from_cache( blocking_lock_id, sizeof(blocking_lock_id)))); - OK(schema_table_store_record(thd, table)); + OK(schema_table_store_record(thd, tables->table)); } DBUG_RETURN(0); @@ -876,7 +916,7 @@ innodb_lock_waits_init( schema = (ST_SCHEMA_TABLE*) p; schema->fields_info = Show::innodb_lock_waits_fields_info; - schema->fill_table = trx_i_s_common_fill_table; + schema->fill_table = fill_innodb_lock_waits_from_cache; DBUG_RETURN(0); } @@ -930,105 +970,6 @@ struct st_maria_plugin i_s_innodb_lock_waits = MariaDB_PLUGIN_MATURITY_STABLE, }; -/*******************************************************************//** -Common function to fill any of the dynamic tables: -INFORMATION_SCHEMA.innodb_trx -INFORMATION_SCHEMA.innodb_locks -INFORMATION_SCHEMA.innodb_lock_waits -@return 0 on success */ -static -int -trx_i_s_common_fill_table( -/*======================*/ - THD* thd, /*!< in: thread */ - TABLE_LIST* tables, /*!< in/out: tables to fill */ - Item* ) /*!< in: condition (not used) */ -{ - LEX_CSTRING table_name; - int ret; - trx_i_s_cache_t* cache; - - DBUG_ENTER("trx_i_s_common_fill_table"); - - /* deny access to non-superusers */ - if (check_global_access(thd, PROCESS_ACL)) { - - DBUG_RETURN(0); - } - - /* minimize the number of places where global variables are - referenced */ - cache = trx_i_s_cache; - - /* which table we have to fill? */ - table_name = tables->schema_table_name; - /* or table_name = tables->schema_table->table_name; */ - - RETURN_IF_INNODB_NOT_STARTED(table_name.str); - - /* update the cache */ - trx_i_s_cache_start_write(cache); - trx_i_s_possibly_fetch_data_into_cache(cache); - trx_i_s_cache_end_write(cache); - - if (trx_i_s_cache_is_truncated(cache)) { - - ib::warn() << "Data in " << table_name.str << " truncated due to" - " memory limit of " << TRX_I_S_MEM_LIMIT << " bytes"; - } - - ret = 0; - - trx_i_s_cache_start_read(cache); - - if (innobase_strcasecmp(table_name.str, "innodb_trx") == 0) { - - if (fill_innodb_trx_from_cache( - cache, thd, tables->table) != 0) { - - ret = 1; - } - - } else if (innobase_strcasecmp(table_name.str, "innodb_locks") == 0) { - - if (fill_innodb_locks_from_cache( - cache, thd, tables->table) != 0) { - - ret = 1; - } - - } else if (innobase_strcasecmp(table_name.str, "innodb_lock_waits") == 0) { - - if (fill_innodb_lock_waits_from_cache( - cache, thd, tables->table) != 0) { - - ret = 1; - } - - } else { - ib::error() << "trx_i_s_common_fill_table() was" - " called to fill unknown table: " << table_name.str << "." - " This function only knows how to fill" - " innodb_trx, innodb_locks and" - " innodb_lock_waits tables."; - - ret = 1; - } - - trx_i_s_cache_end_read(cache); - -#if 0 - DBUG_RETURN(ret); -#else - /* if this function returns something else than 0 then a - deadlock occurs between the mysqld server and mysql client, - see http://bugs.mysql.com/29900 ; when that bug is resolved - we can enable the DBUG_RETURN(ret) above */ - ret++; // silence a gcc46 warning - DBUG_RETURN(0); -#endif -} - namespace Show { /* Fields of the dynamic table information_schema.innodb_cmp. */ static ST_FIELD_INFO i_s_cmp_fields_info[] = diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 0a8655ee4c4..c0870698c5b 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -121,7 +121,6 @@ public: rec_offs* ins_offsets = NULL; dberr_t error = DB_SUCCESS; dtuple_t* dtuple; - ulint count = 0; const ulint flag = BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG | BTR_CREATE_FLAG; @@ -236,7 +235,6 @@ public: mtr_commit(&mtr); rtr_clean_rtr_info(&rtr_info, true); - count++; } m_dtuple_vec->clear(); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_24343.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_24343.result new file mode 100644 index 00000000000..1d154daa8ec --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_24343.result @@ -0,0 +1,75 @@ +# +# MDEV-24343 Spider Left join failed Unknown column 't0.ID' in 'on clause' +# +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection child2_1; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +CREATE TABLE tbl_a ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`first_name` varchar(255) DEFAULT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +INSERT INTO `tbl_a` VALUES (1,'RICHARD'), (2,'STEPHANE'), (3,'ALAIN'); +CREATE TABLE `tbl_b` ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`last_name` varchar(255) DEFAULT NULL, +PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +INSERT INTO `tbl_b` VALUES (1,'DEMONGEOT'),(2,'VAROQUI'); +CREATE TABLE `tbl_c` ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`surname` varchar(255) DEFAULT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +INSERT INTO `tbl_c` VALUES (1,'CON'),(2,'MOYEN'),(3,'MOYEN2'); +SELECT * from tbl_b JOIN tbl_c ON tbl_b.id = tbl_c.id LEFT OUTER JOIN tbl_a ON tbl_a.id = tbl_b.id; +id last_name id surname id first_name +1 DEMONGEOT 1 CON 1 RICHARD +2 VAROQUI 2 MOYEN 2 STEPHANE +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TABLE tbl_a ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`first_name` varchar(255) DEFAULT NULL, +PRIMARY KEY (`id`) +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a"' +PARTITION BY LIST COLUMNS(`id`) ( +PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"' +); +CREATE TABLE `tbl_b` ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`last_name` varchar(255) DEFAULT NULL, +PRIMARY KEY (`id`) +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_b"' +PARTITION BY LIST COLUMNS(`id`) ( +PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"' +); +CREATE TABLE `tbl_c` ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`surname` varchar(255) DEFAULT NULL, +PRIMARY KEY (`id`) +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_c"' +PARTITION BY LIST COLUMNS(`id`) ( +PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"' +); +SELECT * from tbl_b JOIN tbl_c ON tbl_b.id = tbl_c.id LEFT OUTER JOIN tbl_a ON tbl_a.id = tbl_b.id; +id last_name id surname id first_name +1 DEMONGEOT 1 CON 1 RICHARD +2 VAROQUI 2 MOYEN 2 STEPHANE +connection master_1; +DROP DATABASE auto_test_local; +connection child2_1; +DROP DATABASE auto_test_remote; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_24343.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_24343.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_24343.cnf @@ -0,0 +1,3 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_24343.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_24343.test new file mode 100644 index 00000000000..5756cbac993 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_24343.test @@ -0,0 +1,84 @@ +--echo # +--echo # MDEV-24343 Spider Left join failed Unknown column 't0.ID' in 'on clause' +--echo # + +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log + +--connection child2_1 +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +eval CREATE TABLE tbl_a ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `first_name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; + +INSERT INTO `tbl_a` VALUES (1,'RICHARD'), (2,'STEPHANE'), (3,'ALAIN'); + +eval CREATE TABLE `tbl_b` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `last_name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`ID`) +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; + +INSERT INTO `tbl_b` VALUES (1,'DEMONGEOT'),(2,'VAROQUI'); + +eval CREATE TABLE `tbl_c` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `surname` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; + +INSERT INTO `tbl_c` VALUES (1,'CON'),(2,'MOYEN'),(3,'MOYEN2'); + +SELECT * from tbl_b JOIN tbl_c ON tbl_b.id = tbl_c.id LEFT OUTER JOIN tbl_a ON tbl_a.id = tbl_b.id; + +--connection master_1 +CREATE DATABASE auto_test_local; +USE auto_test_local; + +eval CREATE TABLE tbl_a ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `first_name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a"' +PARTITION BY LIST COLUMNS(`id`) ( + PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"' +); + +eval CREATE TABLE `tbl_b` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `last_name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_b"' +PARTITION BY LIST COLUMNS(`id`) ( + PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"' +); + +eval CREATE TABLE `tbl_c` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `surname` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_c"' +PARTITION BY LIST COLUMNS(`id`) ( + PARTITION `pt1` DEFAULT COMMENT = 'srv "s_2_1"' +); + +SELECT * from tbl_b JOIN tbl_c ON tbl_b.id = tbl_c.id LEFT OUTER JOIN tbl_a ON tbl_a.id = tbl_b.id; + +--connection master_1 +DROP DATABASE auto_test_local; + +--connection child2_1 +DROP DATABASE auto_test_remote; + +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/mysql-test/spider/r/direct_join.result b/storage/spider/mysql-test/spider/r/direct_join.result index 4f0db231079..4b2c3e04bfd 100644 --- a/storage/spider/mysql-test/spider/r/direct_join.result +++ b/storage/spider/mysql-test/spider/r/direct_join.result @@ -76,7 +76,7 @@ a b c connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0,`auto_test_remote`.`ta_r_3` t1,`auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc limit 1,2 +select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc limit 1,2 SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_join_using.result b/storage/spider/mysql-test/spider/r/direct_join_using.result index 1bb1b4c1cd2..facfabfe384 100644 --- a/storage/spider/mysql-test/spider/r/direct_join_using.result +++ b/storage/spider/mysql-test/spider/r/direct_join_using.result @@ -79,7 +79,7 @@ a b c connection child2_1; SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0,`auto_test_remote`.`ta_r_3` t1,`auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc +select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index c1943dd6088..e155b6c2356 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -7253,25 +7253,13 @@ int spider_db_mbase_util::append_table( } else if (*current_pos > 0 && !first) { DBUG_PRINT("info",("spider no condition")); - if (top_down) + if (str) { - if (str) + if (str->reserve(SPIDER_SQL_JOIN_LEN)) { - if (str->reserve(SPIDER_SQL_JOIN_LEN)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_JOIN_STR, SPIDER_SQL_JOIN_LEN); - } - } else { - if (str) - { - if (str->reserve(SPIDER_SQL_COMMA_LEN)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); } + str->q_append(SPIDER_SQL_JOIN_STR, SPIDER_SQL_JOIN_LEN); } }