mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 17:33:44 +01:00
16845a71aa
This gives the handler more optimization possiblities and is needed for NDB cluster Fixed not-initialized memory error detected by valgrind mysql-test/mysql-test-run.sh: Fixed address to manual page mysql-test/r/gis-rtree.result: Added test to show fatal error in GIS mysql-test/r/grant.result: New tests mysql-test/t/gis-rtree.test: New tests mysql-test/t/grant.test: New tests sql/handler.cc: Moved reading of ranges from opt_range.cc to handler.cc This gives the handler more optimization possiblities and is needed for NDB cluster sql/handler.h: Moved reading of ranges from opt_range.cc to handler.cc T sql/opt_range.cc: Moved reading of ranges from opt_range.cc to handler.cc Simplified GIS get_next() handling Indentation cleanups sql/opt_range.h: Removed not needed cmp_next() Added new QUICK_SELECT method for GIS keys to make code for normal keys easier and faster sql/sql_select.cc: Fixed wrong handling of usable-keys in test_if_skip_sort_order (not fatal, just a warning from valgrind) Added DBUG Cleaned up comments
118 lines
4.2 KiB
Text
118 lines
4.2 KiB
Text
#
|
|
# test of rtree (using with spatial data)
|
|
#
|
|
--disable_warnings
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (
|
|
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
g GEOMETRY NOT NULL,
|
|
SPATIAL KEY(g)
|
|
) ENGINE=MyISAM;
|
|
|
|
SHOW CREATE TABLE t1;
|
|
|
|
let $1=150;
|
|
let $2=150;
|
|
while ($1)
|
|
{
|
|
eval INSERT INTO t1 (g) VALUES (GeomFromText('LineString($1 $1, $2 $2)'));
|
|
dec $1;
|
|
inc $2;
|
|
}
|
|
|
|
SELECT count(*) FROM t1;
|
|
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
|
|
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t2 (
|
|
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
g GEOMETRY NOT NULL
|
|
) ENGINE=MyISAM;
|
|
|
|
let $1=10;
|
|
while ($1)
|
|
{
|
|
let $2=10;
|
|
while ($2)
|
|
{
|
|
eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
|
|
dec $2;
|
|
}
|
|
dec $1;
|
|
}
|
|
|
|
ALTER TABLE t2 ADD SPATIAL KEY(g);
|
|
SHOW CREATE TABLE t2;
|
|
SELECT count(*) FROM t2;
|
|
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
|
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
|
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
|
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
|
|
|
let $1=10;
|
|
while ($1)
|
|
{
|
|
let $2=10;
|
|
while ($2)
|
|
{
|
|
eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))));
|
|
SELECT count(*) FROM t2;
|
|
dec $2;
|
|
}
|
|
dec $1;
|
|
}
|
|
|
|
DROP TABLE t2;
|
|
|
|
drop table if exists t1;
|
|
CREATE TABLE t1 (a geometry NOT NULL, SPATIAL (a));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
check table t1;
|
|
analyze table t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# The following crashed gis
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
g GEOMETRY NOT NULL,
|
|
SPATIAL KEY(g)
|
|
) ENGINE=MyISAM;
|
|
|
|
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
|
|
#select * from t1 where g<GeomFromText('LineString(1 2, 2 3)');
|
|
drop table t1;
|