55#define CONFIG_FILENAME "postgresql.conf"
56#define HBA_FILENAME "pg_hba.conf"
57#define IDENT_FILENAME "pg_ident.conf"
60#define CONFIG_EXEC_PARAMS "global/config_exec_params"
61#define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"
68#define REALTYPE_PRECISION 17
74#define GUC_SAFE_SEARCH_PATH "pg_catalog, pg_temp"
101#define MAX_UNIT_LEN 3
112#if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
113#error BLCKSZ must be between 1KB and 1MB
115#if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
116#error XLOG_BLCKSZ must be between 1KB and 1MB
147 {
"TB",
GUC_UNIT_XBLOCKS, (1024.0 * 1024.0 * 1024.0) / (XLOG_BLCKSZ / 1024)},
191 "sort_mem",
"work_mem",
192 "vacuum_mem",
"maintenance_work_mem",
193 "ssl_ecdh_curve",
"ssl_groups",
249 const char *curvalue,
253 bool skipIfNoPermissions);
285 bool applying =
false;
286 const char *ConfFileWithError;
339 for (item = head; item; item = item->
next)
342 strcmp(item->
name,
"data_directory") == 0)
347 newlist->
next = NULL;
348 head = tail = newlist;
371 gconf->
status &= ~GUC_IS_IN_FILE;
387 for (item = head; item; item = item->
next)
413 for (pitem = head; pitem != item; pitem = pitem->
next)
416 strcmp(pitem->
name, item->
name) == 0)
427 (
errcode(ERRCODE_UNDEFINED_OBJECT),
428 errmsg(
"unrecognized configuration parameter \"%s\" in file \"%s\" line %d",
431 item->
errmsg =
pstrdup(
"unrecognized configuration parameter");
467 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
468 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
504 (
errmsg(
"parameter \"%s\" removed from configuration file, reset to default",
534 for (item = head; item; item = item->
next)
536 char *pre_value = NULL;
567 if (strcmp(pre_value, post_value) != 0)
569 (
errmsg(
"parameter \"%s\" changed to \"%s\"",
592 if (scres != 0 && applySettings)
605 if (
error && applySettings)
610 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
611 errmsg(
"configuration file \"%s\" contains errors",
612 ConfFileWithError)));
615 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
616 errmsg(
"configuration file \"%s\" contains errors; unaffected changes were applied",
617 ConfFileWithError)));
620 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
621 errmsg(
"configuration file \"%s\" contains errors; no changes were applied",
622 ConfFileWithError)));
646 (
errcode(ERRCODE_OUT_OF_MEMORY),
647 errmsg(
"out of memory")));
671 (
errcode(ERRCODE_OUT_OF_MEMORY),
672 errmsg(
"out of memory")));
680 size_t len = strlen(src) + 1;
733 char *oldval = *field;
794 void *oldval = *field;
830 &(
val->val.stringval),
858 &(
val->val.stringval),
890 qsort(result, *num_vars,
967 size_vars = num_vars + num_vars / 4;
969 hash_ctl.
keysize =
sizeof(
char *);
1059 (
errcode(ERRCODE_OUT_OF_MEMORY),
1060 errmsg(
"out of memory")));
1078 bool saw_sep =
false;
1079 bool name_start =
true;
1081 for (
const char *p =
name; *p; p++)
1090 else if (strchr(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1091 "abcdefghijklmnopqrstuvwxyz_", *p) != NULL ||
1097 else if (!name_start && strchr(
"0123456789$", *p) != NULL)
1128 size_t classLen = sep -
name;
1136 (
errcode(ERRCODE_INVALID_NAME),
1137 errmsg(
"invalid configuration parameter name \"%s\"",
1139 errdetail(
"Custom parameter names must be two or more simple identifiers separated by dots.")));
1145 const char *rcprefix =
lfirst(lc);
1147 if (strlen(rcprefix) == classLen &&
1148 strncmp(
name, rcprefix, classLen) == 0)
1152 (
errcode(ERRCODE_INVALID_NAME),
1153 errmsg(
"invalid configuration parameter name \"%s\"",
1155 errdetail(
"\"%s\" is a reserved prefix.",
1167 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1168 errmsg(
"unrecognized configuration parameter \"%s\"",
1207 var->
variable = (
char **) (var + 1);
1260 skip_errors, elevel);
1263 if (create_placeholders)
1277 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1278 errmsg(
"unrecognized configuration parameter \"%s\"",
1290 const char *namea = **(
const char **
const *)
a;
1291 const char *nameb = **(
const char **
const *)
b;
1307 while (*namea && *nameb)
1309 char cha = *namea++;
1310 char chb = *nameb++;
1312 if (cha >=
'A' && cha <=
'Z')
1314 if (chb >=
'A' && chb <=
'Z')
1333 const char *
name = *(
const char *
const *)
key;
1340 if (ch >=
'A' && ch <=
'Z')
1356 const char *name1 = *(
const char *
const *) key1;
1357 const char *name2 = *(
const char *
const *) key2;
1390 for (
char *ptr = result; *ptr !=
'\0'; ptr++)
1394 if (ch >=
'A' && ch <=
'Z')
1434#ifdef USE_ASSERT_CHECKING
1447 elog(
LOG,
"GUC (PGC_BOOL) %s, boot_val=%d, C-var=%d",
1459 elog(
LOG,
"GUC (PGC_INT) %s, boot_val=%d, C-var=%d",
1471 elog(
LOG,
"GUC (PGC_REAL) %s, boot_val=%g, C-var=%g",
1485 elog(
LOG,
"GUC (PGC_STRING) %s, boot_val=%s, C-var=%s",
1497 elog(
LOG,
"GUC (PGC_ENUM) %s, boot_val=%d, C-var=%d",
1514 elog(
LOG,
"GUC %s flags: NO_SHOW_ALL and !NOT_IN_SAMPLE",
1594 env = getenv(
"PGPORT");
1598 env = getenv(
"PGDATESTYLE");
1602 env = getenv(
"PGCLIENTENCODING");
1614 if (stack_rlimit > 0)
1618 if (new_limit > 100)
1623 if (new_limit < 2048)
1630 snprintf(limbuf,
sizeof(limbuf),
"%ld", new_limit);
1651 gconf->
srole = BOOTSTRAP_SUPERUSERID;
1653 gconf->
stack = NULL;
1654 gconf->
extra = NULL;
1669 elog(
FATAL,
"failed to initialize %s to %d",
1687 elog(
FATAL,
"failed to initialize %s to %d",
1705 elog(
FATAL,
"failed to initialize %s to %g",
1727 elog(
FATAL,
"failed to initialize %s to \"%s\"",
1743 elog(
FATAL,
"failed to initialize %s to %d",
1765 if (gconf->
stack != NULL)
1788 bool fname_is_malloced;
1789 struct stat stat_buf;
1798 if (configdir &&
stat(configdir, &stat_buf) != 0)
1800 write_stderr(
"%s: could not access directory \"%s\": %m\n",
1803 if (errno == ENOENT)
1804 write_stderr(
"Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
1817 fname_is_malloced =
true;
1824 fname_is_malloced =
false;
1828 write_stderr(
"%s does not know where to find the server configuration file.\n"
1829 "You must specify the --config-file or -D invocation "
1830 "option or set the PGDATA environment variable.\n",
1841 if (fname_is_malloced)
1851 write_stderr(
"%s: could not access the server configuration file \"%s\": %m\n",
1879 write_stderr(
"%s does not know where to find the database system data.\n"
1880 "This can be specified as \"data_directory\" in \"%s\", "
1881 "or by the -D invocation option, or by the "
1882 "PGDATA environment variable.\n",
1920 fname_is_malloced =
true;
1927 fname_is_malloced =
false;
1931 write_stderr(
"%s does not know where to find the \"hba\" configuration file.\n"
1932 "This can be specified as \"hba_file\" in \"%s\", "
1933 "or by the -D invocation option, or by the "
1934 "PGDATA environment variable.\n",
1940 if (fname_is_malloced)
1951 fname_is_malloced =
true;
1958 fname_is_malloced =
false;
1962 write_stderr(
"%s does not know where to find the \"ident\" configuration file.\n"
1963 "This can be specified as \"ident_file\" in \"%s\", "
1964 "or by the -D invocation option, or by the "
1965 "PGDATA environment variable.\n",
1971 if (fname_is_malloced)
2125 gconf->
source = newsource;
2143 stack = gconf->
stack;
2205 if (gconf->
stack == NULL)
2207 gconf->
stack = stack;
2223 elog(
WARNING,
"GUC nest level = %d at transaction start",
2293 bool restorePrior =
false;
2294 bool restoreMasked =
false;
2304 restorePrior =
true;
2306 restorePrior =
true;
2311 restoreMasked =
true;
2318 restorePrior =
true;
2320 else if (prev == NULL ||
2379 if (restorePrior || restoreMasked)
2408 void *newextra = newvalue.
extra;
2426 void *newextra = newvalue.
extra;
2444 void *newextra = newvalue.
extra;
2462 void *newextra = newvalue.
extra;
2489 void *newextra = newvalue.
extra;
2514 gconf->
srole = newsrole;
2521 gconf->
stack = prev;
2622 conf->
status &= ~GUC_NEEDS_REPORT;
2672 int base_unit,
double *base_value)
2681 while (*unit !=
'\0' && !isspace((
unsigned char) *unit) &&
2683 unitstr[unitlen++] = *(unit++);
2684 unitstr[unitlen] =
'\0';
2686 while (isspace((
unsigned char) *unit))
2697 for (
i = 0; *table[
i].
unit;
i++)
2699 if (base_unit == table[
i].base_unit &&
2700 strcmp(unitstr, table[
i].unit) == 0)
2709 if (*table[
i + 1].unit &&
2710 base_unit == table[
i + 1].base_unit)
2711 cvalue = rint(cvalue / table[
i + 1].multiplier) *
2714 *base_value = cvalue;
2742 for (
i = 0; *table[
i].
unit;
i++)
2744 if (base_unit == table[
i].base_unit)
2751 if (table[
i].multiplier <= 1.0 ||
2752 base_value % (
int64) table[
i].multiplier == 0)
2754 *
value = (
int64) rint(base_value / table[
i].multiplier);
2755 *unit = table[
i].
unit;
2772 double *
value,
const char **unit)
2784 for (
i = 0; *table[
i].
unit;
i++)
2786 if (base_unit == table[
i].base_unit)
2799 *unit = table[
i].
unit;
2828 static char bbuf[8];
2831 if (bbuf[0] ==
'\0')
2832 snprintf(bbuf,
sizeof(bbuf),
"%dkB", BLCKSZ / 1024);
2837 static char xbuf[8];
2840 if (xbuf[0] ==
'\0')
2841 snprintf(xbuf,
sizeof(xbuf),
"%dkB", XLOG_BLCKSZ / 1024);
2851 elog(
ERROR,
"unrecognized GUC units value: %d",
2895 if (*endptr ==
'.' || *endptr ==
'e' || *endptr ==
'E' ||
2902 if (endptr ==
value || errno == ERANGE)
2910 while (isspace((
unsigned char) *endptr))
2914 if (*endptr !=
'\0')
2938 if (
val > INT_MAX ||
val < INT_MIN)
2941 *hintmsg =
gettext_noop(
"Value exceeds integer range.");
2946 *result = (int)
val;
2975 if (endptr ==
value || errno == ERANGE)
2983 while (isspace((
unsigned char) *endptr))
2987 if (*endptr !=
'\0')
3027 for (entry = record->
options; entry && entry->
name; entry++)
3033 elog(
ERROR,
"could not find enum option %d for %s",
3051 for (entry = record->
options; entry && entry->
name; entry++)
3055 *retval = entry->
val;
3073 const char *suffix,
const char *
separator)
3083 for (entry = record->
options; entry && entry->
name; entry++)
3099 if (retstr.
len >= seplen)
3102 retstr.
data[retstr.
len - seplen] =
'\0';
3103 retstr.
len -= seplen;
3143 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3144 errmsg(
"parameter \"%s\" requires a Boolean value",
3157 const char *hintmsg;
3163 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3164 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3166 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3173 const char *unitspace;
3178 unit = unitspace =
"";
3181 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3182 errmsg(
"%d%s%s is outside the valid range for parameter \"%s\" (%d%s%s .. %d%s%s)",
3183 newval->intval, unitspace, unit,
3185 conf->
min, unitspace, unit,
3186 conf->
max, unitspace, unit)));
3198 const char *hintmsg;
3204 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3205 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3207 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3214 const char *unitspace;
3219 unit = unitspace =
"";
3222 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3223 errmsg(
"%g%s%s is outside the valid range for parameter \"%s\" (%g%s%s .. %g%s%s)",
3224 newval->realval, unitspace, unit,
3226 conf->
min, unitspace, unit,
3227 conf->
max, unitspace, unit)));
3245 if (
newval->stringval == NULL)
3254 strlen(
newval->stringval),
3261 newval->stringval = NULL;
3275 "Available values: ",
3279 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3280 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3282 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3358 srole = BOOTSTRAP_SUPERUSERID;
3362 action, changeVal, elevel,
3389 action, changeVal, elevel,
3413 void *newextra = NULL;
3414 bool prohibitValueChange =
false;
3461 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3462 errmsg(
"parameter \"%s\" cannot be set during a parallel operation",
3477 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3478 errmsg(
"parameter \"%s\" cannot be changed",
3495 prohibitValueChange =
true;
3500 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3501 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3510 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3511 errmsg(
"parameter \"%s\" cannot be changed now",
3537 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3538 errmsg(
"permission denied to set parameter \"%s\"",
3579 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3580 errmsg(
"parameter \"%s\" cannot be set after connection start",
3599 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3600 errmsg(
"permission denied to set parameter \"%s\"",
3638 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3639 errmsg(
"cannot set parameter \"%s\" within security-definer function",
3646 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3647 errmsg(
"cannot set parameter \"%s\" within security-restricted operation",
3659 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3660 errmsg(
"parameter \"%s\" cannot be reset", record->
name)));
3666 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3667 errmsg(
"parameter \"%s\" cannot be set locally in functions",
3691 if (changeVal && !makeDefault)
3693 elog(
DEBUG3,
"\"%s\": setting ignored because previous source is higher priority",
3709#define newval (newval_union.boolval)
3715 &newval_union, &newextra))
3734 if (prohibitValueChange)
3744 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3745 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3749 record->
status &= ~GUC_PENDING_RESTART;
3781 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3790 stack->
srole = srole;
3807#define newval (newval_union.intval)
3813 &newval_union, &newextra))
3832 if (prohibitValueChange)
3842 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3843 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3847 record->
status &= ~GUC_PENDING_RESTART;
3879 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3888 stack->
srole = srole;
3905#define newval (newval_union.realval)
3911 &newval_union, &newextra))
3930 if (prohibitValueChange)
3940 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3941 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3945 record->
status &= ~GUC_PENDING_RESTART;
3977 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3986 stack->
srole = srole;
4004 Oid orig_srole = srole;
4006#define newval (newval_union.stringval)
4012 &newval_union, &newextra))
4047 if (prohibitValueChange)
4049 bool newval_different;
4052 newval_different = (*conf->
variable == NULL ||
4063 if (newval_different)
4067 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4068 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4072 record->
status &= ~GUC_PENDING_RESTART;
4116 strcmp(conf->
gen.
name,
"session_authorization") == 0)
4118 value ?
"none" : NULL,
4143 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
4153 stack->
srole = srole;
4173#define newval (newval_union.enumval)
4179 &newval_union, &newextra))
4198 if (prohibitValueChange)
4208 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4209 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4213 record->
status &= ~GUC_PENDING_RESTART;
4245 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
4254 stack->
srole = srole;
4275 return changeVal ? 1 : -1;
4358 static char buffer[256];
4363 if (restrict_privileged &&
4366 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4367 errmsg(
"permission denied to examine \"%s\"",
name),
4368 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4369 "pg_read_all_settings")));
4374 return *((
struct config_bool *) record)->variable ?
"on" :
"off";
4377 snprintf(buffer,
sizeof(buffer),
"%d",
4382 snprintf(buffer,
sizeof(buffer),
"%g",
4408 static char buffer[256];
4414 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4415 errmsg(
"permission denied to examine \"%s\"",
name),
4416 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4417 "pg_read_all_settings")));
4422 return ((
struct config_bool *) record)->reset_val ?
"on" :
"off";
4425 snprintf(buffer,
sizeof(buffer),
"%d",
4430 snprintf(buffer,
sizeof(buffer),
"%g",
4459 return record->
flags;
4492 for (item = head; item != NULL; item = item->
next)
4504 (
errcode(ERRCODE_OUT_OF_MEMORY),
4505 errmsg(
"out of memory")));
4549 for (item = *head_p; item != NULL; item =
next)
4576 item =
palloc(
sizeof *item);
4586 if (*head_p == NULL)
4589 (*tail_p)->
next = item;
4611 bool resetall =
false;
4625 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4626 errmsg(
"ALTER SYSTEM is not allowed in this environment")));
4645 elog(
ERROR,
"unrecognized alter system stmt type: %d",
4657 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4658 errmsg(
"permission denied to perform ALTER SYSTEM RESET ALL")));
4667 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4668 errmsg(
"permission denied to set parameter \"%s\"",
4692 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4693 errmsg(
"parameter \"%s\" cannot be changed",
4702 void *newextra = NULL;
4708 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4709 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
4736 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4737 errmsg(
"parameter value for ALTER SYSTEM must not contain a newline")));
4744 snprintf(AutoConfFileName,
sizeof(AutoConfFileName),
"%s",
4746 snprintf(AutoConfTmpFileName,
sizeof(AutoConfTmpFileName),
"%s.%s",
4765 if (
stat(AutoConfFileName, &st) == 0)
4774 errmsg(
"could not open file \"%s\": %m",
4775 AutoConfFileName)));
4781 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
4782 errmsg(
"could not parse contents of file \"%s\"",
4783 AutoConfFileName)));
4820 O_CREAT | O_RDWR | O_TRUNC);
4824 errmsg(
"could not open file \"%s\": %m",
4825 AutoConfTmpFileName)));
4854 (void) unlink(AutoConfTmpFileName);
4890 elog(
FATAL,
"cannot create PGC_POSTMASTER variables after startup");
4899 elog(
FATAL,
"extensions cannot define GUC_LIST_QUOTE variables");
4908 (strcmp(
name,
"pljava.classpath") == 0 ||
4909 strcmp(
name,
"pljava.vmoptions") == 0))
4963 (
errcode(ERRCODE_INTERNAL_ERROR),
4964 errmsg(
"attempt to redefine parameter \"%s\"",
name)));
5043 const char *curvalue,
5058 switch (stack->
state)
5062 curscontext, cursource, cursrole,
5069 curscontext, cursource, cursrole,
5076 curscontext, cursource, cursrole,
5091 curscontext, cursource, cursrole,
5098 if (
variable->stack != oldvarstack)
5117 curscontext, cursource, cursrole,
5133 const char *short_desc,
5134 const char *long_desc,
5159 const char *short_desc,
5160 const char *long_desc,
5179 var->
min = minValue;
5180 var->
max = maxValue;
5189 const char *short_desc,
5190 const char *long_desc,
5209 var->
min = minValue;
5210 var->
max = maxValue;
5219 const char *short_desc,
5220 const char *long_desc,
5222 const char *bootValue,
5244 const char *short_desc,
5245 const char *long_desc,
5281 int classLen = strlen(className);
5298 strncmp(className, var->
name, classLen) == 0 &&
5302 (
errcode(ERRCODE_INVALID_NAME),
5303 errmsg(
"invalid configuration parameter name \"%s\", removing it",
5305 errdetail(
"\"%s\" is now a reserved prefix.",
5395 else if (lconf->
boot_val == NULL ||
5419 result[*num] = conf;
5446 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5447 errmsg(
"permission denied to examine \"%s\"",
name),
5448 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
5449 "pg_read_all_settings")));
5452 *varname = record->
name;
5530 snprintf(buffer,
sizeof(buffer),
"%g%s",
5586write_one_nondefault_variable(FILE *fp,
struct config_generic *gconf)
5650 fwrite(&gconf->
srole, 1,
sizeof(gconf->
srole), fp);
5672 errmsg(
"could not write to file \"%s\": %m",
5673 CONFIG_EXEC_PARAMS_NEW)));
5683 write_one_nondefault_variable(fp, gconf);
5690 errmsg(
"could not write to file \"%s\": %m",
5691 CONFIG_EXEC_PARAMS_NEW)));
5699 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5709read_string_with_null(FILE *fp)
5718 if ((ch = fgetc(fp)) == EOF)
5723 elog(
FATAL,
"invalid format of exec config params file");
5727 else if (
i == maxlen)
5741read_nondefault_variables(
void)
5759 if (errno != ENOENT)
5762 errmsg(
"could not read from file \"%s\": %m",
5763 CONFIG_EXEC_PARAMS)));
5769 if ((varname = read_string_with_null(fp)) == NULL)
5773 elog(
FATAL,
"failed to locate variable \"%s\" in exec config params file", varname);
5775 if ((varvalue = read_string_with_null(fp)) == NULL)
5776 elog(
FATAL,
"invalid format of exec config params file");
5777 if ((varsourcefile = read_string_with_null(fp)) == NULL)
5778 elog(
FATAL,
"invalid format of exec config params file");
5779 if (fread(&varsourceline, 1,
sizeof(varsourceline), fp) !=
sizeof(varsourceline))
5780 elog(
FATAL,
"invalid format of exec config params file");
5781 if (fread(&varsource, 1,
sizeof(varsource), fp) !=
sizeof(varsource))
5782 elog(
FATAL,
"invalid format of exec config params file");
5783 if (fread(&varscontext, 1,
sizeof(varscontext), fp) !=
sizeof(varscontext))
5784 elog(
FATAL,
"invalid format of exec config params file");
5785 if (fread(&varsrole, 1,
sizeof(varsrole), fp) !=
sizeof(varsrole))
5786 elog(
FATAL,
"invalid format of exec config params file");
5789 varscontext, varsource, varsrole,
5791 if (varsourcefile[0])
5985 elog(
ERROR,
"not enough space to serialize GUC state");
5994 elog(
ERROR,
"vsnprintf failed: %m with format string \"%s\"",
fmt);
5999 elog(
ERROR,
"not enough space to serialize GUC state");
6011 if (valsize > *maxbytes)
6012 elog(
ERROR,
"not enough space to serialize GUC state");
6014 memcpy(*destptr,
val, valsize);
6015 *destptr += valsize;
6016 *maxbytes -= valsize;
6040 (*conf->
variable ?
"true" :
"false"));
6093 sizeof(gconf->
srole));
6109 Assert(maxsize >
sizeof(actual_size));
6110 curptr = start_address +
sizeof(actual_size);
6111 bytes_left = maxsize -
sizeof(actual_size);
6123 actual_size = maxsize - bytes_left -
sizeof(actual_size);
6124 memcpy(start_address, &actual_size,
sizeof(actual_size));
6136 char *retptr = *srcptr;
6139 if (*srcptr >= srcend)
6143 for (ptr = *srcptr; ptr < srcend && *ptr !=
'\0'; ptr++)
6147 elog(
ERROR,
"could not find null terminator in GUC state");
6159 if (*srcptr +
size > srcend)
6173 char **error_context_name_and_value = (
char **)
arg;
6175 if (error_context_name_and_value)
6176 errcontext(
"while setting parameter \"%s\" to \"%s\"",
6177 error_context_name_and_value[0],
6178 error_context_name_and_value[1]);
6202 char *srcptr = (
char *) gucstate;
6304 memcpy(&
len, gucstate,
sizeof(
len));
6306 srcptr +=
sizeof(
len);
6307 srcend = srcptr +
len;
6312 error_context_callback.
arg = NULL;
6316 while (srcptr < srcend)
6319 char *error_context_name_and_value[2];
6324 if (varsourcefile[0])
6326 &varsourceline,
sizeof(varsourceline));
6330 &varsource,
sizeof(varsource));
6332 &varscontext,
sizeof(varscontext));
6334 &varsrole,
sizeof(varsrole));
6336 error_context_name_and_value[0] = varname;
6337 error_context_name_and_value[1] = varvalue;
6338 error_context_callback.
arg = &error_context_name_and_value[0];
6340 varscontext, varsource, varsrole,
6344 (
errcode(ERRCODE_INTERNAL_ERROR),
6345 errmsg(
"parameter \"%s\" could not be set", varname)));
6346 if (varsourcefile[0])
6348 error_context_callback.
arg = NULL;
6371 equal_pos = strcspn(
string,
"=");
6373 if (
string[equal_pos] ==
'=')
6387 for (cp = *
name; *cp; cp++)
6434 (
errcode(ERRCODE_SYNTAX_ERROR),
6435 errmsg(
"could not parse setting for parameter \"%s\"",
6465 forboth(lc1, gucNames, lc2, gucValues)
6538 if (strncmp(current,
newval, strlen(
name) + 1) == 0)
6670 eqsgn = strchr(
val,
'=');
6709 bool skipIfNoPermissions)
6749 if (skipIfNoPermissions)
6752 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
6753 errmsg(
"permission denied to set parameter \"%s\"",
name)));
6763 else if (skipIfNoPermissions)
6817 errmsg(
"invalid value for parameter \"%s\": %d",
6851 errmsg(
"invalid value for parameter \"%s\": %d",
6885 errmsg(
"invalid value for parameter \"%s\": %g",
6903 volatile bool result =
true;
6928 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
6969 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 Assert(condition)
#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)
void * hash_seq_search(HASH_SEQ_STATUS *status)
long hash_get_num_entries(HTAB *hashp)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
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 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 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, size_t sz)
static dlist_head guc_nondef_list
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 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)
#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)
bool config_enum_lookup_by_name(struct config_enum *record, const char *value, int *retval)
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 set_string_field(struct config_string *conf, char **field, char *newval)
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 int guc_var_compare(const void *a, const void *b)
static void reapply_stacked_values(struct config_generic *variable, struct config_string *pHolder, GucStack *stack, const char *curvalue, GucContext curscontext, GucSource cursource, Oid cursrole)
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)
static bool parse_and_validate_value(struct config_generic *record, const char *value, GucSource source, int elevel, union config_var_val *newval, void **newextra)
static bool call_string_check_hook(struct config_string *conf, char **newval, void **extra, GucSource source, int elevel)
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[]
bool SelectConfigFiles(const char *userDoption, const char *progname)
#define REALTYPE_PRECISION
char * config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
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)
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
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
static void static bool call_bool_check_hook(struct config_bool *conf, bool *newval, void **extra, GucSource source, int elevel)
char * ShowGUCOption(struct config_generic *record, bool use_units)
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)
static bool call_int_check_hook(struct config_int *conf, int *newval, void **extra, GucSource source, int elevel)
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 bool string_field_used(struct config_string *conf, char *strval)
static void set_guc_source(struct config_generic *gconf, GucSource newsource)
void TransformGUCArray(ArrayType *array, List **names, List **values)
static bool call_real_check_hook(struct config_real *conf, double *newval, void **extra, GucSource source, int elevel)
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)
void AtEOXact_GUC(bool isCommit, int nestLevel)
static bool call_enum_check_hook(struct config_enum *conf, int *newval, void **extra, GucSource source, int elevel)
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)
static bool reporting_enabled
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)
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
bool ConfigOptionIsVisible(struct config_generic *conf)
struct config_string ConfigureNamesString[]
struct config_int ConfigureNamesInt[]
struct config_bool ConfigureNamesBool[]
struct config_real ConfigureNamesReal[]
struct config_enum ConfigureNamesEnum[]
#define GUC_PENDING_RESTART
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)
static void const char * fmt
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 uint32 pg_rotate_left32(uint32 word, int n)
#define forboth(cell1, list1, cell2, list2)
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,...)
MemoryContextSwitchTo(old_ctx)
void truncate_identifier(char *ident, int len, bool warn)
Size add_size(Size s1, Size s2)
static pg_noinline void Size size
long 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
struct config_generic gen
GucBoolCheckHook check_hook
GucBoolAssignHook assign_hook
const struct config_enum_entry * options
GucEnumAssignHook assign_hook
struct config_generic gen
GucEnumCheckHook check_hook
GucContext reset_scontext
GucIntAssignHook assign_hook
GucIntCheckHook check_hook
struct config_generic gen
GucRealAssignHook assign_hook
struct config_generic gen
GucRealCheckHook check_hook
struct config_generic gen
GucStringCheckHook check_hook
GucStringAssignHook assign_hook
GucContext masked_scontext
char unit[MAX_UNIT_LEN+1]
bool IsInParallelMode(void)
bool RecoveryInProgress(void)
static void infile(const char *name)