[Tile-serving] [osm2pgsql-dev/osm2pgsql] Cannot insert into custom table anymore? (Issue #2345)
rouen-sk
notifications at github.com
Tue Jun 17 08:24:28 UTC 2025
rouen-sk created an issue (osm2pgsql-dev/osm2pgsql#2345)
Let's say you want to save some extra data with your OSM import, for example I want to have timestamp of newest node or way in dataset. So I defined extra table for it, keep max timestamp I encounter while processing nodes and ways, and finally try to insert it while processing relations (normal OSM data tables and processing omitted for brevity):
```
local maxTimestamp = 0
local tables = {}
tables.osm_data_version = osm2pgsql.define_table({
name = 'osm_data_version',
columns = {
{ column = 'timestamp', type = 'bigint', not_null = true }
}
})
function osm2pgsql.process_node(object)
if object.timestamp > maxTimestamp then
maxTimestamp = object.timestamp
end
...
end
function osm2pgsql.process_relation(object)
-- add single row with max timestamp from nodes and ways
if maxTimestamp > 0 then
print('MAXTIMESTAMP:' .. maxTimestamp)
tables.osm_data_version:insert({
timestamp = maxTimestamp
})
maxTimestamp = 0
end
...
end
```
But if you do this, you will get error:
```
2025-06-17 07:53:40 ERROR: Failed to execute Lua function 'osm2pgsql.process_relation': test.lua:512: Error in 'insert': Trying to add relation to table 'osm_data_version'.
```
Looking at source code for this error, it seems that `output_flex_t::check_and_get_context_object` expect all tables to be node/way/relation tables? So you can't do simple insert into "custom" table like this anymore? (I say anymore, because this has to be new, I used to do this successfully some time ago).
--
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/issues/2345
You are receiving this because you are subscribed to this thread.
Message ID: <osm2pgsql-dev/osm2pgsql/issues/2345 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20250617/f0a7e3c3/attachment.htm>
More information about the Tile-serving
mailing list