I'm using PostgreSQL 9.2.15 with PostGIS 2.0.7 through the standard packages available on CentOS 7 with EPEL.
I have a server script to automatically setup a PostGIS database, by first executing
initdb, then using
postgres --single to create a new database with PostGIS extension. This works roughly like this:
initdb -D ... postgres --single -D ... postgres <<'EOF' CREATE DATABASE mydb; EOF postgres --single -D ... mydb <<'EOF' CREATE EXTENSION postgis; EOF
However, the last command produces the following strange error message:
ERROR: type reclassarg does not exist STATEMENT: CREATE EXTENSION postgis;
If I instead run the database server and execute
CREATE EXTENSION postgis via
sql, everything works fine:
postgres -D ... & # Wait until service it up and running psql mydb <<'EOF' CREATE EXTENSION postgis; EOF
But that is not suitable for a database initialization script.
So how can I initialize a PostGIS database in PostgreSQL single-user mode?
Update: There is a thread in the pgsql-bugs mailinglist on that topic, but that doesn't answer my question. It just explains that it is not planned to improve the single-user mode of PostgreSQL. So there will always be missing PgSQL language features to execute the current PostGIS extension creation script. However, most other PostgreSQL extensions can be installed in single-user mode just fine. So maybe there is a way to reformulate the PostGIS creation script so it achieves the same thing without requiring those language features, i.e. to make it "more portable".
(This question originally appeared on StackExchange / GIS: https://gis.stackexchange.com/q/214449/82644)