Re: Undefined psql variables

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: corey(dot)huinker(at)gmail(dot)com
Cc: coelho(at)cri(dot)ensmp(dot)fr, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Undefined psql variables
Date: 2017-04-07 02:42:13
Message-ID: 20170407.114213.200465732.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 6 Apr 2017 19:21:21 -0400, Corey Huinker <corey(dot)huinker(at)gmail(dot)com> wrote in <CADkLM=eJi_4E9DuhUPq6T_-nh+eX0OY0Sa631Uu4o6cq6bq8cQ(at)mail(dot)gmail(dot)com>
corey.huinker> On Sun, Apr 2, 2017 at 4:57 PM, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
> >> I'm inclined to suggest that we should require all extensions beyond the
> >> boolean-literal case to be set up as a keyword followed by appropriate
> >> argument(s); that seems like it's enough to prevent syntax conflicts from
> >> future additions. So you could imagine
> >>
> >> \if defined varname
> >> \if sql boolean expression to send to server
> >> \if compare value operator value
> >>
> >
> > I'm still thinking:-)
> >
> > Independently of the my aethetical complaint against having a pretty
> > unusual keyword prefix syntax, how would you envision a \set assignment
> > variant? Would \if have a different expression syntax somehow?
>
> Any further thoughts?

If I read Fabien's words correctly, I think \if is different from
\set in what they take and the parameters will be interpreted.

I suppose that we are assuming a very simple parser here. If
there's a possibility to use the first parameter of '\if' as the
kind/interpretation of the following parameters, expressions in
'\if <expr>' should be distinguishable from them only by reading
the first word.

This means that expression also requires to be prefixed by a kind
word (as the "compare" in Tom's suggestion) or prefixed or
enclosed with non-word characters. '\if (<expr>)' for
example. But I'm not sure how represent 'not defined' in this
way.

Or, as Pavel suggested upthread, we could add dedicate keyword
for each type of 'if's. Such as '\if <expr>', "\if(n/un)def
<varname>' and other '\if_blah_blah's.

Otherwise we could introduce pseudo-functions instead, but this
is unnecessarily complex for this case.

| \if defined(<varname>) && execute('select version()')) ~= / 10 devel/

# Ugh.

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-04-07 02:54:17 Re: Time to change pg_regress diffs to unified by default?
Previous Message Michael Paquier 2017-04-07 02:38:16 src/interfaces/libpq shipping nmake-related Makefiles