MCPcopy Create free account
hub / github.com/apache/cloudberry / GUCArrayDelete

Function GUCArrayDelete

src/backend/utils/misc/guc.c:11746–11810  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

11744 * is NULL then a null should be stored.
11745 */
11746ArrayType *
11747GUCArrayDelete(ArrayType *array, const char *name)
11748{
11749 struct config_generic *record;
11750 ArrayType *newarray;
11751 int i;
11752 int index;
11753
11754 Assert(name);
11755
11756 /* test if the option is valid and we're allowed to set it */
11757 (void) validate_option_array_item(name, NULL, false);
11758
11759 /* normalize name (converts obsolete GUC names to modern spellings) */
11760 record = find_option(name, false, true, WARNING);
11761 if (record)
11762 name = record->name;
11763
11764 /* if array is currently null, then surely nothing to delete */
11765 if (!array)
11766 return NULL;
11767
11768 newarray = NULL;
11769 index = 1;
11770
11771 for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11772 {
11773 Datum d;
11774 char *val;
11775 bool isnull;
11776
11777 d = array_ref(array, 1, &i,
11778 -1 /* varlenarray */ ,
11779 -1 /* TEXT's typlen */ ,
11780 false /* TEXT's typbyval */ ,
11781 TYPALIGN_INT /* TEXT's typalign */ ,
11782 &isnull);
11783 if (isnull)
11784 continue;
11785 val = TextDatumGetCString(d);
11786
11787 /* ignore entry if it's what we want to delete */
11788 if (strncmp(val, name, strlen(name)) == 0
11789 && val[strlen(name)] == '=')
11790 continue;
11791
11792 /* else add it to the output array */
11793 if (newarray)
11794 newarray = array_set(newarray, 1, &index,
11795 d,
11796 false,
11797 -1 /* varlenarray */ ,
11798 -1 /* TEXT's typlen */ ,
11799 false /* TEXT's typbyval */ ,
11800 TYPALIGN_INT /* TEXT's typalign */ );
11801 else
11802 newarray = construct_array(&d, 1,
11803 TEXTOID,

Callers 2

update_proconfig_valueFunction · 0.85
AlterSettingFunction · 0.85

Calls 5

find_optionFunction · 0.85
array_refFunction · 0.85
array_setFunction · 0.85
construct_arrayFunction · 0.85

Tested by

no test coverage detected