Re: pgbench - refactor init functions with buffers

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgbench - refactor init functions with buffers
Date: 2019-10-22 07:19:14
Message-ID: CAFiTN-uwZo4=JW=hdstBFQetkEhNR1i8T_Wwt+bX79edYviZog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 22, 2019 at 12:03 PM Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
>
>
> Hello,
>
> While developing pgbench to allow partitioned tabled, I reproduced the
> string management style used in the corresponding functions, but was
> pretty unhappy with that kind of pattern:
>
> snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ...)
>
> However adding a feature is not the place for refactoring.
>
> This patch refactors initialization functions so as to use PQExpBuffer
> where appropriate to simplify and clarify the code. SQL commands are
> generated by accumulating parts into a buffer in order, before executing
> it. I also added a more generic function to execute a statement and fail
> if the result is unexpected.
>

- for (i = 0; i < nbranches * scale; i++)
+ for (int i = 0; i < nbranches * scale; i++)
...
- for (i = 0; i < ntellers * scale; i++)
+ for (int i = 0; i < ntellers * scale; i++)
{

I haven't read the complete patch. But, I have noticed that many
places you changed the variable declaration from c to c++ style (i.e
moved the declaration in the for loop). IMHO, generally in PG, we
don't follow this convention. Is there any specific reason to do
this?

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 李杰 (慎追) 2019-10-22 07:24:41 回复:Bug about drop index concurrently
Previous Message Fabien COELHO 2019-10-22 06:32:45 pgbench - refactor init functions with buffers