Re: pgbench - refactor init functions with buffers
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Jeevan Ladhe <jeevan.ladhe@enterprisedb.com>
Cc: Dilip Kumar <dilipbalaut@gmail.com>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2019-10-24T06:33:06Z
Lists: pgsql-hackers
Attachments
- pgbench-buffer-3.patch (text/x-diff) patch
Hello Jeevan,
> +static void
> +executeStatementExpect(PGconn *con, const char *sql, const ExecStatusType
> expected, bool errorOK)
> +{
>
> I think some instances like this need 80 column alignment?
Yep. Applying the pgindent is kind-of a pain, so I tend to do a reasonable
job by hand and rely on the next global pgindent to fix such things. I
shorten the line anyway.
> + resetPQExpBuffer(&query);
> + appendPQExpBufferStr(&query, DDLINDEXes[i]);
>
> I think you can simply use printfPQExpBuffer() for the first append,
> similar to what you have used in createPartitions(), which is a
> combination of both reset and append.
It could, but it would mean switching to using a format which is not very
useful here as it uses the simpler append*Str variant.
While looking at it, I noticed the repeated tablespace addition just
afterwards, so I factored it out as well in a function.
Attached v3 shorten some lines and adds "append_tablespace".
--
Fabien.
Commits
-
pgbench: Use PQExpBuffer to simplify code that constructs SQL.
- 9796f455c38e 14.0 landed
-
Make command order in test more sensible
- ad4b7aeb8443 13.0 cited