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

sql/pgwire: send proper tags when returning an Ack message #3890

Closed
nvanbenschoten opened this issue Jan 15, 2016 · 9 comments
Closed

sql/pgwire: send proper tags when returning an Ack message #3890

nvanbenschoten opened this issue Jan 15, 2016 · 9 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@nvanbenschoten
Copy link
Member

We currently have a comment here which I have found to be incorrect in practice. For instance, Go's pg driver requires that these tags be returned for operations like BEGIN, COMMIT, or ROLLBACK. See here.

@nvanbenschoten nvanbenschoten added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) SQL labels Jan 15, 2016
@tamird
Copy link
Contributor

tamird commented Jan 15, 2016

How come this doesn't manifest as a test failure? Can you reproduce this in a test?

@dt
Copy link
Member

dt commented Jan 15, 2016

@mjibson and I were looking at this yesterday (in process of looking at #3849). The tags are described more at http://www.postgresql.org/docs/current/static/protocol-message-formats.html

@nvanbenschoten
Copy link
Member Author

@tamird I don't think we ever use any of these commands in a test with a postgre driver. For instance, the only place in our entire codebase where we open a transaction from a sql/driver is when testing the old cockroach driver.

@tamird
Copy link
Contributor

tamird commented Jan 15, 2016

Ah, right. Seems like we send BEGIN as a "statement" in the logic tests, side-stepping this issue.

@dt
Copy link
Member

dt commented Jan 15, 2016

like #3852, despite being pg-wire specific, this will probably want to get propagated through the driver and handled by the actual parser, right?

@nvanbenschoten
Copy link
Member Author

It seems like the link @dt provided is missing some of the tags that are sent back by postgres. I'm not sure if that means postgres returns more than the actual protocol defines, but it seems like drivers are expecting more that the protocol. Here's the list of all tags returned by postgres. It requires a handle on the parse tree, so I assume this would need to get propagated through the driver and handled by the parser.

@dt
Copy link
Member

dt commented Jan 15, 2016

It's possible the go driver is unusual in actually looking at the tag and not just the result code:
looking at ruby's pg, (which leaves most of the work to libpq) it doesn't check.
psycopg2, if I've managed to follow all the c linked c modules, doesn't either https://github.com/psycopg/psycopg2/blob/master/psycopg/pqpath.c#L461

@nvanbenschoten
Copy link
Member Author

I think you're right that it's not completely standard to check, but it seems to me like a good idea to comply with what Postgres sends if possible. Also, interestingly the commit that introduced the tag checking to Go's primary sql/driver cited libpg as doing the same.

@dt
Copy link
Member

dt commented Jan 15, 2016

I'm guessing that commit comment is referring to https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-protocol2.c#L1074 though it isn't completely clear to me what xactStatus is for -- I guess it is surfaced in PQtransactionStatus though.

dt added a commit to dt/cockroach that referenced this issue Jan 27, 2016
Some clients inspect returned command tags eg lib/pq when starting a transaction,
and will fail if the expected tag is not sent.

Statements return their string tag along with their StatementType,
and Executor includes these its results so that pgwrire can return them to clients.

Fixes cockroachdb#3890
dt added a commit to dt/cockroach that referenced this issue Jan 27, 2016
Some clients inspect returned command tags eg lib/pq when starting a transaction,
and will fail if the expected tag is not sent.

Statements return their string tag along with their StatementType,
and Executor includes these its results so that pgwrire can return them to clients.

Fixes cockroachdb#3890
dt added a commit to dt/cockroach that referenced this issue Jan 27, 2016
Some clients inspect returned command tags eg lib/pq when starting a transaction,
and will fail if the expected tag is not sent.

Statements return their string tag along with their StatementType,
and Executor includes these its results so that pgwrire can return them to clients.

Fixes cockroachdb#3890
dt added a commit to dt/cockroach that referenced this issue Feb 1, 2016
Some clients inspect returned command tags eg lib/pq when starting a transaction,
and will fail if the expected tag is not sent.

Statements return their string tag along with their StatementType,
and Executor includes these its results so that pgwrire can return them to clients.

Fixes cockroachdb#3890
dt added a commit to dt/cockroach that referenced this issue Feb 1, 2016
Some clients inspect returned command tags eg lib/pq when starting a transaction,
and will fail if the expected tag is not sent.

Statements return their string tag along with their StatementType,
and Executor includes these its results so that pgwrire can return them to clients.

Fixes cockroachdb#3890
dt added a commit to dt/cockroach that referenced this issue Feb 1, 2016
Some clients inspect returned command tags eg lib/pq when starting a transaction,
and will fail if the expected tag is not sent.

Statements return their string tag along with their StatementType,
and Executor includes these its results so that pgwrire can return them to clients.

Fixes cockroachdb#3890
@dt dt closed this as completed in #3984 Feb 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

No branches or pull requests

3 participants