1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

MDEV-10731: Wrong NULL match results in "Subquery returns more than 1 row" (error code 1242)

NOT NULL predicate was not added to tables in case of an update query having a subquery.
This commit is contained in:
Varun Gupta
2017-02-09 22:23:26 +05:30
parent 99b2de92c6
commit c2b217e243
3 changed files with 60 additions and 7 deletions

View File

@@ -37,3 +37,29 @@ UPDATE t1 a JOIN t2 b ON a.c1 = b.c1 JOIN v1 vw ON b.c2 = vw.c1 JOIN t3 del ON v
drop view v1;
drop table t1,t2,t3,t4;
--echo #
--echo # MDEV-10232 Scalar result of subquery changes after adding an outer select stmt
--echo #
CREATE TABLE t1 (
a_id INT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
b_id INT(20) UNSIGNED NULL DEFAULT NULL,
c_id VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (a_id))COLLATE = 'utf8_general_ci' ENGINE = InnoDB;
CREATE TABLE t2 (
b_id INT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
c_id VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (b_id),
INDEX idx_c_id (c_id))COLLATE = 'utf8_general_ci' ENGINE = InnoDB;
INSERT INTO t1 (b_id, c_id) VALUES (NULL, NULL);
INSERT INTO t2 (c_id) VALUES (NULL);
INSERT INTO t2 (c_id) VALUES (NULL);
SELECT * FROM T1;
SELECT t2.b_id FROM t1,t2 WHERE t2.c_id = t1.c_id;
UPDATE t1 SET b_id = (SELECT t2.b_id FROM t2 t2 WHERE t2.c_id = t1.c_id);
SELECT * FROM T1;
drop table t1,t2;