summaryrefslogtreecommitdiff
path: root/mysql-test/main/insert_select.test
diff options
context:
space:
mode:
authorOleg Smirnov <olernov@gmail.com>2022-06-18 20:54:39 +0700
committerOleg Smirnov <olernov@gmail.com>2022-07-14 11:07:24 +0700
commit49e14000eeb245ea27e9207d2f63cb0a28be1ca9 (patch)
treefa013feb56bb774859cd01e43b84516f84652687 /mysql-test/main/insert_select.test
parent02e85aeafdc3fbe7d628e155880390c4d623f9b4 (diff)
downloadmariadb-git-49e14000eeb245ea27e9207d2f63cb0a28be1ca9.tar.gz
MDEV-26427 MariaDB Server SEGV on INSERT .. SELECT
1. For INSERT..SELECT statements: don't include table/view the data is inserted into in the list of leaf tables 2. Remove duplicated and dead code related to table_count
Diffstat (limited to 'mysql-test/main/insert_select.test')
-rw-r--r--mysql-test/main/insert_select.test54
1 files changed, 54 insertions, 0 deletions
diff --git a/mysql-test/main/insert_select.test b/mysql-test/main/insert_select.test
index 91b2cc6f981..1f672acc203 100644
--- a/mysql-test/main/insert_select.test
+++ b/mysql-test/main/insert_select.test
@@ -459,4 +459,58 @@ INSERT INTO t1 SELECT a*2 FROM t1 ORDER BY a;
DROP TABLE t1;
+#
+# MDEV-26427 MariaDB Server SEGV on INSERT .. SELECT
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 (a) SELECT SUM(1);
+INSERT INTO t1 (a, b) SELECT AVG(2), MIN(3);
+
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 (b) SELECT AVG('x') OVER ();
+INSERT INTO t1 SELECT MIN(7) OVER (), MAX(8) OVER();
+SELECT * FROM t1;
+
+PREPARE stmt FROM 'INSERT INTO t1 (a) SELECT AVG(?)';
+EXECUTE stmt USING 9;
+EXECUTE stmt USING 10;
+
+PREPARE stmt FROM 'INSERT INTO t1 SELECT MIN(?), MAX(?)';
+EXECUTE stmt USING 11, 12;
+EXECUTE stmt USING 13, 14;
+DEALLOCATE PREPARE stmt;
+SELECT * FROM t1;
+
+DELIMITER //;
+CREATE PROCEDURE p1(param_a INT, param_b INT)
+BEGIN
+INSERT INTO t1 SELECT MIN(param_a) OVER (), MAX(param_b);
+END//
+DELIMITER ;//
+CALL p1(21, 22);
+CALL p1(23, 24);
+SELECT * FROM t1;
+
+CREATE TABLE t2 (
+ a DECIMAL UNIQUE CHECK (CASE 0 * 27302337.000000 WHEN 34 THEN
+ + 'x' LIKE 'x' OR a NOT IN (-1 / TRUE ^ 2) ELSE 7105743.000000 END));
+INSERT INTO t2 VALUES (90),( -1),(31152443.000000),(-32768),(NULL),(NULL);
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t2 SELECT AVG('x') OVER (
+ PARTITION BY ((NOT AVG(76698761.000000))) IS NOT NULL);
+INSERT IGNORE INTO t2 () VALUES (0),('x'),(3751286.000000),
+ ('x'),((a = 'x' AND 0 AND 0));
+INSERT INTO t2 VALUES (127);
+--error ER_DUP_ENTRY
+INSERT INTO t2 SELECT -2147483648 END FROM t2 AS TEXT JOIN t2 JOIN t2 TABLES;
+--error ER_TRUNCATED_WRONG_VALUE
+ALTER TABLE t2 ADD (
+ b INT UNIQUE CHECK ((a = 'x' AND ((-(+(BINARY 49730460.000000)))) = 'x'
+ BETWEEN 'x' AND 'x')));
+--error ER_DUP_ENTRY
+UPDATE t2 SET a = -128 WHERE a IS NULL ORDER BY 78 IN ('x','x'),a;
+
+DROP TABLE t1, t2;
+DROP PROCEDURE p1;
+
--echo # End of 10.2 test