Skip site navigation (1) Skip section navigation (2)

Re: SET autocommit begins transaction?

From: Sean Chittenden <sean(at)chittenden(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: SET autocommit begins transaction?
Date: 2002-09-18 22:02:22
Message-ID: 20020918220222.GC15390@perrin.int.nxad.com (view raw or flat)
Thread:
Lists: pgsql-bugs
> > > > Problem is that through various DB APIs such as DBI, you can't
> > > > garuntee to the user doing development that that it's the 1st command
> > > > that they're performing.
> > > 
> > > OK, but why does my suggestion not work:
> > > 
> > > 	SET autocommit = ON;
> > > 	COMMIT;
> > 
> > Hrm... if I changed the DBI layer for Ruby to have:
> > 
> > db['AutoCommit'] = true
> > 
> > use 'SET autocommit = ON; COMMIT;' I think I'd be breaking tons of
> > applications where they wouldn't be expecting the commit.
> 
> Actually, the current approved way is:
> 
> 	BEGIN; SET autocommit = ON; COMMIT;

db.transaction do |dbh|
  db.do('DELETE FROM tbl WHERE id = 5')
  db['AutoCommit'] = true
end

Because there wasn't a commit given, that shouldn't actually delete
the rows found, but by tossing that AutoCommit in there, it should and
will generate a nifty warning if AutoCommit sends the above
BEGIN/SET/COMMIT.  -sc

-- 
Sean Chittenden

In response to

Responses

pgsql-bugs by date

Next:From: Bruce MomjianDate: 2002-09-18 22:05:58
Subject: Re: SET autocommit begins transaction?
Previous:From: Bruce MomjianDate: 2002-09-18 21:59:14
Subject: Re: SET autocommit begins transaction?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group