public inbox for [email protected]
help / color / mirror / Atom feedRe: fix and document CLUSTER privileges
3+ messages / 2 participants
[nested] [flat]
* Re: fix and document CLUSTER privileges
@ 2023-01-04 18:18 Nathan Bossart <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Bossart @ 2023-01-04 18:18 UTC (permalink / raw)
To: Gilles Darold <[email protected]>; +Cc: Andrew Dunstan <[email protected]>; Justin Pryzby <[email protected]>; pgsql-hackers; Robert Haas <[email protected]>
On Wed, Jan 04, 2023 at 02:25:13PM +0100, Gilles Darold wrote:
> This is the current behavior of the CLUSTER command and current patch adds a
> sentence about the silent behavior in the documentation. This is good but I
> just want to ask if we could want to fix this behavior too or just keep
> things like that with the lack of noise.
I've proposed something like what you are describing in another thread [0].
I intended to simply fix and document the current behavior in this thread
and to take up any new changes in the other one.
[0] https://commitfest.postgresql.org/41/4070/
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: fix and document CLUSTER privileges
@ 2023-01-04 22:27 Gilles Darold <[email protected]>
parent: Nathan Bossart <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Gilles Darold @ 2023-01-04 22:27 UTC (permalink / raw)
To: Nathan Bossart <[email protected]>; Gilles Darold <[email protected]>; +Cc: Andrew Dunstan <[email protected]>; Justin Pryzby <[email protected]>; pgsql-hackers; Robert Haas <[email protected]>
Le 04/01/2023 à 19:18, Nathan Bossart a écrit :
> On Wed, Jan 04, 2023 at 02:25:13PM +0100, Gilles Darold wrote:
>> This is the current behavior of the CLUSTER command and current patch adds a
>> sentence about the silent behavior in the documentation. This is good but I
>> just want to ask if we could want to fix this behavior too or just keep
>> things like that with the lack of noise.
> I've proposed something like what you are describing in another thread [0].
> I intended to simply fix and document the current behavior in this thread
> and to take up any new changes in the other one.
>
> [0] https://commitfest.postgresql.org/41/4070/
Got it, this is patch add_cluster_skip_messages.patch . IMHO this patch
should be part of this commitfest as it is directly based on this one.
You could create a second patch here that adds the warning message so
that committers can decide here if it should be applied.
--
Gilles Darold
^ permalink raw reply [nested|flat] 3+ messages in thread
* [PATCH v20 1/5] introduce routine for checking mutually exclusive string GUCs
@ 2023-02-15 22:28 Nathan Bossart <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Bossart @ 2023-02-15 22:28 UTC (permalink / raw)
---
src/backend/postmaster/pgarch.c | 8 +++-----
src/backend/utils/misc/guc.c | 22 ++++++++++++++++++++++
src/include/utils/guc.h | 3 +++
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index c266904b57..55e9a1796b 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -821,11 +821,9 @@ LoadArchiveLibrary(void)
{
ArchiveModuleInit archive_init;
- if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("both archive_command and archive_library set"),
- errdetail("Only one of archive_command, archive_library may be set.")));
+ (void) CheckMutuallyExclusiveStringGUCs(XLogArchiveLibrary, "archive_library",
+ XLogArchiveCommand, "archive_command",
+ ERROR);
/*
* If shell archiving is enabled, use our special initialization function.
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 391866145e..ac507008ce 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2659,6 +2659,28 @@ ReportGUCOption(struct config_generic *record)
pfree(val);
}
+/*
+ * If both parameters are set, emits a log message at 'elevel' and returns
+ * false. Otherwise, returns true.
+ */
+bool
+CheckMutuallyExclusiveStringGUCs(const char *p1val, const char *p1name,
+ const char *p2val, const char *p2name,
+ int elevel)
+{
+ if (p1val[0] != '\0' && p2val[0] != '\0')
+ {
+ ereport(elevel,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("cannot set both %s and %s", p1name, p2name),
+ errdetail("Only one of %s or %s may be set.",
+ p1name, p2name)));
+ return false;
+ }
+
+ return true;
+}
+
/*
* Convert a value from one of the human-friendly units ("kB", "min" etc.)
* to the given base unit. 'value' and 'unit' are the input value and unit
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 3712aba09b..3088ada610 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -376,6 +376,9 @@ extern void RestrictSearchPath(void);
extern void AtEOXact_GUC(bool isCommit, int nestLevel);
extern void BeginReportingGUCOptions(void);
extern void ReportChangedGUCOptions(void);
+extern bool CheckMutuallyExclusiveStringGUCs(const char *p1val, const char *p1name,
+ const char *p2val, const char *p2name,
+ int elevel);
extern void ParseLongOption(const char *string, char **name, char **value);
extern const char *get_config_unit_name(int flags);
extern bool parse_int(const char *value, int *result, int flags,
--
2.25.1
--3V7upXqbjpZ4EhLz
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v20-0002-refactor-code-for-restoring-via-shell.patch"
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-02-15 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 18:18 Re: fix and document CLUSTER privileges Nathan Bossart <[email protected]>
2023-01-04 22:27 ` Gilles Darold <[email protected]>
2023-02-15 22:28 [PATCH v20 1/5] introduce routine for checking mutually exclusive string GUCs Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox