[Tile-serving] [openstreetmap/osm2pgsql] Duplicated serial values when appending data to flex backend (#1522)
Nikolai Lebedev
notifications at github.com
Tue Jun 8 13:30:27 UTC 2021
Defining a column as `sql_type=serial primary key` in flex works fine during initial import, but breaks when running osm2pgsql in append mode.
Postgres throws `Duplicate key violates unique constraint`.
If `primary key` is removed and only `sql_type=serial` is left in a column definition, then append completes successfully, but column receives duplicate values.
Seems like newly created sequence is used only for a temporary table and then is somehow reset when attached to a resulting table.
Here's code to reproduce:
```lua
local tables = {}
tables.test =
osm2pgsql.define_table(
{
schema = "osm",
name = "test",
ids = { type = "node", id_column = "node_id" },
columns = {
{ column = "gid", sql_type = "serial primary key", create_only = true },
{ column = "tags", type = "jsonb" },
{ column = "geom", type = "point" }
}
}
)
function osm2pgsql.process_node(object)
tables.test:add_row({
tags = object.tags,
geom = { create = "point" }
})
end
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/1522
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20210608/6c6162ab/attachment.htm>
More information about the Tile-serving
mailing list