pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: psql: Add more meta-commands able to use the extended protocol
Date: Thu, 22 Aug 2024 07:29:39 +0000
Message-ID: <E1sh2GJ-000tRV-Lm@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d55322b0da60a8798ffdb8b78ef90db0fb5be18e

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml     |  90 +++++++++++++++++++++++++
src/bin/psql/command.c             | 130 ++++++++++++++++++++++++++++++++++++-
src/bin/psql/common.c              |  59 +++++++++++++----
src/bin/psql/help.c                |   4 ++
src/bin/psql/settings.h            |  15 ++++-
src/bin/psql/tab-complete.c        |   6 +-
src/test/regress/expected/psql.out |  55 ++++++++++++++++
src/test/regress/sql/psql.sql      |  28 +++++++-
src/tools/pgindent/typedefs.list   |   1 +
9 files changed, 369 insertions(+), 19 deletions(-)



Message-ID: <E1sh2GJ-000tRV-Lm@gemulon.postgresql.org>
Permalink:  ../E1sh2GJ-000tRV-Lm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sh2GJ-000tRV-Lm@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: psql: Add more meta-commands able to use the extended protocol
  In-Reply-To: <E1sh2GJ-000tRV-Lm@gemulon.postgresql.org>

* 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