Thread: [patch] GUC source file and line number

[patch] GUC source file and line number

From
Alvaro Herrera
Date:
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

Re: [patch] GUC source file and line number

From
Greg Smith
Date:
This looks quite handy.  Needs to have an update to the view-pg-settings 
section of the docs before it gets applied though.

I'd also like to get the default boot_val for each parameter exposed, 
similarly to how the min and max are available.  That should be easy to do 
using your changes as a guide for what to touch.  I'll try to fit that in 
this weekend so it makes the commitfest deadline.  I'll update the docs 
for all the changes (the ones in there already and the one I add) while 
I'm at it and submit a combined patch.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD


Re: [patch] GUC source file and line number

From
Magnus Hagander
Date:
Greg Smith wrote:
> This looks quite handy.  Needs to have an update to the view-pg-settings
> section of the docs before it gets applied though.
> 
> I'd also like to get the default boot_val for each parameter exposed,
> similarly to how the min and max are available.  That should be easy to
> do using your changes as a guide for what to touch.  I'll try to fit
> that in this weekend so it makes the commitfest deadline.  I'll update
> the docs for all the changes (the ones in there already and the one I
> add) while I'm at it and submit a combined patch.

Doing that is going to be a whole lot easier and less invasive, so I'd
suggest doing it as a separate patch. While there may be a small
conflict, it's going to be easy to resolve, and I think keeping them
apart makes it a lot easier to review - at least to review the simple patch.

//Magnus



Re: [patch] GUC source file and line number

From
Robert Treat
Date:
On Thursday 28 August 2008 13:08:58 Alvaro Herrera wrote:
> Hi,
>
> Here's a patch to add source file and line numbers to GUC variables.
> Basically this makes pg_settings look like this:
>
<snip>
> This should make life easier for tools trying to find the config file
> each setting is from (and possibly edit it).
>

If I have read this patch right, anything commented out (aka all of our 
default values) will emit null in these fields... right? Trying to decide 
just how helpful this will actually be for tool writers. 

-- 
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL


Re: [patch] GUC source file and line number

From
Alvaro Herrera
Date:
Robert Treat wrote:
> On Thursday 28 August 2008 13:08:58 Alvaro Herrera wrote:

> > This should make life easier for tools trying to find the config file
> > each setting is from (and possibly edit it).
> 
> If I have read this patch right, anything commented out (aka all of our 
> default values) will emit null in these fields... right?

Of course.

> Trying to decide just how helpful this will actually be for tool
> writers. 

Oh, it's easy -- just rip all the commented stuff out of the default
file.  It's useless anyway.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.