Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction rollback bug #1

Closed
jmcvetta opened this issue Mar 15, 2013 · 1 comment
Closed

Transaction rollback bug #1

jmcvetta opened this issue Mar 15, 2013 · 1 comment

Comments

@jmcvetta
Copy link

I have encountered a bug in transaction rollback handling. The bug occurs when one opens a transaction, issues a query, rolls back the transaction, then tries to issue another query on the same DB object that was used to create the transaction.

Error message is:

pq: unexpected describe rows response: 'C'

Error is coming from here: https://github.com/bmizerany/pq/blob/master/conn.go#L216

Postgres manual says 'C' is a legitimate response header:

CommandComplete (B)
Byte1('C')
Identifies the message as a command-completed response.

Int32
Length of message contents in bytes, including self.

String
The command tag. This is usually a single word that identifies which SQL command was completed.

For an INSERT command, the tag is INSERT oid rows, where rows is the number of rows inserted. oid is the object ID of the inserted row if rows is 1 and the target table has OIDs; otherwise oid is 0.

For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted.

For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated.

For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved.

For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by.

For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor.

For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)

Here's how libpq handles it: http://doxygen.postgresql.org/fe-protocol3_8c_source.html#l00199

Test Case

I wrote a test case that reproduces the bug: https://github.com/jmcvetta/pq/blob/tx_bug/conn_test.go#L469

Impact

This bug is currently blocking development of PostgreSQL dialect of qbs ORM: coocood/qbs#11

@jmcvetta
Copy link
Author

pq lib has moved to new location - re-created this issue pull request over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant