You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1492 lines
60 KiB

MDEV-9217 Split Item::tmp_table_field_from_field_type() into virtual methods in Type_handler - Adding Type_handler::make_table_field() and moving pieces of the code from Item::tmp_table_field_from_field_type() to virtual implementations for various type handlers. - Adding a new Type_all_attributes, to access to Item's extended attributes, such as decimal_precision() and geometry_type(). - Adding a new class Record_addr, to pass record related information to Type_handler methods (ptr, null_ptr and null_bit) as a single structure. Note, later it will possibly be extended for BIT-alike field purposes, by adding new members (bit_ptr_arg, bit_ofs_arg). - Moving the code from Field_new_decimal::create_from_item() to Type_handler_newdecimal::make_table_field(). - Removing Field_new_decimal() and Field_geom() helper constructor variants that were used for temporary field creation. - Adding Item_field::type_handler(), Field::type_handler() and Field_blob::type_handler() to return correct type handlers for blob variants, according to Field_blob::packlength. - Adding Type_handler_blob_common, as a common parent for Type_handler_tiny_blob, Type_handler_blob, Type_handler_medium_blob and Type_handler_long_blob. - Implementing Type_handler_blob_common::Item_hybrid_func_fix_attributes(). It's needed for cases when TEXT variants of different character sets are mixed in LEAST, GREATEST, CASE and its abreviations (IF, IFNULL, COALESCE), e.g.: CREATE TABLE t1 ( a TINYTEXT CHARACTER SET latin1, b TINYTEXT CHARACTER SET utf8 ); CREATE TABLE t2 AS SELECT COALESCE(a,b) FROM t1; Type handler aggregation returns TINYTEXT as a common data type for the two columns. But as conversion from latin1 to utf8 happens for "a", the maximum possible length of "a" grows from 255 to 255*3. Type_handler_blob_common::Item_hybrid_func_fix_attributes() makes sure to update the blob type handler according to max_length. - Adding Type_handler::blob_type_handler(uint max_octet_length). - Adding a few m_type_aggregator_for_result.add() pairs, because now Item_xxx::type_handler() can return pointers to type_handler_tiny_blob, type_handler_blob, type_handler_medium_blob, type_handler_long_blob. Before the patch only type_handler_blob was possible result of type_handler(). - Making type_handler_tiny_blob, type_handler_blob, type_handler_medium_blob, type_handler_long_blob public. - Removing the condition in Item_sum_avg::create_tmp_field() checking Item_sum_avg::result_type() against DECIMAL_RESULT. Now both REAL_RESULT and DECIMAL_RESULT are symmetrically handled by tmp_table_field_from_field_type(). - Removing Item_geometry_func::create_field_for_create_select(), as the inherited version perfectly works. - Fixing Item_func_as_wkb::field_type() to return MYSQL_TYPE_LONG_BLOB rather than MYSQL_TYPE_BLOB. It's needed to make sure that tmp_table_field_from_field_type() creates a LONGBLOB field for AsWKB(). - Fixing Item_func_as_wkt::fix_length_and_dec() to set max_length to UINT32_MAX rather than MAX_BLOB_WIDTH, to make sure that tmp_table_field_from_field_type() creates a LONGTEXT field for AsWKT(). - Removing Item_func_set_user_var::create_field_for_create_select(), as the inherited version works fine. - Adding Item_func_get_user_var::create_field_for_create_select() to make sure that "CREATE TABLE t1 AS SELECT @string_user variable" always creates a field of LONGTEXT/LONGBLOB type. - Item_func_ifnull::create_field_for_create_select() behavior has changed. Before the patch it passed set_blob_packflag=false, which meant to create LONGBLOB for all blob variants. Now it takes into account max_length, which gives better column data types for: CREATE TABLE t2 AS SELECT IFNULL(blob_column1, blob_column2) FROM t1; - Fixing Item_func_nullif::fix_length_and_dec() to use set_handler(args[2]->type_handler()) instead of set_handler_by_field_type(args[2]->field_type()). This is needed to distinguish between BLOB variants. - Implementing Item_blob::type_handler(), to make sure to create proper BLOB field variant, according to max_length, for queries like: CREATE TABLE t1 AS SELECT some_blob_field FROM INFORMATION_SCHEMA.SOME_TABLE; - Fixing Item_field::real_type_handler() to make sure that the code aggregating fields for UNION gets a proper BLOB variant type handler from fields. - Adding a special code into Item_type_holder::make_field_by_type(), to make sure that after aggregating field types it also properly takes into account max_length when mixing TEXT variants of different character sets and chooses a proper TEXT variant: CREATE TABLE t1 ( a TINYTEXT CHARACTER SET latin1, b TINYTEXT CHARACTER SET utf8 ); CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; - Adding tests, for better coverage of IFNULL, NULLIF, UNION. - The fact that tmp_table_field_from_field_type() now takes into account BLOB variants (instead of always creating LONGBLOB), tests results for WEIGHT_STRING() and NULLIF() and UNION have become more precise.
9 years ago
  1. SET default_storage_engine=InnoDB;
  2. SET innodb_strict_mode=OFF;
  3. CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
  4. CREATE TABLE gis_line (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
  5. CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
  6. CREATE TABLE gis_multi_point (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
  7. CREATE TABLE gis_multi_line (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
  8. CREATE TABLE gis_multi_polygon (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
  9. CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
  10. CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
  11. SHOW FIELDS FROM gis_point;
  12. Field Type Null Key Default Extra
  13. fid int(11) NO PRI NULL
  14. g point YES NULL
  15. SHOW FIELDS FROM gis_line;
  16. Field Type Null Key Default Extra
  17. fid int(11) NO PRI NULL
  18. g linestring YES NULL
  19. SHOW FIELDS FROM gis_polygon;
  20. Field Type Null Key Default Extra
  21. fid int(11) NO PRI NULL
  22. g polygon YES NULL
  23. SHOW FIELDS FROM gis_multi_point;
  24. Field Type Null Key Default Extra
  25. fid int(11) NO PRI NULL
  26. g multipoint YES NULL
  27. SHOW FIELDS FROM gis_multi_line;
  28. Field Type Null Key Default Extra
  29. fid int(11) NO PRI NULL
  30. g multilinestring YES NULL
  31. SHOW FIELDS FROM gis_multi_polygon;
  32. Field Type Null Key Default Extra
  33. fid int(11) NO PRI NULL
  34. g multipolygon YES NULL
  35. SHOW FIELDS FROM gis_geometrycollection;
  36. Field Type Null Key Default Extra
  37. fid int(11) NO PRI NULL
  38. g geometrycollection YES NULL
  39. SHOW FIELDS FROM gis_geometry;
  40. Field Type Null Key Default Extra
  41. fid int(11) NO PRI NULL
  42. g geometry YES NULL
  43. INSERT INTO gis_point VALUES
  44. (101, ST_PointFromText('POINT(10 10)')),
  45. (102, ST_PointFromText('POINT(20 10)')),
  46. (103, ST_PointFromText('POINT(20 20)')),
  47. (104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
  48. INSERT INTO gis_line VALUES
  49. (105, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')),
  50. (106, ST_LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
  51. (107, ST_LineStringFromWKB(ST_AsWKB(LineString(Point(10, 10), Point(40, 10)))));
  52. INSERT INTO gis_polygon VALUES
  53. (108, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
  54. (109, ST_PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
  55. (110, ST_PolyFromWKB(ST_AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
  56. INSERT INTO gis_multi_point VALUES
  57. (111, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
  58. (112, ST_MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
  59. (113, ST_MPointFromWKB(ST_AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
  60. INSERT INTO gis_multi_line VALUES
  61. (114, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
  62. (115, ST_MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
  63. (116, ST_MLineFromWKB(ST_AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
  64. INSERT INTO gis_multi_polygon VALUES
  65. (117, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
  66. (118, ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
  67. (119, ST_MPolyFromWKB(ST_AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
  68. INSERT INTO gis_geometrycollection VALUES
  69. (120, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
  70. (121, ST_GeometryFromWKB(ST_AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
  71. INSERT into gis_geometry SELECT * FROM gis_point;
  72. INSERT into gis_geometry SELECT * FROM gis_line;
  73. INSERT into gis_geometry SELECT * FROM gis_polygon;
  74. INSERT into gis_geometry SELECT * FROM gis_multi_point;
  75. INSERT into gis_geometry SELECT * FROM gis_multi_line;
  76. INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
  77. INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
  78. SELECT fid, ST_AsText(g) FROM gis_point;
  79. fid ST_AsText(g)
  80. 101 POINT(10 10)
  81. 102 POINT(20 10)
  82. 103 POINT(20 20)
  83. 104 POINT(10 20)
  84. SELECT fid, ST_AsText(g) FROM gis_line;
  85. fid ST_AsText(g)
  86. 105 LINESTRING(0 0,0 10,10 0)
  87. 106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
  88. 107 LINESTRING(10 10,40 10)
  89. SELECT fid, ST_AsText(g) FROM gis_polygon;
  90. fid ST_AsText(g)
  91. 108 POLYGON((10 10,20 10,20 20,10 20,10 10))
  92. 109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
  93. 110 POLYGON((0 0,30 0,30 30,0 0))
  94. SELECT fid, ST_AsText(g) FROM gis_multi_point;
  95. fid ST_AsText(g)
  96. 111 MULTIPOINT(0 0,10 10,10 20,20 20)
  97. 112 MULTIPOINT(1 1,11 11,11 21,21 21)
  98. 113 MULTIPOINT(3 6,4 10)
  99. SELECT fid, ST_AsText(g) FROM gis_multi_line;
  100. fid ST_AsText(g)
  101. 114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
  102. 115 MULTILINESTRING((10 48,10 21,10 0))
  103. 116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
  104. SELECT fid, ST_AsText(g) FROM gis_multi_polygon;
  105. fid ST_AsText(g)
  106. 117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
  107. 118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
  108. 119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
  109. SELECT fid, ST_AsText(g) FROM gis_geometrycollection;
  110. fid ST_AsText(g)
  111. 120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
  112. 121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
  113. SELECT fid, ST_AsText(g) FROM gis_geometry;
  114. fid ST_AsText(g)
  115. 101 POINT(10 10)
  116. 102 POINT(20 10)
  117. 103 POINT(20 20)
  118. 104 POINT(10 20)
  119. 105 LINESTRING(0 0,0 10,10 0)
  120. 106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
  121. 107 LINESTRING(10 10,40 10)
  122. 108 POLYGON((10 10,20 10,20 20,10 20,10 10))
  123. 109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
  124. 110 POLYGON((0 0,30 0,30 30,0 0))
  125. 111 MULTIPOINT(0 0,10 10,10 20,20 20)
  126. 112 MULTIPOINT(1 1,11 11,11 21,21 21)
  127. 113 MULTIPOINT(3 6,4 10)
  128. 114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
  129. 115 MULTILINESTRING((10 48,10 21,10 0))
  130. 116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
  131. 117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
  132. 118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
  133. 119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
  134. 120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
  135. 121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
  136. SELECT fid, ST_Dimension(g) FROM gis_geometry;
  137. fid ST_Dimension(g)
  138. 101 0
  139. 102 0
  140. 103 0
  141. 104 0
  142. 105 1
  143. 106 1
  144. 107 1
  145. 108 2
  146. 109 2
  147. 110 2
  148. 111 0
  149. 112 0
  150. 113 0
  151. 114 1
  152. 115 1
  153. 116 1
  154. 117 2
  155. 118 2
  156. 119 2
  157. 120 1
  158. 121 1
  159. SELECT fid, ST_GeometryType(g) FROM gis_geometry;
  160. fid ST_GeometryType(g)
  161. 101 POINT
  162. 102 POINT
  163. 103 POINT
  164. 104 POINT
  165. 105 LINESTRING
  166. 106 LINESTRING
  167. 107 LINESTRING
  168. 108 POLYGON
  169. 109 POLYGON
  170. 110 POLYGON
  171. 111 MULTIPOINT
  172. 112 MULTIPOINT
  173. 113 MULTIPOINT
  174. 114 MULTILINESTRING
  175. 115 MULTILINESTRING
  176. 116 MULTILINESTRING
  177. 117 MULTIPOLYGON
  178. 118 MULTIPOLYGON
  179. 119 MULTIPOLYGON
  180. 120 GEOMETRYCOLLECTION
  181. 121 GEOMETRYCOLLECTION
  182. SELECT fid, ST_IsEmpty(g) FROM gis_geometry;
  183. fid ST_IsEmpty(g)
  184. 101 0
  185. 102 0
  186. 103 0
  187. 104 0
  188. 105 0
  189. 106 0
  190. 107 0
  191. 108 0
  192. 109 0
  193. 110 0
  194. 111 0
  195. 112 0
  196. 113 0
  197. 114 0
  198. 115 0
  199. 116 0
  200. 117 0
  201. 118 0
  202. 119 0
  203. 120 0
  204. 121 0
  205. SELECT fid, ST_AsText(ST_Envelope(g)) FROM gis_geometry;
  206. fid ST_AsText(ST_Envelope(g))
  207. 101 POLYGON((10 10,10 10,10 10,10 10,10 10))
  208. 102 POLYGON((20 10,20 10,20 10,20 10,20 10))
  209. 103 POLYGON((20 20,20 20,20 20,20 20,20 20))
  210. 104 POLYGON((10 20,10 20,10 20,10 20,10 20))
  211. 105 POLYGON((0 0,10 0,10 10,0 10,0 0))
  212. 106 POLYGON((10 10,20 10,20 20,10 20,10 10))
  213. 107 POLYGON((10 10,40 10,40 10,10 10,10 10))
  214. 108 POLYGON((10 10,20 10,20 20,10 20,10 10))
  215. 109 POLYGON((0 0,50 0,50 50,0 50,0 0))
  216. 110 POLYGON((0 0,30 0,30 30,0 30,0 0))
  217. 111 POLYGON((0 0,20 0,20 20,0 20,0 0))
  218. 112 POLYGON((1 1,21 1,21 21,1 21,1 1))
  219. 113 POLYGON((3 6,4 6,4 10,3 10,3 6))
  220. 114 POLYGON((10 0,16 0,16 48,10 48,10 0))
  221. 115 POLYGON((10 0,10 0,10 48,10 48,10 0))
  222. 116 POLYGON((1 2,21 2,21 8,1 8,1 2))
  223. 117 POLYGON((28 0,84 0,84 42,28 42,28 0))
  224. 118 POLYGON((28 0,84 0,84 42,28 42,28 0))
  225. 119 POLYGON((0 0,3 0,3 3,0 3,0 0))
  226. 120 POLYGON((0 0,10 0,10 10,0 10,0 0))
  227. 121 POLYGON((3 6,44 6,44 9,3 9,3 6))
  228. explain extended select ST_Dimension(g), ST_GeometryType(g), ST_IsEmpty(g), ST_AsText(ST_Envelope(g)) from gis_geometry;
  229. id select_type table type possible_keys key key_len ref rows filtered Extra
  230. 1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 #
  231. Warnings:
  232. Note 1003 select st_dimension(`test`.`gis_geometry`.`g`) AS `ST_Dimension(g)`,st_geometrytype(`test`.`gis_geometry`.`g`) AS `ST_GeometryType(g)`,st_isempty(`test`.`gis_geometry`.`g`) AS `ST_IsEmpty(g)`,st_astext(st_envelope(`test`.`gis_geometry`.`g`)) AS `ST_AsText(ST_Envelope(g))` from `test`.`gis_geometry`
  233. SELECT fid, ST_X(g) FROM gis_point;
  234. fid ST_X(g)
  235. 101 10
  236. 102 20
  237. 103 20
  238. 104 10
  239. SELECT fid, ST_Y(g) FROM gis_point;
  240. fid ST_Y(g)
  241. 101 10
  242. 102 10
  243. 103 20
  244. 104 20
  245. explain extended select ST_X(g),ST_Y(g) FROM gis_point;
  246. id select_type table type possible_keys key key_len ref rows filtered Extra
  247. 1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 #
  248. Warnings:
  249. Note 1003 select st_x(`test`.`gis_point`.`g`) AS `ST_X(g)`,st_y(`test`.`gis_point`.`g`) AS `ST_Y(g)` from `test`.`gis_point`
  250. SELECT fid, ST_AsText(ST_StartPoint(g)) FROM gis_line;
  251. fid ST_AsText(ST_StartPoint(g))
  252. 105 POINT(0 0)
  253. 106 POINT(10 10)
  254. 107 POINT(10 10)
  255. SELECT fid, ST_AsText(ST_EndPoint(g)) FROM gis_line;
  256. fid ST_AsText(ST_EndPoint(g))
  257. 105 POINT(10 0)
  258. 106 POINT(10 10)
  259. 107 POINT(40 10)
  260. SELECT fid, ST_Length(g) FROM gis_line;
  261. fid ST_Length(g)
  262. 105 24.14213562373095
  263. 106 40
  264. 107 30
  265. SELECT fid, ST_NumPoints(g) FROM gis_line;
  266. fid ST_NumPoints(g)
  267. 105 3
  268. 106 5
  269. 107 2
  270. SELECT fid, ST_AsText(ST_PointN(g, 2)) FROM gis_line;
  271. fid ST_AsText(ST_PointN(g, 2))
  272. 105 POINT(0 10)
  273. 106 POINT(20 10)
  274. 107 POINT(40 10)
  275. SELECT fid, ST_IsClosed(g) FROM gis_line;
  276. fid ST_IsClosed(g)
  277. 105 0
  278. 106 1
  279. 107 0
  280. explain extended select ST_AsText(ST_StartPoint(g)),ST_AsText(ST_EndPoint(g)),ST_Length(g),ST_NumPoints(g),ST_AsText(ST_PointN(g, 2)),ST_IsClosed(g) FROM gis_line;
  281. id select_type table type possible_keys key key_len ref rows filtered Extra
  282. 1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 #
  283. Warnings:
  284. Note 1003 select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `ST_AsText(ST_StartPoint(g))`,st_astext(st_endpoint(`test`.`gis_line`.`g`)) AS `ST_AsText(ST_EndPoint(g))`,st_length(`test`.`gis_line`.`g`) AS `ST_Length(g)`,st_numpoints(`test`.`gis_line`.`g`) AS `ST_NumPoints(g)`,st_astext(st_pointn(`test`.`gis_line`.`g`,2)) AS `ST_AsText(ST_PointN(g, 2))`,st_isclosed(`test`.`gis_line`.`g`) AS `ST_IsClosed(g)` from `test`.`gis_line`
  285. SELECT fid, ST_AsText(ST_Centroid(g)) FROM gis_polygon;
  286. fid ST_AsText(ST_Centroid(g))
  287. 108 POINT(15 15)
  288. 109 POINT(25.416666666666668 25.416666666666668)
  289. 110 POINT(20 10)
  290. SELECT fid, ST_Area(g) FROM gis_polygon;
  291. fid ST_Area(g)
  292. 108 100
  293. 109 2400
  294. 110 450
  295. SELECT fid, ST_AsText(ST_ExteriorRing(g)) FROM gis_polygon;
  296. fid ST_AsText(ST_ExteriorRing(g))
  297. 108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
  298. 109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
  299. 110 LINESTRING(0 0,30 0,30 30,0 0)
  300. SELECT fid, ST_NumInteriorRings(g) FROM gis_polygon;
  301. fid ST_NumInteriorRings(g)
  302. 108 0
  303. 109 1
  304. 110 0
  305. SELECT fid, ST_AsText(ST_InteriorRingN(g, 1)) FROM gis_polygon;
  306. fid ST_AsText(ST_InteriorRingN(g, 1))
  307. 108 NULL
  308. 109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
  309. 110 NULL
  310. explain extended select ST_AsText(ST_Centroid(g)),ST_Area(g),ST_AsText(ST_ExteriorRing(g)),ST_NumInteriorRings(g),ST_AsText(ST_InteriorRingN(g, 1)) FROM gis_polygon;
  311. id select_type table type possible_keys key key_len ref rows filtered Extra
  312. 1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 #
  313. Warnings:
  314. Note 1003 select st_astext(st_centroid(`test`.`gis_polygon`.`g`)) AS `ST_AsText(ST_Centroid(g))`,st_area(`test`.`gis_polygon`.`g`) AS `ST_Area(g)`,st_astext(st_exteriorring(`test`.`gis_polygon`.`g`)) AS `ST_AsText(ST_ExteriorRing(g))`,st_numinteriorrings(`test`.`gis_polygon`.`g`) AS `ST_NumInteriorRings(g)`,st_astext(st_interiorringn(`test`.`gis_polygon`.`g`,1)) AS `ST_AsText(ST_InteriorRingN(g, 1))` from `test`.`gis_polygon`
  315. SELECT fid, ST_IsClosed(g) FROM gis_multi_line;
  316. fid ST_IsClosed(g)
  317. 114 0
  318. 115 0
  319. 116 0
  320. SELECT fid, ST_AsText(ST_Centroid(g)) FROM gis_multi_polygon;
  321. fid ST_AsText(ST_Centroid(g))
  322. 117 POINT(57.98031067576927 17.854754130800433)
  323. 118 POINT(57.98031067576927 17.854754130800433)
  324. 119 POINT(2 2)
  325. SELECT fid, ST_Area(g) FROM gis_multi_polygon;
  326. fid ST_Area(g)
  327. 117 1684.5
  328. 118 1684.5
  329. 119 4.5
  330. SELECT fid, ST_NumGeometries(g) from gis_multi_point;
  331. fid ST_NumGeometries(g)
  332. 111 4
  333. 112 4
  334. 113 2
  335. SELECT fid, ST_NumGeometries(g) from gis_multi_line;
  336. fid ST_NumGeometries(g)
  337. 114 2
  338. 115 1
  339. 116 2
  340. SELECT fid, ST_NumGeometries(g) from gis_multi_polygon;
  341. fid ST_NumGeometries(g)
  342. 117 2
  343. 118 2
  344. 119 1
  345. SELECT fid, ST_NumGeometries(g) from gis_geometrycollection;
  346. fid ST_NumGeometries(g)
  347. 120 2
  348. 121 2
  349. explain extended SELECT fid, ST_NumGeometries(g) from gis_multi_point;
  350. id select_type table type possible_keys key key_len ref rows filtered Extra
  351. 1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 #
  352. Warnings:
  353. Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_numgeometries(`test`.`gis_multi_point`.`g`) AS `ST_NumGeometries(g)` from `test`.`gis_multi_point`
  354. SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_point;
  355. fid ST_AsText(ST_GeometryN(g, 2))
  356. 111 POINT(10 10)
  357. 112 POINT(11 11)
  358. 113 POINT(4 10)
  359. SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_line;
  360. fid ST_AsText(ST_GeometryN(g, 2))
  361. 114 LINESTRING(16 0,16 23,16 48)
  362. 115 NULL
  363. 116 LINESTRING(2 5,5 8,21 7)
  364. SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_polygon;
  365. fid ST_AsText(ST_GeometryN(g, 2))
  366. 117 POLYGON((59 18,67 18,67 13,59 13,59 18))
  367. 118 POLYGON((59 18,67 18,67 13,59 13,59 18))
  368. 119 NULL
  369. SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_geometrycollection;
  370. fid ST_AsText(ST_GeometryN(g, 2))
  371. 120 LINESTRING(0 0,10 10)
  372. 121 LINESTRING(3 6,7 9)
  373. SELECT fid, ST_AsText(ST_GeometryN(g, 1)) from gis_geometrycollection;
  374. fid ST_AsText(ST_GeometryN(g, 1))
  375. 120 POINT(0 0)
  376. 121 POINT(44 6)
  377. explain extended SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_point;
  378. id select_type table type possible_keys key key_len ref rows filtered Extra
  379. 1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 #
  380. Warnings:
  381. Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_astext(st_geometryn(`test`.`gis_multi_point`.`g`,2)) AS `ST_AsText(ST_GeometryN(g, 2))` from `test`.`gis_multi_point`
  382. SELECT g1.fid as first, g2.fid as second,
  383. MBRWithin(g1.g, g2.g) as w, MBRContains(g1.g, g2.g) as c, MBROverlaps(g1.g, g2.g) as o,
  384. MBREquals(g1.g, g2.g) as e, MBRDisjoint(g1.g, g2.g) as d, ST_Touches(g1.g, g2.g) as t,
  385. MBRIntersects(g1.g, g2.g) as i, ST_Crosses(g1.g, g2.g) as r
  386. FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
  387. first second w c o e d t i r
  388. 120 120 1 1 0 1 0 0 1 0
  389. 120 121 0 0 1 0 0 0 1 0
  390. 121 120 0 0 1 0 0 0 1 0
  391. 121 121 1 1 0 1 0 0 1 0
  392. explain extended SELECT g1.fid as first, g2.fid as second,
  393. MBRWithin(g1.g, g2.g) as w, MBRContains(g1.g, g2.g) as c, MBROverlaps(g1.g, g2.g) as o,
  394. MBREquals(g1.g, g2.g) as e, MBRDisjoint(g1.g, g2.g) as d, ST_Touches(g1.g, g2.g) as t,
  395. MBRIntersects(g1.g, g2.g) as i, ST_Crosses(g1.g, g2.g) as r
  396. FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
  397. id select_type table type possible_keys key key_len ref rows filtered Extra
  398. 1 SIMPLE g1 ALL NULL NULL NULL NULL 2 # Using temporary; Using filesort
  399. 1 SIMPLE g2 ALL NULL NULL NULL NULL 2 # Using join buffer (flat, BNL join)
  400. Warnings:
  401. Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,mbrwithin(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,mbrcontains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
  402. DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
  403. CREATE TABLE t1 (
  404. gp point,
  405. ln linestring,
  406. pg polygon,
  407. mp multipoint,
  408. mln multilinestring,
  409. mpg multipolygon,
  410. gc geometrycollection,
  411. gm geometry
  412. );
  413. SHOW FIELDS FROM t1;
  414. Field Type Null Key Default Extra
  415. gp point YES NULL
  416. ln linestring YES NULL
  417. pg polygon YES NULL
  418. mp multipoint YES NULL
  419. mln multilinestring YES NULL
  420. mpg multipolygon YES NULL
  421. gc geometrycollection YES NULL
  422. gm geometry YES NULL
  423. ALTER TABLE t1 ADD fid INT NOT NULL;
  424. SHOW FIELDS FROM t1;
  425. Field Type Null Key Default Extra
  426. gp point YES NULL
  427. ln linestring YES NULL
  428. pg polygon YES NULL
  429. mp multipoint YES NULL
  430. mln multilinestring YES NULL
  431. mpg multipolygon YES NULL
  432. gc geometrycollection YES NULL
  433. gm geometry YES NULL
  434. fid int(11) NO NULL
  435. DROP TABLE t1;
  436. SELECT ST_AsText(ST_GeometryFromWKB(ST_AsWKB(ST_GeometryFromText('POINT(1 4)'))));
  437. ST_AsText(ST_GeometryFromWKB(ST_AsWKB(ST_GeometryFromText('POINT(1 4)'))))
  438. POINT(1 4)
  439. explain extended SELECT ST_AsText(ST_GeometryFromWKB(ST_AsWKB(ST_GeometryFromText('POINT(1 4)'))));
  440. id select_type table type possible_keys key key_len ref rows filtered Extra
  441. 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
  442. Warnings:
  443. Note 1003 select st_astext(st_geometryfromwkb(st_aswkb(st_geometryfromtext('POINT(1 4)')))) AS `ST_AsText(ST_GeometryFromWKB(ST_AsWKB(ST_GeometryFromText('POINT(1 4)'))))`
  444. explain extended SELECT ST_AsText(ST_GeometryFromWKB(ST_AsWKB(ST_PointFromText('POINT(1 4)'))));
  445. id select_type table type possible_keys key key_len ref rows filtered Extra
  446. 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
  447. Warnings:
  448. Note 1003 select st_astext(st_geometryfromwkb(st_aswkb(st_geometryfromtext('POINT(1 4)')))) AS `ST_AsText(ST_GeometryFromWKB(ST_AsWKB(ST_PointFromText('POINT(1 4)'))))`
  449. SELECT ST_SRID(ST_GeomFromText('LineString(1 1,2 2)',101));
  450. ST_SRID(ST_GeomFromText('LineString(1 1,2 2)',101))
  451. 101
  452. explain extended SELECT ST_SRID(ST_GeomFromText('LineString(1 1,2 2)',101));
  453. id select_type table type possible_keys key key_len ref rows filtered Extra
  454. 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
  455. Warnings:
  456. Note 1003 select srid(st_geometryfromtext('LineString(1 1,2 2)',101)) AS `ST_SRID(ST_GeomFromText('LineString(1 1,2 2)',101))`
  457. explain extended select ST_issimple(MultiPoint(Point(3, 6), Point(4, 10))), ST_issimple(Point(3, 6));
  458. id select_type table type possible_keys key key_len ref rows filtered Extra
  459. 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
  460. Warnings:
  461. Note 1003 select st_issimple(multipoint(point(3,6),point(4,10))) AS `ST_issimple(MultiPoint(Point(3, 6), Point(4, 10)))`,st_issimple(point(3,6)) AS `ST_issimple(Point(3, 6))`
  462. create table t1 (a geometry not null);
  463. insert into t1 values (ST_GeomFromText('Point(1 2)'));
  464. insert into t1 values ('Garbage');
  465. ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
  466. insert IGNORE into t1 values ('Garbage');
  467. ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
  468. alter table t1 add spatial index(a);
  469. drop table t1;
  470. create table t1(a geometry not null, index(a(5)));
  471. insert into t1 values
  472. (ST_GeomFromText('POINT(1 1)')), (ST_GeomFromText('POINT(3 3)')),
  473. (ST_GeomFromText('POINT(4 4)')), (ST_GeomFromText('POINT(6 6)'));
  474. select ST_AsText(a) from t1 where
  475. MBRContains(ST_GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a)
  476. or
  477. MBRContains(ST_GeomFromText('Polygon((2 2, 2 5, 5 5, 5 2, 2 2))'), a);
  478. ST_AsText(a)
  479. POINT(1 1)
  480. POINT(3 3)
  481. POINT(4 4)
  482. select ST_AsText(a) from t1 where
  483. MBRContains(ST_GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a)
  484. and
  485. MBRContains(ST_GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
  486. ST_AsText(a)
  487. POINT(1 1)
  488. drop table t1;
  489. CREATE TABLE t1 (Coordinates POINT NOT NULL, INDEX(Coordinates(10)));
  490. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(383293632 1754448)'));
  491. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(564952612 157516260)'));
  492. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(903994614 180726515)'));
  493. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(98128178 141127631)'));
  494. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(862547902 799334546)'));
  495. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(341989013 850270906)'));
  496. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(803302376 93039099)'));
  497. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(857439153 817431356)'));
  498. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(319757546 343162742)'));
  499. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(826341972 717484432)'));
  500. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(305066789 201736238)'));
  501. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(626068992 616241497)'));
  502. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(55789424 755830108)'));
  503. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(802874458 312435220)'));
  504. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(153795660 551723671)'));
  505. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(242207428 537089292)'));
  506. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(553478119 807160039)'));
  507. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(694605552 457472733)'));
  508. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(987886554 792733729)'));
  509. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(598600363 850434457)'));
  510. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(592068275 940589376)'));
  511. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(700705362 395370650)'));
  512. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(33628474 558144514)'));
  513. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(212802006 353386020)'));
  514. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(901307256 39143977)'));
  515. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(70870451 206374045)'));
  516. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(240880214 696939443)'));
  517. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(822615542 296669638)'));
  518. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(452769551 625489999)'));
  519. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(609104858 606565210)'));
  520. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(177213669 851312285)'));
  521. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(143654501 730691787)'));
  522. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(658472325 838260052)'));
  523. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(188164520 646358878)'));
  524. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(630993781 786764883)'));
  525. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(496793334 223062055)'));
  526. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(727354258 197498696)'));
  527. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(618432704 760982731)'));
  528. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(755643210 831234710)'));
  529. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(114368751 656950466)'));
  530. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(870378686 185239202)'));
  531. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(863324511 111258900)'));
  532. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(882178645 685940052)'));
  533. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(407928538 334948195)'));
  534. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(311430051 17033395)'));
  535. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(941513405 488643719)'));
  536. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(868345680 85167906)'));
  537. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(219335507 526818004)'));
  538. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(923427958 407500026)'));
  539. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(173176882 554421738)'));
  540. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(194264908 669970217)'));
  541. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(777483793 921619165)'));
  542. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(867468912 395916497)'));
  543. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(682601897 623112122)'));
  544. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(227151206 796970647)'));
  545. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(280062588 97529892)'));
  546. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(982209849 143387099)'));
  547. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(208788792 864388493)'));
  548. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(829327151 616717329)'));
  549. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(199336688 140757201)'));
  550. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(633750724 140850093)'));
  551. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(629400920 502096404)'));
  552. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(226017998 848736426)'));
  553. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(28914408 149445955)'));
  554. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(256236452 202091290)'));
  555. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(703867693 450501360)'));
  556. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(872061506 481351486)'));
  557. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(372120524 739530418)'));
  558. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(877267982 54722420)'));
  559. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(362642540 104419188)'));
  560. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(851693067 642705127)'));
  561. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(201949080 833902916)'));
  562. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(786092225 410737872)'));
  563. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(698291409 615419376)'));
  564. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(27455201 897628096)'));
  565. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(756176576 661205925)'));
  566. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(38478189 385577496)'));
  567. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(163302328 264496186)'));
  568. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(234313922 192216735)'));
  569. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(413942141 490550373)'));
  570. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(394308025 117809834)'));
  571. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(941051732 266369530)'));
  572. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(599161319 313172256)'));
  573. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(5899948 476429301)'));
  574. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(367894677 368542487)'));
  575. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(580848489 219587743)'));
  576. INSERT INTO t1 VALUES(ST_GeomFromText('POINT(11247614 782797569)'));
  577. drop table t1;
  578. create table t1 select ST_GeomFromWKB(POINT(1,3));
  579. show create table t1;
  580. Table Create Table
  581. t1 CREATE TABLE `t1` (
  582. `ST_GeomFromWKB(POINT(1,3))` geometry DEFAULT NULL
  583. ) ENGINE=InnoDB DEFAULT CHARSET=latin1
  584. drop table t1;
  585. SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
  586. CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
  587. geometry NOT NULL default '') ENGINE=InnoDB ;
  588. SET sql_mode = default;
  589. insert into t1 values ('85984',ST_GeomFromText('MULTIPOLYGON(((-115.006363
  590. 36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163
  591. 36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363
  592. 36.311978,-114.975327 36.312344,-114.96502 36.31597,-114.963364
  593. 36.313629,-114.961723 36.313721,-114.956398 36.316057,-114.951882
  594. 36.320979,-114.947073 36.323475,-114.945207 36.326451,-114.945207
  595. 36.326451,-114.944132 36.326061,-114.94003 36.326588,-114.924017
  596. 36.334484,-114.923281 36.334146,-114.92564 36.331504,-114.94072
  597. 36.319282,-114.945348 36.314812,-114.948091 36.314762,-114.951755
  598. 36.316211,-114.952446 36.313883,-114.952644 36.309488,-114.944725
  599. 36.313083,-114.93706 36.32043,-114.932478 36.323497,-114.924556
  600. 36.327708,-114.922608 36.329715,-114.92009 36.328695,-114.912105
  601. 36.323566,-114.901647 36.317952,-114.897436 36.313968,-114.895344
  602. 36.309573,-114.891699 36.304398,-114.890569 36.303551,-114.886356
  603. 36.302702,-114.885141 36.301351,-114.885709 36.297391,-114.892499
  604. 36.290893,-114.902142 36.288974,-114.904941 36.288838,-114.905308
  605. 36.289845,-114.906325 36.290395,-114.909916 36.289549,-114.914527
  606. 36.287535,-114.918797 36.284423,-114.922982 36.279731,-114.924113
  607. 36.277282,-114.924057 36.275817,-114.927733 36.27053,-114.929354
  608. 36.269029,-114.929354 36.269029,-114.950856 36.268715,-114.950768
  609. 36.264324,-114.960206 36.264293,-114.960301 36.268943,-115.006662
  610. 36.268929,-115.008583 36.265619,-115.00665 36.264247,-115.006659
  611. 36.246873,-115.006659 36.246873,-115.006838 36.247697,-115.010764
  612. 36.247774,-115.015609 36.25113,-115.015765 36.254505,-115.029517
  613. 36.254619,-115.038573 36.249317,-115.038573 36.249317,-115.023403
  614. 36.25841,-115.023873 36.258994,-115.031845 36.259829,-115.03183
  615. 36.261053,-115.025561 36.261095,-115.036417 36.274632,-115.033729
  616. 36.276041,-115.032217 36.274851,-115.029845 36.273959,-115.029934
  617. 36.274966,-115.025763 36.274896,-115.025406 36.281044,-115.028731
  618. 36.284471,-115.036497 36.290377,-115.042071 36.291039,-115.026759
  619. 36.298478,-115.008995 36.301966,-115.006363 36.305435),(-115.079835
  620. 36.244369,-115.079735 36.260186,-115.076435 36.262369,-115.069758
  621. 36.265,-115.070235 36.268757,-115.064542 36.268655,-115.061843
  622. 36.269857,-115.062676 36.270693,-115.06305 36.272344,-115.059051
  623. 36.281023,-115.05918 36.283008,-115.060591 36.285246,-115.061913
  624. 36.290022,-115.062499 36.306353,-115.062499 36.306353,-115.060918
  625. 36.30642,-115.06112 36.289779,-115.05713 36.2825,-115.057314
  626. 36.279446,-115.060779 36.274659,-115.061366 36.27209,-115.057858
  627. 36.26557,-115.055805 36.262883,-115.054688 36.262874,-115.047335
  628. 36.25037,-115.044234 36.24637,-115.052434 36.24047,-115.061734
  629. 36.23507,-115.061934 36.22677,-115.061934 36.22677,-115.061491
  630. 36.225267,-115.062024 36.218194,-115.060134 36.218278,-115.060133
  631. 36.210771,-115.057833 36.210771,-115.057433 36.196271,-115.062233
  632. 36.196271,-115.062233 36.190371,-115.062233 36.190371,-115.065533
  633. 36.190371,-115.071333 36.188571,-115.098331 36.188275,-115.098331
  634. 36.188275,-115.098435 36.237569,-115.097535 36.240369,-115.097535
  635. 36.240369,-115.093235 36.240369,-115.089135 36.240469,-115.083135
  636. 36.240569,-115.083135 36.240569,-115.079835
  637. 36.244369)))')),('85998',ST_GeomFromText('MULTIPOLYGON(((-115.333107
  638. 36.264587,-115.333168 36.280638,-115.333168 36.280638,-115.32226
  639. 36.280643,-115.322538 36.274311,-115.327222 36.274258,-115.32733
  640. 36.263026,-115.330675 36.262984,-115.332132 36.264673,-115.333107
  641. 36.264587),(-115.247239 36.247066,-115.247438 36.218267,-115.247438
  642. 36.218267,-115.278525 36.219263,-115.278525 36.219263,-115.301545
  643. 36.219559,-115.332748 36.219197,-115.332757 36.220041,-115.332757
  644. 36.220041,-115.332895 36.233514,-115.349023 36.233479,-115.351489
  645. 36.234475,-115.353681 36.237021,-115.357106 36.239789,-115.36519
  646. 36.243331,-115.368156 36.243487,-115.367389 36.244902,-115.364553
  647. 36.246014,-115.359219 36.24616,-115.356186 36.248025,-115.353347
  648. 36.248004,-115.350813 36.249507,-115.339673 36.25387,-115.333069
  649. 36.255018,-115.333069 36.255018,-115.333042 36.247767,-115.279039
  650. 36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439
  651. 36.252666,-115.261439 36.247366,-115.247239 36.247066)))'));
  652. select object_id, ST_geometrytype(geo), ST_ISSIMPLE(GEO), ST_ASTEXT(ST_centroid(geo)) from
  653. t1 where object_id=85998;
  654. object_id ST_geometrytype(geo) ST_ISSIMPLE(GEO) ST_ASTEXT(ST_centroid(geo))
  655. 85998 MULTIPOLYGON 1 POINT(115.2970604672862 -36.23335610879993)
  656. select object_id, ST_geometrytype(geo), ST_ISSIMPLE(GEO), ST_ASTEXT(ST_centroid(geo)) from
  657. t1 where object_id=85984;
  658. object_id ST_geometrytype(geo) ST_ISSIMPLE(GEO) ST_ASTEXT(ST_centroid(geo))
  659. 85984 MULTIPOLYGON 1 POINT(-114.86854472054372 36.34725218253213)
  660. drop table t1;
  661. create table t1 (fl geometry not null);
  662. insert into t1 values (1);
  663. ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
  664. insert into t1 values (1.11);
  665. ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
  666. insert into t1 values ("qwerty");
  667. ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
  668. insert into t1 values (ST_pointfromtext('point(1,1)'));
  669. ERROR 23000: Column 'fl' cannot be null
  670. drop table t1;
  671. select (ST_asWKT(ST_geomfromwkb((0x000000000140240000000000004024000000000000))));
  672. (ST_asWKT(ST_geomfromwkb((0x000000000140240000000000004024000000000000))))
  673. POINT(10 10)
  674. select (ST_asWKT(ST_geomfromwkb((0x010100000000000000000024400000000000002440))));
  675. (ST_asWKT(ST_geomfromwkb((0x010100000000000000000024400000000000002440))))
  676. POINT(10 10)
  677. create table t1 (g GEOMETRY);
  678. select * from t1;
  679. Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
  680. def test t1 t1 g g 255 4294967295 0 Y 144 0 63
  681. g
  682. select ST_asbinary(g) from t1;
  683. Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
  684. def ST_asbinary(g) 251 4294967295 0 Y 128 0 63
  685. ST_asbinary(g)
  686. drop table t1;
  687. create table t1 (a TEXT, b GEOMETRY NOT NULL, INDEX(b(5)));
  688. alter table t1 disable keys;
  689. Warnings:
  690. Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
  691. load data infile '../../std_data/bad_gis_data.dat' into table t1;
  692. ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'b' at row 1
  693. alter table t1 enable keys;
  694. Warnings:
  695. Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
  696. drop table t1;
  697. create table t1 (a int, b blob);
  698. insert into t1 values (1, ''), (2, NULL), (3, '1');
  699. select * from t1;
  700. a b
  701. 1
  702. 2 NULL
  703. 3 1
  704. select
  705. ST_geometryfromtext(b) IS NULL, ST_geometryfromwkb(b) IS NULL, ST_astext(b) IS NULL,
  706. ST_aswkb(b) IS NULL, ST_geometrytype(b) IS NULL, ST_centroid(b) IS NULL,
  707. ST_envelope(b) IS NULL, ST_startpoint(b) IS NULL, ST_endpoint(b) IS NULL,
  708. ST_exteriorring(b) IS NULL, ST_pointn(b, 1) IS NULL, ST_geometryn(b, 1) IS NULL,
  709. ST_interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, ST_isempty(b) IS NULL,
  710. ST_issimple(b) IS NULL, ST_isclosed(b) IS NULL, ST_dimension(b) IS NULL,
  711. ST_numgeometries(b) IS NULL, ST_numinteriorrings(b) IS NULL, ST_numpoints(b) IS NULL,
  712. ST_area(b) IS NULL, ST_length(b) IS NULL, ST_srid(b) IS NULL, ST_x(b) IS NULL,
  713. ST_y(b) IS NULL
  714. from t1;
  715. ERROR 22007: Illegal non geometric '`test`.`t1`.`b`' value found during parsing
  716. select
  717. MBRwithin(b, b) IS NULL, MBRcontains(b, b) IS NULL, MBRoverlaps(b, b) IS NULL,
  718. MBRequals(b, b) IS NULL, MBRdisjoint(b, b) IS NULL, ST_touches(b, b) IS NULL,
  719. MBRintersects(b, b) IS NULL, ST_crosses(b, b) IS NULL
  720. from t1;
  721. MBRwithin(b, b) IS NULL MBRcontains(b, b) IS NULL MBRoverlaps(b, b) IS NULL MBRequals(b, b) IS NULL MBRdisjoint(b, b) IS NULL ST_touches(b, b) IS NULL MBRintersects(b, b) IS NULL ST_crosses(b, b) IS NULL
  722. 1 1 1 1 1 1 1 1
  723. 1 1 1 1 1 1 1 1
  724. 1 1 1 1 1 1 1 1
  725. select
  726. point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL,
  727. multilinestring(b) IS NULL, multipolygon(b) IS NULL,
  728. geometrycollection(b) IS NULL
  729. from t1;
  730. ERROR 22007: Illegal non geometric '`test`.`t1`.`b`' value found during parsing
  731. drop table t1;
  732. CREATE TABLE t1(a POINT) ENGINE=InnoDB;
  733. INSERT INTO t1 VALUES (NULL);
  734. SELECT * FROM t1;
  735. a
  736. NULL
  737. DROP TABLE t1;
  738. CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
  739. INSERT IGNORE INTO `t1` VALUES ('','0000-00-00');
  740. select ST_geomfromtext(col9,col89) as a from t1;
  741. a
  742. NULL
  743. DROP TABLE t1;
  744. CREATE TABLE t1 (
  745. geomdata polygon NOT NULL,
  746. KEY index_geom (geomdata(10))
  747. ) ENGINE=InnoDB DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
  748. Warnings:
  749. Warning 1478 InnoDB: assuming ROW_FORMAT=DYNAMIC.
  750. CREATE TABLE t2 (
  751. geomdata polygon NOT NULL,
  752. KEY index_geom (geomdata(10))
  753. ) ENGINE=InnoDB DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
  754. Warnings:
  755. Warning 1478 InnoDB: assuming ROW_FORMAT=DYNAMIC.
  756. CREATE TABLE t3
  757. select
  758. ST_aswkb(ws.geomdata) AS geomdatawkb
  759. from
  760. t1 ws
  761. union
  762. select
  763. ST_aswkb(ws.geomdata) AS geomdatawkb
  764. from
  765. t2 ws;
  766. describe t3;
  767. Field Type Null Key Default Extra
  768. geomdatawkb longblob YES NULL
  769. drop table t1;
  770. drop table t2;
  771. drop table t3;
  772. create table t1(col1 geometry default null,col15 geometrycollection not
  773. null, index(col15(5)),index(col1(15)))engine=InnoDB;
  774. insert into t1 set col15 = ST_GeomFromText('POINT(6 5)');
  775. insert into t1 set col15 = ST_GeomFromText('POINT(6 5)');
  776. check table t1 extended;
  777. Table Op Msg_type Msg_text
  778. test.t1 check status OK
  779. drop table t1;
  780. End of 4.1 tests
  781. create table t1 (s1 geometry not null,s2 char(100));
  782. create trigger t1_bu before update on t1 for each row set new.s1 = null;
  783. insert into t1 values (null,null);
  784. ERROR 23000: Column 's1' cannot be null
  785. drop table t1;
  786. drop procedure if exists fn3;
  787. create function fn3 () returns point deterministic return ST_GeomFromText("point(1 1)");
  788. show create function fn3;
  789. Function sql_mode Create Function character_set_client collation_connection Database Collation
  790. fn3 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS point
  791. DETERMINISTIC
  792. return ST_GeomFromText("point(1 1)") latin1 latin1_swedish_ci latin1_swedish_ci
  793. select ST_astext(fn3());
  794. ST_astext(fn3())
  795. POINT(1 1)
  796. drop function fn3;
  797. create table t1(pt POINT);
  798. alter table t1 add primary key pti(pt);
  799. drop table t1;
  800. create table t1(pt GEOMETRY);
  801. alter table t1 add primary key pti(pt);
  802. ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
  803. alter table t1 add primary key pti(pt(20));
  804. drop table t1;
  805. create table t1 select ST_GeomFromText('point(1 1)');
  806. desc t1;
  807. Field Type Null Key Default Extra
  808. ST_GeomFromText('point(1 1)') geometry YES NULL
  809. drop table t1;
  810. create table t1 (g geometry not null);
  811. insert into t1 values(default);
  812. ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
  813. drop table t1;
  814. CREATE TABLE t1 (a GEOMETRY);
  815. CREATE VIEW v1 AS SELECT ST_GeomFromwkb(ST_ASBINARY(a)) FROM t1;
  816. CREATE VIEW v2 AS SELECT a FROM t1;
  817. DESCRIBE v1;
  818. Field Type Null Key Default Extra
  819. ST_GeomFromwkb(ST_ASBINARY(a)) geometry YES NULL
  820. DESCRIBE v2;
  821. Field Type Null Key Default Extra
  822. a geometry YES NULL
  823. DROP VIEW v1,v2;
  824. DROP TABLE t1;
  825. create table t1 (name VARCHAR(100), square GEOMETRY);
  826. INSERT INTO t1 VALUES("center", ST_GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));
  827. INSERT INTO t1 VALUES("small", ST_GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
  828. INSERT INTO t1 VALUES("big", ST_GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
  829. INSERT INTO t1 VALUES("up", ST_GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
  830. INSERT INTO t1 VALUES("up2", ST_GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));
  831. INSERT INTO t1 VALUES("up3", ST_GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
  832. INSERT INTO t1 VALUES("down", ST_GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));
  833. INSERT INTO t1 VALUES("down2", ST_GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))'));
  834. INSERT INTO t1 VALUES("down3", ST_GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
  835. INSERT INTO t1 VALUES("right", ST_GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
  836. INSERT INTO t1 VALUES("right2", ST_GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
  837. INSERT INTO t1 VALUES("right3", ST_GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));
  838. INSERT INTO t1 VALUES("left", ST_GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))'));
  839. INSERT INTO t1 VALUES("left2", ST_GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))'));
  840. INSERT INTO t1 VALUES("left3", ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
  841. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  842. mbrcontains
  843. center,small
  844. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  845. mbrdisjoint
  846. down3,left3,right3,up3
  847. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequals FROM t1 a1 JOIN t1 a2 ON MBREquals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  848. mbrequals
  849. center
  850. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  851. mbrintersect
  852. big,center,down,down2,left,left2,right,right2,small,up,up2
  853. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  854. mbroverlaps
  855. down,left,right,up
  856. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  857. mbrtouches
  858. down2,left2,right2,up2
  859. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  860. mbrwithin
  861. big,center
  862. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS MBRcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  863. MBRcontains
  864. center,small
  865. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS MBRdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  866. MBRdisjoint
  867. down3,left3,right3,up3
  868. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS MBRequals FROM t1 a1 JOIN t1 a2 ON MBREquals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  869. MBRequals
  870. center
  871. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersects FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  872. intersects
  873. big,center,down,down2,left,left2,right,right2,small,up,up2
  874. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS MBRoverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  875. MBRoverlaps
  876. down,left,right,up
  877. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS ST_touches FROM t1 a1 JOIN t1 a2 ON ST_Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  878. ST_touches
  879. down2,left2,right2,up2
  880. SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS MBRwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
  881. MBRwithin
  882. big,center
  883. SET @vert1 = ST_GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
  884. SET @horiz1 = ST_GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
  885. SET @horiz2 = ST_GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
  886. SET @horiz3 = ST_GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
  887. SET @point1 = ST_GeomFromText('POLYGON ((0 0))');
  888. SET @point2 = ST_GeomFromText('POLYGON ((-2 0))');
  889. SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS MBRoverlaps FROM t1 a1 WHERE MBROverlaps(a1.square, @vert1) GROUP BY a1.name;
  890. MBRoverlaps
  891. SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS MBRoverlaps FROM t1 a1 WHERE MBROverlaps(a1.square, @horiz1) GROUP BY a1.name;
  892. MBRoverlaps
  893. SELECT MBROverlaps(@horiz1, @vert1) FROM DUAL;
  894. MBROverlaps(@horiz1, @vert1)
  895. 0
  896. SELECT MBROverlaps(@horiz1, @horiz2) FROM DUAL;
  897. MBROverlaps(@horiz1, @horiz2)
  898. 1
  899. SELECT MBROverlaps(@horiz1, @horiz3) FROM DUAL;
  900. MBROverlaps(@horiz1, @horiz3)
  901. 0
  902. SELECT MBROverlaps(@horiz1, @point1) FROM DUAL;
  903. MBROverlaps(@horiz1, @point1)
  904. 0
  905. SELECT MBROverlaps(@horiz1, @point2) FROM DUAL;
  906. MBROverlaps(@horiz1, @point2)
  907. 0
  908. DROP TABLE t1;
  909. create table t1(f1 geometry, f2 polygon, f3 linestring);
  910. select f1 from t1 union select f1 from t1;
  911. f1
  912. insert into t1 (f2,f3) values (ST_GeomFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))'), ST_GeomFromText('LINESTRING(0 0,1 1,2 2)'));
  913. select ST_AsText(f2),ST_AsText(f3) from t1;
  914. ST_AsText(f2) ST_AsText(f3)
  915. POLYGON((10 10,20 10,20 20,10 20,10 10)) LINESTRING(0 0,1 1,2 2)
  916. select ST_AsText(a) from (select f2 as a from t1 union select f3 from t1) t;
  917. ST_AsText(a)
  918. POLYGON((10 10,20 10,20 20,10 20,10 10))
  919. LINESTRING(0 0,1 1,2 2)
  920. create table t2 as select f2 as a from t1 union select f3 from t1;
  921. desc t2;
  922. Field Type Null Key Default Extra
  923. a geometry YES NULL
  924. select ST_AsText(a) from t2;
  925. ST_AsText(a)
  926. POLYGON((10 10,20 10,20 20,10 20,10 10))
  927. LINESTRING(0 0,1 1,2 2)
  928. drop table t1, t2;
  929. SELECT 1;
  930. 1
  931. 1
  932. CREATE TABLE t1 (p POINT);
  933. CREATE TABLE t2 (p POINT, INDEX(p));
  934. INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
  935. INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
  936. SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
  937. COUNT(*)
  938. 1
  939. EXPLAIN
  940. SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
  941. id select_type table type possible_keys key key_len ref rows Extra
  942. 1 SIMPLE t2 ref p p 28 const 1 Using where
  943. SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
  944. COUNT(*)
  945. 1
  946. INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
  947. INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
  948. EXPLAIN
  949. SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
  950. id select_type table type possible_keys key key_len ref rows Extra
  951. 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
  952. SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
  953. COUNT(*)
  954. 1
  955. EXPLAIN
  956. SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
  957. id select_type table type possible_keys key key_len ref rows Extra
  958. 1 SIMPLE t2 ref p p 28 const # Using where
  959. SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
  960. COUNT(*)
  961. 1
  962. EXPLAIN
  963. SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
  964. id select_type table type possible_keys key key_len ref rows Extra
  965. 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
  966. SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
  967. COUNT(*)
  968. 1
  969. DROP TABLE t1, t2;
  970. End of 5.0 tests
  971. #
  972. # Test for bug #58650 "Failing assertion: primary_key_no == -1 ||
  973. # primary_key_no == 0".
  974. #
  975. drop table if exists t1;
  976. # The minimal test case.
  977. create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a));
  978. drop table t1;
  979. # The original test case.
  980. create table t1 (a int not null, b linestring not null, unique key b (b(12)));
  981. create unique index a on t1(a);
  982. drop table t1;
  983. create table `t1` (`col002` point)engine=InnoDB;
  984. insert into t1 values (),(),();
  985. select min(`col002`) from t1 union select `col002` from t1;
  986. min(`col002`)
  987. NULL
  988. drop table t1;
  989. #
  990. # Bug #47780: crash when comparing GIS items from subquery
  991. #
  992. CREATE TABLE t1(a INT, b MULTIPOLYGON);
  993. INSERT INTO t1 VALUES
  994. (0,
  995. ST_GEOMFROMTEXT(
  996. 'multipolygon(((1 2,3 4,5 6,7 8,9 8,1 2,1 2),(7 6,5 4,3 2,1 2,3 4,7 6)))'));
  997. # must not crash
  998. SELECT 1 FROM t1 WHERE a <> (SELECT ST_GEOMETRYCOLLECTIONFROMWKB(b) FROM t1);
  999. ERROR HY000: Illegal parameter data types int and geometry for operation '<>'
  1000. DROP TABLE t1;
  1001. #
  1002. # Bug #49250 : spatial btree index corruption and crash
  1003. # Part one : spatial syntax check
  1004. #
  1005. CREATE TABLE t1(col1 MULTIPOLYGON NOT NULL,
  1006. SPATIAL INDEX USING BTREE (col1));
  1007. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE (col1))' at line 2
  1008. CREATE TABLE t2(col1 MULTIPOLYGON NOT NULL);
  1009. CREATE SPATIAL INDEX USING BTREE ON t2(col);
  1010. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE ON t2(col)' at line 1
  1011. ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1);
  1012. ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE (col1)' at line 1
  1013. DROP TABLE t2;
  1014. End of 5.0 tests
  1015. create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);
  1016. create view v1 as select * from t1;
  1017. desc v1;
  1018. Field Type Null Key Default Extra
  1019. f1 tinyint(1) YES NULL
  1020. f2 char(1) YES NULL
  1021. f3 varchar(1) YES NULL
  1022. f4 geometry YES NULL
  1023. f5 datetime YES NULL
  1024. drop view v1;
  1025. drop table t1;
  1026. SELECT MultiPoint(12345,'');
  1027. ERROR HY000: Illegal parameter data type int for operation 'multipoint'
  1028. SELECT 1 FROM (SELECT GREATEST(1,GEOMETRYCOLLECTION('00000','00000')) b FROM DUAL) AS d WHERE (LINESTRING(d.b));
  1029. ERROR HY000: Illegal parameter data type varchar for operation 'geometrycollection'
  1030. #
  1031. # BUG#51875: crash when loading data into geometry function ST_polyfromwkb
  1032. #
  1033. SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
  1034. SET @a=ST_POLYFROMWKB(@a);
  1035. SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
  1036. SET @a=ST_POLYFROMWKB(@a);
  1037. create table t1(a polygon NOT NULL)engine=InnoDB;
  1038. insert into t1 values (ST_geomfromtext("point(0 1)"));
  1039. ERROR 22007: Incorrect POLYGON value: 'POINT' for column `test`.`t1`.`a` at row 1
  1040. insert into t1 values (ST_geomfromtext("point(1 0)"));
  1041. ERROR 22007: Incorrect POLYGON value: 'POINT' for column `test`.`t1`.`a` at row 1
  1042. select * from (select polygon(t1.a) as p from t1 order by t1.a) d;
  1043. p
  1044. drop table t1;
  1045. #
  1046. # Test for bug #59888 "debug assertion when attempt to create spatial index
  1047. # on char > 31 bytes".
  1048. #
  1049. create table t1(a char(32) not null) engine=InnoDB;
  1050. create index i on t1 (a(5));
  1051. drop table t1;
  1052. End of 5.1 tests
  1053. CREATE TABLE t0 (a BINARY(32) NOT NULL);
  1054. CREATE UNIQUE INDEX i on t0 (a(10));
  1055. INSERT INTO t0 VALUES (1);
  1056. CREATE TABLE t1(
  1057. col0 BINARY NOT NULL,
  1058. col2 TIMESTAMP,
  1059. INDEX i1 (col0)
  1060. ) ENGINE=InnoDB;
  1061. CREATE TABLE t2 (
  1062. col0 BINARY NOT NULL,
  1063. col2 TIMESTAMP
  1064. ) ENGINE=InnoDB;
  1065. CREATE INDEX idx0 ON t1(col0);
  1066. Warnings:
  1067. Note 1831 Duplicate index `idx0`. This is deprecated and will be disallowed in a future release
  1068. CREATE TABLE t3 (
  1069. col0 INTEGER NOT NULL,
  1070. col1 POINT,
  1071. col2 POINT
  1072. );
  1073. CREATE SPATIAL INDEX idx0 ON t2 (col1, col2);
  1074. ERROR HY000: Incorrect arguments to SPATIAL INDEX
  1075. CREATE TABLE t4 (
  1076. col0 INTEGER NOT NULL,
  1077. col1 POINT,
  1078. col2 LINESTRING,
  1079. INDEX i1 (col1(5), col2(5))
  1080. );
  1081. DROP TABLE IF EXISTS t0, t1, t2, t3,t4;
  1082. #
  1083. # BUG#12414917 - ST_ISCLOSED() CRASHES ON 64-BIT BUILDS
  1084. #
  1085. SELECT ST_ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
  1086. ST_ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)))
  1087. -1
  1088. #
  1089. # BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
  1090. # GEOMETRY FUNCTION ARGUMENTS
  1091. #
  1092. SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
  1093. ERROR HY000: Illegal parameter data type bigint for operation 'geometrycollection'
  1094. End of 5.1 tests
  1095. #
  1096. # Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE
  1097. #
  1098. CREATE TABLE g1
  1099. (a geometry NOT NULL, UNIQUE KEY i (a(151))) engine=InnoDB;
  1100. INSERT INTO g1 VALUES (ST_geomfromtext('point(1 1)'));
  1101. INSERT INTO g1 VALUES (ST_geomfromtext('point(1 2)'));
  1102. FLUSH TABLES;
  1103. SELECT 1 FROM g1
  1104. FORCE INDEX(i) WHERE a = date_sub(now(), interval 2808.4 year_month)
  1105. ;
  1106. ERROR HY000: Illegal parameter data types geometry and datetime for operation '='
  1107. DROP TABLE g1;
  1108. #
  1109. # Bug#13013970 MORE CRASHES IN FIELD_BLOB::GET_KEY_IMAGE
  1110. #
  1111. CREATE TABLE g1(a TEXT NOT NULL, KEY(a(255)));
  1112. INSERT INTO g1 VALUES ('a'),('a');
  1113. SELECT 1 FROM g1 WHERE a >= ANY
  1114. (SELECT 1 FROM g1 WHERE a = ST_geomfromtext('') OR a) ;
  1115. 1
  1116. Warnings:
  1117. Warning 1292 Truncated incorrect DOUBLE value: 'a'
  1118. Warning 1292 Truncated incorrect DOUBLE value: 'a'
  1119. DROP TABLE g1;
  1120. End of 5.5 tests
  1121. DROP DATABASE IF EXISTS gis_ogs;
  1122. CREATE DATABASE gis_ogs;
  1123. USE gis_ogs;
  1124. #
  1125. # C.3.3.1 Geometry types and functions schema construction
  1126. #
  1127. CREATE TABLE lakes (
  1128. fid INTEGER NOT NULL PRIMARY KEY,
  1129. name CHARACTER VARYING(64),
  1130. shore POLYGON);
  1131. CREATE TABLE road_segments (
  1132. fid INTEGER NOT NULL PRIMARY KEY,
  1133. name CHARACTER VARYING(64),
  1134. aliases CHARACTER VARYING(64),
  1135. num_lanes INTEGER,
  1136. centerline LINESTRING);
  1137. CREATE TABLE divided_routes (
  1138. fid INTEGER NOT NULL PRIMARY KEY,
  1139. name CHARACTER VARYING(64),
  1140. num_lanes INTEGER,
  1141. centerlines MULTILINESTRING);
  1142. CREATE TABLE forests (
  1143. fid INTEGER NOT NULL PRIMARY KEY,
  1144. name CHARACTER VARYING(64),
  1145. boundary MULTIPOLYGON);
  1146. CREATE TABLE bridges (
  1147. fid INTEGER NOT NULL PRIMARY KEY,
  1148. name CHARACTER VARYING(64),
  1149. position POINT);
  1150. CREATE TABLE streams (
  1151. fid INTEGER NOT NULL PRIMARY KEY,
  1152. name CHARACTER VARYING(64),
  1153. centerline LINESTRING);
  1154. CREATE TABLE buildings (
  1155. fid INTEGER NOT NULL PRIMARY KEY,
  1156. address CHARACTER VARYING(64),
  1157. position POINT,
  1158. footprint POLYGON);
  1159. CREATE TABLE ponds (
  1160. fid INTEGER NOT NULL PRIMARY KEY,
  1161. name CHARACTER VARYING(64),
  1162. type CHARACTER VARYING(64),
  1163. shores MULTIPOLYGON);
  1164. CREATE TABLE named_places (
  1165. fid INTEGER NOT NULL PRIMARY KEY,
  1166. name CHARACTER VARYING(64),
  1167. boundary POLYGON);
  1168. CREATE TABLE map_neatlines (
  1169. fid INTEGER NOT NULL PRIMARY KEY,
  1170. neatline POLYGON);
  1171. #
  1172. # C.3.3.2 Geometry types and functions schema data loading
  1173. #
  1174. # Lakes
  1175. INSERT INTO lakes VALUES (
  1176. 101, 'BLUE LAKE',
  1177. ST_PolyFromText(
  1178. 'POLYGON(
  1179. (52 18,66 23,73 9,48 6,52 18),
  1180. (59 18,67 18,67 13,59 13,59 18)
  1181. )',
  1182. 101));
  1183. # Road Segments
  1184. INSERT INTO road_segments VALUES(102, 'Route 5', NULL, 2,
  1185. ST_LineFromText(
  1186. 'LINESTRING( 0 18, 10 21, 16 23, 28 26, 44 31 )' ,101));
  1187. INSERT INTO road_segments VALUES(103, 'Route 5', 'Main Street', 4,
  1188. ST_LineFromText(
  1189. 'LINESTRING( 44 31, 56 34, 70 38 )' ,101));
  1190. INSERT INTO road_segments VALUES(104, 'Route 5', NULL, 2,
  1191. ST_LineFromText(
  1192. 'LINESTRING( 70 38, 72 48 )' ,101));
  1193. INSERT INTO road_segments VALUES(105, 'Main Street', NULL, 4,
  1194. ST_LineFromText(
  1195. 'LINESTRING( 70 38, 84 42 )' ,101));
  1196. INSERT INTO road_segments VALUES(106, 'Dirt Road by Green Forest', NULL,
  1197. 1,
  1198. ST_LineFromText(
  1199. 'LINESTRING( 28 26, 28 0 )',101));
  1200. # DividedRoutes
  1201. INSERT INTO divided_routes VALUES(119, 'Route 75', 4,
  1202. ST_MLineFromText(
  1203. 'MULTILINESTRING((10 48,10 21,10 0),
  1204. (16 0,16 23,16 48))', 101));
  1205. # Forests
  1206. INSERT INTO forests VALUES(109, 'Green Forest',
  1207. ST_MPolyFromText(
  1208. 'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
  1209. (52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))',
  1210. 101));
  1211. # Bridges
  1212. INSERT INTO bridges VALUES(110, 'Cam Bridge', ST_PointFromText(
  1213. 'POINT( 44 31 )', 101));
  1214. # Streams
  1215. INSERT INTO streams VALUES(111, 'Cam Stream',
  1216. ST_LineFromText(
  1217. 'LINESTRING( 38 48, 44 41, 41 36, 44 31, 52 18 )', 101));
  1218. INSERT INTO streams VALUES(112, NULL,
  1219. ST_LineFromText(
  1220. 'LINESTRING( 76 0, 78 4, 73 9 )', 101));
  1221. # Buildings
  1222. INSERT INTO buildings VALUES(113, '123 Main Street',
  1223. ST_PointFromText(
  1224. 'POINT( 52 30 )', 101),
  1225. ST_PolyFromText(
  1226. 'POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )', 101));
  1227. INSERT INTO buildings VALUES(114, '215 Main Street',
  1228. ST_PointFromText(
  1229. 'POINT( 64 33 )', 101),
  1230. ST_PolyFromText(
  1231. 'POLYGON( ( 66 34, 62 34, 62 32, 66 32, 66 34) )', 101));
  1232. # Ponds
  1233. INSERT INTO ponds VALUES(120, NULL, 'Stock Pond',
  1234. ST_MPolyFromText(
  1235. 'MULTIPOLYGON( ( ( 24 44, 22 42, 24 40, 24 44) ),
  1236. ( ( 26 44, 26 40, 28 42, 26 44) ) )', 101));
  1237. # Named Places
  1238. INSERT INTO named_places VALUES(117, 'Ashton',
  1239. ST_PolyFromText(
  1240. 'POLYGON( ( 62 48, 84 48, 84 30, 56 30, 56 34, 62 48) )', 101));
  1241. INSERT INTO named_places VALUES(118, 'Goose Island',
  1242. ST_PolyFromText(
  1243. 'POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )', 101));
  1244. # Map Neatlines
  1245. INSERT INTO map_neatlines VALUES(115,
  1246. ST_PolyFromText(
  1247. 'POLYGON( ( 0 0, 0 48, 84 48, 84 0, 0 0 ) )', 101));
  1248. #
  1249. # C.3.3.3 Geometry types and functions schema test queries
  1250. # Conformance Item T6
  1251. SELECT ST_Dimension(shore)
  1252. FROM lakes
  1253. WHERE name = 'Blue Lake';
  1254. ST_Dimension(shore)
  1255. 2
  1256. # Conformance Item T7
  1257. SELECT ST_GeometryType(centerlines)
  1258. FROM divided_routes
  1259. WHERE name = 'Route 75';
  1260. ST_GeometryType(centerlines)
  1261. MULTILINESTRING
  1262. # Conformance Item T8
  1263. SELECT ST_AsText(boundary)
  1264. FROM named_places
  1265. WHERE name = 'Goose Island';
  1266. ST_AsText(boundary)
  1267. POLYGON((67 13,67 18,59 18,59 13,67 13))
  1268. # Conformance Item T9
  1269. SELECT ST_AsText(ST_PolyFromWKB(ST_AsBinary(boundary),101))
  1270. FROM named_places
  1271. WHERE name = 'Goose Island';
  1272. ST_AsText(ST_PolyFromWKB(ST_AsBinary(boundary),101))
  1273. POLYGON((67 13,67 18,59 18,59 13,67 13))
  1274. # Conformance Item T10
  1275. SELECT ST_SRID(boundary)
  1276. FROM named_places
  1277. WHERE name = 'Goose Island';
  1278. ST_SRID(boundary)
  1279. 101
  1280. # Conformance Item T11
  1281. SELECT ST_IsEmpty(centerline)
  1282. FROM road_segments
  1283. WHERE name = 'Route 5'
  1284. AND aliases = 'Main Street';
  1285. ST_IsEmpty(centerline)
  1286. 0
  1287. # Conformance Item T14
  1288. SELECT ST_AsText(ST_Envelope(boundary))
  1289. FROM named_places
  1290. WHERE name = 'Goose Island';
  1291. ST_AsText(ST_Envelope(boundary))
  1292. POLYGON((59 13,67 13,67 18,59 18,59 13))
  1293. # Conformance Item T15
  1294. SELECT ST_X(position)
  1295. FROM bridges
  1296. WHERE name = 'Cam Bridge';
  1297. ST_X(position)
  1298. 44
  1299. # Conformance Item T16
  1300. SELECT ST_Y(position)
  1301. FROM bridges
  1302. WHERE name = 'Cam Bridge';
  1303. ST_Y(position)
  1304. 31
  1305. # Conformance Item T17
  1306. SELECT ST_AsText(ST_StartPoint(centerline))
  1307. FROM road_segments
  1308. WHERE fid = 102;
  1309. ST_AsText(ST_StartPoint(centerline))
  1310. POINT(0 18)
  1311. # Conformance Item T18
  1312. SELECT ST_AsText(ST_EndPoint(centerline))
  1313. FROM road_segments
  1314. WHERE fid = 102;
  1315. ST_AsText(ST_EndPoint(centerline))
  1316. POINT(44 31)
  1317. # Conformance Item T21
  1318. SELECT ST_Length(centerline)
  1319. FROM road_segments
  1320. WHERE fid = 106;
  1321. ST_Length(centerline)
  1322. 26
  1323. # Conformance Item T22
  1324. SELECT ST_NumPoints(centerline)
  1325. FROM road_segments
  1326. WHERE fid = 102;
  1327. ST_NumPoints(centerline)
  1328. 5
  1329. # Conformance Item T23
  1330. SELECT ST_AsText(ST_PointN(centerline, 1))
  1331. FROM road_segments
  1332. WHERE fid = 102;
  1333. ST_AsText(ST_PointN(centerline, 1))
  1334. POINT(0 18)
  1335. # Conformance Item T24
  1336. SELECT ST_AsText(ST_Centroid(boundary))
  1337. FROM named_places
  1338. WHERE name = 'Goose Island';
  1339. ST_AsText(ST_Centroid(boundary))
  1340. POINT(63 15.5)
  1341. # Conformance Item T26
  1342. SELECT ST_Area(boundary)
  1343. FROM named_places
  1344. WHERE name = 'Goose Island';
  1345. ST_Area(boundary)
  1346. 40
  1347. # Conformance Item T27
  1348. SELECT ST_AsText(ST_ExteriorRing(shore))
  1349. FROM lakes
  1350. WHERE name = 'Blue Lake';
  1351. ST_AsText(ST_ExteriorRing(shore))
  1352. LINESTRING(52 18,66 23,73 9,48 6,52 18)
  1353. # Conformance Item T28
  1354. SELECT ST_NumInteriorRings(shore)
  1355. FROM lakes
  1356. WHERE name = 'Blue Lake';
  1357. ST_NumInteriorRings(shore)
  1358. 1
  1359. # Conformance Item T29
  1360. SELECT ST_AsText(ST_InteriorRingN(shore, 1))
  1361. FROM lakes
  1362. WHERE name = 'Blue Lake';
  1363. ST_AsText(ST_InteriorRingN(shore, 1))
  1364. LINESTRING(59 18,67 18,67 13,59 13,59 18)
  1365. # Conformance Item T30
  1366. SELECT ST_NumGeometries(centerlines)
  1367. FROM divided_routes
  1368. WHERE name = 'Route 75';
  1369. ST_NumGeometries(centerlines)
  1370. 2
  1371. # Conformance Item T31
  1372. SELECT ST_AsText(ST_GeometryN(centerlines, 2))
  1373. FROM divided_routes
  1374. WHERE name = 'Route 75';
  1375. ST_AsText(ST_GeometryN(centerlines, 2))
  1376. LINESTRING(16 0,16 23,16 48)
  1377. # Conformance Item T32
  1378. SELECT ST_IsClosed(centerlines)
  1379. FROM divided_routes
  1380. WHERE name = 'Route 75';
  1381. ST_IsClosed(centerlines)
  1382. 0
  1383. # Conformance Item T33
  1384. SELECT ST_Length(centerlines)
  1385. FROM divided_routes
  1386. WHERE name = 'Route 75';
  1387. ST_Length(centerlines)
  1388. 96
  1389. # Conformance Item T34
  1390. SELECT ST_AsText(ST_Centroid(shores))
  1391. FROM ponds
  1392. WHERE fid = 120;
  1393. ST_AsText(ST_Centroid(shores))
  1394. POINT(25 42)
  1395. # Conformance Item T36
  1396. SELECT ST_Area(shores)
  1397. FROM ponds
  1398. WHERE fid = 120;
  1399. ST_Area(shores)
  1400. 8
  1401. # Conformance Item T37
  1402. SELECT ST_Equals(boundary,
  1403. ST_PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
  1404. FROM named_places
  1405. WHERE name = 'Goose Island';
  1406. ST_Equals(boundary,
  1407. ST_PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
  1408. 1
  1409. # Conformance Item T37
  1410. # Geometry arguments' SRIDs must be identical.
  1411. SELECT ST_Equals(boundary,
  1412. ST_PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',101))
  1413. FROM named_places
  1414. WHERE name = 'Goose Island';
  1415. ST_Equals(boundary,
  1416. ST_PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',101))
  1417. 1
  1418. # Conformance Item T38
  1419. SELECT ST_Disjoint(centerlines, boundary)
  1420. FROM divided_routes, named_places
  1421. WHERE divided_routes.name = 'Route 75'
  1422. AND named_places.name = 'Ashton';
  1423. ST_Disjoint(centerlines, boundary)
  1424. 1
  1425. # Conformance Item T39
  1426. SELECT ST_Touches(centerline, shore)
  1427. FROM streams, lakes
  1428. WHERE streams.name = 'Cam Stream'
  1429. AND lakes.name = 'Blue Lake';
  1430. ST_Touches(centerline, shore)
  1431. 1
  1432. # Conformance Item T42
  1433. SELECT ST_Crosses(road_segments.centerline, divided_routes.centerlines)
  1434. FROM road_segments, divided_routes
  1435. WHERE road_segments.fid = 102
  1436. AND divided_routes.name = 'Route 75';
  1437. ST_Crosses(road_segments.centerline, divided_routes.centerlines)
  1438. 1
  1439. # Conformance Item T43
  1440. SELECT ST_Intersects(road_segments.centerline, divided_routes.centerlines)
  1441. FROM road_segments, divided_routes
  1442. WHERE road_segments.fid = 102
  1443. AND divided_routes.name = 'Route 75';
  1444. ST_Intersects(road_segments.centerline, divided_routes.centerlines)
  1445. 1
  1446. # Conformance Item T44
  1447. SELECT ST_Contains(forests.boundary, named_places.boundary)
  1448. FROM forests, named_places
  1449. WHERE forests.name = 'Green Forest'
  1450. AND named_places.name = 'Ashton';
  1451. ST_Contains(forests.boundary, named_places.boundary)
  1452. 0
  1453. # Conformance Item T46
  1454. SELECT ST_Distance(position, boundary)
  1455. FROM bridges, named_places
  1456. WHERE bridges.name = 'Cam Bridge'
  1457. AND named_places.name = 'Ashton';
  1458. ST_Distance(position, boundary)
  1459. 12
  1460. # Conformance Item T48
  1461. SELECT ST_AsText(ST_Difference(named_places.boundary, forests.boundary))
  1462. FROM named_places, forests
  1463. WHERE named_places.name = 'Ashton'
  1464. AND forests.name = 'Green Forest';
  1465. ST_AsText(ST_Difference(named_places.boundary, forests.boundary))
  1466. POLYGON((56 34,62 48,84 48,84 42,56 34))
  1467. SELECT ST_AsText(ST_Union(shore, boundary))
  1468. FROM lakes, named_places
  1469. WHERE lakes.name = 'Blue Lake'
  1470. AND named_places.name = 'Goose Island';
  1471. ST_AsText(ST_Union(shore, boundary))
  1472. POLYGON((48 6,52 18,66 23,73 9,48 6))
  1473. # Conformance Item T50
  1474. SELECT ST_AsText(ST_SymDifference(shore, boundary))
  1475. FROM lakes, named_places
  1476. WHERE lakes.name = 'Blue Lake'
  1477. AND named_places.name = 'Ashton';
  1478. ST_AsText(ST_SymDifference(shore, boundary))
  1479. MULTIPOLYGON(((48 6,52 18,66 23,73 9,48 6),(59 13,59 18,67 18,67 13,59 13)),((56 30,56 34,62 48,84 48,84 30,56 30)))
  1480. # Conformance Item T51
  1481. SELECT count(*)
  1482. FROM buildings, bridges
  1483. WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
  1484. count(*)
  1485. 1
  1486. DROP DATABASE gis_ogs;
  1487. #
  1488. # Bug#13362660 ASSERTION `FIELD_POS < FIELD_COUNT' FAILED. IN PROTOCOL_TEXT::STORE
  1489. #
  1490. SELECT ST_Union('', ''), md5(1);
  1491. ERROR HY000: Illegal parameter data type varchar for operation 'st_union'