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

From: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'miyake_kouta' <miyake_kouta(at)oss(dot)nttdata(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: [PATCH] pgbench: improve \sleep meta command
Date: 2021-03-08 05:58:04
Message-ID: OSBPR01MB31579C1EBD2765F6D03A89BAF5939@OSBPR01MB3157.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Miyake-san,

Thank you for updating the patch.

> 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).

I see.

> 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.

I confirmed your code and how it works, it's OK.
Finally the message should be "a positive integer" in order to handle
the following case:

\set time -1
\sleep :time

-> pgbench: error: \sleep command argument must be an integer (not "-1")

Best Regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2021-03-08 05:58:46 Re: [HACKERS] logical decoding of two-phase transactions
Previous Message Masahiko Sawada 2021-03-08 05:47:57 Re: a verbose option for autovacuum