blob: 060a0fbcb89c0b0a4afdcaf61733f99da5f02ef3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
---------------------------------------------------------------------------
--
-- float.sql-
-- test float4, float8 adt
--
--
-- Copyright (c) 1994-5, Regents of the University of California
--
-- $Id: float.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
--
---------------------------------------------------------------------------
--
-- float4
--
create table fl (x float4);
insert into fl values ( 3.14 );
insert into fl values ( 147.0 );
insert into fl values ( 3.14 );
insert into fl values ( -3.14 );
select * from fl;
-- float literals
select * from fl where x = 3.14;
select * from fl where x <> 3.14;
select * from fl where x < 3.14;
select * from fl where x <= 3.14;
select * from fl where x > 3.14;
select * from fl where x >= 3.14;
-- adt constant without cast (test coercion)
select * from fl where x = '3.14';
select * from fl where x <> '3.14';
select * from fl where x < '3.14';
select * from fl where x <= '3.14';
select * from fl where x > '3.14';
select * from fl where x >= '3.14';
-- adt constant with float4 cast (test float4 opers)
select * from fl where x = '3.14'::float4;
select * from fl where x <> '3.14'::float4;
select * from fl where x < '3.14'::float4;
select * from fl where x <= '3.14'::float4;
select * from fl where x > '3.14'::float4;
select * from fl where x >= '3.14'::float4;
-- adt constant with float8 cast (test float48 opers)
select * from fl where x = '3.14'::float8;
select * from fl where x <> '3.14'::float8;
select * from fl where x < '3.14'::float8;
select * from fl where x <= '3.14'::float8;
select * from fl where x > '3.14'::float8;
select * from fl where x >= '3.14'::float8;
-- try other operators
update fl set x = x + 2.2;
select * from fl;
update fl set x = x - 2.2;
select * from fl;
update fl set x = x * 2.2;
select * from fl;
update fl set x = x / 2.2;
select * from fl;
--
-- float8
--
create table fl8 (y float8);
insert into fl8 values ( '3.14'::float8 );
insert into fl8 values ( '147.0'::float8 );
insert into fl8 values ( '3.140000001'::float8 );
insert into fl8 values ( '-3.14'::float8);
select * from fl8;
-- float literals
select * from fl8 where y = 3.14;
select * from fl8 where y <> 3.14;
select * from fl8 where y < 3.14;
select * from fl8 where y <= 3.14;
select * from fl8 where y > 3.14;
select * from fl8 where y >= 3.14;
-- adt constant without cast (test coercion)
select * from fl8 where y = '3.14';
select * from fl8 where y <> '3.14';
select * from fl8 where y < '3.14';
select * from fl8 where y <= '3.14';
select * from fl8 where y > '3.14';
select * from fl8 where y >= '3.14';
-- adt constant with float4 cast (test float84 opers)
select * from fl8 where y = '3.14'::float4;
select * from fl8 where y <> '3.14'::float4;
select * from fl8 where y < '3.14'::float4;
select * from fl8 where y <= '3.14'::float4;
select * from fl8 where y > '3.14'::float4;
select * from fl8 where y >= '3.14'::float4;
-- adt constant with float8 cast (test float8 opers)
select * from fl8 where y = '3.14'::float8;
select * from fl8 where y <> '3.14'::float8;
select * from fl8 where y < '3.14'::float8;
select * from fl8 where y <= '3.14'::float8;
select * from fl8 where y > '3.14'::float8;
select * from fl8 where y >= '3.14'::float8;
-- try other operators
update fl8 set y = y + '2.2'::float8;
select * from fl8;
update fl8 set y = y - '2.2'::float8;
select * from fl8;
update fl8 set y = y * '2.2'::float8;
select * from fl8;
update fl8 set y = y / '2.2'::float8;
select * from fl8;
-- drop tables
drop table fl;
drop table fl8;
|