src/backend/utils/misc/guc.c
ArrayType *
GUCArrayDelete(ArrayType *array, const char *name)
{
	const char *varname;
	ArrayType  *newarray;
	int			i;
	int			index;

	Assert(name);

	/* test if the option is valid */
	set_config_option(name, NULL,
					  superuser() ? PGC_SUSET : PGC_USERSET,
					  PGC_S_TEST, false, false);

	/* convert name to canonical spelling, so we can use plain strcmp */
	(void) GetConfigOptionByName(name, &varname);
	name = varname;

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

	newarray = NULL;
	index = 1;

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

		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));

		/* ignore entry if it's what we want to delete */
		if (strncmp(val, name, strlen(name)) == 0
			&& val[strlen(name)] == '=')
			continue;

		/* 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++;
	}

	return newarray;
}
/*
 * Delete an entry from an option array.  The array parameter may be NULL
 * to indicate the current table entry is NULL.  Also, if the return value
 * is NULL then a null should be stored.
 */
Delete an entry from an option array.  The array parameter may be NULL
to indicate the current table entry is NULL.  Also, if the return value
is NULL then a null should be stored.
Delete an entry from an option array . The array parameter may be NULL to indicate the current table entry is NULL . Also if the return value is NULL then a null should be stored .
ArrayType *
GUCArrayDelete(ArrayType *array, const char *name)
{
	const char *varname;
	ArrayType  *newarray;
	int			i;
	int			index;
	Assert(name);
	set_config_option(name, NULL,
					  superuser() ? PGC_SUSET : PGC_USERSET,
					  PGC_S_TEST, false, false);
	(void) GetConfigOptionByName(name, &varname);
	name = varname;
	if (!array)
		return NULL;
	newarray = NULL;
	index = 1;
	for (i = 1; i <= ARR_DIMS(array)[0]; i++)
	{
		Datum		d;
		char	   *val;
		bool		isnull;
		d = array_ref(array, 1, &i,
					  -1  ,
					  -1  ,
					  false  ,
					  'i'  ,
					  &isnull);
		if (isnull)
			continue;
		val = DatumGetCString(DirectFunctionCall1(textout, d));
		if (strncmp(val, name, strlen(name)) == 0
			&& val[strlen(name)] == '=')
			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++;
	}
	return newarray;
}
ArrayType * GUCArrayDelete ( ArrayType * array , const char * name ) { const char * varname ; ArrayType * newarray ; int i ; int index ; Assert ( name ) ; set_config_option ( name , NULL , superuser ( ) ? PGC_SUSET : PGC_USERSET , PGC_S_TEST , false , false ) ; ( void ) GetConfigOptionByName ( name , & varname ) ; name = varname ; if ( ! array ) return NULL ; newarray = NULL ; index = 1 ; for ( i = 1 ; i <= ARR_DIMS ( array ) [ 0 ] ; i ++ ) { Datum d ; char * val ; bool isnull ; d = array_ref ( array , 1 , & i , -1 , -1 , false , ' ' , & isnull ) ; if ( isnull ) continue ; val = DatumGetCString ( DirectFunctionCall1 ( textout , d ) ) ; if ( strncmp ( val , name , strlen ( name ) ) == 0 && val [ strlen ( name ) ] == ' ' ) continue ; if ( newarray ) { newarray = array_set ( newarray , 1 , & index , d , false , -1 , -1 , false , ' ' ) ; } else newarray = construct_array ( & d , 1 , TEXTOID , -1 , false , ' ' ) ; index ++ ; } return newarray ; }
Delete an entry from an option array.
Delete an entry from an option array .
/* test if the option is valid */ /* convert name to canonical spelling, so we can use plain strcmp */ /* if array is currently null, then surely nothing to delete */ /* varlenarray */ /* TEXT's typlen */ /* TEXT's typbyval */ /* TEXT's typalign */ /* ignore entry if it's what we want to delete */ /* else add it to the output array */ /* varlenarray */ /* TEXT's typlen */ /* TEXT's typbyval */ /* TEXT's typalign */