int_size.slt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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/int_size
  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. subtest defaults
  23. query T
  24. SHOW default_int_size
  25. ----
  26. 8
  27. subtest set_int4
  28. statement ok
  29. SET default_int_size=4
  30. query T
  31. SHOW default_int_size
  32. ----
  33. 4
  34. statement ok
  35. CREATE TABLE i4 (i4 INT)
  36. query TT
  37. SHOW CREATE TABLE i4
  38. ----
  39. i4 CREATE TABLE i4 (
  40. i4 INT4 NULL,
  41. FAMILY "primary" (i4, rowid)
  42. )
  43. subtest set_int8
  44. statement ok
  45. SET default_int_size=8
  46. query T
  47. SHOW default_int_size
  48. ----
  49. 8
  50. statement ok
  51. CREATE TABLE i8 (i8 INT)
  52. query TT
  53. SHOW CREATE TABLE i8
  54. ----
  55. i8 CREATE TABLE i8 (
  56. i8 INT8 NULL,
  57. FAMILY "primary" (i8, rowid)
  58. )
  59. # https://github.com/cockroachdb/cockroach/issues/32846
  60. subtest issue_32846
  61. statement ok
  62. SET default_int_size=8
  63. # Parsing and evaluation are async, so the setting won't take
  64. # effect until the next statement is evaluated.
  65. statement ok
  66. SET default_int_size=4; CREATE TABLE late4 (a INT)
  67. query TT
  68. SHOW CREATE TABLE late4
  69. ----
  70. late4 CREATE TABLE late4 (
  71. a INT8 NULL,
  72. FAMILY "primary" (a, rowid)
  73. )
  74. query T
  75. SHOW default_int_size
  76. ----
  77. 4
  78. subtest set_bad_value
  79. statement error pq: only 4 or 8 are supported by default_int_size
  80. SET default_int_size=2
  81. # We want to check the combinations of default_int_size and
  82. # experimental_serialization_normalization.
  83. subtest serial_rowid
  84. # When using rowid, we should always see INT8, since that's the
  85. # return type of unique_rowid()
  86. statement ok
  87. SET default_int_size=4; SET experimental_serial_normalization='rowid';
  88. statement ok
  89. CREATE TABLE i4_rowid (a SERIAL)
  90. query TT
  91. SHOW CREATE TABLE i4_rowid
  92. ----
  93. i4_rowid CREATE TABLE i4_rowid (
  94. a INT8 NOT NULL DEFAULT unique_rowid(),
  95. FAMILY "primary" (a, rowid)
  96. )
  97. statement ok
  98. SET default_int_size=8; SET experimental_serial_normalization='rowid';
  99. statement ok
  100. CREATE TABLE i8_rowid (a SERIAL)
  101. query TT
  102. SHOW CREATE TABLE i8_rowid
  103. ----
  104. i8_rowid CREATE TABLE i8_rowid (
  105. a INT8 NOT NULL DEFAULT unique_rowid(),
  106. FAMILY "primary" (a, rowid)
  107. )
  108. subtest serial_sql_sequence
  109. # When using rowid, we should see an INTx that matches the current size setting.
  110. statement ok
  111. SET default_int_size=4; SET experimental_serial_normalization='sql_sequence';
  112. statement ok
  113. CREATE TABLE i4_sql_sequence (a SERIAL)
  114. query TT
  115. SHOW CREATE TABLE i4_sql_sequence
  116. ----
  117. i4_sql_sequence CREATE TABLE i4_sql_sequence (
  118. a INT4 NOT NULL DEFAULT nextval('i4_sql_sequence_a_seq':::STRING),
  119. FAMILY "primary" (a, rowid)
  120. )
  121. statement ok
  122. SET default_int_size=8; SET experimental_serial_normalization='sql_sequence';
  123. statement ok
  124. CREATE TABLE i8_sql_sequence (a SERIAL)
  125. query TT
  126. SHOW CREATE TABLE i8_sql_sequence
  127. ----
  128. i8_sql_sequence CREATE TABLE i8_sql_sequence (
  129. a INT8 NOT NULL DEFAULT nextval('i8_sql_sequence_a_seq':::STRING),
  130. FAMILY "primary" (a, rowid)
  131. )
  132. subtest serial_virtual_sequence
  133. # Virtual sequences are a wrapper around unique_rowid(), so they will also
  134. # return an INT8 value.
  135. statement ok
  136. SET default_int_size=4; SET experimental_serial_normalization='virtual_sequence';
  137. statement ok
  138. CREATE TABLE i4_virtual_sequence (a SERIAL)
  139. query TT
  140. SHOW CREATE TABLE i4_virtual_sequence
  141. ----
  142. i4_virtual_sequence CREATE TABLE i4_virtual_sequence (
  143. a INT8 NOT NULL DEFAULT nextval('i4_virtual_sequence_a_seq':::STRING),
  144. FAMILY "primary" (a, rowid)
  145. )
  146. statement ok
  147. SET default_int_size=8; SET experimental_serial_normalization='virtual_sequence';
  148. statement ok
  149. CREATE TABLE i8_virtual_sequence (a SERIAL)
  150. query TT
  151. SHOW CREATE TABLE i8_virtual_sequence
  152. ----
  153. i8_virtual_sequence CREATE TABLE i8_virtual_sequence (
  154. a INT8 NOT NULL DEFAULT nextval('i8_virtual_sequence_a_seq':::STRING),
  155. FAMILY "primary" (a, rowid)
  156. )