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

importer: disallow subqueries in function arguments for pg_dump #118569

Merged
merged 1 commit into from Feb 2, 2024

Conversation

DrewKimball
Copy link
Collaborator

Some functions can modify the db schema, and so can be included in a pg_dump file. The pg_dump importer logic type-checks such functions, which can lead to a nil-pointer panic in cases like the following: SELECT addgeometrycolumn('t', 'foo', 4326, (SELECT 'POINT'), 2) This is because subqueries cannot be type-checked outside the optbuilder, which sets the type annotation for the subquery.

This patch explicitly disallows subqueries in the type-checking that happens for processing a pg_dump file. This will ensure that users get an expected subqueries are not allowed in pg_dump function arguments error, instead of the panic.

Fixes #117724

Release note (bug fix): Fixed a rare panic that could happen during a pg_dump import that contains a function like SELECT addgeometrycolumn(...). Now, attempting to import a pg_dump with a function that has a subquery in one of its arguments results in an expected error.

Some functions can modify the db schema, and so can be included in a
pg_dump file. The pg_dump importer logic type-checks such functions,
which can lead to a nil-pointer panic in cases like the following:
`SELECT addgeometrycolumn('t', 'foo', 4326, (SELECT 'POINT'), 2)`
This is because subqueries cannot be type-checked outside the optbuilder,
which sets the type annotation for the subquery.

This patch explicitly disallows subqueries in the type-checking that
happens for processing a pg_dump file. This will ensure that users get
an expected `subqueries are not allowed in pg_dump function arguments`
error, instead of the panic.

Fixes cockroachdb#117724

Release note (bug fix): Fixed a rare panic that could happen during a
pg_dump import that contains a function like `SELECT addgeometrycolumn(...)`.
Now, attempting to import a pg_dump with a function that has a subquery
in one of its arguments results in an expected error.
@DrewKimball DrewKimball added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. labels Feb 1, 2024
@DrewKimball DrewKimball requested a review from a team as a code owner February 1, 2024 08:45
@DrewKimball DrewKimball requested review from michae2 and removed request for a team February 1, 2024 08:45
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Nice fix!

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)

@DrewKimball
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 2, 2024

Build succeeded:

@craig craig bot merged commit 90453dd into cockroachdb:master Feb 2, 2024
9 checks passed
@DrewKimball DrewKimball deleted the pgdump branch February 2, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import: v23.1.13: ReturnType called on TypedExpr with empty typeAnnotation on a subquery
3 participants