16 CREATE TABLE POLYGON_TBL(f1 polygon);
17 INSERT INTO POLYGON_TBL(f1) VALUES ('(2.0,0.0),(2.0,4.0),(0.0,0.0)');
18 INSERT INTO POLYGON_TBL(f1) VALUES ('(3.0,1.0),(3.0,3.0),(1.0,0.0)');
19 -- degenerate polygons
20 INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,0.0)');
21 INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,1.0),(0.0,1.0)');
22 -- bad polygon input strings
23 INSERT INTO POLYGON_TBL(f1) VALUES ('0.0');
24 ERROR: invalid input syntax for type polygon: "0.0"
25 LINE 1: INSERT INTO POLYGON_TBL(f1) VALUES ('0.0');
27 INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0 0.0');
28 ERROR: invalid input syntax for type polygon: "(0.0 0.0"
29 LINE 1: INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0 0.0');
31 INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2)');
32 ERROR: invalid input syntax for type polygon: "(0,1,2)"
33 LINE 1: INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2)');
35 INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3');
36 ERROR: invalid input syntax for type polygon: "(0,1,2,3"
37 LINE 1: INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3');
39 INSERT INTO POLYGON_TBL(f1) VALUES ('asdf');
40 ERROR: invalid input syntax for type polygon: "asdf"
41 LINE 1: INSERT INTO POLYGON_TBL(f1) VALUES ('asdf');
43 SELECT '' AS four, * FROM POLYGON_TBL;
45 ------+---------------------
53 SELECT '' AS three, p.*
55 WHERE p.f1 && '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
57 -------+---------------------
63 SELECT '' AS four, p.*
65 WHERE p.f1 &< '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
67 ------+---------------------
77 WHERE p.f1 &> '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
79 -----+---------------------
86 WHERE p.f1 << '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
94 SELECT '' AS zero, p.*
96 WHERE p.f1 >> '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
102 SELECT '' AS one, p.*
104 WHERE p.f1 <@ polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
106 -----+---------------------
107 | ((3,1),(3,3),(1,0))
111 SELECT '' AS one, p.*
113 WHERE p.f1 ~= polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
115 -----+---------------------
116 | ((3,1),(3,3),(1,0))
120 SELECT '' AS one, p.*
122 WHERE p.f1 @> polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
124 -----+---------------------
125 | ((3,1),(3,3),(1,0))
142 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' << polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
149 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' << polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS true;
156 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' &> polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
163 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' >> polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
170 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' <@ polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
177 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' @> polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
184 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' ~= polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
191 SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' && polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS true;