RE: [PATCH] pgbench: improve \sleep meta command

From: miyake_kouta <miyake_kouta(at)oss(dot)nttdata(dot)com>
To: kuroda(dot)hayato(at)fujitsu(dot)com
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: [PATCH] pgbench: improve \sleep meta command
Date: 2021-03-08 01:51:27
Message-ID: 648872e96c8851cbb84400d4e41ebb44@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thank you for your comments!
I fixed my patch based on your comment, and attached it to this mail.

2021-03-05 12:57, kuroda(dot)hayato(at)fujitsu(dot)com wrote:

> * When the following line is input, the error message is not happy.
> I think output should be " \sleep command argument must be an
> integer...".
>
> \sleep foo
> -> pgbench: fatal: test.sql:5: unrecognized time unit, must be us, ms
> or s (foo) in command "sleep"
> \sleep foo
> ^ error found here

When argc == 2, pgbench assumes that (1) argv[1] is just a number (e.g.
\sleep 10) or (2) argv[1] is a pair of a number and a time unit (e.g.
\sleep 10ms).
So I fixed the problem as follows:
1) When argv[1] starts with a number, raises an error depending on
whether the time unit is correct or not.
2) When argv[1] does not starts with a number, raises an error because
it must be an integer.

With this modification, the behavior for input should be as follows.
"\sleep 10" -> pass
"\sleep 10s" -> pass
"\sleep 10foo" -> "unrecognized time unit" error
"\sleep foo10" -> "\sleep command argument must be an integer..." error

Is this OK? Please tell me what you think.

> * A blank is missed in some lines, for example:
>
>> + if (my_command->argc ==2)
>
> A blank should be added between a variable and an operator.

OK! I fixed it.

Regards
--
Kota Miyake

Attachment Content-Type Size
v02_pgbench_sleep.patch text/x-diff 1.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-03-08 02:18:42 Re: pgbench: option delaying queries till connections establishment?
Previous Message Masahiko Sawada 2021-03-08 01:49:20 Re: n_mod_since_analyze isn't reset at table truncation