Skip to content

Commit c411393

Browse files
committed
MDEV-24715 Assertion !node->table->skip_alter_undo in CREATE...REPLACE SELECT
In commit 3cef4f8 (MDEV-515) we inadvertently broke CREATE TABLE...REPLACE SELECT statements by wrongly disabling row-level undo logging. select_create::prepare(): Only invoke extra(HA_EXTRA_BEGIN_ALTER_COPY) if no special treatment of duplicates is needed.
1 parent 68b2819 commit c411393

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# MDEV-24715 Assertion !node->table->skip_alter_undo
3+
#
4+
CREATE TABLE t (a INT UNIQUE) ENGINE=InnoDB
5+
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
6+
SELECT * FROM t;
7+
a b
8+
1 3
9+
DROP TABLE t;
10+
CREATE TEMPORARY TABLE t (a INT UNIQUE) ENGINE=InnoDB
11+
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
12+
SELECT * FROM t;
13+
a b
14+
1 3
15+
DROP TEMPORARY TABLE t;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--source include/have_innodb.inc
2+
3+
--echo #
4+
--echo # MDEV-24715 Assertion !node->table->skip_alter_undo
5+
--echo #
6+
CREATE TABLE t (a INT UNIQUE) ENGINE=InnoDB
7+
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
8+
SELECT * FROM t;
9+
DROP TABLE t;
10+
11+
CREATE TEMPORARY TABLE t (a INT UNIQUE) ENGINE=InnoDB
12+
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
13+
SELECT * FROM t;
14+
DROP TEMPORARY TABLE t;

sql/sql_insert.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4746,7 +4746,8 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
47464746
if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
47474747
{
47484748
table->file->ha_start_bulk_insert((ha_rows) 0);
4749-
table->file->extra(HA_EXTRA_BEGIN_ALTER_COPY);
4749+
if (thd->lex->duplicates == DUP_ERROR && !thd->lex->ignore)
4750+
table->file->extra(HA_EXTRA_BEGIN_ALTER_COPY);
47504751
}
47514752
thd->abort_on_warning= !info.ignore && thd->is_strict_mode();
47524753
if (check_that_all_fields_are_given_values(thd, table, table_list))

0 commit comments

Comments
 (0)