Opened 13 years ago

Closed 13 years ago

#4277 closed defect (invalid)

Issue with sql expression with tab file

Reported by: elzouavo Owned by: warmerdam
Priority: high Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

I have trouble with GDAL 1.8.0 (released 2011/01/12) but not problem with GDAL 1.7.0b2, FWTools 2.4.7, released 2010/01/19.

When I do sql request on tab files : ogrinfo --DEBUG ON -sql "SELECT ID,TYPE,CODE_V2,DESC,NOM_ETUDE,M_OUVRAGE,PRODUCTEUR,VALIDATION,DATE,ECHELLE FROM 'Zonage_PPRI_provisoire'" "C:\Documents and Settings\SAEZ.CETE-AIX\Mes documents\Cartelie\Assistance\DDTM_30\erreur_OGR\shp_traducteur_universel\tab_trad_univ\mapinfo\Zonage_PPRI_provisoire.TAB"

Result : GEOCONCEPT: Failed to open Geoconcept C:\Documents and Settings\SAEZ.CETE-AIX\Mes documents\Cartelie\Assistance\DDTM_30\erreur_OGR\shp_traducteur_universel\tab_trad_univ\mapinfo\Zonage_PPRI_provisoire.TAB. It may be corrupt. OGR: OGROpen(C:\Documents and Settings\SAEZ.CETE-AIX\Mes documents\Cartelie\Assi stance\DDTM_30\erreur_OGR\shp_traducteur_universel\tab_trad_univ\mapinfo\Zonage_ PPRI_provisoire.TAB) failed. OGR: OGROpen(C:\Documents and Settings\SAEZ.CETE-AIX\Mes documents\Cartelie\Assi stance\DDTM_30\erreur_OGR\shp_traducteur_universel\tab_trad_univ\mapinfo\Zonage_ PPRI_provisoire.TAB/00D25EB0) succeeded as MapInfo File. Had to open data source read-only. INFO: Open of `C:\Documents and Settings\SAEZ.CETE-AIX\Mes documents\Cartelie\As sistance\DDTM_30\erreur_OGR\shp_traducteur_universel\tab_trad_univ\mapinfo\Zonag e_PPRI_provisoire.TAB'

using driver `MapInfo File' successful.

ERROR 1: SQL Expression Parsing Error: syntax error OGR: GetLayerCount() = 1

Attachments (1)

ogr_sql_problem.zip (15.7 KB ) - added by elzouavo 13 years ago.
TAB file to test

Download all attachments as: .zip

Change History (2)

by elzouavo, 13 years ago

Attachment: ogr_sql_problem.zip added

TAB file to test

comment:1 by Even Rouault, 13 years ago

Resolution: invalid
Status: newclosed

The cause of the error is the DESC column. DESC is a SQL keyword used in a "ORDER BY xxxx [ASC|DESC]" clause, and its use confuses the OGR SQL parser (it has been rewritten from scratch in OGR 1.8.0 and is stricter than the previous one). This can be solved howevever by surrounding this column name by single-quote character.

I see that other SQL engines wouldn't like unquoted DESC as column name : http://www.eggheadcafe.com/microsoft/SQL-Server/30674854/desc-as-column-name.aspx

So I'm tempted to consider this as an expected behaviour.

Note: See TracTickets for help on using tickets.