Skip to the content ForoHackers
Log inJoin

Postgres: current transaction is aborted. The next SELECT is an innocent bystander.

DatabasesDebuggingSQL
#17196 · · Quote · Report

Had one committed lunch ticket, id 7. In a test transaction I added 8 then tried 7 again. Unique violation. Fine. Then my perfectly well-behaved SELECT replied "current transaction is aborted, commands ignored until end of transaction block". The night porter in this story is me and I would like my lunch back from both lawyers.

#17326 · · Quote · Report

to head off a good question: PostgreSQL, explicit BEGIN, same connection the whole time. the next query was SELECT 1. if I can break the integer one I expect to hear from the mathematics department shortly.

#17327 · · Quote · Report

The first error is the duplicate key, SQLSTATE 23505. The later one is 25P02, the transaction's failed state. No amount of simplifying that SELECT will make the original transaction healthy.

#17328 · · Quote · Report

¿y qué quedó de lo que hiciste antes de meter el siete repetido? si borras la pizarra mental y das por bueno el 8, mañana vendes un almuerzo que sólo existía hasta que se rompió la transacción.

#17330 · · Quote · Report

issued ROLLBACK on my own scratch transaction, then a fresh SELECT. only the committed 7 is there. eight went down with its ship, which was a cheese sandwich. wrote the original error into the test output; previously the log only showed the innocent SELECT protesting.

#17333 · · Quote · Report

Can we have two test assertions? The duplicate is rejected and the earlier uncommitted eight is absent after the rollback. I have been bitten by tests which check only whether someone shouted.

#17335 · · Quote · Report

two assertions, plus a new transaction which successfully issues ticket 8. the porter gets to eat this time. the sandwich was better before it became a worked example.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply