pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Corey Huinker <corey.huinker@gmail.com>
Cc: Greg Stark <stark@mit.edu>
Cc: Daniel Verite <daniel@manitou-mail.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Developers <pgsql-hackers@postgresql.org>
Subject: Re: Variable substitution in psql backtick expansion
Date: Mon, 17 Apr 2017 15:09:23 +0900 (JST)
Message-ID: <alpine.DEB.2.20.1704171454530.4025@lancre> (raw)
In-Reply-To: <CAFj8pRCqm-MfcwM49KsiqF_-1C_p3fNjSL1w76xkBDpdG_pnFA@mail.gmail.com>
References: <bc15034d-b421-42ac-89b1-c3485fa1728b@manitou-mail.org>
	<alpine.DEB.2.20.1704020841490.4632@lancre>
	<CAM-w4HMq2RoVg2L=GPGR3xYXKQJMsc2noCPdZjt=5eWRnmoEVQ@mail.gmail.com>
	<CAFj8pRCnVW+yxH-22yLj9NdYSuTKR3dXVvFqTZT1DPVMFkGacg@mail.gmail.com>
	<alpine.DEB.2.20.1704111546170.29476@lancre>
	<CADkLM=fKTp39o1HXk9Or_0LWb=+zarKuF3ja08EZEbzcQJ_9yg@mail.gmail.com>
	<alpine.DEB.2.20.1704120828160.9028@lancre>
	<CAFj8pRCqm-MfcwM49KsiqF_-1C_p3fNjSL1w76xkBDpdG_pnFA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>


Hello Pavel,

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 
earlier.

> 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
> message"

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.

Consider:

   \set port 5432

Then you can write:

   SELECT :port ;
   -- 5432

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:

   \if ...
     \set port 5432
   \endif

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" 
defined.

> 5. we can introduce \setexpr in psql, and \if can use pgbench expr too (the
> result of expression) must be boolean value like now

Yes.

> 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

Probably.

> 8. the psql builtin variables can be enhanced about info about processed
> rows

Yep. I've already submitted something about ROW_COUNT and such, see:

 	https://commitfest.postgresql.org/14/1103/

> 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.

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



view thread (96+ messages)  latest in thread

Message-ID: <alpine.DEB.2.20.1704171454530.4025@lancre>
Permalink:  ../alpine.DEB.2.20.1704171454530.4025@lancre/
Also on:    postgresql.org/message-id/alpine.DEB.2.20.1704171454530.4025@lancre

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: coelho@cri.ensmp.fr, pavel.stehule@gmail.com, corey.huinker@gmail.com, stark@mit.edu, daniel@manitou-mail.org, tgl@sss.pgh.pa.us
  Subject: Re: Variable substitution in psql backtick expansion
  In-Reply-To: <alpine.DEB.2.20.1704171454530.4025@lancre>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox