Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-31618: Server crashes in process_i_s_table_temporary_tables/get_all_tables #2685

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions mysql-test/main/information_schema_temp_table.result
Expand Up @@ -231,3 +231,38 @@ def test t1 BASE TABLE MyISAM 10 Fixed 1 7 X X X X NULL X X NULL latin1_swedish_
def test t2 TEMPORARY MRG_MyISAM 10 Fixed 0 0 X X X X NULL X X NULL latin1_swedish_ci NULL X Y
def test t3 BASE TABLE MRG_MyISAM 10 Fixed 1 5 X X X X NULL X X NULL latin1_swedish_ci NULL X N
DROP TABLE t1,t2,t3;
#
# MDEV-31618: Server crashes in
# process_i_s_table_temporary_tables/get_all_tables
#
CREATE TEMPORARY SEQUENCE seq1;
SHOW FULL TABLES;
Tables_in_test Table_type
seq1 TEMPORARY SEQUENCE
SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_type='temporary sequence';
table_schema table_name
test seq1
mysqltest s2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vuvova not sure how this happened, when mysqltest is removed before?
tmp_mem_root maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I don't understand. what do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temporary sequences are shown because they where created in previous tests that did not clean up itself properly.
Fix by moving:
DROP TABLE mysqltest.s1;
DROP TABLE mysqltest.s2;
before the line
#MDEV-31618: Server crashes in

mysqltest s1
ALTER TABLE `seq1` CHANGE `cache_size` cache_size int;
ERROR HY000: Sequence 'test.seq1' table structure is invalid (cache_size)
SHOW FULL TABLES;
Tables_in_test Table_type
seq1 TEMPORARY SEQUENCE
SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_type='temporary sequence';
table_schema table_name
test seq1
mysqltest s2
mysqltest s1
CREATE OR REPLACE TEMPORARY SEQUENCE seq1;
SHOW FULL TABLES;
Tables_in_test Table_type
seq1 TEMPORARY SEQUENCE
SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_type='temporary sequence';
table_schema table_name
test seq1
mysqltest s2
mysqltest s1
DROP TABLE seq1;
DROP TABLE mysqltest.s1;
DROP TABLE mysqltest.s2;
23 changes: 23 additions & 0 deletions mysql-test/main/information_schema_temp_table.test
Expand Up @@ -219,3 +219,26 @@ CREATE TABLE t3 (a INT) ENGINE=MERGE UNION=(t1);
--replace_column 10 X 11 X 12 X 13 X 15 X 16 X 22 X
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test';
DROP TABLE t1,t2,t3;

--echo #
--echo # MDEV-31618: Server crashes in
--echo # process_i_s_table_temporary_tables/get_all_tables
--echo #

CREATE TEMPORARY SEQUENCE seq1;
# Check show temp tables before alter
SHOW FULL TABLES;
SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_type='temporary sequence';
--error 4086
ALTER TABLE `seq1` CHANGE `cache_size` cache_size int;
# Check show temp tables after alter
SHOW FULL TABLES;
SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_type='temporary sequence';

CREATE OR REPLACE TEMPORARY SEQUENCE seq1;
# Check show temp tables after create/replace alter
SHOW FULL TABLES;
SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_type='temporary sequence';
DROP TABLE seq1;
DROP TABLE mysqltest.s1;
DROP TABLE mysqltest.s2;
1 change: 1 addition & 0 deletions sql/sql_parse.cc
Expand Up @@ -787,6 +787,7 @@ void init_update_queries(void)
Note that SQLCOM_RENAME_TABLE should not be in this list!
*/
sql_command_flags[SQLCOM_CREATE_TABLE]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_CREATE_SEQUENCE]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_CREATE_INDEX]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_ALTER_TABLE]|= CF_PREOPEN_TMP_TABLES;
sql_command_flags[SQLCOM_TRUNCATE]|= CF_PREOPEN_TMP_TABLES;
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_show.cc
Expand Up @@ -5326,7 +5326,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
system_charset_info);
schema_table_store_record(thd, table);
}
else /* SCH_TABLE */
else /* SCH_TABLES */
process_i_s_table_temporary_tables(thd, table, tmp_tbl);
}
}
Expand Down Expand Up @@ -5372,7 +5372,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
continue;
}
#endif
restore_record(table, s->default_values);
restore_record(table, s->default_values);
table->field[schema_table->idx_field1]->
store(db_name->str, db_name->length, system_charset_info);
table->field[schema_table->idx_field2]->
Expand Down