sqlsmith.slt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/sqlsmith
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. mode cockroach
  20. simple conn=mz_system,user=mz_system
  21. ALTER SYSTEM SET unsafe_enable_table_keys = true
  22. ----
  23. COMPLETE 0
  24. # This file contains regression tests discovered by sqlsmith.
  25. # Regression: materialize#28836 (nulls in string_agg)
  26. statement ok
  27. SELECT subq_0.c3 AS c0, subq_0.c6 AS c1, subq_0.c4 AS c2, CASE WHEN (SELECT start_key FROM crdb_internal.ranges LIMIT 1 OFFSET 6) < CAST(NULLIF(pg_catalog.string_agg(CAST((SELECT start_key FROM crdb_internal.ranges LIMIT 1 OFFSET 7) AS BYTEA), CAST((SELECT pg_catalog.xor_agg(tgargs) FROM pg_catalog.pg_trigger) AS BYTEA)) OVER (PARTITION BY subq_0.c0 ORDER BY subq_0.c0, subq_0.c5, subq_0.c2), CAST(NULL AS BYTEA)) AS BYTEA) THEN subq_0.c6 ELSE subq_0.c6 END AS c3, subq_0.c2 AS c4, subq_0.c7 AS c5, CAST(COALESCE(subq_0.c7, subq_0.c7) AS INT8) AS c6 FROM (SELECT ref_0.table_name AS c0, ref_0.table_catalog AS c1, ref_0.table_type AS c2, (SELECT rolcreatedb FROM pg_catalog.pg_roles LIMIT 1 OFFSET 79) AS c3, ref_0.table_name AS c4, ref_0.version AS c5, ref_0.version AS c6, ref_0.version AS c7 FROM information_schema.tables AS ref_0 WHERE (ref_0.version IS NOT NULL) OR (pg_catalog.set_masklen(CAST(CAST(NULL AS INET) AS INET), CAST(ref_0.version AS INT8)) != (SELECT pg_catalog.max(client_addr) FROM pg_catalog.pg_stat_activity)) LIMIT 101) AS subq_0 WHERE subq_0.c7 IS NOT NULL
  28. # Regression: make sure lookup join planNode propagates its close signal. This
  29. # query could panic otherwise with a failure to empty all memory accounts.
  30. statement ok
  31. CREATE TABLE a (a INT PRIMARY KEY);
  32. statement ok
  33. SELECT true FROM (SELECT ref_1.a AS c0 FROM crdb_internal.cluster_queries AS ref_0 JOIN a AS ref_1 ON (ref_0.node_id = ref_1.a) WHERE (SELECT a from a limit 1 offset 1) is null);
  34. # Regression: cockroach#34437 (union all could produce panic in distsql planning)
  35. statement ok
  36. CREATE TABLE table8 (col1 TIME, col2 BYTEA, col4 OID, col6 NAME, col9 TIMESTAMP, PRIMARY KEY (col1));
  37. statement ok
  38. CREATE TABLE table5 (col0 TIME NULL, col1 OID, col3 INET, PRIMARY KEY (col1 ASC));
  39. statement ok
  40. INSERT INTO table8 (col1, col2, col4, col6)
  41. VALUES ('19:06:18.321589', NULL, NULL, NULL)
  42. UNION ALL (SELECT NULL, NULL, NULL, NULL FROM table5 AS tab_8);
  43. # Regression: cockroach#36441 (raw indexed var can't be type checked)
  44. query TO
  45. WITH
  46. with_20394 (col_162526)
  47. AS (
  48. SELECT
  49. *
  50. FROM
  51. (
  52. VALUES
  53. (
  54. 'd2d225e2-e9be-4420-a645-d1b8f577511c':::UUID
  55. )
  56. )
  57. AS tab_25520 (col_162526)
  58. UNION ALL
  59. SELECT
  60. *
  61. FROM
  62. (
  63. VALUES
  64. (
  65. '1d6eaf81-8a2c-43c5-a495-a3b102917ab1':::UUID
  66. )
  67. )
  68. AS tab_25521 (col_162527)
  69. )
  70. SELECT
  71. max(with_20394.col_162526::UUID)::UUID AS col_162534,
  72. 3697877132:::OID AS col_162541
  73. FROM
  74. with_20394
  75. GROUP BY
  76. with_20394.col_162526
  77. ORDER BY
  78. with_20394.col_162526 ASC
  79. ----
  80. 1d6eaf81-8a2c-43c5-a495-a3b102917ab1 3697877132
  81. d2d225e2-e9be-4420-a645-d1b8f577511c 3697877132
  82. # Regression: cockroach#36830 (can't run wrapped window node)
  83. statement ok
  84. CREATE TABLE table9 (a INT8);
  85. statement ok
  86. INSERT INTO table9 SELECT lag(a) OVER (PARTITION BY a) FROM table9;
  87. # Regression: cockroach#36607 (can't serialize or type-check arrays of NULL properly)
  88. query TTTT
  89. WITH
  90. with_194015 (col_1548014)
  91. AS (
  92. SELECT
  93. *
  94. FROM
  95. (
  96. VALUES
  97. (('-28 years -2 mons -677 days -11:53:30.528699':::INTERVAL::INTERVAL + '11:55:41.419498':::TIME::TIME)::TIME + '1973-01-24':::DATE::DATE),
  98. ('1970-01-11 01:38:09.000155+00:00':::TIMESTAMP),
  99. ('1970-01-09 07:04:13.000247+00:00':::TIMESTAMP),
  100. ('1970-01-07 14:19:52.000951+00:00':::TIMESTAMP),
  101. (NULL)
  102. )
  103. AS tab_240443 (col_1548014)
  104. ),
  105. with_194016 (col_1548015, col_1548016, col_1548017)
  106. AS (
  107. SELECT
  108. *
  109. FROM
  110. (
  111. VALUES
  112. (
  113. '160.182.25.199/22':::INET::INET << 'c2af:30cb:5db8:bb79:4d11:2d0:1de8:bcea/59':::INET::INET,
  114. '09:14:05.761109':::TIME::TIME + '4 years 7 mons 345 days 23:43:13.325036':::INTERVAL::INTERVAL,
  115. B'0101010110101011101001111010100011001111001110001000101100011001101'
  116. ),
  117. (false, '14:36:41.282187':::TIME, B'011111111011001100000001101101011111110110010011110100110111100')
  118. )
  119. AS tab_240444 (col_1548015, col_1548016, col_1548017)
  120. ),
  121. with_194017 (col_1548018)
  122. AS (SELECT * FROM (VALUES ('43a30bc5-e412-426d-b99a-65783a7ed445':::UUID), (NULL), (crdb_internal.cluster_id()::UUID)) AS tab_240445 (col_1548018))
  123. SELECT
  124. CASE
  125. WHEN false THEN age('1970-01-09 08:48:24.000568+00:00':::TIMESTAMPTZ::TIMESTAMPTZ, '1970-01-07 08:40:45.000483+00:00':::TIMESTAMPTZ::TIMESTAMPTZ)::INTERVAL
  126. ELSE (
  127. (
  128. (-0.02805450661234963150):::DECIMAL::DECIMAL
  129. * array_position(
  130. (gen_random_uuid()::UUID::UUID || (NULL::UUID || NULL::UUID[])::UUID[])::UUID[],
  131. '5f29920d-7db1-4efc-b1cc-d1a7d0bcf145':::UUID::UUID
  132. )::INT8::INT8
  133. )::DECIMAL
  134. * age('1970-01-04 07:17:45.000268+00:00':::TIMESTAMPTZ::TIMESTAMPTZ, NULL::TIMESTAMPTZ)::INTERVAL::INTERVAL
  135. )
  136. END::INTERVAL
  137. + '-21 years -10 mons -289 days -13:27:05.205069':::INTERVAL::INTERVAL
  138. AS col_1548019,
  139. '1984-01-07':::DATE AS col_1548020,
  140. NULL AS col_1548021,
  141. 'f96fd19a-d2a9-4d98-81dd-97e3fc2a45d2':::UUID AS col_1548022
  142. FROM
  143. with_194015
  144. ORDER BY
  145. with_194015.col_1548014 DESC
  146. LIMIT
  147. 4:::INT8;
  148. ----
  149. NULL 1984-01-07 00:00:00 +0000 +0000 NULL f96fd19a-d2a9-4d98-81dd-97e3fc2a45d2
  150. NULL 1984-01-07 00:00:00 +0000 +0000 NULL f96fd19a-d2a9-4d98-81dd-97e3fc2a45d2
  151. NULL 1984-01-07 00:00:00 +0000 +0000 NULL f96fd19a-d2a9-4d98-81dd-97e3fc2a45d2
  152. NULL 1984-01-07 00:00:00 +0000 +0000 NULL f96fd19a-d2a9-4d98-81dd-97e3fc2a45d2