diff options
-rw-r--r-- | mysql-test/main/create_or_replace.result | 9 | ||||
-rw-r--r-- | mysql-test/main/create_or_replace.test | 11 | ||||
-rw-r--r-- | sql/sql_insert.cc | 7 |
3 files changed, 26 insertions, 1 deletions
diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 00bc5a81ec4..6267838fcca 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -940,3 +940,12 @@ create table t (a int) engine=myisam; create temporary table tm (a int) engine=merge union=(t); create or replace table tt like tm; drop tables tt, tm, t; +# +# MDEV-29793 Assertion failure in translog_write_record upon CREATE OR REPLACE +# +CREATE TABLE t1 (id INT, f INT, KEY(f), PRIMARY KEY (id)) ENGINE=Aria; +INSERT INTO t1 VALUES (1,1),(2,7),(3,9); +CREATE TABLE t2 (a INT) ENGINE=Aria; +INSERT INTO t2 VALUES (2),(1); +CREATE OR REPLACE TABLE t3 AS SELECT t2.* FROM t2, t1 WHERE t2.a = t1.f OR t2.a = t1.id; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 14fd4f0763e..882f98aa217 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -738,3 +738,14 @@ create table t (a int) engine=myisam; create temporary table tm (a int) engine=merge union=(t); create or replace table tt like tm; drop tables tt, tm, t; + +--echo # +--echo # MDEV-29793 Assertion failure in translog_write_record upon CREATE OR REPLACE +--echo # +CREATE TABLE t1 (id INT, f INT, KEY(f), PRIMARY KEY (id)) ENGINE=Aria; +INSERT INTO t1 VALUES (1,1),(2,7),(3,9); +CREATE TABLE t2 (a INT) ENGINE=Aria; +INSERT INTO t2 VALUES (2),(1); +CREATE OR REPLACE TABLE t3 AS SELECT t2.* FROM t2, t1 WHERE t2.a = t1.f OR t2.a = t1.id; +# Cleanup +DROP TABLE t1, t2, t3; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 8319694a8d4..9746c31cdc3 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4751,7 +4751,10 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items, table->pos_in_table_list= table_list; int error; - /* Disable logging of inserted rows */ + /* + Disable logging of inserted rows, ha_start_bulk_insert() depends + on that. + */ mysql_trans_prepare_alter_copy_data(thd); if ((DBUG_IF("atomic_replace_external_lock_fail") && @@ -5060,6 +5063,8 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u) table->file->ha_start_bulk_insert((ha_rows) 0); if (thd->lex->duplicates == DUP_ERROR && !thd->lex->ignore) table->file->extra(HA_EXTRA_BEGIN_ALTER_COPY); + if (atomic_replace) + thd->transaction->on= true; } thd->abort_on_warning= !info.ignore && thd->is_strict_mode(); if (check_that_all_fields_are_given_values(thd, table, table_list)) |