Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZSju-0002Jl-Kf for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Feb 2017 01:32:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cZSjt-0003FJ-Ux for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Feb 2017 01:32:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZSjt-0003EY-1Z; Fri, 03 Feb 2017 01:32:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZSjp-0001mK-Ov; Fri, 03 Feb 2017 01:32:36 +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 v131WNF4003110; Thu, 2 Feb 2017 20:32:23 -0500 From: Tom Lane To: Corey Huinker cc: Jim Nasby , Fabien COELHO , Erik Rijkers , Daniel Verite , PostgreSQL , pgsql-hackers-owner@postgresql.org Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless) In-reply-to: References: <1084.1485886511@sss.pgh.pa.us> Comments: In-reply-to Corey Huinker message dated "Thu, 02 Feb 2017 18:29:38 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3108.1486085543.1@sss.pgh.pa.us> Date: Thu, 02 Feb 2017 20:32:23 -0500 Message-ID: <3109.1486085543@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 Corey Huinker writes: >> As it is, I've added interactive mode psql_error notifications about the >> resulting branching state of any branching commands, and any attempt to >> send non-branching commands or queries while in an inactive branch will >> generate a psql_error saying that the command was ignored. Waiting til I >> get what should or shouldn't be done about prompts before issuing the next >> patch revision. On reflection, it seems fairly improbable to me that people would use \if and friends interactively. They're certainly useful for scripting, but would you really type commands that you know are going to be ignored? Therefore, I don't think we should stress out about fitting branching activity into the prompts. That's just not the use-case. (Note: we might well have to reconsider that if we get looping, but for now it's not a problem.) Moreover, if someone is confused because they don't realize they're inside a failed \if, it's unlikely that a subtle change in the prompt would help them. So your more in-the-face approach of printing messages seems good to me. > So far, interactive branching information will look like this (it prints on > every branching command and on every ignored command): This seems more or less reasonable, although: > # \endif > active \endif, executing commands looks a bit weird. Maybe instead say "exited \if, executing commands"? BTW, what is your policy about nesting these things in include files? My immediate inclination is that if we hit EOF with open \if state, we should drop it and revert to the state in the surrounding file. Otherwise things will be way too confusing. 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