summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2021-12-24 14:00:47 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2022-01-03 18:14:59 +0530
commit452c9a4d72c18a19136a91f4d59ee60eedd486be (patch)
tree2a824206a75eda98b8d2d70f67e3f7611bc420eb /mysql-test/t
parent5d57e04b27d0e69081b63b9e382cc3d9dc4480c0 (diff)
downloadmariadb-git-bb-10.2-MDEV-26698.tar.gz
MDEV-26698: Incorrect row number upon INSERT .. SELECT from the samebb-10.2-MDEV-26698
table: rows are counted twice Analysis: When the table we are trying to insert into and the SELECT table are same for INSERT ... SELECT, rows from the SELECT table are copied into internal temporary table and then to the INSERT table. We only want to count the rows when we start inserting into the table. Fix: Reset the counter to 1 before starting to copy from internal temporary table to select table and then increment the counter.
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/insert_select.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 27a831fbe3f..e577f29fd92 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -435,3 +435,28 @@ show create table t2;
drop table t1, t2;
--echo End of 5.5 tests
+
+--echo #
+--echo # Beginning of 10.2 test
+--echo #
+--echo # MDEV-26698: Incorrect row number upon INSERT .. SELECT from the same
+--echo # table: rows are counted twice
+--echo #
+
+CREATE TABLE t1(a TINYINT);
+
+INSERT INTO t1 VALUES (1), (100);
+
+INSERT INTO t1 SELECT a*2 FROM t1;
+
+TRUNCATE TABLE t1;
+
+--echo # using ORDER BY
+
+INSERT INTO t1 VALUES(1), (2), (100), (3);
+
+INSERT INTO t1 SELECT a*2 FROM t1 ORDER BY a;
+
+DROP TABLE t1;
+
+--echo # End of 10.2 test