no_primary_key.slt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/no_primary_key
  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. # we don't support rowid
  21. # query error duplicate column name: "rowid"
  22. # CREATE TABLE t (
  23. # rowid INT
  24. #)
  25. statement ok
  26. CREATE TABLE t (
  27. a INT,
  28. b INT
  29. )
  30. statement ok
  31. INSERT INTO t VALUES (1, 2)
  32. statement ok
  33. INSERT INTO t VALUES (1, 2)
  34. statement ok
  35. INSERT INTO t VALUES (3, 4)
  36. query II rowsort
  37. SELECT a, b FROM t
  38. ----
  39. 1 2
  40. 1 2
  41. 3 4
  42. query I
  43. SELECT count(rowid) FROM t
  44. ----
  45. 3
  46. # Make sure column order for insertion is not affected by the rowid column.
  47. statement ok
  48. ALTER TABLE t ADD c STRING
  49. statement ok
  50. INSERT INTO t VALUES (5, 6, '7')
  51. query IIT rowsort
  52. select * from t
  53. ----
  54. 1 2 NULL
  55. 1 2 NULL
  56. 3 4 NULL
  57. 5 6 7
  58. statement ok
  59. SELECT a, b, c, rowid FROM t
  60. statement ok
  61. INSERT INTO t (a, rowid) VALUES (10, 11)
  62. query I
  63. SELECT rowid FROM t WHERE a = 10
  64. ----
  65. 11
  66. query TTBTTTB
  67. SHOW COLUMNS FROM t
  68. ----
  69. a INT8 true NULL · {} false
  70. b INT8 true NULL · {} false
  71. rowid INT8 false unique_rowid() · {primary} true
  72. c STRING true NULL · {} false
  73. statement ok
  74. CREATE INDEX a_idx ON t (a)
  75. statement ok
  76. INSERT INTO t DEFAULT VALUES
  77. statement error syntax error
  78. INSERT INTO t (a, b) DEFAULT VALUES