4 CREATE TABLE FLOAT4_TBL (f1 float4);
5 INSERT INTO FLOAT4_TBL(f1) VALUES (' 0.0');
6 INSERT INTO FLOAT4_TBL(f1) VALUES ('1004.30 ');
7 INSERT INTO FLOAT4_TBL(f1) VALUES (' -34.84 ');
8 INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e+20');
9 INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20');
10 -- test for over and under flow
11 INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70');
12 ERROR: value out of range: overflow
13 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70');
15 INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70');
16 ERROR: value out of range: overflow
17 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70');
19 INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70');
20 ERROR: value out of range: underflow
21 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70');
23 INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
24 ERROR: value out of range: underflow
25 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70');
28 INSERT INTO FLOAT4_TBL(f1) VALUES ('');
29 ERROR: invalid input syntax for type real: ""
30 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('');
32 INSERT INTO FLOAT4_TBL(f1) VALUES (' ');
33 ERROR: invalid input syntax for type real: " "
34 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES (' ');
36 INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz');
37 ERROR: invalid input syntax for type real: "xyz"
38 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz');
40 INSERT INTO FLOAT4_TBL(f1) VALUES ('5.0.0');
41 ERROR: invalid input syntax for type real: "5.0.0"
42 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('5.0.0');
44 INSERT INTO FLOAT4_TBL(f1) VALUES ('5 . 0');
45 ERROR: invalid input syntax for type real: "5 . 0"
46 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('5 . 0');
48 INSERT INTO FLOAT4_TBL(f1) VALUES ('5. 0');
49 ERROR: invalid input syntax for type real: "5. 0"
50 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('5. 0');
52 INSERT INTO FLOAT4_TBL(f1) VALUES (' - 3.0');
53 ERROR: invalid input syntax for type real: " - 3.0"
54 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES (' - 3.0');
56 INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5');
57 ERROR: invalid input syntax for type real: "123 5"
58 LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5');
73 SELECT ' NAN '::float4;
79 SELECT 'infinity'::float4;
85 SELECT ' -INFINiTY '::float4;
92 SELECT 'N A N'::float4;
93 ERROR: invalid input syntax for type real: "N A N"
94 LINE 1: SELECT 'N A N'::float4;
96 SELECT 'NaN x'::float4;
97 ERROR: invalid input syntax for type real: "NaN x"
98 LINE 1: SELECT 'NaN x'::float4;
100 SELECT ' INFINITY x'::float4;
101 ERROR: invalid input syntax for type real: " INFINITY x"
102 LINE 1: SELECT ' INFINITY x'::float4;
104 SELECT 'Infinity'::float4 + 100.0;
110 SELECT 'Infinity'::float4 / 'Infinity'::float4;
116 SELECT 'nan'::float4 / 'nan'::float4;
122 SELECT '' AS five, * FROM FLOAT4_TBL;
132 SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
141 SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
147 SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
149 -------+-------------
155 SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
157 -------+-------------
163 SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
172 SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
181 SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
184 -------+-------------+--------------
186 | 1.23457e+20 | -1.23457e+21
187 | 1.23457e-20 | -1.23457e-19
190 SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
193 -------+-------------+-------------
195 | 1.23457e+20 | 1.23457e+20
199 SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
202 -------+-------------+--------------
204 | 1.23457e+20 | -1.23457e+19
205 | 1.23457e-20 | -1.23457e-21
208 SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
211 -------+-------------+-------------
213 | 1.23457e+20 | 1.23457e+20
217 -- test divide by zero
218 SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
219 ERROR: division by zero
220 SELECT '' AS five, * FROM FLOAT4_TBL;
230 -- test the unary float4abs operator
231 SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
233 ------+-------------+-------------
237 | 1.23457e+20 | 1.23457e+20
238 | 1.23457e-20 | 1.23457e-20
242 SET f1 = FLOAT4_TBL.f1 * '-1'
243 WHERE FLOAT4_TBL.f1 > '0.0';
244 SELECT '' AS five, * FROM FLOAT4_TBL;
246 ------+--------------