case_sensitive_names.slt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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/case_sensitive_names
  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. # Case sensitivity of database names
  25. # statement ok
  26. # CREATE DATABASE D
  27. # statement ok
  28. # SHOW TABLES FROM d
  29. # statement error target database or schema does not exist
  30. # SHOW TABLES FROM "D"
  31. # statement ok
  32. # CREATE DATABASE "E"
  33. # statement error target database or schema does not exist
  34. # SHOW TABLES FROM e
  35. # statement ok
  36. # SHOW TABLES FROM "E"
  37. # Case sensitivity of table names:
  38. # When non-quoted, table names are normalized during creation.
  39. statement ok
  40. CREATE TABLE A(x INT)
  41. statement error pgcode 42P01 unknown catalog item 'A'
  42. SHOW COLUMNS FROM "A"
  43. statement error pgcode 42P01 unknown catalog item 'A'
  44. SHOW INDEXES ON "A"
  45. # statement error pgcode 42P01 catalog item '"A"' does not exist
  46. # SHOW CREATE TABLE "A"
  47. # statement error pgcode 42P01 catalog item '"A"' does not exist
  48. # SHOW GRANTS ON TABLE "A"
  49. # statement error pgcode 42P01 catalog item '"test.A"' does not exist
  50. # SHOW GRANTS ON TABLE test."A"
  51. # statement error pgcode 42P01 catalog item '"A"' does not exist
  52. # SHOW CONSTRAINTS FROM "A"
  53. statement error pgcode 42P01 unknown catalog item 'A'
  54. SELECT * FROM "A"
  55. # statement error pgcode 42P01 catalog item '"A"' does not exist
  56. # INSERT INTO "A"(x) VALUES(1)
  57. # statement error pgcode 42P01 catalog item '"A"' does not exist
  58. # UPDATE "A" SET x = 42
  59. # statement error pgcode 42P01 catalog item '"A"' does not exist
  60. # DELETE FROM "A"
  61. # statement error pgcode 42P01 catalog item '"A"' does not exist
  62. # TRUNCATE "A"
  63. statement error pgcode 42P01 unknown catalog item 'A'
  64. DROP TABLE "A"
  65. statement ok
  66. SHOW COLUMNS FROM a
  67. statement ok
  68. SHOW INDEXES ON a
  69. # statement ok
  70. # SHOW CREATE TABLE a
  71. # statement ok
  72. # SHOW CONSTRAINTS FROM a
  73. statement ok
  74. SELECT * FROM a
  75. statement ok
  76. INSERT INTO a(x) VALUES(1)
  77. statement ok
  78. UPDATE a SET x = 42
  79. statement ok
  80. DELETE FROM a
  81. # statement ok
  82. # TRUNCATE a
  83. statement ok
  84. DROP TABLE a
  85. # When quoted, a table name does not get normalized during create, and
  86. # must be thus quoted during use.
  87. statement ok
  88. CREATE TABLE "B"(x INT)
  89. statement error pgcode 42P01 unknown catalog item 'b'
  90. SHOW COLUMNS FROM B
  91. statement error pgcode 42P01 unknown catalog item 'b'
  92. SHOW INDEXES ON B
  93. # statement error pgcode 42P01 catalog item 'b' does not exist
  94. # SHOW CREATE TABLE B
  95. # statement error pgcode 42P01 catalog item 'b' does not exist
  96. # SHOW GRANTS ON TABLE B
  97. # statement error pgcode 42P01 catalog item 'test.b' does not exist
  98. # SHOW GRANTS ON TABLE test.B
  99. # statement error pgcode 42P01 catalog item 'b' does not exist
  100. # SHOW CONSTRAINTS FROM B
  101. statement error pgcode 42P01 unknown catalog item 'b'
  102. SELECT * FROM B
  103. # statement error pgcode 42P01 catalog item 'b' does not exist
  104. # INSERT INTO B(x) VALUES(1)
  105. # statement error pgcode 42P01 catalog item 'b' does not exist
  106. # UPDATE B SET x = 42
  107. # statement error pgcode 42P01 catalog item 'b' does not exist
  108. # DELETE FROM B
  109. # statement error pgcode 42P01 catalog item 'b' does not exist
  110. # TRUNCATE B
  111. statement error pgcode 42P01 unknown catalog item 'b'
  112. DROP TABLE B
  113. statement ok
  114. SHOW COLUMNS FROM "B"
  115. statement ok
  116. SHOW INDEXES ON "B"
  117. # statement ok
  118. # SHOW CREATE TABLE "B"
  119. # statement ok
  120. # SHOW GRANTS ON TABLE "B"
  121. # statement ok
  122. # SHOW GRANTS ON TABLE test."B"
  123. # statement ok
  124. # SHOW CONSTRAINTS FROM "B"
  125. statement ok
  126. SELECT * FROM "B"
  127. statement ok
  128. INSERT INTO "B"(x) VALUES(1)
  129. statement ok
  130. UPDATE "B" SET x = 42
  131. statement ok
  132. DELETE FROM "B"
  133. # statement ok
  134. # TRUNCATE "B"
  135. statement ok
  136. DROP TABLE "B"
  137. # Case sensitivity of column names.
  138. statement ok
  139. CREATE TABLE foo(X INT, "Y" INT, "created_AT" timestamp)
  140. query III colnames
  141. SELECT x, X, "Y" FROM foo
  142. ----
  143. x x Y
  144. statement error db error: ERROR: column "X" does not exist\nHINT: The similarly named column "x" does exist.
  145. SELECT "X" FROM foo
  146. statement error column "y" does not exist\nHINT: The similarly named column "Y" does exist.
  147. SELECT Y FROM foo
  148. simple
  149. SELECT creaetd_at FROM foo
  150. ----
  151. db error: ERROR: column "creaetd_at" does not exist
  152. HINT: The similarly named column "created_AT" does exist. Make sure to surround case sensitive names in double quotes.
  153. # The following should not be ambiguous.
  154. query II colnames
  155. SELECT Y, "Y" FROM (SELECT x as y, "Y" FROM foo)
  156. ----
  157. y Y
  158. statement ok
  159. CREATE TABLE foo_multi_case ("cAsE" INT, "CASE" INT)
  160. statement error ERROR: column "foo_multi_case.case" does not exist\nHINT: There are similarly named columns that do exist: "foo_multi_case.cAsE", "foo_multi_case.CASE". Make sure to surround case sensitive names in double quotes.
  161. SELECT foo_multi_case.case FROM foo_multi_case;
  162. statement ok
  163. CREATE TABLE j1 ("X" int);
  164. statement ok
  165. INSERT INTO j1 VALUES (1), (2), (3);
  166. statement ok
  167. CREATE TABLE j2 ("X" int, "Y" int);
  168. statement ok
  169. INSERT INTO j2 VALUES (1, 5), (2, 7), (8, 9);
  170. statement ok
  171. CREATE TABLE j3 ("X" int, "Z" int);
  172. statement ok
  173. INSERT INTO j3 VALUES (1, 7), (10, 11), (12, 13);
  174. statement error db error: ERROR: column "Y" does not exist\nHINT: The similarly named column "y" does exist.
  175. SELECT "Y" FROM ( SELECT "X" as y FROM j1 NATURAL JOIN j2 );
  176. query I
  177. SELECT y FROM ( SELECT "X" as y FROM j1 NATURAL JOIN j2 );
  178. ----
  179. 1
  180. 2
  181. # Even though the column "Y" exists, it should not get suggested since it's not in scope.
  182. statement error db error: ERROR: column "y" does not exist
  183. SELECT "X", y FROM j1 LEFT JOIN ( SELECT "X", "Z" FROM j2 LEFT JOIN j3 USING ("X") ) USING ("X");
  184. # Case sensitivity of view names.
  185. mode standard
  186. statement ok
  187. CREATE VIEW XV AS SELECT X, "Y" FROM foo
  188. query TT
  189. SHOW CREATE VIEW xv
  190. ----
  191. materialize.public.xv
  192. CREATE VIEW materialize.public.xv AS SELECT x, "Y" FROM materialize.public.foo;
  193. query error unknown catalog item 'XV'
  194. SHOW CREATE VIEW "XV"
  195. statement ok
  196. CREATE VIEW "YV" AS SELECT X, "Y" FROM foo
  197. query TT
  198. SHOW CREATE VIEW "YV"
  199. ----
  200. materialize.public.YV
  201. CREATE VIEW materialize.public."YV" AS SELECT x, "Y" FROM materialize.public.foo;
  202. query error unknown catalog item 'yv'
  203. SHOW CREATE VIEW YV
  204. mode cockroach
  205. # Case sensitivity of index names.
  206. statement ok
  207. CREATE TABLE a(x INT, y INT, CONSTRAINT FooIdx PRIMARY KEY(x))
  208. statement ok
  209. CREATE INDEX I ON a(y)
  210. # statement error index "I" not found
  211. # SELECT * FROM a@"I"
  212. # statement error index "FooIdx" not found
  213. # SELECT * FROM a@"FooIdx"
  214. # statement error index "I" not found
  215. # SELECT * FROM a ORDER BY INDEX a@"I"
  216. # statement error index "FooIdx" not found
  217. # SELECT * FROM a ORDER BY INDEX a@"FooIdx"
  218. # statement error index "I" does not exist
  219. # DROP INDEX a@"I"
  220. # statement ok
  221. # SELECT * FROM a@I
  222. # statement ok
  223. # SELECT * FROM a@FooIdx
  224. # statement ok
  225. # SELECT * FROM a ORDER BY INDEX a@I
  226. # statement ok
  227. # SELECT * FROM a ORDER BY INDEX a@FooIdx
  228. statement ok
  229. DROP INDEX I
  230. # Unicode sequences are preserved.
  231. statement ok
  232. CREATE TABLE Amelie("Amélie" INT, "Amélie" INT)
  233. statement ok
  234. INSERT INTO Amelie VALUES (1, 2)
  235. # # Check that the column names were encoded properly
  236. # query I
  237. # SELECT ordinal_position FROM information_schema.columns WHERE table_name = 'amelie' AND column_name::BYTES = b'Ame\xcc\x81lie'
  238. # ----
  239. # 1
  240. # query I
  241. # SELECT ordinal_position FROM information_schema.columns WHERE table_name = 'amelie' AND column_name::BYTES = b'Am\xc3\xa9lie'
  242. # ----
  243. # 2
  244. # Check that the non-normalized names propagate throughout until results.
  245. query II colnames
  246. SELECT "Amélie", "Amélie" FROM Amelie
  247. ----
  248. Amélie Amélie
  249. 2 1
  250. # Check that function names are also recognized case-insensitively.
  251. query T
  252. SELECT AsCIi('abc')
  253. ----
  254. 97