Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpmSD-0006xg-F2 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Mar 2017 01:49:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cpmSC-0006RX-Lv for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Mar 2017 01:49:48 +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 1cpmQi-0003pc-UI for pgsql-hackers@postgresql.org; Mon, 20 Mar 2017 01:48:17 +0000 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cpmQc-0006NG-1l for pgsql-hackers@postgresql.org; Mon, 20 Mar 2017 01:48:15 +0000 Received: by mail-qt0-x22a.google.com with SMTP id n21so96963297qta.1 for ; Sun, 19 Mar 2017 18:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=nf3W42H2WL+jWkYSTPoKZU141x/EDVCGy43Mj39MxmI=; b=yoW931oULJq56xUZ0rEZrcjJTARAmwJxGdx+puKvI0gjdZV27nt3z3AZm9TWEKnM3k oNeRGCb8mqZ1me95bWwg1fTW4J2d/5HqLMg6eV40hU1cgW3PsyPCv3MdSFX15MMstfj8 syeG0vi3Ao2lpdIcx66MndR0J4n/cwwbq4M8wOGKhuZUg89Z6am9bvXvGW9Kx4dfzfs8 BkBlDzPbjpbRpwTP2zh4ilhtXqRbkl/vIMIrW/t06h/gi5jXIV5Jg6wi7Z1jtPE7IRsO ixOcxtBB9a+hnETQO81n5KWUn01EoG6XVu/rzYmcQ7kW2+7gOFemynoTQtrqT1Hq6RG0 Z7pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=nf3W42H2WL+jWkYSTPoKZU141x/EDVCGy43Mj39MxmI=; b=V0sKgBFlG8LYFfWEpo4CqtoyAb1VEX7QliX5/hF8G2JadwQ85XZiNZMHBWTRH2uZOm AuefASCaBJ09MBy6lwjROH039mQe7ZhMr2le+RcWjI+kc7jT4V7MO3dLQmRFVyO6C+Kw 724QVlYPNrtuA5P+1nE/VE8VpL3f1EvfTKTjx2mj7llpdvKQVB2+7tXYtvKn1c8/OCEL 9uNEiEitKfMItNR8ZsNpRpcu5CHMZjz5frzvXfCLPEWWtA7k2pPTeaaUkFkzzRFS28Dc bpNanwPug/VczUcRGKlA9L+88qoGOs6H4YRgrU5iXbbtsV/oAXSK7rPSYMbk3iZlv+gF W4gw== X-Gm-Message-State: AFeK/H0OD72r7Fc3jamGwiFMPmpUYTfWnzr1mcFuGWn9X2xNlMGEVRGWRPVZs3isbjo6WCYh X-Received: by 10.200.56.86 with SMTP id r22mr23741965qtb.190.1489974488528; Sun, 19 Mar 2017 18:48:08 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.217.208.245]) by smtp.gmail.com with ESMTPSA id j20sm11365163qke.14.2017.03.19.18.48.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Mar 2017 18:48:07 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 04EF9662; Sun, 19 Mar 2017 17:00:08 -0300 (CLST) Date: Sun, 19 Mar 2017 17:00:07 -0300 From: Alvaro Herrera To: Tom Lane 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) Message-ID: <20170319200007.2qol6aqyzowmodvc@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <27329.1489945688@sss.pgh.pa.us> User-Agent: NeoMutt/20170206-195-7adf12 (1.7.2) X-Pg-Spam-Score: -2.6 (--) 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 Tom Lane wrote: > 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? Currently, exec_command is a 1500-line function. If I had to see how a single \-command worked, I would have to fold everything but the command I'm interested in, in case there's something nontrivial at function start or end (or even in between -- I would have to start by figuring out whether there's anything other than "else if" somewhere in those 1500 lines). I think splitting into command-specific functions makes this much easier to follow, particularly if we want to add extra tricks such as returning early etc. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers