From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | pgbench - refactor init functions with buffers |
Date: | 2019-10-22 06:32:45 |
Message-ID: | alpine.DEB.2.21.1910220826570.15559@lancre |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
pgbench-buffer-1.patch | text/x-diff | 10.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Dilip Kumar | 2019-10-22 07:19:14 | Re: pgbench - refactor init functions with buffers |
Previous Message | Maciek Sakrejda | 2019-10-22 06:18:32 | EXPLAIN BUFFERS and I/O timing accounting questions |