Bug #679 Function intersects : unexpected behaviour
Submitted: 19 Jun 2003 0:53 Modified: 28 Jun 2003 7:15
Reporter: Ramil Kalimullin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1 OS:Linux (Linux)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[19 Jun 2003 0:53] Ramil Kalimullin
Description:
Hello,
> 
> I may underline a bug within the <TT>intersects</TT> funtion (spatial extensions) distributed with mysql-standard-4.1.0-alpha-pc-linux-i686.
> 
> Here is the problem definition :
> It seems that the function intersects ALWAYS return 0 when there is only one line in the table on which the query is made.
> 
> Here is the problem illustration :
> <TT>
> mysql> create table city(City VARCHAR(30),Location geometry);
> Query OK, 0 rows affected (0.02 sec)
> 
> mysql> insert into city values("Paris",GeomFromText('POINT(2.33 48.87)'));
> Query OK, 1 row affected (0.00 sec)
> 
> mysql> select City from city where (select intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0);
> +-------+
> | City  |
> +-------+
> | Paris |
> +-------+
> 1 row in set (0.00 sec)
> </TT>
> 
> This behaviour is unexpected because Paris is included in the defined Polygon.
> 
> <TT>
> mysql> insert into city values("Toulouse",GeomFromText('POINT(1.43 43.6)'));
> Query OK, 1 row affected (0.00 sec)
> 
> mysql> select City from city;
> +----------+
> | City     |
> +----------+
> | Paris    |
> | Toulouse |
> +----------+
> 2 rows in set (0.00 sec)
> 
> mysql> select City from city where (select intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0);
> +----------+
> | City     |
> +----------+
> | Toulouse |
> +----------+
> 1 row in set (0.00 sec)
> </TT>
> 
> When there is another line in the table, the intersects function seems to work correctly.
> 
> 

How to repeat:
see description
[19 Jun 2003 0:56] Ramil Kalimullin
query (without subquery):
select City from city where intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0;
returns right (empty set) result.
So, it seems to me that problem is in subquery code.
[19 Jun 2003 1:25] Ramil Kalimullin
Using debugger I see that intersects() function is not even called.
[19 Jun 2003 8:15] Oleksandr Byelkin
Thank you for exelent bugreport, but this bug is same with 442 and 443 which 
are in patch pending state.
[19 Jun 2003 8:28] Oleksandr Byelkin
Oops. Sorry, I mistaken.
[20 Jun 2003 0:19] Oleksandr Byelkin
ChangeSet 
  1.1563 03/06/20 10:15:58 bell@sanja.is.com.ua +3 -0
[28 Jun 2003 7:15] Oleksandr Byelkin
Thank you for bugreport, patch included in bk repository and will be included 
in next MySQL release.