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: respect IF NOT EXISTS in CREATE EXTERNAL CONNECTION #117312

Merged
merged 1 commit into from Jan 17, 2024

Conversation

stevendanna
Copy link
Collaborator

Previously, while the IF NOT EXISTS syntax was allowed nothing checked the boolean on the constructed tree node. Here, we check the boolean and elide DuplicateViolation errors from create.

Fixes #116997

Release note (bug fix): CREATE EXTERNAL CONNECTION IF NOT EXISTS no longer returns an error if the connection already exists.

@stevendanna stevendanna requested review from a team as code owners January 4, 2024 12:10
@stevendanna stevendanna requested review from msbutler and removed request for a team January 4, 2024 12:10
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@@ -144,6 +144,10 @@ func (p *planner) createExternalConnection(
// Create the External Connection and persist it in the
// `system.external_connections` table.
if err := ex.Create(params.ctx, txn); err != nil {
isNotExists := n.ConnectionLabelSpec.IfNotExists
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: s/is/if/r

also, I think a few words in the commit message could be swapped for clearer reading.

Previously, while the IF NOT EXISTS syntax was allowed nothing checked
the boolean on the constructed tree node. Here, we check the boolean
and elide DuplicateViolation errors from create.

Fixes cockroachdb#116997

Release note (bug fix): CREATE EXTERNAL CONNECTION IF NOT EXISTS no
longer returns an error if the connection already exists.
@stevendanna
Copy link
Collaborator Author

bors r=msbutler

@craig
Copy link
Contributor

craig bot commented Jan 17, 2024

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jan 17, 2024

Build succeeded:

@craig craig bot merged commit 9009eab into cockroachdb:master Jan 17, 2024
8 of 9 checks passed
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.

CREATE EXTERNAL CONNECTION IF NOT EXISTS does not work as expected
3 participants