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 1p2K91-00036q-FB for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Dec 2022 22:41:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2K90-0008Bk-D6 for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Dec 2022 22:41:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2K8z-0008Bb-CW for pgsql-hackers@lists.postgresql.org; Mon, 05 Dec 2022 22:41:02 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2K8w-0006fe-7F for pgsql-hackers@postgresql.org; Mon, 05 Dec 2022 22:41:00 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id CF5785802E1; Mon, 5 Dec 2022 17:40:56 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 05 Dec 2022 17:40:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1670280056; x=1670287256; bh=2 R4J5TInHgVwVwNugn231y0TDPd6OdsTn1QmFHqi0eM=; b=AHn9ZRK3zZRABN++G wuwM2ZwFXYdQfUpVB8ArT5LvsVoRcDKKNPxFnLGZLxCJGm/iaj63lK18y5NCeNHW /fxuki5+Mu1oSFKCOkctSOdiU1LdVmgQOpAbZN8Ay/XwDpMFLItS3ZDXtXhCFbSr zSoCfhx21peINKMfIxzNx8CFPz0/kmx9o70Tc/QBGJKJfOebmLEtHUkvdROL+99I /46PyHCV3sn+O6o9FrszZRJ7ue5E9QZHKr4cGliTZySYOCAcQlMae/SQndgZsl96 5sFlGNxHHNdCybOwskQU9vat7KrvGxZ3iXfMvH8/h8S5Ggk+HdJN/84ftzuscW48 QhD8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgddtudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeelgfetfeeitdelleeggeej vefhueetfedvtdejheevueeifeegvdfhueeludetueenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 17:40:55 -0500 (EST) Message-ID: <924d08b2-0fb0-a97e-2e2e-7c365ea42f0c@enterprisedb.com> Date: Mon, 5 Dec 2022 23:40:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: initdb: Refactor PG_CMD_PUTS loops To: Andrew Dunstan , pgsql-hackers References: <2c50823b-f453-bb97-e38b-34751c51dcdf@enterprisedb.com> <962a4a82-ec18-6a4f-7002-4edb2a47b94c@dunslane.net> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <962a4a82-ec18-6a4f-7002-4edb2a47b94c@dunslane.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 02.12.22 15:07, Andrew Dunstan wrote: > On 2022-12-01 Th 05:02, Peter Eisentraut wrote: >> Keeping the SQL commands that initdb runs in string arrays before >> feeding them to PG_CMD_PUTS() seems unnecessarily verbose and >> inflexible.  In some cases, the array only has one member.  In other >> cases, one might want to use PG_CMD_PRINTF() instead, to parametrize a >> command, but that would require breaking up the loop or using >> workarounds like replace_token().  This patch unwinds all that; it's >> much simpler that way. > > Looks reasonable. (Most of this dates back to 2003/2004, the very early > days of initdb.c.) committed