Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2Qcx-000HS0-09 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2026 09:22:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2Qct-00HQ4f-22 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2026 09:22:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2Qct-00HQ4W-0h for pgsql-hackers@lists.postgresql.org; Tue, 17 Mar 2026 09:22:11 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2Qcp-00000000A0h-2wGa for pgsql-hackers@lists.postgresql.org; Tue, 17 Mar 2026 09:22:10 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-8cd79e43da3so579850985a.1 for ; Tue, 17 Mar 2026 02:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773739328; cv=none; d=google.com; s=arc-20240605; b=ciGIMXtGLgiTUVjKS32BJoxavSvY/ssnnL+0HMPRPygyq2xdZZvv9lzeNCkK2jOMMM Whb/YgEXegS1l8Vh+2dlc3zRBq1kezFT6stmRtocCC2lNpqBXlHgUingd9y8asTZrJFT Buw+9NvQswgsJ3ay8fK310QyirrJ/LcI55P4SXfa37MvEqB3Yod6AcmHUcJ4Vdhssv1t cLoIGcSvUwQBRYBbePNJ9NYlXsANTAbtVkujlEEBThD2VQvJiMSmVNz5nnvJRmngZxR6 VoqT6FzU1Hsq2942Rp3FZTXQxnbWZXRzf2NupeIa0xPhpSGnhQ4g4U9XoXfQS9pB0tbt VsUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=J7JuEQ2luMn8dwNkFjNl/R1g8SSLYlhcbpJhveVh3Xs=; fh=Z+Yn4mu52gDDtRxq61ajk9Tx8YHr1zoukeuBecbI9CQ=; b=L3EDn3XJdVwvuACMVsr12iMcAYZDXgMq6df4d8RqyEH/LhBHehKqYb5YWPqDnApvw1 g4zGNS2uCWTsYDzsJuWrm2Dc7EP15Ytt2i8EzDd+vkP3mFNPJEhQlofOuSn3tJxlTFaM I0aQohxDC2KK6FJQhZjcG3FKwUYfZ8AcMIHT8GWV8JSru8kVqeAN56EkaQpwBi6X05M2 PII95X29EQPNpc48yed6lBHCqT9a0db4UAzbK9cZYAFM2bZKjky4fDiK9CtzzH2aoeOQ FAbEAw3ArbYuMJgVMEt01QT2mNTlvDdlYTI+2MwcKEMRnVK5yq+7YcD/D9h88V20MIRO mr8w==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773739328; x=1774344128; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=J7JuEQ2luMn8dwNkFjNl/R1g8SSLYlhcbpJhveVh3Xs=; b=ewpsK0cGTYgb9VQxplKHMNOecA4ICNs2vUVO0BtWhu7nqEk9A7akAZ/XLzc1OC3DVl FSJGCEG/kKd0H57jK37FVjpG4AqrFO13HgPbAtvSNzWpnfVaeajxa0gYlLq8ppmE14GZ lNG4PBsM00jdai9LYB9/b8FRX6xjPtx8VzvG9vFb8pClunWJxZdr2NgRpbxm2dCF7OT8 bFOHVVxzJmEW9dt/K6F+JMAHUtwBct4HnqpLf5pPoOaPeVqcIJaZBIZ+Eqh1XWSjlMMP b/0Ma3fT8gFtS00fAfhYJdeBPdd2uZBDPobweWV5mmCpobagqDrUbwzeqqJ4AmBFUOev NA2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773739328; x=1774344128; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=J7JuEQ2luMn8dwNkFjNl/R1g8SSLYlhcbpJhveVh3Xs=; b=koaKeqtoK/ewgpLsdUMePg8MCWmuUCyw1vbrdoTH4Y7KmlunGYJREeNejpQc5+7JEp 3zleCS1DkdwfjRCe+KfyHuxIqR4AN46ioKCxMzWCosS7bnP/eco/h1xfYmywPmOHbvnO IoIWXN1yyVv0gNL5fv7N0R+ZVzbEHJbzwl1dKpZ+KcMxfMkcJJx0x2i4quOIR8pWTT2V H4iJVWnojuRJPh9279k0YWD2GooOfkkgDeEkFF1MudYkl7ne4edtsCB+rsnAqHYIHCbY x0twSyWP0mr8ZqeqoCJ7w/ugDFJA0/Np/ZE0gVN9s5HeRPKekOXpqaq8JgawDLtGGlts Biag== X-Forwarded-Encrypted: i=1; AJvYcCW4zjgxwctoPgGbTFxVPgkY9zHHMZmnckJwrCvwIioX3OovWhx9e42vYFmTpxKHD5swZjUlcilbxuh3PR28@lists.postgresql.org X-Gm-Message-State: AOJu0YxhzA11ab/pU6O8zYgl9FAxYja4KdGCOsvy/wrTa4S8gDO/P4nu RJ9p8PIUCXSW/BsSL5PGfX4L+UglDsxW5srBXQ5wmKO3ettTc8nOIiVNxqhxzb3weow9z7SRNfH eYs8Xb5G6+GfwzudV+Qvup5lknu2Cy1Y= X-Gm-Gg: ATEYQzwWmkyBtlI029ICWjXWg+cqMQvqkmRjyhUD+CoZWoS1N6cDPQ6+ffOLBWq+RJ8 oIKA9S8GmwcTtwmZAI3HGXpColBT3CXoQx81ozbkAf8i2en3tZir/54AyttZeYF0EIhp7JkBsPm ASF681Xi1Ex7Si/h8xwHstZUxV9QuUF8a2q/tek2guaYxzx6D8TBIhT+CM5dMP/h7/ktIHB+U/I 1LaNobA2QQOOJQq0KKCB4VLtbs2XtoKXWozYDwohaeb2fNJKxQAMdkwdyzufGGgl42ywT6anB3h yQfqZADT X-Received: by 2002:a05:620a:298f:b0:8ca:3d7c:e74c with SMTP id af79cd13be357-8cdb5b7ccbfmr2057334685a.69.1773739328059; Tue, 17 Mar 2026 02:22:08 -0700 (PDT) MIME-Version: 1.0 References: <1d66a1e5-ce44-448b-8407-31d5ed9bc10d@dunslane.net> In-Reply-To: From: Mahendra Singh Thalor Date: Tue, 17 Mar 2026 14:51:56 +0530 X-Gm-Features: AaiRm53RpIpn0qNYNy74EFHA9oFtyoChLZXofxRCH-2HM2_uipokOZsl2WoMjCs Message-ID: Subject: Re: pg_restore --format= option(without any value) should report an error as pg_dump is reporting an error To: Nathan Bossart Cc: Andrew Dunstan , PostgreSQL Hackers Content-Type: multipart/mixed; boundary="00000000000092d8b0064d34de3f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000092d8b0064d34de3f Content-Type: multipart/alternative; boundary="00000000000092d8ae064d34de3d" --00000000000092d8ae064d34de3d Content-Type: text/plain; charset="UTF-8" Thanks Nathan for the review and feedback. On Tue, 17 Mar 2026 at 01:04, Nathan Bossart wrote: > > On Sun, Mar 15, 2026 at 10:32:11PM +0530, Mahendra Singh Thalor wrote: > > Here, I am attaching an updated patch for the review. I removed the > > length check for host, port and format in pg_restore as we don't have > > check in pg_dump also. > > Looks generally reasonable to me. > > > I think we don't need any test cases for host and port. > > Why not? I did some more testing and found that if there is an empty string with --port/--host, then we don't report any error because we don't validate empty strings. This looks weird to me but this is happening with all tools so I was not adding any test case for --host and --port. Please see the test cases. *test case1: ./psql -d postgres --port* ./psql: option '--port' requires an argument psql: hint: Try "psql --help" for more information. *test case 2: ./psql -d postgres --port=* psql (19devel) Type "help" for help. postgres=# \q *test case 3: ./psql -d postgres --port= 9* psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "9" does not exist In case 2 and 3, empty string is considered as valid value for --port and the same is happening with --host and other options also. I think we should add checks for all the tools to validate empty strings (tools should report errors as value is required with these arguments.) Please add your opinion. > > > If we want to backpatch, then I can make patches for back branches but > > as of now, I am uploading a patch for master only. > > -1 for back-patching. --format seems to have been broken since pg_restore > was first committed in 2000 (commit 500b62b057), so I don't sense any > urgency here. Not to mention that someone might be relying on the current > behavior. Okay. I agree with you. > > +command_fails_like( > > + [ 'pg_restore', '-f -', '-F', 'p' ], > > + qr/\Qpg_restore: error: archive format "p" is not supported; please use psql\E/, > > + 'pg_restore: unrecognized archive format p|plain'); > > How does this test relate to this change? > > -- > nathan Fixed. I removed this test case from the current patch. Here, I am attaching an updated patch. -- Thanks and Regards Mahendra Singh Thalor EnterpriseDB: http://www.enterprisedb.com --00000000000092d8ae064d34de3d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks Nathan for the review and feedback.

On Tue, = 17 Mar 2026 at 01:04, Nathan Bossart <nathandbossart@gmail.com> wrote:
>
> On Sun, M= ar 15, 2026 at 10:32:11PM +0530, Mahendra Singh Thalor wrote:
> > = Here, I am attaching an updated patch for the review. I removed the
>= > length check for host, port and format in pg_restore as we don't = have
> > check =C2=A0in pg_dump also.
>
> Looks genera= lly reasonable to me.
>
> > I think we don't need any te= st cases for host and port.
>
> Why not?

I did some more= testing and found that if there is an empty string with --port/--host, the= n we don't report any error because we don't validate empty strings= . This looks weird to me but this is happening with all tools so I was not = adding any test case for --host and --port.

Please see the test case= s.
test case1: ./psql -d postgres --port
./psql: option '-= -port' requires an argument
psql: hint: Try "psql --help&q= uot; for more information.

test case 2:=C2=A0 ./psql= -d postgres --port=3D
psql (19devel)
Type "help" = for help.
postgres=3D# \q

test case 3:=C2=A0 ./psql -d postgre= s --port=3D 9
psql: error: connection to server on socket "/tmp= /.s.PGSQL.5432" failed: FATAL: =C2=A0role "9" does not exist=

In case 2 and 3, empty string is considered as va= lid value for --port and the same is happening=C2=A0with --host and other o= ptions also. I think we should add checks for all the tools to validate emp= ty strings (tools should report errors as value is required with these argu= ments.)

Please add your opinion.

>
> > If we want to backpatch, then I can make patches = for back branches but
> > as of now, I am uploading a patch for ma= ster only.
>
> -1 for back-patching. =C2=A0--format seems to ha= ve been broken since pg_restore
> was first committed in 2000 (commit= 500b62b057), so I don't sense any
> urgency here.=C2=A0 Not to m= ention that someone might be relying on the current
> behavior.
Okay. I agree with you.

> > +command_fails_like(
> >= ; + =C2=A0 =C2=A0 [ 'pg_restore', '-f -', '-F', = 9;p' ],
> > + =C2=A0 =C2=A0 qr/\Qpg_restore: error: archive fo= rmat "p" is not supported; please use psql\E/,
> > + =C2= =A0 =C2=A0 'pg_restore: unrecognized archive format p|plain');
&= gt;
> How does this test relate to this change?
>
> --> nathan

Fixed. I removed this test case from the current patch.=

Here, I am attaching an updated patch.

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB:= http://www.enterprisedb.com
--00000000000092d8ae064d34de3d-- --00000000000092d8b0064d34de3f Content-Type: text/x-patch; charset="US-ASCII"; name="v04-pg_restore-format-host-port-options-should-validate-all-values.patch" Content-Disposition: attachment; filename="v04-pg_restore-format-host-port-options-should-validate-all-values.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_mmueiuey0 RnJvbSBlODhiYWFlMWU4ODMxYmVkYTM2Y2IwZTZmNTYxODE2ZTE1NjU4ODYyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYWhlbmRyYSBTaW5naCBUaGFsb3IgPG1haGk2cnVuQGdtYWls LmNvbT4KRGF0ZTogVHVlLCAxNyBNYXIgMjAyNiAxNDozNToxNSArMDUzMApTdWJqZWN0OiBbUEFU Q0hdIHBnX3Jlc3RvcmUgLUYvLS1mb3JtYXQsIC1oLy0taG9zdCwgL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