Opened 14 years ago

Last modified 14 years ago

#1298 closed defect (fixed)

GetNextFeature core dumps when ExecuteSQL used with distinct and query returns no results

Reported by: ethan@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc: ethan@…


I'm getting a core dump from the attached example script. It appears to be related to using ExecuteSQL with "select distinct" but only when the query returns no results. If I remove the "distinct" the script functions properly. The core dump occurrs at line 2233 of swq.c during a GetNextFeature call.

I'm getting this in 1.3.2 and a browse of the CVS shows swq.c has not been modified recently.

I don't see the option to attach a file here. Hopefully I can from the bug page.

Attachments (1) (167.7 KB) - added by ethan@… 14 years ago.
contains a shapefile and a perl script that demonstrates the core dump

Download all attachments as: .zip

Change History (3)

Changed 14 years ago by ethan@…

Attachment: added

contains a shapefile and a perl script that demonstrates the core dump

comment:1 Changed 14 years ago by ethan@…

Afaict if PrepareSummary() returns FALSE GetFeature will return NULL (the desired result for no results). To accomplish this I inserted the following check at line 507 of ogr_gensql.cpp:

if(psSelectInfo->column_summary == NULL) {
        return FALSE;

This may be the patch needed since swq_select_summarize is what allocates the column_summary. If there are no results it doesn't get allocated. 


comment:2 Changed 14 years ago by warmerdam

I have made some changes in /gdal/ogr/ogrsf_frmts/generic/ogr_gensql.cpp's
PrepareSummary() to deal with this issue.  I've also extended the 
gdalautotest/ogr/ script to test DISTINCT and MAX() on a
result with no records.


Note: See TracTickets for help on using tickets.