Ensure Postgresql search_path entries are quoted correctly #3009
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.
Impact
Description
In postgresql and it's varients (redshift, cockroachdb, etc), the search_path that gets set based on the defaultSchemaName uses the value returned from
show search_path
. Sometimes, objects such as$user
in that shown search path are note quoted like is needed to re-set them.This PR updates the logic from handling only values that start with a
$
and only on cockroachdb to handling all non-quoted values on all postgresql versions.The change handles cases where a value comes back already quoted from
show search_path
.For example, if defaultSchemaName is being set to
test
, it willset search_path=test, "$user", "public"
whether the originalshow seach_path
returned"$user", public
or$user, public
.By quoting
"public"
like that, it will enforce the case on public, but in my testing the value in search_path was already correctly cased. If I calledset search_path=$user, PUBLIC"
then show search_path still returned$user, public
. And if I calledset search_path=$user, "TEST", public
it showed as"$user", "TEST", public
. So the change seems correct still.Fixes #2928
Things to be aware of
Things to worry about