Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-35765 ST_OVERLAPS wrong result when dim(geom1) <> dim(geom2) #3740

Open
wants to merge 1 commit into
base: 10.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mysql-test/main/mdev-35765.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# MDEV-35765 ST_OVERLAPS returns true despite dim(originalInput1) <> dim(originalInput2)
#
DROP table if EXISTS t1;
Warnings:
Note 1051 Unknown table 'test.t1'
DROP table if EXISTS t2;
Warnings:
Note 1051 Unknown table 'test.t2'
CREATE TABLE t1(geom geometry NOT NULL);
CREATE TABLE t2(geom geometry NOT NULL);
INSERT INTO t1 (geom) VALUES(ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t2 (geom) VALUES(ST_GeomFromText('LINESTRING (1 1, 1 2, 2 2, 2 1, 1 1)'));
SELECT ST_OVERLAPS(t1.geom, t2.geom) FROM t1, t2;
ST_OVERLAPS(t1.geom, t2.geom)
0
DROP TABLE t1, t2;
#
# End of 10.6 tests
#
14 changes: 14 additions & 0 deletions mysql-test/main/mdev-35765.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--echo #
--echo # MDEV-35765 ST_OVERLAPS returns true despite dim(originalInput1) <> dim(originalInput2)
--echo #
DROP table if EXISTS t1;
DROP table if EXISTS t2;
CREATE TABLE t1(geom geometry NOT NULL);
CREATE TABLE t2(geom geometry NOT NULL);
INSERT INTO t1 (geom) VALUES(ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t2 (geom) VALUES(ST_GeomFromText('LINESTRING (1 1, 1 2, 2 2, 2 1, 1 1)'));
SELECT ST_OVERLAPS(t1.geom, t2.geom) FROM t1, t2;
DROP TABLE t1, t2;
--echo #
--echo # End of 10.6 tests
--echo #
10 changes: 10 additions & 0 deletions sql/item_geofunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,16 @@ bool Item_func_spatial_precise_rel::val_bool()
null_value= g1.store_shapes(&trn) || g2.store_shapes(&trn);
break;
case SP_OVERLAPS_FUNC:
{
// Both geometries must have the same number of dimensions.
uint32 g1_dim, g2_dim;
const char *dummy;
g1.geom->dimension(&g1_dim, &dummy);
g2.geom->dimension(&g2_dim, &dummy);
if (g1_dim != g2_dim)
DBUG_RETURN(0);
// Intentionally fall-through to SP_CROSSES_FUNC case.
}
case SP_CROSSES_FUNC:
func.add_operation(Gcalc_function::op_intersection, 2);
if (func.reserve_op_buffer(3))
Expand Down