pgbench --partitions=0

Started by Amit Langoteover 3 years ago6 messages
#1Amit Langote
amitlangote09@gmail.com
1 attachment(s)

Hi,

I noticed that $subject causes an error in HEAD:

$ pgbench -i --partitions=0
pgbench: error: --partitions must be in range 1..2147483647

However, it works in v13 and v14, assuming no partitions.

I think the commit 6f164e6d17 may have unintentionally broken it, by
introducing this hunk:

@@ -6135,12 +6116,9 @@ main(int argc, char **argv)
                break;
            case 11:            /* partitions */
                initialization_option_set = true;
-               partitions = atoi(optarg);
-               if (partitions < 0)
-               {
-                   pg_log_fatal("invalid number of partitions:
\"%s\"", optarg);
+               if (!option_parse_int(optarg, "--partitions", 1, INT_MAX,
+                                     &partitions))
                    exit(1);
-               }

Attached a patch to fix with a test added. cc'ing Michael who
authored that commit.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

Attachments:

pgbench-accept-0-partitions.patchapplication/octet-stream; name=pgbench-accept-0-partitions.patchDownload
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 79c0cd374d..fbb74bdc4c 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6865,7 +6865,7 @@ main(int argc, char **argv)
 				break;
 			case 11:			/* partitions */
 				initialization_option_set = true;
-				if (!option_parse_int(optarg, "--partitions", 1, INT_MAX,
+				if (!option_parse_int(optarg, "--partitions", 0, INT_MAX,
 									  &partitions))
 					exit(1);
 				break;
#2Michael Paquier
michael@paquier.xyz
In reply to: Amit Langote (#1)
Re: pgbench --partitions=0

On Mon, May 16, 2022 at 11:34:41AM +0900, Amit Langote wrote:

Attached a patch to fix with a test added. cc'ing Michael who
authored that commit.

Indeed, 6f164e6d got that incorrectly. I don't really want to play
with the master branch at this stage, even if this is trivial, but
I'll fix it after the version is tagged. Thanks for the report,
Amit.
--
Michael

#3Amit Langote
amitlangote09@gmail.com
In reply to: Michael Paquier (#2)
Re: pgbench --partitions=0

On Mon, May 16, 2022 at 2:41 PM Michael Paquier <michael@paquier.xyz> wrote:

On Mon, May 16, 2022 at 11:34:41AM +0900, Amit Langote wrote:

Attached a patch to fix with a test added. cc'ing Michael who
authored that commit.

Indeed, 6f164e6d got that incorrectly. I don't really want to play
with the master branch at this stage, even if this is trivial, but
I'll fix it after the version is tagged.

Sounds good to me.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

#4Michael Paquier
michael@paquier.xyz
In reply to: Amit Langote (#3)
Re: pgbench --partitions=0

On Mon, May 16, 2022 at 02:44:47PM +0900, Amit Langote wrote:

Sounds good to me.

(I have added an open item, just in case.)
--
Michael

#5Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#4)
Re: pgbench --partitions=0

On Mon, May 16, 2022 at 03:00:51PM +0900, Michael Paquier wrote:

(I have added an open item, just in case.)

And fixed as of 27f1366.
--
Michael

#6Amit Langote
amitlangote09@gmail.com
In reply to: Michael Paquier (#5)
Re: pgbench --partitions=0

On Wed, May 18, 2022 at 9:50 Michael Paquier <michael@paquier.xyz> wrote:

On Mon, May 16, 2022 at 03:00:51PM +0900, Michael Paquier wrote:

(I have added an open item, just in case.)

And fixed as of 27f1366

Thank you.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com