Refactor script execution state machine in pgbench

Enterprise / PostgreSQL - Heikki Linnakangas [iki.fi] - 26 September 2016 02:56 UTC

The doCustom() function had grown into quite a mess. Rewrite it, in a more explicit state machine style, for readability.

This also fixes one minor bug: if a script consisted entirely of meta commands, doCustom() never returned to the caller, so progress reports with the -P option were not printed. I don't want to backpatch this refactoring, and the bug is quite insignificant, so only commit this to master, and leave the bug unfixed in back-branches.

Review and original bug report by Fabien Coelho.

Discussion:

12788ae Refactor script execution state machine in pgbench.
src/bin/pgbench/pgbench.c | 1106 +++++++++++++++++++++++++++------------------
1 file changed, 661 insertions(+), 445 deletions(-)

Upstream: git.postgresql.org


  • Share