Skip site navigation (1) Skip section navigation (2)

[patch] GUC source file and line number

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [patch] GUC source file and line number
Date: 2008-08-28 17:08:58
Message-ID: 20080828170858.GF8424@alvh.no-ip.org (view raw or flat)
Thread:
Lists: 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: guc-sourcefile.patch
Description: text/x-diff (29.3 KB)

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2008-08-28 17:59:59
Subject: WIP patch: add parser location info to most expression node types
Previous:From: Brendan JurdDate: 2008-08-28 16:39:10
Subject: Re: TODO <-> Commitfest

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group