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 1vmruw-00HClp-1T for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 11:16:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vmruu-00DU5g-1j for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 11:16:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vmruu-00DU5Y-0Y for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 11:16:29 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vmrus-00000000fIV-0JL7 for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 11:16:28 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 255977A013B; Mon, 2 Feb 2026 06:16:24 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Mon, 02 Feb 2026 06:16:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1770030983; x=1770117383; bh=4 6TtakkpfxtX2oWTM5EBpkmShlA1bYeozMWp90kB7PI=; b=JE2aRuCi0KLgxjPI1 lzeJzsGgTdWM6/9JKAshv/5O59BByIRMmpF7A/cEPp3EDmzwJERhGnUMSzpufuqT hAckoURPXVMOgbakmtM9ejUqrM0n+zPSGFXwjThYH0q5Qt/mCPIaYyOyYSoZ3vzl FKxyO7bUePZ1SO6N8jU7qplXOBlIFS/OQBKMUnd18GNrYP5Yv6OTMYIncU+ncZ/T 3jEFjF7a3zgQo/+X+lJ1N0oHKYfGMhY++ZQzX1CAhchAc4kUmG+ReroRUeIrzc3F JvNeWslO7RoP+gw3G17l6CMBl/Itw7mt77nzlLz1ecf/Z1vfKGhHxqiggC4DWAbo r7+rg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddujeejgeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvdehueffhefgueekueefheehgffhuefgfedukeejveduffeg ffekgeffffevgeehnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprhgtphhtthhopeeipdhmohguvg epshhmthhpohhuthdprhgtphhtthhopegrnhgurhgvfiesughunhhslhgrnhgvrdhnvght pdhrtghpthhtohepmhgrhhhiiehruhhnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepnh grthhhrghnuggsohhsshgrrhhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshhrihhn rghthhdvudeffeesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkh gvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehtghhl sehsshhsrdhpghhhrdhprgdruhhs X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 2 Feb 2026 06:16:23 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1770030980; bh=SEAT1mI8ZvC4+vRBFdiYgiSCgymp54UdVw4MZMWCIfQ=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=SWSq4juSI7ZIhWnn+D0sHzrJA36SbHgzPKkp03u0lOrmCDwsMfX24etw/JIgKaHM6 hX+EJ/R5uW0AalrRsiUekCJfJrfbyS0YDgpTEEpUNzadwIv7PPIMRZXOqyxSlCM7qF 9xrPasPkdsu8UO/O8K4h6oHwqRzbXMY0u1Rl6hRifH/t/e4VwFOxnfcu1e8dual8hv cfVcVBZo/R8JILGbej83Tx98osN483gJhj3A0qoeO7lEVjRpzhm7TjQoIkXoNdp56v BtVAv03dE/Cf9reYiP8JvcnaunYE1p55P1uO5nm7+lQY1us8XaoAmUJSMrAGb59vWE Vgv1ixcuB/1gQ== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id CEAF974; Mon, 02 Feb 2026 12:16:20 +0100 (CET) Date: Mon, 2 Feb 2026 12:16:20 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Mahendra Singh Thalor Cc: Tom Lane , Andrew Dunstan , Nathan Bossart , Srinath Reddy , pgsql-hackers@lists.postgresql.org Subject: Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote Message-ID: <202602021101.lguk6kclmciv@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > +void > +reject_newline_in_name(const char *objname, const char *objtype) > +{ > + /* Report error if name has \n or \r character. */ > + if (strpbrk(objname, "\n\r")) > + ereport(ERROR, > + (errcode(ERRCODE_INVALID_PARAMETER_VALUE)), > + errmsg("\"%s\" name \"%s\" contains a newline or carriage return character",objtype, objname)); > +} I think this error message doesn't work very well. Having the "database" word be an untranslatable piece of the message makes no sense to me. I would rather have the ereport() in each place where this is needed so that we can have a complete phrase to translate, and avoid this wrinkle. Alternatively you could pass the error message from the caller (to abstract away the strpbrk() call) but I'm not sure that's really all that useful. BTW, looking at generate_db in src/bin/pg_upgrade/t/002_pg_upgrade.pl I wonder why don't we reject BEL here also. (Or actually, maybe not, but I think commit 322becb6085c was wrong to lose the part of the comment that explained the reason.) > --- a/src/bin/scripts/t/020_createdb.pl > +++ b/src/bin/scripts/t/020_createdb.pl > @@ -241,6 +241,18 @@ $node->command_fails( > ], > 'fails for invalid locale provider'); > > +$node->command_fails_like( > + [ 'createdb', "invalid \n dbname" ], > + qr(contains a newline or carriage return character), > + 'fails if database name containing newline character in name' > +); > + > +$node->command_fails_like( > + [ 'createdb', "invalid \r dbname" ], > + qr(contains a newline or carriage return character),, > + 'fails if database name containing carriage return character in name' > +); Note there are two commas the the qr() line in the second stanza. Seems to be innocuous, because the test log shows # Running: createdb invalid dbname [11:57:00.942](0.012s) ok 34 - fails if database name containing newline character in name: exit code not 0 [11:57:00.942](0.000s) ok 35 - fails if database name containing newline character in name: matches # Running: createdb invalid ^M dbname [11:57:00.953](0.011s) ok 36 - fails if database name containing carriage return character in name: exit code not 0 [11:57:00.954](0.000s) ok 37 - fails if database name containing carriage return character in name: matches but it'd look nicer without those commas. Also, the "fails if ... containing" test names sound ungrammatical to me. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Always assume the user will do much worse than the stupidest thing you can imagine." (Julien PUYDT)