diff options
author | Anel Husakovic <anel@mariadb.org> | 2022-07-16 13:32:37 +0200 |
---|---|---|
committer | Anel Husakovic <anel@mariadb.org> | 2022-07-16 13:32:37 +0200 |
commit | 243f33bc25ac50b298bc5f5c8ae15c6facc2d70d (patch) | |
tree | e8427daa74d82ec39ed04bb561a20ecb53d502dc | |
parent | 18bb37d7e5b9b723729f59659a4d5a7ee2b7d97c (diff) | |
download | mariadb-git-243f33bc25ac50b298bc5f5c8ae15c6facc2d70d.tar.gz |
MDEV-28332: Alter on temporary table causes ER_TABLE_EXISTS_ERROR note
- Additionally update comments
Reviewed by: <monty@mariadb.org>
-rw-r--r-- | mysql-test/main/information_schema_temp_table.result | 12 | ||||
-rw-r--r-- | mysql-test/main/information_schema_temp_table.test | 11 | ||||
-rw-r--r-- | mysql-test/main/lock_multi.result | 2 | ||||
-rw-r--r-- | mysql-test/main/temp_table.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/maria/temporary.result | 1 | ||||
-rw-r--r-- | mysql-test/suite/plugins/r/audit_null.result | 3 | ||||
-rw-r--r-- | sql/sql_show.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 23 |
8 files changed, 40 insertions, 20 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 7a34324f919..4257a5dd7d6 100644 --- a/mysql-test/main/information_schema_temp_table.test +++ b/mysql-test/main/information_schema_temp_table.test @@ -92,3 +92,14 @@ 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; 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/mysql-test/suite/maria/temporary.result b/mysql-test/suite/maria/temporary.result index c414d2e49b1..4184731c774 100644 --- a/mysql-test/suite/maria/temporary.result +++ b/mysql-test/suite/maria/temporary.result @@ -20,7 +20,6 @@ test.t1 check status OK ALTER TABLE t1 CHANGE COLUMN IF EXISTS x x INT; Warnings: Note 1054 Unknown column 'x' in 't1' -Note 1050 Table 't1' already exists ALTER TABLE t1; DROP TEMPORARY TABLE t1; DROP TABLE t1; diff --git a/mysql-test/suite/plugins/r/audit_null.result b/mysql-test/suite/plugins/r/audit_null.result index 1a88e8d7716..221ea5d9ebd 100644 --- a/mysql-test/suite/plugins/r/audit_null.result +++ b/mysql-test/suite/plugins/r/audit_null.result @@ -48,8 +48,6 @@ select * from t2; a 2020-10-09 alter table t2 add column b int; -Warnings: -Note 1050 Table 't2' already exists drop table t2; explain select distinct * from t2; id select_type table type possible_keys key key_len ref rows Extra @@ -106,7 +104,6 @@ root[root] @ localhost [] >> SHOW WARNINGS root[root] @ localhost [] >> insert t2 values ('2020-10-09') root[root] @ localhost [] >> select * from t2 root[root] @ localhost [] >> alter table t2 add column b int -root[root] @ localhost [] >> SHOW WARNINGS root[root] @ localhost [] >> drop table t2 root[root] @ localhost [] >> explain select distinct * from t2 root[root] @ localhost [] test.t2 : read diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fde04014760..1589c80e5bb 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5875,14 +5875,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 ae280f2b0ed..8de0515e795 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4344,23 +4344,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); + } } } |