issue with pydo transactions in postgresql

Adam Ward <[email protected]> Mon, 20 Jun 2005 18:27:34 +1000
Newsgroups gmane.comp.web.skunkweb
Organization Managed Solutions
Message-ID <[email protected]>
When an error occurs in postgreSQL during a transaction block any
further commands executed will return an error. As seen by the
following:
=> begin work;
BEGIN
=> insert into users(name) values (NULL);
ERROR:  null value in column "name" violates not-null constraint
=> select * from users;
ERROR:  current transaction is aborted, commands ignored until end of
transaction block

This will result in psycopg throwing a ProgrammingError

As seen by logically the same code:
>>> User.new()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/pydo/base.py", line 402, in new
    return cls._new(fieldData, refetch)
  File "/usr/lib/python2.4/site-packages/pydo/base.py", line 438, in
_new
    res = conn.execute(sql, converter.values)
  File "/usr/lib/python2.4/site-packages/pydo/drivers/psycopgconn.py",
line 124, in execute
    c.execute(sql, values)
psycopg.IntegrityError: null value in column "name" violates not-null
constraint

>>> User.getSome()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/pydo/base.py", line 571, in
getSome
    results = conn.execute(query, values)
  File "/usr/lib/python2.4/site-packages/pydo/drivers/psycopgconn.py",
line 126, in execute
    c.execute(sql)
psycopg.ProgrammingError: current transaction is aborted, commands
ignored until end of transaction block


This results in a complete shutdown of any pydo objects using the same
connection alias.

The problem is fixed upon issuing a .commit() on any PyDO class.

I have also had problems when the underlying connection to the database
is lost. However I have been unable to recover from this.

Is there a better solution, or do you have any suggestions?


Using:
psycopg v2.0b3.
pydo 2.0a3

tested against:
Postgresql 8.0 and 7.4


-- 

Adam Ward



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click