Skip to content

EXISTS subquery returns duplicate rows with PRIMARY KEY #9797

@momoway

Description

@momoway
CREATE  TABLE  t(c0 INT, c1 INT, PRIMARY KEY(c0, c1));
INSERT INTO t VALUES (1, 1);
INSERT INTO t VALUES (2, 2);
INSERT INTO t VALUES (2, 3);

SELECT * FROM t
WHERE EXISTS (
  SELECT 1
  FROM t AS x
  WHERE x.c0 = t.c0
);

+----+----+
| c0 | c1 |
+----+----+
|  1 |  1 |
|  2 |  2 |
|  2 |  2 |
|  2 |  3 |
|  2 |  3 |
+----+----+
5 rows in set (0.00 sec)

should return 3 rows, MySQL will return

+----+----+
| c0 | c1 |
+----+----+
|  1 |  1 |
|  2 |  2 |
|  2 |  3 |
+----+----+
3 rows in set (0.00 sec)

Dolt version: 1.59.3

mysql> select dolt_version();
+----------------+
| dolt_version() |
+----------------+
| 1.59.3         |
+----------------+
1 row in set (0.00 sec)

OS: Linux (x86)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions