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 1tDXM0-001O9X-2a for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Nov 2024 23:09:52 +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 1tDXLy-000Tob-G5 for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Nov 2024 23:09:50 +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.94.2) (envelope-from ) id 1tDXLy-000ToR-75 for pgsql-bugs@lists.postgresql.org; Tue, 19 Nov 2024 23:09:50 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDXLv-002pI9-Ui for pgsql-bugs@lists.postgresql.org; Tue, 19 Nov 2024 23:09:49 +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 4AJN9iAo3976666; Tue, 19 Nov 2024 18:09:44 -0500 From: Tom Lane To: Nathan Bossart cc: adam@labkey.com, Bertrand Drouvot , 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: <18711-7503ee3e449d2c47@postgresql.org> <3072825.1731866414@sss.pgh.pa.us> <3796535.1732044807@sss.pgh.pa.us> Comments: In-reply-to Nathan Bossart message dated "Tue, 19 Nov 2024 16:50:36 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3976664.1732057784.1@sss.pgh.pa.us> Date: Tue, 19 Nov 2024 18:09:44 -0500 Message-ID: <3976665.1732057784@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Tue, Nov 19, 2024 at 02:33:27PM -0500, Tom Lane wrote: >> I did think of a way that we could approximate encoding-correct >> truncation here, relying on the fact that what's in pg_database >> is encoding-correct according to somebody: >> ... > That's an interesting idea. That code would probably need to live in > GetDatabaseTuple(), but it seems doable. We might be able to avoid the > "mighty improbable" case by always truncating up to > MAX_MULTIBYTE_CHAR_LEN-1 times and failing if there are multiple matches, > too. Hmm ... but with short characters (e.g. LATIN1) there might be legitimately-different names that that rule would complain about. Still, the workaround remains "so spell it like it is in the catalog". On balance I think that's an improvement over what I was visualizing. Also, we could bypass the multiple lookups unless both the NAMEDATALEN-1'th and NAMEDATALEN-2'th bytes are non-ASCII, which should be rare enough to make it not much of a performance issue. One annoying point is that we also need this for role lookup. regards, tom lane