Compare commits

..

No commits in common. "5e4dacb9878cf71e32950e90993afd9450dab4da" and "36a14afc076024ba48c399f2af2d4cd1b2c39348" have entirely different histories.

8 changed files with 103 additions and 182 deletions

View File

@ -28,7 +28,6 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 4 || ([$]1 == 3 && [$]2 >= 9)) exit 1; else exit 0;}';then if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 4 || ([$]1 == 3 && [$]2 >= 9)) exit 1; else exit 0;}';then
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required]) AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required])
fi fi
AC_MSG_NOTICE([using llvm $pgac_llvm_version])
# need clang to create some bitcode files # need clang to create some bitcode files
AC_ARG_VAR(CLANG, [path to clang compiler to generate bitcode]) AC_ARG_VAR(CLANG, [path to clang compiler to generate bitcode])

2
configure vendored
View File

@ -5123,8 +5123,6 @@ fi
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 4 || ($1 == 3 && $2 >= 9)) exit 1; else exit 0;}';then if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 4 || ($1 == 3 && $2 >= 9)) exit 1; else exit 0;}';then
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required" "$LINENO" 5 as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required" "$LINENO" 5
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: using llvm $pgac_llvm_version" >&5
$as_echo "$as_me: using llvm $pgac_llvm_version" >&6;}
# need clang to create some bitcode files # need clang to create some bitcode files

View File

@ -82,7 +82,11 @@ ParameterAclCreate(const char *parameter)
* To prevent cluttering pg_parameter_acl with useless entries, insist * To prevent cluttering pg_parameter_acl with useless entries, insist
* that the name be valid. * that the name be valid.
*/ */
check_GUC_name_for_parameter_acl(parameter); if (!check_GUC_name_for_parameter_acl(parameter))
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid parameter name \"%s\"",
parameter)));
/* Convert name to the form it should have in pg_parameter_acl. */ /* Convert name to the form it should have in pg_parameter_acl. */
parname = convert_GUC_name_for_parameter_acl(parameter); parname = convert_GUC_name_for_parameter_acl(parameter);

View File

@ -927,7 +927,7 @@ dsm_unpin_mapping(dsm_segment *seg)
void void
dsm_pin_segment(dsm_segment *seg) dsm_pin_segment(dsm_segment *seg)
{ {
void *handle = NULL; void *handle;
/* /*
* Bump reference count for this segment in shared memory. This will * Bump reference count for this segment in shared memory. This will
@ -938,7 +938,6 @@ dsm_pin_segment(dsm_segment *seg)
LWLockAcquire(DynamicSharedMemoryControlLock, LW_EXCLUSIVE); LWLockAcquire(DynamicSharedMemoryControlLock, LW_EXCLUSIVE);
if (dsm_control->item[seg->control_slot].pinned) if (dsm_control->item[seg->control_slot].pinned)
elog(ERROR, "cannot pin a segment that is already pinned"); elog(ERROR, "cannot pin a segment that is already pinned");
if (!is_main_region_dsm_handle(seg->handle))
dsm_impl_pin_segment(seg->handle, seg->impl_private, &handle); dsm_impl_pin_segment(seg->handle, seg->impl_private, &handle);
dsm_control->item[seg->control_slot].pinned = true; dsm_control->item[seg->control_slot].pinned = true;
dsm_control->item[seg->control_slot].refcnt++; dsm_control->item[seg->control_slot].refcnt++;
@ -996,7 +995,6 @@ dsm_unpin_segment(dsm_handle handle)
* releasing the lock, because impl_private_pm_handle may get modified by * releasing the lock, because impl_private_pm_handle may get modified by
* dsm_impl_unpin_segment. * dsm_impl_unpin_segment.
*/ */
if (!is_main_region_dsm_handle(handle))
dsm_impl_unpin_segment(handle, dsm_impl_unpin_segment(handle,
&dsm_control->item[control_slot].impl_private_pm_handle); &dsm_control->item[control_slot].impl_private_pm_handle);

View File

@ -250,8 +250,6 @@ static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *h
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
const char *name, const char *value); const char *name, const char *value);
static bool valid_custom_variable_name(const char *name); static bool valid_custom_variable_name(const char *name);
static bool assignable_custom_variable_name(const char *name, bool skip_errors,
int elevel);
static void do_serialize(char **destptr, Size *maxbytes, static void do_serialize(char **destptr, Size *maxbytes,
const char *fmt,...) pg_attribute_printf(3, 4); const char *fmt,...) pg_attribute_printf(3, 4);
static bool call_bool_check_hook(struct config_bool *conf, bool *newval, static bool call_bool_check_hook(struct config_bool *conf, bool *newval,
@ -1065,7 +1063,7 @@ add_guc_variable(struct config_generic *var, int elevel)
* *
* It must be two or more identifiers separated by dots, where the rules * It must be two or more identifiers separated by dots, where the rules
* for what is an identifier agree with scan.l. (If you change this rule, * for what is an identifier agree with scan.l. (If you change this rule,
* adjust the errdetail in assignable_custom_variable_name().) * adjust the errdetail in find_option().)
*/ */
static bool static bool
valid_custom_variable_name(const char *name) valid_custom_variable_name(const char *name)
@ -1100,71 +1098,6 @@ valid_custom_variable_name(const char *name)
return saw_sep; return saw_sep;
} }
/*
* Decide whether an unrecognized variable name is allowed to be SET.
*
* It must pass the syntactic rules of valid_custom_variable_name(),
* and it must not be in any namespace already reserved by an extension.
* (We make this separate from valid_custom_variable_name() because we don't
* apply the reserved-namespace test when reading configuration files.)
*
* If valid, return true. Otherwise, return false if skip_errors is true,
* else throw a suitable error at the specified elevel (and return false
* if that's less than ERROR).
*/
static bool
assignable_custom_variable_name(const char *name, bool skip_errors, int elevel)
{
/* If there's no separator, it can't be a custom variable */
const char *sep = strchr(name, GUC_QUALIFIER_SEPARATOR);
if (sep != NULL)
{
size_t classLen = sep - name;
ListCell *lc;
/* The name must be syntactically acceptable ... */
if (!valid_custom_variable_name(name))
{
if (!skip_errors)
ereport(elevel,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid configuration parameter name \"%s\"",
name),
errdetail("Custom parameter names must be two or more simple identifiers separated by dots.")));
return false;
}
/* ... and it must not match any previously-reserved prefix */
foreach(lc, reserved_class_prefix)
{
const char *rcprefix = lfirst(lc);
if (strlen(rcprefix) == classLen &&
strncmp(name, rcprefix, classLen) == 0)
{
if (!skip_errors)
ereport(elevel,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid configuration parameter name \"%s\"",
name),
errdetail("\"%s\" is a reserved prefix.",
rcprefix)));
return false;
}
}
/* OK to create it */
return true;
}
/* Unrecognized single-part name */
if (!skip_errors)
ereport(elevel,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("unrecognized configuration parameter \"%s\"",
name)));
return false;
}
/* /*
* Create and add a placeholder variable for a custom variable name. * Create and add a placeholder variable for a custom variable name.
*/ */
@ -1258,15 +1191,52 @@ find_option(const char *name, bool create_placeholders, bool skip_errors,
if (create_placeholders) if (create_placeholders)
{ {
/* /*
* Check if the name is valid, and if so, add a placeholder. * Check if the name is valid, and if so, add a placeholder. If it
* doesn't contain a separator, don't assume that it was meant to be a
* placeholder.
*/ */
if (assignable_custom_variable_name(name, skip_errors, elevel)) const char *sep = strchr(name, GUC_QUALIFIER_SEPARATOR);
if (sep != NULL)
{
size_t classLen = sep - name;
ListCell *lc;
/* The name must be syntactically acceptable ... */
if (!valid_custom_variable_name(name))
{
if (!skip_errors)
ereport(elevel,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid configuration parameter name \"%s\"",
name),
errdetail("Custom parameter names must be two or more simple identifiers separated by dots.")));
return NULL;
}
/* ... and it must not match any previously-reserved prefix */
foreach(lc, reserved_class_prefix)
{
const char *rcprefix = lfirst(lc);
if (strlen(rcprefix) == classLen &&
strncmp(name, rcprefix, classLen) == 0)
{
if (!skip_errors)
ereport(elevel,
(errcode(ERRCODE_INVALID_NAME),
errmsg("invalid configuration parameter name \"%s\"",
name),
errdetail("\"%s\" is a reserved prefix.",
rcprefix)));
return NULL;
}
}
/* OK, create it */
return add_placeholder_variable(name, elevel); return add_placeholder_variable(name, elevel);
else }
return NULL; /* error message, if any, already emitted */
} }
/* Unknown name and we're not supposed to make a placeholder */ /* Unknown name */
if (!skip_errors) if (!skip_errors)
ereport(elevel, ereport(elevel,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
@ -1399,16 +1369,18 @@ convert_GUC_name_for_parameter_acl(const char *name)
/* /*
* Check whether we should allow creation of a pg_parameter_acl entry * Check whether we should allow creation of a pg_parameter_acl entry
* for the given name. (This can be applied either before or after * for the given name. (This can be applied either before or after
* canonicalizing it.) Throws error if not. * canonicalizing it.)
*/ */
void bool
check_GUC_name_for_parameter_acl(const char *name) check_GUC_name_for_parameter_acl(const char *name)
{ {
/* OK if the GUC exists. */ /* OK if the GUC exists. */
if (find_option(name, false, true, DEBUG5) != NULL) if (find_option(name, false, true, DEBUG1) != NULL)
return; return true;
/* Otherwise, it'd better be a valid custom GUC name. */ /* Otherwise, it'd better be a valid custom GUC name. */
(void) assignable_custom_variable_name(name, false, ERROR); if (valid_custom_variable_name(name))
return true;
return false;
} }
/* /*
@ -4543,13 +4515,12 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
{ {
struct config_generic *record; struct config_generic *record;
/* We don't want to create a placeholder if there's not one already */ record = find_option(name, false, false, ERROR);
record = find_option(name, false, true, DEBUG5); Assert(record != NULL);
if (record != NULL)
{
/* /*
* Don't allow parameters that can't be set in configuration files * Don't allow parameters that can't be set in configuration files to
* to be set in PG_AUTOCONF_FILENAME file. * be set in PG_AUTOCONF_FILENAME file.
*/ */
if ((record->context == PGC_INTERNAL) || if ((record->context == PGC_INTERNAL) ||
(record->flags & GUC_DISALLOW_IN_FILE) || (record->flags & GUC_DISALLOW_IN_FILE) ||
@ -4567,6 +4538,7 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
union config_var_val newval; union config_var_val newval;
void *newextra = NULL; void *newextra = NULL;
/* Check that it's acceptable for the indicated parameter */
if (!parse_and_validate_value(record, name, value, if (!parse_and_validate_value(record, name, value,
PGC_S_FILE, ERROR, PGC_S_FILE, ERROR,
&newval, &newextra)) &newval, &newextra))
@ -4578,30 +4550,18 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
if (record->vartype == PGC_STRING && newval.stringval != NULL) if (record->vartype == PGC_STRING && newval.stringval != NULL)
guc_free(newval.stringval); guc_free(newval.stringval);
guc_free(newextra); guc_free(newextra);
}
}
else
{
/*
* Variable not known; check we'd be allowed to create it. (We
* cannot validate the value, but that's fine. A non-core GUC in
* the config file cannot cause postmaster start to fail, so we
* don't have to be too tense about possibly installing a bad
* value.)
*/
(void) assignable_custom_variable_name(name, false, ERROR);
}
/* /*
* We must also reject values containing newlines, because the grammar * We must also reject values containing newlines, because the
* for config files doesn't support embedded newlines in string * grammar for config files doesn't support embedded newlines in
* literals. * string literals.
*/ */
if (value && strchr(value, '\n')) if (strchr(value, '\n'))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("parameter value for ALTER SYSTEM must not contain a newline"))); errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
} }
}
/* /*
* PG_AUTOCONF_FILENAME and its corresponding temporary file are always in * PG_AUTOCONF_FILENAME and its corresponding temporary file are always in

View File

@ -363,7 +363,7 @@ extern const char *GetConfigOptionResetString(const char *name);
extern int GetConfigOptionFlags(const char *name, bool missing_ok); extern int GetConfigOptionFlags(const char *name, bool missing_ok);
extern void ProcessConfigFile(GucContext context); extern void ProcessConfigFile(GucContext context);
extern char *convert_GUC_name_for_parameter_acl(const char *name); extern char *convert_GUC_name_for_parameter_acl(const char *name);
extern void check_GUC_name_for_parameter_acl(const char *name); extern bool check_GUC_name_for_parameter_acl(const char *name);
extern void InitializeGUCOptions(void); extern void InitializeGUCOptions(void);
extern bool SelectConfigFiles(const char *userDoption, const char *progname); extern bool SelectConfigFiles(const char *userDoption, const char *progname);
extern void ResetAllOptions(void); extern void ResetAllOptions(void);

View File

@ -220,31 +220,9 @@ SELECT 1 FROM pg_parameter_acl WHERE parname = 'none.such';
---------- ----------
(0 rows) (0 rows)
-- Superuser should be able to ALTER SYSTEM SET a non-existent custom GUC.
ALTER SYSTEM SET none.such = 'whiz bang';
-- None of the above should have created a placeholder GUC for none.such.
SHOW none.such; -- error
ERROR: unrecognized configuration parameter "none.such"
-- However, if we reload ...
SELECT pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
-- and start a new session to avoid race condition ...
\c -
SET SESSION AUTHORIZATION regress_admin;
-- then it should be there.
SHOW none.such;
none.such
-----------
whiz bang
(1 row)
-- Can't grant on a non-existent core GUC. -- Can't grant on a non-existent core GUC.
GRANT ALL ON PARAMETER no_such_guc TO regress_host_resource_admin; -- fail GRANT ALL ON PARAMETER no_such_guc TO regress_host_resource_admin; -- fail
ERROR: unrecognized configuration parameter "no_such_guc" ERROR: invalid parameter name "no_such_guc"
-- Initially there are no privileges and no catalog entry for this GUC. -- Initially there are no privileges and no catalog entry for this GUC.
SELECT has_parameter_privilege('regress_host_resource_admin', 'enable_material', 'SET'); SELECT has_parameter_privilege('regress_host_resource_admin', 'enable_material', 'SET');
has_parameter_privilege has_parameter_privilege
@ -481,8 +459,6 @@ SELECT set_config ('temp_buffers', '8192', false); -- ok
ALTER SYSTEM RESET autovacuum_work_mem; -- ok, privileges have been granted ALTER SYSTEM RESET autovacuum_work_mem; -- ok, privileges have been granted
ALTER SYSTEM RESET ALL; -- fail, insufficient privileges ALTER SYSTEM RESET ALL; -- fail, insufficient privileges
ERROR: permission denied to perform ALTER SYSTEM RESET ALL ERROR: permission denied to perform ALTER SYSTEM RESET ALL
ALTER SYSTEM SET none.such2 = 'whiz bang'; -- fail, not superuser
ERROR: permission denied to set parameter "none.such2"
ALTER ROLE regress_host_resource_admin SET lc_messages = 'POSIX'; -- fail ALTER ROLE regress_host_resource_admin SET lc_messages = 'POSIX'; -- fail
ERROR: permission denied to set parameter "lc_messages" ERROR: permission denied to set parameter "lc_messages"
ALTER ROLE regress_host_resource_admin SET max_stack_depth = '1MB'; -- ok ALTER ROLE regress_host_resource_admin SET max_stack_depth = '1MB'; -- ok

View File

@ -98,19 +98,6 @@ GRANT ALL ON PARAMETER none.such TO regress_host_resource_admin;
SELECT 1 FROM pg_parameter_acl WHERE parname = 'none.such'; SELECT 1 FROM pg_parameter_acl WHERE parname = 'none.such';
REVOKE ALL ON PARAMETER "None.Such" FROM regress_host_resource_admin; REVOKE ALL ON PARAMETER "None.Such" FROM regress_host_resource_admin;
SELECT 1 FROM pg_parameter_acl WHERE parname = 'none.such'; SELECT 1 FROM pg_parameter_acl WHERE parname = 'none.such';
-- Superuser should be able to ALTER SYSTEM SET a non-existent custom GUC.
ALTER SYSTEM SET none.such = 'whiz bang';
-- None of the above should have created a placeholder GUC for none.such.
SHOW none.such; -- error
-- However, if we reload ...
SELECT pg_reload_conf();
-- and start a new session to avoid race condition ...
\c -
SET SESSION AUTHORIZATION regress_admin;
-- then it should be there.
SHOW none.such;
-- Can't grant on a non-existent core GUC. -- Can't grant on a non-existent core GUC.
GRANT ALL ON PARAMETER no_such_guc TO regress_host_resource_admin; -- fail GRANT ALL ON PARAMETER no_such_guc TO regress_host_resource_admin; -- fail
@ -203,7 +190,6 @@ ALTER SYSTEM RESET lc_messages; -- fail, insufficient privileges
SELECT set_config ('temp_buffers', '8192', false); -- ok SELECT set_config ('temp_buffers', '8192', false); -- ok
ALTER SYSTEM RESET autovacuum_work_mem; -- ok, privileges have been granted ALTER SYSTEM RESET autovacuum_work_mem; -- ok, privileges have been granted
ALTER SYSTEM RESET ALL; -- fail, insufficient privileges ALTER SYSTEM RESET ALL; -- fail, insufficient privileges
ALTER SYSTEM SET none.such2 = 'whiz bang'; -- fail, not superuser
ALTER ROLE regress_host_resource_admin SET lc_messages = 'POSIX'; -- fail ALTER ROLE regress_host_resource_admin SET lc_messages = 'POSIX'; -- fail
ALTER ROLE regress_host_resource_admin SET max_stack_depth = '1MB'; -- ok ALTER ROLE regress_host_resource_admin SET max_stack_depth = '1MB'; -- ok
SELECT setconfig FROM pg_db_role_setting SELECT setconfig FROM pg_db_role_setting