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.94.2) (envelope-from ) id 1tGhdl-000BYa-L0 for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Nov 2024 16:45:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tGhdi-006Ift-D0 for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Nov 2024 16:45:14 +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.94.2) (envelope-from ) id 1tGhdi-006Ifl-3S for pgsql-bugs@lists.postgresql.org; Thu, 28 Nov 2024 16:45:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGhdf-0001OX-FB for pgsql-bugs@lists.postgresql.org; Thu, 28 Nov 2024 16:45:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4ASGj64J2094159; Thu, 28 Nov 2024 11:45:06 -0500 From: Tom Lane To: Thomas Munro cc: Nathan Bossart , Bertrand Drouvot , Bruce Momjian , adam@labkey.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails In-reply-to: References: <659706.1732303427@sss.pgh.pa.us> <665338.1732306066@sss.pgh.pa.us> <1865227.1732723416@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Fri, 29 Nov 2024 01:22:49 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2094157.1732812306.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 28 Nov 2024 11:45:06 -0500 Message-ID: <2094158.1732812306@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro writes: > On Thu, Nov 28, 2024 at 5:04 AM Tom Lane wrote: >> (If we recorded the encoding of names in shared catalogs then this >> particular issue would be far easier to solve, but then we have >> other problems to address --- particularly, what to do if a name >> in the catalog fails to convert to the encoding we are using.) > Here is a much dumber coarse-grained way I have wondered about for > making the encoding certain, without having to do any new conversions > at all: (1) single-encoding cluster mode, shared catalogues use same > encoding as all databases, (2) multi-encoding cluster mode with > ASCII-only shared catalogues, and (3) legacy squishy/raw mode you > normally only reach by pg_upgrade. Maybe you could switch between > them with an operation that validates names. Hmm, yeah maybe that could work. The other consideration here (which we've been dancing around in this thread) is "what encoding are role and database names in startup packets presented in?" But I think your idea addresses that too: * mode 1: incoming names must be in the One True Encoding * mode 2: incoming names must be ASCII * mode 3: same wild-west behavior as always In modes 1 and 2 we could validate that the string meets our expectations (and then truncate it correctly, too). > I guess serious users of multi-encoding clusters already learn to > stick to ASCII-only role names and database names anyway, unless they > like seeing garbage? Probably ... that's been the recommendation in the small number of cases that have been reported, IIRC. That suggests that mode 2 might be the most reasonable default. regards, tom lane