Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgfuj-0005zz-Nv for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Feb 2017 23:01:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cgfuj-0002zK-B6 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Feb 2017 23:01:37 +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 1cgftJ-0000Cq-Hl; Wed, 22 Feb 2017 23:00: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 1cgftH-0000FN-Iw; Wed, 22 Feb 2017 23:00:08 +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 v1MMxx3l021889; Wed, 22 Feb 2017 17:59:59 -0500 From: Tom Lane To: Corey Huinker cc: Fabien COELHO , Greg Stark , Erik Rijkers , Robert Haas , Daniel Verite , 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: <24063.1486671184@sss.pgh.pa.us> <5095.1486674948@sss.pgh.pa.us> <4fb8635d88c7dc907d069e15fdd1ab94@xs4all.nl> <28640.1487108678@sss.pgh.pa.us> <16856.1487797250@sss.pgh.pa.us> ! <18672.1487799954@sss.pgh.pa.us> Comments: In-reply-to Corey Huinker message dated "Wed, 22 Feb 2017 17:52:28 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21887.1487804399.1@sss.pgh.pa.us> Date: Wed, 22 Feb 2017 17:59:59 -0500 Message-ID: <21888.1487804399@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: > After some research, GetVariable is called by psql_get_variable, which is > one of the callback functions passed to psql_scan_create(). So passing a > state variable around probably isn't going to work and PsqlFileState now > looks like the best option. Ah, I see why *that* wants to know about it ... I think. I suppose you're arguing that variable expansion shouldn't be able to insert, say, an \else in a non-active branch? Maybe, but if it can insert an \else in an active branch, then why not non-active too? Seems a bit inconsistent. Anyway, what this seems to point up is that maybe we should've allowed for a passthrough "void *" argument to the psqlscan callback functions. There wasn't one in the original design but it's a fairly standard part of our usual approach to callback functions, so it's hard to see an objection to adding one now. 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