Add some basic tests of GUC behavior.

Joachim Wieland
This commit is contained in:
Tom Lane 2006-08-04 00:00:14 +00:00
parent 7946f77220
commit c82264291e
4 changed files with 222 additions and 4 deletions

View File

@ -0,0 +1,150 @@
-- 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)

View File

@ -1,6 +1,6 @@
# ----------
# The first group of parallel test
# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.32 2006/03/11 04:38:41 momjian Exp $
# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.33 2006/08/04 00:00:13 tgl Exp $
# ----------
test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric
@ -69,7 +69,7 @@ test: misc
# ----------
# The fifth group of parallel test
# ----------
test: select_views portals_p2 rules foreign_key cluster dependency
test: select_views portals_p2 rules foreign_key cluster dependency guc
# ----------
# The sixth group of parallel test

View File

@ -1,4 +1,4 @@
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.30 2006/01/22 05:20:34 neilc Exp $
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.31 2006/08/04 00:00:13 tgl Exp $
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: char
@ -84,6 +84,8 @@ test: portals_p2
test: rules
test: foreign_key
test: cluster
test: dependency
test: guc
test: limit
test: plpgsql
test: copy2
@ -100,4 +102,3 @@ test: polymorphism
test: rowtypes
test: stats
test: tablespace
test: dependency

View File

@ -0,0 +1,67 @@
-- SET vacuum_cost_delay to some value
SET vacuum_cost_delay TO 400;
SHOW vacuum_cost_delay;
-- SET LOCAL has no effect outside of a transaction
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
-- SET LOCAL within a transaction that commits
BEGIN;
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
COMMIT;
SHOW vacuum_cost_delay;
-- SET should be reverted after ROLLBACK
BEGIN;
SET vacuum_cost_delay TO 600;
SHOW vacuum_cost_delay;
ROLLBACK;
SHOW vacuum_cost_delay;
-- 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;
SAVEPOINT second_sp;
SET vacuum_cost_delay TO 900;
SAVEPOINT third_sp;
SET vacuum_cost_delay TO 1000;
SHOW vacuum_cost_delay;
ROLLBACK TO third_sp;
SHOW vacuum_cost_delay;
ROLLBACK TO second_sp;
SHOW vacuum_cost_delay;
ROLLBACK;
-- SET LOCAL with Savepoints
BEGIN;
SHOW vacuum_cost_delay;
SAVEPOINT sp;
SET LOCAL vacuum_cost_delay TO 300;
SHOW vacuum_cost_delay;
ROLLBACK TO sp;
SHOW vacuum_cost_delay;
ROLLBACK;
-- SET followed by SET LOCAL
BEGIN;
SET vacuum_cost_delay TO 400;
SET LOCAL vacuum_cost_delay TO 500;
SHOW vacuum_cost_delay;
COMMIT;
SHOW vacuum_cost_delay;
--
-- 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;
RESET datestyle;
SHOW datestyle;