github-5984.td 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. #
  10. # Regression test for https://github.com/MaterializeInc/database-issues/issues/1846
  11. #
  12. # wrong result with ORDER BY and NULLs in scalar subquery
  13. #
  14. > CREATE TABLE t1 (f1 INTEGER);
  15. > CREATE INDEX i1 ON t1(f1);
  16. > INSERT INTO t1 VALUES (1);
  17. > CREATE TABLE t2 (f1 INTEGER);
  18. > INSERT INTO t2 VALUES (1);
  19. > CREATE TABLE t3 (f1 INTEGER);
  20. > INSERT INTO t3 VALUES (NULL);
  21. > INSERT INTO t3 VALUES (1);
  22. > SELECT COUNT(*) FROM t1 WHERE f1 = ( SELECT t2 . f1 FROM t3 LEFT JOIN t2 ON ( t3 . f1 = t1.f1 ) ORDER BY 1 DESC LIMIT 1);
  23. 0
  24. > SELECT f1 = ( SELECT t2 . f1 FROM t3 LEFT JOIN t2 ON ( t3 . f1 = t1.f1 ) ORDER BY 1 DESC LIMIT 1) IS NULL FROM t1;
  25. true