Re: pgbench: \gset and \aset should store SQL NULL as the null value

From: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgbench: \gset and \aset should store SQL NULL as the null value
Date: 2026-08-18 13:44:00
Message-ID: CAOzEurQXUi_i2x9JqxbdgoKk7a=r1Xo9k1-CPMkF9dR-xNuj4A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thank you for looking into this.

On Tue, Aug 18, 2026 at 4:46 PM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
> On the
> other hand, I think the tests could be reduced somewhat. For example,
> I don't think the tests for \aset and sorting are particularly
> necessary.

Removed them in v2. \aset goes through the same storing loop as \gset,
so the \gset cases already cover it.

> I think this change can also be seen as making \gset and \aset behave
> as one would naturally expect from the existing documentation: an SQL
> NULL result is stored as a pgbench NULL value. If so, I wonder whether
> additional documentation is needed at all. I think documentation of
> the existing behavior would be better handled in a separate patch from
> this change.

Agreed. 0001 no longer touches the documentation and 0002 has it. The
behaviors it describes apply to every variable regardless of how it
was set, so the paragraph goes next to the description of the
variable-substitution facility rather than under an individual meta
command.

> This happens with any string that cannot be converted to a value type
> supported by pgbench expressions. So I think it would be possible to
> replace an empty string returned by PQgetvalue() with "null", but if
> we are going to check for NULL anyway, I think it is better to assign
> NULL directly.

Agreed, and thanks for confirming.

I created a CF entry: https://commitfest.postgresql.org/patch/7163/

--
Shinya Kato
NTT OSS Center

Attachment Content-Type Size
v2-0001-Make-pgbench-gset-and-aset-store-SQL-NULL-as-the-.patch application/octet-stream 5.3 KB
v2-0002-doc-Describe-how-a-NULL-valued-pgbench-variable-i.patch application/octet-stream 2.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Anthonin Bonnefoy 2026-08-18 13:48:35 Re: Compression of bigger WAL records
Previous Message Amit Langote 2026-08-18 13:42:14 Re: PG19 FK fast path: OOB write and missed FK checks during batched