Hi,

I've been using postgres for a little over a year now, and overall I've
been very pleased with it. Thanks!

The psql client is really nice, but I was frustrated by the lack of a
"no-autocommit" mode. So, I made a few small modifications to the client
to wrap everything in a transaction block automatically. I've been using
it locally for a while, and it seems to work alright. The patch is
attached (it's a patch to the 7.2.1 branch).

Do other people think this is a useful feature?

The one thing that I don't like about the patch, but that I'm not sure how
to handle, is telling the user that one transaction has ended and another
has begun. Currently, I am just printing NOTICE messages ("NOTICE:
aborting current transaction and beginning a new one", for example) but
this seems wrong, since the messages aren't coming from the backend.
Suggestions on how to handle this?

...dave
Thu, 22 Aug 2002 09:38:01 -0700 (PDT)
David Van Wie <vanwie@cryptio.net>
turning off autocommit behavior in psql
David Van Wie <vanwie@cryptio.net> writes:
> The psql client is really nice, but I was frustrated by the lack of a
> "no-autocommit" mode. So, I made a few small modifications to the client
> to wrap everything in a transaction block automatically.

I believe our intention has been to modify the backend to offer that
behavior (with a GUC variable to turn it on or off).  Supporting it
only in psql doesn't seem the way to go.

			regards, tom lane

Thu, 22 Aug 2002 12:59:16 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: turning off autocommit behavior in psql 
On Thu, 22 Aug 2002, Tom Lane wrote:

> I believe our intention has been to modify the backend to offer that
> behavior (with a GUC variable to turn it on or off).  Supporting it
> only in psql doesn't seem the way to go.

After playing around with the transaction code for a while, I think I have
a reasonable idea of how to do this in the backend. This is my first time
working with the backend code, so it's entirely possible that I'm going
about this completely wrong, but the change seems to work and pass
regression tests.

I added a GUC variable "autocommit" which defaults to true. (Current
behavior). When it is set to false, the backend should begin a transaction
block if it is not inside one when executing any command. I did this by
changing StartTransactionCommand() in backend/access/transam/xact.c to
call BeginTransactionBlock() after StartTransaction() if it is not
currently in a transaction block.

Does this sound like a reasonable approach?

My first attempt at a patch (to current cvs source) is attached.

...dave
Thu, 22 Aug 2002 18:36:20 -0700 (PDT)
David Van Wie <vanwie@cryptio.net>
Re: turning off autocommit behavior in psql 

Your patch has been added to the PostgreSQL unapplied patches list at:

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

I will try to apply it within the next 48 hours.

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


David Van Wie wrote:
> On Thu, 22 Aug 2002, Tom Lane wrote:
> 
> > I believe our intention has been to modify the backend to offer that
> > behavior (with a GUC variable to turn it on or off).  Supporting it
> > only in psql doesn't seem the way to go.
> 
> After playing around with the transaction code for a while, I think I have
> a reasonable idea of how to do this in the backend. This is my first time
> working with the backend code, so it's entirely possible that I'm going
> about this completely wrong, but the change seems to work and pass
> regression tests.
> 
> I added a GUC variable "autocommit" which defaults to true. (Current
> behavior). When it is set to false, the backend should begin a transaction
> block if it is not inside one when executing any command. I did this by
> changing StartTransactionCommand() in backend/access/transam/xact.c to
> call BeginTransactionBlock() after StartTransaction() if it is not
> currently in a transaction block.
> 
> Does this sound like a reasonable approach?
> 
> My first attempt at a patch (to current cvs source) is attached.
> 
> ...dave

Content-Description: 

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  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, Pennsylvania 19073

Tue, 27 Aug 2002 16:41:31 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: turning off autocommit behavior in psql
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Your patch has been added to the PostgreSQL unapplied patches list at:

Please wait for this to be reviewed.

			regards, tom lane

Tue, 27 Aug 2002 18:04:36 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: turning off autocommit behavior in psql 

Tom Lane has applied this patch and merged it into our code.  Thanks.

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

David Van Wie wrote:
> On Thu, 22 Aug 2002, Tom Lane wrote:
> 
> > I believe our intention has been to modify the backend to offer that
> > behavior (with a GUC variable to turn it on or off).  Supporting it
> > only in psql doesn't seem the way to go.
> 
> After playing around with the transaction code for a while, I think I have
> a reasonable idea of how to do this in the backend. This is my first time
> working with the backend code, so it's entirely possible that I'm going
> about this completely wrong, but the change seems to work and pass
> regression tests.
> 
> I added a GUC variable "autocommit" which defaults to true. (Current
> behavior). When it is set to false, the backend should begin a transaction
> block if it is not inside one when executing any command. I did this by
> changing StartTransactionCommand() in backend/access/transam/xact.c to
> call BeginTransactionBlock() after StartTransaction() if it is not
> currently in a transaction block.
> 
> Does this sound like a reasonable approach?
> 
> My first attempt at a patch (to current cvs source) is attached.
> 
> ...dave

Content-Description: 

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  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, Pennsylvania 19073

Sat, 31 Aug 2002 01:42:11 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: turning off autocommit behavior in psql