mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
Allow "SET list_guc TO NULL" to specify setting the GUC to empty.
We have never had a SET syntax that allows setting a GUC_LIST_INPUT parameter to be an empty list. A locution such as SET search_path = ''; doesn't mean that; it means setting the GUC to contain a single item that is an empty string. (For search_path the net effect is much the same, because search_path ignores invalid schema names and '' must be invalid.) This is confusing, not least because configuration-file entries and the set_config() function can easily produce empty-list values. We considered making the empty-string syntax do this, but that would foreclose ever allowing empty-string items to be valid in list GUCs. While there isn't any obvious use-case for that today, it feels like the kind of restriction that might hurt someday. Instead, let's accept the forbidden-up-to-now value NULL and treat that as meaning an empty list. (An objection to this could be "what if we someday want to allow NULL as a GUC value?". That seems unlikely though, and even if we did allow it for scalar GUCs, we could continue to treat it as meaning an empty list for list GUCs.) Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andrei Klychkov <andrew.a.klychkov@gmail.com> Reviewed-by: Jim Jones <jim.jones@uni-muenster.de> Discussion: https://postgr.es/m/CA+mfrmwsBmYsJayWjc8bJmicxc3phZcHHY=yW5aYe=P-1d_4bg@mail.gmail.com
This commit is contained in:
@@ -31,6 +31,28 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
|
||||
2006-08-13 12:34:56-07
|
||||
(1 row)
|
||||
|
||||
-- Check handling of list GUCs
|
||||
SET search_path = 'pg_catalog', Foo, 'Bar', '';
|
||||
SHOW search_path;
|
||||
search_path
|
||||
----------------------------
|
||||
pg_catalog, foo, "Bar", ""
|
||||
(1 row)
|
||||
|
||||
SET search_path = null; -- means empty list
|
||||
SHOW search_path;
|
||||
search_path
|
||||
-------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SET search_path = null, null; -- syntax error
|
||||
ERROR: syntax error at or near ","
|
||||
LINE 1: SET search_path = null, null;
|
||||
^
|
||||
SET enable_seqscan = null; -- error
|
||||
ERROR: NULL is an invalid value for enable_seqscan
|
||||
RESET search_path;
|
||||
-- SET LOCAL has no effect outside of a transaction
|
||||
SET LOCAL vacuum_cost_delay TO 50;
|
||||
WARNING: SET LOCAL can only be used in transaction blocks
|
||||
|
||||
@@ -3572,6 +3572,7 @@ CREATE FUNCTION func_with_set_params() RETURNS integer
|
||||
SET extra_float_digits TO 2
|
||||
SET work_mem TO '4MB'
|
||||
SET datestyle to iso, mdy
|
||||
SET temp_tablespaces to NULL
|
||||
SET local_preload_libraries TO "Mixed/Case", 'c:/''a"/path', '', '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
|
||||
IMMUTABLE STRICT;
|
||||
SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
|
||||
@@ -3585,6 +3586,7 @@ SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
|
||||
SET extra_float_digits TO '2' +
|
||||
SET work_mem TO '4MB' +
|
||||
SET "DateStyle" TO 'iso, mdy' +
|
||||
SET temp_tablespaces TO NULL +
|
||||
SET local_preload_libraries TO 'Mixed/Case', 'c:/''a"/path', '', '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'+
|
||||
AS $function$select 1;$function$ +
|
||||
|
||||
|
||||
@@ -12,6 +12,15 @@ SHOW vacuum_cost_delay;
|
||||
SHOW datestyle;
|
||||
SELECT '2006-08-13 12:34:56'::timestamptz;
|
||||
|
||||
-- Check handling of list GUCs
|
||||
SET search_path = 'pg_catalog', Foo, 'Bar', '';
|
||||
SHOW search_path;
|
||||
SET search_path = null; -- means empty list
|
||||
SHOW search_path;
|
||||
SET search_path = null, null; -- syntax error
|
||||
SET enable_seqscan = null; -- error
|
||||
RESET search_path;
|
||||
|
||||
-- SET LOCAL has no effect outside of a transaction
|
||||
SET LOCAL vacuum_cost_delay TO 50;
|
||||
SHOW vacuum_cost_delay;
|
||||
|
||||
@@ -1217,6 +1217,7 @@ CREATE FUNCTION func_with_set_params() RETURNS integer
|
||||
SET extra_float_digits TO 2
|
||||
SET work_mem TO '4MB'
|
||||
SET datestyle to iso, mdy
|
||||
SET temp_tablespaces to NULL
|
||||
SET local_preload_libraries TO "Mixed/Case", 'c:/''a"/path', '', '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
|
||||
IMMUTABLE STRICT;
|
||||
SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
|
||||
|
||||
Reference in New Issue
Block a user