Re: Common function for percent placeholder replacement

2023-01-11 Thread Peter Eisentraut
On 11.01.23 19:54, Nathan Bossart wrote: On Wed, Jan 11, 2023 at 11:09:01AM +0100, Peter Eisentraut wrote: committed with that fixed While rebasing my recovery modules patch set, I noticed a couple of small things that might be worth cleaning up. committed, thanks

Re: Common function for percent placeholder replacement

2023-01-11 Thread Nathan Bossart
On Wed, Jan 11, 2023 at 11:09:01AM +0100, Peter Eisentraut wrote: > committed with that fixed While rebasing my recovery modules patch set, I noticed a couple of small things that might be worth cleaning up. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com diff --git a/src/backend/a

Re: Common function for percent placeholder replacement

2023-01-11 Thread Peter Eisentraut
On 09.01.23 18:53, Nathan Bossart wrote: + nativePath = pstrdup(path); + make_native_path(nativePath); + nativePath = pstrdup(xlogpath); + make_native_path(nativePath); Should these be freed? committed with that fixed

Re: Common function for percent placeholder replacement

2023-01-09 Thread Nathan Bossart
On Mon, Jan 09, 2023 at 09:36:12AM +0100, Peter Eisentraut wrote: > On 04.01.23 01:37, Nathan Bossart wrote: >> On Tue, Dec 20, 2022 at 06:30:40AM +0100, Peter Eisentraut wrote: >> > + * A value may be NULL. If the corresponding placeholder is found in the >> > + * input string, the whole function

Re: Common function for percent placeholder replacement

2023-01-09 Thread Peter Eisentraut
On 04.01.23 01:37, Nathan Bossart wrote: In general, +1. On Tue, Dec 20, 2022 at 06:30:40AM +0100, Peter Eisentraut wrote: (Still need to think about Robert's comment about lack of error context.) Would adding the name of the GUC be sufficient? ereport(ERROR,

Re: Common function for percent placeholder replacement

2023-01-03 Thread Nathan Bossart
In general, +1. On Tue, Dec 20, 2022 at 06:30:40AM +0100, Peter Eisentraut wrote: > (Still need to think about Robert's comment about lack of error context.) Would adding the name of the GUC be sufficient? ereport(ERROR, (errmsg("could not build %s", guc_name),

Re: Common function for percent placeholder replacement

2022-12-20 Thread Corey Huinker
> > How about this new one with variable arguments? I like this a lot, but I also see merit in Alvaro's PERCENT_OPT variadic, which at least avoids the two lists getting out of sync. Initially, I was going to ask that we have shell-quote-safe equivalents of whatever fixed parameters we baked in,

Re: Common function for percent placeholder replacement

2022-12-19 Thread Peter Eisentraut
On 19.12.22 10:51, Alvaro Herrera wrote: I think the new one is not great. I wish we could do something more straightforward, maybe like replace_percent_placeholders(base_command, PERCENT_OPT("f", filename), PERCENT_OPT("d", tar

Re: Common function for percent placeholder replacement

2022-12-19 Thread Robert Haas
On Mon, Dec 19, 2022 at 3:13 AM Peter Eisentraut wrote: > I agree. Here is an updated patch with the error checking included. Nice, but I think something in the error report needs to indicate what caused the problem exactly. As coded, I think the user would have to guess which GUC caused the pro

Re: Common function for percent placeholder replacement

2022-12-19 Thread Alvaro Herrera
On 2022-Dec-19, Peter Eisentraut wrote: > On 14.12.22 18:05, Justin Pryzby wrote: > > On Wed, Dec 14, 2022 at 08:31:02AM +0100, Peter Eisentraut wrote: > > > + return replace_percent_placeholders(base_command, "df", (const char > > > *[]){target_detail, filename}); > > > > This is a "compound li

Re: Common function for percent placeholder replacement

2022-12-19 Thread Peter Eisentraut
On 14.12.22 18:05, Justin Pryzby wrote: On Wed, Dec 14, 2022 at 08:31:02AM +0100, Peter Eisentraut wrote: + return replace_percent_placeholders(base_command, "df", (const char *[]){target_detail, filename}); This is a "compound literal", which I gather is required by C99. But I don't t

Re: Common function for percent placeholder replacement

2022-12-19 Thread Peter Eisentraut
On 14.12.22 17:09, Robert Haas wrote: Well, OK, I'll tentatively cast a vote in favor of adopting basebackup_to_shell's approach elsewhere. Or to put that in plain English: I think that if the input appears to be malformed, it's better to throw an error than to guess what the user meant. In the c

Re: Common function for percent placeholder replacement

2022-12-14 Thread Tom Lane
Justin Pryzby writes: > On Wed, Dec 14, 2022 at 08:31:02AM +0100, Peter Eisentraut wrote: >> +return replace_percent_placeholders(base_command, "df", (const char >> *[]){target_detail, filename}); > This is a "compound literal", which I gather is required by C99. > But I don't think that's

Re: Common function for percent placeholder replacement

2022-12-14 Thread Justin Pryzby
On Wed, Dec 14, 2022 at 08:31:02AM +0100, Peter Eisentraut wrote: > + return replace_percent_placeholders(base_command, "df", (const char > *[]){target_detail, filename}); This is a "compound literal", which I gather is required by C99. But I don't think that's currently being exercised, so

Re: Common function for percent placeholder replacement

2022-12-14 Thread Robert Haas
On Wed, Dec 14, 2022 at 2:31 AM Peter Eisentraut wrote: > There are a number of places where a shell command is constructed with > percent-placeholders (like %x). First, it's obviously cumbersome to > have to open-code this several times. Second, each of those pieces of > code silently encodes s