I am doing an SQL transaction from kohana 3.2 framework in PHP with Postgresql 9.0
I get an exception
Database_Exception [ 0 ]: ERROR: current transaction is aborted,
commands ignored until end of transaction block [ SELECT c.* FROM
contents c WHERE c.content_id = 129 AND EXISTS( SELECT NULL FROM
contents tmp WHERE tmp.content_id = c.content_id AND c.content_id =
129 GROUP BY tmp.content_id HAVING MAX(tmp.version) = c.version ) ]
which i strange because this implies to me that some SQL prior to this one failed and thus no more SQL statements are being accepted. However I have all my SQL calls in a try/catch block and do a rollback on catch before rethrowing.
so i should never see this exception right?, Instead expect to see the one before, which would have spoiled the transaction to begin with…
I added logging to my PHP DB driver, and logged the following SQL statements leading up to the problem. The last SELECT statement below is the one referenced in my exception above.
The statement prior to the exception statement is an INSERT which would be a good candidate for the spoiler, however when i run all these statements by hand they all go thru properly.
UPDATE "articles"
SET article_id = 126, title = 'abc', blurb = 'abc article blurb'
WHERE "article_id" = 126
SELECT c.* FROM contents c
WHERE c.content_id = 127
AND EXISTS(
SELECT NULL FROM contents tmp
WHERE tmp.content_id = c.content_id AND c.content_id = 127
GROUP BY tmp.content_id HAVING MAX(tmp.version) = c.version
)
SELECT c.* FROM contents c
WHERE c.content_id = 128 AND EXISTS(
SELECT NULL FROM contents tmp
WHERE tmp.content_id = c.content_id AND c.content_id = 128
GROUP BY tmp.content_id HAVING MAX(tmp.version) = c.version
)
INSERT INTO "contents"
("blurb", "content", "content_id", "content_type_id", "title", "author_id", "version", "editor_id")
VALUES
('postit art', 'FEATURE_IMG_david-chan-drawing_IMG_0221.JPG', 128, 2, 'david chan drawing', 5, 2, 4)
SELECT c.* FROM contents c
WHERE c.content_id = 129 AND EXISTS(
SELECT NULL FROM contents tmp
WHERE tmp.content_id = c.content_id AND c.content_id = 129
GROUP BY tmp.content_id HAVING MAX(tmp.version) = c.version
)
what is causing my transaction to abort ?
The PostgreSQL server itself will log errors in transactions, along with the SQL that caused them, that might help provide another end of the thread to get hold of?
You might need to define a
log_line_prefixto help you pick out your client if the database does a lot of different tasks (e.g. sth likelog_line_prefix = '%t %c %q%u@%h:%d ')