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,
254 bool skipIfNoPermissions);
286 bool applying =
false;
287 const char *ConfFileWithError;
340 for (item = head; item; item = item->
next)
343 strcmp(item->
name,
"data_directory") == 0)
348 newlist->
next = NULL;
349 head = tail = newlist;
372 gconf->
status &= ~GUC_IS_IN_FILE;
388 for (item = head; item; item = item->
next)
414 for (pitem = head; pitem != item; pitem = pitem->
next)
417 strcmp(pitem->
name, item->
name) == 0)
428 (
errcode(ERRCODE_UNDEFINED_OBJECT),
429 errmsg(
"unrecognized configuration parameter \"%s\" in file \"%s\" line %d",
432 item->
errmsg =
pstrdup(
"unrecognized configuration parameter");
468 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
469 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
505 (
errmsg(
"parameter \"%s\" removed from configuration file, reset to default",
535 for (item = head; item; item = item->
next)
537 char *pre_value = NULL;
568 if (strcmp(pre_value, post_value) != 0)
570 (
errmsg(
"parameter \"%s\" changed to \"%s\"",
593 if (scres != 0 && applySettings)
606 if (
error && applySettings)
611 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
612 errmsg(
"configuration file \"%s\" contains errors",
613 ConfFileWithError)));
616 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
617 errmsg(
"configuration file \"%s\" contains errors; unaffected changes were applied",
618 ConfFileWithError)));
621 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
622 errmsg(
"configuration file \"%s\" contains errors; no changes were applied",
623 ConfFileWithError)));
647 (
errcode(ERRCODE_OUT_OF_MEMORY),
648 errmsg(
"out of memory")));
672 (
errcode(ERRCODE_OUT_OF_MEMORY),
673 errmsg(
"out of memory")));
681 size_t len = strlen(src) + 1;
734 char *oldval = *field;
795 void *oldval = *field;
831 &(
val->val.stringval),
859 &(
val->val.stringval),
891 qsort(result, *num_vars,
968 size_vars = num_vars + num_vars / 4;
970 hash_ctl.
keysize =
sizeof(
char *);
1060 (
errcode(ERRCODE_OUT_OF_MEMORY),
1061 errmsg(
"out of memory")));
1079 bool saw_sep =
false;
1080 bool name_start =
true;
1082 for (
const char *p =
name; *p; p++)
1091 else if (strchr(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1092 "abcdefghijklmnopqrstuvwxyz_", *p) != NULL ||
1098 else if (!name_start && strchr(
"0123456789$", *p) != NULL)
1129 size_t classLen = sep -
name;
1137 (
errcode(ERRCODE_INVALID_NAME),
1138 errmsg(
"invalid configuration parameter name \"%s\"",
1140 errdetail(
"Custom parameter names must be two or more simple identifiers separated by dots.")));
1146 const char *rcprefix =
lfirst(lc);
1148 if (strlen(rcprefix) == classLen &&
1149 strncmp(
name, rcprefix, classLen) == 0)
1153 (
errcode(ERRCODE_INVALID_NAME),
1154 errmsg(
"invalid configuration parameter name \"%s\"",
1156 errdetail(
"\"%s\" is a reserved prefix.",
1168 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1169 errmsg(
"unrecognized configuration parameter \"%s\"",
1208 var->
variable = (
char **) (var + 1);
1261 skip_errors, elevel);
1264 if (create_placeholders)
1278 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1279 errmsg(
"unrecognized configuration parameter \"%s\"",
1291 const char *namea = **(
const char **
const *)
a;
1292 const char *nameb = **(
const char **
const *)
b;
1308 while (*namea && *nameb)
1310 char cha = *namea++;
1311 char chb = *nameb++;
1313 if (cha >=
'A' && cha <=
'Z')
1315 if (chb >=
'A' && chb <=
'Z')
1334 const char *
name = *(
const char *
const *)
key;
1341 if (ch >=
'A' && ch <=
'Z')
1357 const char *name1 = *(
const char *
const *) key1;
1358 const char *name2 = *(
const char *
const *) key2;
1391 for (
char *ptr = result; *ptr !=
'\0'; ptr++)
1395 if (ch >=
'A' && ch <=
'Z')
1435#ifdef USE_ASSERT_CHECKING
1448 elog(
LOG,
"GUC (PGC_BOOL) %s, boot_val=%d, C-var=%d",
1460 elog(
LOG,
"GUC (PGC_INT) %s, boot_val=%d, C-var=%d",
1472 elog(
LOG,
"GUC (PGC_REAL) %s, boot_val=%g, C-var=%g",
1486 elog(
LOG,
"GUC (PGC_STRING) %s, boot_val=%s, C-var=%s",
1498 elog(
LOG,
"GUC (PGC_ENUM) %s, boot_val=%d, C-var=%d",
1515 elog(
LOG,
"GUC %s flags: NO_SHOW_ALL and !NOT_IN_SAMPLE",
1593 ssize_t stack_rlimit;
1595 env = getenv(
"PGPORT");
1599 env = getenv(
"PGDATESTYLE");
1603 env = getenv(
"PGCLIENTENCODING");
1615 if (stack_rlimit > 0)
1619 if (new_limit > 100)
1624 if (new_limit < 2048)
1631 snprintf(limbuf,
sizeof(limbuf),
"%d", (
int) new_limit);
1652 gconf->
srole = BOOTSTRAP_SUPERUSERID;
1654 gconf->
stack = NULL;
1655 gconf->
extra = NULL;
1670 elog(
FATAL,
"failed to initialize %s to %d",
1688 elog(
FATAL,
"failed to initialize %s to %d",
1706 elog(
FATAL,
"failed to initialize %s to %g",
1728 elog(
FATAL,
"failed to initialize %s to \"%s\"",
1744 elog(
FATAL,
"failed to initialize %s to %d",
1766 if (gconf->
stack != NULL)
1789 bool fname_is_malloced;
1790 struct stat stat_buf;
1799 if (configdir &&
stat(configdir, &stat_buf) != 0)
1801 write_stderr(
"%s: could not access directory \"%s\": %m\n",
1804 if (errno == ENOENT)
1805 write_stderr(
"Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
1818 fname_is_malloced =
true;
1825 fname_is_malloced =
false;
1829 write_stderr(
"%s does not know where to find the server configuration file.\n"
1830 "You must specify the --config-file or -D invocation "
1831 "option or set the PGDATA environment variable.\n",
1842 if (fname_is_malloced)
1852 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)
2130 gconf->
source = newsource;
2148 stack = gconf->
stack;
2210 if (gconf->
stack == NULL)
2212 gconf->
stack = stack;
2228 elog(
WARNING,
"GUC nest level = %d at transaction start",
2298 bool restorePrior =
false;
2299 bool restoreMasked =
false;
2309 restorePrior =
true;
2311 restorePrior =
true;
2316 restoreMasked =
true;
2323 restorePrior =
true;
2325 else if (prev == NULL ||
2384 if (restorePrior || restoreMasked)
2413 void *newextra = newvalue.
extra;
2431 void *newextra = newvalue.
extra;
2449 void *newextra = newvalue.
extra;
2467 void *newextra = newvalue.
extra;
2494 void *newextra = newvalue.
extra;
2519 gconf->
srole = newsrole;
2526 gconf->
stack = prev;
2627 conf->
status &= ~GUC_NEEDS_REPORT;
2677 int base_unit,
double *base_value)
2686 while (*unit !=
'\0' && !isspace((
unsigned char) *unit) &&
2688 unitstr[unitlen++] = *(unit++);
2689 unitstr[unitlen] =
'\0';
2691 while (isspace((
unsigned char) *unit))
2704 if (base_unit ==
table[
i].base_unit &&
2705 strcmp(unitstr,
table[
i].unit) == 0)
2714 if (*
table[
i + 1].unit &&
2715 base_unit ==
table[
i + 1].base_unit)
2716 cvalue = rint(cvalue /
table[
i + 1].multiplier) *
2719 *base_value = cvalue;
2749 if (base_unit ==
table[
i].base_unit)
2756 if (
table[
i].multiplier <= 1.0 ||
2777 double *
value,
const char **unit)
2791 if (base_unit ==
table[
i].base_unit)
2833 static char bbuf[8];
2836 if (bbuf[0] ==
'\0')
2837 snprintf(bbuf,
sizeof(bbuf),
"%dkB", BLCKSZ / 1024);
2842 static char xbuf[8];
2845 if (xbuf[0] ==
'\0')
2846 snprintf(xbuf,
sizeof(xbuf),
"%dkB", XLOG_BLCKSZ / 1024);
2856 elog(
ERROR,
"unrecognized GUC units value: %d",
2900 if (*endptr ==
'.' || *endptr ==
'e' || *endptr ==
'E' ||
2907 if (endptr ==
value || errno == ERANGE)
2915 while (isspace((
unsigned char) *endptr))
2919 if (*endptr !=
'\0')
2943 if (
val > INT_MAX ||
val < INT_MIN)
2946 *hintmsg =
gettext_noop(
"Value exceeds integer range.");
2951 *result = (int)
val;
2980 if (endptr ==
value || errno == ERANGE)
2988 while (isspace((
unsigned char) *endptr))
2992 if (*endptr !=
'\0')
3032 for (entry = record->
options; entry && entry->
name; entry++)
3038 elog(
ERROR,
"could not find enum option %d for %s",
3056 for (entry = record->
options; entry && entry->
name; entry++)
3060 *retval = entry->
val;
3078 const char *suffix,
const char *
separator)
3088 for (entry = record->
options; entry && entry->
name; entry++)
3104 if (retstr.
len >= seplen)
3107 retstr.
data[retstr.
len - seplen] =
'\0';
3108 retstr.
len -= seplen;
3148 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3149 errmsg(
"parameter \"%s\" requires a Boolean value",
3162 const char *hintmsg;
3168 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3169 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3171 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3178 const char *unitspace;
3183 unit = unitspace =
"";
3186 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3187 errmsg(
"%d%s%s is outside the valid range for parameter \"%s\" (%d%s%s .. %d%s%s)",
3188 newval->intval, unitspace, unit,
3190 conf->
min, unitspace, unit,
3191 conf->
max, unitspace, unit)));
3203 const char *hintmsg;
3209 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3210 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3212 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3219 const char *unitspace;
3224 unit = unitspace =
"";
3227 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3228 errmsg(
"%g%s%s is outside the valid range for parameter \"%s\" (%g%s%s .. %g%s%s)",
3229 newval->realval, unitspace, unit,
3231 conf->
min, unitspace, unit,
3232 conf->
max, unitspace, unit)));
3250 if (
newval->stringval == NULL)
3259 strlen(
newval->stringval),
3266 newval->stringval = NULL;
3280 "Available values: ",
3284 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3285 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3287 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3363 srole = BOOTSTRAP_SUPERUSERID;
3367 action, changeVal, elevel,
3394 action, changeVal, elevel,
3418 void *newextra = NULL;
3419 bool prohibitValueChange =
false;
3466 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3467 errmsg(
"parameter \"%s\" cannot be set during a parallel operation",
3482 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3483 errmsg(
"parameter \"%s\" cannot be changed",
3500 prohibitValueChange =
true;
3505 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3506 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3515 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3516 errmsg(
"parameter \"%s\" cannot be changed now",
3542 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3543 errmsg(
"permission denied to set parameter \"%s\"",
3584 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3585 errmsg(
"parameter \"%s\" cannot be set after connection start",
3604 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3605 errmsg(
"permission denied to set parameter \"%s\"",
3643 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3644 errmsg(
"cannot set parameter \"%s\" within security-definer function",
3651 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3652 errmsg(
"cannot set parameter \"%s\" within security-restricted operation",
3664 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3665 errmsg(
"parameter \"%s\" cannot be reset", record->
name)));
3671 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3672 errmsg(
"parameter \"%s\" cannot be set locally in functions",
3696 if (changeVal && !makeDefault)
3698 elog(
DEBUG3,
"\"%s\": setting ignored because previous source is higher priority",
3714#define newval (newval_union.boolval)
3720 &newval_union, &newextra))
3739 if (prohibitValueChange)
3749 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3750 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3754 record->
status &= ~GUC_PENDING_RESTART;
3786 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3795 stack->
srole = srole;
3812#define newval (newval_union.intval)
3818 &newval_union, &newextra))
3837 if (prohibitValueChange)
3847 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3848 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3852 record->
status &= ~GUC_PENDING_RESTART;
3884 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3893 stack->
srole = srole;
3910#define newval (newval_union.realval)
3916 &newval_union, &newextra))
3935 if (prohibitValueChange)
3945 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3946 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3950 record->
status &= ~GUC_PENDING_RESTART;
3982 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3991 stack->
srole = srole;
4009 Oid orig_srole = srole;
4011#define newval (newval_union.stringval)
4017 &newval_union, &newextra))
4052 if (prohibitValueChange)
4054 bool newval_different;
4057 newval_different = (*conf->
variable == NULL ||
4068 if (newval_different)
4072 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4073 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4077 record->
status &= ~GUC_PENDING_RESTART;
4121 strcmp(conf->
gen.
name,
"session_authorization") == 0)
4123 value ?
"none" : NULL,
4148 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
4158 stack->
srole = srole;
4178#define newval (newval_union.enumval)
4184 &newval_union, &newextra))
4203 if (prohibitValueChange)
4213 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4214 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4218 record->
status &= ~GUC_PENDING_RESTART;
4250 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
4259 stack->
srole = srole;
4280 return changeVal ? 1 : -1;
4363 static char buffer[256];
4368 if (restrict_privileged &&
4371 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4372 errmsg(
"permission denied to examine \"%s\"",
name),
4373 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4374 "pg_read_all_settings")));
4379 return *((
struct config_bool *) record)->variable ?
"on" :
"off";
4382 snprintf(buffer,
sizeof(buffer),
"%d",
4387 snprintf(buffer,
sizeof(buffer),
"%g",
4413 static char buffer[256];
4419 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4420 errmsg(
"permission denied to examine \"%s\"",
name),
4421 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4422 "pg_read_all_settings")));
4427 return ((
struct config_bool *) record)->reset_val ?
"on" :
"off";
4430 snprintf(buffer,
sizeof(buffer),
"%d",
4435 snprintf(buffer,
sizeof(buffer),
"%g",
4464 return record->
flags;
4497 for (item = head; item != NULL; item = item->
next)
4509 (
errcode(ERRCODE_OUT_OF_MEMORY),
4510 errmsg(
"out of memory")));
4554 for (item = *head_p; item != NULL; item =
next)
4581 item =
palloc(
sizeof *item);
4591 if (*head_p == NULL)
4594 (*tail_p)->
next = item;
4616 bool resetall =
false;
4630 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4631 errmsg(
"ALTER SYSTEM is not allowed in this environment")));
4650 elog(
ERROR,
"unrecognized alter system stmt type: %d",
4662 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4663 errmsg(
"permission denied to perform ALTER SYSTEM RESET ALL")));
4672 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4673 errmsg(
"permission denied to set parameter \"%s\"",
4697 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4698 errmsg(
"parameter \"%s\" cannot be changed",
4707 void *newextra = NULL;
4713 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4714 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
4746 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4747 errmsg(
"parameter value for ALTER SYSTEM must not contain a newline")));
4754 snprintf(AutoConfFileName,
sizeof(AutoConfFileName),
"%s",
4756 snprintf(AutoConfTmpFileName,
sizeof(AutoConfTmpFileName),
"%s.%s",
4775 if (
stat(AutoConfFileName, &st) == 0)
4784 errmsg(
"could not open file \"%s\": %m",
4785 AutoConfFileName)));
4791 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
4792 errmsg(
"could not parse contents of file \"%s\"",
4793 AutoConfFileName)));
4830 O_CREAT | O_RDWR | O_TRUNC);
4834 errmsg(
"could not open file \"%s\": %m",
4835 AutoConfTmpFileName)));
4864 (void) unlink(AutoConfTmpFileName);
4900 elog(
FATAL,
"cannot create PGC_POSTMASTER variables after startup");
4909 elog(
FATAL,
"extensions cannot define GUC_LIST_QUOTE variables");
4918 (strcmp(
name,
"pljava.classpath") == 0 ||
4919 strcmp(
name,
"pljava.vmoptions") == 0))
4974 (
errcode(ERRCODE_INTERNAL_ERROR),
4975 errmsg(
"attempt to redefine parameter \"%s\"",
name)));
5046 const char *curvalue,
5061 switch (stack->
state)
5065 curscontext, cursource, cursrole,
5072 curscontext, cursource, cursrole,
5079 curscontext, cursource, cursrole,
5094 curscontext, cursource, cursrole,
5101 if (
variable->stack != oldvarstack)
5120 curscontext, cursource, cursrole,
5155 const char *short_desc,
5156 const char *long_desc,
5181 const char *short_desc,
5182 const char *long_desc,
5201 var->
min = minValue;
5202 var->
max = maxValue;
5211 const char *short_desc,
5212 const char *long_desc,
5231 var->
min = minValue;
5232 var->
max = maxValue;
5241 const char *short_desc,
5242 const char *long_desc,
5244 const char *bootValue,
5266 const char *short_desc,
5267 const char *long_desc,
5303 int classLen = strlen(className);
5318 strncmp(className, var->
name, classLen) == 0 &&
5322 (
errcode(ERRCODE_INVALID_NAME),
5323 errmsg(
"invalid configuration parameter name \"%s\", removing it",
5325 errdetail(
"\"%s\" is now a reserved prefix.",
5417 else if (lconf->
boot_val == NULL ||
5441 result[*num] = conf;
5468 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5469 errmsg(
"permission denied to examine \"%s\"",
name),
5470 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
5471 "pg_read_all_settings")));
5474 *varname = record->
name;
5552 snprintf(buffer,
sizeof(buffer),
"%g%s",
5608write_one_nondefault_variable(FILE *fp,
struct config_generic *gconf)
5672 fwrite(&gconf->
srole, 1,
sizeof(gconf->
srole), fp);
5676write_nondefault_variables(
GucContext context)
5694 errmsg(
"could not write to file \"%s\": %m",
5695 CONFIG_EXEC_PARAMS_NEW)));
5705 write_one_nondefault_variable(fp, gconf);
5712 errmsg(
"could not write to file \"%s\": %m",
5713 CONFIG_EXEC_PARAMS_NEW)));
5721 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5731read_string_with_null(FILE *fp)
5740 if ((ch = fgetc(fp)) == EOF)
5745 elog(
FATAL,
"invalid format of exec config params file");
5749 else if (
i == maxlen)
5763read_nondefault_variables(
void)
5781 if (errno != ENOENT)
5784 errmsg(
"could not read from file \"%s\": %m",
5785 CONFIG_EXEC_PARAMS)));
5791 if ((varname = read_string_with_null(fp)) == NULL)
5795 elog(
FATAL,
"failed to locate variable \"%s\" in exec config params file", varname);
5797 if ((varvalue = read_string_with_null(fp)) == NULL)
5798 elog(
FATAL,
"invalid format of exec config params file");
5799 if ((varsourcefile = read_string_with_null(fp)) == NULL)
5800 elog(
FATAL,
"invalid format of exec config params file");
5801 if (fread(&varsourceline, 1,
sizeof(varsourceline), fp) !=
sizeof(varsourceline))
5802 elog(
FATAL,
"invalid format of exec config params file");
5803 if (fread(&varsource, 1,
sizeof(varsource), fp) !=
sizeof(varsource))
5804 elog(
FATAL,
"invalid format of exec config params file");
5805 if (fread(&varscontext, 1,
sizeof(varscontext), fp) !=
sizeof(varscontext))
5806 elog(
FATAL,
"invalid format of exec config params file");
5807 if (fread(&varsrole, 1,
sizeof(varsrole), fp) !=
sizeof(varsrole))
5808 elog(
FATAL,
"invalid format of exec config params file");
5811 varscontext, varsource, varsrole,
5813 if (varsourcefile[0])
5880 size = strlen(gconf->
name) + 1;
5946 size =
add_size(size, valsize + 1);
5976 size =
sizeof(
Size);
6007 elog(
ERROR,
"not enough space to serialize GUC state");
6009 va_start(vargs, fmt);
6010 n =
vsnprintf(*destptr, *maxbytes, fmt, vargs);
6016 elog(
ERROR,
"vsnprintf failed: %m with format string \"%s\"", fmt);
6021 elog(
ERROR,
"not enough space to serialize GUC state");
6033 if (valsize > *maxbytes)
6034 elog(
ERROR,
"not enough space to serialize GUC state");
6036 memcpy(*destptr,
val, valsize);
6037 *destptr += valsize;
6038 *maxbytes -= valsize;
6062 (*conf->
variable ?
"true" :
"false"));
6115 sizeof(gconf->
srole));
6131 Assert(maxsize >
sizeof(actual_size));
6132 curptr = start_address +
sizeof(actual_size);
6133 bytes_left = maxsize -
sizeof(actual_size);
6145 actual_size = maxsize - bytes_left -
sizeof(actual_size);
6146 memcpy(start_address, &actual_size,
sizeof(actual_size));
6158 char *retptr = *srcptr;
6161 if (*srcptr >= srcend)
6165 for (ptr = *srcptr; ptr < srcend && *ptr !=
'\0'; ptr++)
6169 elog(
ERROR,
"could not find null terminator in GUC state");
6181 if (*srcptr + size > srcend)
6184 memcpy(
dest, *srcptr, size);
6195 char **error_context_name_and_value = (
char **)
arg;
6197 if (error_context_name_and_value)
6198 errcontext(
"while setting parameter \"%s\" to \"%s\"",
6199 error_context_name_and_value[0],
6200 error_context_name_and_value[1]);
6224 char *srcptr = (
char *) gucstate;
6326 memcpy(&
len, gucstate,
sizeof(
len));
6328 srcptr +=
sizeof(
len);
6329 srcend = srcptr +
len;
6334 error_context_callback.
arg = NULL;
6338 while (srcptr < srcend)
6341 char *error_context_name_and_value[2];
6346 if (varsourcefile[0])
6348 &varsourceline,
sizeof(varsourceline));
6352 &varsource,
sizeof(varsource));
6354 &varscontext,
sizeof(varscontext));
6356 &varsrole,
sizeof(varsrole));
6358 error_context_name_and_value[0] = varname;
6359 error_context_name_and_value[1] = varvalue;
6360 error_context_callback.
arg = &error_context_name_and_value[0];
6362 varscontext, varsource, varsrole,
6366 (
errcode(ERRCODE_INTERNAL_ERROR),
6367 errmsg(
"parameter \"%s\" could not be set", varname)));
6368 if (varsourcefile[0])
6370 error_context_callback.
arg = NULL;
6393 equal_pos = strcspn(
string,
"=");
6395 if (
string[equal_pos] ==
'=')
6409 for (cp = *
name; *cp; cp++)
6456 (
errcode(ERRCODE_SYNTAX_ERROR),
6457 errmsg(
"could not parse setting for parameter \"%s\"",
6487 forboth(lc1, gucNames, lc2, gucValues)
6560 if (strncmp(current,
newval, strlen(
name) + 1) == 0)
6692 eqsgn = strchr(
val,
'=');
6731 bool skipIfNoPermissions)
6762 if (!gconf && !reset_custom)
6777 if (skipIfNoPermissions)
6780 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
6781 errmsg(
"permission denied to set parameter \"%s\"",
name)));
6791 else if (skipIfNoPermissions)
6845 errmsg(
"invalid value for parameter \"%s\": %d",
6879 errmsg(
"invalid value for parameter \"%s\": %d",
6913 errmsg(
"invalid value for parameter \"%s\": %g",
6931 volatile bool result =
true;
6956 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
6997 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 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)
static void free_placeholder(struct config_string *pHolder)
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)
PGDLLIMPORT struct config_int ConfigureNamesInt[]
PGDLLIMPORT struct config_real ConfigureNamesReal[]
PGDLLIMPORT struct config_string ConfigureNamesString[]
PGDLLIMPORT struct config_enum ConfigureNamesEnum[]
PGDLLIMPORT struct config_bool ConfigureNamesBool[]
#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
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
bool IsInParallelMode(void)
bool RecoveryInProgress(void)
static void infile(const char *name)