psql: Add more meta-commands able to use the extended protocol
Michael Paquier <michael@paquier.xyz>
psql: Add more meta-commands able to use the extended protocol Currently, only unnamed prepared statement are supported by psql with the meta-command \bind. With only this command, it is not possible to test named statement creation, execution or close through the extended protocol. This commit introduces three additional commands: * \parse creates a prepared statement using the extended protocol, acting as a wrapper of libpq's PQsendPrepare(). * \bind_named binds and executes an existing prepared statement using the extended protocol, for PQsendQueryPrepared(). * \close closes an existing prepared statement using the extended protocol, for PQsendClosePrepared(). This is going to be useful to add regression tests for the extended query protocol, and I have some plans for that on separate threads. Note that \bind relies on PQsendQueryParams(). The code of psql is refactored so as bind_flag is replaced by an enum in _psqlSettings that tracks the type of libpq routine to execute, based on the meta-command involved, with the default being PQsendQuery(). This refactoring piece has been written by me, while Anthonin has implemented the rest. Author: Anthonin Bonnefoy, Michael Paquier Reviewed-by: Aleksander Alekseev, Jelte Fennema-Nio Discussion: https://postgr.es/m/CAO6_XqpSq0Q0kQcVLCbtagY94V2GxNP3zCnR6WnOM8WqXPK4nw@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/ref/psql-ref.sgml | modified | +90 −0 |
| src/bin/psql/command.c | modified | +129 −1 |
| src/bin/psql/common.c | modified | +47 −12 |
| src/bin/psql/help.c | modified | +4 −0 |
| src/bin/psql/settings.h | modified | +13 −2 |
| src/bin/psql/tab-complete.c | modified | +3 −3 |
| src/test/regress/expected/psql.out | modified | +55 −0 |
| src/test/regress/sql/psql.sql | modified | +27 −1 |
| src/tools/pgindent/typedefs.list | modified | +1 −0 |
Documentation touched
Discussion
- [PATCH] Add additional extended protocol commands to psql: \parse and \bindx 44 messages · 2023-11-02 → 2025-06-24