Thread: Transaction status in default psql prompt?

Transaction status in default psql prompt?

From
Peter Eisentraut
Date:
What do people think about adding the transaction status indicator to the
default psql prompt, so it'd look something like this:

peter=# begin;
BEGIN
peter*=# foo;
ERROR:  syntax error at or near "foo" at character 1
peter!=# rollback;
ROLLBACK
peter=#

I think many people would find that useful.

Btw., would anyone mind if the code for this indicator where not %T, but
say instead %x, because there is a correspondence between psql's codes and
tcsh's, and tcsh uses %T for the hour of the day, which is something that
someone might want to add someday.

-- 
Peter Eisentraut   peter_e@gmx.net



Re: Transaction status in default psql prompt?

From
Rod Taylor
Date:
On Wed, 2003-09-03 at 19:53, Peter Eisentraut wrote:
> What do people think about adding the transaction status indicator to the
> default psql prompt, so it'd look something like this:
>
> peter=# begin;
> BEGIN
> peter*=# foo;
> ERROR:  syntax error at or near "foo" at character 1
> peter!=# rollback;
> ROLLBACK
> peter=#
>
> I think many people would find that useful.

Great idea.  Would it be worth while adding the depth with the
assumption that sub-transactions will appear someday?


Re: Transaction status in default psql prompt?

From
Darcy Buskermolen
Date:
On Wednesday 03 September 2003 13:06, Rod Taylor wrote:
> On Wed, 2003-09-03 at 19:53, Peter Eisentraut wrote:
> > What do people think about adding the transaction status indicator to the
> > default psql prompt, so it'd look something like this:
> >
> > peter=# begin;
> > BEGIN
> > peter*=# foo;
> > ERROR:  syntax error at or near "foo" at character 1
> > peter!=# rollback;
> > ROLLBACK
> > peter=#
> >
> > I think many people would find that useful.
>
> Great idea.  Would it be worth while adding the depth with the
> assumption that sub-transactions will appear someday?

I  think this is a good idea as well. While we are on this, has there
ever/recently been any thought to not making transactions marked "failed" in
the event of a syntax error (given we don't have nested transactions), this
becomes most annoying when having to do a large manual set of updates and one
gets sloppy with typing?


--
Darcy Buskermolen
Wavefire Technologies Corp.
ph: 250.717.0200
fx:  250.763.1759
http://www.wavefire.com


Re: Transaction status in default psql prompt?

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> What do people think about adding the transaction status indicator to the
> default psql prompt, so it'd look something like this:
> 
> peter=# begin;
> BEGIN
> peter*=# foo;
> ERROR:  syntax error at or near "foo" at character 1
> peter!=# rollback;
> ROLLBACK
> peter=#
> 
> I think many people would find that useful.
> 
> Btw., would anyone mind if the code for this indicator where not %T, but
> say instead %x, because there is a correspondence between psql's codes and
> tcsh's, and tcsh uses %T for the hour of the day, which is something that
> someone might want to add someday.

If you take a close look at the output above, you will see that the
prompt shifts one character to the right when you are in a transaction. 
That is going to look terrible.  I don't think we should have a moving
prompt as a default.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: Transaction status in default psql prompt?

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> What do people think about adding the transaction status indicator to the
> default psql prompt, so it'd look something like this:

Okay with me.

> Btw., would anyone mind if the code for this indicator where not %T, but
> say instead %x, because there is a correspondence between psql's codes and
> tcsh's, and tcsh uses %T for the hour of the day, which is something that
> someone might want to add someday.

Go for it.  I chose %T at random, if there's a potential conflict now is
the time to fix it.
        regards, tom lane


Re: Transaction status in default psql prompt?

From
Bruce Momjian
Date:
Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > What do people think about adding the transaction status indicator to the
> > default psql prompt, so it'd look something like this:
> 
> Okay with me.
> 
> > Btw., would anyone mind if the code for this indicator where not %T, but
> > say instead %x, because there is a correspondence between psql's codes and
> > tcsh's, and tcsh uses %T for the hour of the day, which is something that
> > someone might want to add someday.
> 
> Go for it.  I chose %T at random, if there's a potential conflict now is
> the time to fix it.

If we vote to do it, can we have a place holder for when we are _not_ in
a transaction, so the prompt doesn't move around:
test==> BEGIN;test=*> SELECT 1;

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: Transaction status in default psql prompt?

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> If you take a close look at the output above, you will see that the
> prompt shifts one character to the right when you are in a transaction. 
> That is going to look terrible.

It didn't look so bad to me.  But anyway, what the %T indicator should
look like is an orthogonal discussion from whether it should be in the
default prompt, no?
        regards, tom lane


Re: Transaction status in default psql prompt?

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > If you take a close look at the output above, you will see that the
> > prompt shifts one character to the right when you are in a transaction. 
> > That is going to look terrible.
> 
> It didn't look so bad to me.  But anyway, what the %T indicator should
> look like is an orthogonal discussion from whether it should be in the
> default prompt, no?

Yes, I like the transaction status being the default prompt, but I don't
like the prompt shifting.  Remember guys who have the current directory
in their prompt --- the thing bounces around all over the place.

Maybe a natural indenting of the transaction commands will look good ---
I don't know, but I think we should look at it before making the
decision on the default appearance.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: Transaction status in default psql prompt?

From
"Jeroen T. Vermeulen"
Date:
On Wed, Sep 03, 2003 at 11:31:55PM -0400, Bruce Momjian wrote:
> 
> Yes, I like the transaction status being the default prompt, but I don't
> like the prompt shifting.  Remember guys who have the current directory
> in their prompt --- the thing bounces around all over the place.

Is that avoidable if you want to be able to indicate nesting level as well?
There may be a simple but difficult choice there.  Personally I'd like to
see something like an opening brace ("{") in my prompt for a transaction;
that'd be a nice, nagging reminder that I'm in the middle of unfinished
business.


Jeroen