2006-08-13 21:31:06 +02:00
|
|
|
-- pg_regress should ensure that this default value applies; however
|
|
|
|
-- we can't rely on any specific default value of vacuum_cost_delay
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- SET to some nondefault value
|
2009-02-28 01:10:52 +01:00
|
|
|
SET vacuum_cost_delay TO 40;
|
2006-08-13 21:31:06 +02:00
|
|
|
SET datestyle = 'ISO, YMD';
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
-- SET LOCAL has no effect outside of a transaction
|
2009-02-28 01:10:52 +01:00
|
|
|
SET LOCAL vacuum_cost_delay TO 50;
|
2013-11-26 01:19:40 +01:00
|
|
|
WARNING: SET LOCAL can only be used in transaction blocks
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SET LOCAL datestyle = 'SQL';
|
2013-11-26 01:19:40 +01:00
|
|
|
WARNING: SET LOCAL can only be used in transaction blocks
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
-- SET LOCAL within a transaction that commits
|
|
|
|
BEGIN;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET LOCAL vacuum_cost_delay TO 50;
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
50ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SET LOCAL datestyle = 'SQL';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
SQL, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
-------------------------
|
|
|
|
08/13/2006 12:34:56 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
COMMIT;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
-- SET should be reverted after ROLLBACK
|
|
|
|
BEGIN;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET vacuum_cost_delay TO 60;
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
60ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SET datestyle = 'German';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-------------
|
|
|
|
German, DMY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
-------------------------
|
|
|
|
13.08.2006 12:34:56 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
ROLLBACK;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
-- Some tests with subtransactions
|
|
|
|
BEGIN;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET vacuum_cost_delay TO 70;
|
2006-08-13 21:31:06 +02:00
|
|
|
SET datestyle = 'MDY';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
SAVEPOINT first_sp;
|
2019-03-10 20:01:39 +01:00
|
|
|
SET vacuum_cost_delay TO 80.1;
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2019-03-10 20:01:39 +01:00
|
|
|
80100us
|
2006-08-13 21:31:06 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SET datestyle = 'German, DMY';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-------------
|
|
|
|
German, DMY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
-------------------------
|
|
|
|
13.08.2006 12:34:56 PDT
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ROLLBACK TO first_sp;
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SAVEPOINT second_sp;
|
2019-03-10 20:01:39 +01:00
|
|
|
SET vacuum_cost_delay TO '900us';
|
2006-08-13 21:31:06 +02:00
|
|
|
SET datestyle = 'SQL, YMD';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
SQL, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
-------------------------
|
|
|
|
08/13/2006 12:34:56 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
SAVEPOINT third_sp;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET vacuum_cost_delay TO 100;
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
100ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SET datestyle = 'Postgres, MDY';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------------
|
|
|
|
Sun Aug 13 12:34:56 2006 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
ROLLBACK TO third_sp;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2019-03-10 20:01:39 +01:00
|
|
|
900us
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
SQL, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
-------------------------
|
|
|
|
08/13/2006 12:34:56 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
ROLLBACK TO second_sp;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
70ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
ROLLBACK;
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-13 21:31:06 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
-- SET LOCAL with Savepoints
|
|
|
|
BEGIN;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
SAVEPOINT sp;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET LOCAL vacuum_cost_delay TO 30;
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
30ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SET LOCAL datestyle = 'Postgres, MDY';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------------
|
|
|
|
Sun Aug 13 12:34:56 2006 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
ROLLBACK TO sp;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
ROLLBACK;
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-13 21:31:06 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2007-09-11 02:06:42 +02:00
|
|
|
-- SET LOCAL persists through RELEASE (which was not true in 8.0-8.2)
|
|
|
|
BEGIN;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SAVEPOINT sp;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET LOCAL vacuum_cost_delay TO 30;
|
2007-09-11 02:06:42 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
30ms
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SET LOCAL datestyle = 'Postgres, MDY';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------------
|
|
|
|
Sun Aug 13 12:34:56 2006 PDT
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
RELEASE SAVEPOINT sp;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
30ms
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------------
|
|
|
|
Sun Aug 13 12:34:56 2006 PDT
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
ROLLBACK;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
-- SET followed by SET LOCAL
|
|
|
|
BEGIN;
|
2009-02-28 01:10:52 +01:00
|
|
|
SET vacuum_cost_delay TO 40;
|
|
|
|
SET LOCAL vacuum_cost_delay TO 50;
|
2006-08-04 02:00:14 +02:00
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
50ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SET datestyle = 'ISO, DMY';
|
|
|
|
SET LOCAL datestyle = 'Postgres, MDY';
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------------
|
|
|
|
Sun Aug 13 12:34:56 2006 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
COMMIT;
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
2009-02-28 01:10:52 +01:00
|
|
|
40ms
|
2006-08-04 02:00:14 +02:00
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, DMY
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
--
|
|
|
|
-- Test RESET. We use datestyle because the reset value is forced by
|
|
|
|
-- pg_regress, so it doesn't depend on the installation's configuration.
|
|
|
|
--
|
|
|
|
SET datestyle = iso, ymd;
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
-----------
|
|
|
|
ISO, YMD
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------
|
|
|
|
2006-08-13 12:34:56-07
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-04 02:00:14 +02:00
|
|
|
RESET datestyle;
|
|
|
|
SHOW datestyle;
|
|
|
|
DateStyle
|
|
|
|
---------------
|
|
|
|
Postgres, MDY
|
|
|
|
(1 row)
|
|
|
|
|
2006-08-13 21:31:06 +02:00
|
|
|
SELECT '2006-08-13 12:34:56'::timestamptz;
|
|
|
|
timestamptz
|
|
|
|
------------------------------
|
|
|
|
Sun Aug 13 12:34:56 2006 PDT
|
|
|
|
(1 row)
|
|
|
|
|
2019-03-10 17:58:51 +01:00
|
|
|
-- Test some simple error cases
|
|
|
|
SET seq_page_cost TO 'NaN';
|
2019-03-10 20:01:39 +01:00
|
|
|
ERROR: invalid value for parameter "seq_page_cost": "NaN"
|
2019-03-10 17:58:51 +01:00
|
|
|
SET vacuum_cost_delay TO '10s';
|
2019-03-10 18:18:17 +01:00
|
|
|
ERROR: 10000 ms is outside the valid range for parameter "vacuum_cost_delay" (0 .. 100)
|
2021-04-07 17:22:22 +02:00
|
|
|
SET no_such_variable TO 42;
|
|
|
|
ERROR: unrecognized configuration parameter "no_such_variable"
|
|
|
|
-- Test "custom" GUCs created on the fly (which aren't really an
|
|
|
|
-- intended feature, but many people use them).
|
2021-06-03 00:50:15 +02:00
|
|
|
SHOW custom.my_guc; -- error, not known yet
|
|
|
|
ERROR: unrecognized configuration parameter "custom.my_guc"
|
2021-04-07 17:22:22 +02:00
|
|
|
SET custom.my_guc = 42;
|
|
|
|
SHOW custom.my_guc;
|
|
|
|
custom.my_guc
|
|
|
|
---------------
|
|
|
|
42
|
|
|
|
(1 row)
|
|
|
|
|
2021-06-03 00:50:15 +02:00
|
|
|
RESET custom.my_guc; -- this makes it go to empty, not become unknown again
|
|
|
|
SHOW custom.my_guc;
|
|
|
|
custom.my_guc
|
|
|
|
---------------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SET custom.my.qualified.guc = 'foo';
|
|
|
|
SHOW custom.my.qualified.guc;
|
|
|
|
custom.my.qualified.guc
|
|
|
|
-------------------------
|
|
|
|
foo
|
|
|
|
(1 row)
|
|
|
|
|
2021-04-07 17:22:22 +02:00
|
|
|
SET custom."bad-guc" = 42; -- disallowed because -c cannot set this name
|
|
|
|
ERROR: invalid configuration parameter name "custom.bad-guc"
|
2021-06-03 00:50:15 +02:00
|
|
|
DETAIL: Custom parameter names must be two or more simple identifiers separated by dots.
|
2021-04-07 17:22:22 +02:00
|
|
|
SHOW custom."bad-guc";
|
|
|
|
ERROR: unrecognized configuration parameter "custom.bad-guc"
|
|
|
|
SET special."weird name" = 'foo'; -- could be allowed, but we choose not to
|
|
|
|
ERROR: invalid configuration parameter name "special.weird name"
|
2021-06-03 00:50:15 +02:00
|
|
|
DETAIL: Custom parameter names must be two or more simple identifiers separated by dots.
|
2021-04-07 17:22:22 +02:00
|
|
|
SHOW special."weird name";
|
|
|
|
ERROR: unrecognized configuration parameter "special.weird name"
|
2022-02-21 20:10:15 +01:00
|
|
|
-- Check what happens when you try to set a "custom" GUC within the
|
|
|
|
-- namespace of an extension.
|
|
|
|
SET plpgsql.extra_foo_warnings = true; -- allowed if plpgsql is not loaded yet
|
|
|
|
LOAD 'plpgsql'; -- this will throw a warning and delete the variable
|
|
|
|
WARNING: invalid configuration parameter name "plpgsql.extra_foo_warnings", removing it
|
|
|
|
DETAIL: "plpgsql" is now a reserved prefix.
|
|
|
|
SET plpgsql.extra_foo_warnings = true; -- now, it's an error
|
|
|
|
ERROR: invalid configuration parameter name "plpgsql.extra_foo_warnings"
|
|
|
|
DETAIL: "plpgsql" is a reserved prefix.
|
|
|
|
SHOW plpgsql.extra_foo_warnings;
|
|
|
|
ERROR: unrecognized configuration parameter "plpgsql.extra_foo_warnings"
|
2007-04-12 08:53:49 +02:00
|
|
|
--
|
2007-04-26 18:13:15 +02:00
|
|
|
-- Test DISCARD TEMP
|
2007-04-12 08:53:49 +02:00
|
|
|
--
|
|
|
|
CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS;
|
|
|
|
SELECT relname FROM pg_class WHERE relname = 'reset_test';
|
|
|
|
relname
|
|
|
|
------------
|
|
|
|
reset_test
|
|
|
|
(1 row)
|
|
|
|
|
2007-04-26 18:13:15 +02:00
|
|
|
DISCARD TEMP;
|
2007-04-12 08:53:49 +02:00
|
|
|
SELECT relname FROM pg_class WHERE relname = 'reset_test';
|
|
|
|
relname
|
|
|
|
---------
|
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
--
|
2007-04-26 18:13:15 +02:00
|
|
|
-- Test DISCARD ALL
|
2007-04-12 08:53:49 +02:00
|
|
|
--
|
|
|
|
-- do changes
|
|
|
|
DECLARE foo CURSOR WITH HOLD FOR SELECT 1;
|
|
|
|
PREPARE foo AS SELECT 1;
|
|
|
|
LISTEN foo_event;
|
|
|
|
SET vacuum_cost_delay = 13;
|
|
|
|
CREATE TEMP TABLE tmp_foo (data text) ON COMMIT DELETE ROWS;
|
2016-07-18 00:42:31 +02:00
|
|
|
CREATE ROLE regress_guc_user;
|
|
|
|
SET SESSION AUTHORIZATION regress_guc_user;
|
2007-04-12 08:53:49 +02:00
|
|
|
-- look changes
|
2010-02-16 23:34:57 +01:00
|
|
|
SELECT pg_listening_channels();
|
|
|
|
pg_listening_channels
|
|
|
|
-----------------------
|
2007-04-12 08:53:49 +02:00
|
|
|
foo_event
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT name FROM pg_prepared_statements;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
foo
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT name FROM pg_cursors;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
foo
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
|
|
|
13ms
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT relname from pg_class where relname = 'tmp_foo';
|
|
|
|
relname
|
|
|
|
---------
|
|
|
|
tmp_foo
|
|
|
|
(1 row)
|
|
|
|
|
2016-07-18 00:42:31 +02:00
|
|
|
SELECT current_user = 'regress_guc_user';
|
2007-04-12 08:53:49 +02:00
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
2007-04-26 18:13:15 +02:00
|
|
|
-- discard everything
|
|
|
|
DISCARD ALL;
|
2007-04-12 08:53:49 +02:00
|
|
|
-- look again
|
2010-02-16 23:34:57 +01:00
|
|
|
SELECT pg_listening_channels();
|
|
|
|
pg_listening_channels
|
|
|
|
-----------------------
|
2007-04-12 08:53:49 +02:00
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
SELECT name FROM pg_prepared_statements;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
SELECT name FROM pg_cursors;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
SHOW vacuum_cost_delay;
|
|
|
|
vacuum_cost_delay
|
|
|
|
-------------------
|
|
|
|
0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT relname from pg_class where relname = 'tmp_foo';
|
|
|
|
relname
|
|
|
|
---------
|
|
|
|
(0 rows)
|
|
|
|
|
2016-07-18 00:42:31 +02:00
|
|
|
SELECT current_user = 'regress_guc_user';
|
2007-04-12 08:53:49 +02:00
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
f
|
|
|
|
(1 row)
|
|
|
|
|
2016-07-18 00:42:31 +02:00
|
|
|
DROP ROLE regress_guc_user;
|
2007-09-03 02:39:26 +02:00
|
|
|
--
|
2012-04-11 17:29:22 +02:00
|
|
|
-- 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;
|
|
|
|
--
|
2007-09-03 02:39:26 +02:00
|
|
|
-- Tests for function-local GUC settings
|
|
|
|
--
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '3MB';
|
2007-09-03 02:39:26 +02:00
|
|
|
create function report_guc(text) returns text as
|
|
|
|
$$ select current_setting($1) $$ language sql
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '1MB';
|
|
|
|
select report_guc('work_mem'), current_setting('work_mem');
|
2007-09-03 02:39:26 +02:00
|
|
|
report_guc | current_setting
|
|
|
|
------------+-----------------
|
2009-10-21 22:38:58 +02:00
|
|
|
1MB | 3MB
|
2007-09-03 02:39:26 +02:00
|
|
|
(1 row)
|
|
|
|
|
2012-04-11 17:29:22 +02:00
|
|
|
alter function report_guc(text) set work_mem = '2MB';
|
2009-10-21 22:38:58 +02:00
|
|
|
select report_guc('work_mem'), current_setting('work_mem');
|
2007-09-03 02:39:26 +02:00
|
|
|
report_guc | current_setting
|
|
|
|
------------+-----------------
|
2009-10-21 22:38:58 +02:00
|
|
|
2MB | 3MB
|
2007-09-03 02:39:26 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
alter function report_guc(text) reset all;
|
2009-10-21 22:38:58 +02:00
|
|
|
select report_guc('work_mem'), current_setting('work_mem');
|
2007-09-03 02:39:26 +02:00
|
|
|
report_guc | current_setting
|
|
|
|
------------+-----------------
|
2009-10-21 22:38:58 +02:00
|
|
|
3MB | 3MB
|
2007-09-03 02:39:26 +02:00
|
|
|
(1 row)
|
|
|
|
|
2007-09-11 02:06:42 +02:00
|
|
|
-- SET LOCAL is restricted by a function SET option
|
|
|
|
create or replace function myfunc(int) returns text as $$
|
|
|
|
begin
|
2009-10-21 22:38:58 +02:00
|
|
|
set local work_mem = '2MB';
|
|
|
|
return current_setting('work_mem');
|
2007-09-11 02:06:42 +02:00
|
|
|
end $$
|
|
|
|
language plpgsql
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '1MB';
|
|
|
|
select myfunc(0), current_setting('work_mem');
|
|
|
|
myfunc | current_setting
|
|
|
|
--------+-----------------
|
|
|
|
2MB | 3MB
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
alter function myfunc(int) reset all;
|
2009-10-21 22:38:58 +02:00
|
|
|
select myfunc(0), current_setting('work_mem');
|
|
|
|
myfunc | current_setting
|
|
|
|
--------+-----------------
|
|
|
|
2MB | 2MB
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '3MB';
|
2007-09-11 02:06:42 +02:00
|
|
|
-- but SET isn't
|
|
|
|
create or replace function myfunc(int) returns text as $$
|
|
|
|
begin
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '2MB';
|
|
|
|
return current_setting('work_mem');
|
2007-09-11 02:06:42 +02:00
|
|
|
end $$
|
|
|
|
language plpgsql
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '1MB';
|
|
|
|
select myfunc(0), current_setting('work_mem');
|
|
|
|
myfunc | current_setting
|
|
|
|
--------+-----------------
|
|
|
|
2MB | 2MB
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '3MB';
|
2007-09-11 02:06:42 +02:00
|
|
|
-- it should roll back on error, though
|
|
|
|
create or replace function myfunc(int) returns text as $$
|
|
|
|
begin
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '2MB';
|
2007-09-11 02:06:42 +02:00
|
|
|
perform 1/$1;
|
2009-10-21 22:38:58 +02:00
|
|
|
return current_setting('work_mem');
|
2007-09-11 02:06:42 +02:00
|
|
|
end $$
|
|
|
|
language plpgsql
|
2009-10-21 22:38:58 +02:00
|
|
|
set work_mem = '1MB';
|
2007-09-11 02:06:42 +02:00
|
|
|
select myfunc(0);
|
|
|
|
ERROR: division by zero
|
2009-11-22 06:20:41 +01:00
|
|
|
CONTEXT: SQL statement "SELECT 1/$1"
|
2012-02-01 08:14:37 +01:00
|
|
|
PL/pgSQL function myfunc(integer) line 4 at PERFORM
|
2009-10-21 22:38:58 +02:00
|
|
|
select current_setting('work_mem');
|
2007-09-11 02:06:42 +02:00
|
|
|
current_setting
|
|
|
|
-----------------
|
2009-10-21 22:38:58 +02:00
|
|
|
3MB
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
2009-10-21 22:38:58 +02:00
|
|
|
select myfunc(1), current_setting('work_mem');
|
|
|
|
myfunc | current_setting
|
|
|
|
--------+-----------------
|
|
|
|
2MB | 2MB
|
2007-09-11 02:06:42 +02:00
|
|
|
(1 row)
|
|
|
|
|
2015-07-02 22:40:55 +02:00
|
|
|
-- check current_setting()'s behavior with invalid setting name
|
|
|
|
select current_setting('nosuch.setting'); -- FAIL
|
|
|
|
ERROR: unrecognized configuration parameter "nosuch.setting"
|
|
|
|
select current_setting('nosuch.setting', false); -- FAIL
|
|
|
|
ERROR: unrecognized configuration parameter "nosuch.setting"
|
|
|
|
select current_setting('nosuch.setting', true) is null;
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- after this, all three cases should yield 'nada'
|
|
|
|
set nosuch.setting = 'nada';
|
|
|
|
select current_setting('nosuch.setting');
|
|
|
|
current_setting
|
|
|
|
-----------------
|
|
|
|
nada
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select current_setting('nosuch.setting', false);
|
|
|
|
current_setting
|
|
|
|
-----------------
|
|
|
|
nada
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
select current_setting('nosuch.setting', true);
|
|
|
|
current_setting
|
|
|
|
-----------------
|
|
|
|
nada
|
|
|
|
(1 row)
|
|
|
|
|
2013-09-04 00:32:20 +02:00
|
|
|
-- Normally, CREATE FUNCTION should complain about invalid values in
|
|
|
|
-- function SET options; but not if check_function_bodies is off,
|
|
|
|
-- because that creates ordering hazards for pg_dump
|
|
|
|
create function func_with_bad_set() returns int as $$ select 1 $$
|
|
|
|
language sql
|
|
|
|
set default_text_search_config = no_such_config;
|
|
|
|
NOTICE: text search configuration "no_such_config" does not exist
|
|
|
|
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
|
|
|
|
set check_function_bodies = off;
|
|
|
|
create function func_with_bad_set() returns int as $$ select 1 $$
|
|
|
|
language sql
|
|
|
|
set default_text_search_config = no_such_config;
|
|
|
|
NOTICE: text search configuration "no_such_config" does not exist
|
|
|
|
select func_with_bad_set();
|
|
|
|
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
|
|
|
|
reset check_function_bodies;
|
2019-01-15 00:30:24 +01:00
|
|
|
set default_with_oids to f;
|
|
|
|
-- Should not allow to set it to true.
|
|
|
|
set default_with_oids to t;
|
|
|
|
ERROR: tables declared WITH OIDS are not supported
|
2022-01-31 00:56:41 +01:00
|
|
|
-- Test GUC categories and flag patterns
|
|
|
|
SELECT pg_settings_get_flags(NULL);
|
|
|
|
pg_settings_get_flags
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT pg_settings_get_flags('does_not_exist');
|
|
|
|
pg_settings_get_flags
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
CREATE TABLE tab_settings_flags AS SELECT name, category,
|
|
|
|
'EXPLAIN' = ANY(flags) AS explain,
|
Introduce GUC_NO_RESET flag.
Previously, the transaction-property GUCs such as transaction_isolation
could be reset after starting a transaction, because we marked them
as GUC_NO_RESET_ALL but still allowed a targeted RESET. That leads to
assertion failures or worse, because those properties aren't supposed
to change after we've acquired a transaction snapshot.
There are some NO_RESET_ALL variables for which RESET is okay, so
we can't just redefine the semantics of that flag. Instead introduce
a separate GUC_NO_RESET flag. Mark "seed", as well as the transaction
property GUCs, as GUC_NO_RESET.
We have to disallow GUC_ACTION_SAVE as well as straight RESET, because
otherwise a function having a "SET transaction_isolation" clause can
still break things: the end-of-function restore action is equivalent
to a RESET.
No back-patch, as it's conceivable that someone is doing something
this patch will forbid (like resetting one of these GUCs at transaction
start, or "CREATE FUNCTION ... SET transaction_read_only = 1") and not
running into problems with it today. Given how long we've had this
issue and not noticed, the side effects in non-assert builds can't be
too serious.
Per bug #17385 from Andrew Bille.
Masahiko Sawada
Discussion: https://postgr.es/m/17385-9ee529fb091f0ce5@postgresql.org
2022-09-27 17:47:12 +02:00
|
|
|
'NO_RESET' = ANY(flags) AS no_reset,
|
2022-01-31 00:56:41 +01:00
|
|
|
'NO_RESET_ALL' = ANY(flags) AS no_reset_all,
|
|
|
|
'NOT_IN_SAMPLE' = ANY(flags) AS not_in_sample,
|
|
|
|
'RUNTIME_COMPUTED' = ANY(flags) AS runtime_computed
|
|
|
|
FROM pg_show_all_settings() AS psas,
|
|
|
|
pg_settings_get_flags(psas.name) AS flags;
|
|
|
|
-- Developer GUCs should be flagged with GUC_NOT_IN_SAMPLE:
|
|
|
|
SELECT name FROM tab_settings_flags
|
|
|
|
WHERE category = 'Developer Options' AND NOT not_in_sample
|
|
|
|
ORDER BY 1;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
-- Most query-tuning GUCs are flagged as valid for EXPLAIN.
|
|
|
|
-- default_statistics_target is an exception.
|
|
|
|
SELECT name FROM tab_settings_flags
|
|
|
|
WHERE category ~ '^Query Tuning' AND NOT explain
|
|
|
|
ORDER BY 1;
|
|
|
|
name
|
|
|
|
---------------------------
|
|
|
|
default_statistics_target
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- Runtime-computed GUCs should be part of the preset category.
|
|
|
|
SELECT name FROM tab_settings_flags
|
|
|
|
WHERE NOT category = 'Preset Options' AND runtime_computed
|
|
|
|
ORDER BY 1;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
-- Preset GUCs are flagged as NOT_IN_SAMPLE.
|
|
|
|
SELECT name FROM tab_settings_flags
|
|
|
|
WHERE category = 'Preset Options' AND NOT not_in_sample
|
|
|
|
ORDER BY 1;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
(0 rows)
|
|
|
|
|
Introduce GUC_NO_RESET flag.
Previously, the transaction-property GUCs such as transaction_isolation
could be reset after starting a transaction, because we marked them
as GUC_NO_RESET_ALL but still allowed a targeted RESET. That leads to
assertion failures or worse, because those properties aren't supposed
to change after we've acquired a transaction snapshot.
There are some NO_RESET_ALL variables for which RESET is okay, so
we can't just redefine the semantics of that flag. Instead introduce
a separate GUC_NO_RESET flag. Mark "seed", as well as the transaction
property GUCs, as GUC_NO_RESET.
We have to disallow GUC_ACTION_SAVE as well as straight RESET, because
otherwise a function having a "SET transaction_isolation" clause can
still break things: the end-of-function restore action is equivalent
to a RESET.
No back-patch, as it's conceivable that someone is doing something
this patch will forbid (like resetting one of these GUCs at transaction
start, or "CREATE FUNCTION ... SET transaction_read_only = 1") and not
running into problems with it today. Given how long we've had this
issue and not noticed, the side effects in non-assert builds can't be
too serious.
Per bug #17385 from Andrew Bille.
Masahiko Sawada
Discussion: https://postgr.es/m/17385-9ee529fb091f0ce5@postgresql.org
2022-09-27 17:47:12 +02:00
|
|
|
-- NO_RESET implies NO_RESET_ALL.
|
|
|
|
SELECT name FROM tab_settings_flags
|
|
|
|
WHERE no_reset AND NOT no_reset_all
|
|
|
|
ORDER BY 1;
|
|
|
|
name
|
|
|
|
------
|
|
|
|
(0 rows)
|
|
|
|
|
2022-01-31 00:56:41 +01:00
|
|
|
DROP TABLE tab_settings_flags;
|