Re: Variable substitution in psql backtick expansion
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>,
PostgreSQL Developers <pgsql-hackers@postgreSQL.org>
Date: 2017-04-02T14:38:16Z
Lists: pgsql-hackers
Hello Daniel,
>> SELECT some-boolean-expression AS okay \gset
>> \if :okay
>
> Yes, the question was whether we leave it as that for v10,
> or if it's worth a last-minute improvement for usability,
> assuming it's doable, similarly to what $subject does to backtick
> expansion for external evaluation.
My 0.02 € about server-side expressions: ISTM that there is nothing
obvious/easy to do to include these:
- how would it work, both with \set ... and \if ...?
- should it be just simple expressions or may it allow complex
queries?
- how would error detection and handling work from a script?
- should it have some kind of continuation, as expressions are
likely to be longer than a constant?
- how would they interact with possible client-side expressions?
(on this point, I think that client-side is NOT needed for "psql".
It makes sense for "pgbench" in a benchmarking context where the
client must interact with the server in some special meaningful
way, but for simple scripting the performance requirement and
logic is not the same, so server-side could be enough).
Basically quite a few questions which would not find an instantaneous
answer and associated patch.
However I agree with you that there may be minimal usability things to add
before 10, similar to Tom's backtick variable substitution.
Having some access to the client version as suggested by Pavel looks like
a good idea for the kind of script which may rely on conditionals...
Maybe other things, not sure what, though. Maybe other client settings
could be exported as variables, but the version looks like the main which
is currently missing.
Maybe a way to know what is the client current status? eg in transaction,
transaction has aborted, things like that?
--
Fabien.
Commits
-
Add psql variables showing server version and psql version.
- a6c678f018d3 10.0 landed
- 9ae9d8c1549c 11.0 landed
-
Reformat psql's --help=variables output.
- 3955c8c4eda2 11.0 landed
-
Remove reinvention of stringify macro.
- cd6baed78150 10.0 landed
-
Allow psql variable substitution to occur in backtick command strings.
- f833c847b8fa 10.0 landed