RE: [PATCH] pgbench: improve \sleep meta command
miyake_kouta <miyake_kouta@oss.nttdata.com>
From: miyake_kouta <miyake_kouta@oss.nttdata.com>
To: kuroda.hayato@fujitsu.com
Cc: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2021-03-08T01:51:27Z
Lists: pgsql-hackers
Attachments
- v02_pgbench_sleep.patch (text/x-diff) patch v2
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.hayato@fujitsu.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
Commits
-
pgbench: Improve error-handling in \sleep command.
- 8c6eda2d1c92 14.0 landed