Re: pgbench - minor fix for meta command only scripts

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: pgbench - minor fix for meta command only scripts
Дата
Msg-id CAB7nPqRZmRbsfdShOLPMGuqU3BeZFbYG5u0jsXv1q+LxLsP5uw@mail.gmail.com
обсуждение исходный текст
Ответ на pgbench - minor fix for meta command only scripts  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: pgbench - minor fix for meta command only scripts  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
On Sat, Jul 9, 2016 at 4:09 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>
> While testing meta-command pgbench only scripts, I noticed that there is an
> infinite loop in threadRun, which means that other tasks such as reporting
> progress do not get a chance.
>
> The attached patch breaks this loop by always returning at the end of a
> script.
>
> On "pgbench -T 3 -P 1 -f noop.sql", before this patch, the progress is not
> shown, after it is.

You may want to name your patches with .patch or .diff. Using .sql is
disturbing style :)

Indeed, not reporting the progress back to the client in the case of a
script with only meta commands is non-intuitive.

-       /* after a meta command, immediately proceed with next command */
-       goto top;
+       /*
+        * After a meta command, immediately proceed with next command...
+        * although not if last. This exception ensures that a meta command
+        * only script does not always loop in doCustom, so that other tasks
+        * in threadRun, eg progress reporting or switching client,
get a chance.
+        */
+       if (commands[st->state + 1] != NULL)
+           goto top;

This looks good to me. I'd just rewrite the comment block with
something like that, more simplified:
+       /*
+        * After a meta command, immediately proceed with next command.
+        * But if this is the last command, just leave.
+        */
-- 
Michael



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Fix Error Message for allocate_recordbuf() Failure
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: pgbench - minor doc improvements