56#define CONFIG_FILENAME "postgresql.conf"
57#define HBA_FILENAME "pg_hba.conf"
58#define IDENT_FILENAME "pg_ident.conf"
61#define CONFIG_EXEC_PARAMS "global/config_exec_params"
62#define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
69#define REALTYPE_PRECISION 17
75#define GUC_SAFE_SEARCH_PATH "pg_catalog, pg_temp"
102#define MAX_UNIT_LEN 3
113#if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
114#error BLCKSZ must be between 1KB and 1MB
116#if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
117#error XLOG_BLCKSZ must be between 1KB and 1MB
148 {
"TB",
GUC_UNIT_XBLOCKS, (1024.0 * 1024.0 * 1024.0) / (XLOG_BLCKSZ / 1024)},
192 "sort_mem",
"work_mem",
193 "vacuum_mem",
"maintenance_work_mem",
194 "ssl_ecdh_curve",
"ssl_groups",
250 const char *curvalue,
255 bool skipIfNoPermissions);
287 bool applying =
false;
288 const char *ConfFileWithError;
343 strcmp(item->name,
"data_directory") == 0)
348 newlist->
next = NULL;
349 head = tail = newlist;
372 gconf->
status &= ~GUC_IS_IN_FILE;
400 record =
find_option(item->name,
false,
true, elevel);
414 if (!pitem->ignore &&
415 strcmp(pitem->name, item->name) == 0)
416 pitem->ignore =
true;
426 (
errcode(ERRCODE_UNDEFINED_OBJECT),
427 errmsg(
"unrecognized configuration parameter \"%s\" in file \"%s\" line %d",
429 item->filename, item->sourceline)));
430 item->errmsg =
pstrdup(
"unrecognized configuration parameter");
432 ConfFileWithError = item->filename;
465 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
466 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
502 (
errmsg(
"parameter \"%s\" removed from configuration file, reset to default",
534 char *pre_value = NULL;
565 if (strcmp(pre_value, post_value) != 0)
567 (
errmsg(
"parameter \"%s\" changed to \"%s\"",
568 item->name, item->value)));
570 item->applied =
true;
575 item->errmsg =
pstrdup(
"setting could not be applied");
576 ConfFileWithError = item->filename;
581 item->applied =
true;
590 if (scres != 0 && applySettings)
603 if (
error && applySettings)
608 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
609 errmsg(
"configuration file \"%s\" contains errors",
610 ConfFileWithError)));
613 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
614 errmsg(
"configuration file \"%s\" contains errors; unaffected changes were applied",
615 ConfFileWithError)));
618 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
619 errmsg(
"configuration file \"%s\" contains errors; no changes were applied",
620 ConfFileWithError)));
644 (
errcode(ERRCODE_OUT_OF_MEMORY),
645 errmsg(
"out of memory")));
669 (
errcode(ERRCODE_OUT_OF_MEMORY),
670 errmsg(
"out of memory")));
678 size_t len = strlen(src) + 1;
729 char *oldval = *field;
767 void *oldval = *field;
825 &(
val->val.stringval),
857 qsort(result, *num_vars,
895 size_vars = num_vars + num_vars / 4;
897 hash_ctl.
keysize =
sizeof(
char *);
939 (
errcode(ERRCODE_OUT_OF_MEMORY),
940 errmsg(
"out of memory")));
958 bool saw_sep =
false;
959 bool name_start =
true;
961 for (
const char *p =
name; *p; p++)
970 else if (strchr(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
971 "abcdefghijklmnopqrstuvwxyz_", *p) != NULL ||
977 else if (!name_start && strchr(
"0123456789$", *p) != NULL)
1008 size_t classLen = sep -
name;
1016 (
errcode(ERRCODE_INVALID_NAME),
1017 errmsg(
"invalid configuration parameter name \"%s\"",
1019 errdetail(
"Custom parameter names must be two or more simple identifiers separated by dots.")));
1025 const char *rcprefix =
lfirst(lc);
1027 if (strlen(rcprefix) == classLen &&
1028 strncmp(
name, rcprefix, classLen) == 0)
1032 (
errcode(ERRCODE_INVALID_NAME),
1033 errmsg(
"invalid configuration parameter name \"%s\"",
1035 errdetail(
"\"%s\" is a reserved prefix.",
1047 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1048 errmsg(
"unrecognized configuration parameter \"%s\"",
1068 if (var->
name == NULL)
1076 var->
short_desc =
"GUC placeholder variable";
1137 skip_errors, elevel);
1140 if (create_placeholders)
1154 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1155 errmsg(
"unrecognized configuration parameter \"%s\"",
1184 while (*namea && *nameb)
1186 char cha = *namea++;
1187 char chb = *nameb++;
1189 if (cha >=
'A' && cha <=
'Z')
1191 if (chb >=
'A' && chb <=
'Z')
1210 const char *
name = *(
const char *
const *)
key;
1217 if (ch >=
'A' && ch <=
'Z')
1233 const char *name1 = *(
const char *
const *) key1;
1234 const char *name2 = *(
const char *
const *) key2;
1267 for (
char *ptr = result; *ptr !=
'\0'; ptr++)
1271 if (ch >=
'A' && ch <=
'Z')
1311#ifdef USE_ASSERT_CHECKING
1324 elog(
LOG,
"GUC (PGC_BOOL) %s, boot_val=%d, C-var=%d",
1336 elog(
LOG,
"GUC (PGC_INT) %s, boot_val=%d, C-var=%d",
1348 elog(
LOG,
"GUC (PGC_REAL) %s, boot_val=%g, C-var=%g",
1362 elog(
LOG,
"GUC (PGC_STRING) %s, boot_val=%s, C-var=%s",
1374 elog(
LOG,
"GUC (PGC_ENUM) %s, boot_val=%d, C-var=%d",
1391 elog(
LOG,
"GUC %s flags: NO_SHOW_ALL and !NOT_IN_SAMPLE",
1469 ssize_t stack_rlimit;
1471 env = getenv(
"PGPORT");
1475 env = getenv(
"PGDATESTYLE");
1479 env = getenv(
"PGCLIENTENCODING");
1491 if (stack_rlimit > 0)
1495 if (new_limit > 100)
1500 if (new_limit < 2048)
1507 snprintf(limbuf,
sizeof(limbuf),
"%d", (
int) new_limit);
1530 gconf->
srole = BOOTSTRAP_SUPERUSERID;
1532 gconf->
stack = NULL;
1533 gconf->
extra = NULL;
1547 elog(
FATAL,
"failed to initialize %s to %d",
1563 elog(
FATAL,
"failed to initialize %s to %d",
1579 elog(
FATAL,
"failed to initialize %s to %g",
1599 elog(
FATAL,
"failed to initialize %s to \"%s\"",
1613 elog(
FATAL,
"failed to initialize %s to %d",
1636 if (gconf->
stack != NULL)
1659 bool fname_is_malloced;
1660 struct stat stat_buf;
1669 if (configdir &&
stat(configdir, &stat_buf) != 0)
1671 write_stderr(
"%s: could not access directory \"%s\": %m\n",
1674 if (errno == ENOENT)
1675 write_stderr(
"Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
1688 fname_is_malloced =
true;
1695 fname_is_malloced =
false;
1699 write_stderr(
"%s does not know where to find the server configuration file.\n"
1700 "You must specify the --config-file or -D invocation "
1701 "option or set the PGDATA environment variable.\n",
1712 if (fname_is_malloced)
1722 write_stderr(
"%s: could not access the server configuration file \"%s\": %m\n",
1741 data_directory_rec =
1749 write_stderr(
"%s does not know where to find the database system data.\n"
1750 "This can be specified as \"data_directory\" in \"%s\", "
1751 "or by the -D invocation option, or by the "
1752 "PGDATA environment variable.\n",
1790 fname_is_malloced =
true;
1797 fname_is_malloced =
false;
1801 write_stderr(
"%s does not know where to find the \"hba\" configuration file.\n"
1802 "This can be specified as \"hba_file\" in \"%s\", "
1803 "or by the -D invocation option, or by the "
1804 "PGDATA environment variable.\n",
1810 if (fname_is_malloced)
1821 fname_is_malloced =
true;
1828 fname_is_malloced =
false;
1832 write_stderr(
"%s does not know where to find the \"ident\" configuration file.\n"
1833 "This can be specified as \"ident_file\" in \"%s\", "
1834 "or by the -D invocation option, or by the "
1835 "PGDATA environment variable.\n",
1841 if (fname_is_malloced)
2000 gconf->
source = newsource;
2018 stack = gconf->
stack;
2080 if (gconf->
stack == NULL)
2082 gconf->
stack = stack;
2098 elog(
WARNING,
"GUC nest level = %d at transaction start",
2168 bool restorePrior =
false;
2169 bool restoreMasked =
false;
2179 restorePrior =
true;
2181 restorePrior =
true;
2186 restoreMasked =
true;
2193 restorePrior =
true;
2195 else if (prev == NULL ||
2254 if (restorePrior || restoreMasked)
2283 void *newextra = newvalue.
extra;
2286 gconf->
extra != newextra)
2301 void *newextra = newvalue.
extra;
2304 gconf->
extra != newextra)
2319 void *newextra = newvalue.
extra;
2322 gconf->
extra != newextra)
2337 void *newextra = newvalue.
extra;
2340 gconf->
extra != newextra)
2364 void *newextra = newvalue.
extra;
2367 gconf->
extra != newextra)
2389 gconf->
srole = newsrole;
2396 gconf->
stack = prev;
2497 conf->
status &= ~GUC_NEEDS_REPORT;
2547 int base_unit,
double *base_value)
2555 while (*unit !=
'\0' && !isspace((
unsigned char) *unit) &&
2557 unitstr[unitlen++] = *(unit++);
2558 unitstr[unitlen] =
'\0';
2560 while (isspace((
unsigned char) *unit))
2571 for (
int i = 0; *
table[
i].unit;
i++)
2573 if (base_unit ==
table[
i].base_unit &&
2574 strcmp(unitstr,
table[
i].unit) == 0)
2583 if (*
table[
i + 1].unit &&
2584 base_unit ==
table[
i + 1].base_unit)
2585 cvalue = rint(cvalue /
table[
i + 1].multiplier) *
2588 *base_value = cvalue;
2615 for (
int i = 0; *
table[
i].unit;
i++)
2617 if (base_unit ==
table[
i].base_unit)
2624 if (
table[
i].multiplier <= 1.0 ||
2645 double *
value,
const char **unit)
2656 for (
int i = 0; *
table[
i].unit;
i++)
2658 if (base_unit ==
table[
i].base_unit)
2700 static char bbuf[8];
2703 if (bbuf[0] ==
'\0')
2704 snprintf(bbuf,
sizeof(bbuf),
"%dkB", BLCKSZ / 1024);
2709 static char xbuf[8];
2712 if (xbuf[0] ==
'\0')
2713 snprintf(xbuf,
sizeof(xbuf),
"%dkB", XLOG_BLCKSZ / 1024);
2723 elog(
ERROR,
"unrecognized GUC units value: %d",
2767 if (*endptr ==
'.' || *endptr ==
'e' || *endptr ==
'E' ||
2774 if (endptr ==
value || errno == ERANGE)
2782 while (isspace((
unsigned char) *endptr))
2786 if (*endptr !=
'\0')
2810 if (
val > INT_MAX ||
val < INT_MIN)
2813 *hintmsg =
gettext_noop(
"Value exceeds integer range.");
2818 *result = (int)
val;
2847 if (endptr ==
value || errno == ERANGE)
2855 while (isspace((
unsigned char) *endptr))
2859 if (*endptr !=
'\0')
2899 if (entry->val ==
val)
2903 elog(
ERROR,
"could not find enum option %d for %s",
2923 *retval = entry->val;
2941 const char *suffix,
const char *
separator)
2966 if (retstr.
len >= seplen)
2969 retstr.
data[retstr.
len - seplen] =
'\0';
2970 retstr.
len -= seplen;
3008 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3009 errmsg(
"parameter \"%s\" requires a Boolean value",
3022 const char *hintmsg;
3025 record->
flags, &hintmsg))
3028 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3029 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3031 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3038 const char *unitspace;
3043 unit = unitspace =
"";
3046 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3047 errmsg(
"%d%s%s is outside the valid range for parameter \"%s\" (%d%s%s .. %d%s%s)",
3048 newval->intval, unitspace, unit,
3050 conf->
min, unitspace, unit,
3051 conf->
max, unitspace, unit)));
3063 const char *hintmsg;
3066 record->
flags, &hintmsg))
3069 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3070 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3072 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3079 const char *unitspace;
3084 unit = unitspace =
"";
3087 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3088 errmsg(
"%g%s%s is outside the valid range for parameter \"%s\" (%g%s%s .. %g%s%s)",
3089 newval->realval, unitspace, unit,
3091 conf->
min, unitspace, unit,
3092 conf->
max, unitspace, unit)));
3108 if (
newval->stringval == NULL)
3117 strlen(
newval->stringval),
3124 newval->stringval = NULL;
3138 _(
"Available values: "),
3153 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3154 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3156 hintmsg ?
errhint(
"%s", hintmsg) : 0));
3232 srole = BOOTSTRAP_SUPERUSERID;
3236 action, changeVal, elevel,
3263 action, changeVal, elevel,
3287 void *newextra = NULL;
3288 bool prohibitValueChange =
false;
3335 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3336 errmsg(
"parameter \"%s\" cannot be set during a parallel operation",
3351 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3352 errmsg(
"parameter \"%s\" cannot be changed",
3369 prohibitValueChange =
true;
3374 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3375 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3384 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3385 errmsg(
"parameter \"%s\" cannot be changed now",
3411 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3412 errmsg(
"permission denied to set parameter \"%s\"",
3453 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3454 errmsg(
"parameter \"%s\" cannot be set after connection start",
3473 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3474 errmsg(
"permission denied to set parameter \"%s\"",
3512 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3513 errmsg(
"cannot set parameter \"%s\" within security-definer function",
3520 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3521 errmsg(
"cannot set parameter \"%s\" within security-restricted operation",
3533 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3534 errmsg(
"parameter \"%s\" cannot be reset", record->
name)));
3540 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3541 errmsg(
"parameter \"%s\" cannot be set locally in functions",
3565 if (changeVal && !makeDefault)
3567 elog(
DEBUG3,
"\"%s\": setting ignored because previous source is higher priority",
3583#define newval (newval_union.boolval)
3589 &newval_union, &newextra))
3608 if (prohibitValueChange)
3618 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3619 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3623 record->
status &= ~GUC_PENDING_RESTART;
3640 record->
srole = srole;
3655 if (stack->source <=
source)
3657 stack->prior.val.boolval =
newval;
3661 stack->scontext = context;
3662 stack->srole = srole;
3679#define newval (newval_union.intval)
3685 &newval_union, &newextra))
3704 if (prohibitValueChange)
3714 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3715 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3719 record->
status &= ~GUC_PENDING_RESTART;
3736 record->
srole = srole;
3751 if (stack->source <=
source)
3753 stack->prior.val.intval =
newval;
3757 stack->scontext = context;
3758 stack->srole = srole;
3775#define newval (newval_union.realval)
3781 &newval_union, &newextra))
3800 if (prohibitValueChange)
3810 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3811 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3815 record->
status &= ~GUC_PENDING_RESTART;
3832 record->
srole = srole;
3847 if (stack->source <=
source)
3849 stack->prior.val.realval =
newval;
3853 stack->scontext = context;
3854 stack->srole = srole;
3872 Oid orig_srole = srole;
3874#define newval (newval_union.stringval)
3880 &newval_union, &newextra))
3915 if (prohibitValueChange)
3917 bool newval_different;
3920 newval_different = (*conf->
variable == NULL ||
3931 if (newval_different)
3935 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3936 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3940 record->
status &= ~GUC_PENDING_RESTART;
3957 record->
srole = srole;
3984 strcmp(record->
name,
"session_authorization") == 0)
3986 value ?
"none" : NULL,
4011 if (stack->source <=
source)
4018 stack->scontext = context;
4019 stack->srole = srole;
4039#define newval (newval_union.enumval)
4045 &newval_union, &newextra))
4064 if (prohibitValueChange)
4074 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4075 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4079 record->
status &= ~GUC_PENDING_RESTART;
4096 record->
srole = srole;
4111 if (stack->source <=
source)
4113 stack->prior.val.enumval =
newval;
4117 stack->scontext = context;
4118 stack->srole = srole;
4139 return changeVal ? 1 : -1;
4222 static char buffer[256];
4227 if (restrict_privileged &&
4230 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4231 errmsg(
"permission denied to examine \"%s\"",
name),
4232 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4233 "pg_read_all_settings")));
4241 snprintf(buffer,
sizeof(buffer),
"%d",
4246 snprintf(buffer,
sizeof(buffer),
"%g",
4272 static char buffer[256];
4278 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4279 errmsg(
"permission denied to examine \"%s\"",
name),
4280 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4281 "pg_read_all_settings")));
4289 snprintf(buffer,
sizeof(buffer),
"%d",
4294 snprintf(buffer,
sizeof(buffer),
"%g",
4323 return record->
flags;
4367 (
errcode(ERRCODE_OUT_OF_MEMORY),
4368 errmsg(
"out of memory")));
4427 pfree(item->filename);
4447 newitem->
next = NULL;
4449 if (*head_p == NULL)
4452 (*tail_p)->
next = newitem;
4474 bool resetall =
false;
4488 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4489 errmsg(
"ALTER SYSTEM is not allowed in this environment")));
4508 elog(
ERROR,
"unrecognized alter system stmt type: %d",
4520 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4521 errmsg(
"permission denied to perform ALTER SYSTEM RESET ALL")));
4530 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4531 errmsg(
"permission denied to set parameter \"%s\"",
4555 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4556 errmsg(
"parameter \"%s\" cannot be changed",
4565 void *newextra = NULL;
4571 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4572 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
4604 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4605 errmsg(
"parameter value for ALTER SYSTEM must not contain a newline")));
4612 snprintf(AutoConfFileName,
sizeof(AutoConfFileName),
"%s",
4614 snprintf(AutoConfTmpFileName,
sizeof(AutoConfTmpFileName),
"%s.%s",
4633 if (
stat(AutoConfFileName, &st) == 0)
4642 errmsg(
"could not open file \"%s\": %m",
4643 AutoConfFileName)));
4649 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
4650 errmsg(
"could not parse contents of file \"%s\"",
4651 AutoConfFileName)));
4688 O_CREAT | O_RDWR | O_TRUNC);
4692 errmsg(
"could not open file \"%s\": %m",
4693 AutoConfTmpFileName)));
4722 (void) unlink(AutoConfTmpFileName);
4757 elog(
FATAL,
"cannot create PGC_POSTMASTER variables after startup");
4766 elog(
FATAL,
"extensions cannot define GUC_LIST_QUOTE variables");
4775 (strcmp(
name,
"pljava.classpath") == 0 ||
4776 strcmp(
name,
"pljava.vmoptions") == 0))
4831 (
errcode(ERRCODE_INTERNAL_ERROR),
4832 errmsg(
"attempt to redefine parameter \"%s\"",
name)));
4835 pHolder = hentry->
gucvar;
4903 const char *curvalue,
4922 curscontext, cursource, cursrole,
4929 curscontext, cursource, cursrole,
4936 curscontext, cursource, cursrole,
4951 curscontext, cursource, cursrole,
4958 if (
variable->stack != oldvarstack)
4977 curscontext, cursource, cursrole,
5095 const char *bootValue,
5150 int classLen = strlen(className);
5165 strncmp(className, var->
name, classLen) == 0 &&
5169 (
errcode(ERRCODE_INVALID_NAME),
5170 errmsg(
"invalid configuration parameter name \"%s\", removing it",
5172 errdetail(
"\"%s\" is now a reserved prefix.",
5264 else if (lconf->
boot_val == NULL ||
5288 result[*num] = conf;
5315 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5316 errmsg(
"permission denied to examine \"%s\"",
name),
5317 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
5318 "pg_read_all_settings")));
5321 *varname = record->
name;
5399 snprintf(buffer,
sizeof(buffer),
"%g%s",
5455write_one_nondefault_variable(FILE *fp,
struct config_generic *gconf)
5519 fwrite(&gconf->
srole, 1,
sizeof(gconf->
srole), fp);
5523write_nondefault_variables(
GucContext context)
5541 errmsg(
"could not write to file \"%s\": %m",
5542 CONFIG_EXEC_PARAMS_NEW)));
5552 write_one_nondefault_variable(fp, gconf);
5559 errmsg(
"could not write to file \"%s\": %m",
5560 CONFIG_EXEC_PARAMS_NEW)));
5568 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5578read_string_with_null(FILE *fp)
5587 if ((ch = fgetc(fp)) == EOF)
5592 elog(
FATAL,
"invalid format of exec config params file");
5596 else if (
i == maxlen)
5610read_nondefault_variables(
void)
5628 if (errno != ENOENT)
5631 errmsg(
"could not read from file \"%s\": %m",
5632 CONFIG_EXEC_PARAMS)));
5638 if ((varname = read_string_with_null(fp)) == NULL)
5642 elog(
FATAL,
"failed to locate variable \"%s\" in exec config params file", varname);
5644 if ((varvalue = read_string_with_null(fp)) == NULL)
5645 elog(
FATAL,
"invalid format of exec config params file");
5646 if ((varsourcefile = read_string_with_null(fp)) == NULL)
5647 elog(
FATAL,
"invalid format of exec config params file");
5648 if (fread(&varsourceline, 1,
sizeof(varsourceline), fp) !=
sizeof(varsourceline))
5649 elog(
FATAL,
"invalid format of exec config params file");
5650 if (fread(&varsource, 1,
sizeof(varsource), fp) !=
sizeof(varsource))
5651 elog(
FATAL,
"invalid format of exec config params file");
5652 if (fread(&varscontext, 1,
sizeof(varscontext), fp) !=
sizeof(varscontext))
5653 elog(
FATAL,
"invalid format of exec config params file");
5654 if (fread(&varsrole, 1,
sizeof(varsrole), fp) !=
sizeof(varsrole))
5655 elog(
FATAL,
"invalid format of exec config params file");
5658 varscontext, varsource, varsrole,
5660 if (varsourcefile[0])
5727 size = strlen(gconf->
name) + 1;
5793 size =
add_size(size, valsize + 1);
5823 size =
sizeof(
Size);
5854 elog(
ERROR,
"not enough space to serialize GUC state");
5856 va_start(vargs, fmt);
5857 n =
vsnprintf(*destptr, *maxbytes, fmt, vargs);
5863 elog(
ERROR,
"vsnprintf failed: %m with format string \"%s\"", fmt);
5868 elog(
ERROR,
"not enough space to serialize GUC state");
5880 if (valsize > *maxbytes)
5881 elog(
ERROR,
"not enough space to serialize GUC state");
5883 memcpy(*destptr,
val, valsize);
5884 *destptr += valsize;
5885 *maxbytes -= valsize;
5909 (*conf->
variable ?
"true" :
"false"));
5962 sizeof(gconf->
srole));
5978 Assert(maxsize >
sizeof(actual_size));
5979 curptr = start_address +
sizeof(actual_size);
5980 bytes_left = maxsize -
sizeof(actual_size);
5992 actual_size = maxsize - bytes_left -
sizeof(actual_size);
5993 memcpy(start_address, &actual_size,
sizeof(actual_size));
6005 char *retptr = *srcptr;
6008 if (*srcptr >= srcend)
6012 for (ptr = *srcptr; ptr < srcend && *ptr !=
'\0'; ptr++)
6016 elog(
ERROR,
"could not find null terminator in GUC state");
6028 if (*srcptr + size > srcend)
6031 memcpy(
dest, *srcptr, size);
6042 char **error_context_name_and_value = (
char **)
arg;
6044 if (error_context_name_and_value)
6045 errcontext(
"while setting parameter \"%s\" to \"%s\"",
6046 error_context_name_and_value[0],
6047 error_context_name_and_value[1]);
6071 char *srcptr = (
char *) gucstate;
6147 memcpy(&
len, gucstate,
sizeof(
len));
6149 srcptr +=
sizeof(
len);
6150 srcend = srcptr +
len;
6155 error_context_callback.
arg = NULL;
6159 while (srcptr < srcend)
6162 char *error_context_name_and_value[2];
6167 if (varsourcefile[0])
6169 &varsourceline,
sizeof(varsourceline));
6173 &varsource,
sizeof(varsource));
6175 &varscontext,
sizeof(varscontext));
6177 &varsrole,
sizeof(varsrole));
6179 error_context_name_and_value[0] = varname;
6180 error_context_name_and_value[1] = varvalue;
6181 error_context_callback.
arg = &error_context_name_and_value[0];
6183 varscontext, varsource, varsrole,
6187 (
errcode(ERRCODE_INTERNAL_ERROR),
6188 errmsg(
"parameter \"%s\" could not be set", varname)));
6189 if (varsourcefile[0])
6191 error_context_callback.
arg = NULL;
6213 equal_pos = strcspn(
string,
"=");
6215 if (
string[equal_pos] ==
'=')
6229 for (
char *cp = *
name; *cp; cp++)
6274 (
errcode(ERRCODE_SYNTAX_ERROR),
6275 errmsg(
"could not parse setting for parameter \"%s\"",
6305 forboth(lc1, gucNames, lc2, gucValues)
6377 if (strncmp(current,
newval, strlen(
name) + 1) == 0)
6507 eqsgn = strchr(
val,
'=');
6546 bool skipIfNoPermissions)
6577 if (!gconf && !reset_custom)
6592 if (skipIfNoPermissions)
6595 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
6596 errmsg(
"permission denied to set parameter \"%s\"",
name)));
6606 else if (skipIfNoPermissions)
6660 errmsg(
"invalid value for parameter \"%s\": %d",
6694 errmsg(
"invalid value for parameter \"%s\": %d",
6728 errmsg(
"invalid value for parameter \"%s\": %g",
6746 volatile bool result =
true;
6771 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
6812 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
AclResult pg_parameter_aclcheck(const char *name, Oid roleid, AclMode mode)
ArrayType * array_set(ArrayType *array, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
TimestampTz GetCurrentTimestamp(void)
#define write_stderr(str)
bool parse_bool(const char *value, bool *result)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define unconstify(underlying_type, expr)
#define IS_HIGHBIT_SET(ch)
#define pg_attribute_printf(f, a)
#define CONF_FILE_START_DEPTH
#define fprintf(file, fmt, msg)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
void * hash_seq_search(HASH_SEQ_STATUS *status)
int64 hash_get_num_entries(HTAB *hashp)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
void FlushErrorState(void)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int durable_rename(const char *oldfile, const char *newfile, int elevel)
int BasicOpenFile(const char *fileName, int fileFlags)
FILE * AllocateFile(const char *name, const char *mode)
#define palloc_object(type)
#define MCXT_ALLOC_NO_OOM
void FreeConfigVariables(ConfigVariable *list)
void record_config_file_error(const char *errmsg, const char *config_file, int lineno, ConfigVariable **head_p, ConfigVariable **tail_p)
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
bool ParseConfigFile(const char *config_file, bool strict, const char *calling_file, int calling_lineno, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
void ProcessConfigFile(GucContext context)
void BeginReportingGUCOptions(void)
static bool validate_option_array_item(const char *name, const char *value, bool skipIfNoPermissions)
void GUC_check_errcode(int sqlerrcode)
static const char *const map_old_guc_names[]
static void guc_restore_error_context_callback(void *arg)
static void ReportGUCOption(struct config_generic *record)
void RestoreGUCState(void *gucstate)
static bool assignable_custom_variable_name(const char *name, bool skip_errors, int elevel)
static dlist_head guc_nondef_list
const char * config_enum_lookup_by_value(const struct config_generic *record, int val)
static int guc_name_match(const void *key1, const void *key2, Size keysize)
int set_config_option_ext(const char *name, const char *value, GucContext context, GucSource source, Oid srole, GucAction action, bool changeVal, int elevel, bool is_reload)
static bool call_real_check_hook(const struct config_generic *conf, double *newval, void **extra, GucSource source, int elevel)
static void do_serialize(char **destptr, Size *maxbytes, const char *fmt,...) pg_attribute_printf(3
bool parse_int(const char *value, int *result, int flags, const char **hintmsg)
char * config_enum_get_options(const struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
#define GUC_SAFE_SEARCH_PATH
static slist_head guc_report_list
static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
const char * get_config_unit_name(int flags)
void DefineCustomRealVariable(const char *name, const char *short_desc, const char *long_desc, double *valueAddr, double bootValue, double minValue, double maxValue, GucContext context, int flags, GucRealCheckHook check_hook, GucRealAssignHook assign_hook, GucShowHook show_hook)
void DefineCustomEnumVariable(const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, const struct config_enum_entry *options, GucContext context, int flags, GucEnumCheckHook check_hook, GucEnumAssignHook assign_hook, GucShowHook show_hook)
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
static bool convert_to_base_unit(double value, const char *unit, int base_unit, double *base_value)
static void do_serialize_binary(char **destptr, Size *maxbytes, void *val, Size valsize)
static void serialize_variable(char **destptr, Size *maxbytes, struct config_generic *gconf)
static void define_custom_variable(struct config_generic *variable)
static void free_placeholder(struct config_generic *pHolder)
int NewGUCNestLevel(void)
ArrayType * GUCArrayAdd(ArrayType *array, const char *name, const char *value)
void ProcessGUCArray(ArrayType *array, GucContext context, GucSource source, GucAction action)
static bool valid_custom_variable_name(const char *name)
struct config_generic ** get_guc_variables(int *num_vars)
char * GUC_check_errhint_string
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
static bool call_enum_check_hook(const struct config_generic *conf, int *newval, void **extra, GucSource source, int elevel)
static int guc_var_compare(const void *a, const void *b)
static void set_string_field(struct config_generic *conf, char **field, char *newval)
void * guc_realloc(int elevel, void *old, size_t size)
void DefineCustomStringVariable(const char *name, const char *short_desc, const char *long_desc, char **valueAddr, const char *bootValue, GucContext context, int flags, GucStringCheckHook check_hook, GucStringAssignHook assign_hook, GucShowHook show_hook)
void * guc_malloc(int elevel, size_t size)
bool parse_real(const char *value, double *result, int flags, const char **hintmsg)
static void push_old_value(struct config_generic *gconf, GucAction action)
void DefineCustomBoolVariable(const char *name, const char *short_desc, const char *long_desc, bool *valueAddr, bool bootValue, GucContext context, int flags, GucBoolCheckHook check_hook, GucBoolAssignHook assign_hook, GucShowHook show_hook)
static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head)
static void InitializeOneGUCOption(struct config_generic *gconf)
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
static bool can_skip_gucvar(struct config_generic *gconf)
void SerializeGUCState(Size maxsize, char *start_address)
static void pg_timezone_abbrev_initialize(void)
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
static const unit_conversion memory_unit_conversion_table[]
static bool call_int_check_hook(const struct config_generic *conf, int *newval, void **extra, GucSource source, int elevel)
bool SelectConfigFiles(const char *userDoption, const char *progname)
static void reapply_stacked_values(struct config_generic *variable, struct config_generic *pHolder, GucStack *stack, const char *curvalue, GucContext curscontext, GucSource cursource, Oid cursrole)
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type)
static bool parse_and_validate_value(const struct config_generic *record, const char *value, GucSource source, int elevel, union config_var_val *newval, void **newextra)
#define REALTYPE_PRECISION
config_handle * get_config_handle(const char *name)
char * GUC_check_errmsg_string
void AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
Size EstimateGUCStateSpace(void)
static const char *const memory_units_hint
static void discard_stack_value(struct config_generic *gconf, config_var_value *val)
static int GUC_check_errcode_value
void ParseLongOption(const char *string, char **name, char **value)
void ResetAllOptions(void)
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
static void RemoveGUCFromLists(struct config_generic *gconf)
const char * GetConfigOptionResetString(const char *name)
bool config_enum_lookup_by_name(const struct config_enum *record, const char *value, int *retval)
void build_guc_variables(void)
static struct config_generic * add_placeholder_variable(const char *name, int elevel)
static void set_stack_value(struct config_generic *gconf, config_var_value *val)
void InitializeGUCOptions(void)
static void read_gucstate_binary(char **srcptr, char *srcend, void *dest, Size size)
void MarkGUCPrefixReserved(const char *className)
ArrayType * GUCArrayReset(ArrayType *array)
struct config_generic ** get_explain_guc_options(int *num)
ArrayType * GUCArrayDelete(ArrayType *array, const char *name)
static bool add_guc_variable(struct config_generic *var, int elevel)
static bool extra_field_used(struct config_generic *gconf, void *extra)
static char * read_gucstate(char **srcptr, char *srcend)
static List * reserved_class_prefix
void RestrictSearchPath(void)
int GetConfigOptionFlags(const char *name, bool missing_ok)
char * GUC_check_errdetail_string
static uint32 guc_name_hash(const void *key, Size keysize)
void check_GUC_name_for_parameter_acl(const char *name)
static void InitializeGUCOptionsFromEnvironment(void)
char * convert_GUC_name_for_parameter_acl(const char *name)
static slist_head guc_stack_list
int set_config_with_handle(const char *name, config_handle *handle, const char *value, GucContext context, GucSource source, Oid srole, GucAction action, bool changeVal, int elevel, bool is_reload)
static const char *const time_units_hint
ConfigVariable * ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
static Size estimate_variable_size(struct config_generic *gconf)
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
int guc_name_compare(const char *namea, const char *nameb)
static void set_guc_source(struct config_generic *gconf, GucSource newsource)
static void static bool call_bool_check_hook(const struct config_generic *conf, bool *newval, void **extra, GucSource source, int elevel)
void TransformGUCArray(ArrayType *array, List **names, List **values)
char * guc_strdup(int elevel, const char *src)
static void set_extra_field(struct config_generic *gconf, void **field, void *newval)
static const unit_conversion time_unit_conversion_table[]
static HTAB * guc_hashtab
static MemoryContext GUCMemoryContext
void ReportChangedGUCOptions(void)
static bool string_field_used(struct config_generic *conf, char *strval)
void AtEOXact_GUC(bool isCommit, int nestLevel)
void DefineCustomIntVariable(const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, int minValue, int maxValue, GucContext context, int flags, GucIntCheckHook check_hook, GucIntAssignHook assign_hook, GucShowHook show_hook)
char * ShowGUCOption(const struct config_generic *record, bool use_units)
static bool reporting_enabled
static bool call_string_check_hook(const struct config_generic *conf, char **newval, void **extra, GucSource source, int elevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
bool(* GucBoolCheckHook)(bool *newval, void **extra, GucSource source)
#define PG_AUTOCONF_FILENAME
bool(* GucRealCheckHook)(double *newval, void **extra, GucSource source)
void(* GucStringAssignHook)(const char *newval, void *extra)
bool(* GucEnumCheckHook)(int *newval, void **extra, GucSource source)
void(* GucBoolAssignHook)(bool newval, void *extra)
#define GUC_CUSTOM_PLACEHOLDER
void(* GucEnumAssignHook)(int newval, void *extra)
#define GUC_NOT_WHILE_SEC_REST
#define GUC_DISALLOW_IN_FILE
bool(* GucStringCheckHook)(char **newval, void **extra, GucSource source)
#define GUC_DISALLOW_IN_AUTO_FILE
void(* GucIntAssignHook)(int newval, void *extra)
void(* GucRealAssignHook)(double newval, void *extra)
#define GUC_ALLOW_IN_PARALLEL
bool(* GucIntCheckHook)(int *newval, void **extra, GucSource source)
#define GUC_NOT_IN_SAMPLE
#define GUC_QUALIFIER_SEPARATOR
const char *(* GucShowHook)(void)
bool ConfigOptionIsVisible(const struct config_generic *conf)
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
PGDLLIMPORT struct config_generic ConfigureNames[]
#define GUC_PENDING_RESTART
Assert(PointerIsAligned(start, uint64))
void slist_delete(slist_head *head, const slist_node *node)
static void slist_delete_current(slist_mutable_iter *iter)
#define dlist_foreach(iter, lhead)
static void dlist_delete(dlist_node *node)
#define slist_foreach_modify(iter, lhead)
#define dlist_foreach_modify(iter, lhead)
static void slist_push_head(slist_head *head, slist_node *node)
static void dlist_push_tail(dlist_head *head, dlist_node *node)
#define slist_container(type, membername, ptr)
#define dlist_container(type, membername, ptr)
List * lappend(List *list, void *datum)
void list_free(List *list)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
const char * GetDatabaseEncodingName(void)
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext TopTransactionContext
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext GetMemoryChunkContext(void *pointer)
void * MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
void * repalloc_extended(void *pointer, Size size, int flags)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define IsBootstrapProcessingMode()
bool InSecurityRestrictedOperation(void)
bool InLocalUserIdChange(void)
void SetDataDir(const char *dir)
bool process_shared_preload_libraries_in_progress
#define InvokeObjectPostAlterHookArgStr(classId, objectName, subId, auxiliaryId, is_internal)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static uint32 pg_rotate_left32(uint32 word, int n)
#define forboth(cell1, list1, cell2, list2)
static const struct lconv_member_info table[]
static void bail_out(bool noatexit, const char *fmt,...) pg_attribute_printf(2
static rewind_source * source
void pg_timezone_initialize(void)
int pg_strcasecmp(const char *s1, const char *s2)
char * escape_single_quotes_ascii(const char *src)
char * make_absolute_path(const char *path)
#define qsort(a, b, c, d)
size_t strlcpy(char *dst, const char *src, size_t siz)
CommandDest whereToSendOutput
static const char * userDoption
static int fd(const char *x, int i)
#define PqMsg_ParameterStatus
char * psprintf(const char *fmt,...)
void truncate_identifier(char *ident, int len, bool warn)
Size add_size(Size s1, Size s2)
ssize_t get_stack_depth_rlimit(void)
void resetStringInfo(StringInfo str)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
VariableSetStmt * setstmt
struct ConfigVariable * next
struct ErrorContextCallback * previous
void(* callback)(void *arg)
struct config_generic * gucvar
GucBoolCheckHook check_hook
GucBoolAssignHook assign_hook
const struct config_enum_entry * options
GucEnumAssignHook assign_hook
GucEnumCheckHook check_hook
struct config_string _string
GucContext reset_scontext
GucIntAssignHook assign_hook
GucIntCheckHook check_hook
GucRealAssignHook assign_hook
GucRealCheckHook check_hook
GucStringCheckHook check_hook
GucStringAssignHook assign_hook
GucContext masked_scontext
bool IsInParallelMode(void)
bool RecoveryInProgress(void)
static void infile(const char *name)