Re: psql: Add command to use extended query protocol

Tobias Bussmann <t.bussmann@gmx.net>

From: Tobias Bussmann <t.bussmann@gmx.net>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Corey Huinker <corey.huinker@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Date: 2023-09-14T20:26:55Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. psql: Add command to use extended query protocol

Attachments

In one of my environments, this feature didn't work as expected. Digging into it, I found that it is incompatible with FETCH_COUNT being set. Sorry for not recognising this during the betas.

Attached a simple patch with tests running the cursor declaration through PQexecParams instead of PGexec.

Alternatively, we could avoid going to ExecQueryUsingCursor and force execution via ExecQueryAndProcessResults in SendQuery (around line 1134 in src/bin/psql/common.c) when \bind is used:

	else if (pset.fetch_count <= 0 || pset.gexec_flag ||
-			 pset.crosstab_flag || !is_select_command(query))
+			 pset.crosstab_flag || !is_select_command(query) ||
+			 pset.bind_flag)

best regards
Tobias