* Handle options fetched from pg_db_role_setting.setconfig, * pg_proc.proconfig, etc. Caller must specify proper context/source/action. * * The array parameter must be an array of TEXT (it must not be NULL). */
| 11599 | * The array parameter must be an array of TEXT (it must not be NULL). |
| 11600 | */ |
| 11601 | void |
| 11602 | ProcessGUCArray(ArrayType *array, |
| 11603 | GucContext context, GucSource source, GucAction action) |
| 11604 | { |
| 11605 | int i; |
| 11606 | |
| 11607 | Assert(array != NULL); |
| 11608 | Assert(ARR_ELEMTYPE(array) == TEXTOID); |
| 11609 | Assert(ARR_NDIM(array) == 1); |
| 11610 | Assert(ARR_LBOUND(array)[0] == 1); |
| 11611 | |
| 11612 | for (i = 1; i <= ARR_DIMS(array)[0]; i++) |
| 11613 | { |
| 11614 | Datum d; |
| 11615 | bool isnull; |
| 11616 | char *s; |
| 11617 | char *name; |
| 11618 | char *value; |
| 11619 | char *namecopy; |
| 11620 | char *valuecopy; |
| 11621 | |
| 11622 | d = array_ref(array, 1, &i, |
| 11623 | -1 /* varlenarray */ , |
| 11624 | -1 /* TEXT's typlen */ , |
| 11625 | false /* TEXT's typbyval */ , |
| 11626 | TYPALIGN_INT /* TEXT's typalign */ , |
| 11627 | &isnull); |
| 11628 | |
| 11629 | if (isnull) |
| 11630 | continue; |
| 11631 | |
| 11632 | s = TextDatumGetCString(d); |
| 11633 | |
| 11634 | ParseLongOption(s, &name, &value); |
| 11635 | if (!value) |
| 11636 | { |
| 11637 | ereport(WARNING, |
| 11638 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 11639 | errmsg("could not parse setting for parameter \"%s\"", |
| 11640 | name))); |
| 11641 | free(name); |
| 11642 | continue; |
| 11643 | } |
| 11644 | |
| 11645 | /* free malloc'd strings immediately to avoid leak upon error */ |
| 11646 | namecopy = pstrdup(name); |
| 11647 | free(name); |
| 11648 | valuecopy = pstrdup(value); |
| 11649 | free(value); |
| 11650 | |
| 11651 | (void) set_config_option(namecopy, valuecopy, |
| 11652 | context, source, |
| 11653 | action, true, 0, false); |
| 11654 | |
| 11655 | pfree(namecopy); |
| 11656 | pfree(valuecopy); |
| 11657 | pfree(s); |
| 11658 | } |
no test coverage detected