~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- BOX
 
3
--
 
4
--
 
5
-- box logic
 
6
--           o
 
7
-- 3      o--|X
 
8
--        |  o|
 
9
-- 2    +-+-+ |
 
10
--      | | | |
 
11
-- 1    | o-+-o
 
12
--      |   |
 
13
-- 0    +---+
 
14
--
 
15
--      0 1 2 3
 
16
--
 
17
-- boxes are specified by two points, given by four floats x1,y1,x2,y2
 
18
CREATE TABLE BOX_TBL (f1 box);
 
19
INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)');
 
20
INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)');
 
21
-- degenerate cases where the box is a line or a point
 
22
-- note that lines and points boxes all have zero area
 
23
INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
 
24
INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)');
 
25
-- badly formatted box inputs
 
26
INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
 
27
ERROR:  invalid input syntax for type box: "(2.3, 4.5)"
 
28
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
 
29
                                         ^
 
30
INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
 
31
ERROR:  invalid input syntax for type box: "asdfasdf(ad"
 
32
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
 
33
                                         ^
 
34
SELECT '' AS four, * FROM BOX_TBL;
 
35
 four |         f1          
 
36
------+---------------------
 
37
      | (2,2),(0,0)
 
38
      | (3,3),(1,1)
 
39
      | (2.5,3.5),(2.5,2.5)
 
40
      | (3,3),(3,3)
 
41
(4 rows)
 
42
 
 
43
SELECT '' AS four, b.*, area(b.f1) as barea
 
44
   FROM BOX_TBL b;
 
45
 four |         f1          | barea 
 
46
------+---------------------+-------
 
47
      | (2,2),(0,0)         |     4
 
48
      | (3,3),(1,1)         |     4
 
49
      | (2.5,3.5),(2.5,2.5) |     0
 
50
      | (3,3),(3,3)         |     0
 
51
(4 rows)
 
52
 
 
53
-- overlap
 
54
SELECT '' AS three, b.f1
 
55
   FROM BOX_TBL b
 
56
   WHERE b.f1 && box '(2.5,2.5,1.0,1.0)';
 
57
 three |         f1          
 
58
-------+---------------------
 
59
       | (2,2),(0,0)
 
60
       | (3,3),(1,1)
 
61
       | (2.5,3.5),(2.5,2.5)
 
62
(3 rows)
 
63
 
 
64
-- left-or-overlap (x only)
 
65
SELECT '' AS two, b1.*
 
66
   FROM BOX_TBL b1
 
67
   WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)';
 
68
 two |         f1          
 
69
-----+---------------------
 
70
     | (2,2),(0,0)
 
71
     | (2.5,3.5),(2.5,2.5)
 
72
(2 rows)
 
73
 
 
74
-- right-or-overlap (x only)
 
75
SELECT '' AS two, b1.*
 
76
   FROM BOX_TBL b1
 
77
   WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)';
 
78
 two |         f1          
 
79
-----+---------------------
 
80
     | (2.5,3.5),(2.5,2.5)
 
81
     | (3,3),(3,3)
 
82
(2 rows)
 
83
 
 
84
-- left of
 
85
SELECT '' AS two, b.f1
 
86
   FROM BOX_TBL b
 
87
   WHERE b.f1 << box '(3.0,3.0,5.0,5.0)';
 
88
 two |         f1          
 
89
-----+---------------------
 
90
     | (2,2),(0,0)
 
91
     | (2.5,3.5),(2.5,2.5)
 
92
(2 rows)
 
93
 
 
94
-- area <=
 
95
SELECT '' AS four, b.f1
 
96
   FROM BOX_TBL b
 
97
   WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)';
 
98
 four |         f1          
 
99
------+---------------------
 
100
      | (2,2),(0,0)
 
101
      | (3,3),(1,1)
 
102
      | (2.5,3.5),(2.5,2.5)
 
103
      | (3,3),(3,3)
 
104
(4 rows)
 
105
 
 
106
-- area <
 
107
SELECT '' AS two, b.f1
 
108
   FROM BOX_TBL b
 
109
   WHERE b.f1 < box '(3.0,3.0,5.0,5.0)';
 
110
 two |         f1          
 
111
-----+---------------------
 
112
     | (2.5,3.5),(2.5,2.5)
 
113
     | (3,3),(3,3)
 
114
(2 rows)
 
115
 
 
116
-- area =
 
117
SELECT '' AS two, b.f1
 
118
   FROM BOX_TBL b
 
119
   WHERE b.f1 = box '(3.0,3.0,5.0,5.0)';
 
120
 two |     f1      
 
121
-----+-------------
 
122
     | (2,2),(0,0)
 
123
     | (3,3),(1,1)
 
124
(2 rows)
 
125
 
 
126
-- area >
 
127
SELECT '' AS two, b.f1
 
128
   FROM BOX_TBL b                               -- zero area
 
129
   WHERE b.f1 > box '(3.5,3.0,4.5,3.0)';
 
130
 two |     f1      
 
131
-----+-------------
 
132
     | (2,2),(0,0)
 
133
     | (3,3),(1,1)
 
134
(2 rows)
 
135
 
 
136
-- area >=
 
137
SELECT '' AS four, b.f1
 
138
   FROM BOX_TBL b                               -- zero area
 
139
   WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)';
 
140
 four |         f1          
 
141
------+---------------------
 
142
      | (2,2),(0,0)
 
143
      | (3,3),(1,1)
 
144
      | (2.5,3.5),(2.5,2.5)
 
145
      | (3,3),(3,3)
 
146
(4 rows)
 
147
 
 
148
-- right of
 
149
SELECT '' AS two, b.f1
 
150
   FROM BOX_TBL b
 
151
   WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1;
 
152
 two |         f1          
 
153
-----+---------------------
 
154
     | (2,2),(0,0)
 
155
     | (2.5,3.5),(2.5,2.5)
 
156
(2 rows)
 
157
 
 
158
-- contained in
 
159
SELECT '' AS three, b.f1
 
160
   FROM BOX_TBL b
 
161
   WHERE b.f1 <@ box '(0,0,3,3)';
 
162
 three |     f1      
 
163
-------+-------------
 
164
       | (2,2),(0,0)
 
165
       | (3,3),(1,1)
 
166
       | (3,3),(3,3)
 
167
(3 rows)
 
168
 
 
169
-- contains
 
170
SELECT '' AS three, b.f1
 
171
   FROM BOX_TBL b
 
172
   WHERE box '(0,0,3,3)' @> b.f1;
 
173
 three |     f1      
 
174
-------+-------------
 
175
       | (2,2),(0,0)
 
176
       | (3,3),(1,1)
 
177
       | (3,3),(3,3)
 
178
(3 rows)
 
179
 
 
180
-- box equality
 
181
SELECT '' AS one, b.f1
 
182
   FROM BOX_TBL b
 
183
   WHERE box '(1,1,3,3)' ~= b.f1;
 
184
 one |     f1      
 
185
-----+-------------
 
186
     | (3,3),(1,1)
 
187
(1 row)
 
188
 
 
189
-- center of box, left unary operator
 
190
SELECT '' AS four, @@(b1.f1) AS p
 
191
   FROM BOX_TBL b1;
 
192
 four |    p    
 
193
------+---------
 
194
      | (1,1)
 
195
      | (2,2)
 
196
      | (2.5,3)
 
197
      | (3,3)
 
198
(4 rows)
 
199
 
 
200
-- wholly-contained
 
201
SELECT '' AS one, b1.*, b2.*
 
202
   FROM BOX_TBL b1, BOX_TBL b2
 
203
   WHERE b1.f1 @> b2.f1 and not b1.f1 ~= b2.f1;
 
204
 one |     f1      |     f1      
 
205
-----+-------------+-------------
 
206
     | (3,3),(1,1) | (3,3),(3,3)
 
207
(1 row)
 
208
 
 
209
SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL;
 
210
 four | height | width 
 
211
------+--------+-------
 
212
      |      2 |     2
 
213
      |      2 |     2
 
214
      |      1 |     0
 
215
      |      0 |     0
 
216
(4 rows)
 
217