summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2023-01-18 16:52:15 +0300
committerAleksey Midenkov <midenok@gmail.com>2023-01-26 17:15:21 +0300
commit72e8d4465666347a7e8926d0702757e48495be29 (patch)
tree7eabc9d5145ab79d719605af2dff90ae15514367
parenta84895a0137e234ad86dc82d94b347c3351b00c1 (diff)
downloadmariadb-git-72e8d4465666347a7e8926d0702757e48495be29.tar.gz
MDEV-29793 Assertion failure in translog_write_record upon CREATE OR REPLACE
Aria cannot start bulk insert with transactional logging of temporary table (fails on assertion). But complex join does external_lock() which disables logging again but sees log_incomplete and does translog_write_record() which expects logging on. Probably some logic of Aria is wrong. Atomic C-O-R does mysql_trans_prepare_alter_copy_data() hack to overcome the prohibition of transactional logging in temporary table for bulk insert. There is no objective reason for that prohibition for atomic C-O-R temporary table as the same works with non-temporary table. And now we enable transaction back after ha_start_bulk_insert() so complex join will be happy with external_lock().
-rw-r--r--mysql-test/main/create_or_replace.result9
-rw-r--r--mysql-test/main/create_or_replace.test11
-rw-r--r--sql/sql_insert.cc7
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))