-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
scale
176 lines (125 loc) · 3.42 KB
/
scale
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
# LogicTest: default parallel-stmts distsql
statement ok
CREATE TABLE test (
t CHAR(4),
UNIQUE INDEX a (t)
)
statement ok
INSERT INTO test VALUES ('a')
statement ok
INSERT INTO test VALUES ('ab')
statement ok
INSERT INTO test VALUES ('abcd')
statement error value too long for type STRING\(4\) \(column "t"\)
INSERT INTO test VALUES ('abcdef')
statement ok
INSERT INTO test VALUES ('áááá')
statement error value too long
INSERT INTO test VALUES ('ááááß')
statement ok
UPDATE test SET t = 'b' WHERE t = 'abcde'
statement error value too long
UPDATE test SET t = 'cdefg' WHERE t = 'ab'
statement ok
CREATE TABLE tb (
b BIT(3),
UNIQUE INDEX a (b)
)
statement ok
INSERT INTO tb VALUES (1)
statement ok
INSERT INTO tb VALUES (3)
statement ok
INSERT INTO tb VALUES (7)
statement error integer out of range for type BIT \(column "b"\)
INSERT INTO tb VALUES (15)
statement ok
UPDATE tb SET b = 2 WHERE b = 7
statement error integer out of range for type BIT \(column "b"\)
UPDATE tb SET b = 16 WHERE b = 2
statement ok
CREATE TABLE tc (
b INT2,
UNIQUE INDEX a (b)
)
statement ok
INSERT INTO tc VALUES (50)
statement ok
INSERT INTO tc VALUES (-32768)
statement ok
INSERT INTO tc VALUES (32767)
statement error integer out of range for type INT2 \(column "b"\)
INSERT INTO tc VALUES (-32769)
statement error integer out of range for type INT2 \(column "b"\)
INSERT INTO tc VALUES (32768)
statement ok
UPDATE tc SET b = 80 WHERE b = 50
statement error integer out of range for type INT2 \(column "b"\)
UPDATE tc SET b = 32768 WHERE b = 32767
statement ok
CREATE TABLE tc1 (
b INT4,
UNIQUE INDEX a (b)
)
statement ok
INSERT INTO tc1 VALUES (50)
statement ok
INSERT INTO tc1 VALUES (-2147483648)
statement ok
INSERT INTO tc1 VALUES (2147483647)
statement error integer out of range for type INT4 \(column "b"\)
INSERT INTO tc1 VALUES (-2147483649)
statement error integer out of range for type INT4 \(column "b"\)
INSERT INTO tc1 VALUES (2147483648)
statement ok
UPDATE tc1 SET b = 80 WHERE b = 50
statement error integer out of range for type INT4 \(column "b"\)
UPDATE tc1 SET b = 2147483648 WHERE b = 2147483647
statement ok
CREATE TABLE td (
d DECIMAL(3, 2),
UNIQUE INDEX b (d)
)
statement ok
INSERT INTO td VALUES (DECIMAL '3.1')
statement ok
INSERT INTO td VALUES (DECIMAL '3.14')
statement error duplicate
INSERT INTO td VALUES (DECIMAL '3.1415')
statement error type DECIMAL\(3,2\) \(column "d"\): value with precision 3, scale 2 must round to an absolute value less than 10\^1
INSERT INTO td VALUES (DECIMAL '13.1415')
query R rowsort
SELECT d FROM td
----
3.10
3.14
statement error must round
UPDATE td SET d = DECIMAL '101.414' WHERE d = DECIMAL '3.14'
statement ok
UPDATE td SET d = DECIMAL '1.414' WHERE d = DECIMAL '3.14'
statement error duplicate
UPDATE td SET d = DECIMAL '1.41' WHERE d = DECIMAL '3.1'
query R rowsort
SELECT d FROM td
----
3.10
1.41
statement ok
CREATE TABLE td2 (x DECIMAL(3), y DECIMAL)
statement ok
INSERT INTO td2 VALUES (DECIMAL '123.1415', DECIMAL '123.1415')
query RR
select x, y FROM td2
----
123 123.1415
# Ensure decimal columns greater than 16 precision are supported.
statement ok
CREATE TABLE td3 (a decimal, b decimal(3, 1), c decimal(20, 10))
statement ok
INSERT INTO td3 VALUES (123456789012.123456789012, 12.3, 1234567890.1234567890)
query RRR
select * from td3
----
123456789012.123456789012 12.3 1234567890.1234567890
statement error must round
INSERT INTO td3 (c) VALUES (12345678901)