diff options
author | anel <anel@mariadb.org> | 2022-04-18 06:30:30 -0700 |
---|---|---|
committer | anel <anel@mariadb.org> | 2022-04-26 08:43:39 -0700 |
commit | 27b467076a625b19ba716152b5770a82c2de74c0 (patch) | |
tree | a84f84e0be7a46204393260e8ac44f15491b9ff4 | |
parent | e62a2a0615fc89bbbe139ed48e578fdc3b0388ee (diff) | |
download | mariadb-git-bb-10.9-anel-MDEV-28332-inf_schema.tar.gz |
MDEV-28332: Alter on temporary table causes ER_TABLE_EXISTS_ERROR notebb-10.9-anel-MDEV-28332-inf_schema
- Additionally update comments
Reviewed by: <monty@askmonty.org>
-rw-r--r-- | mysql-test/main/information_schema_temp_table.result | 12 | ||||
-rw-r--r-- | mysql-test/main/information_schema_temp_table.test | 10 | ||||
-rw-r--r-- | mysql-test/main/lock_multi.result | 2 | ||||
-rw-r--r-- | mysql-test/main/temp_table.result | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 23 |
6 files changed, 39 insertions, 16 deletions
diff --git a/mysql-test/main/information_schema_temp_table.result b/mysql-test/main/information_schema_temp_table.result index e85def6bfd2..ab2cd811ba2 100644 --- a/mysql-test/main/information_schema_temp_table.result +++ b/mysql-test/main/information_schema_temp_table.result @@ -96,3 +96,15 @@ drop table test.t_temp; drop table test.t_temp; drop database my_db; drop database some_db; +# +# MDEV-28332: Alter on temporary table causes ER_TABLE_EXISTS_ERROR note +# +create table t (a int); +create temporary table t (b int); +Warnings: +Level Note +Code 1050 +Message Table 't' already exists +alter table t add c int; +drop temporary table t; +drop table t; diff --git a/mysql-test/main/information_schema_temp_table.test b/mysql-test/main/information_schema_temp_table.test index 327e853d4a4..f8b1935edcf 100644 --- a/mysql-test/main/information_schema_temp_table.test +++ b/mysql-test/main/information_schema_temp_table.test @@ -93,3 +93,13 @@ drop database some_db; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc +--echo # +--echo # MDEV-28332: Alter on temporary table causes ER_TABLE_EXISTS_ERROR note +--echo # +create table t (a int); +create temporary table t (b int); +alter table t add c int; + +# Cleanup +drop temporary table t; +drop table t;
\ No newline at end of file diff --git a/mysql-test/main/lock_multi.result b/mysql-test/main/lock_multi.result index 6d0a1807d6e..83e20bc5e33 100644 --- a/mysql-test/main/lock_multi.result +++ b/mysql-test/main/lock_multi.result @@ -611,8 +611,6 @@ CREATE TEMPORARY TABLE t1 (id INT); Warnings: Note 1050 Table 't1' already exists ALTER TABLE t1 ADD COLUMN j INT; -Warnings: -Note 1050 Table 't1' already exists connection default; disconnect con1; UNLOCK TABLES; diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 97ef065dcc6..ff8156f9ace 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -60,8 +60,6 @@ a b 5 f 6 g alter table t2 add primary key (a,b); -Warnings: -Note 1050 Table 't2' already exists drop table t1,t2; select * from t1; c d diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 11d1a739eb2..0b694e23668 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5803,14 +5803,14 @@ err: /** @brief Fill IS.table with temporary tables + @param[in] thd thread handle @param[in] table I_S table (TABLE) - @param[in] db_name db name of temporary table - @param[in] table_name table name of temporary table + @param[in] tmp_tbl temporary table @return Operation status @retval 0 - success @retval 1 - failure */ -void process_i_s_table_temporary_tables(THD *thd, TABLE * table, TABLE *tmp_tbl) +void process_i_s_table_temporary_tables(THD *thd, TABLE *table, TABLE *tmp_tbl) { TABLE_LIST table_list; bzero((char*) &table_list, sizeof(TABLE_LIST)); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f52733c2640..79c8a946487 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4357,23 +4357,28 @@ int create_table_impl(THD *thd, ddl_log_state_create= 0; ddl_log_state_rm= 0; - if (ha_table_exists(thd, &orig_db, &orig_table_name, NULL, NULL, NULL)) + if (create_table_mode != C_ALTER_TABLE_FRM_ONLY && + create_table_mode != C_ALTER_TABLE) { + if (ha_table_exists(thd, &orig_db, &orig_table_name, NULL, NULL, NULL)) + { #ifndef NO_EMBEDDED_ACCESS_CHECKS - TABLE_LIST table_acl_check; - bzero((char*) &table_acl_check, sizeof(table_acl_check)); - table_acl_check.db= orig_db; - table_acl_check.table_name= orig_table_name; - if (!check_table_access(thd, TABLE_ACLS, &table_acl_check, true, 1, true)) - warning_given= 1; + TABLE_LIST table_acl_check; + bzero((char*) &table_acl_check, sizeof(table_acl_check)); + table_acl_check.db= orig_db; + table_acl_check.table_name= orig_table_name; + if (!check_table_access(thd, TABLE_ACLS, &table_acl_check, true, 1, true)) + warning_given= 1; #else - warning_given=1; + warning_given=1; #endif /* NO_EMBEDDED_ACCESS_CHECKS */ - if (warning_given) + + if (warning_given) push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_TABLE_EXISTS_ERROR, ER_THD(thd, ER_TABLE_EXISTS_ERROR), orig_table_name.str); + } } } |