Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cv2mU-0007Y8-H4 for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Apr 2017 14:16:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cv2mU-00020n-3c for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Apr 2017 14:16:30 +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 1cv2mS-0001yF-F4 for pgsql-hackers@postgresql.org; Mon, 03 Apr 2017 14:16:28 +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 1cv2mP-000147-GP for pgsql-hackers@postgresql.org; Mon, 03 Apr 2017 14:16:27 +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 v33EGIKG012588; Mon, 3 Apr 2017 10:16:19 -0400 From: Tom Lane To: "Daniel Verite" cc: "Fabien COELHO" , "PostgreSQL Developers" Subject: Re: Variable substitution in psql backtick expansion In-reply-to: References: Comments: In-reply-to "Daniel Verite" message dated "Mon, 03 Apr 2017 14:12:45 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12586.1491228978.1@sss.pgh.pa.us> Date: Mon, 03 Apr 2017 10:16:18 -0400 Message-ID: <12587.1491228978@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 "Daniel Verite" writes: > Let's imagine that psql would support a syntax like this: > \if [select current_setting('server_version_num')::int < 110000] > or > \if [select 1 from pg_catalog.pg_extension where extname='pgcrypto'] I really dislike this syntax proposal. It would get us into having to count nested brackets, and distinguish quoted from unquoted brackets, and so on ... and for what? It's not really better than \if sql select 1 from pg_catalog.pg_extension where extname='pgcrypto' (ie, "\if sql ...text to send to server..."). If you're worried about shaving keystrokes, make the "select" be implicit. That would be particularly convenient for the common case where you're just trying to evaluate a boolean expression with no table reference. 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