Skip to content

Commit 409e210

Browse files
committed
MDEV-19449 Got error 168 for valid TRUNCATE (temporary) TABLE
Add the test case. The parent commit, which cherry-picked the MDEV-17167 fix from 10.3 (commit bad2f15) fixed the bug.
1 parent 95fb88d commit 409e210

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

mysql-test/r/temp_table.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,15 @@ LOCK TABLES t2 WRITE;
572572
TRUNCATE TABLE t1;
573573
UNLOCK TABLES;
574574
DROP TABLE t1, t2;
575+
#
576+
# MDEV-19449 1030: Got error 168 "Unknown (generic) error from engine"
577+
# for valid TRUNCATE (temporary) TABLE
578+
#
579+
CREATE TEMPORARY TABLE t1 (col1 BIGINT) ENGINE = InnoDB;
580+
INSERT INTO t1 (no_such_col) SELECT * FROM t1;
581+
ERROR 42S22: Unknown column 'no_such_col' in 'field list'
582+
TRUNCATE TABLE t1;
583+
ALTER TABLE t1 CHANGE no_such_col1 col1 BIGINT NULL;
584+
ERROR 42S22: Unknown column 'no_such_col1' in 't1'
585+
TRUNCATE TABLE t1;
586+
DROP TEMPORARY TABLE t1;

mysql-test/t/temp_table.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,19 @@ TRUNCATE TABLE t1;
623623
UNLOCK TABLES;
624624

625625
DROP TABLE t1, t2;
626+
627+
--echo #
628+
--echo # MDEV-19449 1030: Got error 168 "Unknown (generic) error from engine"
629+
--echo # for valid TRUNCATE (temporary) TABLE
630+
--echo #
631+
632+
CREATE TEMPORARY TABLE t1 (col1 BIGINT) ENGINE = InnoDB;
633+
--error ER_BAD_FIELD_ERROR
634+
INSERT INTO t1 (no_such_col) SELECT * FROM t1;
635+
TRUNCATE TABLE t1;
636+
--error ER_BAD_FIELD_ERROR
637+
ALTER TABLE t1 CHANGE no_such_col1 col1 BIGINT NULL;
638+
# This would wrongly try to re-truncate the old copy of the table that
639+
# was not dropped during the first TRUNCATE due to extra table handles.
640+
TRUNCATE TABLE t1;
641+
DROP TEMPORARY TABLE t1;

0 commit comments

Comments
 (0)