Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>, Srinath Reddy <srinath2133(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)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
Date: 2026-02-02 20:52:43
Message-ID: aYEOm3npcIHqLeiX@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 02, 2026 at 09:14:28AM -0500, Tom Lane wrote:
> =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
>> This is not an objection to this patch, but I don't see why we should
>> allow newlines in tablespace names if we're going to restrict them in
>> names of roles and databases. Is it only because pg_dumpall happens not
>> to dump a comment with the tablespace name on it, like we do for dbs and
>> roles? Sounds unprincipled.
>> I think keeping these things under the same rules makes the most sense.
>
> Yeah, I was thinking the same.

A while back, I did a bit of testing with a patch that disallowed line
feeds and carriage returns in all names by adding a check to namein,
namerecv, and namestrcpy. I'm not sure exactly why I stopped, but that
seemed to work relatively well, although it is a quite large hammer. I
also recall seeing this thread from 2016 [0], which I don't think has been
cited here.

In any case, even if this change goes through, we'll need to teach
applications like pg_dump to either 1) verify there are no names with \n\r
or 2) handle them appropriately for all supported server versions. IMHO
(2) is quite fragile.

[0] https://postgr.es/m/flat/CAB7nPqRbDwmrZW-W6QW6AwiL1WoZJO4XJ-b1%2B_O4xyy67zn%3DFw%40mail.gmail.com

--
nathan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-02-02 21:19:47 Re: use the malloc macros in pg_dump.c
Previous Message KAZAR Ayoub 2026-02-02 20:45:04 Re: Speed up COPY FROM text/CSV parsing using SIMD