Re: pgbench: extend variable usage in scripts

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench: extend variable usage in scripts
Date: 2025-08-29 07:27:36
Message-ID: CAFj8pRA1mPTdKAZsoJzW3NLq1C8xuKXTcN8iXESJrr5zLFto_w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

pá 29. 8. 2025 v 9:23 odesílatel Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> napsal:

> Hi,
>
> I would like to propose patches to extend variable usage in pgbench
> scripts.
>
> * 0001: Allow variables to be used as an SQL literal or identifier
>
> Currently, variables in pgbench scripts are expanded always without
> quotes, so they cannot be used as SQL literals or identifiers.
> This patch allows the use of :'var' and :"var" in addition to :var
>
> However, they can used only in SQL commands, not in the arguments of
> meta-commands, since exprscan.l (the lexical scanner for pgbench backslash
> commands) cannot currently handle quoted values.
>
> Also, we have to use \aset, \gset or -D option to assign a string to a
> varialbe,
> since pgbench's \set command cannot recognize text values in its arguments.
>
> * 0002: Add syntax for variable exisitence check
>
> Currently, pgbench does not support :{?var} syntax to check whether the
> variable
> is defined or not. This patch adds support for this syntax in meta-command
> arguments.
> This is useful for checking if \aset set the result to the variable or not.
>
> However, it cannot be used in SQL statements for now.
>
>
> Some of the current limitations described above might be relaxed in the
> future, but
> for now, I would like to ask for initial feedback on this proposal.
>

+1

Regards

Pavel

>
> Regards,
> Yugo Nagata
>
> --
> Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Роман Хапов 2025-08-29 07:31:21 Re: pg_dump: fix memory leak
Previous Message Pavel Stehule 2025-08-29 07:25:47 Re: Assert single row returning SQL-standard functions