pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Common function for percent placeholder replacement
Date: Mon, 19 Dec 2022 10:51:14 +0100
Message-ID: <20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql> (raw)
In-Reply-To: <dfc00ffd-ae72-6479-997a-e51a424d3088@enterprisedb.com>

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 literal", which I gather is required by C99.
> > 
> > But I don't think that's currently being exercised, so I wonder if it's
> > going to break some BF members.
> 
> We already use this, for example in pg_dump.

Yeah, we have this

#define ARCHIVE_OPTS(...) &(ArchiveOpts){__VA_ARGS__}

which we then use like this

    ArchiveEntry(fout,
                 dbCatId,       /* catalog ID */
                 dbDumpId,      /* dump ID */
                 ARCHIVE_OPTS(.tag = datname,
                              .owner = dba,
                              .description = "DATABASE",
                              .section = SECTION_PRE_DATA,
                              .createStmt = creaQry->data,
                              .dropStmt = delQry->data));

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", target_detail));

Is there a performance disadvantage to a variadic implementation?
Alternatively, have all these macro calls form an array.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
Subversion to GIT: the shortest path to happiness I've ever heard of
                                                (Alexey Klyukin)





view thread (16+ messages)  latest in thread

Message-ID: <20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql>
Permalink:  ../20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql/
Also on:    postgresql.org/message-id/20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, peter.eisentraut@enterprisedb.com, pryzby@telsasoft.com
  Subject: Re: Common function for percent placeholder replacement
  In-Reply-To: <20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql>
  References: <dfc00ffd-ae72-6479-997a-e51a424d3088@enterprisedb.com> <20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox