SET autocommit begins transaction?

From: Sean Chittenden <sean(at)chittenden(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: SET autocommit begins transaction?
Date: 2002-09-18 18:17:00
Message-ID: 20020918181700.GN99484@perrin.int.nxad.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Here's the simplest way of reproducing this:

ways# psql -q template1 pgsql
template1=# SET AUTOCOMMIT TO OFF;
template1=# DROP DATABASE my_db_name;
ERROR: DROP DATABASE: may not be called in a transaction block

2002-09-18 11:05:19 LOG: query: select getdatabaseencoding()
2002-09-18 11:05:19 LOG: query: SELECT usesuper FROM pg_catalog.pg_user WHERE usename = 'pgsql'
2002-09-18 11:05:30 LOG: query: SET AUTOCOMMIT TO OFF;
2002-09-18 11:05:38 LOG: query: DROP DATABASE my_db_name;
2002-09-18 11:05:38 ERROR: DROP DATABASE: may not be called in a transaction block
2002-09-18 11:05:38 LOG: statement: DROP DATABASE my_db_name;

Does turnning autocommit off enter you into a transaction? Am I
smoking something or does that seems broken? It looks like this was a
conscious and deliberate decission based off of the comments in
src/backend/access/transam/xact.c around lines 1248-1293. In my
reading of the code, I might be confusing the GUC autocommit with the
SET autocommit, but ... this just doesn't seem right because it
forces my application code to do the following:

db = MyOrg::Db.connect('init')
db.rollback
db.do('DROP DATABASE my_db_name')

which reads really awkwardly and warrents a comment explaining why I'm
rolling back immediately after I connect. Thoughts/comments? -sc

--
Sean Chittenden

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Sean Chittenden 2002-09-18 18:31:44 Re: [NOVICE] Postgres storing time in strange manner
Previous Message Tom Lane 2002-09-18 14:26:41 Re: [NOVICE] Postgres storing time in strange manner