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

cherrypick-2.0: sql: fix cockroach dump for sequences #23062

Merged
merged 2 commits into from Feb 26, 2018

Conversation

knz
Copy link
Contributor

@knz knz commented Feb 25, 2018

Picks #23051.

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.

cc @cockroachdb/release

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.
@knz knz requested a review from vilterp February 25, 2018 09:56
@knz knz requested a review from a team as a code owner February 25, 2018 09:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz knz requested a review from a team February 25, 2018 09:56
@knz knz merged commit a77f18d into cockroachdb:release-2.0 Feb 26, 2018
@knz knz deleted the 20180225-cherrypick-23051 branch February 26, 2018 17:18
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

Successfully merging this pull request may close these issues.

None yet

3 participants