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 1mlvA9-0000eQ-25 for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Nov 2021 15:41:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mlvA7-0003nL-Ku for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Nov 2021 15:41:51 +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 1mlvA7-0003nC-Bj for pgsql-hackers@lists.postgresql.org; Sat, 13 Nov 2021 15:41:51 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlvA2-0006vG-JP for pgsql-hackers@lists.postgresql.org; Sat, 13 Nov 2021 15:41:50 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9EDAA5C00FB; Sat, 13 Nov 2021 10:41:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 13 Nov 2021 10:41:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=56nWpZZMCpeuFbVbaI0QP1OUodWMlflCHm8S7HUmFt4=; b=S5QCXULT rDMp4Fa5F56u4lR1uFcglDM+tA69GE6OKXwCFL0VBjxIboWeTZp77cMjEpkP17ir VdGYYPMqmVwaCq098q9BArALravMINUzyMv92tta4Ldhp6QV+XhZQ9s/01+tfLa3 B/Vr7BsUor1Qps8eptphhnv6CSbELBQn2mG0IPGVliwfoRo3zYVYOmBk24XoZZcl RJLpxBKkcFRJ7EmKH1C+CLpGQ1QrEVbnL8zcYHbuRyhVK/dr65Wk19zPX1V8EuRu QQFUhSGSauRu5P8rJigInVXxEWdtzxHt/SeQ62ZZ+Jcp7+DWia9LtJhisfAsYJfm evzJgCjCgIpiZg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrvdehgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepudejveejffejveduudetvdekieeuiedtvdeileefkeevjedu feeguedvjefhueelnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Nov 2021 10:41:45 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 9E6262A07B8; Sat, 13 Nov 2021 12:41:42 -0300 (-03) Date: Sat, 13 Nov 2021 12:41:42 -0300 From: Alvaro Herrera To: Zhihong Yu Cc: Pg Hackers Subject: Re: support for MERGE Message-ID: <202111131541.knkewwxtdt4u@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 2021-Nov-12, Zhihong Yu wrote: > +lmerge_matched: > ... > + foreach(l, resultRelInfo->ri_matchedMergeAction) > > I suggest expanding the foreach macro into the form of for loop where the > loop condition has extra boolean variable merge_matched. > Initial value for merge_matched can be true. > Inside the loop, we can adjust merge_matched's value to control whether the > for loop continues. > This would avoid using goto label. Heh, have you seen the definition of foreach() lately? I do *not* want to expand that anywhere. Anyway, even if we had the old foreach() (before commit 1cff1b95ab6d), ISTM that the goto makes the whole thing much clearer. For example, where would you do the table_tuple_fetch_row_version call that currently lies after the goto label but before the foreach loop starts? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "If you have nothing to say, maybe you need just the right tool to help you not say it." (New York Times, about Microsoft PowerPoint)