Re: SET autocommit begins transaction? - Mailing list pgsql-bugs

From Sean Chittenden
Subject Re: SET autocommit begins transaction?
Date
Msg-id 20020918220222.GC15390@perrin.int.nxad.com
Whole thread Raw
In response to Re: SET autocommit begins transaction?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: SET autocommit begins transaction?
List 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

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: SET autocommit begins transaction?
Next
From: Bruce Momjian
Date:
Subject: Re: SET autocommit begins transaction?