Re: [HACKERS] pgbench - allow to store select results into variables

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Stephen Frost <sfrost(at)snowman(dot)net>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] pgbench - allow to store select results into variables
Date: 2018-11-17 11:06:54
Message-ID: 20181117110654.ekd2duiss4lwph6y@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-Nov-17, Fabien COELHO wrote:

>
> > I think this patch's Command->lines would benefit from using PQExpBuffer
> > (or maybe StringInfo?) for the command string instead of open-coding
> > string manipulation and allocation.
>
> Indeed it could be used, but it is not used anywhere in "pgbench": not for
> lines, not for variable subtitutions, not for the PREPARE stuff... So I did
> not think that it was time to start, I just kept the current style.
>
> Probably it could be a refactoring patch to replace all basic string stuff
> with PQExpBuffer infrastructure within pgbench.

Well, I think command handling was mostly straightforward before, but
it's not as straightforward after your patch. Also, PQExpBuffer is
already in use in pgbench when interacting with the lexer, so yeah I
think we should fix that. I don't think we should replace *ALL* string
handling in pgbench with PQExpBuffer, just the command stuff.

> > I'm not sure that Command->first_line is really all that useful. It
> > seems we go to a lot of trouble to keep it up to date. Isn't it easier
> > to chop Command->lines at the first newline when it is needed?
>
> Hmmm, it is needed quite often (about 12 times) to report errors, that would
> mean having to handle the truncation in many places, so I felt it was worth
> the trouble.

Ok, as long as we don't repeat the work during script execution.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-11-17 11:16:53 Re: New function pg_stat_statements_reset_query() to reset statistics of a specific query
Previous Message Fabien COELHO 2018-11-17 10:46:59 RE: pgbench - doCustom cleanup