schemas.slt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. mode cockroach
  10. query T
  11. show search_path
  12. ----
  13. public
  14. statement ok
  15. SET search_path = foo
  16. query T
  17. show search_path
  18. ----
  19. foo
  20. statement ok
  21. SET search_path = 'foo'
  22. query T
  23. show search_path
  24. ----
  25. foo
  26. statement ok
  27. SET search_path = 'ba r', foo, 'x, y', "a, b"
  28. query T
  29. show search_path
  30. ----
  31. "ba r", foo, "x, y", "a, b"
  32. query T
  33. SELECT current_schema()
  34. ----
  35. NULL
  36. query T
  37. SELECT current_schemas(false)
  38. ----
  39. {}
  40. query T
  41. SELECT current_schemas(true)
  42. ----
  43. {mz_catalog,pg_catalog}
  44. # Ensure both `current_schemas` and `current_schema` work when the specified
  45. # cluster is invalid.
  46. statement ok
  47. SET cluster = noexist
  48. query T
  49. SELECT current_schema()
  50. ----
  51. NULL
  52. query T
  53. SELECT current_schemas(false)
  54. ----
  55. {}
  56. query T
  57. SELECT current_schemas(true)
  58. ----
  59. {mz_catalog,pg_catalog}
  60. statement ok
  61. SET cluster = quickstart
  62. statement error no valid schema selected
  63. CREATE TABLE t (i INT)
  64. statement error no valid schema selected
  65. SHOW SOURCES;
  66. statement error no valid schema selected
  67. SHOW SINKS;
  68. statement error no valid schema selected
  69. SHOW INDEXES;
  70. statement ok
  71. CREATE SCHEMA foo
  72. ----
  73. query T
  74. SELECT current_schema()
  75. ----
  76. foo
  77. query T
  78. SELECT current_schemas(false)
  79. ----
  80. {foo}
  81. query T
  82. SELECT current_schemas(true)
  83. ----
  84. {mz_catalog,pg_catalog,foo}
  85. statement ok
  86. CREATE TABLE t (i INT)
  87. query T
  88. SELECT count(*) from t
  89. ----
  90. 0
  91. statement ok
  92. SET search_path = pg_catalog
  93. query T
  94. show search_path
  95. ----
  96. pg_catalog
  97. query T
  98. SELECT current_schema()
  99. ----
  100. pg_catalog
  101. query T
  102. SELECT current_schemas(true)
  103. ----
  104. {mz_catalog,pg_catalog}
  105. query T
  106. SELECT current_schemas(false)
  107. ----
  108. {pg_catalog}
  109. query TT
  110. SELECT id, name FROM mz_schemas WHERE name = 'mz_catalog' OR name = 'pg_catalog' OR name = 'mz_internal' OR name = 'information_schema';
  111. ----
  112. s1 mz_catalog
  113. s2 pg_catalog
  114. s4 mz_internal
  115. s5 information_schema