pg_settings view

From: Joe Conway <mail(at)joeconway(dot)com>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: pg_settings view
Date: 2002-08-10 22:56:02
Message-ID: 3D559A02.6030102@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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:

test=# update pg_settings set setting = 'on' where name =
'show_query_stats';
set_config
------------
on
(1 row)

test=# update pg_settings set setting = 'off' where name =
'show_query_stats';
set_config
------------
off
(1 row)

test=# update pg_settings set setting = 'off' where name = 'does not exist';
set_config
------------
(0 rows)

test=# update pg_settings set name = 'why would I do this?' where name =
'show_query_stats';
set_config
------------
(0 rows)

I have adjusted the regression test for rules also. All regression tests
passed.

I have not revised the docs yet. I wanted to see if this would be
accepted before spending time on the documentation, because it has gone
back and forth more than once already ;-)

If there are no objections, please apply.

Thanks,

Joe

Attachment Content-Type Size
all_settings.2002.08.10.1.patch text/plain 34.7 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-08-11 00:33:39 Re: pg_settings view
Previous Message Bruce Momjian 2002-08-10 22:16:36 Re: More schema support for psql