Re: psql: Add command to use extended query protocol

Aleksander Alekseev <aleksander@timescale.com>

From: Aleksander Alekseev <aleksander@timescale.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Tobias Bussmann <t.bussmann@gmx.net>, Corey Huinker <corey.huinker@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Date: 2024-02-16T15:15:57Z
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

Hi,

> > 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.
>
> Hmm, strange.  I had been trying to make \bind work with extended
> protocol, and my findings were that there's interactions with the code
> that was added for pipeline mode(*).  I put research aside to work on
> other things, but intended to get back to it soon ... I'm really
> surprised that it works for you here.
>
> Maybe your tests are just not extensive enough to show that it fails.
>
> (*) This is not actually proven, but Peter had told me that his \bind
> stuff had previously worked when he first implemented it before pipeline
> landed.  Because that's the only significant change that has happened to
> the libpq code lately, it's a reasonable hypothesis.

A colleague of mine is very excited about the new \bind functionality
in psql. However he is puzzled by the fact that there is no obvious
way to bind a NULL value, except for something like:

```
create table t (v text);
insert into t values (case when $1 = '' then NULL else $1 end) \bind '' \g
select v, v is null from t;
```

Maybe we should also support something like ... \bind val1 \null val3 \g ?

-- 
Best regards,
Aleksander Alekseev