--- SET vacuum_cost_delay to some value
+-- 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
SET vacuum_cost_delay TO 400;
+SET datestyle = 'ISO, YMD';
SHOW vacuum_cost_delay;
vacuum_cost_delay
-------------------
400ms
(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)
+
-- SET LOCAL has no effect outside of a transaction
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
400ms
(1 row)
+SET LOCAL datestyle = 'SQL';
+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)
+
-- SET LOCAL within a transaction that commits
BEGIN;
SET LOCAL vacuum_cost_delay TO 500;
500ms
(1 row)
+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)
+
COMMIT;
SHOW vacuum_cost_delay;
vacuum_cost_delay
400ms
(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)
+
-- SET should be reverted after ROLLBACK
BEGIN;
SET vacuum_cost_delay TO 600;
600ms
(1 row)
+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)
+
ROLLBACK;
SHOW vacuum_cost_delay;
vacuum_cost_delay
400ms
(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)
+
-- Some tests with subtransactions
BEGIN;
SET vacuum_cost_delay TO 700;
+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)
+
SAVEPOINT first_sp;
SET vacuum_cost_delay TO 800;
-ROLLBACK TO first_sp;
SHOW vacuum_cost_delay;
vacuum_cost_delay
-------------------
- 700ms
+ 800ms
+(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
(1 row)
SAVEPOINT second_sp;
SET vacuum_cost_delay TO 900;
+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)
+
SAVEPOINT third_sp;
SET vacuum_cost_delay TO 1000;
SHOW vacuum_cost_delay;
1s
(1 row)
+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)
+
ROLLBACK TO third_sp;
SHOW vacuum_cost_delay;
vacuum_cost_delay
900ms
(1 row)
+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)
+
ROLLBACK TO second_sp;
SHOW vacuum_cost_delay;
vacuum_cost_delay
700ms
(1 row)
+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)
+
ROLLBACK;
+SHOW vacuum_cost_delay;
+ vacuum_cost_delay
+-------------------
+ 400ms
+(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)
+
-- SET LOCAL with Savepoints
BEGIN;
SHOW vacuum_cost_delay;
400ms
(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;
SET LOCAL vacuum_cost_delay TO 300;
SHOW vacuum_cost_delay;
300ms
(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)
+
ROLLBACK TO sp;
SHOW vacuum_cost_delay;
vacuum_cost_delay
400ms
(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)
+
ROLLBACK;
+SHOW vacuum_cost_delay;
+ vacuum_cost_delay
+-------------------
+ 400ms
+(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)
+
-- SET followed by SET LOCAL
BEGIN;
SET vacuum_cost_delay TO 400;
500ms
(1 row)
+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)
+
COMMIT;
SHOW vacuum_cost_delay;
vacuum_cost_delay
400ms
(1 row)
+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)
+
--
-- 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)
+SELECT '2006-08-13 12:34:56'::timestamptz;
+ timestamptz
+------------------------
+ 2006-08-13 12:34:56-07
+(1 row)
+
RESET datestyle;
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)
+
--- SET vacuum_cost_delay to some value
+-- 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;
+
+-- SET to some nondefault value
SET vacuum_cost_delay TO 400;
+SET datestyle = 'ISO, YMD';
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
-- SET LOCAL has no effect outside of a transaction
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
+SET LOCAL datestyle = 'SQL';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
-- SET LOCAL within a transaction that commits
BEGIN;
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
+SET LOCAL datestyle = 'SQL';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
COMMIT;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
-- SET should be reverted after ROLLBACK
BEGIN;
SET vacuum_cost_delay TO 600;
SHOW vacuum_cost_delay;
+SET datestyle = 'German';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
ROLLBACK;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
-- Some tests with subtransactions
BEGIN;
SET vacuum_cost_delay TO 700;
+SET datestyle = 'MDY';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
SAVEPOINT first_sp;
SET vacuum_cost_delay TO 800;
-ROLLBACK TO first_sp;
SHOW vacuum_cost_delay;
+SET datestyle = 'German, DMY';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
+ROLLBACK TO first_sp;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
SAVEPOINT second_sp;
SET vacuum_cost_delay TO 900;
+SET datestyle = 'SQL, YMD';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
SAVEPOINT third_sp;
SET vacuum_cost_delay TO 1000;
SHOW vacuum_cost_delay;
+SET datestyle = 'Postgres, MDY';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
ROLLBACK TO third_sp;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
ROLLBACK TO second_sp;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
ROLLBACK;
+SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
-- SET LOCAL with Savepoints
BEGIN;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
SAVEPOINT sp;
SET LOCAL vacuum_cost_delay TO 300;
SHOW vacuum_cost_delay;
+SET LOCAL datestyle = 'Postgres, MDY';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
ROLLBACK TO sp;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
ROLLBACK;
+SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
-- SET followed by SET LOCAL
BEGIN;
SET vacuum_cost_delay TO 400;
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
+SET datestyle = 'ISO, DMY';
+SET LOCAL datestyle = 'Postgres, MDY';
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
COMMIT;
SHOW vacuum_cost_delay;
+SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
--
-- 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;
SET datestyle = iso, ymd;
SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;
RESET datestyle;
SHOW datestyle;
+SELECT '2006-08-13 12:34:56'::timestamptz;