Обсуждение: PGSYSCONFDIR?

Поиск
Список
Период
Сортировка

PGSYSCONFDIR?

От
John Sutton
Дата:
Hi there

Having spent about 2 hours trying to solve a simple problem, I think it might be worthwhile to record my efforts.
Perhapssomeone can point out how extremely silly I have been… or is the documentation lacking? 

My original question was: where is the system-wide psqlrc file located?

Some material on the web suggests that this is ~postgres/.psqlrc but this not true, this is just the postgres user’s
user-specificconfig file. 

I tried putting it alongside pg_hba.conf etc but that didn’t work.

The psqlrc.sample file contains the wording “Copy this to your sysconf directory (typically /usr/local/pqsql/etc) …”
butthat directory doesn’t exist on either of my target systems!  (I’m using postgres 9.1 on Ubuntu and Mac OS X.) 

As a last resort (which surely shouldn’t be necessary) on the Ubuntu system I did:

strings /usr/bin/psql | grep -i sysconf

$ENV{'PGSYSCONFDIR'} = '/etc/postgresql-common' if !$ENV{'PGSYSCONFDIR’};

So that’s where it needs to be: /etc/postgresql-common/psqlrc

I’ve still no clue for Mac OS X however, since the same trick only finds a placeholder :( :

strings /Applications/Postgres.app/Contents/MacOS/bin/psql | grep -i sysconf

PGSYSCONFDIR
PGSYSCONFDIR=%s

Hope this saves somebody some time.

--
John Sutton




Re: PGSYSCONFDIR?

От
Alvaro Herrera
Дата:
John Sutton escribió:

> As a last resort (which surely shouldn’t be necessary) on the Ubuntu system I did:
>
> strings /usr/bin/psql | grep -i sysconf
>
> $ENV{'PGSYSCONFDIR'} = '/etc/postgresql-common' if !$ENV{'PGSYSCONFDIR’};
>
> So that’s where it needs to be: /etc/postgresql-common/psqlrc

Meh.  /usr/bin/psql in Debian/Ubuntu is a shell script provided by the
packaging.

> I’ve still no clue for Mac OS X however, since the same trick only finds a placeholder :( :
>
> strings /Applications/Postgres.app/Contents/MacOS/bin/psql | grep -i sysconf
>
> PGSYSCONFDIR
> PGSYSCONFDIR=%s

This is probably what you would get if you had stringied the binary in
Debian/Ubuntu, too, instead of the wrapper script.

I think the way to get the PGSYSCONFDIR would be to use
  pg_config --sysconfdir

If you don't have pg_config, ...  Tough.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: PGSYSCONFDIR?

От
Tom Lane
Дата:
John Sutton <johnericsutton@gmail.com> writes:
> Hi there
> Having spent about 2 hours trying to solve a simple problem, I think it might be worthwhile to record my efforts.
Perhapssomeone can point out how extremely silly I have been� or is the documentation lacking? 

> My original question was: where is the system-wide psqlrc file located?

The easy way to find that out is "pg_config --sysconfdir".  I agree that
the psql man page ought to mention that, and fails to.  Will see about
fixing that...

            regards, tom lane


Re: PGSYSCONFDIR?

От
Steve Atkins
Дата:
On Jan 14, 2014, at 10:58 AM, John Sutton <johnericsutton@gmail.com> wrote:

> Hi there
>
> Having spent about 2 hours trying to solve a simple problem, I think it might be worthwhile to record my efforts.
Perhapssomeone can point out how extremely silly I have been… or is the documentation lacking? 
>
> My original question was: where is the system-wide psqlrc file located?

The default is a compile-time configuration option.

You can get that for your installation using "pg_config --sysconfdir”

The environment PGSYSCONFDIR variable can override it if it’s set. Like a lot of client configuration settings it’s not
reallyhandled by the client, but by libpq. That’s good; makes for a nice consistent UI. What’s less good is that it
meansthat they’re documented in the libpq docs - http://www.postgresql.org/docs/current/static/libpq-envars.html 

>
> Some material on the web suggests that this is ~postgres/.psqlrc but this not true, this is just the postgres user’s
user-specificconfig file. 
>
> I tried putting it alongside pg_hba.conf etc but that didn’t work.
>
> The psqlrc.sample file contains the wording “Copy this to your sysconf directory (typically /usr/local/pqsql/etc) …”
butthat directory doesn’t exist on either of my target systems!  (I’m using postgres 9.1 on Ubuntu and Mac OS X.) 
>
> As a last resort (which surely shouldn’t be necessary) on the Ubuntu system I did:
>
> strings /usr/bin/psql | grep -i sysconf
>
> $ENV{'PGSYSCONFDIR'} = '/etc/postgresql-common' if !$ENV{'PGSYSCONFDIR’};

On Ubuntu that’s not really psql, it’s a shell script wrapper that runs the real psql - and it looks like they’re
overridingwhatever the built-in default is in their wrapper. 

>
> So that’s where it needs to be: /etc/postgresql-common/psqlrc
>
> I’ve still no clue for Mac OS X however, since the same trick only finds a placeholder :( :
>
> strings /Applications/Postgres.app/Contents/MacOS/bin/psql | grep -i sysconf

satsuke:shared (develop)$ pg_config --sysconfdir
/Applications/Postgres.app/Contents/MacOS/etc

:)

Cheers,
  Steve