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.
--- Begin Message --- 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 [EMAIL PROTECTED] http://www.gregsmith.com Baltimore, MD
Index: doc/src/sgml/catalogs.sgml
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/doc/src/sgml/catalogs.sgml,v
retrieving revision 2.172
diff -c -r2.172 catalogs.sgml
*** doc/src/sgml/catalogs.sgml  30 Jul 2008 17:05:04 -0000      2.172
--- doc/src/sgml/catalogs.sgml  1 Sep 2008 23:55:25 -0000
***************
*** 6414,6419 ****
--- 6414,6436 ----
        <entry>Allowed values in enum parameters (NULL for non-enum
        values)</entry>
       </row>
+      <row>
+       <entry><structfield>default_val</structfield></entry>
+       <entry><type>text</type></entry>
+       <entry>Default value if the parameter is not explicitly set</entry>
+      </row>
+      <row>
+       <entry><structfield>sourcefile</structfield></entry>
+       <entry><type>text</type></entry>
+       <entry>Input file the current value was set from (if any), helpful 
+       when using configuration include directives</entry>
+      </row>
+      <row>
+       <entry><structfield>sourceline</structfield></entry>
+       <entry><type>text</type></entry>
+       <entry>Line number within the sourcefile the current value was set 
+       from</entry>
+      </row>
      </tbody>
     </tgroup>
    </table>
Index: src/backend/utils/adt/ri_triggers.c
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/backend/utils/adt/ri_triggers.c,v
retrieving revision 1.109
diff -c -r1.109 ri_triggers.c
*** src/backend/utils/adt/ri_triggers.c 19 May 2008 04:14:24 -0000      1.109
--- src/backend/utils/adt/ri_triggers.c 1 Sep 2008 23:27:02 -0000
***************
*** 2738,2743 ****
--- 2738,2744 ----
        snprintf(workmembuf, sizeof(workmembuf), "%d", maintenance_work_mem);
        (void) set_config_option("work_mem", workmembuf,
                                                         PGC_USERSET, 
PGC_S_SESSION,
+                                                        NULL, 0,
                                                         GUC_ACTION_LOCAL, 
true);
  
        if (SPI_connect() != SPI_OK_CONNECT)
***************
*** 2827,2832 ****
--- 2828,2834 ----
        snprintf(workmembuf, sizeof(workmembuf), "%d", old_work_mem);
        (void) set_config_option("work_mem", workmembuf,
                                                         PGC_USERSET, 
PGC_S_SESSION,
+                                                        NULL, 0,
                                                         GUC_ACTION_LOCAL, 
true);
  
        return true;
Index: src/backend/utils/misc/guc-file.l
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/backend/utils/misc/guc-file.l,v
retrieving revision 1.56
diff -c -r1.56 guc-file.l
*** src/backend/utils/misc/guc-file.l   22 Aug 2008 00:20:40 -0000      1.56
--- src/backend/utils/misc/guc-file.l   1 Sep 2008 23:27:02 -0000
***************
*** 39,44 ****
--- 39,46 ----
  {
        char       *name;
        char       *value;
+       char       *filename;
+       int                sourceline;
        struct name_value_pair *next;
  };
  
***************
*** 232,238 ****
                }
  
                if (!set_config_option(item->name, item->value, context,
!                                                          PGC_S_FILE, 
GUC_ACTION_SET, false))
                        goto cleanup_list;
        }
  
--- 234,240 ----
                }
  
                if (!set_config_option(item->name, item->value, context,
!                                                          PGC_S_FILE, NULL, 0, 
GUC_ACTION_SET, false))
                        goto cleanup_list;
        }
  
***************
*** 280,286 ****
  
                /* Now we can re-apply the wired-in default */
                set_config_option(gconf->name, NULL, context, PGC_S_DEFAULT,
!                                                 GUC_ACTION_SET, true);
        }
  
        /*
--- 282,288 ----
  
                /* Now we can re-apply the wired-in default */
                set_config_option(gconf->name, NULL, context, PGC_S_DEFAULT,
!                                                 NULL, 0, GUC_ACTION_SET, 
true);
        }
  
        /*
***************
*** 296,314 ****
        envvar = getenv("PGDATESTYLE");
        if (envvar != NULL)
                set_config_option("datestyle", envvar, PGC_POSTMASTER,
!                                                 PGC_S_ENV_VAR, 
GUC_ACTION_SET, true);
  
        envvar = getenv("PGCLIENTENCODING");
        if (envvar != NULL)
                set_config_option("client_encoding", envvar, PGC_POSTMASTER,
!                                                 PGC_S_ENV_VAR, 
GUC_ACTION_SET, true);
  
  
        /* If we got here all the options checked out okay, so apply them. */
        for (item = head; item; item = item->next)
        {
                set_config_option(item->name, item->value, context,
!                                                 PGC_S_FILE, GUC_ACTION_SET, 
true);
        }
  
        /* Remember when we last successfully loaded the config file. */
--- 298,317 ----
        envvar = getenv("PGDATESTYLE");
        if (envvar != NULL)
                set_config_option("datestyle", envvar, PGC_POSTMASTER,
!                                                 PGC_S_ENV_VAR, NULL, 0, 
GUC_ACTION_SET, true);
  
        envvar = getenv("PGCLIENTENCODING");
        if (envvar != NULL)
                set_config_option("client_encoding", envvar, PGC_POSTMASTER,
!                                                 PGC_S_ENV_VAR, NULL, 0, 
GUC_ACTION_SET, true);
  
  
        /* If we got here all the options checked out okay, so apply them. */
        for (item = head; item; item = item->next)
        {
                set_config_option(item->name, item->value, context,
!                                                 PGC_S_FILE, item->filename, 
item->sourceline,
!                                                 GUC_ACTION_SET, true);
        }
  
        /* Remember when we last successfully loaded the config file. */
***************
*** 483,488 ****
--- 486,493 ----
                                pfree(item->value);
                                item->name = opt_name;
                                item->value = opt_value;
+                               item->filename = pstrdup(config_file);
+                               item->sourceline = ConfigFileLineno-1;
                        }
                        else
                        {
***************
*** 490,495 ****
--- 495,502 ----
                                item = palloc(sizeof *item);
                                item->name = opt_name;
                                item->value = opt_value;
+                               item->filename = pstrdup(config_file);
+                               item->sourceline = ConfigFileLineno-1;
                                item->next = *head_p;
                                *head_p = item;
                                if (*tail_p == NULL)
***************
*** 502,507 ****
--- 509,516 ----
                        item = palloc(sizeof *item);
                        item->name = opt_name;
                        item->value = opt_value;
+                       item->filename = pstrdup(config_file);
+                       item->sourceline = ConfigFileLineno-1;
                        item->next = NULL;
                        if (*head_p == NULL)
                                *head_p = item;
***************
*** 553,558 ****
--- 562,568 ----
  
                pfree(item->name);
                pfree(item->value);
+               pfree(item->filename);
                pfree(item);
                item = next;
        }
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.470
diff -c -r1.470 guc.c
*** src/backend/utils/misc/guc.c        25 Aug 2008 15:11:00 -0000      1.470
--- src/backend/utils/misc/guc.c        1 Sep 2008 23:37:09 -0000
***************
*** 3200,3205 ****
--- 3200,3209 ----
                gconf->reset_source = PGC_S_DEFAULT;
                gconf->source = PGC_S_DEFAULT;
                gconf->stack = NULL;
+               gconf->sourcefile = NULL;
+               gconf->sourceline = 0;
+               gconf->reset_sourcefile = NULL;
+               gconf->reset_sourceline = 0;
  
                switch (gconf->vartype)
                {
***************
*** 3541,3547 ****
                                                                                
                   PGC_S_SESSION))
                                                        elog(ERROR, "failed to 
reset %s", conf->gen.name);
                                        *conf->variable = conf->reset_val;
-                                       conf->gen.source = 
conf->gen.reset_source;
                                        break;
                                }
                        case PGC_INT:
--- 3545,3550 ----
***************
*** 3553,3559 ****
                                                                                
                   PGC_S_SESSION))
                                                        elog(ERROR, "failed to 
reset %s", conf->gen.name);
                                        *conf->variable = conf->reset_val;
-                                       conf->gen.source = 
conf->gen.reset_source;
                                        break;
                                }
                        case PGC_REAL:
--- 3556,3561 ----
***************
*** 3565,3571 ****
                                                                                
                   PGC_S_SESSION))
                                                        elog(ERROR, "failed to 
reset %s", conf->gen.name);
                                        *conf->variable = conf->reset_val;
-                                       conf->gen.source = 
conf->gen.reset_source;
                                        break;
                                }
                        case PGC_STRING:
--- 3567,3572 ----
***************
*** 3594,3600 ****
                                        }
  
                                        set_string_field(conf, conf->variable, 
str);
-                                       conf->gen.source = 
conf->gen.reset_source;
                                        break;
                                }
                        case PGC_ENUM:
--- 3595,3600 ----
***************
*** 3606,3616 ****
                                                                                
                   PGC_S_SESSION))
                                                        elog(ERROR, "failed to 
reset %s", conf->gen.name);
                                        *conf->variable = conf->reset_val;
-                                       conf->gen.source = 
conf->gen.reset_source;
                                        break;
                                }
                }
  
                if (gconf->flags & GUC_REPORT)
                        ReportGUCOption(gconf);
        }
--- 3606,3621 ----
                                                                                
                   PGC_S_SESSION))
                                                        elog(ERROR, "failed to 
reset %s", conf->gen.name);
                                        *conf->variable = conf->reset_val;
                                        break;
                                }
                }
  
+               gconf->source = gconf->reset_source;
+               if (gconf->sourcefile)
+                       free(gconf->sourcefile);
+               gconf->sourcefile = gconf->reset_sourcefile;
+               gconf->sourceline = gconf->reset_sourceline;
+ 
                if (gconf->flags & GUC_REPORT)
                        ReportGUCOption(gconf);
        }
***************
*** 4499,4504 ****
--- 4504,4534 ----
        return result;
  }
  
+ /*
+  * Set the fields for source file and line number the setting came from.
+  * If the setting came from something that's not a file, clear the fields.
+  */
+ static void
+ set_config_sourcefile(struct config_generic *conf, const char *sourcefile,
+                                         int sourceline)
+ {
+       if (conf->source != PGC_S_FILE)
+       {
+               if (conf->sourcefile)
+                       free(conf->sourcefile);
+               conf->sourcefile = NULL;
+               conf->sourceline = 0;
+       }
+       else
+       {
+               /* NULL sourcefile means don't touch what's in the field */
+               if (sourcefile == NULL)
+                       return;
+ 
+               conf->sourcefile = guc_strdup(ERROR, sourcefile);
+               conf->sourceline = sourceline;
+       }
+ }
  
  /*
   * Sets option `name' to given value. The value should be a string
***************
*** 4530,4535 ****
--- 4560,4566 ----
  bool
  set_config_option(const char *name, const char *value,
                                  GucContext context, GucSource source,
+                                 const char *sourcefile, int sourceline,
                                  GucAction action, bool changeVal)
  {
        struct config_generic *record;
***************
*** 4722,4727 ****
--- 4753,4760 ----
                                {
                                        newval = conf->reset_val;
                                        source = conf->gen.reset_source;
+                                       sourcefile = conf->gen.reset_sourcefile;
+                                       sourceline = conf->gen.reset_sourceline;
                                }
  
                                /* Save old value to support transaction abort 
*/
***************
*** 4742,4747 ****
--- 4775,4781 ----
                                {
                                        *conf->variable = newval;
                                        conf->gen.source = source;
+                                       set_config_sourcefile(&conf->gen, 
sourcefile, sourceline);
                                }
                                if (makeDefault)
                                {
***************
*** 4751,4756 ****
--- 4785,4794 ----
                                        {
                                                conf->reset_val = newval;
                                                conf->gen.reset_source = source;
+                                               if (conf->gen.reset_sourcefile)
+                                                       
free(conf->gen.reset_sourcefile);
+                                               conf->gen.reset_sourcefile = 
sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+                                               conf->gen.reset_sourceline = 
sourceline;
                                        }
                                        for (stack = conf->gen.stack; stack; 
stack = stack->prev)
                                        {
***************
*** 4797,4802 ****
--- 4835,4842 ----
                                {
                                        newval = conf->reset_val;
                                        source = conf->gen.reset_source;
+                                       sourcefile = conf->gen.reset_sourcefile;
+                                       sourceline = conf->gen.reset_sourceline;
                                }
  
                                /* Save old value to support transaction abort 
*/
***************
*** 4817,4822 ****
--- 4857,4863 ----
                                {
                                        *conf->variable = newval;
                                        conf->gen.source = source;
+                                       set_config_sourcefile(&conf->gen, 
sourcefile, sourceline);
                                }
                                if (makeDefault)
                                {
***************
*** 4826,4831 ****
--- 4867,4876 ----
                                        {
                                                conf->reset_val = newval;
                                                conf->gen.reset_source = source;
+                                               if (conf->gen.reset_sourcefile)
+                                                       
free(conf->gen.reset_sourcefile);
+                                               conf->gen.reset_sourcefile = 
sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+                                               conf->gen.reset_sourceline = 
sourceline;
                                        }
                                        for (stack = conf->gen.stack; stack; 
stack = stack->prev)
                                        {
***************
*** 4869,4874 ****
--- 4914,4921 ----
                                {
                                        newval = conf->reset_val;
                                        source = conf->gen.reset_source;
+                                       sourcefile = conf->gen.reset_sourcefile;
+                                       sourceline = conf->gen.reset_sourceline;
                                }
  
                                /* Save old value to support transaction abort 
*/
***************
*** 4889,4894 ****
--- 4936,4942 ----
                                {
                                        *conf->variable = newval;
                                        conf->gen.source = source;
+                                       set_config_sourcefile(&conf->gen, 
sourcefile, sourceline);
                                }
                                if (makeDefault)
                                {
***************
*** 4898,4903 ****
--- 4946,4955 ----
                                        {
                                                conf->reset_val = newval;
                                                conf->gen.reset_source = source;
+                                               if (conf->gen.reset_sourcefile)
+                                                       
free(conf->gen.reset_sourcefile);
+                                               conf->gen.reset_sourcefile = 
sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+                                               conf->gen.reset_sourceline = 
sourceline;
                                        }
                                        for (stack = conf->gen.stack; stack; 
stack = stack->prev)
                                        {
***************
*** 4956,4961 ****
--- 5008,5015 ----
                                                        return false;
                                        }
                                        source = conf->gen.reset_source;
+                                       sourcefile = conf->gen.reset_sourcefile;
+                                       sourceline = conf->gen.reset_sourceline;
                                }
  
                                /* Save old value to support transaction abort 
*/
***************
*** 5003,5008 ****
--- 5057,5063 ----
                                {
                                        set_string_field(conf, conf->variable, 
newval);
                                        conf->gen.source = source;
+                                       set_config_sourcefile(&conf->gen, 
sourcefile, sourceline);
                                }
                                if (makeDefault)
                                {
***************
*** 5012,5017 ****
--- 5067,5076 ----
                                        {
                                                set_string_field(conf, 
&conf->reset_val, newval);
                                                conf->gen.reset_source = source;
+                                               if (conf->gen.reset_sourcefile)
+                                                       
free(conf->gen.reset_sourcefile);
+                                               conf->gen.reset_sourcefile = 
sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+                                               conf->gen.reset_sourceline = 
sourceline;
                                        }
                                        for (stack = conf->gen.stack; stack; 
stack = stack->prev)
                                        {
***************
*** 5056,5061 ****
--- 5115,5122 ----
                                {
                                        newval = conf->reset_val;
                                        source = conf->gen.reset_source;
+                                       sourcefile = conf->gen.reset_sourcefile;
+                                       sourceline = conf->gen.reset_sourceline;
                                }
  
                                /* Save old value to support transaction abort 
*/
***************
*** 5077,5082 ****
--- 5138,5144 ----
                                {
                                        *conf->variable = newval;
                                        conf->gen.source = source;
+                                       set_config_sourcefile(&conf->gen, 
sourcefile, sourceline);
                                }
                                if (makeDefault)
                                {
***************
*** 5086,5091 ****
--- 5148,5157 ----
                                        {
                                                conf->reset_val = newval;
                                                conf->gen.reset_source = source;
+                                               if (conf->gen.reset_sourcefile)
+                                                       
free(conf->gen.reset_sourcefile);
+                                               conf->gen.reset_sourcefile = 
sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+                                               conf->gen.reset_sourceline = 
sourceline;
                                        }
                                        for (stack = conf->gen.stack; stack; 
stack = stack->prev)
                                        {
***************
*** 5111,5127 ****
   * Set a config option to the given value. See also set_config_option,
   * this is just the wrapper to be called from outside GUC.    NB: this
   * is used only for non-transactional operations.
   */
  void
  SetConfigOption(const char *name, const char *value,
                                GucContext context, GucSource source)
  {
!       (void) set_config_option(name, value, context, source,
                                                         GUC_ACTION_SET, true);
  }
  
  
- 
  /*
   * Fetch the current value of the option `name'. If the option doesn't exist,
   * throw an ereport and don't return.
--- 5177,5195 ----
   * Set a config option to the given value. See also set_config_option,
   * this is just the wrapper to be called from outside GUC.    NB: this
   * is used only for non-transactional operations.
+  *
+  * Note: there is no support here for setting source file/line, as it
+  * is currently not needed.
   */
  void
  SetConfigOption(const char *name, const char *value,
                                GucContext context, GucSource source)
  {
!       (void) set_config_option(name, value, context, source, NULL, 0,
                                                         GUC_ACTION_SET, true);
  }
  
  
  /*
   * Fetch the current value of the option `name'. If the option doesn't exist,
   * throw an ereport and don't return.
***************
*** 5424,5429 ****
--- 5492,5498 ----
                                                          
ExtractSetVariableArgs(stmt),
                                                          (superuser() ? 
PGC_SUSET : PGC_USERSET),
                                                          PGC_S_SESSION,
+                                                         NULL, 0,
                                                          action,
                                                          true);
                        break;
***************
*** 5481,5486 ****
--- 5550,5556 ----
                                                          NULL,
                                                          (superuser() ? 
PGC_SUSET : PGC_USERSET),
                                                          PGC_S_SESSION,
+                                                         NULL, 0,
                                                          action,
                                                          true);
                        break;
***************
*** 5526,5531 ****
--- 5596,5602 ----
                                          argstring,
                                          (superuser() ? PGC_SUSET : 
PGC_USERSET),
                                          PGC_S_SESSION,
+                                         NULL, 0,
                                          is_local ? GUC_ACTION_LOCAL : 
GUC_ACTION_SET,
                                          true);
  }
***************
*** 5569,5574 ****
--- 5640,5646 ----
                                          value,
                                          (superuser() ? PGC_SUSET : 
PGC_USERSET),
                                          PGC_S_SESSION,
+                                         NULL, 0,
                                          is_local ? GUC_ACTION_LOCAL : 
GUC_ACTION_SET,
                                          true);
  
***************
*** 5661,5666 ****
--- 5733,5739 ----
        if (value)
                set_config_option(name, value,
                                                  pHolder->gen.context, 
pHolder->gen.source,
+                                                 NULL, 0,
                                                  GUC_ACTION_SET, true);
  
        /*
***************
*** 6056,6061 ****
--- 6129,6136 ----
        {
                case PGC_BOOL:
                        {
+                               struct config_bool *lconf = (struct config_bool 
*) conf;
+ 
                                /* min_val */
                                values[9] = NULL;
  
***************
*** 6064,6069 ****
--- 6139,6148 ----
  
                                /* enumvals */
                                values[11] = NULL;
+ 
+                               /* default_val */
+                               snprintf(buffer, sizeof(buffer), "%s", 
lconf->boot_val ? "on" : "off");
+                               values[12] = pstrdup(buffer);
                        }
                        break;
  
***************
*** 6081,6086 ****
--- 6160,6169 ----
  
                                /* enumvals */
                                values[11] = NULL;
+ 
+                               /* default_val */
+                               snprintf(buffer, sizeof(buffer), "%d", 
lconf->boot_val);
+                               values[12] = pstrdup(buffer);
                        }
                        break;
  
***************
*** 6098,6108 ****
--- 6181,6197 ----
  
                                /* enumvals */
                                values[11] = NULL;
+ 
+                               /* default_val */
+                               snprintf(buffer, sizeof(buffer), "%g", 
lconf->boot_val);
+                               values[12] = pstrdup(buffer);
                        }
                        break;
  
                case PGC_STRING:
                        {
+                               struct config_string *lconf = (struct 
config_string *) conf;
+ 
                                /* min_val */
                                values[9] = NULL;
  
***************
*** 6111,6121 ****
--- 6200,6222 ----
  
                                /* enumvals */
                                values[11] = NULL;
+ 
+                               /* default_val */
+                               if (lconf->boot_val == NULL)
+                               {
+                                       values[12] = NULL;
+                               } else
+                               {
+                                       snprintf(buffer, sizeof(buffer), "%s", 
lconf->boot_val);
+                                       values[12] = pstrdup(buffer);
+                               }
                        }
                        break;
  
                case PGC_ENUM:
                        {
+                               struct config_enum *lconf = (struct config_enum 
*) conf;
+ 
                                /* min_val */
                                values[9] = NULL;
  
***************
*** 6124,6129 ****
--- 6225,6234 ----
  
                                /* enumvals */
                                values[11] = config_enum_get_options((struct 
config_enum *) conf, "", "");
+ 
+                               /* default_val */
+                               snprintf(buffer, sizeof(buffer), "%s", 
config_enum_lookup_by_value(lconf, lconf->boot_val));
+                               values[12] = pstrdup(buffer);
                        }
                        break;
  
***************
*** 6141,6149 ****
--- 6246,6270 ----
  
                                /* enumvals */
                                values[11] = NULL;
+ 
+                               /* default_val */
+                               values[12] = NULL;
                        }
                        break;
        }
+ 
+       /* If the setting came from a config file, set the source location */
+       if (conf->source == PGC_S_FILE)
+       {
+               values[13] = conf->sourcefile;
+               snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
+               values[14] = pstrdup(buffer);
+       }
+       else
+       {
+               values[13] = NULL;
+               values[14] = NULL;
+       }
  }
  
  /*
***************
*** 6179,6185 ****
   * show_all_settings - equiv to SHOW ALL command but implemented as
   * a Table Function.
   */
! #define NUM_PG_SETTINGS_ATTS  12
  
  Datum
  show_all_settings(PG_FUNCTION_ARGS)
--- 6300,6306 ----
   * show_all_settings - equiv to SHOW ALL command but implemented as
   * a Table Function.
   */
! #define NUM_PG_SETTINGS_ATTS  15
  
  Datum
  show_all_settings(PG_FUNCTION_ARGS)
***************
*** 6231,6236 ****
--- 6352,6363 ----
                                                   TEXTOID, -1, 0);
                TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
                                                   TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 13, "default_val",
+                                                  TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 14, "sourcefile",
+                                                  TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourceline",
+                                                  INT4OID, -1, 0);
  
                /*
                 * Generate attribute metadata needed later to produce tuples 
from raw
***************
*** 6702,6708 ****
                        elog(FATAL, "invalid format of exec config params 
file");
  
                (void) set_config_option(varname, varvalue, record->context,
!                                                                varsource, 
GUC_ACTION_SET, true);
                free(varname);
                free(varvalue);
        }
--- 6829,6835 ----
                        elog(FATAL, "invalid format of exec config params 
file");
  
                (void) set_config_option(varname, varvalue, record->context,
!                                                                varsource, 
NULL, 0, GUC_ACTION_SET, true);
                free(varname);
                free(varvalue);
        }
***************
*** 6799,6805 ****
                        continue;
                }
  
!               (void) set_config_option(name, value, context, source, action, 
true);
  
                free(name);
                if (value)
--- 6926,6932 ----
                        continue;
                }
  
!               (void) set_config_option(name, value, context, source, NULL, 0, 
action, true);
  
                free(name);
                if (value)
***************
*** 6826,6832 ****
        /* test if the option is valid */
        set_config_option(name, value,
                                          superuser() ? PGC_SUSET : PGC_USERSET,
!                                         PGC_S_TEST, GUC_ACTION_SET, false);
  
        /* convert name to canonical spelling, so we can use plain strcmp */
        (void) GetConfigOptionByName(name, &varname);
--- 6953,6959 ----
        /* test if the option is valid */
        set_config_option(name, value,
                                          superuser() ? PGC_SUSET : PGC_USERSET,
!                                         PGC_S_TEST, NULL, 0, GUC_ACTION_SET, 
false);
  
        /* convert name to canonical spelling, so we can use plain strcmp */
        (void) GetConfigOptionByName(name, &varname);
***************
*** 6904,6910 ****
        /* test if the option is valid */
        set_config_option(name, NULL,
                                          superuser() ? PGC_SUSET : PGC_USERSET,
!                                         PGC_S_TEST, GUC_ACTION_SET, false);
  
        /* convert name to canonical spelling, so we can use plain strcmp */
        (void) GetConfigOptionByName(name, &varname);
--- 7031,7037 ----
        /* test if the option is valid */
        set_config_option(name, NULL,
                                          superuser() ? PGC_SUSET : PGC_USERSET,
!                                         PGC_S_TEST, NULL, 0, GUC_ACTION_SET, 
false);
  
        /* convert name to canonical spelling, so we can use plain strcmp */
        (void) GetConfigOptionByName(name, &varname);
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.512
diff -c -r1.512 pg_proc.h
*** src/include/catalog/pg_proc.h       25 Aug 2008 11:18:43 -0000      1.512
--- src/include/catalog/pg_proc.h       1 Sep 2008 23:27:02 -0000
***************
*** 3157,3163 ****
  DESCR("SHOW X as a function");
  DATA(insert OID = 2078 (  set_config          PGNSP PGUID 12 1 0 0 f f f f v 
3 25 "25 25 16" _null_ _null_ _null_ set_config_by_name _null_ _null_ _null_ ));
  DESCR("SET X as a function");
! DATA(insert OID = 2084 (  pg_show_all_settings        PGNSP PGUID 12 1 1000 0 
f f t t s 0 2249 "" "{25,25,25,25,25,25,25,25,25,25,25,25}" 
"{o,o,o,o,o,o,o,o,o,o,o,o}" 
"{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals}"
 show_all_settings _null_ _null_ _null_ ));
  DESCR("SHOW ALL as a function");
  DATA(insert OID = 1371 (  pg_lock_status   PGNSP PGUID 12 1 1000 0 f f t t v 
0 2249 "" "{25,26,26,23,21,25,28,26,26,21,25,23,25,16}" 
"{o,o,o,o,o,o,o,o,o,o,o,o,o,o}" 
"{locktype,database,relation,page,tuple,virtualxid,transactionid,classid,objid,objsubid,virtualtransaction,pid,mode,granted}"
 pg_lock_status _null_ _null_ _null_ ));
  DESCR("view system lock information");
--- 3157,3163 ----
  DESCR("SHOW X as a function");
  DATA(insert OID = 2078 (  set_config          PGNSP PGUID 12 1 0 0 f f f f v 
3 25 "25 25 16" _null_ _null_ _null_ set_config_by_name _null_ _null_ _null_ ));
  DESCR("SET X as a function");
! DATA(insert OID = 2084 (  pg_show_all_settings        PGNSP PGUID 12 1 1000 0 
f f t t s 0 2249 "" "{25,25,25,25,25,25,25,25,25,25,25,25,25,25,23}" 
"{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}" 
"{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,default_val,sourcefile,sourceline}"
 show_all_settings _null_ _null_ _null_ ));
  DESCR("SHOW ALL as a function");
  DATA(insert OID = 1371 (  pg_lock_status   PGNSP PGUID 12 1 1000 0 f f t t v 
0 2249 "" "{25,26,26,23,21,25,28,26,26,21,25,23,25,16}" 
"{o,o,o,o,o,o,o,o,o,o,o,o,o,o}" 
"{locktype,database,relation,page,tuple,virtualxid,transactionid,classid,objid,objsubid,virtualtransaction,pid,mode,granted}"
 pg_lock_status _null_ _null_ _null_ ));
  DESCR("view system lock information");
Index: src/include/utils/guc.h
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/include/utils/guc.h,v
retrieving revision 1.98
diff -c -r1.98 guc.h
*** src/include/utils/guc.h     23 Jul 2008 17:29:53 -0000      1.98
--- src/include/utils/guc.h     1 Sep 2008 23:27:02 -0000
***************
*** 229,234 ****
--- 229,235 ----
  extern bool parse_real(const char *value, double *result);
  extern bool set_config_option(const char *name, const char *value,
                                  GucContext context, GucSource source,
+                                 const char *sourcefile, int sourceline,
                                  GucAction action, bool changeVal);
  extern char *GetConfigOptionByName(const char *name, const char **varname);
  extern void GetConfigOptionByNum(int varnum, const char **values, bool 
*noshow);
Index: src/include/utils/guc_tables.h
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/include/utils/guc_tables.h,v
retrieving revision 1.41
diff -c -r1.41 guc_tables.h
*** src/include/utils/guc_tables.h      17 Mar 2008 17:45:09 -0000      1.41
--- src/include/utils/guc_tables.h      1 Sep 2008 23:27:02 -0000
***************
*** 126,131 ****
--- 126,135 ----
        GucSource       reset_source;   /* source of the reset_value */
        GucSource       source;                 /* source of the current actual 
value */
        GucStack   *stack;                      /* stacked prior values */
+       char       *sourcefile;         /* file this settings is from (NULL if 
not file) */
+       int                     sourceline;             /* line in source file 
*/
+       char       *reset_sourcefile;   /* file that the reset_val is from */
+       int                     reset_sourceline;       /* line in source file 
for reset_val */
  };
  
  /* bit values in flags field */
Index: src/test/regress/expected/rules.out
===================================================================
RCS file: /home/gsmith/cvsrepo/pgsql/src/test/regress/expected/rules.out,v
retrieving revision 1.141
diff -c -r1.141 rules.out
*** src/test/regress/expected/rules.out 25 Aug 2008 11:18:43 -0000      1.141
--- src/test/regress/expected/rules.out 1 Sep 2008 23:27:02 -0000
***************
*** 1287,1293 ****
   pg_prepared_xacts        | SELECT p.transaction, p.gid, p.prepared, 
u.rolname AS owner, d.datname AS database FROM ((pg_prepared_xact() 
p(transaction, gid, prepared, ownerid, dbid) LEFT JOIN pg_authid u ON 
((p.ownerid = u.oid))) LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
   pg_roles                 | SELECT pg_authid.rolname, pg_authid.rolsuper, 
pg_authid.rolinherit, pg_authid.rolcreaterole, pg_authid.rolcreatedb, 
pg_authid.rolcatupdate, pg_authid.rolcanlogin, pg_authid.rolconnlimit, 
'********'::text AS rolpassword, pg_authid.rolvaliduntil, pg_authid.rolconfig, 
pg_authid.oid FROM pg_authid;
   pg_rules                 | SELECT n.nspname AS schemaname, c.relname AS 
tablename, r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r 
JOIN pg_class c ON ((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid 
= c.relnamespace))) WHERE (r.rulename <> '_RETURN'::name);
!  pg_settings              | SELECT a.name, a.setting, a.unit, a.category, 
a.short_desc, a.extra_desc, a.context, a.vartype, a.source, a.min_val, 
a.max_val, a.enumvals FROM pg_show_all_settings() a(name, setting, unit, 
category, short_desc, extra_desc, context, vartype, source, min_val, max_val, 
enumvals);
   pg_shadow                | SELECT pg_authid.rolname AS usename, 
pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, 
pg_authid.rolsuper AS usesuper, pg_authid.rolcatupdate AS usecatupd, 
pg_authid.rolpassword AS passwd, (pg_authid.rolvaliduntil)::abstime AS 
valuntil, pg_authid.rolconfig AS useconfig FROM pg_authid WHERE 
pg_authid.rolcanlogin;
   pg_stat_activity         | SELECT s.datid, d.datname, s.procpid, s.usesysid, 
u.rolname AS usename, s.current_query, s.waiting, s.xact_start, s.query_start, 
s.backend_start, s.client_addr, s.client_port FROM pg_database d, 
pg_stat_get_activity(NULL::integer) s(datid, procpid, usesysid, current_query, 
waiting, xact_start, query_start, backend_start, client_addr, client_port), 
pg_authid u WHERE ((s.datid = d.oid) AND (s.usesysid = u.oid));
   pg_stat_all_indexes      | SELECT c.oid AS relid, i.oid AS indexrelid, 
n.nspname AS schemaname, c.relname, i.relname AS indexrelname, 
pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS 
idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM 
(((pg_class c JOIN pg_index x ON ((c.oid = x.indrelid))) JOIN pg_class i ON 
((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = 
c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]));
--- 1287,1293 ----
   pg_prepared_xacts        | SELECT p.transaction, p.gid, p.prepared, 
u.rolname AS owner, d.datname AS database FROM ((pg_prepared_xact() 
p(transaction, gid, prepared, ownerid, dbid) LEFT JOIN pg_authid u ON 
((p.ownerid = u.oid))) LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
   pg_roles                 | SELECT pg_authid.rolname, pg_authid.rolsuper, 
pg_authid.rolinherit, pg_authid.rolcreaterole, pg_authid.rolcreatedb, 
pg_authid.rolcatupdate, pg_authid.rolcanlogin, pg_authid.rolconnlimit, 
'********'::text AS rolpassword, pg_authid.rolvaliduntil, pg_authid.rolconfig, 
pg_authid.oid FROM pg_authid;
   pg_rules                 | SELECT n.nspname AS schemaname, c.relname AS 
tablename, r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r 
JOIN pg_class c ON ((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid 
= c.relnamespace))) WHERE (r.rulename <> '_RETURN'::name);
!  pg_settings              | SELECT a.name, a.setting, a.unit, a.category, 
a.short_desc, a.extra_desc, a.context, a.vartype, a.source, a.min_val, 
a.max_val, a.enumvals, a.default_val, a.sourcefile, a.sourceline FROM 
pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, 
context, vartype, source, min_val, max_val, enumvals, default_val, sourcefile, 
sourceline);
   pg_shadow                | SELECT pg_authid.rolname AS usename, 
pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, 
pg_authid.rolsuper AS usesuper, pg_authid.rolcatupdate AS usecatupd, 
pg_authid.rolpassword AS passwd, (pg_authid.rolvaliduntil)::abstime AS 
valuntil, pg_authid.rolconfig AS useconfig FROM pg_authid WHERE 
pg_authid.rolcanlogin;
   pg_stat_activity         | SELECT s.datid, d.datname, s.procpid, s.usesysid, 
u.rolname AS usename, s.current_query, s.waiting, s.xact_start, s.query_start, 
s.backend_start, s.client_addr, s.client_port FROM pg_database d, 
pg_stat_get_activity(NULL::integer) s(datid, procpid, usesysid, current_query, 
waiting, xact_start, query_start, backend_start, client_addr, client_port), 
pg_authid u WHERE ((s.datid = d.oid) AND (s.usesysid = u.oid));
   pg_stat_all_indexes      | SELECT c.oid AS relid, i.oid AS indexrelid, 
n.nspname AS schemaname, c.relname, i.relname AS indexrelname, 
pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS 
idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM 
(((pg_class c JOIN pg_index x ON ((c.oid = x.indrelid))) JOIN pg_class i ON 
((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = 
c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]));

--- End Message ---
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to