forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathint_size.slt
199 lines (156 loc) · 4.54 KB
/
int_size.slt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
#
# This file is derived from the logic test suite in CockroachDB. The
# original file was retrieved on June 10, 2019 from:
#
# https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/int_size
#
# The original source code is subject to the terms of the Apache
# 2.0 license, a copy of which can be found in the LICENSE file at the
# root of this repository.
# not supported yet
halt
mode cockroach
subtest defaults
query T
SHOW default_int_size
----
8
subtest set_int4
statement ok
SET default_int_size=4
query T
SHOW default_int_size
----
4
statement ok
CREATE TABLE i4 (i4 INT)
query TT
SHOW CREATE TABLE i4
----
i4 CREATE TABLE i4 (
i4 INT4 NULL,
FAMILY "primary" (i4, rowid)
)
subtest set_int8
statement ok
SET default_int_size=8
query T
SHOW default_int_size
----
8
statement ok
CREATE TABLE i8 (i8 INT)
query TT
SHOW CREATE TABLE i8
----
i8 CREATE TABLE i8 (
i8 INT8 NULL,
FAMILY "primary" (i8, rowid)
)
# https://github.com/cockroachdb/cockroach/issues/32846
subtest issue_32846
statement ok
SET default_int_size=8
# Parsing and evaluation are async, so the setting won't take
# effect until the next statement is evaluated.
statement ok
SET default_int_size=4; CREATE TABLE late4 (a INT)
query TT
SHOW CREATE TABLE late4
----
late4 CREATE TABLE late4 (
a INT8 NULL,
FAMILY "primary" (a, rowid)
)
query T
SHOW default_int_size
----
4
subtest set_bad_value
statement error pq: only 4 or 8 are supported by default_int_size
SET default_int_size=2
# We want to check the combinations of default_int_size and
# experimental_serialization_normalization.
subtest serial_rowid
# When using rowid, we should always see INT8, since that's the
# return type of unique_rowid()
statement ok
SET default_int_size=4; SET experimental_serial_normalization='rowid';
statement ok
CREATE TABLE i4_rowid (a SERIAL)
query TT
SHOW CREATE TABLE i4_rowid
----
i4_rowid CREATE TABLE i4_rowid (
a INT8 NOT NULL DEFAULT unique_rowid(),
FAMILY "primary" (a, rowid)
)
statement ok
SET default_int_size=8; SET experimental_serial_normalization='rowid';
statement ok
CREATE TABLE i8_rowid (a SERIAL)
query TT
SHOW CREATE TABLE i8_rowid
----
i8_rowid CREATE TABLE i8_rowid (
a INT8 NOT NULL DEFAULT unique_rowid(),
FAMILY "primary" (a, rowid)
)
subtest serial_sql_sequence
# When using rowid, we should see an INTx that matches the current size setting.
statement ok
SET default_int_size=4; SET experimental_serial_normalization='sql_sequence';
statement ok
CREATE TABLE i4_sql_sequence (a SERIAL)
query TT
SHOW CREATE TABLE i4_sql_sequence
----
i4_sql_sequence CREATE TABLE i4_sql_sequence (
a INT4 NOT NULL DEFAULT nextval('i4_sql_sequence_a_seq':::STRING),
FAMILY "primary" (a, rowid)
)
statement ok
SET default_int_size=8; SET experimental_serial_normalization='sql_sequence';
statement ok
CREATE TABLE i8_sql_sequence (a SERIAL)
query TT
SHOW CREATE TABLE i8_sql_sequence
----
i8_sql_sequence CREATE TABLE i8_sql_sequence (
a INT8 NOT NULL DEFAULT nextval('i8_sql_sequence_a_seq':::STRING),
FAMILY "primary" (a, rowid)
)
subtest serial_virtual_sequence
# Virtual sequences are a wrapper around unique_rowid(), so they will also
# return an INT8 value.
statement ok
SET default_int_size=4; SET experimental_serial_normalization='virtual_sequence';
statement ok
CREATE TABLE i4_virtual_sequence (a SERIAL)
query TT
SHOW CREATE TABLE i4_virtual_sequence
----
i4_virtual_sequence CREATE TABLE i4_virtual_sequence (
a INT8 NOT NULL DEFAULT nextval('i4_virtual_sequence_a_seq':::STRING),
FAMILY "primary" (a, rowid)
)
statement ok
SET default_int_size=8; SET experimental_serial_normalization='virtual_sequence';
statement ok
CREATE TABLE i8_virtual_sequence (a SERIAL)
query TT
SHOW CREATE TABLE i8_virtual_sequence
----
i8_virtual_sequence CREATE TABLE i8_virtual_sequence (
a INT8 NOT NULL DEFAULT nextval('i8_virtual_sequence_a_seq':::STRING),
FAMILY "primary" (a, rowid)
)