sql: fix cockroach dump for sequences#23051
Merged
knz merged 2 commits intocockroachdb:masterfrom Feb 25, 2018
Merged
Conversation
Prior to this patch, `cockroach dump` would attempt to determine the increment for a given sequence using a query to `pg_catalog.pg_sequences`. Unfortunately this query did not constraint the OID to the sequence considered, and so it would always retrieve the metata for the 1st sequence defined in the cluster overall, not the sequence being considered. This wasn't visible in tests because the tests all used the default sequence parameters. This patch fixes the issue by constraining the `pg_sequence` query appropriately. A related issue, which also prevented earlier recognition of this bug, is that the object `sqlConn` internal to the `cli` package (that attempts to emulate `sql.Conn` over the in-memory connection to the test server) is not appropriately checking that queries passed to its `QueryRow` method only return 1 row. If it did, it would have determined earlier that there were multiple results for the query on `pg_sequences`. This will be addressed separately. Release note (bug fix): `cockroach dump` is now able to dump sequences with non-default parameters.
Member
Release note: none
Contributor
|
Looking forward to @justinj's #22403, which will make it faster to write good tests. Thanks for the Reviewed 2 of 2 files at r1, 1 of 1 files at r2. Comments from Reviewable |
Contributor
Author
|
TFYR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prior to this patch,
cockroach dumpwould attempt to determine theincrement for a given sequence using a query to
pg_catalog.pg_sequences. Unfortunately this query did not constraintthe OID to the sequence considered, and so it would always retrieve
the metata for the 1st sequence defined in the cluster overall, not
the sequence being considered. This wasn't visible in tests because
the tests all used the default sequence parameters.
This patch fixes the issue by constraining the
pg_sequencequeryappropriately.
A related issue, which also prevented earlier recognition of this bug,
is that the object
sqlConninternal to theclipackage (thatattempts to emulate
sql.Connover the in-memory connection to thetest server) is not appropriately checking that queries passed to its
QueryRowmethod only return 1 row. If it did, it would havedetermined earlier that there were multiple results for the query on
pg_sequences. This will be addressed separately.Release note (bug fix):
cockroach dumpis now able to dump sequenceswith non-default parameters.