[gdal-dev] ogr2ogr, preserve_fid and Postgres sequences

César Martínez cmartinez at scolab.es
Thu Sep 7 07:21:51 PDT 2017


Hi,

When loading a layer on PostGIS using ogr2ogr, a sequence is created for
the serial primary key.
If -preserve_fid paramenter is provided, the sequence start is not properly
initialized (i. e. sequence starts on 1). This leads to problems if the
layer is later edited. Is this an intended behaviour or should be
considered a bug?

Note that I am using GDAL version 1.11.3.

Example:

# Using -preserve_fid
ogr2ogr -preserve_fid -update -f PostgreSQL "PG:host='localhost'
dbname='test'" myshp.shp  myshp -nln "test1"

# SELECT last_value from test1_ogc_fid_seq ;
 last_value
------------
          1
(1 row)

# Not using -preserve_fid: sequence properly initialized to 102
ogr2ogr -update -f PostgreSQL "PG:host='localhost' dbname='test'"
myshp.shp  myshp  -nln "test2"

# SELECT last_value from test2_ogc_fid_seq ;
 last_value
------------
        102
(1 row)

Thanks in advance,

César

-- 
SCOLAB
http://scolab.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170907/ff8442d7/attachment-0001.html>


More information about the gdal-dev mailing list