-- SET vacuum_cost_delay to some value
SET vacuum_cost_delay TO 400;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

-- SET LOCAL has no effect outside of a transaction
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

-- SET LOCAL within a transaction that commits
BEGIN;
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 500ms
(1 row)

COMMIT;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

-- SET should be reverted after ROLLBACK
BEGIN;
SET vacuum_cost_delay TO 600;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 600ms
(1 row)

ROLLBACK;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

-- Some tests with subtransactions
BEGIN;
SET vacuum_cost_delay TO 700;
SAVEPOINT first_sp;
SET vacuum_cost_delay TO 800;
ROLLBACK TO first_sp;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 700ms
(1 row)

SAVEPOINT second_sp;
SET vacuum_cost_delay TO 900;
SAVEPOINT third_sp;
SET vacuum_cost_delay TO 1000;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 1s
(1 row)

ROLLBACK TO third_sp;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 900ms
(1 row)

ROLLBACK TO second_sp;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 700ms
(1 row)

ROLLBACK;
-- SET LOCAL with Savepoints
BEGIN;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

SAVEPOINT sp;
SET LOCAL vacuum_cost_delay TO 300;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 300ms
(1 row)

ROLLBACK TO sp;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

ROLLBACK;
-- SET followed by SET LOCAL
BEGIN;
SET vacuum_cost_delay TO 400;
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 500ms
(1 row)

COMMIT;
SHOW vacuum_cost_delay;
 vacuum_cost_delay 
-------------------
 400ms
(1 row)

--
-- Test RESET.  We use datestyle because the reset value is forced by
-- pg_regress, so it doesn't depend on the installation's configuration.
--
SHOW datestyle;
   DateStyle   
---------------
 Postgres, MDY
(1 row)

SET datestyle = iso, ymd;
SHOW datestyle;
 DateStyle 
-----------
 ISO, YMD
(1 row)

RESET datestyle;
SHOW datestyle;
   DateStyle   
---------------
 Postgres, MDY
(1 row)

