Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpexl-0002is-RC for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Mar 2017 17:49:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cpexk-0006LV-8l for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Mar 2017 17:49:52 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cpewG-0003j8-AF; Sun, 19 Mar 2017 17:48:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cpewD-0005kM-LP; Sun, 19 Mar 2017 17:48:19 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v2JHm80Z027330; Sun, 19 Mar 2017 13:48:08 -0400 From: Tom Lane To: Alvaro Herrera cc: Fabien COELHO , Corey Huinker , Daniel Verite , "David G. Johnston" , Greg Stark , Erik Rijkers , Robert Haas , Jim Nasby , PostgreSQL , pgsql-hackers-owner@postgresql.org Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless) In-reply-to: <20170319172643.asukyqvva724phnz@alvherre.pgsql> References: <20170319172643.asukyqvva724phnz@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Sun, 19 Mar 2017 14:26:43 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27328.1489945688.1@sss.pgh.pa.us> Date: Sun, 19 Mar 2017 13:48:08 -0400 Message-ID: <27329.1489945688@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Alvaro Herrera writes: > The reason this is so large is that there is an entangled refactoring > patch, splitting the exec_command() function from one giant switch() > into one routine for each command. It's up to the committer whether to > do it all in one patch, or to request this to be split into a > refactoring patch plus another adding functionality on top. Assuming we want to do it that way at all, two steps would probably be easier to review in detail. I'm not entirely convinced that function-per-command is an improvement though. Seems like it would only help to the extent that you could do a simple "return" to implement early exit, and it looks to me like that doesn't work in a lot of places because you still have to clean up things like malloc'd argument strings before you can return. So the question we have to answer is whether this way looks cleaner than what we'd get if we just changed the logic in-place. For the purpose of answering that question, looking at the final state is the right thing to do. I don't have a definite opinion on that core question yet, since I've not read this version of the patch. Anybody else want to give an opinion? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers