summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2022-10-14 20:10:06 +0300
committerAleksey Midenkov <midenok@gmail.com>2022-10-14 20:12:25 +0300
commitaabf07307497c8ed2089869f8f1d2210c06c1709 (patch)
treecc85052a3af14d1c1d1f95a4800df67fe728be0b
parent396253ad9c0aed4fb8b27a5709dec4bd303badc3 (diff)
downloadmariadb-git-aabf07307497c8ed2089869f8f1d2210c06c1709.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 542db523968..2ddd4ad9ff1 100644
--- a/mysql-test/main/create_or_replace.result
+++ b/mysql-test/main/create_or_replace.result
@@ -964,3 +964,12 @@ t1.MYI
drop table t1;
MYSQLD_DATADIR/test:
MYSQL_TMP_DIR:
+#
+# 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 dc75b72bb9b..9fb1ef16aef 100644
--- a/mysql-test/main/create_or_replace.test
+++ b/mysql-test/main/create_or_replace.test
@@ -757,3 +757,14 @@ drop table t1;
--list_files $MYSQLD_DATADIR/test *t1*
--echo MYSQL_TMP_DIR:
--list_files $MYSQL_TMP_DIR *t1*
+
+--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 310c1baed3a..4b904e02ef1 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4734,7 +4734,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") &&
@@ -5041,6 +5044,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))