~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/int2.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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:  invalid input syntax for integer: "34.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 errors
 
16
INSERT INTO INT2_TBL(f1) VALUES ('100000');
 
17
ERROR:  value "100000" is out of range for type smallint
 
18
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
 
19
ERROR:  invalid input syntax for integer: "asdf"
 
20
INSERT INTO INT2_TBL(f1) VALUES ('    ');
 
21
ERROR:  invalid input syntax for integer: "    "
 
22
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
 
23
ERROR:  invalid input syntax for integer: "- 1234"
 
24
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
 
25
ERROR:  invalid input syntax for integer: "4 444"
 
26
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
 
27
ERROR:  invalid input syntax for integer: "123 dt"
 
28
INSERT INTO INT2_TBL(f1) VALUES ('');
 
29
ERROR:  invalid input syntax for integer: ""
 
30
SELECT '' AS five, INT2_TBL.*;
 
31
 five |   f1   
 
32
------+--------
 
33
      |      0
 
34
      |   1234
 
35
      |  -1234
 
36
      |  32767
 
37
      | -32767
 
38
(5 rows)
 
39
 
 
40
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
 
41
 four |   f1   
 
42
------+--------
 
43
      |   1234
 
44
      |  -1234
 
45
      |  32767
 
46
      | -32767
 
47
(4 rows)
 
48
 
 
49
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
 
50
 four |   f1   
 
51
------+--------
 
52
      |   1234
 
53
      |  -1234
 
54
      |  32767
 
55
      | -32767
 
56
(4 rows)
 
57
 
 
58
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
 
59
 one | f1 
 
60
-----+----
 
61
     |  0
 
62
(1 row)
 
63
 
 
64
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
 
65
 one | f1 
 
66
-----+----
 
67
     |  0
 
68
(1 row)
 
69
 
 
70
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
 
71
 two |   f1   
 
72
-----+--------
 
73
     |  -1234
 
74
     | -32767
 
75
(2 rows)
 
76
 
 
77
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
 
78
 two |   f1   
 
79
-----+--------
 
80
     |  -1234
 
81
     | -32767
 
82
(2 rows)
 
83
 
 
84
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
 
85
 three |   f1   
 
86
-------+--------
 
87
       |      0
 
88
       |  -1234
 
89
       | -32767
 
90
(3 rows)
 
91
 
 
92
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
 
93
 three |   f1   
 
94
-------+--------
 
95
       |      0
 
96
       |  -1234
 
97
       | -32767
 
98
(3 rows)
 
99
 
 
100
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
 
101
 two |  f1   
 
102
-----+-------
 
103
     |  1234
 
104
     | 32767
 
105
(2 rows)
 
106
 
 
107
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
 
108
 two |  f1   
 
109
-----+-------
 
110
     |  1234
 
111
     | 32767
 
112
(2 rows)
 
113
 
 
114
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
 
115
 three |  f1   
 
116
-------+-------
 
117
       |     0
 
118
       |  1234
 
119
       | 32767
 
120
(3 rows)
 
121
 
 
122
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
 
123
 three |  f1   
 
124
-------+-------
 
125
       |     0
 
126
       |  1234
 
127
       | 32767
 
128
(3 rows)
 
129
 
 
130
-- positive odds 
 
131
SELECT '' AS one, i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
 
132
 one |  f1   
 
133
-----+-------
 
134
     | 32767
 
135
(1 row)
 
136
 
 
137
-- any evens 
 
138
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
 
139
 three |  f1   
 
140
-------+-------
 
141
       |     0
 
142
       |  1234
 
143
       | -1234
 
144
(3 rows)
 
145
 
 
146
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
 
147
ERROR:  smallint out of range
 
148
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i
 
149
WHERE abs(f1) < 16384;
 
150
 five |  f1   |   x   
 
151
------+-------+-------
 
152
      |     0 |     0
 
153
      |  1234 |  2468
 
154
      | -1234 | -2468
 
155
(3 rows)
 
156
 
 
157
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
 
158
 five |   f1   |   x    
 
159
------+--------+--------
 
160
      |      0 |      0
 
161
      |   1234 |   2468
 
162
      |  -1234 |  -2468
 
163
      |  32767 |  65534
 
164
      | -32767 | -65534
 
165
(5 rows)
 
166
 
 
167
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
 
168
ERROR:  smallint out of range
 
169
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i
 
170
WHERE f1 < 32766;
 
171
 five |   f1   |   x    
 
172
------+--------+--------
 
173
      |      0 |      2
 
174
      |   1234 |   1236
 
175
      |  -1234 |  -1232
 
176
      | -32767 | -32765
 
177
(4 rows)
 
178
 
 
179
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
 
180
 five |   f1   |   x    
 
181
------+--------+--------
 
182
      |      0 |      2
 
183
      |   1234 |   1236
 
184
      |  -1234 |  -1232
 
185
      |  32767 |  32769
 
186
      | -32767 | -32765
 
187
(5 rows)
 
188
 
 
189
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
 
190
ERROR:  smallint out of range
 
191
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i
 
192
WHERE f1 > -32767;
 
193
 five |  f1   |   x   
 
194
------+-------+-------
 
195
      |     0 |    -2
 
196
      |  1234 |  1232
 
197
      | -1234 | -1236
 
198
      | 32767 | 32765
 
199
(4 rows)
 
200
 
 
201
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
 
202
 five |   f1   |   x    
 
203
------+--------+--------
 
204
      |      0 |     -2
 
205
      |   1234 |   1232
 
206
      |  -1234 |  -1236
 
207
      |  32767 |  32765
 
208
      | -32767 | -32769
 
209
(5 rows)
 
210
 
 
211
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
 
212
 five |   f1   |   x    
 
213
------+--------+--------
 
214
      |      0 |      0
 
215
      |   1234 |    617
 
216
      |  -1234 |   -617
 
217
      |  32767 |  16383
 
218
      | -32767 | -16383
 
219
(5 rows)
 
220
 
 
221
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
 
222
 five |   f1   |   x    
 
223
------+--------+--------
 
224
      |      0 |      0
 
225
      |   1234 |    617
 
226
      |  -1234 |   -617
 
227
      |  32767 |  16383
 
228
      | -32767 | -16383
 
229
(5 rows)
 
230