database.slt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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/database
  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. # not supported yet
  20. halt
  21. mode cockroach
  22. statement ok
  23. CREATE DATABASE a
  24. statement error pgcode 42P04 database "a" already exists
  25. CREATE DATABASE a
  26. statement ok
  27. CREATE DATABASE IF NOT EXISTS a
  28. statement error empty database name
  29. CREATE DATABASE ""
  30. query T colnames
  31. SHOW DATABASES
  32. ----
  33. database_name
  34. a
  35. materialize
  36. postgres
  37. system
  38. test
  39. query T colnames
  40. SHOW SCHEMAS FROM a
  41. ----
  42. schema_name
  43. crdb_internal
  44. information_schema
  45. pg_catalog
  46. public
  47. statement ok
  48. CREATE DATABASE b TEMPLATE=template0
  49. statement error unsupported template: nope
  50. CREATE DATABASE c TEMPLATE=NOPE
  51. statement error unsupported template: nope
  52. CREATE DATABASE IF NOT EXISTS c TEMPLATE=NOPE
  53. statement ok
  54. CREATE DATABASE b2 ENCODING='UTF8'
  55. statement error unsupported encoding: NOPE
  56. CREATE DATABASE c ENCODING='NOPE'
  57. statement error unsupported encoding: NOPE
  58. CREATE DATABASE IF NOT EXISTS c ENCODING='NOPE'
  59. statement ok
  60. CREATE DATABASE b3 LC_COLLATE='C.UTF-8'
  61. statement error unsupported collation: NOPE
  62. CREATE DATABASE c LC_COLLATE='NOPE'
  63. statement error unsupported collation: NOPE
  64. CREATE DATABASE IF NOT EXISTS c LC_COLLATE='NOPE'
  65. statement ok
  66. CREATE DATABASE b4 LC_CTYPE='C.UTF-8'
  67. statement error unsupported character classification: NOPE
  68. CREATE DATABASE c LC_CTYPE='NOPE'
  69. statement error unsupported character classification: NOPE
  70. CREATE DATABASE IF NOT EXISTS c LC_CTYPE='NOPE'
  71. statement ok
  72. CREATE DATABASE b5 TEMPLATE=template0 ENCODING='UTF8' LC_COLLATE='C.UTF-8' LC_CTYPE='C.UTF-8'
  73. statement ok
  74. CREATE DATABASE b6 TEMPLATE template0 ENCODING 'UTF8' LC_COLLATE 'C.UTF-8' LC_CTYPE 'C.UTF-8'
  75. statement ok
  76. CREATE DATABASE c
  77. query T
  78. SHOW DATABASES
  79. ----
  80. a
  81. b
  82. b2
  83. b3
  84. b4
  85. b5
  86. b6
  87. c
  88. materialize
  89. postgres
  90. system
  91. test
  92. statement ok
  93. CREATE TABLE b.a (id INT PRIMARY KEY)
  94. statement ok
  95. INSERT INTO b.a VALUES (3),(7),(2)
  96. query I rowsort
  97. SELECT * FROM b.a
  98. ----
  99. 2
  100. 3
  101. 7
  102. statement error database "b" is not empty
  103. DROP DATABASE b RESTRICT
  104. statement ok
  105. DROP DATABASE b CASCADE
  106. statement error pgcode 42P01 relation "b.a" does not exist
  107. SELECT * FROM b.a
  108. statement error database "b" does not exist
  109. DROP DATABASE b
  110. statement ok
  111. DROP DATABASE IF EXISTS b
  112. statement ok
  113. DROP DATABASE b2 CASCADE;
  114. DROP DATABASE b3 CASCADE;
  115. DROP DATABASE b4 CASCADE;
  116. DROP DATABASE b5 CASCADE;
  117. DROP DATABASE b6 CASCADE
  118. statement error empty database name
  119. DROP DATABASE ""
  120. query T colnames
  121. SHOW DATABASES
  122. ----
  123. database_name
  124. a
  125. c
  126. materialize
  127. postgres
  128. system
  129. test
  130. statement ok
  131. CREATE DATABASE b
  132. statement error pgcode 42P01 relation "b.a" does not exist
  133. SELECT * FROM b.a
  134. statement ok
  135. CREATE TABLE b.a (id INT PRIMARY KEY)
  136. query I
  137. SELECT * FROM b.a
  138. ----
  139. user testuser
  140. statement error only superusers are allowed to CREATE DATABASE
  141. CREATE DATABASE privs
  142. user root
  143. statement ok
  144. CREATE DATABASE privs
  145. user testuser
  146. statement error user testuser does not have DROP privilege on database privs
  147. DROP DATABASE privs CASCADE
  148. user root
  149. statement ok
  150. GRANT DROP ON DATABASE privs TO testuser
  151. user testuser
  152. statement ok
  153. DROP DATABASE privs CASCADE