[gdal-dev] ogr2ogr, preserve_fid and Postgres sequences
César Martínez
cmartinez at scolab.es
Thu Sep 7 08:55:40 PDT 2017
Done, thanks for the support:
https://trac.osgeo.org/gdal/ticket/7032
César
2017-09-07 17:41 GMT+02:00 Even Rouault <even.rouault at spatialys.com>:
> On jeudi 7 septembre 2017 17:05:36 CEST César Martínez wrote:
>
> > Hi Jukka, see answer inline:
>
> >
>
> > 2017-09-07 16:48 GMT+02:00 jratike80 <jukka.rahkonen@
> maanmittauslaitos.fi>:
>
> > > Hi César,
>
> > >
>
> > > What are the problems you face when editing such layer?
>
> >
>
> > If you later try to add a new record to the layer without providing an
> id,
>
> > it will raise an error, defeating the purpose of having a serial PK. For
>
> > instance:
>
> >
>
> > INSERT INTO test1 (wkb_geometry)
>
> > VALUES (ST_GeomFromText('MULTIPOINT(-5.34510248270791
> 36.1506091987899)',
>
> > 4258)) ;
>
> >
>
> > ERROR: duplicate key value violates unique constraint "test1_pkey"
>
> > SQL state: 23505
>
> > Detail: Key (ogc_fid)=(1) already exists.
>
> >
>
> > They you must provide the ogc_fid by hand:
>
> >
>
> > INSERT INTO test1 (ogc_fid, wkb_geometry)
>
> > VALUES (102, ST_GeomFromText('MULTIPOINT(-5.34510248270791
>
> > 36.1506091987899)', 4258)) ;
>
> >
>
> > > Do you have an
>
> > > alternative suggestion about what to do for the sequence?
>
> >
>
> > The sequence should be initialized in the same way as it is done when
>
> > -preserve_fid is not provided.
>
> > For the layer & sequence in the example, the following SQL statement
> would
>
> > work:
>
> >
>
> > SELECT set_val('test1_ogc_fid_seq', max(ogc_fid)) FROM test1 ;
>
>
>
> Would you mind opening a ticket in Trac about that
>
> https://trac.osgeo.org/gdal/newticket
>
>
>
> Even
>
>
>
> --
>
> Spatialys - Geospatial professional services
>
> http://www.spatialys.com
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
--
SCOLAB
http://scolab.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170907/393c2c42/attachment-0001.html>
More information about the gdal-dev
mailing list