On 09/13/2011 10:53 AM, Chris Clark wrote:

Just to throw some PostgreSQL two cents in here. It should not be
legal to change transaction state once a transaction has begun. The
"driver" should throw an error if that is tried. It shouldn't even
reach the database. Consider:

conn.begin()
insert
insert

At this point we have an open transaction with two inserts pending. We
are then going to:

conn.autocommit()?

Uh, no. The driver should throw an error and the database should
remain waiting for next statement whether it be commit or whatever.


Thanks for the feedback Joshua, could you go in to more detail to
explain your reasoning please? I think the more justifications we have
the easier it is to make a decision.

You made an interesting comment on the autocommit request, "It shouldn't
even reach the database". I think you are saying the "set auto commit
on" request should not be sent to the DBMS and be handled by the driver
when there are open transactions. If I modify your example slightly:

conn.begin()
curs.execute('issue server non transaction based directive ') # i.e. not
dml, not ddl
curs.execute('issue session directive ') # for example change session
language of error messages, Oracle NLS settings
conn.autocommit()


What should be the behavior be in this instance? No exception being
raised makes the most sense to me as we are not in a transaction, I'm
unclear how the driver could make this decision unless it parses and
understands each curs.execute call.

Oh now that is interesting. Hmmm... perhaps conn.autocommit() is actually a synonym for conn.begin() except that it sets the autocommit property? So we would have two semantics:

conn.begin() -- Starts a transaction, will not commit unless explicit conn.commit() is called.

conn.autocommit() -- Works in autocommit mode, calling conn.commit() is redundant, each statement is executed as it is delivered to the database.

?

Sincerely,

Joshua D. Drake

--
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Support, Training, Professional Services and Development
The PostgreSQL Conference - http://www.postgresqlconference.org/
@cmdpromptinc - @postgresconf - 509-416-6579
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to