[Tile-serving] [openstreetmap/osm2pgsql] `osm2pgsql-replication`: compute database date fails if data is not in `public` schema (Issue #1818)
Jakob Miksch
notifications at github.com
Sat Nov 5 18:55:59 UTC 2022
<!-- Please don't use screenshots. Copy and paste the *text* output here if that's needed for context. -->
## What version of osm2pgsql are you using?
`master` at https://github.com/openstreetmap/osm2pgsql/commit/41f2e56d8c18b8a694ceb5307926d652ae1faec0
## What did you do exactly?
I imported OSM data in the schema `foobar` and tried to initilise the replication **without** providing the OSM file.
```shell
export PGHOST=localhost
export PGPORT=5432
export PGUSER=postgres
export PGPASSWORD=postgres
export PGDATABASE=osm
DB_SCHEMA=foobar
psql -c "CREATE SCHEMA IF NOT EXISTS ${DB_SCHEMA}";
osm2pgsql \
--create \
--slim \
--verbose \
--middle-schema=${DB_SCHEMA} \
path/to/osm-file.pbf
osm2pgsql-replication init
```
## What did you expect to happen?
The date from the OSM should have been read and a table with the replication should have been created.
## What did happen instead?
`osm2pgsql-replication` could not find the table with OSM date, because it is not aware that it is stored in a schema. Error message:
```
Traceback (most recent call last):
File "/home/jakob/Repos/osm2pgsql/scripts/osm2pgsql-replication", line 551, in <module>
sys.exit(main())
File "/home/jakob/Repos/osm2pgsql/scripts/osm2pgsql-replication", line 545, in main
return args.handler(conn, args)
File "/home/jakob/Repos/osm2pgsql/scripts/osm2pgsql-replication", line 290, in init
date = compute_database_date(conn, args.prefix)
File "/home/jakob/Repos/osm2pgsql/scripts/osm2pgsql-replication", line 103, in compute_database_date
cur.execute(sql.SQL("SELECT max(id) FROM {}").format(table))
psycopg2.errors.UndefinedTable: relation "planet_osm_ways" does not exist
LINE 1: SELECT max(id) FROM "planet_osm_ways"
```
## What did you do to try analyzing the problem?
I assume the script `osm2pgsql-replication` has to be adapted to handle OSM data stored in different schemas. The error occurs [here](https://github.com/openstreetmap/osm2pgsql/blob/41f2e56d8c18b8a694ceb5307926d652ae1faec0/scripts/osm2pgsql-replication#L102)
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/1818
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/osm2pgsql/issues/1818 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20221105/3bac2183/attachment-0001.htm>
More information about the Tile-serving
mailing list