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"
104 #define MAX_UNIT_LEN 3
115 #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
116 #error BLCKSZ must be between 1KB and 1MB
118 #if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024)
119 #error XLOG_BLCKSZ must be between 1KB and 1MB
150 {
"TB",
GUC_UNIT_XBLOCKS, (1024.0 * 1024.0 * 1024.0) / (XLOG_BLCKSZ / 1024)},
194 "sort_mem",
"work_mem",
195 "vacuum_mem",
"maintenance_work_mem",
251 const char *curvalue,
255 bool skipIfNoPermissions);
287 bool applying =
false;
288 const char *ConfFileWithError;
341 for (item = head; item; item = item->
next)
344 strcmp(item->
name,
"data_directory") == 0)
349 newlist->
next = NULL;
350 head = tail = newlist;
389 for (item = head; item; item = item->
next)
415 for (pitem = head; pitem != item; pitem = pitem->
next)
418 strcmp(pitem->
name, item->
name) == 0)
429 (
errcode(ERRCODE_UNDEFINED_OBJECT),
430 errmsg(
"unrecognized configuration parameter \"%s\" in file \"%s\" line %d",
433 item->
errmsg =
pstrdup(
"unrecognized configuration parameter");
469 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
470 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
506 (
errmsg(
"parameter \"%s\" removed from configuration file, reset to default",
536 for (item = head; item; item = item->
next)
538 char *pre_value = NULL;
569 if (strcmp(pre_value, post_value) != 0)
571 (
errmsg(
"parameter \"%s\" changed to \"%s\"",
594 if (scres != 0 && applySettings)
607 if (
error && applySettings)
612 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
613 errmsg(
"configuration file \"%s\" contains errors",
614 ConfFileWithError)));
617 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
618 errmsg(
"configuration file \"%s\" contains errors; unaffected changes were applied",
619 ConfFileWithError)));
622 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
623 errmsg(
"configuration file \"%s\" contains errors; no changes were applied",
624 ConfFileWithError)));
648 (
errcode(ERRCODE_OUT_OF_MEMORY),
649 errmsg(
"out of memory")));
673 (
errcode(ERRCODE_OUT_OF_MEMORY),
674 errmsg(
"out of memory")));
682 size_t len = strlen(src) + 1;
735 char *oldval = *field;
796 void *oldval = *field;
832 &(
val->val.stringval),
860 &(
val->val.stringval),
892 qsort(result, *num_vars,
969 size_vars = num_vars + num_vars / 4;
971 hash_ctl.
keysize =
sizeof(
char *);
1061 (
errcode(ERRCODE_OUT_OF_MEMORY),
1062 errmsg(
"out of memory")));
1080 bool saw_sep =
false;
1081 bool name_start =
true;
1083 for (
const char *p =
name; *p; p++)
1092 else if (strchr(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1093 "abcdefghijklmnopqrstuvwxyz_", *p) != NULL ||
1099 else if (!name_start && strchr(
"0123456789$", *p) != NULL)
1130 size_t classLen = sep -
name;
1138 (
errcode(ERRCODE_INVALID_NAME),
1139 errmsg(
"invalid configuration parameter name \"%s\"",
1141 errdetail(
"Custom parameter names must be two or more simple identifiers separated by dots.")));
1147 const char *rcprefix =
lfirst(lc);
1149 if (strlen(rcprefix) == classLen &&
1150 strncmp(
name, rcprefix, classLen) == 0)
1154 (
errcode(ERRCODE_INVALID_NAME),
1155 errmsg(
"invalid configuration parameter name \"%s\"",
1157 errdetail(
"\"%s\" is a reserved prefix.",
1169 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1170 errmsg(
"unrecognized configuration parameter \"%s\"",
1209 var->
variable = (
char **) (var + 1);
1262 skip_errors, elevel);
1265 if (create_placeholders)
1279 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1280 errmsg(
"unrecognized configuration parameter \"%s\"",
1309 while (*namea && *nameb)
1311 char cha = *namea++;
1312 char chb = *nameb++;
1314 if (cha >=
'A' && cha <=
'Z')
1316 if (chb >=
'A' && chb <=
'Z')
1335 const char *
name = *(
const char *
const *)
key;
1342 if (ch >=
'A' && ch <=
'Z')
1358 const char *name1 = *(
const char *
const *) key1;
1359 const char *name2 = *(
const char *
const *) key2;
1392 for (
char *ptr = result; *ptr !=
'\0'; ptr++)
1396 if (ch >=
'A' && ch <=
'Z')
1436 #ifdef USE_ASSERT_CHECKING
1449 elog(
LOG,
"GUC (PGC_BOOL) %s, boot_val=%d, C-var=%d",
1461 elog(
LOG,
"GUC (PGC_INT) %s, boot_val=%d, C-var=%d",
1473 elog(
LOG,
"GUC (PGC_REAL) %s, boot_val=%g, C-var=%g",
1487 elog(
LOG,
"GUC (PGC_STRING) %s, boot_val=%s, C-var=%s",
1499 elog(
LOG,
"GUC (PGC_ENUM) %s, boot_val=%d, C-var=%d",
1516 elog(
LOG,
"GUC %s flags: NO_SHOW_ALL and !NOT_IN_SAMPLE",
1596 env = getenv(
"PGPORT");
1600 env = getenv(
"PGDATESTYLE");
1604 env = getenv(
"PGCLIENTENCODING");
1616 if (stack_rlimit > 0)
1620 if (new_limit > 100)
1625 if (new_limit < 2048)
1632 snprintf(limbuf,
sizeof(limbuf),
"%ld", new_limit);
1653 gconf->
srole = BOOTSTRAP_SUPERUSERID;
1655 gconf->
stack = NULL;
1656 gconf->
extra = NULL;
1671 elog(
FATAL,
"failed to initialize %s to %d",
1689 elog(
FATAL,
"failed to initialize %s to %d",
1707 elog(
FATAL,
"failed to initialize %s to %g",
1729 elog(
FATAL,
"failed to initialize %s to \"%s\"",
1745 elog(
FATAL,
"failed to initialize %s to %d",
1767 if (gconf->
stack != NULL)
1790 bool fname_is_malloced;
1791 struct stat stat_buf;
1800 if (configdir &&
stat(configdir, &stat_buf) != 0)
1802 write_stderr(
"%s: could not access directory \"%s\": %m\n",
1805 if (errno == ENOENT)
1806 write_stderr(
"Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
1819 fname_is_malloced =
true;
1826 fname_is_malloced =
false;
1830 write_stderr(
"%s does not know where to find the server configuration file.\n"
1831 "You must specify the --config-file or -D invocation "
1832 "option or set the PGDATA environment variable.\n",
1843 if (fname_is_malloced)
1853 write_stderr(
"%s: could not access the server configuration file \"%s\": %m\n",
1881 write_stderr(
"%s does not know where to find the database system data.\n"
1882 "This can be specified as data_directory in \"%s\", "
1883 "or by the -D invocation option, or by the "
1884 "PGDATA environment variable.\n",
1922 fname_is_malloced =
true;
1929 fname_is_malloced =
false;
1933 write_stderr(
"%s does not know where to find the \"hba\" configuration file.\n"
1934 "This can be specified as \"hba_file\" in \"%s\", "
1935 "or by the -D invocation option, or by the "
1936 "PGDATA environment variable.\n",
1942 if (fname_is_malloced)
1953 fname_is_malloced =
true;
1960 fname_is_malloced =
false;
1964 write_stderr(
"%s does not know where to find the \"ident\" configuration file.\n"
1965 "This can be specified as \"ident_file\" in \"%s\", "
1966 "or by the -D invocation option, or by the "
1967 "PGDATA environment variable.\n",
1973 if (fname_is_malloced)
2127 gconf->
source = newsource;
2145 stack = gconf->
stack;
2207 if (gconf->
stack == NULL)
2209 gconf->
stack = stack;
2225 elog(
WARNING,
"GUC nest level = %d at transaction start",
2295 bool restorePrior =
false;
2296 bool restoreMasked =
false;
2306 restorePrior =
true;
2308 restorePrior =
true;
2313 restoreMasked =
true;
2320 restorePrior =
true;
2322 else if (prev == NULL ||
2381 if (restorePrior || restoreMasked)
2410 void *newextra = newvalue.
extra;
2428 void *newextra = newvalue.
extra;
2446 void *newextra = newvalue.
extra;
2464 void *newextra = newvalue.
extra;
2491 void *newextra = newvalue.
extra;
2516 gconf->
srole = newsrole;
2523 gconf->
stack = prev;
2674 int base_unit,
double *base_value)
2683 while (*unit !=
'\0' && !isspace((
unsigned char) *unit) &&
2685 unitstr[unitlen++] = *(unit++);
2686 unitstr[unitlen] =
'\0';
2688 while (isspace((
unsigned char) *unit))
2699 for (
i = 0; *table[
i].
unit;
i++)
2701 if (base_unit == table[
i].base_unit &&
2702 strcmp(unitstr, table[
i].unit) == 0)
2711 if (*table[
i + 1].unit &&
2712 base_unit == table[
i + 1].base_unit)
2713 cvalue = rint(cvalue / table[
i + 1].multiplier) *
2716 *base_value = cvalue;
2732 int64 *
value,
const char **unit)
2744 for (
i = 0; *table[
i].
unit;
i++)
2746 if (base_unit == table[
i].base_unit)
2753 if (table[
i].multiplier <= 1.0 ||
2754 base_value % (int64) table[
i].multiplier == 0)
2756 *
value = (int64) rint(base_value / table[
i].multiplier);
2757 *unit = table[
i].
unit;
2774 double *
value,
const char **unit)
2786 for (
i = 0; *table[
i].
unit;
i++)
2788 if (base_unit == table[
i].base_unit)
2801 *unit = table[
i].
unit;
2830 static char bbuf[8];
2833 if (bbuf[0] ==
'\0')
2834 snprintf(bbuf,
sizeof(bbuf),
"%dkB", BLCKSZ / 1024);
2839 static char xbuf[8];
2842 if (xbuf[0] ==
'\0')
2843 snprintf(xbuf,
sizeof(xbuf),
"%dkB", XLOG_BLCKSZ / 1024);
2853 elog(
ERROR,
"unrecognized GUC units value: %d",
2897 if (*endptr ==
'.' || *endptr ==
'e' || *endptr ==
'E' ||
2904 if (endptr ==
value || errno == ERANGE)
2912 while (isspace((
unsigned char) *endptr))
2916 if (*endptr !=
'\0')
2940 if (
val > INT_MAX ||
val < INT_MIN)
2943 *hintmsg =
gettext_noop(
"Value exceeds integer range.");
2948 *result = (int)
val;
2977 if (endptr ==
value || errno == ERANGE)
2985 while (isspace((
unsigned char) *endptr))
2989 if (*endptr !=
'\0')
3029 for (entry = record->
options; entry && entry->
name; entry++)
3035 elog(
ERROR,
"could not find enum option %d for %s",
3053 for (entry = record->
options; entry && entry->
name; entry++)
3057 *retval = entry->
val;
3075 const char *suffix,
const char *
separator)
3085 for (entry = record->
options; entry && entry->
name; entry++)
3101 if (retstr.
len >= seplen)
3104 retstr.
data[retstr.
len - seplen] =
'\0';
3105 retstr.
len -= seplen;
3146 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3147 errmsg(
"parameter \"%s\" requires a Boolean value",
3160 const char *hintmsg;
3166 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3167 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3169 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3178 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3179 errmsg(
"%d%s%s is outside the valid range for parameter \"%s\" (%d .. %d)",
3196 const char *hintmsg;
3202 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3203 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3205 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3214 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3215 errmsg(
"%g%s%s is outside the valid range for parameter \"%s\" (%g .. %g)",
3238 if (
newval->stringval == NULL)
3247 strlen(
newval->stringval),
3254 newval->stringval = NULL;
3268 "Available values: ",
3272 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3273 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
3275 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0));
3349 srole = BOOTSTRAP_SUPERUSERID;
3353 action, changeVal, elevel,
3380 action, changeVal, elevel,
3401 void *newextra = NULL;
3402 bool prohibitValueChange =
false;
3436 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3437 errmsg(
"cannot set parameters during a parallel operation")));
3461 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3462 errmsg(
"parameter \"%s\" cannot be changed",
3479 prohibitValueChange =
true;
3484 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3485 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3494 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3495 errmsg(
"parameter \"%s\" cannot be changed now",
3521 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3522 errmsg(
"permission denied to set parameter \"%s\"",
3563 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3564 errmsg(
"parameter \"%s\" cannot be set after connection start",
3583 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3584 errmsg(
"permission denied to set parameter \"%s\"",
3622 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3623 errmsg(
"cannot set parameter \"%s\" within security-definer function",
3630 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3631 errmsg(
"cannot set parameter \"%s\" within security-restricted operation",
3643 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3644 errmsg(
"parameter \"%s\" cannot be reset",
name)));
3650 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3651 errmsg(
"parameter \"%s\" cannot be set locally in functions",
3675 if (changeVal && !makeDefault)
3677 elog(
DEBUG3,
"\"%s\": setting ignored because previous source is higher priority",
3693 #define newval (newval_union.boolval)
3699 &newval_union, &newextra))
3718 if (prohibitValueChange)
3728 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3729 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3765 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3774 stack->
srole = srole;
3791 #define newval (newval_union.intval)
3797 &newval_union, &newextra))
3816 if (prohibitValueChange)
3826 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3827 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3863 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3872 stack->
srole = srole;
3889 #define newval (newval_union.realval)
3895 &newval_union, &newextra))
3914 if (prohibitValueChange)
3924 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
3925 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
3961 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
3970 stack->
srole = srole;
3987 #define newval (newval_union.stringval)
3993 &newval_union, &newextra))
4028 if (prohibitValueChange)
4030 bool newval_different;
4033 newval_different = (*conf->
variable == NULL ||
4044 if (newval_different)
4048 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4049 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4086 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
4096 stack->
srole = srole;
4116 #define newval (newval_union.enumval)
4122 &newval_union, &newextra))
4141 if (prohibitValueChange)
4151 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4152 errmsg(
"parameter \"%s\" cannot be changed without restarting the server",
4188 for (stack = conf->
gen.
stack; stack; stack = stack->
prev)
4197 stack->
srole = srole;
4218 return changeVal ? 1 : -1;
4301 static char buffer[256];
4306 if (restrict_privileged &&
4309 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4310 errmsg(
"permission denied to examine \"%s\"",
name),
4311 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4312 "pg_read_all_settings")));
4317 return *((
struct config_bool *) record)->variable ?
"on" :
"off";
4320 snprintf(buffer,
sizeof(buffer),
"%d",
4325 snprintf(buffer,
sizeof(buffer),
"%g",
4351 static char buffer[256];
4357 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4358 errmsg(
"permission denied to examine \"%s\"",
name),
4359 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
4360 "pg_read_all_settings")));
4365 return ((
struct config_bool *) record)->reset_val ?
"on" :
"off";
4368 snprintf(buffer,
sizeof(buffer),
"%d",
4373 snprintf(buffer,
sizeof(buffer),
"%g",
4402 return record->
flags;
4435 for (item = head; item != NULL; item = item->
next)
4447 (
errcode(ERRCODE_OUT_OF_MEMORY),
4448 errmsg(
"out of memory")));
4492 for (item = *head_p; item != NULL; item =
next)
4519 item =
palloc(
sizeof *item);
4529 if (*head_p == NULL)
4532 (*tail_p)->
next = item;
4554 bool resetall =
false;
4583 elog(
ERROR,
"unrecognized alter system stmt type: %d",
4595 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4596 errmsg(
"permission denied to perform ALTER SYSTEM RESET ALL")));
4605 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
4606 errmsg(
"permission denied to set parameter \"%s\"",
4630 (
errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
4631 errmsg(
"parameter \"%s\" cannot be changed",
4640 void *newextra = NULL;
4646 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4647 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
4674 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4675 errmsg(
"parameter value for ALTER SYSTEM must not contain a newline")));
4682 snprintf(AutoConfFileName,
sizeof(AutoConfFileName),
"%s",
4684 snprintf(AutoConfTmpFileName,
sizeof(AutoConfTmpFileName),
"%s.%s",
4703 if (
stat(AutoConfFileName, &st) == 0)
4712 errmsg(
"could not open file \"%s\": %m",
4713 AutoConfFileName)));
4719 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
4720 errmsg(
"could not parse contents of file \"%s\"",
4721 AutoConfFileName)));
4758 O_CREAT | O_RDWR | O_TRUNC);
4762 errmsg(
"could not open file \"%s\": %m",
4763 AutoConfTmpFileName)));
4792 (void) unlink(AutoConfTmpFileName);
4828 elog(
FATAL,
"cannot create PGC_POSTMASTER variables after startup");
4837 elog(
FATAL,
"extensions cannot define GUC_LIST_QUOTE variables");
4846 (strcmp(
name,
"pljava.classpath") == 0 ||
4847 strcmp(
name,
"pljava.vmoptions") == 0))
4901 (
errcode(ERRCODE_INTERNAL_ERROR),
4902 errmsg(
"attempt to redefine parameter \"%s\"",
name)));
4981 const char *curvalue,
4996 switch (stack->
state)
5000 curscontext, cursource, cursrole,
5007 curscontext, cursource, cursrole,
5014 curscontext, cursource, cursrole,
5029 curscontext, cursource, cursrole,
5036 if (
variable->stack != oldvarstack)
5055 curscontext, cursource, cursrole,
5071 const char *short_desc,
5072 const char *long_desc,
5097 const char *short_desc,
5098 const char *long_desc,
5117 var->
min = minValue;
5118 var->
max = maxValue;
5127 const char *short_desc,
5128 const char *long_desc,
5147 var->
min = minValue;
5148 var->
max = maxValue;
5157 const char *short_desc,
5158 const char *long_desc,
5160 const char *bootValue,
5182 const char *short_desc,
5183 const char *long_desc,
5219 int classLen = strlen(className);
5236 strncmp(className, var->
name, classLen) == 0 &&
5240 (
errcode(ERRCODE_INVALID_NAME),
5241 errmsg(
"invalid configuration parameter name \"%s\", removing it",
5243 errdetail(
"\"%s\" is now a reserved prefix.",
5333 else if (lconf->
boot_val == NULL ||
5357 result[*num] = conf;
5384 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
5385 errmsg(
"permission denied to examine \"%s\"",
name),
5386 errdetail(
"Only roles with privileges of the \"%s\" role may examine this parameter.",
5387 "pg_read_all_settings")));
5390 *varname = record->
name;
5468 snprintf(buffer,
sizeof(buffer),
"%g%s",
5524 write_one_nondefault_variable(FILE *fp,
struct config_generic *gconf)
5588 fwrite(&gconf->
srole, 1,
sizeof(gconf->
srole), fp);
5592 write_nondefault_variables(
GucContext context)
5610 errmsg(
"could not write to file \"%s\": %m",
5611 CONFIG_EXEC_PARAMS_NEW)));
5621 write_one_nondefault_variable(fp, gconf);
5628 errmsg(
"could not write to file \"%s\": %m",
5629 CONFIG_EXEC_PARAMS_NEW)));
5637 rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS);
5647 read_string_with_null(FILE *fp)
5656 if ((ch = fgetc(fp)) == EOF)
5661 elog(
FATAL,
"invalid format of exec config params file");
5665 else if (
i == maxlen)
5679 read_nondefault_variables(
void)
5697 if (errno != ENOENT)
5700 errmsg(
"could not read from file \"%s\": %m",
5701 CONFIG_EXEC_PARAMS)));
5707 if ((varname = read_string_with_null(fp)) == NULL)
5711 elog(
FATAL,
"failed to locate variable \"%s\" in exec config params file", varname);
5713 if ((varvalue = read_string_with_null(fp)) == NULL)
5714 elog(
FATAL,
"invalid format of exec config params file");
5715 if ((varsourcefile = read_string_with_null(fp)) == NULL)
5716 elog(
FATAL,
"invalid format of exec config params file");
5717 if (fread(&varsourceline, 1,
sizeof(varsourceline), fp) !=
sizeof(varsourceline))
5718 elog(
FATAL,
"invalid format of exec config params file");
5719 if (fread(&varsource, 1,
sizeof(varsource), fp) !=
sizeof(varsource))
5720 elog(
FATAL,
"invalid format of exec config params file");
5721 if (fread(&varscontext, 1,
sizeof(varscontext), fp) !=
sizeof(varscontext))
5722 elog(
FATAL,
"invalid format of exec config params file");
5723 if (fread(&varsrole, 1,
sizeof(varsrole), fp) !=
sizeof(varsrole))
5724 elog(
FATAL,
"invalid format of exec config params file");
5727 varscontext, varsource, varsrole,
5729 if (varsourcefile[0])
5782 strcmp(gconf->
name,
"role") == 0;
5929 elog(
ERROR,
"not enough space to serialize GUC state");
5938 elog(
ERROR,
"vsnprintf failed: %m with format string \"%s\"",
fmt);
5943 elog(
ERROR,
"not enough space to serialize GUC state");
5955 if (valsize > *maxbytes)
5956 elog(
ERROR,
"not enough space to serialize GUC state");
5958 memcpy(*destptr,
val, valsize);
5959 *destptr += valsize;
5960 *maxbytes -= valsize;
5984 (*conf->
variable ?
"true" :
"false"));
6037 sizeof(gconf->
srole));
6053 Assert(maxsize >
sizeof(actual_size));
6054 curptr = start_address +
sizeof(actual_size);
6055 bytes_left = maxsize -
sizeof(actual_size);
6067 actual_size = maxsize - bytes_left -
sizeof(actual_size);
6068 memcpy(start_address, &actual_size,
sizeof(actual_size));
6080 char *retptr = *srcptr;
6083 if (*srcptr >= srcend)
6087 for (ptr = *srcptr; ptr < srcend && *ptr !=
'\0'; ptr++)
6091 elog(
ERROR,
"could not find null terminator in GUC state");
6103 if (*srcptr +
size > srcend)
6117 char **error_context_name_and_value = (
char **)
arg;
6119 if (error_context_name_and_value)
6120 errcontext(
"while setting parameter \"%s\" to \"%s\"",
6121 error_context_name_and_value[0],
6122 error_context_name_and_value[1]);
6146 char *srcptr = (
char *) gucstate;
6248 memcpy(&
len, gucstate,
sizeof(
len));
6250 srcptr +=
sizeof(
len);
6251 srcend = srcptr +
len;
6256 error_context_callback.
arg = NULL;
6260 while (srcptr < srcend)
6263 char *error_context_name_and_value[2];
6268 if (varsourcefile[0])
6270 &varsourceline,
sizeof(varsourceline));
6274 &varsource,
sizeof(varsource));
6276 &varscontext,
sizeof(varscontext));
6278 &varsrole,
sizeof(varsrole));
6280 error_context_name_and_value[0] = varname;
6281 error_context_name_and_value[1] = varvalue;
6282 error_context_callback.
arg = &error_context_name_and_value[0];
6284 varscontext, varsource, varsrole,
6288 (
errcode(ERRCODE_INTERNAL_ERROR),
6289 errmsg(
"parameter \"%s\" could not be set", varname)));
6290 if (varsourcefile[0])
6292 error_context_callback.
arg = NULL;
6315 equal_pos = strcspn(
string,
"=");
6317 if (
string[equal_pos] ==
'=')
6331 for (cp = *
name; *cp; cp++)
6378 (
errcode(ERRCODE_SYNTAX_ERROR),
6379 errmsg(
"could not parse setting for parameter \"%s\"",
6409 forboth(lc1, gucNames, lc2, gucValues)
6482 if (strncmp(current,
newval, strlen(
name) + 1) == 0)
6614 eqsgn = strchr(
val,
'=');
6653 bool skipIfNoPermissions)
6693 if (skipIfNoPermissions)
6696 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
6697 errmsg(
"permission denied to set parameter \"%s\"",
name)));
6707 else if (skipIfNoPermissions)
6761 errmsg(
"invalid value for parameter \"%s\": %d",
6795 errmsg(
"invalid value for parameter \"%s\": %d",
6829 errmsg(
"invalid value for parameter \"%s\": %g",
6847 volatile bool result =
true;
6872 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
6913 errmsg(
"invalid value for parameter \"%s\": \"%s\"",
AclResult pg_parameter_aclcheck(const char *name, Oid roleid, AclMode mode)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
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)
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
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
long hash_get_num_entries(HTAB *hashp)
void * hash_seq_search(HASH_SEQ_STATUS *status)
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,...)
FILE * AllocateFile(const char *name, const char *mode)
int durable_rename(const char *oldfile, const char *newfile, int elevel)
int BasicOpenFile(const char *fileName, int fileFlags)
#define MCXT_ALLOC_NO_OOM
void BeginReportingGUCOptions(void)
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
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)
void * guc_malloc(int elevel, size_t size)
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
static dlist_head guc_nondef_list
static bool parse_and_validate_value(struct config_generic *record, const char *name, const char *value, GucSource source, int elevel, union config_var_val *newval, void **newextra)
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)
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)
#define GUC_SAFE_SEARCH_PATH
static slist_head guc_report_list
struct config_generic ** get_guc_variables(int *num_vars)
static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
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)
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 * GUCArrayReset(ArrayType *array)
void ProcessGUCArray(ArrayType *array, GucContext context, GucSource source, GucAction action)
static bool valid_custom_variable_name(const char *name)
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 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)
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)
config_handle * get_config_handle(const char *name)
static char * read_gucstate(char **srcptr, char *srcend)
static bool can_skip_gucvar(struct config_generic *gconf)
const char * GetConfigOptionResetString(const char *name)
void SerializeGUCState(Size maxsize, char *start_address)
static void pg_timezone_abbrev_initialize(void)
static const unit_conversion memory_unit_conversion_table[]
bool SelectConfigFiles(const char *userDoption, const char *progname)
#define REALTYPE_PRECISION
char * GUC_check_errmsg_string
void AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
Size EstimateGUCStateSpace(void)
char * ShowGUCOption(struct config_generic *record, bool use_units)
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
const char * get_config_unit_name(int flags)
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)
void build_guc_variables(void)
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)
ConfigVariable * ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
struct config_generic ** get_explain_guc_options(int *num)
void MarkGUCPrefixReserved(const char *className)
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
ArrayType * GUCArrayAdd(ArrayType *array, const char *name, const char *value)
static bool add_guc_variable(struct config_generic *var, int elevel)
static bool extra_field_used(struct config_generic *gconf, void *extra)
void * guc_realloc(int elevel, void *old, size_t size)
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)
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)
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
char * convert_GUC_name_for_parameter_acl(const char *name)
ArrayType * GUCArrayDelete(ArrayType *array, const char *name)
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 struct config_generic * add_placeholder_variable(const char *name, int elevel)
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
char * config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
char * guc_strdup(int elevel, const char *src)
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)
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
void FreeConfigVariables(ConfigVariable *list)
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
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
const char *(* GucShowHook)(void)
bool(* GucStringCheckHook)(char **newval, void **extra, GucSource source)
#define GUC_DISALLOW_IN_AUTO_FILE
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(* GucIntAssignHook)(int newval, void *extra)
void(* GucRealAssignHook)(double newval, void *extra)
bool(* GucIntCheckHook)(int *newval, void **extra, GucSource source)
#define GUC_NOT_IN_SAMPLE
#define GUC_QUALIFIER_SEPARATOR
void ProcessConfigFile(GucContext context)
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
bool ConfigOptionIsVisible(struct config_generic *conf)
void record_config_file_error(const char *errmsg, const char *config_file, int lineno, ConfigVariable **head_p, ConfigVariable **tail_p)
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
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
MemoryContext TopTransactionContext
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * MemoryContextAllocZero(MemoryContext context, Size size)
void * MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
MemoryContext GetMemoryChunkContext(void *pointer)
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 void bail_out(bool noatexit, const char *fmt,...) pg_attribute_printf(2
static rewind_source * source
void pg_timezone_initialize(void)
char * make_absolute_path(const char *path)
int pg_strcasecmp(const char *s1, const char *s2)
#define qsort(a, b, c, d)
size_t strlcpy(char *dst, const char *src, size_t siz)
char * escape_single_quotes_ascii(const char *src)
CommandDest whereToSendOutput
long get_stack_depth_rlimit(void)
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)
static pg_noinline void Size size
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)