4 CREATE TABLE POINT_TBL(f1 point);
5 INSERT INTO POINT_TBL(f1) VALUES ('(0.0,0.0)');
6 INSERT INTO POINT_TBL(f1) VALUES ('(-10.0,0.0)');
7 INSERT INTO POINT_TBL(f1) VALUES ('(-3.0,4.0)');
8 INSERT INTO POINT_TBL(f1) VALUES ('(5.1, 34.5)');
9 INSERT INTO POINT_TBL(f1) VALUES ('(-5.0,-12.0)');
11 INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf');
12 ERROR: invalid input syntax for type point: "asdfasdf"
13 LINE 1: INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf');
15 INSERT INTO POINT_TBL(f1) VALUES ('10.0,10.0');
16 INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)');
17 ERROR: invalid input syntax for type point: "(10.0 10.0)"
18 LINE 1: INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)');
20 INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0');
21 ERROR: invalid input syntax for type point: "(10.0,10.0"
22 LINE 1: INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0');
24 SELECT '' AS six, * FROM POINT_TBL;
36 SELECT '' AS three, p.* FROM POINT_TBL p WHERE p.f1 << '(0.0, 0.0)';
45 SELECT '' AS three, p.* FROM POINT_TBL p WHERE '(0.0,0.0)' >> p.f1;
54 SELECT '' AS one, p.* FROM POINT_TBL p WHERE '(0.0,0.0)' >^ p.f1;
61 SELECT '' AS one, p.* FROM POINT_TBL p WHERE p.f1 <^ '(0.0, 0.0)';
68 SELECT '' AS one, p.* FROM POINT_TBL p WHERE p.f1 ~= '(5.1, 34.5)';
75 SELECT '' AS three, p.* FROM POINT_TBL p
76 WHERE p.f1 <@ box '(0,0,100,100)';
84 SELECT '' AS three, p.* FROM POINT_TBL p
85 WHERE not p.f1 <@ box '(0,0,100,100)';
93 SELECT '' AS two, p.* FROM POINT_TBL p
94 WHERE p.f1 <@ path '[(0,0),(-10,0),(-10,10)]';
101 SELECT '' AS six, p.f1, p.f1 <-> point '(0,0)' AS dist
105 -----+------------+------------------
110 | (10,10) | 14.142135623731
111 | (5.1,34.5) | 34.8749193547455
114 SELECT '' AS thirtysix, p1.f1 AS point1, p2.f1 AS point2, p1.f1 <-> p2.f1 AS dist
115 FROM POINT_TBL p1, POINT_TBL p2
116 ORDER BY dist, p1.f1[0], p2.f1[0];
117 thirtysix | point1 | point2 | dist
118 -----------+------------+------------+------------------
119 | (-10,0) | (-10,0) | 0
120 | (-5,-12) | (-5,-12) | 0
121 | (-3,4) | (-3,4) | 0
123 | (5.1,34.5) | (5.1,34.5) | 0
124 | (10,10) | (10,10) | 0
127 | (-10,0) | (-3,4) | 8.06225774829855
128 | (-3,4) | (-10,0) | 8.06225774829855
129 | (-10,0) | (0,0) | 10
130 | (0,0) | (-10,0) | 10
131 | (-10,0) | (-5,-12) | 13
132 | (-5,-12) | (-10,0) | 13
133 | (-5,-12) | (0,0) | 13
134 | (0,0) | (-5,-12) | 13
135 | (0,0) | (10,10) | 14.142135623731
136 | (10,10) | (0,0) | 14.142135623731
137 | (-3,4) | (10,10) | 14.3178210632764
138 | (10,10) | (-3,4) | 14.3178210632764
139 | (-5,-12) | (-3,4) | 16.1245154965971
140 | (-3,4) | (-5,-12) | 16.1245154965971
141 | (-10,0) | (10,10) | 22.3606797749979
142 | (10,10) | (-10,0) | 22.3606797749979
143 | (5.1,34.5) | (10,10) | 24.9851956166046
144 | (10,10) | (5.1,34.5) | 24.9851956166046
145 | (-5,-12) | (10,10) | 26.6270539113887
146 | (10,10) | (-5,-12) | 26.6270539113887
147 | (-3,4) | (5.1,34.5) | 31.5572495632937
148 | (5.1,34.5) | (-3,4) | 31.5572495632937
149 | (0,0) | (5.1,34.5) | 34.8749193547455
150 | (5.1,34.5) | (0,0) | 34.8749193547455
151 | (-10,0) | (5.1,34.5) | 37.6597928831267
152 | (5.1,34.5) | (-10,0) | 37.6597928831267
153 | (-5,-12) | (5.1,34.5) | 47.5842410888311
154 | (5.1,34.5) | (-5,-12) | 47.5842410888311
157 SELECT '' AS thirty, p1.f1 AS point1, p2.f1 AS point2
158 FROM POINT_TBL p1, POINT_TBL p2
159 WHERE (p1.f1 <-> p2.f1) > 3;
160 thirty | point1 | point2
161 --------+------------+------------
169 | (-10,0) | (5.1,34.5)
174 | (-3,4) | (5.1,34.5)
178 | (5.1,34.5) | (-10,0)
179 | (5.1,34.5) | (-3,4)
180 | (5.1,34.5) | (-5,-12)
181 | (5.1,34.5) | (10,10)
185 | (-5,-12) | (5.1,34.5)
190 | (10,10) | (5.1,34.5)
194 -- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10
195 SELECT '' AS fifteen, p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance
196 FROM POINT_TBL p1, POINT_TBL p2
197 WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1
198 ORDER BY distance, p1.f1[0], p2.f1[0];
199 fifteen | point1 | point2 | distance
200 ---------+------------+------------+------------------
202 | (-10,0) | (-3,4) | 8.06225774829855
203 | (-10,0) | (0,0) | 10
204 | (-10,0) | (-5,-12) | 13
205 | (-5,-12) | (0,0) | 13
206 | (0,0) | (10,10) | 14.142135623731
207 | (-3,4) | (10,10) | 14.3178210632764
208 | (-5,-12) | (-3,4) | 16.1245154965971
209 | (-10,0) | (10,10) | 22.3606797749979
210 | (5.1,34.5) | (10,10) | 24.9851956166046
211 | (-5,-12) | (10,10) | 26.6270539113887
212 | (-3,4) | (5.1,34.5) | 31.5572495632937
213 | (0,0) | (5.1,34.5) | 34.8749193547455
214 | (-10,0) | (5.1,34.5) | 37.6597928831267
215 | (-5,-12) | (5.1,34.5) | 47.5842410888311
218 -- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10
219 SELECT '' AS three, p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance
220 FROM POINT_TBL p1, POINT_TBL p2
221 WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 and p1.f1 >^ p2.f1
223 three | point1 | point2 | distance
224 -------+------------+----------+------------------
226 | (-10,0) | (-5,-12) | 13
227 | (5.1,34.5) | (10,10) | 24.9851956166046