Re: psql: Add command to use extended query protocol - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: psql: Add command to use extended query protocol
Date
Msg-id CADkLM=fbX7NiEzjPoX97hw4bKu-_XbbR2e-Q-+3uzx+51_yH-w@mail.gmail.com
Whole thread Raw
In response to Re: psql: Add command to use extended query protocol  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: psql: Add command to use extended query protocol
List pgsql-hackers


what about introduction new syntax for psql variables that should be passed as bind variables.

I thought about basically reserving the \$[0-9]+ space as bind variables, but it is possible, though unlikely, that users have been naming their variables like that.

It's unclear from your example if that's what you meant, or if you wanted actual named variables ($name, $timestamp_before, $x).

Actual named variables might cause problems with    CREATE FUNCTION AS ... $body$ ... $body$; as well as the need to deduplicate them.

So while it is less seamless, I do like the \bind x y z \g idea because it requires no changes in variable interpolation, and the list can be terminated with a slash command or ;

To your point about forcing extended query protocol even when no parameters are, that would be SELECT 1 \bind \g

It hasn't been discussed, but the question of how to handle output parameters seems fairly straightforward: the value of the bind variable is the name of the psql variable to be set a la \gset.






 

pgsql-hackers by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Next
From: Pavel Luzanov
Date:
Subject: Re: Add proper planner support for ORDER BY / DISTINCT aggregates