github-7467.slt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Regression test for database-issues#7467.
  10. # The schema is a simplified version of
  11. # https://github.com/MaterializeInc/RQG/blob/main/conf/mz/simple.sql
  12. statement ok
  13. CREATE TABLE t1 (f1 INT, f2 INT NOT NULL);
  14. statement ok
  15. INSERT INTO t1 VALUES (2, 2), (2, 2), (3, 3);
  16. statement ok
  17. CREATE TABLE t2 (f1 INT, f2 INT NOT NULL);
  18. statement ok
  19. INSERT INTO t2 VALUES (NULL, 0);
  20. # Prior to the bugfix for database-issues#7467 this query was (wrongly) returning a single
  21. # row.
  22. query II
  23. SELECT DISTINCT
  24. (a1.f1) AS c1,
  25. (a1.f2) AS c2
  26. FROM
  27. t1 AS a1
  28. JOIN (VALUES(1, 2)) AS a2(f1, f2) ON (a2.f2 = a1.f1)
  29. WHERE
  30. a1.f2 + a2.f2 > (SELECT DISTINCT 0 c2 FROM t2 AS a1) AND a2.f2 IS NULL
  31. OR NULLIF (a2.f2, a2.f1) = a1.f2 + a1.f2;
  32. ----