Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnXPv-0004wV-NS for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Mar 2017 21:22:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cnXPv-0006ww-1g for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Mar 2017 21:22:11 +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 1cnXPs-0006uL-T7; Mon, 13 Mar 2017 21:22:09 +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 1cnXPq-0007BP-K1; Mon, 13 Mar 2017 21:22:07 +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 v2DLLwLD015876; Mon, 13 Mar 2017 17:21:58 -0400 From: Tom Lane To: "Daniel Verite" cc: "David G. Johnston" , "Corey Huinker" , "Fabien COELHO" , "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: References: Comments: In-reply-to "Daniel Verite" message dated "Mon, 13 Mar 2017 20:11:10 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15874.1489440118.1@sss.pgh.pa.us> Date: Mon, 13 Mar 2017 17:21:58 -0400 Message-ID: <15875.1489440118@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) 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 "Daniel Verite" writes: > Tom Lane wrote: >> when we see \if is that we do nothing but absorb text >> until we see the matching \endif. At that point we could bitch and throw >> everything away if, say, there's \elif after \else, or anything else you >> want to regard as a "compile time error". Otherwise we start execution, >> and from there on it probably has to behave as we've been discussing. >> But this'd be pretty unfriendly from an interactive standpoint, and I'm >> not really convinced that it makes for significantly better error >> reporting. > On the whole, isn't that a reasonable model to follow for psql? One thing that occurs to me after more thought is that with such a model, we could not have different lexing rules for live vs not-live branches, since we would not have made those decisions before scanning the input. This seems problematic. Even if you discount the question of whether variable expansion is allowed to change command-boundary decisions, we'd still not want backtick execution to happen everywhere in the block, ISTM. Maybe we could fix things so that backtick execution happens later, but it would be a pretty significant and invasive change to backslash command execution, I'm afraid. 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