Commit d551c922 authored by Sergei Golubchik's avatar Sergei Golubchik

GIS fixes for --view

parent dd040b5c
...@@ -5534,14 +5534,14 @@ SELECT ST_ISVALID(@g); ...@@ -5534,14 +5534,14 @@ SELECT ST_ISVALID(@g);
ST_ISVALID(@g) ST_ISVALID(@g)
1 1
# Some tests for Polygons # Some tests for Polygons
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))')); SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))')) c;
ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))')) c
1 1
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))')); SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))')) c;
ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))')) c
1 1
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((0 0, 0 2, 2 2, 1 1, 2 0, 0 0))')); SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((0 0, 0 2, 2 2, 1 1, 2 0, 0 0))')) c;
ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((0 0, 0 2, 2 2, 1 1, 2 0, 0 0))')) c
1 1
SELECT ST_ISVALID(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((4 4, 4 5, 5 5, 5 4, 4 4)))')) AS a; SELECT ST_ISVALID(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((4 4, 4 5, 5 5, 5 4, 4 4)))')) AS a;
a a
......
...@@ -3536,11 +3536,11 @@ SELECT ST_ISVALID(@g); ...@@ -3536,11 +3536,11 @@ SELECT ST_ISVALID(@g);
--echo # Some tests for Polygons --echo # Some tests for Polygons
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))')); SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))')) c;
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))')); SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))')) c;
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((0 0, 0 2, 2 2, 1 1, 2 0, 0 0))')); SELECT ST_ISVALID(ST_GEOMFROMTEXT('POLYGON((0 0, 0 2, 2 2, 1 1, 2 0, 0 0))')) c;
SELECT ST_ISVALID(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((4 4, 4 5, 5 5, 5 4, 4 4)))')) AS a; SELECT ST_ISVALID(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((4 4, 4 5, 5 5, 5 4, 4 4)))')) AS a;
......
...@@ -13,17 +13,13 @@ INSERT INTO table_simple_aggregation ( grouping_condition, location ) VALUES ...@@ -13,17 +13,13 @@ INSERT INTO table_simple_aggregation ( grouping_condition, location ) VALUES
# result shall be 1 # result shall be 1
SELECT ST_EQUALS( (SELECT ST_COLLECT( location ) AS t FROM SELECT ST_EQUALS( (SELECT ST_COLLECT( location ) AS t FROM
table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 0,1 0,2 table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 0,1 0,2
0,3 0) ',4326)); 0,3 0) ',4326)) c;
ST_EQUALS( (SELECT ST_COLLECT( location ) AS t FROM c
table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 0,1 0,2
0,3 0) ',4326))
1 1
SELECT ST_EQUALS( (SELECT ST_COLLECT( DISTINCT location ) AS t FROM SELECT ST_EQUALS( (SELECT ST_COLLECT( DISTINCT location ) AS t FROM
table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 0,2 0,3 table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 0,2 0,3
0) ',4326)); 0) ',4326)) c;
ST_EQUALS( (SELECT ST_COLLECT( DISTINCT location ) AS t FROM c
table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 0,2 0,3
0) ',4326))
1 1
INSERT INTO table_simple_aggregation (location) VALUES INSERT INTO table_simple_aggregation (location) VALUES
( ST_GEOMFROMTEXT('POINT(0 -0)' ,4326)), ( ST_GEOMFROMTEXT('POINT(0 -0)' ,4326)),
...@@ -33,35 +29,30 @@ INSERT INTO table_simple_aggregation (location) VALUES ...@@ -33,35 +29,30 @@ INSERT INTO table_simple_aggregation (location) VALUES
# the result here shall be 1 # the result here shall be 1
SELECT ST_EQUALS((SELECT ST_COLLECT(LOCATION) AS T FROM SELECT ST_EQUALS((SELECT ST_COLLECT(LOCATION) AS T FROM
table_simple_aggregation), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION( MULTIPOINT(0 table_simple_aggregation), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION( MULTIPOINT(0
0,1 0,3 0), MULTIPOINT(2 0,0 0), POINT(0 0))',4326)); 0,1 0,3 0), MULTIPOINT(2 0,0 0), POINT(0 0))',4326)) c;
ST_EQUALS((SELECT ST_COLLECT(LOCATION) AS T FROM c
table_simple_aggregation), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION( MULTIPOINT(0
0,1 0,3 0), MULTIPOINT(2 0,0 0), POINT(0 0))',4326))
1 1
# F-1 ST_COLLECT SHALL only return NULL if all elements are NULL or the # F-1 ST_COLLECT SHALL only return NULL if all elements are NULL or the
# aggregate is empty. # aggregate is empty.
# as only a null is aggregated the result of the subquery shall be NULL # as only a null is aggregated the result of the subquery shall be NULL
# and the result of the whole query shall be 1 # and the result of the whole query shall be 1
SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE
location = NULL) IS NULL; location = NULL) IS NULL c;
(SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE c
location = NULL) IS NULL
1 1
# as no element is aggregated the result of the subquery shall be NULL # as no element is aggregated the result of the subquery shall be NULL
# and the result of the whole query shall be 1 # and the result of the whole query shall be 1
SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE
st_srid(location)=2110) IS NULL; st_srid(location)=2110) IS NULL c;
(SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE c
st_srid(location)=2110) IS NULL
1 1
INSERT INTO table_simple_aggregation (location) VALUES INSERT INTO table_simple_aggregation (location) VALUES
( ST_GEOMFROMTEXT('POINT(0 -0)' ,4326)), ( ST_GEOMFROMTEXT('POINT(0 -0)' ,4326)),
( NULL), ( NULL),
( NULL); ( NULL);
SELECT ST_ASTEXT(ST_COLLECT(location) OVER ( ROWS BETWEEN 1 PRECEDING AND SELECT ST_ASTEXT(ST_COLLECT(location) OVER ( ROWS BETWEEN 1 PRECEDING AND
CURRENT ROW)) FROM table_simple_aggregation; CURRENT ROW)) c FROM table_simple_aggregation;
ST_ASTEXT(ST_COLLECT(location) OVER ( ROWS BETWEEN 1 PRECEDING AND c
CURRENT ROW))
MULTIPOINT(0 0) MULTIPOINT(0 0)
MULTIPOINT(0 0,0 0) MULTIPOINT(0 0,0 0)
MULTIPOINT(0 0,1 0) MULTIPOINT(0 0,1 0)
......
...@@ -32,12 +32,12 @@ INSERT INTO table_simple_aggregation ( grouping_condition, location ) VALUES ...@@ -32,12 +32,12 @@ INSERT INTO table_simple_aggregation ( grouping_condition, location ) VALUES
--echo # result shall be 1 --echo # result shall be 1
SELECT ST_EQUALS( (SELECT ST_COLLECT( location ) AS t FROM SELECT ST_EQUALS( (SELECT ST_COLLECT( location ) AS t FROM
table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 0,1 0,2 table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 0,1 0,2
0,3 0) ',4326)); 0,3 0) ',4326)) c;
# --echo # Functional requirement F-8 Shall support DISTINCT in aggregates # --echo # Functional requirement F-8 Shall support DISTINCT in aggregates
# --echo # result shall be 1 # --echo # result shall be 1
SELECT ST_EQUALS( (SELECT ST_COLLECT( DISTINCT location ) AS t FROM SELECT ST_EQUALS( (SELECT ST_COLLECT( DISTINCT location ) AS t FROM
table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 0,2 0,3 table_simple_aggregation) , ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 0,2 0,3
0) ',4326)); 0) ',4326)) c;
# --echo # Functional requirement F-5: ST_COLLECT shall support group by, which # --echo # Functional requirement F-5: ST_COLLECT shall support group by, which
# --echo # is given by aggregation machinery # --echo # is given by aggregation machinery
# --echo # result shall be # --echo # result shall be
...@@ -61,24 +61,24 @@ INSERT INTO table_simple_aggregation (location) VALUES ...@@ -61,24 +61,24 @@ INSERT INTO table_simple_aggregation (location) VALUES
--echo # the result here shall be 1 --echo # the result here shall be 1
SELECT ST_EQUALS((SELECT ST_COLLECT(LOCATION) AS T FROM SELECT ST_EQUALS((SELECT ST_COLLECT(LOCATION) AS T FROM
table_simple_aggregation), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION( MULTIPOINT(0 table_simple_aggregation), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION( MULTIPOINT(0
0,1 0,3 0), MULTIPOINT(2 0,0 0), POINT(0 0))',4326)); 0,1 0,3 0), MULTIPOINT(2 0,0 0), POINT(0 0))',4326)) c;
--echo # F-1 ST_COLLECT SHALL only return NULL if all elements are NULL or the --echo # F-1 ST_COLLECT SHALL only return NULL if all elements are NULL or the
--echo # aggregate is empty. --echo # aggregate is empty.
--echo # as only a null is aggregated the result of the subquery shall be NULL --echo # as only a null is aggregated the result of the subquery shall be NULL
--echo # and the result of the whole query shall be 1 --echo # and the result of the whole query shall be 1
SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE
location = NULL) IS NULL; location = NULL) IS NULL c;
--echo # as no element is aggregated the result of the subquery shall be NULL --echo # as no element is aggregated the result of the subquery shall be NULL
--echo # and the result of the whole query shall be 1 --echo # and the result of the whole query shall be 1
SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE SELECT (SELECT ST_COLLECT(location) AS t FROM table_simple_aggregation WHERE
st_srid(location)=2110) IS NULL; st_srid(location)=2110) IS NULL c;
INSERT INTO table_simple_aggregation (location) VALUES INSERT INTO table_simple_aggregation (location) VALUES
( ST_GEOMFROMTEXT('POINT(0 -0)' ,4326)), ( ST_GEOMFROMTEXT('POINT(0 -0)' ,4326)),
( NULL), ( NULL),
( NULL); ( NULL);
SELECT ST_ASTEXT(ST_COLLECT(location) OVER ( ROWS BETWEEN 1 PRECEDING AND SELECT ST_ASTEXT(ST_COLLECT(location) OVER ( ROWS BETWEEN 1 PRECEDING AND
CURRENT ROW)) FROM table_simple_aggregation; CURRENT ROW)) c FROM table_simple_aggregation;
# --echo Excercising multiple code paths. # --echo Excercising multiple code paths.
......
...@@ -17,29 +17,26 @@ ERROR 22023: Invalid GIS data provided to function st_validate. ...@@ -17,29 +17,26 @@ ERROR 22023: Invalid GIS data provided to function st_validate.
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT(15 25)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT(15 25)')));
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT(15 25)'))) ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT(15 25)')))
POINT(15 25) POINT(15 25)
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT(5 0,25 0,15 10,15 25)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT(5 0,25 0,15 10,15 25)'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT(5 0,25 0,15 10,15 25)'))) c
MULTIPOINT(5 0,25 0,15 10,15 25) MULTIPOINT(5 0,25 0,15 10,15 25)
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(10 15,20 15)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(10 15,20 15)'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(10 15,20 15)'))) c
LINESTRING(10 15,20 15) LINESTRING(10 15,20 15)
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((25 0,0 15,15 30,0 5))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((25 0,0 15,15 30,0 5))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((25 0,0 15,15 30,0 5))'))) c
MULTILINESTRING((25 0,0 15,15 30,0 5)) MULTILINESTRING((25 0,0 15,15 30,0 5))
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'))) c
POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0)) POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10)))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10)))'))) c
MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10))) MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10)))
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(10 10),' SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(10 10),'
'MULTIPOINT(0 0,10 10),' 'MULTIPOINT(0 0,10 10),'
'LINESTRING(1 1,2 2,3 3),' 'LINESTRING(1 1,2 2,3 3),'
'MULTILINESTRING((0 0,0 10,10 10,10 0),(10 10,10 15,15 15,10 10)))'))); 'MULTILINESTRING((0 0,0 10,10 10,10 0),(10 10,10 15,15 15,10 10)))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(10 10),' c
'MULTIPOINT(0 0,10 10),'
'LINESTRING(1 1,2 2,3 3),'
GEOMETRYCOLLECTION(POINT(10 10),MULTIPOINT(0 0,10 10),LINESTRING(1 1,2 2,3 3),MULTILINESTRING((0 0,0 10,10 10,10 0),(10 10,10 15,15 15,10 10))) GEOMETRYCOLLECTION(POINT(10 10),MULTIPOINT(0 0,10 10),LINESTRING(1 1,2 2,3 3),MULTILINESTRING((0 0,0 10,10 10,10 0),(10 10,10 15,15 15,10 10)))
# The only valid empty geometry is the empty geometrycollection # The only valid empty geometry is the empty geometrycollection
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT()'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT()')));
...@@ -57,37 +54,37 @@ NULL ...@@ -57,37 +54,37 @@ NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON(())'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON(())')));
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON(())'))) ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON(())')))
NULL NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON((()),(()))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON((()),(()))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON((()),(()))'))) c
NULL NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()')));
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()')))
GEOMETRYCOLLECTION EMPTY GEOMETRYCOLLECTION EMPTY
# Invalid geometries return null # Invalid geometries return null
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(0 0,-0.00 0,0.0 0)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(0 0,-0.00 0,0.0 0)'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(0 0,-0.00 0,0.0 0)'))) c
NULL NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0))'))) c
NULL NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0))')));
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0))'))) ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0))')))
NULL NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((1 1, 1 1, 1 1, 1 1, 1 1)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((1 1, 1 1, 1 1, 1 1, 1 1)))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((1 1, 1 1, 1 1, 1 1, 1 1)))'))) c
NULL NULL
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0))'))) c
NULL NULL
# If a polygon or multipolygon has counterclockwise internal rings, the rings are returned counterclockwise # If a polygon or multipolygon has counterclockwise internal rings, the rings are returned counterclockwise
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1))'))) c
POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1)) POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1))
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))) c
MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1))) MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1)))
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))) c;
ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))) c
GEOMETRYCOLLECTION(POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1))) GEOMETRYCOLLECTION(POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1)))
# ST_VALIDATE raises an error if longitude is out of range # ST_VALIDATE raises an error if longitude is out of range
SELECT ST_VALIDATE(ST_GEOMFROMTEXT('POINT(0 270)', 4326)); SELECT ST_VALIDATE(ST_GEOMFROMTEXT('POINT(0 270)', 4326));
......
...@@ -33,15 +33,15 @@ SELECT ST_VALIDATE( x'00000000DEADBEEF'); ...@@ -33,15 +33,15 @@ SELECT ST_VALIDATE( x'00000000DEADBEEF');
--echo # ST_VALIDATE return the input if it is valid --echo # ST_VALIDATE return the input if it is valid
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT(15 25)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT(15 25)')));
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT(5 0,25 0,15 10,15 25)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT(5 0,25 0,15 10,15 25)'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(10 15,20 15)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(10 15,20 15)'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((25 0,0 15,15 30,0 5))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((25 0,0 15,15 30,0 5))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,0 0)),((10 10,10 15,15 15,10 10)))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(10 10),' SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(10 10),'
'MULTIPOINT(0 0,10 10),' 'MULTIPOINT(0 0,10 10),'
'LINESTRING(1 1,2 2,3 3),' 'LINESTRING(1 1,2 2,3 3),'
'MULTILINESTRING((0 0,0 10,10 10,10 0),(10 10,10 15,15 15,10 10)))'))); 'MULTILINESTRING((0 0,0 10,10 10,10 0),(10 10,10 15,15 15,10 10)))'))) c;
--echo # The only valid empty geometry is the empty geometrycollection --echo # The only valid empty geometry is the empty geometrycollection
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT()'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POINT()')));
...@@ -49,20 +49,20 @@ SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT()'))); ...@@ -49,20 +49,20 @@ SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOINT()')));
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING()'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING()')));
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING(())'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING(())')));
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON(())'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON(())')));
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON((()),(()))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON((()),(()))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()')));
--echo # Invalid geometries return null --echo # Invalid geometries return null
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(0 0,-0.00 0,0.0 0)'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('LINESTRING(0 0,-0.00 0,0.0 0)'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0))')));
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((1 1, 1 1, 1 1, 1 1, 1 1)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((1 1, 1 1, 1 1, 1 1, 1 1)))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0))'))) c;
--echo # If a polygon or multipolygon has counterclockwise internal rings, the rings are returned counterclockwise --echo # If a polygon or multipolygon has counterclockwise internal rings, the rings are returned counterclockwise
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))) c;
SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))); SELECT ST_ASTEXT(ST_VALIDATE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1)))'))) c;
--echo # ST_VALIDATE raises an error if longitude is out of range --echo # ST_VALIDATE raises an error if longitude is out of range
--error ER_LONGITUDE_OUT_OF_RANGE --error ER_LONGITUDE_OUT_OF_RANGE
......
...@@ -2780,7 +2780,7 @@ double Item_func_sphere_distance::spherical_distance_points(Geometry *g1, ...@@ -2780,7 +2780,7 @@ double Item_func_sphere_distance::spherical_distance_points(Geometry *g1,
} }
String *Item_func_geohash::val_str(String *str) String *Item_func_geohash::val_str_ascii(String *str)
{ {
DBUG_ASSERT(fixed()); DBUG_ASSERT(fixed());
double latitude, longitude; double latitude, longitude;
......
...@@ -1279,7 +1279,7 @@ class Item_func_sphere_distance: public Item_real_func ...@@ -1279,7 +1279,7 @@ class Item_func_sphere_distance: public Item_real_func
}; };
class Item_func_geohash: public Item_geometry_func class Item_func_geohash: public Item_str_ascii_checksum_func
{ {
void encode_geohash(String *str, double longitude, double latitude, void encode_geohash(String *str, double longitude, double latitude,
uint length); uint length);
...@@ -1291,22 +1291,28 @@ class Item_func_geohash: public Item_geometry_func ...@@ -1291,22 +1291,28 @@ class Item_func_geohash: public Item_geometry_func
public: public:
Item_func_geohash(THD *thd, Item *point, Item *max_length): Item_func_geohash(THD *thd, Item *point, Item *max_length):
Item_geometry_func(thd, point, max_length) {} Item_str_ascii_checksum_func(thd, point, max_length) {}
Item_func_geohash(THD *thd, Item *longitude, Item *latitude, Item_func_geohash(THD *thd, Item *longitude, Item *latitude,
Item *max_length): Item *max_length):
Item_geometry_func(thd, longitude, latitude, max_length) {} Item_str_ascii_checksum_func(thd, longitude, latitude, max_length) {}
bool fix_length_and_dec(THD *thd) override
{
fix_length_and_charset(UINT_MAX32, default_charset());
return FALSE;
}
LEX_CSTRING func_name_cstring() const override LEX_CSTRING func_name_cstring() const override
{ {
static LEX_CSTRING name= {STRING_WITH_LEN("st_geohash") }; static LEX_CSTRING name= {STRING_WITH_LEN("st_geohash") };
return name; return name;
} }
String *val_str(String *) override; String *val_str_ascii(String *) override;
Item *do_get_copy(THD *thd) const override Item *do_get_copy(THD *thd) const override
{ return get_item_copy<Item_func_geohash>(thd, this); } { return get_item_copy<Item_func_geohash>(thd, this); }
}; };
class Item_func_latlongfromgeohash : public Item_real_func { class Item_func_latlongfromgeohash : public Item_real_func
{
private: private:
String buf; String buf;
static const uint8_t geohash_alphabet[256]; static const uint8_t geohash_alphabet[256];
......
...@@ -105,6 +105,8 @@ class Item_str_ascii_checksum_func: public Item_str_ascii_func ...@@ -105,6 +105,8 @@ class Item_str_ascii_checksum_func: public Item_str_ascii_func
:Item_str_ascii_func(thd, a) { } :Item_str_ascii_func(thd, a) { }
Item_str_ascii_checksum_func(THD *thd, Item *a, Item *b) Item_str_ascii_checksum_func(THD *thd, Item *a, Item *b)
:Item_str_ascii_func(thd, a, b) { } :Item_str_ascii_func(thd, a, b) { }
Item_str_ascii_checksum_func(THD *thd, Item *a, Item *b, Item *c)
:Item_str_ascii_func(thd, a, b, c) { }
bool eq(const Item *item, bool binary_cmp) const override bool eq(const Item *item, bool binary_cmp) const override
{ {
// Always use binary argument comparison: MD5('x') != MD5('X') // Always use binary argument comparison: MD5('x') != MD5('X')
......
...@@ -2119,7 +2119,7 @@ class Item_func_group_concat : public Item_sum ...@@ -2119,7 +2119,7 @@ class Item_func_group_concat : public Item_sum
}; };
class Item_func_collect :public Item_sum_int class Item_func_collect :public Item_sum_int // XXX why *int* ???
{ {
uint32 srid; uint32 srid;
bool has_cached_result; bool has_cached_result;
...@@ -2140,15 +2140,17 @@ class Item_func_collect :public Item_sum_int ...@@ -2140,15 +2140,17 @@ class Item_func_collect :public Item_sum_int
Item_func_collect(THD *thd, bool is_distinct, Item *item_par); Item_func_collect(THD *thd, bool is_distinct, Item *item_par);
Item_func_collect(THD *thd, bool is_distinct, Item_func_collect *item); Item_func_collect(THD *thd, bool is_distinct, Item_func_collect *item);
bool fix_length_and_dec(THD *thd) override
{
Item_sum_int::fix_length_and_dec(thd);
base_flags|= item_base_t::MAYBE_NULL;
return false;
}
enum Sumfunctype sum_func () const override enum Sumfunctype sum_func () const override
{ {
return GEOMETRY_COLLECT_FUNC; return GEOMETRY_COLLECT_FUNC;
} }
void no_rows_in_result() override {; } void no_rows_in_result() override {; }
void make_const(longlong count_arg)
{
Item_sum_int::make_const();
}
const Type_handler *type_handler() const override const Type_handler *type_handler() const override
{ return &type_handler_string; } { return &type_handler_string; }
longlong val_int() override { return 0; } longlong val_int() override { return 0; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment