1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00
Files
mariadb/mysql-test/main/unique.test
Sergei Petrunia a52362b90c MDEV-36389 Incorrect query results for an indexed text column
Fixes a scenario where an IN subquery returned the wrong result
because the pushed WHERE clause was not retained for downstream
result filtering.  For example:
  CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1)));
  INSERT INTO t1 (c1) VALUES ('a');
  SELECT 'abc' IN (SELECT c1 FROM t1);
Internally, he 'abc' IN subquery condition becomes the constant
condition:
  'abc' = t1.c1 or t1.c1 is null
Prior to this patch, this condition was incorrectly removed when
converting the subquery engine to an index lookup-based engine.
Now eligible conditions are preserved during such engine rewrites.
2025-07-23 15:24:12 -04:00

46 lines
1.1 KiB
Plaintext

--source include/have_innodb.inc
#
# MDEV-19224 Assertion `marked_for_read()' failed in various places with long
# unique key
#
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, a varchar(30000), UNIQUE (a)) ENGINE=innodb;
INSERT INTO t1 (a) VALUES (20),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
SELECT * FROM t1 WHERE a BETWEEN '1' AND '100';
DROP TABLE t1;
#
# MDEV-19252 Warning about assertion failure marked_for_write_or_computed()
# printed by release build with DBUG_ASSERT_AS_PRINTF, but no failure on debug
# build
#
CREATE TABLE t2 (n BLOB, UNIQUE(n));
INSERT INTO t2 VALUES (1);
DELETE FROM t2 WHERE n = 1;
DROP TABLE t2;
--echo #
--echo # Beginning of 11.4 tests
--echo #
--echo #
--echo # MDEV-36389
--echo #
CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1)));
INSERT INTO t1 (c1) VALUES ('a');
SELECT c1 FROM t1 WHERE ('abc' IN (SELECT c1 FROM t1)) IS FALSE;
DROP TABLE t1;
CREATE TABLE t0 (c1 text not null);
insert into t0 values ('abc'),('abc');
CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1))) engine=myisam;
INSERT INTO t1 (c1) VALUES ('a'),('b'),('c');
SELECT c1, c1 IN (SELECT c1 FROM t1) FROM t0;
DROP TABLE t0, t1;
--echo # End of 11.4 tests