diff options
| author | Tom Lane | 2012-04-11 15:29:22 +0000 |
|---|---|---|
| committer | Tom Lane | 2012-04-11 16:02:50 +0000 |
| commit | 880bfc3287dd68cfe90d10d9597d7b0fd2dae3e5 (patch) | |
| tree | fc098a016d67756b4841267b50b634c7be695a0b /src/test | |
| parent | b035cb9db7aa7c0f28581b23feb10d3c559701f6 (diff) | |
Silently ignore any nonexistent schemas that are listed in search_path.
Previously we attempted to throw an error or at least warning for missing
schemas, but this was done inconsistently because of implementation
restrictions (in many cases, GUC settings are applied outside transactions
so that we can't do system catalog lookups). Furthermore, there were
exceptions to the rule even in the beginning, and we'd been poking more
and more holes in it as time went on, because it turns out that there are
lots of use-cases for having some irrelevant items in a common search_path
value. It seems better to just adopt a philosophy similar to what's always
been done with Unix PATH settings, wherein nonexistent or unreadable
directories are silently ignored.
This commit also fixes the documentation to point out that schemas for
which the user lacks USAGE privilege are silently ignored. That's always
been true but was previously not documented.
This is mostly in response to Robert Haas' complaint that 9.1 started to
throw errors or warnings for missing schemas in cases where prior releases
had not. We won't adopt such a significant behavioral change in a back
branch, so something different will be needed in 9.1.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/guc.out | 34 | ||||
| -rw-r--r-- | src/test/regress/sql/guc.sql | 20 |
2 files changed, 39 insertions, 15 deletions
diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out index d3248620499..271706d31e9 100644 --- a/src/test/regress/expected/guc.out +++ b/src/test/regress/expected/guc.out @@ -605,6 +605,31 @@ SELECT current_user = 'temp_reset_user'; DROP ROLE temp_reset_user; -- +-- search_path should react to changes in pg_namespace +-- +set search_path = foo, public, not_there_initially; +select current_schemas(false); + current_schemas +----------------- + {public} +(1 row) + +create schema not_there_initially; +select current_schemas(false); + current_schemas +------------------------------ + {public,not_there_initially} +(1 row) + +drop schema not_there_initially; +select current_schemas(false); + current_schemas +----------------- + {public} +(1 row) + +reset search_path; +-- -- Tests for function-local GUC settings -- set work_mem = '3MB'; @@ -617,14 +642,7 @@ select report_guc('work_mem'), current_setting('work_mem'); 1MB | 3MB (1 row) --- this should draw only a warning -alter function report_guc(text) set search_path = no_such_schema; -NOTICE: schema "no_such_schema" does not exist --- with error occurring here -select report_guc('work_mem'), current_setting('work_mem'); -ERROR: invalid value for parameter "search_path": "no_such_schema" -DETAIL: schema "no_such_schema" does not exist -alter function report_guc(text) reset search_path set work_mem = '2MB'; +alter function report_guc(text) set work_mem = '2MB'; select report_guc('work_mem'), current_setting('work_mem'); report_guc | current_setting ------------+----------------- diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql index 21ed86f26ba..0c217923814 100644 --- a/src/test/regress/sql/guc.sql +++ b/src/test/regress/sql/guc.sql @@ -183,6 +183,18 @@ SELECT current_user = 'temp_reset_user'; DROP ROLE temp_reset_user; -- +-- search_path should react to changes in pg_namespace +-- + +set search_path = foo, public, not_there_initially; +select current_schemas(false); +create schema not_there_initially; +select current_schemas(false); +drop schema not_there_initially; +select current_schemas(false); +reset search_path; + +-- -- Tests for function-local GUC settings -- @@ -194,13 +206,7 @@ set work_mem = '1MB'; select report_guc('work_mem'), current_setting('work_mem'); --- this should draw only a warning -alter function report_guc(text) set search_path = no_such_schema; - --- with error occurring here -select report_guc('work_mem'), current_setting('work_mem'); - -alter function report_guc(text) reset search_path set work_mem = '2MB'; +alter function report_guc(text) set work_mem = '2MB'; select report_guc('work_mem'), current_setting('work_mem'); |
