|From:||Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>|
|To:||Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>|
|Cc:||Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Greg Stark <stark(at)mit(dot)edu>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: Variable substitution in psql backtick expansion|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
A more detailed answer to your many points.
> The pgbench expression language is perfect for us - there is not any new
> dependency - it is working on all supported platforms.
> Can be nice, if we can reuse pgbench expressions in psql - there are some
> task that should be solved first (it is definitely topic for next release)
> 1. synchronise lexers - the psql lexer doesn't supports types, but
> supports variable escaping
Yep. Probably no big deal.
> 2. move pgbench expressions to separate module
Yep, that is needed, "fe_utils" looks like the place as I pointed out
> 3. teach pgbench expressions booleans and strings
Boolean are in progress. For string, ISTM that = <> and maybe
|| would make sense.
> 4. because pgbench doesn't do early variable evaluation, implementation of
> "defined" function is easy - we can introduce some new syntax for
> implementation some bash patterns like "default value" or "own undefined
Maybe. ISTM that a :* syntax should be thought for so that it always work
where variable can be used, not only within client side expressions.
\set port 5432
Then you can write:
SELECT :port ;
And it currently works as expected in SQL. Now I think that the same
behavior is desirable for variable definition testing, i.e. with a :*
syntax the substitution can be performed everywhere, eg with:
\set port 5432
Then it would work both client side:
\let port_is_defined :?port
and also server side:
SELECT :?port AS port_is_defined \gset
However I do not think that this can be done cleanly with a "à la perl"
> 5. we can introduce \setexpr in psql, and \if can use pgbench expr too (the
> result of expression) must be boolean value like now
> 6. the psql builtin variables should be enhanced about server side and
> client side numeric versions
Yes, add some typing where appropriate.
> 7. the psql builtin variables should be enhanced about sqlstate - we are
> able to handle errors due setting ON_ERROR_STOP already
> 8. the psql builtin variables can be enhanced about info about processed
Yep. I've already submitted something about ROW_COUNT and such, see:
> The pgbench can take \if command and \setexpr command (although \setexpr
> can be redundant there, there can be nice compatibility with psql)
I now believe that "\let" is the nicest sounding close to set short
option, and indeed it should be made to work for pgbench as well to keep
things consistent, for some definition of consistent.
|Next Message||Fabien COELHO||2017-04-17 06:34:53||Re: pgbench - allow to store select results into variables|
|Previous Message||Amit Langote||2017-04-17 06:00:31||Re: Shouldn't duplicate addition to publication be a no-op?|