Re: Improvements in psql hooks for variables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
Cc: "Ashutosh Sharma" <ashu(dot)coek88(at)gmail(dot)com>, "Rahila Syed" <rahilasyed90(at)gmail(dot)com>, "Stephen Frost" <sfrost(at)snowman(dot)net>, "Ashutosh Bapat" <ashutosh(dot)bapat(at)enterprisedb(dot)com>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improvements in psql hooks for variables
Date: 2017-01-20 14:02:10
Message-ID: 25606.1484920930@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Daniel Verite" <daniel(at)manitou-mail(dot)org> writes:
> Setting ENCODING has no effect, like DBNAME, USER, HOST and PORT.
> In a way, it's a read-only variable that's here to inform the user,
> not as a means to change the encoding (\encoding does that and
> has proper support for tab completion)

Right.

> What we could do as of this patch is emit an error when we try
> to change ENCODING, with a hook returning false and
> a proper error message hinting to \encoding.

I think that the current behavior is intentional: it avoids making
those variables reserved. That is, if you're unaware that psql
sets them and try to use them for your own purposes, it will work.

However, it only really works if psql never overwrites the values
after startup, whereas I believe all of these are overwritten by
a \c command.

So maybe it's more user-friendly to make these variables fully
reserved, even at the risk of breaking existing scripts. But
I don't think it's exactly an open-and-shut question.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-01-20 14:06:18 pgsql: Logical replication
Previous Message Jorge Solórzano 2017-01-20 13:53:05 Re: [JDBC] SEGFAULT in HEAD with replication