Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p7Cnw-0004Qr-8d for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Dec 2022 09:51:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p7Cnu-00052e-PF for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Dec 2022 09:51:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p7Cnt-00052U-OA for pgsql-hackers@lists.postgresql.org; Mon, 19 Dec 2022 09:51:26 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p7Cnq-00048t-Ne for pgsql-hackers@postgresql.org; Mon, 19 Dec 2022 09:51:25 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0A823320046E; Mon, 19 Dec 2022 04:51:18 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 19 Dec 2022 04:51:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1671443478; x=1671529878; bh=z vdurJxJ3DHD5akYq4pWvd6WIVNf3gdKA4PrD7Bqls8=; b=Srg0CGnz9QtZecWIM i6e4r0PHG2VJ9BlW7BXucQnT4VAPSndT3Bbu/KuoW4MiCWz4FMT3NmLLTqzh7b1g Qk54/68f9OBnQicJJqiEgda4JBsXalMKcCe3jA/GlK3uJWmV1ncDN4bk8gtH5cJ3 iyNZPKu/2R3jN3MyOUm0mh+77SB2F3YkjpaRZOOOKx3SL64+htZ9G51QDvmKL/h+ VV/dVrUkrenvYJOmEXS0SKzvaZsnTloqcvjPhGE2hBJLV++YqLprc+Ih62we2OGg 7sTJoPIC4DxlSxc93wOl6ZOQFGSIO1GY2b159aqUBeqF0GaWN2yPjU9Ifa5aWeeP fsfqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeefgddtiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Dec 2022 04:51:17 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id AA75EE98; Mon, 19 Dec 2022 10:51:14 +0100 (CET) Date: Mon, 19 Dec 2022 10:51:14 +0100 From: Alvaro Herrera To: Peter Eisentraut Cc: Justin Pryzby , pgsql-hackers@postgresql.org Subject: Re: Common function for percent placeholder replacement Message-ID: <20221219095114.m4nlp4fb3owmsu65@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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)