mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
19bbb7cc85
Optimised version of ADD/DROP/REORGANIZE partitions for non-NDB storage engines. New syntax to handle REBUILD/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions Quite a few bug fixes include/thr_lock.h: New method to downgrade locks from TL_WRITE_ONLY Possibility to upgrade lock while aborting locks mysql-test/r/ndb_autodiscover.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_bitfield.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_gis.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_partition_key.result: New test case mysql-test/r/partition.result: New test case mysql-test/r/partition_error.result: New test case mysql-test/r/partition_mgm_err.result: Fix of test case results mysql-test/t/disabled.def: partition_03ndb still has bug mysql-test/t/ndb_partition_key.test: New test cases for new functionality and bugs mysql-test/t/partition.test: New test cases for new functionality and bugs mysql-test/t/partition_error.test: New test cases for new functionality and bugs mysql-test/t/partition_mgm_err.test: New test cases for new functionality and bugs mysys/thr_lock.c: New method to downgrade TL_WRITE_ONLY locks Possibility to specify if locks are to be upgraded at abort locks sql/ha_archive.cc: New handlerton methods sql/ha_berkeley.cc: New handlerton methods sql/ha_blackhole.cc: New handlerton methods sql/ha_federated.cc: New handlerton methods sql/ha_heap.cc: New handlerton methods sql/ha_innodb.cc: New handlerton methods sql/ha_myisam.cc: New handlerton methods sql/ha_myisammrg.cc: New handlerton methods sql/ha_ndbcluster.cc: New handlerton methods Moved out packfrm and unpackfrm methods Adapted many parts to use table_share instead of table->s Ensured that .ndb file uses filename and not tablename according to new encoding of names (WL 1324) All NDB tables are partitioned and set up partition info Fixed such that tablenames use tablenames and not filenames in NDB NDB uses auto partitioning for ENGINE=NDB tables Warning for very large tables Set RANGE data Set LIST data New method to set-up partition info Set Default number of partitions flag Set linear hash flag Set node group array Set number of fragments Set max rows Set tablespace names New method to get number of partitions of table to use at open table sql/ha_ndbcluster.h: Removed partition_flags and alter_table_flags from handler class A couple of new and changed method headers sql/ha_ndbcluster_binlog.cc: Use new method headers sql/ha_partition.cc: New handlerton methods Lots of new function headers Use #P# as separator between table name and partition name and #SP# as separator between partition name and subpartition name Use filename encoding for files both of table name part and of partition name parts New method to drop partitions based on partition state New method to rename partitions based on partition state New methods to optimize, analyze, check and repair partitions New methods to optimize, analyze, check and repair table Helper method to create new partition, open it and external lock it, not needed to lock it internally since no one else knows about it yet. Cleanup method at error for new partitions New methods to perform bulk of work at ADD/REORGANIZE partitions (change_partitions, copy_partitions) sql/ha_partition.h: New methods and variables A few dropped ones and a few changed ones sql/handler.cc: Handlerton interface changes New flag to open_table_from_share sql/handler.h: New alter_table_flags New partition flags New partition states More states for default handling Lots of new, dropped and changed interfaces sql/lex.h: Added REBUILD and changed name of REORGANISE to REORGANIZE sql/lock.cc: Method to downgrade locks Able to specify if locks upgraded on abort locks sql/log.cc: New handlerton methods sql/mysql_priv.h: Lots of new interfaces sql/share/errmsg.txt: Lots of new, dropped and changed error messages sql/sql_base.cc: Adapted to new method headers New method to abort and upgrade lock New method to close open tables and downgrade lock New method to wait for completed table sql/sql_lex.h: New flags sql/sql_partition.cc: Return int instead of bool in get_partition_id More defaults handling Make use of new mem_alloc_error method More work on function headers Changes to generate partition syntax to cater for intermediate partition states Lots of new code with large comments describing new features for Partition Management: ADD/DROP/REORGANIZE/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions sql/sql_show.cc: Minors sql/sql_table.cc: Moved a couple of methods New methods to copy create lists and key lists for use with mysql_prepare_table New method to write frm file New handling of handlers with auto partitioning Fix CREATE TABLE LIKE Moved code for ADD/DROP/REORGANIZE partitions Use handlerton method for alter_table_flags sql/sql_yacc.yy: More memory alloc error checks New syntax for REBUILD, ANALYZE, CHECK, OPTIMIZE, REPAIR partitions sql/table.cc: Fix length of extra part to be 4 bytes Partition state introduced in frm file sql/table.h: Partition state introduced sql/unireg.cc: Partition state introduced Default partition storage/csv/ha_tina.cc: New handlerton methods storage/example/ha_example.cc: New handlerton methods storage/ndb/include/kernel/ndb_limits.h: RANGE DATA storage/ndb/include/kernel/signaldata/AlterTable.hpp: New interfaces in ALTER TABLE towards NDB kernel storage/ndb/include/kernel/signaldata/DiAddTab.hpp: New section storage/ndb/include/kernel/signaldata/DictTabInfo.hpp: Lots of new parts of table description storage/ndb/include/kernel/signaldata/LqhFrag.hpp: tablespace id specified in LQHFRAGREQ storage/ndb/include/ndbapi/NdbDictionary.hpp: Lots of new methods in NDB dictionary storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: New error insertion storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: a few extra jam's storage/ndb/src/ndbapi/NdbBlob.cpp: Changes to definition of blob tables storage/ndb/src/ndbapi/NdbDictionary.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Lots of new stuff in NDB dictionary storage/ndb/test/ndbapi/test_event.cpp: removed use of methods no longer in existence storage/ndb/tools/restore/Restore.cpp: Renamed variable
916 lines
34 KiB
Text
916 lines
34 KiB
Text
SET storage_engine=ndbcluster;
|
|
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
|
|
CREATE TABLE gis_point (fid INTEGER, g POINT);
|
|
CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
|
|
CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
|
|
CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
|
|
CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
|
|
CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
|
|
CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
|
|
CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
|
|
SHOW CREATE TABLE gis_point;
|
|
Table Create Table
|
|
gis_point CREATE TABLE `gis_point` (
|
|
`fid` int(11) default NULL,
|
|
`g` point default NULL
|
|
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
|
SHOW FIELDS FROM gis_point;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g point YES NULL
|
|
SHOW FIELDS FROM gis_line;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g linestring YES NULL
|
|
SHOW FIELDS FROM gis_polygon;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g polygon YES NULL
|
|
SHOW FIELDS FROM gis_multi_point;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g multipoint YES NULL
|
|
SHOW FIELDS FROM gis_multi_line;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g multilinestring YES NULL
|
|
SHOW FIELDS FROM gis_multi_polygon;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g multipolygon YES NULL
|
|
SHOW FIELDS FROM gis_geometrycollection;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g geometrycollection YES NULL
|
|
SHOW FIELDS FROM gis_geometry;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g geometry YES NULL
|
|
INSERT INTO gis_point VALUES
|
|
(101, PointFromText('POINT(10 10)')),
|
|
(102, PointFromText('POINT(20 10)')),
|
|
(103, PointFromText('POINT(20 20)')),
|
|
(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
|
|
INSERT INTO gis_line VALUES
|
|
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
|
|
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
|
|
(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
|
|
INSERT INTO gis_polygon VALUES
|
|
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
|
|
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
|
|
(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
|
|
INSERT INTO gis_multi_point VALUES
|
|
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
|
|
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
|
|
(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
|
|
INSERT INTO gis_multi_line VALUES
|
|
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
|
|
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
|
|
(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
|
|
INSERT INTO gis_multi_polygon VALUES
|
|
(117, 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)))')),
|
|
(118, 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)))')),
|
|
(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
|
|
INSERT INTO gis_geometrycollection VALUES
|
|
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
|
|
(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
|
|
INSERT into gis_geometry SELECT * FROM gis_point;
|
|
INSERT into gis_geometry SELECT * FROM gis_line;
|
|
INSERT into gis_geometry SELECT * FROM gis_polygon;
|
|
INSERT into gis_geometry SELECT * FROM gis_multi_point;
|
|
INSERT into gis_geometry SELECT * FROM gis_multi_line;
|
|
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
|
|
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
|
|
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
|
|
fid AsText(g)
|
|
101 POINT(10 10)
|
|
102 POINT(20 10)
|
|
103 POINT(20 20)
|
|
104 POINT(10 20)
|
|
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
|
|
fid AsText(g)
|
|
105 LINESTRING(0 0,0 10,10 0)
|
|
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
107 LINESTRING(10 10,40 10)
|
|
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
|
|
fid AsText(g)
|
|
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
|
|
110 POLYGON((0 0,30 0,30 30,0 0))
|
|
SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid;
|
|
fid AsText(g)
|
|
111 MULTIPOINT(0 0,10 10,10 20,20 20)
|
|
112 MULTIPOINT(1 1,11 11,11 21,21 21)
|
|
113 MULTIPOINT(3 6,4 10)
|
|
SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid;
|
|
fid AsText(g)
|
|
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
|
|
115 MULTILINESTRING((10 48,10 21,10 0))
|
|
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
|
|
SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid;
|
|
fid AsText(g)
|
|
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)))
|
|
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)))
|
|
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
|
|
SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid;
|
|
fid AsText(g)
|
|
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
|
|
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
|
|
SELECT fid, AsText(g) FROM gis_geometry ORDER by fid;
|
|
fid AsText(g)
|
|
101 POINT(10 10)
|
|
102 POINT(20 10)
|
|
103 POINT(20 20)
|
|
104 POINT(10 20)
|
|
105 LINESTRING(0 0,0 10,10 0)
|
|
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
107 LINESTRING(10 10,40 10)
|
|
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
|
|
110 POLYGON((0 0,30 0,30 30,0 0))
|
|
111 MULTIPOINT(0 0,10 10,10 20,20 20)
|
|
112 MULTIPOINT(1 1,11 11,11 21,21 21)
|
|
113 MULTIPOINT(3 6,4 10)
|
|
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
|
|
115 MULTILINESTRING((10 48,10 21,10 0))
|
|
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
|
|
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)))
|
|
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)))
|
|
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
|
|
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
|
|
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
|
|
SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid;
|
|
fid Dimension(g)
|
|
101 0
|
|
102 0
|
|
103 0
|
|
104 0
|
|
105 1
|
|
106 1
|
|
107 1
|
|
108 2
|
|
109 2
|
|
110 2
|
|
111 0
|
|
112 0
|
|
113 0
|
|
114 1
|
|
115 1
|
|
116 1
|
|
117 2
|
|
118 2
|
|
119 2
|
|
120 1
|
|
121 1
|
|
SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid;
|
|
fid GeometryType(g)
|
|
101 POINT
|
|
102 POINT
|
|
103 POINT
|
|
104 POINT
|
|
105 LINESTRING
|
|
106 LINESTRING
|
|
107 LINESTRING
|
|
108 POLYGON
|
|
109 POLYGON
|
|
110 POLYGON
|
|
111 MULTIPOINT
|
|
112 MULTIPOINT
|
|
113 MULTIPOINT
|
|
114 MULTILINESTRING
|
|
115 MULTILINESTRING
|
|
116 MULTILINESTRING
|
|
117 MULTIPOLYGON
|
|
118 MULTIPOLYGON
|
|
119 MULTIPOLYGON
|
|
120 GEOMETRYCOLLECTION
|
|
121 GEOMETRYCOLLECTION
|
|
SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid;
|
|
fid IsEmpty(g)
|
|
101 0
|
|
102 0
|
|
103 0
|
|
104 0
|
|
105 0
|
|
106 0
|
|
107 0
|
|
108 0
|
|
109 0
|
|
110 0
|
|
111 0
|
|
112 0
|
|
113 0
|
|
114 0
|
|
115 0
|
|
116 0
|
|
117 0
|
|
118 0
|
|
119 0
|
|
120 0
|
|
121 0
|
|
SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid;
|
|
fid AsText(Envelope(g))
|
|
101 POLYGON((10 10,10 10,10 10,10 10,10 10))
|
|
102 POLYGON((20 10,20 10,20 10,20 10,20 10))
|
|
103 POLYGON((20 20,20 20,20 20,20 20,20 20))
|
|
104 POLYGON((10 20,10 20,10 20,10 20,10 20))
|
|
105 POLYGON((0 0,10 0,10 10,0 10,0 0))
|
|
106 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
107 POLYGON((10 10,40 10,40 10,10 10,10 10))
|
|
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
109 POLYGON((0 0,50 0,50 50,0 50,0 0))
|
|
110 POLYGON((0 0,30 0,30 30,0 30,0 0))
|
|
111 POLYGON((0 0,20 0,20 20,0 20,0 0))
|
|
112 POLYGON((1 1,21 1,21 21,1 21,1 1))
|
|
113 POLYGON((3 6,4 6,4 10,3 10,3 6))
|
|
114 POLYGON((10 0,16 0,16 48,10 48,10 0))
|
|
115 POLYGON((10 0,10 0,10 48,10 48,10 0))
|
|
116 POLYGON((1 2,21 2,21 8,1 8,1 2))
|
|
117 POLYGON((28 0,84 0,84 42,28 42,28 0))
|
|
118 POLYGON((28 0,84 0,84 42,28 42,28 0))
|
|
119 POLYGON((0 0,3 0,3 3,0 3,0 0))
|
|
120 POLYGON((0 0,10 0,10 10,0 10,0 0))
|
|
121 POLYGON((3 6,44 6,44 9,3 9,3 6))
|
|
explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21
|
|
Warnings:
|
|
Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
|
|
SELECT fid, X(g) FROM gis_point ORDER by fid;
|
|
fid X(g)
|
|
101 10
|
|
102 20
|
|
103 20
|
|
104 10
|
|
SELECT fid, Y(g) FROM gis_point ORDER by fid;
|
|
fid Y(g)
|
|
101 10
|
|
102 10
|
|
103 20
|
|
104 20
|
|
explain extended select X(g),Y(g) FROM gis_point;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4
|
|
Warnings:
|
|
Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
|
|
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
|
|
fid AsText(StartPoint(g))
|
|
105 POINT(0 0)
|
|
106 POINT(10 10)
|
|
107 POINT(10 10)
|
|
SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid;
|
|
fid AsText(EndPoint(g))
|
|
105 POINT(10 0)
|
|
106 POINT(10 10)
|
|
107 POINT(40 10)
|
|
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
|
|
fid GLength(g)
|
|
105 24.142135623731
|
|
106 40
|
|
107 30
|
|
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
|
|
fid NumPoints(g)
|
|
105 3
|
|
106 5
|
|
107 2
|
|
SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid;
|
|
fid AsText(PointN(g, 2))
|
|
105 POINT(0 10)
|
|
106 POINT(20 10)
|
|
107 POINT(40 10)
|
|
SELECT fid, IsClosed(g) FROM gis_line ORDER by fid;
|
|
fid IsClosed(g)
|
|
105 0
|
|
106 1
|
|
107 0
|
|
explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
|
|
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
|
|
fid AsText(Centroid(g))
|
|
108 POINT(15 15)
|
|
109 POINT(25.416666666667 25.416666666667)
|
|
110 POINT(20 10)
|
|
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
|
|
fid Area(g)
|
|
108 100
|
|
109 2400
|
|
110 450
|
|
SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid;
|
|
fid AsText(ExteriorRing(g))
|
|
108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
|
|
110 LINESTRING(0 0,30 0,30 30,0 0)
|
|
SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid;
|
|
fid NumInteriorRings(g)
|
|
108 0
|
|
109 1
|
|
110 0
|
|
SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid;
|
|
fid AsText(InteriorRingN(g, 1))
|
|
108 NULL
|
|
109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
110 NULL
|
|
explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
|
|
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
|
|
fid IsClosed(g)
|
|
114 0
|
|
115 0
|
|
116 0
|
|
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
|
|
fid AsText(Centroid(g))
|
|
117 POINT(55.588527753042 17.426536064114)
|
|
118 POINT(55.588527753042 17.426536064114)
|
|
119 POINT(2 2)
|
|
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
|
|
fid Area(g)
|
|
117 1684.5
|
|
118 1684.5
|
|
119 4.5
|
|
SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid;
|
|
fid NumGeometries(g)
|
|
111 4
|
|
112 4
|
|
113 2
|
|
SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid;
|
|
fid NumGeometries(g)
|
|
114 2
|
|
115 1
|
|
116 2
|
|
SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid;
|
|
fid NumGeometries(g)
|
|
117 2
|
|
118 2
|
|
119 1
|
|
SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid;
|
|
fid NumGeometries(g)
|
|
120 2
|
|
121 2
|
|
explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
111 POINT(10 10)
|
|
112 POINT(11 11)
|
|
113 POINT(4 10)
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
114 LINESTRING(16 0,16 23,16 48)
|
|
115 NULL
|
|
116 LINESTRING(2 5,5 8,21 7)
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
117 POLYGON((59 18,67 18,67 13,59 13,59 18))
|
|
118 POLYGON((59 18,67 18,67 13,59 13,59 18))
|
|
119 NULL
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
120 LINESTRING(0 0,10 10)
|
|
121 LINESTRING(3 6,7 9)
|
|
SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid;
|
|
fid AsText(GeometryN(g, 1))
|
|
120 POINT(0 0)
|
|
121 POINT(44 6)
|
|
explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
|
|
SELECT g1.fid as first, g2.fid as second,
|
|
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
|
|
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
|
|
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
|
|
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
|
|
first second w c o e d t i r
|
|
120 120 1 1 0 1 0 0 1 0
|
|
120 121 0 0 0 0 0 0 1 0
|
|
121 120 0 0 1 0 0 0 1 0
|
|
121 121 1 1 0 1 0 0 1 0
|
|
explain extended SELECT g1.fid as first, g2.fid as second,
|
|
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
|
|
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
|
|
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
|
|
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
|
1 SIMPLE g2 ALL NULL NULL NULL NULL 2
|
|
Warnings:
|
|
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,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`
|
|
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
|
|
CREATE TABLE t1 (
|
|
gp point,
|
|
ln linestring,
|
|
pg polygon,
|
|
mp multipoint,
|
|
mln multilinestring,
|
|
mpg multipolygon,
|
|
gc geometrycollection,
|
|
gm geometry
|
|
);
|
|
SHOW FIELDS FROM t1;
|
|
Field Type Null Key Default Extra
|
|
gp point YES NULL
|
|
ln linestring YES NULL
|
|
pg polygon YES NULL
|
|
mp multipoint YES NULL
|
|
mln multilinestring YES NULL
|
|
mpg multipolygon YES NULL
|
|
gc geometrycollection YES NULL
|
|
gm geometry YES NULL
|
|
ALTER TABLE t1 ADD fid INT;
|
|
SHOW FIELDS FROM t1;
|
|
Field Type Null Key Default Extra
|
|
gp point YES NULL
|
|
ln linestring YES NULL
|
|
pg polygon YES NULL
|
|
mp multipoint YES NULL
|
|
mln multilinestring YES NULL
|
|
mpg multipolygon YES NULL
|
|
gc geometrycollection YES NULL
|
|
gm geometry YES NULL
|
|
fid int(11) YES NULL
|
|
DROP TABLE t1;
|
|
create table t1 (a geometry not null);
|
|
insert into t1 values (GeomFromText('Point(1 2)'));
|
|
insert into t1 values ('Garbage');
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert IGNORE into t1 values ('Garbage');
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
drop table t1;
|
|
create table t1 (fl geometry);
|
|
insert into t1 values (1);
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert into t1 values (1.11);
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert into t1 values ("qwerty");
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert into t1 values (pointfromtext('point(1,1)'));
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
drop table t1;
|
|
set engine_condition_pushdown = on;
|
|
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
|
|
CREATE TABLE gis_point (fid INTEGER, g POINT);
|
|
CREATE TABLE gis_line (fid INTEGER, g LINESTRING);
|
|
CREATE TABLE gis_polygon (fid INTEGER, g POLYGON);
|
|
CREATE TABLE gis_multi_point (fid INTEGER, g MULTIPOINT);
|
|
CREATE TABLE gis_multi_line (fid INTEGER, g MULTILINESTRING);
|
|
CREATE TABLE gis_multi_polygon (fid INTEGER, g MULTIPOLYGON);
|
|
CREATE TABLE gis_geometrycollection (fid INTEGER, g GEOMETRYCOLLECTION);
|
|
CREATE TABLE gis_geometry (fid INTEGER, g GEOMETRY);
|
|
SHOW CREATE TABLE gis_point;
|
|
Table Create Table
|
|
gis_point CREATE TABLE `gis_point` (
|
|
`fid` int(11) default NULL,
|
|
`g` point default NULL
|
|
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
|
|
SHOW FIELDS FROM gis_point;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g point YES NULL
|
|
SHOW FIELDS FROM gis_line;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g linestring YES NULL
|
|
SHOW FIELDS FROM gis_polygon;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g polygon YES NULL
|
|
SHOW FIELDS FROM gis_multi_point;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g multipoint YES NULL
|
|
SHOW FIELDS FROM gis_multi_line;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g multilinestring YES NULL
|
|
SHOW FIELDS FROM gis_multi_polygon;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g multipolygon YES NULL
|
|
SHOW FIELDS FROM gis_geometrycollection;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g geometrycollection YES NULL
|
|
SHOW FIELDS FROM gis_geometry;
|
|
Field Type Null Key Default Extra
|
|
fid int(11) YES NULL
|
|
g geometry YES NULL
|
|
INSERT INTO gis_point VALUES
|
|
(101, PointFromText('POINT(10 10)')),
|
|
(102, PointFromText('POINT(20 10)')),
|
|
(103, PointFromText('POINT(20 20)')),
|
|
(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
|
|
INSERT INTO gis_line VALUES
|
|
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
|
|
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
|
|
(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
|
|
INSERT INTO gis_polygon VALUES
|
|
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
|
|
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
|
|
(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
|
|
INSERT INTO gis_multi_point VALUES
|
|
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
|
|
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
|
|
(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
|
|
INSERT INTO gis_multi_line VALUES
|
|
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
|
|
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
|
|
(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
|
|
INSERT INTO gis_multi_polygon VALUES
|
|
(117, 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)))')),
|
|
(118, 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)))')),
|
|
(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
|
|
INSERT INTO gis_geometrycollection VALUES
|
|
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
|
|
(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
|
|
INSERT into gis_geometry SELECT * FROM gis_point;
|
|
INSERT into gis_geometry SELECT * FROM gis_line;
|
|
INSERT into gis_geometry SELECT * FROM gis_polygon;
|
|
INSERT into gis_geometry SELECT * FROM gis_multi_point;
|
|
INSERT into gis_geometry SELECT * FROM gis_multi_line;
|
|
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
|
|
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
|
|
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
|
|
fid AsText(g)
|
|
101 POINT(10 10)
|
|
102 POINT(20 10)
|
|
103 POINT(20 20)
|
|
104 POINT(10 20)
|
|
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
|
|
fid AsText(g)
|
|
105 LINESTRING(0 0,0 10,10 0)
|
|
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
107 LINESTRING(10 10,40 10)
|
|
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
|
|
fid AsText(g)
|
|
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
|
|
110 POLYGON((0 0,30 0,30 30,0 0))
|
|
SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid;
|
|
fid AsText(g)
|
|
111 MULTIPOINT(0 0,10 10,10 20,20 20)
|
|
112 MULTIPOINT(1 1,11 11,11 21,21 21)
|
|
113 MULTIPOINT(3 6,4 10)
|
|
SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid;
|
|
fid AsText(g)
|
|
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
|
|
115 MULTILINESTRING((10 48,10 21,10 0))
|
|
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
|
|
SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid;
|
|
fid AsText(g)
|
|
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)))
|
|
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)))
|
|
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
|
|
SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid;
|
|
fid AsText(g)
|
|
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
|
|
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
|
|
SELECT fid, AsText(g) FROM gis_geometry ORDER by fid;
|
|
fid AsText(g)
|
|
101 POINT(10 10)
|
|
102 POINT(20 10)
|
|
103 POINT(20 20)
|
|
104 POINT(10 20)
|
|
105 LINESTRING(0 0,0 10,10 0)
|
|
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
107 LINESTRING(10 10,40 10)
|
|
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
|
|
110 POLYGON((0 0,30 0,30 30,0 0))
|
|
111 MULTIPOINT(0 0,10 10,10 20,20 20)
|
|
112 MULTIPOINT(1 1,11 11,11 21,21 21)
|
|
113 MULTIPOINT(3 6,4 10)
|
|
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
|
|
115 MULTILINESTRING((10 48,10 21,10 0))
|
|
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
|
|
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)))
|
|
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)))
|
|
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
|
|
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
|
|
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
|
|
SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid;
|
|
fid Dimension(g)
|
|
101 0
|
|
102 0
|
|
103 0
|
|
104 0
|
|
105 1
|
|
106 1
|
|
107 1
|
|
108 2
|
|
109 2
|
|
110 2
|
|
111 0
|
|
112 0
|
|
113 0
|
|
114 1
|
|
115 1
|
|
116 1
|
|
117 2
|
|
118 2
|
|
119 2
|
|
120 1
|
|
121 1
|
|
SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid;
|
|
fid GeometryType(g)
|
|
101 POINT
|
|
102 POINT
|
|
103 POINT
|
|
104 POINT
|
|
105 LINESTRING
|
|
106 LINESTRING
|
|
107 LINESTRING
|
|
108 POLYGON
|
|
109 POLYGON
|
|
110 POLYGON
|
|
111 MULTIPOINT
|
|
112 MULTIPOINT
|
|
113 MULTIPOINT
|
|
114 MULTILINESTRING
|
|
115 MULTILINESTRING
|
|
116 MULTILINESTRING
|
|
117 MULTIPOLYGON
|
|
118 MULTIPOLYGON
|
|
119 MULTIPOLYGON
|
|
120 GEOMETRYCOLLECTION
|
|
121 GEOMETRYCOLLECTION
|
|
SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid;
|
|
fid IsEmpty(g)
|
|
101 0
|
|
102 0
|
|
103 0
|
|
104 0
|
|
105 0
|
|
106 0
|
|
107 0
|
|
108 0
|
|
109 0
|
|
110 0
|
|
111 0
|
|
112 0
|
|
113 0
|
|
114 0
|
|
115 0
|
|
116 0
|
|
117 0
|
|
118 0
|
|
119 0
|
|
120 0
|
|
121 0
|
|
SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid;
|
|
fid AsText(Envelope(g))
|
|
101 POLYGON((10 10,10 10,10 10,10 10,10 10))
|
|
102 POLYGON((20 10,20 10,20 10,20 10,20 10))
|
|
103 POLYGON((20 20,20 20,20 20,20 20,20 20))
|
|
104 POLYGON((10 20,10 20,10 20,10 20,10 20))
|
|
105 POLYGON((0 0,10 0,10 10,0 10,0 0))
|
|
106 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
107 POLYGON((10 10,40 10,40 10,10 10,10 10))
|
|
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
|
|
109 POLYGON((0 0,50 0,50 50,0 50,0 0))
|
|
110 POLYGON((0 0,30 0,30 30,0 30,0 0))
|
|
111 POLYGON((0 0,20 0,20 20,0 20,0 0))
|
|
112 POLYGON((1 1,21 1,21 21,1 21,1 1))
|
|
113 POLYGON((3 6,4 6,4 10,3 10,3 6))
|
|
114 POLYGON((10 0,16 0,16 48,10 48,10 0))
|
|
115 POLYGON((10 0,10 0,10 48,10 48,10 0))
|
|
116 POLYGON((1 2,21 2,21 8,1 8,1 2))
|
|
117 POLYGON((28 0,84 0,84 42,28 42,28 0))
|
|
118 POLYGON((28 0,84 0,84 42,28 42,28 0))
|
|
119 POLYGON((0 0,3 0,3 3,0 3,0 0))
|
|
120 POLYGON((0 0,10 0,10 10,0 10,0 0))
|
|
121 POLYGON((3 6,44 6,44 9,3 9,3 6))
|
|
explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21
|
|
Warnings:
|
|
Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
|
|
SELECT fid, X(g) FROM gis_point ORDER by fid;
|
|
fid X(g)
|
|
101 10
|
|
102 20
|
|
103 20
|
|
104 10
|
|
SELECT fid, Y(g) FROM gis_point ORDER by fid;
|
|
fid Y(g)
|
|
101 10
|
|
102 10
|
|
103 20
|
|
104 20
|
|
explain extended select X(g),Y(g) FROM gis_point;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4
|
|
Warnings:
|
|
Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
|
|
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
|
|
fid AsText(StartPoint(g))
|
|
105 POINT(0 0)
|
|
106 POINT(10 10)
|
|
107 POINT(10 10)
|
|
SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid;
|
|
fid AsText(EndPoint(g))
|
|
105 POINT(10 0)
|
|
106 POINT(10 10)
|
|
107 POINT(40 10)
|
|
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
|
|
fid GLength(g)
|
|
105 24.142135623731
|
|
106 40
|
|
107 30
|
|
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
|
|
fid NumPoints(g)
|
|
105 3
|
|
106 5
|
|
107 2
|
|
SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid;
|
|
fid AsText(PointN(g, 2))
|
|
105 POINT(0 10)
|
|
106 POINT(20 10)
|
|
107 POINT(40 10)
|
|
SELECT fid, IsClosed(g) FROM gis_line ORDER by fid;
|
|
fid IsClosed(g)
|
|
105 0
|
|
106 1
|
|
107 0
|
|
explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
|
|
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
|
|
fid AsText(Centroid(g))
|
|
108 POINT(15 15)
|
|
109 POINT(25.416666666667 25.416666666667)
|
|
110 POINT(20 10)
|
|
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
|
|
fid Area(g)
|
|
108 100
|
|
109 2400
|
|
110 450
|
|
SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid;
|
|
fid AsText(ExteriorRing(g))
|
|
108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
|
|
110 LINESTRING(0 0,30 0,30 30,0 0)
|
|
SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid;
|
|
fid NumInteriorRings(g)
|
|
108 0
|
|
109 1
|
|
110 0
|
|
SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid;
|
|
fid AsText(InteriorRingN(g, 1))
|
|
108 NULL
|
|
109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
|
110 NULL
|
|
explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
|
|
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
|
|
fid IsClosed(g)
|
|
114 0
|
|
115 0
|
|
116 0
|
|
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
|
|
fid AsText(Centroid(g))
|
|
117 POINT(55.588527753042 17.426536064114)
|
|
118 POINT(55.588527753042 17.426536064114)
|
|
119 POINT(2 2)
|
|
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
|
|
fid Area(g)
|
|
117 1684.5
|
|
118 1684.5
|
|
119 4.5
|
|
SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid;
|
|
fid NumGeometries(g)
|
|
111 4
|
|
112 4
|
|
113 2
|
|
SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid;
|
|
fid NumGeometries(g)
|
|
114 2
|
|
115 1
|
|
116 2
|
|
SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid;
|
|
fid NumGeometries(g)
|
|
117 2
|
|
118 2
|
|
119 1
|
|
SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid;
|
|
fid NumGeometries(g)
|
|
120 2
|
|
121 2
|
|
explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
111 POINT(10 10)
|
|
112 POINT(11 11)
|
|
113 POINT(4 10)
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
114 LINESTRING(16 0,16 23,16 48)
|
|
115 NULL
|
|
116 LINESTRING(2 5,5 8,21 7)
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
117 POLYGON((59 18,67 18,67 13,59 13,59 18))
|
|
118 POLYGON((59 18,67 18,67 13,59 13,59 18))
|
|
119 NULL
|
|
SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid;
|
|
fid AsText(GeometryN(g, 2))
|
|
120 LINESTRING(0 0,10 10)
|
|
121 LINESTRING(3 6,7 9)
|
|
SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid;
|
|
fid AsText(GeometryN(g, 1))
|
|
120 POINT(0 0)
|
|
121 POINT(44 6)
|
|
explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3
|
|
Warnings:
|
|
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
|
|
SELECT g1.fid as first, g2.fid as second,
|
|
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
|
|
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
|
|
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
|
|
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
|
|
first second w c o e d t i r
|
|
120 120 1 1 0 1 0 0 1 0
|
|
120 121 0 0 0 0 0 0 1 0
|
|
121 120 0 0 1 0 0 0 1 0
|
|
121 121 1 1 0 1 0 0 1 0
|
|
explain extended SELECT g1.fid as first, g2.fid as second,
|
|
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
|
|
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
|
|
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
|
|
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
|
1 SIMPLE g2 ALL NULL NULL NULL NULL 2
|
|
Warnings:
|
|
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,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`
|
|
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
|
|
CREATE TABLE t1 (
|
|
gp point,
|
|
ln linestring,
|
|
pg polygon,
|
|
mp multipoint,
|
|
mln multilinestring,
|
|
mpg multipolygon,
|
|
gc geometrycollection,
|
|
gm geometry
|
|
);
|
|
SHOW FIELDS FROM t1;
|
|
Field Type Null Key Default Extra
|
|
gp point YES NULL
|
|
ln linestring YES NULL
|
|
pg polygon YES NULL
|
|
mp multipoint YES NULL
|
|
mln multilinestring YES NULL
|
|
mpg multipolygon YES NULL
|
|
gc geometrycollection YES NULL
|
|
gm geometry YES NULL
|
|
ALTER TABLE t1 ADD fid INT;
|
|
SHOW FIELDS FROM t1;
|
|
Field Type Null Key Default Extra
|
|
gp point YES NULL
|
|
ln linestring YES NULL
|
|
pg polygon YES NULL
|
|
mp multipoint YES NULL
|
|
mln multilinestring YES NULL
|
|
mpg multipolygon YES NULL
|
|
gc geometrycollection YES NULL
|
|
gm geometry YES NULL
|
|
fid int(11) YES NULL
|
|
DROP TABLE t1;
|
|
create table t1 (a geometry not null);
|
|
insert into t1 values (GeomFromText('Point(1 2)'));
|
|
insert into t1 values ('Garbage');
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert IGNORE into t1 values ('Garbage');
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
drop table t1;
|
|
create table t1 (fl geometry);
|
|
insert into t1 values (1);
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert into t1 values (1.11);
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert into t1 values ("qwerty");
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
insert into t1 values (pointfromtext('point(1,1)'));
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
drop table t1;
|