Re: initlocation and createdb - Mailing list pgsql-general

From Tom Lane
Subject Re: initlocation and createdb
Date
Msg-id 4961.960934456@sss.pgh.pa.us
Whole thread Raw
In response to initlocation and createdb  ("Barnes" <aardvark@ibm.net>)
List pgsql-general
"Barnes" <aardvark@ibm.net> writes:
> I'm having trouble setting up databases in a new location.  In particular, I
> do the following:

> [postgres@whopper pgdata]$ export PGDATA2=/home/pgdata
> [postgres@whopper pgdata]$ initlocation PGDATA2
> The location will be initialized with username "postgres".
> This user will own all the files and must also own the server process.

> Fixing permissions on pre-existing directory /home/pgdata
> Creating directory /home/pgdata/base

> initlocation is complete.
> You can now create a database using
>   CREATE DATABASE <name> WITH LOCATION = 'PGDATA2'
> in SQL, or
>   createdb <name> -D 'PGDATA2'
> from the shell.

> [postgres@whopper pgdata]$ createdb optodb -D 'PGDATA2'
> ERROR:  The database path 'PGDATA2' is invalid. This may be due to a
> character that is not allowed or because the chosen path isn't permitted for
> databases
> createdb: database creation failed
> [postgres@whopper pgdata]$

I believe the problem here is that you haven't made the environment
variable PGDATA2 visible to the postmaster.  initlocation is just a
shell script and will run fine as long as the environment variable
is in its environment --- but when you try to access that location
in a backend operation, the environment variable must be present in
the postmaster's environment.

In short: restart the postmaster with PGDATA2=/home/pgdata in its
environment.

This whole initlocation mechanism is pretty bizarre and confusing IMHO.
I believe the motivation for it is to allow the dbadmin to control what
locations users are allowed to create databases in, but an explicit
system table of allowed locations would be a lot better...

            regards, tom lane

pgsql-general by date:

Previous
From: "Barnes"
Date:
Subject: RE: initlocation and createdb
Next
From: JanWieck@t-online.de (Jan Wieck)
Date:
Subject: Re: triggers and functions in pgsql 7.0.2