Thread: Add %x to PROMPT1 and PROMPT2

Add %x to PROMPT1 and PROMPT2

From
Vik Fearing
Date:
I cannot ever think of a time when I don't want to know if I'm in a
transaction or not (and what its state is).  Every new setup I do, I add
%x to the psql prompt.

I think it should be part of the default prompt.  Path attached.
-- 
Vik Fearing

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Christoph Berg
Date:
Re: Vik Fearing 2020-01-26 <09502c40-cfe1-bb29-10f9-4b3fa7b2bbb2@2ndquadrant.com>
> I cannot ever think of a time when I don't want to know if I'm in a
> transaction or not (and what its state is).  Every new setup I do, I add
> %x to the psql prompt.
> 
> I think it should be part of the default prompt.  Path attached.

+1, same here.

Christoph



Re: Add %x to PROMPT1 and PROMPT2

From
Fabien COELHO
Date:
Hello Vik,

> I cannot ever think of a time when I don't want to know if I'm in a
> transaction or not (and what its state is).  Every new setup I do, I add
> %x to the psql prompt.
>
> I think it should be part of the default prompt.  Path attached.

Isn't there examples in the documentation which use the default prompts?

If so, should they be updated accordingly?

-- 
Fabien.



Re: Add %x to PROMPT1 and PROMPT2

From
Vik Fearing
Date:
On 26/01/2020 19:48, Fabien COELHO wrote:
> 
> Hello Vik,
> 
>> I cannot ever think of a time when I don't want to know if I'm in a
>> transaction or not (and what its state is).  Every new setup I do, I add
>> %x to the psql prompt.
>>
>> I think it should be part of the default prompt.  Path attached.
> 
> Isn't there examples in the documentation which use the default prompts?
> 
> If so, should they be updated accordingly?

Good catch!
I thought about the documentation but not the examples therein.

Updated patch attached.
-- 
Vik Fearing

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Fabien COELHO
Date:
Hello Vik,

>> Isn't there examples in the documentation which use the default prompts?
>>
>> If so, should they be updated accordingly?
>
> Good catch!
> I thought about the documentation but not the examples therein.
>
> Updated patch attached.

Ok.

Only one transaction prompt example in the whole documentation:-(
No tests is troubled by the change:-(
Sigh…

Patch applies and compiles cleanly, global and psql make check ok.

Doc build ok.

Works for me.

I'd be in favor of adding a non trivial session example in psql 
documentation at the end of the prompt stuff section, something like:

BEGIN;
CREATE TABLE
   Word(data TEXT PRIMARY KEY);
COPY Word(data) FROM STDIN;
hello
\.
SELECT 2+;
ROLLBACK;

but this is not necessary for this patch.

-- 
Fabien.

Re: Add %x to PROMPT1 and PROMPT2

From
Vik Fearing
Date:
On 29/01/2020 08:25, Fabien COELHO wrote:
> 
> Hello Vik,
> 
>>> Isn't there examples in the documentation which use the default prompts?
>>>
>>> If so, should they be updated accordingly?
>>
>> Good catch!
>> I thought about the documentation but not the examples therein.
>>
>> Updated patch attached.
> 
> Ok.
> 
> Only one transaction prompt example in the whole documentation:-(
> No tests is troubled by the change:-(
> Sigh…
> 
> Patch applies and compiles cleanly, global and psql make check ok.
> 
> Doc build ok.
> 
> Works for me.

Thanks for the review!

Would you mind changing the status in the commitfest app?
https://commitfest.postgresql.org/27/2427/
-- 
Vik Fearing



Re: Add %x to PROMPT1 and PROMPT2

From
Michael Paquier
Date:
On Wed, Jan 29, 2020 at 11:51:10PM +0100, Vik Fearing wrote:
> Thanks for the review!
>
> Would you mind changing the status in the commitfest app?
> https://commitfest.postgresql.org/27/2427/

FWIW, I am not really in favor of changing a default old enough that
it could vote (a45195a).
--
Michael

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Daniel Gustafsson
Date:
> On 3 Feb 2020, at 08:08, Michael Paquier <michael@paquier.xyz> wrote:

> FWIW, I am not really in favor of changing a default old enough that
> it could vote (a45195a).

That by itself doesn't seem a good reason to not change things.

My concern would be that users who have never ever considered that the prompt
can be changed, all of sudden wonder why the prompt is showing characters it
normally isn't, thus causing confusion.  That being said, I agree that this is
a better default long-term.

cheers ./daniel


Re: Add %x to PROMPT1 and PROMPT2

From
Alvaro Herrera
Date:
On 2020-Feb-03, Daniel Gustafsson wrote:

> > On 3 Feb 2020, at 08:08, Michael Paquier <michael@paquier.xyz> wrote:
> 
> > FWIW, I am not really in favor of changing a default old enough that
> > it could vote (a45195a).
> 
> That by itself doesn't seem a good reason to not change things.

Yeah.

> My concern would be that users who have never ever considered that the prompt
> can be changed, all of sudden wonder why the prompt is showing characters it
> normally isn't, thus causing confusion.  That being said, I agree that this is
> a better default long-term.

I think this is the good kind of surprise, not the bad kind.

I think the only kind of user that would be negatively affected would be
those that have scripted psql under expect(1) and would fail to read the
new prompt correctly.  But I would say that that kind of user is the one
most likely to be able to fix things as needed.  Everybody else is just
looking at an extra char in the screen, and they don't really care.

I'm +1 for the default change.

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



Re: Add %x to PROMPT1 and PROMPT2

From
Tom Lane
Date:
Daniel Gustafsson <daniel@yesql.se> writes:
> On 3 Feb 2020, at 08:08, Michael Paquier <michael@paquier.xyz> wrote:
>> FWIW, I am not really in favor of changing a default old enough that
>> it could vote (a45195a).

> That by itself doesn't seem a good reason to not change things.

> My concern would be that users who have never ever considered that the prompt
> can be changed, all of sudden wonder why the prompt is showing characters it
> normally isn't, thus causing confusion.  That being said, I agree that this is
> a better default long-term.

I've got the same misgivings as Michael.  In a green field this'd likely
be a good idea, but after so many years I'm afraid it will make fewer
people happy than unhappy.

Now on the other hand, we did change the server's default log_line_prefix
not so long ago (7d3235ba4), and the feared storm of complaints was pretty
much undetectable.  So maybe this'd go down the same way.  Worth noting
also is that this shouldn't be able to break any applications, since the
prompt is an interactive-only behavior.

            regards, tom lane



Re: Add %x to PROMPT1 and PROMPT2

From
Ian Barwick
Date:
On 2020/02/03 23:40, Tom Lane wrote:
> Daniel Gustafsson <daniel@yesql.se> writes:
>> On 3 Feb 2020, at 08:08, Michael Paquier <michael@paquier.xyz> wrote:
>>> FWIW, I am not really in favor of changing a default old enough that
>>> it could vote (a45195a).
> 
>> That by itself doesn't seem a good reason to not change things.
> 
>> My concern would be that users who have never ever considered that the prompt
>> can be changed, all of sudden wonder why the prompt is showing characters it
>> normally isn't, thus causing confusion.  That being said, I agree that this is
>> a better default long-term.
> 
> I've got the same misgivings as Michael.  In a green field this'd likely
> be a good idea, but after so many years I'm afraid it will make fewer
> people happy than unhappy.
> 
> Now on the other hand, we did change the server's default log_line_prefix
> not so long ago (7d323to se5ba4), and the feared storm of complaints was pretty
> much undetectable.  So maybe this'd go down the same way.  Worth noting
> also is that this shouldn't be able to break any applications, since the
> prompt is an interactive-only behavior.

The last change I recall affecting default psql behaviour was the addition
of COMP_KEYWORD_CASE in 9.2 (db84ba65), which personally I (and no doubt others)
found annoying, but the world still turns.

+1 one for this change, it's something I also add to every .psqlrc I setup.

Moreover, some of my work involves logging in at short notice to other people's
systems where I don't have control over the .psqlrc setup - while I can of
course set the prompt manually it's an extra step, and it would be really
nice to see the transaction status by default when working on critical
systems in a time-critical situation. (Obviously it'll take a few years
for this change to filter into production...).


Regards


Ian Barwick

-- 
Ian Barwick                   https://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services



Re: Add %x to PROMPT1 and PROMPT2

From
Michael Paquier
Date:
On Tue, Feb 04, 2020 at 10:31:43AM +0900, Ian Barwick wrote:
> The last change I recall affecting default psql behaviour was the addition
> of COMP_KEYWORD_CASE in 9.2 (db84ba65), which personally I (and no doubt others)
> found annoying, but the world still turns.
>
> +1 one for this change, it's something I also add to every .psqlrc I setup.

So..  We have:
+1: Vik, Ian, Daniel, Alvaro, Christoph
+-0: Tom (?), Fabien (?)
-1: Michael P.

So there is a clear majority in favor of changing the default.  Any
extra opinions from others?
--
Michael

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Robert Haas
Date:
On Tue, Feb 4, 2020 at 3:20 AM Michael Paquier <michael@paquier.xyz> wrote:
> So..  We have:
> +1: Vik, Ian, Daniel, Alvaro, Christoph
> +-0: Tom (?), Fabien (?)
> -1: Michael P.

I'm not really against this change but, given how long it's been the
way that it is, I think we shouldn't make it without more plus votes.
If we've actually got a broad consensus on it, sure, but I don't think
4 votes is a broad consensus.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: Add %x to PROMPT1 and PROMPT2

From
Tom Lane
Date:
Robert Haas <robertmhaas@gmail.com> writes:
> I'm not really against this change but, given how long it's been the
> way that it is, I think we shouldn't make it without more plus votes.
> If we've actually got a broad consensus on it, sure, but I don't think
> 4 votes is a broad consensus.

Fair point.  I'm still abstaining, but maybe this should be proposed
on pgsql-general to try to get more opinions?

            regards, tom lane



Re: Add %x to PROMPT1 and PROMPT2

From
Magnus Hagander
Date:
On Wed, Feb 5, 2020 at 3:30 PM Robert Haas <robertmhaas@gmail.com> wrote:
>
> On Tue, Feb 4, 2020 at 3:20 AM Michael Paquier <michael@paquier.xyz> wrote:
> > So..  We have:
> > +1: Vik, Ian, Daniel, Alvaro, Christoph
> > +-0: Tom (?), Fabien (?)
> > -1: Michael P.
>
> I'm not really against this change but, given how long it's been the
> way that it is, I think we shouldn't make it without more plus votes.
> If we've actually got a broad consensus on it, sure, but I don't think
> 4 votes is a broad consensus.

Here's another +1 for making the change.

//Magnus



Re: Add %x to PROMPT1 and PROMPT2

From
Fabien COELHO
Date:
>> +1 one for this change, it's something I also add to every .psqlrc I setup.
>
> So..  We have:
> +1: Vik, Ian, Daniel, Alvaro, Christoph
> +-0: Tom (?), Fabien (?)

I did not know I had a vote. I'm "+1" on this change, if that matters.

Just this morning I had a case where I wished I had the current 
transaction status under the eye under psql.

> -1: Michael P.
>
> So there is a clear majority in favor of changing the default.  Any
> extra opinions from others?

-- 
Fabien.



Re: Add %x to PROMPT1 and PROMPT2

From
Michael Paquier
Date:
On Wed, Feb 05, 2020 at 10:21:11AM -0500, Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> I'm not really against this change but, given how long it's been the
>> way that it is, I think we shouldn't make it without more plus votes.
>> If we've actually got a broad consensus on it, sure, but I don't think
>> 4 votes is a broad consensus.
>
> Fair point.  I'm still abstaining, but maybe this should be proposed
> on pgsql-general to try to get more opinions?

Indeed, still I am not sure what kind of number is enough to define a
large consensus.  Vik, could you start a new thread on -general?

FWIW, 24 hours later I am counting two more people in favor (Magnus
and Fabien), for a total of 7, with one abstention and one not in
favor.
--
Michael

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Vik Fearing
Date:
On 06/02/2020 03:38, Michael Paquier wrote:
> On Wed, Feb 05, 2020 at 10:21:11AM -0500, Tom Lane wrote:
>> Robert Haas <robertmhaas@gmail.com> writes:
>>> I'm not really against this change but, given how long it's been the
>>> way that it is, I think we shouldn't make it without more plus votes.
>>> If we've actually got a broad consensus on it, sure, but I don't think
>>> 4 votes is a broad consensus.
>>
>> Fair point.  I'm still abstaining, but maybe this should be proposed
>> on pgsql-general to try to get more opinions?
> 
> Indeed, still I am not sure what kind of number is enough to define a
> large consensus.  Vik, could you start a new thread on -general?

https://www.postgresql.org/message-id/flat/3d8e809b-fc26-87c5-55ac-616a98d2b0be%40postgresfriends.org
-- 
Vik Fearing



Re: Add %x to PROMPT1 and PROMPT2

From
Vik Fearing
Date:
On 06/02/2020 03:56, Vik Fearing wrote:
> On 06/02/2020 03:38, Michael Paquier wrote:
>> On Wed, Feb 05, 2020 at 10:21:11AM -0500, Tom Lane wrote:
>>> Robert Haas <robertmhaas@gmail.com> writes:
>>>> I'm not really against this change but, given how long it's been the
>>>> way that it is, I think we shouldn't make it without more plus votes.
>>>> If we've actually got a broad consensus on it, sure, but I don't think
>>>> 4 votes is a broad consensus.
>>>
>>> Fair point.  I'm still abstaining, but maybe this should be proposed
>>> on pgsql-general to try to get more opinions?
>>
>> Indeed, still I am not sure what kind of number is enough to define a
>> large consensus.  Vik, could you start a new thread on -general?
> 
> https://www.postgresql.org/message-id/flat/3d8e809b-fc26-87c5-55ac-616a98d2b0be%40postgresfriends.org

The vote here was 6 yeas and 1 nay (85.7%) with 2 abstentions.

The poll on pgsql-general has gone stale with 19 yeas and 2 nays (90.5%).

My poll on Twitter has ended with 33 yeas and 4 nays (89.2%).
https://twitter.com/pg_xocolatl/status/1225258876527874048

There is a little bit of overlap within those three groups but among the
minuscule percentage of our users that responded, the result is
overwhelmingly in favor of this change.
-- 
Vik Fearing



Re: Add %x to PROMPT1 and PROMPT2

From
Michael Paquier
Date:
On Mon, Feb 10, 2020 at 12:16:44AM +0100, Vik Fearing wrote:
> There is a little bit of overlap within those three groups but among the
> minuscule percentage of our users that responded, the result is
> overwhelmingly in favor of this change.

Thanks Vik for handling that.  So, it seems to me that we have a
conclusion here.  Any last words?
--
Michael

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Robert Haas
Date:
On Sun, Feb 9, 2020 at 7:45 PM Michael Paquier <michael@paquier.xyz> wrote:
> On Mon, Feb 10, 2020 at 12:16:44AM +0100, Vik Fearing wrote:
> > There is a little bit of overlap within those three groups but among the
> > minuscule percentage of our users that responded, the result is
> > overwhelmingly in favor of this change.
>
> Thanks Vik for handling that.  So, it seems to me that we have a
> conclusion here.  Any last words?

No objections here. I'm glad that we put in the effort to get more
opinions, but I agree that an overall vote of ~58 to ~8 is a pretty
strong consensus.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: Add %x to PROMPT1 and PROMPT2

From
Michael Paquier
Date:
On Tue, Feb 11, 2020 at 10:05:25AM -0500, Robert Haas wrote:
> No objections here. I'm glad that we put in the effort to get more
> opinions, but I agree that an overall vote of ~58 to ~8 is a pretty
> strong consensus.

Clearly, so done as dcdbb5a.
--
Michael

Attachment

Re: Add %x to PROMPT1 and PROMPT2

From
Vik Fearing
Date:
On 12/02/2020 05:35, Michael Paquier wrote:
> On Tue, Feb 11, 2020 at 10:05:25AM -0500, Robert Haas wrote:
>> No objections here. I'm glad that we put in the effort to get more
>> opinions, but I agree that an overall vote of ~58 to ~8 is a pretty
>> strong consensus.
> 
> Clearly, so done as dcdbb5a.

Thanks!
-- 
Vik Fearing