src/backend/utils/misc/guc.c
ArrayType *
GUCArrayReset(ArrayType *array)
{
	ArrayType  *newarray;
	int			i;
	int			index;

	/* if array is currently null, nothing to do */
	if (!array)
		return NULL;

	/* if we're superuser, we can delete everything */
	if (superuser())
		return NULL;

	newarray = NULL;
	index = 1;

	for (i = 1; i <= ARR_DIMS(array)[0]; i++)
	{
		Datum		d;
		char	   *val;
		char	   *eqsgn;
		bool		isnull;
		struct config_generic *gconf;

		d = array_ref(array, 1, &i,
					  -1 /* varlenarray */ ,
					  -1 /* TEXT's typlen */ ,
					  false /* TEXT's typbyval */ ,
					  'i' /* TEXT's typalign */ ,
					  &isnull);

		if (isnull)
			continue;
		val = DatumGetCString(DirectFunctionCall1(textout, d));

		eqsgn = strchr(val, '=');
		*eqsgn = '\0';

		gconf = find_option(val, WARNING);
		if (!gconf)
			continue;

		/* note: superuser-ness was already checked above */
		/* skip entry if OK to delete */
		if (gconf->context == PGC_USERSET)
			continue;

		/* XXX do we need to worry about database owner? */

		/* else add it to the output array */
		if (newarray)
		{
			newarray = array_set(newarray, 1, &index,
								 d,
								 false,
								 -1 /* varlenarray */ ,
								 -1 /* TEXT's typlen */ ,
								 false /* TEXT's typbyval */ ,
								 'i' /* TEXT's typalign */ );
		}
		else
			newarray = construct_array(&d, 1,
									   TEXTOID,
									   -1, false, 'i');

		index++;
		pfree(val);
	}

	return newarray;
}
/*
 * Given a GUC array, delete all settings from it that our permission
 * level allows: if superuser, delete them all; if regular user, only
 * those that are PGC_USERSET
 */
Given a GUC array, delete all settings from it that our permission
level allows: if superuser, delete them all; if regular user, only
those that are PGC_USERSET
Given a GUC array delete all settings from it that our permission level allows : if superuser delete them all ; if regular user only those that are PGC_USERSET
ArrayType *
GUCArrayReset(ArrayType *array)
{
	ArrayType  *newarray;
	int			i;
	int			index;
	if (!array)
		return NULL;
	if (superuser())
		return NULL;
	newarray = NULL;
	index = 1;
	for (i = 1; i <= ARR_DIMS(array)[0]; i++)
	{
		Datum		d;
		char	   *val;
		char	   *eqsgn;
		bool		isnull;
		struct config_generic *gconf;
		d = array_ref(array, 1, &i,
					  -1  ,
					  -1  ,
					  false  ,
					  'i'  ,
					  &isnull);
		if (isnull)
			continue;
		val = DatumGetCString(DirectFunctionCall1(textout, d));
		eqsgn = strchr(val, '=');
		*eqsgn = '\0';
		gconf = find_option(val, WARNING);
		if (!gconf)
			continue;
		if (gconf->context == PGC_USERSET)
			continue;
		if (newarray)
		{
			newarray = array_set(newarray, 1, &index,
								 d,
								 false,
								 -1  ,
								 -1  ,
								 false  ,
								 'i'  );
		}
		else
			newarray = construct_array(&d, 1,
									   TEXTOID,
									   -1, false, 'i');
		index++;
		pfree(val);
	}
	return newarray;
}
ArrayType * GUCArrayReset ( ArrayType * array ) { ArrayType * newarray ; int i ; int index ; if ( ! array ) return NULL ; if ( superuser ( ) ) return NULL ; newarray = NULL ; index = 1 ; for ( i = 1 ; i <= ARR_DIMS ( array ) [ 0 ] ; i ++ ) { Datum d ; char * val ; char * eqsgn ; bool isnull ; struct config_generic * gconf ; d = array_ref ( array , 1 , & i , -1 , -1 , false , ' ' , & isnull ) ; if ( isnull ) continue ; val = DatumGetCString ( DirectFunctionCall1 ( textout , d ) ) ; eqsgn = strchr ( val , ' ' ) ; * eqsgn = ' \0 ' ; gconf = find_option ( val , WARNING ) ; if ( ! gconf ) continue ; if ( gconf -> context == PGC_USERSET ) continue ; if ( newarray ) { newarray = array_set ( newarray , 1 , & index , d , false , -1 , -1 , false , ' ' ) ; } else newarray = construct_array ( & d , 1 , TEXTOID , -1 , false , ' ' ) ; index ++ ; pfree ( val ) ; } return newarray ; }
Given a GUC array, delete all settings from it that our permission
 level allows: if superuser, delete them all; if regular user, only
 those that are PGC_USERSET
Given a GUC array delete all settings from it that our permission level allows : if superuser delete them all ; if regular user only those that are PGC_USERSET
/* if array is currently null, nothing to do */ /* if we're superuser, we can delete everything */ /* varlenarray */ /* TEXT's typlen */ /* TEXT's typbyval */ /* TEXT's typalign */ /* note: superuser-ness was already checked above */ /* skip entry if OK to delete */ /* XXX do we need to worry about database owner? */ /* else add it to the output array */ /* varlenarray */ /* TEXT's typlen */ /* TEXT's typbyval */ /* TEXT's typalign */