Re: Automatic transactions in psql

Lists: pgsql-hackerspgsql-patches
From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Automatic transactions in psql
Date: 2002-02-06 21:07:29
Message-ID: E16YZ9U-0001vx-00@granger.mail.mindspring.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The attached patch actually does two related things. First,
it keeps track of whether or not you are in a trnasaction
and modifies the prompt slightly when you are by putting
an asterick at the very front of it.

Secondly, it adds a "begin transaction" option that, when
enabled, ensures that you are always inside a transaction
while in psql, so you can always rollback. It does this
by issuing a BEGIN at the appropriate times. This patch
(if ever accepted) conflicts a bit with LO_RTANSACTION:
psql now *does* have a way to know if it is in a
transaction or not, so that part may need to get rewritten.

Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200202061602

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBPGGZ37ybkGcUlkrIEQJhJQCgr2TEKcvPakEIC8Exn09pInLLOywAoL4I
uGv3TL6hUm/O1oSPrDVdmdc4
=rmRt
-----END PGP SIGNATURE-----

Attachment Content-Type Size
patch text/plain 8.6 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Automatic transactions in psql
Date: 2002-02-07 00:17:25
Message-ID: Pine.LNX.4.30.0202061913070.682-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Greg Sabino Mullane writes:

> The attached patch actually does two related things. First,
> it keeps track of whether or not you are in a trnasaction
> and modifies the prompt slightly when you are by putting
> an asterick at the very front of it.

This is an interesting idea, although you may want to give the user the
option to customize his prompt. Add an escape, maybe %* or %t, with the
meaning "resolves to * if in a transaction block and to the empty string
if not". (The existing escapes were all stolen from tcsh, so look there
if you need an idea.)

> Secondly, it adds a "begin transaction" option that, when
> enabled, ensures that you are always inside a transaction
> while in psql, so you can always rollback.

This should be done in the backend.

--
Peter Eisentraut peter_e(at)gmx(dot)net


From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Automatic transactions in psql
Date: 2002-02-07 00:51:14
Message-ID: GNELIHDDFBOCMGBFGEFOEEEMCBAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

> Secondly, it adds a "begin transaction" option that, when
> enabled, ensures that you are always inside a transaction
> while in psql, so you can always rollback. It does this
> by issuing a BEGIN at the appropriate times. This patch
> (if ever accepted) conflicts a bit with LO_RTANSACTION:
> psql now *does* have a way to know if it is in a
> transaction or not, so that part may need to get rewritten.

Sweeeet. I've gone mad trying to get people with access to our production
databases to do _everything_ within a transaction when they start fiddling
around!

Chris


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Automatic transactions in psql
Date: 2002-02-07 18:40:34
Message-ID: 14614.1013107234@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> This is an interesting idea, although you may want to give the user the
> option to customize his prompt.

Seems cool. I am a bit worried about whether the transaction-block
detection mechanism is reliable, though. We might need to add something
to the FE/BE protocol to make this work correctly.

>> Secondly, it adds a "begin transaction" option that, when
>> enabled, ensures that you are always inside a transaction
>> while in psql, so you can always rollback.

> This should be done in the backend.

Agreed. If I recall recent discussions correctly, the spec says that
certain SQL commands should open a transaction and others should not.
It's not reasonable to have that logic in psql rather than the backend.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Automatic transactions in psql
Date: 2002-02-22 04:01:42
Message-ID: 200202220401.g1M41gW13973@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Thread added.

This has been saved for the 7.3 release:

http://candle.pha.pa.us/cgi-bin/pgpatches2

---------------------------------------------------------------------------

Greg Sabino Mullane wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> The attached patch actually does two related things. First,
> it keeps track of whether or not you are in a trnasaction
> and modifies the prompt slightly when you are by putting
> an asterick at the very front of it.
>
> Secondly, it adds a "begin transaction" option that, when
> enabled, ensures that you are always inside a transaction
> while in psql, so you can always rollback. It does this
> by issuing a BEGIN at the appropriate times. This patch
> (if ever accepted) conflicts a bit with LO_RTANSACTION:
> psql now *does* have a way to know if it is in a
> transaction or not, so that part may need to get rewritten.
>
> Greg Sabino Mullane greg(at)turnstep(dot)com
> PGP Key: 0x14964AC8 200202061602
>
> -----BEGIN PGP SIGNATURE-----
> Comment: http://www.turnstep.com/pgp.html
>
> iQA/AwUBPGGZ37ybkGcUlkrIEQJhJQCgr2TEKcvPakEIC8Exn09pInLLOywAoL4I
> uGv3TL6hUm/O1oSPrDVdmdc4
> =rmRt
> -----END PGP SIGNATURE-----
>

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Greg Sabino Mullane <greg(at)turnstep(dot)com>, Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Automatic transactions in psql
Date: 2002-02-22 15:21:51
Message-ID: 3C76620F.C73CBE11@fourpalms.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

...
> > Secondly, it adds a "begin transaction" option that, when
> > enabled, ensures that you are always inside a transaction
> > while in psql, so you can always rollback. It does this
> > by issuing a BEGIN at the appropriate times. This patch
> > (if ever accepted) conflicts a bit with LO_RTANSACTION:
> > psql now *does* have a way to know if it is in a
> > transaction or not, so that part may need to get rewritten.

This part of the feature (corresponding to the Ingres "autocommit = off"
feature) should be implemented in the backend rather than in psql. I've
had a moderate interest in doing this but haven't gotten to it; if
someone wants to pick it up I'm sure it would be well received...

- Thomas


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: lockhart(at)fourpalms(dot)org
Cc: Greg Sabino Mullane <greg(at)turnstep(dot)com>, Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Automatic transactions in psql
Date: 2002-02-22 16:09:48
Message-ID: 200202221609.g1MG9mT12566@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Thomas Lockhart wrote:
> ...
> > > Secondly, it adds a "begin transaction" option that, when
> > > enabled, ensures that you are always inside a transaction
> > > while in psql, so you can always rollback. It does this
> > > by issuing a BEGIN at the appropriate times. This patch
> > > (if ever accepted) conflicts a bit with LO_RTANSACTION:
> > > psql now *does* have a way to know if it is in a
> > > transaction or not, so that part may need to get rewritten.
>
> This part of the feature (corresponding to the Ingres "autocommit = off"
> feature) should be implemented in the backend rather than in psql. I've
> had a moderate interest in doing this but haven't gotten to it; if
> someone wants to pick it up I'm sure it would be well received...

Agreed. I wondered whether we could use the psql status part of this
patch. We currently cound parens and quotes, and show that in the psql
prompt. Could we do that for transaction status? Considering we
already track the parens/quotes, another level of status on the psql
display seems a bit much, even if we could do it reliably. Comments?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Automatic transactions in psql
Date: 2002-02-22 16:12:56
Message-ID: 200202221612.g1MGCv112712@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > This is an interesting idea, although you may want to give the user the
> > option to customize his prompt.
>
> Seems cool. I am a bit worried about whether the transaction-block
> detection mechanism is reliable, though. We might need to add something
> to the FE/BE protocol to make this work correctly.

OK, status on this? Seems we can't apply the patch as-is because of
reliability of the status display. Do people wnat a TODO item? I don't
think I want to make an incompatible protocol change for this feature.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Automatic transactions in psql
Date: 2002-02-22 16:17:25
Message-ID: 17306.1014394645@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> OK, status on this? Seems we can't apply the patch as-is because of
> reliability of the status display. Do people wnat a TODO item? I don't
> think I want to make an incompatible protocol change for this feature.

I believe Fernando Nasser at Red Hat is currently working on backend
changes to do this properly; so I recommend we not apply the psql hack.

The notion of customizing the psql prompt based on
in-an-xact-block-or-not seems cool; but I do not see how to do it
reliably without a protocol change, and it's not worth that.

regards, tom lane