Re: Bit by "commands ignored until end of transaction block" again

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Bit by "commands ignored until end of transaction block" again
Date: 2009-07-23 07:32:17
Message-ID: h493ls$fd$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)[local]:5432) 17:04:21 [test]
> # savepoint xyz;
> ERROR: SAVEPOINT can only be used in transaction blocks
> (csmith(at)[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 your example 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Glenn Maynard 2009-07-23 07:39:23 Re: Bit by "commands ignored until end of transaction block" again
Previous Message A. Kretschmer 2009-07-23 07:10:08 Re: Need magical advice for counting NOTHING