Opened 8 years ago

Closed 8 years ago

#4507 closed defect (fixed)

SQL drivers : bad AND priority when spatial and attribute filter are combined

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.9.1
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc: tamas

Description

At least for PG, MySQL, SQLite and MSSpatial driver (and probably in other drivers), when we build the where clause, we build something like "WHERE spatial_filter AND attribute_filter". The issue is that if attribute_filter contains a OR, we end up with "WHERE spatial_filter AND attribute_filter_part1 OR attribute_filter_part2", which evaluates to "WHERE (spatial_filter AND attribute_filter_part1) OR attribute_filter_part2".

Which queries more features than really necessary. Generally, you won't notice it since client side spatial filtering will still be done. But this can be sometimes seen when running GetFeatureCount?().

Change History (1)

comment:1 Changed 8 years ago by Even Rouault

Cc: tamas added
Resolution: fixed
Status: newclosed

Tamas, you might want to check that the following fix doesn't break MSSpatial driver.

r23942 /trunk/gdal/ogr/ogrsf_frmts/ (5 files in 4 dirs): Fix bad AND priority when spatial and attribute filter are combined in PG, MySQL, SQLite and MSSpatial drivers (#4507)

r23943 /branches/1.9/gdal/ogr/ogrsf_frmts/ (5 files in 4 dirs): Fix bad AND priority when spatial and attribute filter are combined in PG, MySQL, SQLite and MSSpatial drivers (#4507)

Note: See TracTickets for help on using tickets.