diff options
| author | Bruce Momjian | 2002-08-15 02:51:27 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2002-08-15 02:51:27 +0000 |
| commit | 45e25445846e98fe4aac23d1073566c08cd62f0b (patch) | |
| tree | 7db989a91d752dca0a014eaaa6b160cb04b08b1c /src/bin/initdb | |
| parent | 4c4854c4583f1d7c3d0a28b714304e433f5571e8 (diff) | |
As discussed on several occasions previously, the new anonymous
composite type capability makes it possible to create a system view
based on a table function in a way that is hopefully palatable to
everyone. The attached patch takes advantage of this, moving
show_all_settings() from contrib/tablefunc into the backend (renamed
all_settings(). It is defined as a builtin returning type RECORD. During
initdb a system view is created to expose the same information presently
available through SHOW ALL. For example:
test=# select * from pg_settings where name like '%debug%';
name | setting
-----------------------+---------
debug_assertions | on
debug_pretty_print | off
debug_print_parse | off
debug_print_plan | off
debug_print_query | off
debug_print_rewritten | off
wal_debug | 0
(7 rows)
Additionally during initdb two rules are created which make it possible
to change settings by updating the system view -- a "virtual table" as
Tom put it. Here's an example:
Joe Conway
Diffstat (limited to 'src/bin/initdb')
| -rw-r--r-- | src/bin/initdb/initdb.sh | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh index 0a09d6252f2..d876a888a20 100644 --- a/src/bin/initdb/initdb.sh +++ b/src/bin/initdb/initdb.sh @@ -27,7 +27,7 @@ # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group # Portions Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.165 2002/08/08 19:39:05 tgl Exp $ +# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.166 2002/08/15 02:51:26 momjian Exp $ # #------------------------------------------------------------------------- @@ -1015,6 +1015,21 @@ CREATE VIEW pg_stat_database AS \ pg_stat_get_db_blocks_hit(D.oid) AS blks_hit \ FROM pg_database D; +CREATE VIEW pg_settings AS \ + SELECT \ + A.name, \ + A.setting \ + FROM pg_show_all_settings() AS A(name text, setting text); + +CREATE RULE pg_settings_u AS \ + ON UPDATE TO pg_settings \ + WHERE new.name = old.name DO \ + SELECT set_config(old.name, new.setting, 'f'); + +CREATE RULE pg_settings_n AS \ + ON UPDATE TO pg_settings \ + DO INSTEAD NOTHING; + EOF if [ "$?" -ne 0 ]; then exit_nicely |
