3 -- Test various combinations of numeric types and functions.
6 -- Test implicit type conversions
7 -- This fails for Postgres v6.1 (and earlier?)
8 -- so let's try explicit conversions for now - tgl 97/05/07
10 CREATE TABLE TEMP_FLOAT (f1 FLOAT8);
11 INSERT INTO TEMP_FLOAT (f1)
12 SELECT float8(f1) FROM INT4_TBL;
13 INSERT INTO TEMP_FLOAT (f1)
14 SELECT float8(f1) FROM INT2_TBL;
15 SELECT '' AS ten, f1 FROM TEMP_FLOAT
32 CREATE TABLE TEMP_INT4 (f1 INT4);
33 INSERT INTO TEMP_INT4 (f1)
34 SELECT int4(f1) FROM FLOAT8_TBL
35 WHERE (f1 > -2147483647) AND (f1 < 2147483647);
36 INSERT INTO TEMP_INT4 (f1)
37 SELECT int4(f1) FROM INT2_TBL;
38 SELECT '' AS nine, f1 FROM TEMP_INT4
54 CREATE TABLE TEMP_INT2 (f1 INT2);
55 INSERT INTO TEMP_INT2 (f1)
56 SELECT int2(f1) FROM FLOAT8_TBL
57 WHERE (f1 >= -32767) AND (f1 <= 32767);
58 INSERT INTO TEMP_INT2 (f1)
59 SELECT int2(f1) FROM INT4_TBL
60 WHERE (f1 >= -32767) AND (f1 <= 32767);
61 SELECT '' AS five, f1 FROM TEMP_INT2
73 -- Group-by combinations
75 CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8);
76 INSERT INTO TEMP_GROUP
77 SELECT 1, (- i.f1), (- f.f1)
78 FROM INT4_TBL i, FLOAT8_TBL f;
79 INSERT INTO TEMP_GROUP
81 FROM INT4_TBL i, FLOAT8_TBL f;
82 SELECT DISTINCT f1 AS two FROM TEMP_GROUP ORDER BY 1;
89 SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float
92 ORDER BY two, max_float, min_float;
93 two | max_float | min_float
94 -----+----------------------+-----------------------
95 1 | 1.2345678901234e+200 | 0
96 2 | 0 | -1.2345678901234e+200
99 -- GROUP BY a result column name is not legal per SQL92, but we accept it
100 -- anyway (if the name is not the name of any column exposed by FROM).
101 SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float
104 ORDER BY two, max_float, min_float;
105 two | max_float | min_float
106 -----+----------------------+-----------------------
107 1 | 1.2345678901234e+200 | 0
108 2 | 0 | -1.2345678901234e+200
111 SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
114 ORDER BY two, min_minus_1;
115 two | max_plus_1 | min_minus_1
116 -----+----------------------+-----------------------
117 1 | 1.2345678901234e+200 | -1
118 2 | 1 | -1.2345678901234e+200
122 max(f2) + min(f2) AS max_plus_min,
123 min(f3) - 1 AS min_minus_1
126 ORDER BY two, min_minus_1;
127 two | max_plus_min | min_minus_1
128 -----+--------------+-----------------------
130 2 | 0 | -1.2345678901234e+200
133 DROP TABLE TEMP_INT2;
134 DROP TABLE TEMP_INT4;
135 DROP TABLE TEMP_FLOAT;
136 DROP TABLE TEMP_GROUP;