Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ba0506

Browse files
committed
First examples of multiplatform result comparison files.
1 parent62cbd53 commit8ba0506

File tree

2 files changed

+530
-0
lines changed

2 files changed

+530
-0
lines changed
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
--
2+
-- INT2
3+
-- NOTE: int2 operators never check for over/underflow!
4+
-- Some of these answers are consequently numerically incorrect.
5+
--
6+
CREATE TABLE INT2_TBL(f1 int2);
7+
INSERT INTO INT2_TBL(f1) VALUES ('0');
8+
INSERT INTO INT2_TBL(f1) VALUES ('1234');
9+
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
10+
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
11+
ERROR: pg_atoi: error in "34.5": can't parse ".5"
12+
-- largest and smallest values
13+
INSERT INTO INT2_TBL(f1) VALUES ('32767');
14+
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
15+
-- bad input values -- should give warnings
16+
INSERT INTO INT2_TBL(f1) VALUES ('100000');
17+
ERROR: pg_atoi: error reading "100000": Result too large
18+
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
19+
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
20+
SELECT '' AS five, INT2_TBL.*;
21+
five | f1
22+
------+--------
23+
| 0
24+
| 1234
25+
| -1234
26+
| 32767
27+
| -32767
28+
(5 rows)
29+
30+
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
31+
four | f1
32+
------+--------
33+
| 1234
34+
| -1234
35+
| 32767
36+
| -32767
37+
(4 rows)
38+
39+
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
40+
four | f1
41+
------+--------
42+
| 1234
43+
| -1234
44+
| 32767
45+
| -32767
46+
(4 rows)
47+
48+
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
49+
one | f1
50+
-----+----
51+
| 0
52+
(1 row)
53+
54+
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
55+
one | f1
56+
-----+----
57+
| 0
58+
(1 row)
59+
60+
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
61+
two | f1
62+
-----+--------
63+
| -1234
64+
| -32767
65+
(2 rows)
66+
67+
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
68+
two | f1
69+
-----+--------
70+
| -1234
71+
| -32767
72+
(2 rows)
73+
74+
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
75+
three | f1
76+
-------+--------
77+
| 0
78+
| -1234
79+
| -32767
80+
(3 rows)
81+
82+
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
83+
three | f1
84+
-------+--------
85+
| 0
86+
| -1234
87+
| -32767
88+
(3 rows)
89+
90+
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
91+
two | f1
92+
-----+-------
93+
| 1234
94+
| 32767
95+
(2 rows)
96+
97+
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
98+
two | f1
99+
-----+-------
100+
| 1234
101+
| 32767
102+
(2 rows)
103+
104+
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
105+
three | f1
106+
-------+-------
107+
| 0
108+
| 1234
109+
| 32767
110+
(3 rows)
111+
112+
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
113+
three | f1
114+
-------+-------
115+
| 0
116+
| 1234
117+
| 32767
118+
(3 rows)
119+
120+
-- positive odds
121+
SELECT '' AS one, i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
122+
one | f1
123+
-----+-------
124+
| 32767
125+
(1 row)
126+
127+
-- any evens
128+
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
129+
three | f1
130+
-------+-------
131+
| 0
132+
| 1234
133+
| -1234
134+
(3 rows)
135+
136+
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
137+
five | f1 | x
138+
------+--------+-------
139+
| 0 | 0
140+
| 1234 | 2468
141+
| -1234 | -2468
142+
| 32767 | -2
143+
| -32767 | 2
144+
(5 rows)
145+
146+
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
147+
five | f1 | x
148+
------+--------+--------
149+
| 0 | 0
150+
| 1234 | 2468
151+
| -1234 | -2468
152+
| 32767 | 65534
153+
| -32767 | -65534
154+
(5 rows)
155+
156+
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
157+
five | f1 | x
158+
------+--------+--------
159+
| 0 | 2
160+
| 1234 | 1236
161+
| -1234 | -1232
162+
| 32767 | -32767
163+
| -32767 | -32765
164+
(5 rows)
165+
166+
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
167+
five | f1 | x
168+
------+--------+--------
169+
| 0 | 2
170+
| 1234 | 1236
171+
| -1234 | -1232
172+
| 32767 | 32769
173+
| -32767 | -32765
174+
(5 rows)
175+
176+
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
177+
five | f1 | x
178+
------+--------+-------
179+
| 0 | -2
180+
| 1234 | 1232
181+
| -1234 | -1236
182+
| 32767 | 32765
183+
| -32767 | 32767
184+
(5 rows)
185+
186+
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
187+
five | f1 | x
188+
------+--------+--------
189+
| 0 | -2
190+
| 1234 | 1232
191+
| -1234 | -1236
192+
| 32767 | 32765
193+
| -32767 | -32769
194+
(5 rows)
195+
196+
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
197+
five | f1 | x
198+
------+--------+--------
199+
| 0 | 0
200+
| 1234 | 617
201+
| -1234 | -617
202+
| 32767 | 16383
203+
| -32767 | -16383
204+
(5 rows)
205+
206+
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
207+
five | f1 | x
208+
------+--------+--------
209+
| 0 | 0
210+
| 1234 | 617
211+
| -1234 | -617
212+
| 32767 | 16383
213+
| -32767 | -16383
214+
(5 rows)
215+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp