[gsmith@gregsmith.com: Re: [patch] GUC source file and line number] - Mailing list pgsql-hackers

From Alvaro Herrera
Subject [gsmith@gregsmith.com: Re: [patch] GUC source file and line number]
Date
Msg-id 20080902011705.GC3839@alvh.no-ip.org
Whole thread Raw
Responses Re: [gsmith@gregsmith.com: Re: [patch] GUC source file and line number]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Greg just sent me this patch, augmenting the one I sent to add source
file and line to GUC vars; Greg's patch adds a column with the default
value of each var.

I forward it to -hackers to have a public Message-Id to link to in the
Commitfest page.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Attached patch extends the last one Alvaro sent me to add a default_val
column to pg_settings.  I renumbered the new columns the sourcefile/line
patch added to fit it into a logical order (the default is just after the
enumvalues).  That and minimizing the number of times everybody has to
test in this area are why I wanted to squeeze this in at the same time.

Sample that shows the sort of thing I expect tuning tools will use this
for:

select name,setting,default_val from pg_settings where not
setting=default_val;

             name            |      setting       |    default_val
----------------------------+--------------------+-------------------
  archive_command            | (disabled)         |
  client_encoding            | UTF8               | SQL_ASCII
  default_text_search_config | pg_catalog.english | pg_catalog.simple
  lc_collate                 | en_US.UTF-8        | C
  lc_ctype                   | en_US.UTF-8        | C
  lc_messages                | en_US.UTF-8        |
  lc_monetary                | en_US.UTF-8        | C
  lc_numeric                 | en_US.UTF-8        | C
  lc_time                    | en_US.UTF-8        | C
  log_timezone               | US/Eastern         | UNKNOWN
  max_fsm_pages              | 204800             | 20000
  max_stack_depth            | 2048               | 100
  server_encoding            | UTF8               | SQL_ASCII
  shared_buffers             | 4096               | 1024
  TimeZone                   | US/Eastern         | UNKNOWN
  timezone_abbreviations     | Default            | UNKNOWN

While there is a "default" for source, it's impossible to distinguish
cases where someone set the value explicitly, but to the default value,
unless tool writers have their own database of what the defaults are.
That situation often happens when people uncomment the parameter in their
postgresql.conf but don't actually change it from the default.  Example:

select name,setting,default_val,sourcefile,sourceline from pg_settings
where name='max_connections';

       name       | setting | default_val |                   sourcefile
| sourceline
-----------------+---------+-------------+-------------------------------------------------+------------
  max_connections | 100     | 100         |
/home/gsmith/pgproject/guc/data/postgresql.conf |         61

Hope I didn't introduce any bugs in your otherwise clean patch.

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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Mysterious Bus Error with get_fn_expr_argtype()
Next
From: Tom Lane
Date:
Subject: Re: Fwd: [Patch Review] TRUNCATE Permission