Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#2965 closed defect (invalid)

OGR GPX driver using reserved SQL keyword for field name

Reported by: hamish Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: gpx
Cc:

Description

Hi,

I am attempting to import a GPX file into GRASS using the v.in.ogr module.

I am getting this error:

Layer: waypoints
WARNING: Width for column name set to 255 (was not specified by OGR), some
         strings may be truncated!
WARNING: Width for column cmt set to 255 (was not specified by OGR), some
         strings may be truncated!
WARNING: Width for column desc set to 255 (was not specified by OGR), some
         strings may be truncated!
WARNING: Width for column src set to 255 (was not specified by OGR), some
         strings may be truncated!
WARNING: Width for column link1_href set to 255 (was not specified by OGR),
         some strings may be truncated!
WARNING: Width for column link1_text set to 255 (was not specified by OGR),
         some strings may be truncated!
WARNING: Width for column link1_type set to 255 (was not specified by OGR),
         some strings may be truncated!
WARNING: Width for column link2_href set to 255 (was not specified by OGR),
         some strings may be truncated!
WARNING: Width for column link2_text set to 255 (was not specified by OGR),
         some strings may be truncated!
WARNING: Width for column link2_type set to 255 (was not specified by OGR),
         some strings may be truncated!
WARNING: Width for column sym set to 255 (was not specified by OGR), some
         strings may be truncated!
WARNING: Width for column type set to 255 (was not specified by OGR), some
         strings may be truncated!
WARNING: Width for column fix set to 255 (was not specified by OGR), some
         strings may be truncated!

DBMI-DBF driver error:
SQL parser error: syntax error, unexpected TIME, expecting NAME processing 'time'
in statement:
create table gps_trk_28Apr2009_1 (cat integer, ele double precision, time datetime, magvar double precision, geoidheight double precision, name varchar ( 255 ), cmt varchar ( 255 ), desc varchar ( 255 ), src varchar ( 255 ), link1_href varchar ( 255 ), link1_text varchar ( 255 ), link1_type varchar ( 255 ), link2_href varchar ( 255 ), link2_text varchar ( 255 ), link2_type varchar ( 255 ), sym varchar ( 255 ), type varchar ( 255 ), fix varchar ( 255 ), sat integer, hdop double precision, vdop double precision, pdop double precision, ageofdgpsdata double precision, dgpsid integer)
Error in db_execute_immediate()

ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp line 110 sets a OGRFieldDefn named "time", but this is a SQL reserved word for some DBs, so fails.

http://www.postgresql.org/docs/8.3/interactive/sql-keywords-appendix.html

I can work around this in GRASS either by setting the v.in.ogr cnames= option to rename the fields, or by using another DB backend which doesn't have 'time' as a reserved word (like SQLite).

Hamish

Change History (3)

comment:1 Changed 13 years ago by hamish

Component: defaultOGR_SF
Keywords: gpx added
Version: unspecifiedsvn-trunk

comment:2 Changed 13 years ago by Even Rouault

Resolution: invalid
Status: newclosed

There is no reason for the GPX driver not to use "time" as a field name. I think you should report it rather to the GRASS project. They should likely quote the field names (provided that it supports that). This is what the PG and MySQL driver in OGR do, so you can use any name, even if it is a SQL reserved keyword.

comment:3 Changed 12 years ago by hamish

filed as GRASS wish # 578 http://trac.osgeo.org/grass/ticket/578

Note: See TracTickets for help on using tickets.