MDEV-16192 Table 't' is specified twice, both as a target for 'CREATE' and...
as a separate source for data Actually MDEV-15867 and MDEV-16192 are same, Slave adds "or replace" to create table stmt. So create table t1 is create or replace on slave. So this bug is not because of replication, We can get this bug on general server if we manually add or replace to create query. Problem:- So if we try to create table t1 (same name as of temp table t1 ) via CREATE or replace TABLE t AS SELECT * FROM t; Since in this query we are creating table from select * from t1 , we call unique_table function to see whether if source and destination table are same. But there is one issue unique_table does not account if source table is tmp table in this case source and destination table can be same. Solution:- We will change find_dup_table to not to look for temp table if CHECK_DUP_SKIP_TEMP_TABLE flag is on.
This commit is contained in:
parent
1cc1d0429d
commit
9827c5e103
4
mysql-test/r/create_replace_tmp.result
Normal file
4
mysql-test/r/create_replace_tmp.result
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE TEMPORARY TABLE t (i INT);
|
||||
CREATE or replace TABLE t AS SELECT * FROM t;
|
||||
DROP TEMPORARY TABLE t;
|
||||
DROP TABLE t;
|
9
mysql-test/suite/rpl/r/rpl_15867.result
Normal file
9
mysql-test/suite/rpl/r/rpl_15867.result
Normal file
@ -0,0 +1,9 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
CREATE TEMPORARY TABLE t (i INT);
|
||||
CREATE TABLE t AS SELECT * FROM t;
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP TEMPORARY TABLE t;
|
||||
DROP TABLE t;
|
||||
include/rpl_end.inc
|
11
mysql-test/suite/rpl/t/rpl_15867.test
Normal file
11
mysql-test/suite/rpl/t/rpl_15867.test
Normal file
@ -0,0 +1,11 @@
|
||||
--source include/master-slave.inc
|
||||
CREATE TEMPORARY TABLE t (i INT);
|
||||
CREATE TABLE t AS SELECT * FROM t;
|
||||
|
||||
--sync_slave_with_master
|
||||
|
||||
# Cleanup
|
||||
--connection master
|
||||
DROP TEMPORARY TABLE t;
|
||||
DROP TABLE t;
|
||||
--source include/rpl_end.inc
|
4
mysql-test/t/create_replace_tmp.test
Normal file
4
mysql-test/t/create_replace_tmp.test
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE TEMPORARY TABLE t (i INT);
|
||||
CREATE or replace TABLE t AS SELECT * FROM t;
|
||||
DROP TEMPORARY TABLE t;
|
||||
DROP TABLE t;
|
@ -1031,6 +1031,12 @@ retry:
|
||||
if (res->table && (res->table == table->table))
|
||||
continue;
|
||||
|
||||
/* Skip if table is tmp table */
|
||||
if (check_flag & CHECK_DUP_SKIP_TEMP_TABLE &&
|
||||
res->table && res->table->s->tmp_table != NO_TMP_TABLE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (check_flag & CHECK_DUP_FOR_CREATE)
|
||||
DBUG_RETURN(res);
|
||||
|
||||
|
@ -64,6 +64,7 @@ enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
|
||||
/* Flag bits for unique_table() */
|
||||
#define CHECK_DUP_ALLOW_DIFFERENT_ALIAS 1
|
||||
#define CHECK_DUP_FOR_CREATE 2
|
||||
#define CHECK_DUP_SKIP_TEMP_TABLE 4
|
||||
|
||||
uint get_table_def_key(const TABLE_LIST *table_list, const char **key);
|
||||
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
|
||||
|
@ -3910,8 +3910,8 @@ mysql_execute_command(THD *thd)
|
||||
{
|
||||
TABLE_LIST *duplicate;
|
||||
if ((duplicate= unique_table(thd, lex->query_tables,
|
||||
lex->query_tables->next_global,
|
||||
CHECK_DUP_FOR_CREATE)))
|
||||
lex->query_tables->next_global,
|
||||
CHECK_DUP_FOR_CREATE | CHECK_DUP_SKIP_TEMP_TABLE)))
|
||||
{
|
||||
update_non_unique_table_error(lex->query_tables, "CREATE",
|
||||
duplicate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user