[patch] GUC source file and line number - Mailing list pgsql-hackers

From Alvaro Herrera
Subject [patch] GUC source file and line number
Date
Msg-id 20080828170858.GF8424@alvh.no-ip.org
Whole thread Raw
Responses Re: [patch] GUC source file and line number  (Greg Smith <gsmith@gregsmith.com>)
Re: [patch] GUC source file and line number  (Robert Treat <xzilla@users.sourceforge.net>)
List pgsql-hackers
Hi,

Here's a patch to add source file and line numbers to GUC variables.
Basically this makes pg_settings look like this:

alvherre=# select name, setting, sourcefile, sourceline from pg_settings where name like '%work%';
          name          | setting |                 sourcefile                 | sourceline
------------------------+---------+--------------------------------------------+------------
 autovacuum_max_workers | 3       |                                            |
 maintenance_work_mem   | 32768   | /pgsql/install/00head/data/postgresql.conf |        119
 work_mem               | 2048    | /pgsql/install/00head/data/workmem.conf    |          4
(3 lignes)

This should make life easier for tools trying to find the config file
each setting is from (and possibly edit it).

It was initially authored by Magnus, but I had to hit it with the clue
stick until it understood reset sources, i.e. to make it behave sanely
when a session has a SET value and then a SIGHUP causes the backend to
read a config file that has changed underneath it:

-- initial value was 1MB

alvherre=# select name, setting, sourcefile, sourceline from pg_settings where name = 'work_mem';
          name          | setting |                 sourcefile                 | sourceline
------------------------+---------+--------------------------------------------+------------
 work_mem               | 1024    | /pgsql/install/00head/data/workmem.conf    |          1
(1 ligne)

alvherre=# set work_mem to 200;
SET
alvherre=# select name, setting, sourcefile, sourceline from pg_settings where name = 'work_mem';
          name          | setting |                 sourcefile                 | sourceline
------------------------+---------+--------------------------------------------+------------
 work_mem               | 200     |                                            |
(1 ligne)

-- SIGHUP happened here, file was changed to 2MB and the setting moved some lines below

alvherre=# select name, setting, sourcefile, sourceline from pg_settings where name = 'work_mem';
          name          | setting |                 sourcefile                 | sourceline
------------------------+---------+--------------------------------------------+------------
 work_mem               | 200     |                                            |
(1 ligne)

alvherre=# reset work_mem ;
RESET
alvherre=# select name, setting, sourcefile, sourceline from pg_settings where name = 'work_mem';
          name          | setting |                 sourcefile                 | sourceline
------------------------+---------+--------------------------------------------+------------
 work_mem               | 2048    | /pgsql/install/00head/data/workmem.conf    |          4
(1 ligne)


--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment

pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: A smaller default postgresql.conf
Next
From: Dean Rasheed
Date:
Subject: Re: Auto-explain patch