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
Index: src/backend/utils/adt/ri_triggers.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/adt/ri_triggers.c,v
retrieving revision 1.109
diff -c -p -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	18 Aug 2008 15:50:26 -0000
*************** RI_Initial_Check(Trigger *trigger, Relat
*** 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)
*************** RI_Initial_Check(Trigger *trigger, Relat
*** 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/alvherre/Code/cvs/pgsql/src/backend/utils/misc/guc-file.l,v
retrieving revision 1.56
diff -c -p -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	25 Aug 2008 15:22:27 -0000
*************** struct name_value_pair
*** 39,44 ****
--- 39,46 ----
  {
  	char       *name;
  	char       *value;
+ 	char	   *filename;
+ 	int		   sourceline;
  	struct name_value_pair *next;
  };
  
*************** ProcessConfigFile(GucContext context)
*** 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;
  	}
  
*************** ProcessConfigFile(GucContext context)
*** 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);
  	}
  
  	/*
*************** ProcessConfigFile(GucContext context)
*** 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. */
*************** ParseConfigFile(const char *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
  			{
*************** ParseConfigFile(const char *config_file,
*** 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)
*************** ParseConfigFile(const char *config_file,
*** 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;
*************** free_name_value_list(struct name_value_p
*** 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/alvherre/Code/cvs/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.469
diff -c -p -r1.469 guc.c
*** src/backend/utils/misc/guc.c	22 Aug 2008 18:47:07 -0000	1.469
--- src/backend/utils/misc/guc.c	28 Aug 2008 17:08:30 -0000
*************** InitializeGUCOptions(void)
*** 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)
  		{
*************** ResetAllOptions(void)
*** 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 ----
*************** ResetAllOptions(void)
*** 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 ----
*************** ResetAllOptions(void)
*** 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 ----
*************** ResetAllOptions(void)
*** 3594,3600 ****
  					}
  
  					set_string_field(conf, conf->variable, str);
- 					conf->gen.source = conf->gen.reset_source;
  					break;
  				}
  			case PGC_ENUM:
--- 3595,3600 ----
*************** ResetAllOptions(void)
*** 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);
  	}
*************** call_string_assign_hook(GucStringAssignH
*** 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
*************** call_string_assign_hook(GucStringAssignH
*** 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;
*************** set_config_option(const char *name, cons
*** 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 */
*************** set_config_option(const char *name, cons
*** 4742,4747 ****
--- 4775,4781 ----
  				{
  					*conf->variable = newval;
  					conf->gen.source = source;
+ 					set_config_sourcefile(&conf->gen, sourcefile, sourceline);
  				}
  				if (makeDefault)
  				{
*************** set_config_option(const char *name, cons
*** 4751,4756 ****
--- 4785,4792 ----
  					{
  						conf->reset_val = newval;
  						conf->gen.reset_source = source;
+ 						conf->gen.reset_sourcefile = sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+ 						conf->gen.reset_sourceline = sourceline;
  					}
  					for (stack = conf->gen.stack; stack; stack = stack->prev)
  					{
*************** set_config_option(const char *name, cons
*** 4797,4802 ****
--- 4833,4840 ----
  				{
  					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 */
*************** set_config_option(const char *name, cons
*** 4817,4822 ****
--- 4855,4861 ----
  				{
  					*conf->variable = newval;
  					conf->gen.source = source;
+ 					set_config_sourcefile(&conf->gen, sourcefile, sourceline);
  				}
  				if (makeDefault)
  				{
*************** set_config_option(const char *name, cons
*** 4826,4831 ****
--- 4865,4872 ----
  					{
  						conf->reset_val = newval;
  						conf->gen.reset_source = source;
+ 						conf->gen.reset_sourcefile = sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+ 						conf->gen.reset_sourceline = sourceline;
  					}
  					for (stack = conf->gen.stack; stack; stack = stack->prev)
  					{
*************** set_config_option(const char *name, cons
*** 4869,4874 ****
--- 4910,4917 ----
  				{
  					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 */
*************** set_config_option(const char *name, cons
*** 4889,4894 ****
--- 4932,4938 ----
  				{
  					*conf->variable = newval;
  					conf->gen.source = source;
+ 					set_config_sourcefile(&conf->gen, sourcefile, sourceline);
  				}
  				if (makeDefault)
  				{
*************** set_config_option(const char *name, cons
*** 4898,4903 ****
--- 4942,4949 ----
  					{
  						conf->reset_val = newval;
  						conf->gen.reset_source = source;
+ 						conf->gen.reset_sourcefile = sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+ 						conf->gen.reset_sourceline = sourceline;
  					}
  					for (stack = conf->gen.stack; stack; stack = stack->prev)
  					{
*************** set_config_option(const char *name, cons
*** 4956,4961 ****
--- 5002,5009 ----
  							return false;
  					}
  					source = conf->gen.reset_source;
+ 					sourcefile = conf->gen.reset_sourcefile;
+ 					sourceline = conf->gen.reset_sourceline;
  				}
  
  				/* Save old value to support transaction abort */
*************** set_config_option(const char *name, cons
*** 5003,5008 ****
--- 5051,5057 ----
  				{
  					set_string_field(conf, conf->variable, newval);
  					conf->gen.source = source;
+ 					set_config_sourcefile(&conf->gen, sourcefile, sourceline);
  				}
  				if (makeDefault)
  				{
*************** set_config_option(const char *name, cons
*** 5012,5017 ****
--- 5061,5068 ----
  					{
  						set_string_field(conf, &conf->reset_val, newval);
  						conf->gen.reset_source = source;
+ 						conf->gen.reset_sourcefile = sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+ 						conf->gen.reset_sourceline = sourceline;
  					}
  					for (stack = conf->gen.stack; stack; stack = stack->prev)
  					{
*************** set_config_option(const char *name, cons
*** 5056,5061 ****
--- 5107,5114 ----
  				{
  					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 */
*************** set_config_option(const char *name, cons
*** 5077,5082 ****
--- 5130,5136 ----
  				{
  					*conf->variable = newval;
  					conf->gen.source = source;
+ 					set_config_sourcefile(&conf->gen, sourcefile, sourceline);
  				}
  				if (makeDefault)
  				{
*************** set_config_option(const char *name, cons
*** 5086,5091 ****
--- 5140,5147 ----
  					{
  						conf->reset_val = newval;
  						conf->gen.reset_source = source;
+ 						conf->gen.reset_sourcefile = sourcefile ? guc_strdup(elevel, sourcefile) : NULL;
+ 						conf->gen.reset_sourceline = sourceline;
  					}
  					for (stack = conf->gen.stack; stack; stack = stack->prev)
  					{
*************** set_config_option(const char *name, cons
*** 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.
--- 5167,5185 ----
   * 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.
*************** ExecSetVariableStmt(VariableSetStmt *stm
*** 5424,5429 ****
--- 5482,5488 ----
  							  ExtractSetVariableArgs(stmt),
  							  (superuser() ? PGC_SUSET : PGC_USERSET),
  							  PGC_S_SESSION,
+ 							  NULL, 0,
  							  action,
  							  true);
  			break;
*************** ExecSetVariableStmt(VariableSetStmt *stm
*** 5481,5486 ****
--- 5540,5546 ----
  							  NULL,
  							  (superuser() ? PGC_SUSET : PGC_USERSET),
  							  PGC_S_SESSION,
+ 							  NULL, 0,
  							  action,
  							  true);
  			break;
*************** SetPGVariable(const char *name, List *ar
*** 5526,5531 ****
--- 5586,5592 ----
  					  argstring,
  					  (superuser() ? PGC_SUSET : PGC_USERSET),
  					  PGC_S_SESSION,
+ 					  NULL, 0,
  					  is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
  					  true);
  }
*************** set_config_by_name(PG_FUNCTION_ARGS)
*** 5569,5574 ****
--- 5630,5636 ----
  					  value,
  					  (superuser() ? PGC_SUSET : PGC_USERSET),
  					  PGC_S_SESSION,
+ 					  NULL, 0,
  					  is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
  					  true);
  
*************** define_custom_variable(struct config_gen
*** 5661,5666 ****
--- 5723,5729 ----
  	if (value)
  		set_config_option(name, value,
  						  pHolder->gen.context, pHolder->gen.source,
+ 						  NULL, 0,
  						  GUC_ACTION_SET, true);
  
  	/*
*************** GetConfigOptionByNum(int varnum, const c
*** 6144,6149 ****
--- 6207,6225 ----
  			}
  			break;
  	}
+ 
+ 	/* If the setting came from a config file, set the source location */
+ 	if (conf->source == PGC_S_FILE)
+ 	{
+ 		values[12] = conf->sourcefile;
+ 		snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
+ 		values[13] = pstrdup(buffer);
+ 	}
+ 	else
+ 	{
+ 		values[12] = NULL;
+ 		values[13] = NULL;
+ 	}
  }
  
  /*
*************** show_config_by_name(PG_FUNCTION_ARGS)
*** 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)
--- 6255,6261 ----
   * show_all_settings - equiv to SHOW ALL command but implemented as
   * a Table Function.
   */
! #define NUM_PG_SETTINGS_ATTS	14
  
  Datum
  show_all_settings(PG_FUNCTION_ARGS)
*************** show_all_settings(PG_FUNCTION_ARGS)
*** 6231,6236 ****
--- 6307,6316 ----
  						   TEXTOID, -1, 0);
  		TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
  						   TEXTOID, -1, 0);
+ 		TupleDescInitEntry(tupdesc, (AttrNumber) 13, "sourcefile",
+ 						   TEXTOID, -1, 0);
+ 		TupleDescInitEntry(tupdesc, (AttrNumber) 14, "sourceline",
+ 						   INT4OID, -1, 0);
  
  		/*
  		 * Generate attribute metadata needed later to produce tuples from raw
*************** read_nondefault_variables(void)
*** 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);
  	}
--- 6782,6788 ----
  			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);
  	}
*************** ProcessGUCArray(ArrayType *array,
*** 6799,6805 ****
  			continue;
  		}
  
! 		(void) set_config_option(name, value, context, source, action, true);
  
  		free(name);
  		if (value)
--- 6879,6885 ----
  			continue;
  		}
  
! 		(void) set_config_option(name, value, context, source, NULL, 0, action, true);
  
  		free(name);
  		if (value)
*************** GUCArrayAdd(ArrayType *array, const char
*** 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);
--- 6906,6912 ----
  	/* 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);
*************** GUCArrayDelete(ArrayType *array, const c
*** 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);
--- 6984,6990 ----
  	/* 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/alvherre/Code/cvs/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.512
diff -c -p -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	25 Aug 2008 23:35:59 -0000
*************** DATA(insert OID = 2077 (  current_settin
*** 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,23}" "{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,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/alvherre/Code/cvs/pgsql/src/include/utils/guc.h,v
retrieving revision 1.98
diff -c -p -r1.98 guc.h
*** src/include/utils/guc.h	23 Jul 2008 17:29:53 -0000	1.98
--- src/include/utils/guc.h	18 Aug 2008 15:50:26 -0000
*************** extern bool parse_int(const char *value,
*** 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/alvherre/Code/cvs/pgsql/src/include/utils/guc_tables.h,v
retrieving revision 1.41
diff -c -p -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	28 Aug 2008 16:59:18 -0000
*************** struct config_generic
*** 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/alvherre/Code/cvs/pgsql/src/test/regress/expected/rules.out,v
retrieving revision 1.141
diff -c -p -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	25 Aug 2008 15:25:41 -0000
*************** SELECT viewname, definition FROM pg_view
*** 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.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, 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"]));
-- 
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