From: | Srinath Reddy <srinath2133(at)gmail(dot)com> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | 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: | 2025-03-26 12:36:30 |
Message-ID: | CAFC+b6ocP-8VtvvgVU8npVPp4cc379DvDkRjdRKUc+fa2fKwwg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
./psql postgres
Hi,
On Wed, Mar 26, 2025 at 5:55 PM Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> You can still create a database with these using "CREATE DATABASE" though.
> Shouldn't we should really be preventing that?
>
yes, solution 1 which i mentioned prevents these while we are using "CREATE
DATABASE".
/*
* Create a new database using the WAL_LOG strategy.
@@ -741,6 +742,13 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
CreateDBStrategy dbstrategy = CREATEDB_WAL_LOG;
createdb_failure_params fparms;
+ /* Report error if dbname have newline or carriage return in name. */
+ if (is_name_contain_lfcr(dbname))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE)),
+ errmsg("database name contains a newline or carriage return character"),
+ errhint("newline or carriage return character is not allowed in database
name"));
+
psql (18devel)
Type "help" for help.
postgres=# create database "test
postgres"# lines";
ERROR: database name contains a newline or carriage return character
HINT: newline or carriage return character is not allowed in database name
Thanks and regards,
Srinath Reddy Sadipiralla,
EnterpriseDB: http://www.enterprisedb.com
postgres=#\q
From | Date | Subject | |
---|---|---|---|
Next Message | cca5507 | 2025-03-26 12:51:30 | Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state |
Previous Message | Pavel Stehule | 2025-03-26 12:35:37 | Re: Allow default \watch interval in psql to be configured |