Closed fefux closed 1 month ago
Works for me.
You might have looked at the temporary tables while the import is running. The temporary tables don't have the create_only
columns in them. But after the import is done, the temporary tables will be sorted and copied into the final tables. And those have the create_only
columns. This is the expected behaviour and needed for some situations (see #1522).
Oups, my bad... As I couldn't see my column in the table, I didn't wait the whole import (~1h)... I retry now
What version of osm2pgsql are you using?
osm2pgsql version 2.0.0 (2.0.0) Build: RelWithDebInfo Compiled using the following library versions: Libosmium 2.20.0 Proj 8.2.1 Lua 5.1.4 (LuaJIT 2.1.0-beta3)
What operating system and PostgreSQL/PostGIS version are you using?
Distributor ID: Ubuntu Description: Ubuntu 22.04.5 LTS Release: 22.04 Codename: jammy
Tell us something about your system
Bare metal hp server 250gb of ram 24 cpu
What did you do exactly?
I tried to use flex output to customize import table by adding column to enumerate rows. I tried with the file
flex-config/compatible.lua
I changed the function gen_columns and add this line :I ran osm2pgsql with :
osm2pgsql -c -d map -U gisuser -H localhost -S ../test/osm2pgsql/test.lua -O flex -v france.osm.pbf
output :
What did you expect to happen?
As my customized column is listed in the log above :
cluster = 'auto'
with the methodosm2pgsql.define_table
What did happen instead?
The column is not created at all as the SQL create table command just drops it without any message
What did you do to try analyzing the problem?
I ran osm2pgsql with :
osm2pgsql -c -d map -U gisuser -H localhost -S ../test/osm2pgsql/test.lua -O flex --log-sql france.osm.pbf
output :I dig deeper and found that piece of code in file flex-table.cpp :
And I checked what defined a permanent table instead of an interim table. I found in the same file :
And then, in flex-table.hpp :
And concluded by : If the table contains a geometry column and has the flag cluster to true, it's an interim table and create_only column will be dropped from the create table.
To fix the issue, in the lua file, you need to set :
With the flag cluster to 'no' ('auto' by default)
I hope it will be clear enough ;)