On Fri, 28 Mar 2025 at 01:37, Mahendra Singh Thalor <mahi6...@gmail.com> wrote: > > On Thu, 27 Mar 2025 at 18:33, Álvaro Herrera <alvhe...@alvh.no-ip.org> wrote: > > > > On 2025-Mar-27, Andrew Dunstan wrote: > > > > > I don't think we can backpatch this. It's a behaviour change. > > > > I agree, we can't. > > > > Also, if we're going to enforce this rule, then pg_upgrade --check needs > > to alert users that they have a database name that's no longer valid. > > That needs to be part of this patch as well. We should also ensure that > > these are the only problem characters, which IMO means it should add a > > test for pg_dumpall that creates a database whose name has all possible > > characters and ensures that it is dumpable. > > > > -- > > Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ > > "La virtud es el justo medio entre dos defectos" (Aristóteles) > > Thanks Álvaro. > > Yes, I also agree with you. "pg_upgrade --check" should alert users regarding database names because pg_upgrade is failing if we have \n\r in dbname(old cluster). > > pg_upgrade --check: This is passing but pg_upgrade is failing. > ............ > Checking for new cluster tablespace directories ok > *Clusters are compatible* > > pg_upgrade: > ......................... > Creating dump of global objects ok > Creating dump of database schemas > shell command argument contains a newline or carriage return: "dbname='invalid > db'"
In the attached patch, instead of the above error, we will get proper ALERT for invalid names even with "pg_upgrade --check" also. *Ex:* > Performing Consistency Checks > ----------------------------- > Checking cluster versions ok > Checking database connection settings ok > Checking names of databases/users/roles fatal > > > > > > *All the database names should have only valid characters. A newline or > carriage return character is not allowed in database name. To fix this, > please rename database names with valid names. > /home/mst/pg_all/head_pg/postgres/inst/bin/data/pg_upgrade_output.d/20250328T164926.680/db_role_invalid_names.txtFailure, > exiting* > > > As a part of this patch, we can teach pg_upgrade to alert users regarding database names with invalid characters or we can keep old behavior as upgrade is already failing without this patch also. > > I will try to make a separate patch to teach "pg_upgrade --check" to alert users regarding database/user/role with \n\r in the old cluster. > > Here, I am attaching an updated patch for review. > > This patch has changes for: CREATE DATABASE, CREATE ROLE, CREATE USER and RENAME DATABASE/USER/ROLE and have some tests also. (EXCEPT RENAME test case) > > -- > Thanks and Regards > Mahendra Singh Thalor > EnterpriseDB: http://www.enterprisedb.com Here, I am attaching updated patches for review. v04_001* has the changes for CREATE DATABASE/ROLE/USER and v04_002* has the changes into pg_upgrade to give ALERTS for invalid names. -- Thanks and Regards Mahendra Singh Thalor EnterpriseDB: http://www.enterprisedb.com
v04_002-add-handling-to-pg_upgrade-to-report-alert-for-invalid-names.patch
Description: Binary data
v04_001_don-t-allow-newline-or-carriage-return-in-db-user-role-names.patch
Description: Binary data