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

Attachment: msg04859/pgp00000.pgp
Description: PGP signature

Reply via email to