Re: [GENERAL] ~/.psqlrc file is ignored [solved: $HOME/.psqlrc]

2017-07-20 Thread vstuart
~/.bashrc alias:

alias pg='echo "  [sudo -u postgres -i]" && sudo -u postgres -i'



--
View this message in context: 
http://www.postgresql-archive.org/psqlrc-file-is-ignored-tp5971773p5972153.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] ~/.psqlrc file is ignored [solved: $HOME/.psqlrc]

2017-07-20 Thread vstuart
'Solution,' for anyone else encountering this issue (Arch Linux PostgreSQL
install ...).

TLDR: symlink ~/.psqlrc to  postgres $HOME/.psqlrc

-

[victoria@victoria ~]$ echo $HOME
/home/victoria

[victoria@victoria ~]$ ls -la .psq*
-rw-r--r-- 1 victoria victoria 3.9K Jul 17 10:42 .psqlrc

[victoria@victoria ~]$ pg
  [sudo -u postgres -i]
  [sudo] password for victoria: 

[postgres@victoria ~]$ echo $HOME
/var/lib/postgres

[postgres@victoria ~]$ ln -s  /home/victoria/.psqlrc  /var/lib/postgres/

[postgres@victoria ~]$ ls -la .psqlrc
lrwxrwxrwx 1 postgres postgres 22 Jul 20 08:10 .psqlrc ->
/home/victoria/.psqlrc

[postgres@victoria ~]$ psql

psql:/var/lib/postgres/.psqlrc:14: invalid command \SET
Pager usage is off.
Null display is "[NULL]".
Timing is on.
Expanded display is used automatically.
psql (9.6.3)
Type "help" for help.

[local] postgres@postgres=# \q


## EDITED /home/victoria/.psqlrc in text editor, correcting line 14 error:
## " \SET client_encoding = 'UTF8' " >> " \set CLIENT_ENCODING = 'UTF8' "
## ('\set' needed to be lowercase)


[postgres@victoria ~]$ psql

Pager usage is off.
Null display is "[NULL]".
Timing is on.
Expanded display is used automatically.
psql (9.6.3)
Type "help" for help.

[local] postgres@postgres=# \q

[postgres@victoria ~]$ exit
logout

[victoria@victoria ~]$ 




--
View this message in context: 
http://www.postgresql-archive.org/psqlrc-file-is-ignored-tp5971773p5972146.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] ~/.psqlrc file is ignored

2017-07-19 Thread vstuart
Hi David: I see what you are saying; sorry for the confusion. This is how 
postgres operates on my system:

[victoria@victoria ~]$ echo $HOME
  /home/victoria

[victoria@victoria ~]$ which postgres
  /usr/bin/postgres

[victoria@victoria ~]$ postgres
  postgres does not know where to find the server configuration file.
  You must specify the --config-file or -D invocation option or set the PGDATA 
environment variable.

[victoria@victoria ~]$ psql
  psql: FATAL:  database "victoria" does not exist

[victoria@victoria ~]$ sudo -u postgres -i

[postgres@victoria ~]$ echo $HOME
  /var/lib/postgres

[postgres@victoria ~]$ psql
  psql (9.6.3)
  Type "help" for help.

postgres=# \q

[postgres@victoria ~]$ exit
  logout

[victoria@victoria ~]$

... That postgres had a different $HOME environment than mine was not apparent 
to me, when I posted this question.

> What does "your" ~/.psqlrc have to do with any of this?  If you are
> executing psql while masquarding at the postgres user its the postgres
> user's​ ~/.psqlrc file that will be looked for.

> Typically one doesn't execute psql as the postgres user.  They configure
> the system so that they can execute psql as a regular user.  You should
> probably do that and then everything should work like you are thinking.




--
View this message in context: 
http://www.postgresql-archive.org/psqlrc-file-is-ignored-tp5971773p5971984.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Re: [GENERAL] ~/.psqlrc file is ignored

2017-07-19 Thread vstuart
Hi Thom: thank you for your reply; I can't figure this one out!  Per your reply:

[victoria@victoria ~]$ pg
  [sudo -u postgres -i]
  [sudo] password for victoria:

[postgres@victoria ~]$ psql -a
  psql (9.6.3)
  Type "help" for help.

postgres=# \q

[postgres@victoria ~]$ psql -af ~/.psqlrc
  /var/lib/postgres/.psqlrc: No such file or directory

[postgres@victoria ~]$ exit
  logout

[victoria@victoria ~]$

So, it appears that postgres is looking for the .psqlrc file there (does not 
exist), but ignoring my ~/.psqlrc file, right?

Edit: from that, it appears that postgres thinks that my home directory is 
/var/lib/postgres/.  ... Confirmed:

[postgres@victoria ~]$ echo $HOME
  /var/lib/postgres

As a simple solution, I can sudo symlink MY ~/.psqlrc to that directory 
(/var/...; changing ownership also to postgres), but there appears to be some 
underlying issue, as Pg should find ~/.psqlrc, correct?

FYI, I installed postgresql (Arch Linux) using the "pacman" package manager; 
the only significant change I made is to define a custom data directory, on my 
home partition.


From: "Thom Brown-2 [via PostgreSQL]" 
Subject: Re: ~/.psqlrc file is ignored
Date: Wed, 19 Jul 2017 11:31:49 -0700 (MST)

Do you get anything with "psql -a"?

If not, what do you get when you use "psql -af ~/.psqlrc" ?

Thom




--
View this message in context: 
http://www.postgresql-archive.org/psqlrc-file-is-ignored-tp5971773p5971973.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

[GENERAL] ~/.psqlrc file is ignored

2017-07-19 Thread vstuart
My ~/.psqlrc file is ignored by my PostgreSQL installation (v.9.6.3; Arch
Linux x86_64 platform). 

Suggestions?



--
View this message in context: 
http://www.postgresql-archive.org/psqlrc-file-is-ignored-tp5971773.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general