~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/sql/int2.sql

  • 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
 
 
7
CREATE TABLE INT2_TBL(f1 int2);
 
8
 
 
9
INSERT INTO INT2_TBL(f1) VALUES ('0   ');
 
10
 
 
11
INSERT INTO INT2_TBL(f1) VALUES ('  1234 ');
 
12
 
 
13
INSERT INTO INT2_TBL(f1) VALUES ('    -1234');
 
14
 
 
15
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
 
16
 
 
17
-- largest and smallest values
 
18
INSERT INTO INT2_TBL(f1) VALUES ('32767');
 
19
 
 
20
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
 
21
 
 
22
-- bad input values -- should give errors
 
23
INSERT INTO INT2_TBL(f1) VALUES ('100000');
 
24
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
 
25
INSERT INTO INT2_TBL(f1) VALUES ('    ');
 
26
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
 
27
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
 
28
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
 
29
INSERT INTO INT2_TBL(f1) VALUES ('');
 
30
 
 
31
 
 
32
SELECT '' AS five, INT2_TBL.*;
 
33
 
 
34
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
 
35
 
 
36
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
 
37
 
 
38
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
 
39
 
 
40
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
 
41
 
 
42
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
 
43
 
 
44
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
 
45
 
 
46
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
 
47
 
 
48
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
 
49
 
 
50
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
 
51
 
 
52
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
 
53
 
 
54
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
 
55
 
 
56
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
 
57
 
 
58
-- positive odds 
 
59
SELECT '' AS one, i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
 
60
 
 
61
-- any evens 
 
62
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
 
63
 
 
64
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
 
65
 
 
66
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i
 
67
WHERE abs(f1) < 16384;
 
68
 
 
69
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
 
70
 
 
71
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
 
72
 
 
73
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i
 
74
WHERE f1 < 32766;
 
75
 
 
76
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
 
77
 
 
78
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
 
79
 
 
80
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i
 
81
WHERE f1 > -32767;
 
82
 
 
83
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
 
84
 
 
85
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
 
86
 
 
87
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
 
88