src/backend/utils/misc/guc.c
void
ResetAllOptions(void)
{
	int			i;

	for (i = 0; i < num_guc_variables; i++)
	{
		struct config_generic *gconf = guc_variables[i];

		/* Don't reset non-SET-able values */
		if (gconf->context != PGC_SUSET &&
			gconf->context != PGC_USERSET)
			continue;
		/* Don't reset if special exclusion from RESET ALL */
		if (gconf->flags & GUC_NO_RESET_ALL)
			continue;
		/* No need to reset if wasn't SET */
		if (gconf->source <= PGC_S_OVERRIDE)
			continue;

		/* Save old value to support transaction abort */
		push_old_value(gconf);

		switch (gconf->vartype)
		{
			case PGC_BOOL:
				{
					struct config_bool *conf = (struct config_bool *) gconf;

					if (conf->assign_hook)
						if (!(*conf->assign_hook) (conf->reset_val, true,
												   PGC_S_SESSION))
							elog(ERROR, "failed to reset %s", conf->gen.name);
					*conf->variable = conf->reset_val;
					conf->tentative_val = conf->reset_val;
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
			case PGC_INT:
				{
					struct config_int *conf = (struct config_int *) gconf;

					if (conf->assign_hook)
						if (!(*conf->assign_hook) (conf->reset_val, true,
												   PGC_S_SESSION))
							elog(ERROR, "failed to reset %s", conf->gen.name);
					*conf->variable = conf->reset_val;
					conf->tentative_val = conf->reset_val;
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
			case PGC_REAL:
				{
					struct config_real *conf = (struct config_real *) gconf;

					if (conf->assign_hook)
						if (!(*conf->assign_hook) (conf->reset_val, true,
												   PGC_S_SESSION))
							elog(ERROR, "failed to reset %s", conf->gen.name);
					*conf->variable = conf->reset_val;
					conf->tentative_val = conf->reset_val;
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
			case PGC_STRING:
				{
					struct config_string *conf = (struct config_string *) gconf;
					char	   *str;

					if (conf->reset_val == NULL)
					{
						/* Nothing to reset to, as yet; so do nothing */
						break;
					}

					/* We need not strdup here */
					str = conf->reset_val;

					if (conf->assign_hook)
					{
						const char *newstr;

						newstr = (*conf->assign_hook) (str, true,
													   PGC_S_SESSION);
						if (newstr == NULL)
							elog(ERROR, "failed to reset %s", conf->gen.name);
						else if (newstr != str)
						{
							/*
							 * See notes in set_config_option about casting
							 */
							str = (char *) newstr;
						}
					}

					set_string_field(conf, conf->variable, str);
					set_string_field(conf, &conf->tentative_val, str);
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
		}

		if (gconf->flags & GUC_REPORT)
			ReportGUCOption(gconf);
	}
}
/*
 * Reset all options to their saved default values (implements RESET ALL)
 */
Reset all options to their saved default values (implements RESET ALL)
Reset all options to their saved default values ( implements RESET ALL )
void
ResetAllOptions(void)
{
	int			i;
	for (i = 0; i < num_guc_variables; i++)
	{
		struct config_generic *gconf = guc_variables[i];
		if (gconf->context != PGC_SUSET &&
			gconf->context != PGC_USERSET)
			continue;
		if (gconf->flags & GUC_NO_RESET_ALL)
			continue;
		if (gconf->source <= PGC_S_OVERRIDE)
			continue;
		push_old_value(gconf);
		switch (gconf->vartype)
		{
			case PGC_BOOL:
				{
					struct config_bool *conf = (struct config_bool *) gconf;
					if (conf->assign_hook)
						if (!(*conf->assign_hook) (conf->reset_val, true,
												   PGC_S_SESSION))
							elog(ERROR, "failed to reset %s", conf->gen.name);
					*conf->variable = conf->reset_val;
					conf->tentative_val = conf->reset_val;
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
			case PGC_INT:
				{
					struct config_int *conf = (struct config_int *) gconf;
					if (conf->assign_hook)
						if (!(*conf->assign_hook) (conf->reset_val, true,
												   PGC_S_SESSION))
							elog(ERROR, "failed to reset %s", conf->gen.name);
					*conf->variable = conf->reset_val;
					conf->tentative_val = conf->reset_val;
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
			case PGC_REAL:
				{
					struct config_real *conf = (struct config_real *) gconf;
					if (conf->assign_hook)
						if (!(*conf->assign_hook) (conf->reset_val, true,
												   PGC_S_SESSION))
							elog(ERROR, "failed to reset %s", conf->gen.name);
					*conf->variable = conf->reset_val;
					conf->tentative_val = conf->reset_val;
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
			case PGC_STRING:
				{
					struct config_string *conf = (struct config_string *) gconf;
					char	   *str;
					if (conf->reset_val == NULL)
					{
						break;
					}
					str = conf->reset_val;
					if (conf->assign_hook)
					{
						const char *newstr;
						newstr = (*conf->assign_hook) (str, true,
													   PGC_S_SESSION);
						if (newstr == NULL)
							elog(ERROR, "failed to reset %s", conf->gen.name);
						else if (newstr != str)
						{
							str = (char *) newstr;
						}
					}
					set_string_field(conf, conf->variable, str);
					set_string_field(conf, &conf->tentative_val, str);
					conf->gen.source = conf->gen.reset_source;
					conf->gen.tentative_source = conf->gen.reset_source;
					conf->gen.status |= GUC_HAVE_TENTATIVE;
					guc_dirty = true;
					guc_cannotprepare = true;
					break;
				}
		}
		if (gconf->flags & GUC_REPORT)
			ReportGUCOption(gconf);
	}
}
void ResetAllOptions ( void ) { int i ; for ( i = 0 ; i < num_guc_variables ; i ++ ) { struct config_generic * gconf = guc_variables [ i ] ; if ( gconf -> context != PGC_SUSET && gconf -> context != PGC_USERSET ) continue ; if ( gconf -> flags & GUC_NO_RESET_ALL ) continue ; if ( gconf -> source <= PGC_S_OVERRIDE ) continue ; push_old_value ( gconf ) ; switch ( gconf -> vartype ) { case PGC_BOOL : { struct config_bool * conf = ( struct config_bool * ) gconf ; if ( conf -> assign_hook ) if ( ! ( * conf -> assign_hook ) ( conf -> reset_val , true , PGC_S_SESSION ) ) elog ( ERROR , " " , conf -> gen . name ) ; * conf -> variable = conf -> reset_val ; conf -> tentative_val = conf -> reset_val ; conf -> gen . source = conf -> gen . reset_source ; conf -> gen . tentative_source = conf -> gen . reset_source ; conf -> gen . status |= GUC_HAVE_TENTATIVE ; guc_dirty = true ; guc_cannotprepare = true ; break ; } case PGC_INT : { struct config_int * conf = ( struct config_int * ) gconf ; if ( conf -> assign_hook ) if ( ! ( * conf -> assign_hook ) ( conf -> reset_val , true , PGC_S_SESSION ) ) elog ( ERROR , " " , conf -> gen . name ) ; * conf -> variable = conf -> reset_val ; conf -> tentative_val = conf -> reset_val ; conf -> gen . source = conf -> gen . reset_source ; conf -> gen . tentative_source = conf -> gen . reset_source ; conf -> gen . status |= GUC_HAVE_TENTATIVE ; guc_dirty = true ; guc_cannotprepare = true ; break ; } case PGC_REAL : { struct config_real * conf = ( struct config_real * ) gconf ; if ( conf -> assign_hook ) if ( ! ( * conf -> assign_hook ) ( conf -> reset_val , true , PGC_S_SESSION ) ) elog ( ERROR , " " , conf -> gen . name ) ; * conf -> variable = conf -> reset_val ; conf -> tentative_val = conf -> reset_val ; conf -> gen . source = conf -> gen . reset_source ; conf -> gen . tentative_source = conf -> gen . reset_source ; conf -> gen . status |= GUC_HAVE_TENTATIVE ; guc_dirty = true ; guc_cannotprepare = true ; break ; } case PGC_STRING : { struct config_string * conf = ( struct config_string * ) gconf ; char * str ; if ( conf -> reset_val == NULL ) { break ; } str = conf -> reset_val ; if ( conf -> assign_hook ) { const char * newstr ; newstr = ( * conf -> assign_hook ) ( str , true , PGC_S_SESSION ) ; if ( newstr == NULL ) elog ( ERROR , " " , conf -> gen . name ) ; else if ( newstr != str ) { str = ( char * ) newstr ; } } set_string_field ( conf , conf -> variable , str ) ; set_string_field ( conf , & conf -> tentative_val , str ) ; conf -> gen . source = conf -> gen . reset_source ; conf -> gen . tentative_source = conf -> gen . reset_source ; conf -> gen . status |= GUC_HAVE_TENTATIVE ; guc_dirty = true ; guc_cannotprepare = true ; break ; } } if ( gconf -> flags & GUC_REPORT ) ReportGUCOption ( gconf ) ; } }
Reset all options to their saved default values (implements RESET ALL)
Reset all options to their saved default values ( implements RESET ALL )
/* Don't reset non-SET-able values */ /* Don't reset if special exclusion from RESET ALL */ /* No need to reset if wasn't SET */ /* Save old value to support transaction abort */ /* Nothing to reset to, as yet; so do nothing */ /* We need not strdup here */ /*
							 * See notes in set_config_option about casting
							 */