Skip to content

cherry-pick 2.0: sql: fix the handling of current_schema and search_path#24758

Merged
craig[bot] merged 1 commit intocockroachdb:release-2.0from
knz:20180413-cherrypick-24718
Apr 13, 2018
Merged

cherry-pick 2.0: sql: fix the handling of current_schema and search_path#24758
craig[bot] merged 1 commit intocockroachdb:release-2.0from
knz:20180413-cherrypick-24718

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Apr 12, 2018

Picks #24718.

cc @cockroachdb/release

Prior to this patch, CockroachDB was following the pg docs to the
letter regarding the relationship between `search_path` and the
"current schema": the current schema was taken to always be the first
item in `search_path`, as indicated in
https://www.postgresql.org/docs/10/static/functions-info.html
("current_schema returns the name of the schema that is first in the
search path (or a null value if the search path is empty).")

This in turn impacts the creation of objects (tables, views, etc) when
the name is unqualified: pg also specifies that such objects are to be
created in the current schema.

Unfortunately the pg doc is incorrect, as pg has a more nuanced
behavior: only the _valid_ schemas in `search_path` are considered to
determine the current schema in that way.

This was causing an unfortunate visible compatibility bug: if the user
specified an invalid schema in the search path, subsequent create
operations would fail with CockroachDB and succeed with pg.

This patch corrects this issue by adopting pg's behavior.

Ditto for `current_schemas`.

Release note (sql change, bug fix): the built-in functions
`current_schema` and `current_schemas` now only consider valid
schemas, like PostgreSQL does.
@knz knz requested review from a team and justinj April 12, 2018 22:58
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Apr 13, 2018

bors r+

craig bot pushed a commit that referenced this pull request Apr 13, 2018
24758: cherry-pick 2.0: sql: fix the handling of current_schema and search_path r=knz a=knz

Picks #24718.

cc @cockroachdb/release 

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 13, 2018

Build succeeded

@craig craig bot merged commit 54a1632 into cockroachdb:release-2.0 Apr 13, 2018
@knz knz deleted the 20180413-cherrypick-24718 branch April 13, 2018 08:32
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.

4 participants