summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2022-12-10 14:25:54 +0300
committerAleksey Midenkov <midenok@gmail.com>2023-01-17 12:34:43 +0300
commit1b3e94f78b89f897231c9da93a17bce6068bc571 (patch)
tree7704b82795ac710b352ee9ee917955c75445577f
parent8e53c357ca8f2479199c9b9363d153fd30425cc1 (diff)
downloadmariadb-git-1b3e94f78b89f897231c9da93a17bce6068bc571.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))