Re: Bit by "commands ignored until end of transaction block" again - Mailing list pgsql-sql

From Thomas Kellerer
Subject Re: Bit by "commands ignored until end of transaction block" again
Date
Msg-id h493ls$fd$1@ger.gmane.org
Whole thread Raw
In response to Re: Bit by "commands ignored until end of transaction block" again  (Chris <dmagick@gmail.com>)
List pgsql-sql
Chris, 23.07.2009 09:06:
> psql -d dbname
> ..
> # select now();
>               now
> -------------------------------
>  2009-07-23 17:04:21.406424+10
> (1 row)
> 
> Time: 2.434 ms
> (csmith@[local]:5432) 17:04:21 [test]
> # savepoint xyz;
> ERROR:  SAVEPOINT can only be used in transaction blocks
> (csmith@[local]:5432) 17:04:25 [test]
> 
> You haven't explicitly started a transaction, therefore savepoints won't 
> work.
> 
> Django (it seems) just issues queries with no knowledge of (and no way 
> to support) them.

The above situation only arises if you run in autocommit mode which is the default for psql (which I have *never*
understood).
 

If you do a "\set AUTOCOMMIT off", then you can set a savepoint without using BEGIN. I have this in my psqlrc.conf and
yourexample looks like this on my computer:
 

c:\Temp>psql training thomas
psql (8.4.0)
Type "help" for help.

training=> select now();           now
----------------------------2009-07-23 09:30:55.791+02
(1 row)


training=> savepoint abc;
SAVEPOINT
training=> release abc;
RELEASE
training=>


I don't believe any serious ORM would run in autocommit mode, so that shouldn't be a problem. 

Thomas



pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Need magical advice for counting NOTHING
Next
From: Glenn Maynard
Date:
Subject: Re: Bit by "commands ignored until end of transaction block" again