Re: Undefined psql variables

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Undefined psql variables
Date: 2017-04-07 16:28:30
Message-ID: CAFj8pRAq1LnQchM-wH+q2awNRZjYvjxEAf73PsJb2zYtr2Lj+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2017-04-07 9:52 GMT+02:00 Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>:

>
> Hello Corey,
>
> \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?
>>
>
> My current opinion:
>
> - I'm fine if \set stays as it is, i.e. no expression.
>
> - I agree that some client-side expressions are needed, along the
> semantics suggested by Tom, i.e. definition and comparisons.
>
> - I'm really against the prefix syntax suggested by Tom
>
>
> I wish I could have an explanation about why the :?varname (or some other
> variant) syntax I suggested has a "namespace" issue.
>
> The advantage that I see is that although it is obviously ugly, it is ugly
> in the continuity of the various :["'?]varname syntaxes already offered and
> it allows to get rid of "defined varname" which does not look like SQL. A
> second advantage is that with the "defined" proposal
>

I don't think so this argument is valid - \if doesn't look like SQL too.

>
> \if defined var1 and defined var2 or defined var3 and sqlrt() >= ..
>
> Would probably never work work, as it cannot be embedded in another
> expression, while it would work with
>
> \if :?var1 and :?var2 or :?var3 and ...
>
>
I don't see any reason why first should not work and second should to work

>
> Moreover, I would like the condition syntax to be basically SQL & psql
> variables, without explicit prefixes, with a transparent decision whether
> it is evaluated client side or server side.
>
> As client-side expressions are pretty simple, ISTM that some regex could
> be used for this purpose, eg for integer and boolean comparisons:
>
> ^\s*\d+\s*(=|<>|!=|<|<=|>|>=)\s*\d+\s*$
> ^\s*(bool...)\s*(=|<>|!=)\s*(bool...)\s*$
> ^\s*(NOT\s*)?(bool...)\s*$
>
> So that one could just write the expressions without having to tell where
> it is executed, eg
>
> \if :VERSION_NUM < 110000
>
> Would lead to
>
> \if 100000 < 110000
>
> Caught by the first regex, and evaluated with a few lines of code.

I have a different opinion - the condition expression should not be SQL
necessary. This language is oriented on client side operations. What is
benefit from server side expression?

Regards

Pavel

>
>
> --
> Fabien.
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2017-04-07 16:31:45 Re: Performance issue with postgres9.6
Previous Message Heikki Linnakangas 2017-04-07 16:20:55 Re: Duplicate assignment in Unicode/convutils.pm