From: | Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-sql(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] Re: [SQL] createdb -D xxxx not working |
Date: | 2000-01-11 15:57:09 |
Message-ID: | 387B52D5.17CB18EA@alumni.caltech.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
> >> Surely you want $PGDATA2 in the latter two lines?
> > You might recall me mentioning that the whole alternative location
> > business doesn't work in the first place.
I'm not recalling the details here; what is the problem? It works for
me (but then I wrote it ;)
> Fine. BTW, am I the only one who thinks that it's really silly for
> initlocation to expect to be given an unexpanded environment variable
> name? That's not normal practice (either elsewhere in Postgres, or
> anywhere else that I know of). It's confusing because it's not how
> an ordinary Unix user would expect a shell command to behave, and it
> doesn't buy any functionality that I can see.
It is not silly at all, unless you want to shoot holes in the basic
premise of the alternate location. This is described in the docs, but
the short form is:
initlocation is used to create the directory structure *with correct
permissions* for an alternate location. It takes an environment
variable because usually the backend should have that same environment
variable defined to ensure consistancy and as a security measure. The
environment variable can be expanded or not; initlocation does the
right thing in either case.
createdb takes a "-D" argument, which specifies the alternate
location. Unless allowed at compile-time, via the
ALLOW_ABSOLUTE_DBPATHS variable, all references to an alternate
location must refer to an environment variable, to give the dbadmin
control over *where* alternate locations will appear. The mechanism is
enforced by the backend, by looking for a directory delimiter in the
datpath field of pg_database, then expanding the first field as an
environment variable. On my system, with one database in an alternate
location, this table looks like:
test=# select * from pg_database;
datname | datdba | encoding | datpath
------------+--------+----------+--------------
template1 | 100 | 0 | template1
postgres | 100 | 0 | postgres
regression | 100 | 0 | regression
test | 100 | 0 | PGDATA2/test
(4 rows)
So, this works:
[postgres(at)golem parser]$ createdb -D PGDATA2 test2
CREATE DATABASE
But this does not (but can be enabled at compile-time if the sysadmin
wants to allow users to scatter databases everywhere (?!!)):
[postgres(at)golem regress]$ createdb -D /opt/postgres/data2 test2
ERROR: The path '/opt/postgres/data2/test2' is invalid.
This may be due to a missing environment variable on the server.
createdb: Database creation failed.
> I'd vote for taking
> out the auto-expansion, so that the correct invocation becomes
> initlocation $PGDATA2
> which is what an average user would expect.
But the average user does not necessarily have access to the PGDATA2
environment variable! This is usually a sysadmin function.
> Actually, after looking at what initlocation really does, which is
> darn near nothing, I wonder whether we shouldn't dispense with it
> altogether...
?? I hope the explanation above helps...
- Thomas
--
Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
South Pasadena, California
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2000-01-11 16:25:15 | Re: [HACKERS] Who fried this? |
Previous Message | Tom Lane | 2000-01-11 15:31:13 | Re: [HACKERS] Potential vacuum bug? |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-01-11 16:14:35 | Re: [SQL] best strategy doing a large copy and using indexes |
Previous Message | Dirk Lutzebaeck | 2000-01-11 15:21:51 | best strategy doing a large copy and using indexes |