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 1tDcFM-00216H-QG for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Nov 2024 04:23:20 +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 1tDcFL-0023qv-9u for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Nov 2024 04:23:19 +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 1tDcFL-0023pY-1U for pgsql-bugs@lists.postgresql.org; Wed, 20 Nov 2024 04:23:19 +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 1tDcFI-002rbg-Mk for pgsql-bugs@lists.postgresql.org; Wed, 20 Nov 2024 04:23:18 +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 4AK4NDQ1075266; Tue, 19 Nov 2024 23:23:13 -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> <3976665.1732057784@sss.pgh.pa.us> Comments: In-reply-to Nathan Bossart message dated "Tue, 19 Nov 2024 21:47:09 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <75264.1732076593.1@sss.pgh.pa.us> Date: Tue, 19 Nov 2024 23:23:13 -0500 Message-ID: <75265.1732076593@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 06:09:44PM -0500, Tom Lane wrote: >> 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. > I'm admittedly not an expert in the multi-byte code, but since there are > encodings like LATIN1 that use a byte per character, don't we need to do > multiple lookups any time the NAMEDATALEN-1'th byte is non-ASCII? I don't think so, but maybe I'm missing something. An important property of backend-legal encodings is that all bytes of a multibyte character have their high bits set. Thus if the NAMEDATALEN-2'th byte does not have that, it is not part of a multibyte character. That's also the reason we can stop if we reach a high-bit-clear byte while backing up to earlier bytes. regards, tom lane