Re: Variable substitution in psql backtick expansion

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: 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
Date: 2017-04-02 14:38:16
Message-ID: alpine.DEB.2.20.1704021617400.4632@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dong Yuan 2017-04-02 14:54:50 [GSoC] Question about "Explicitly support predicate locks in index access methods besides btree"
Previous Message Daniel Verite 2017-04-02 13:31:02 Re: Variable substitution in psql backtick expansion