From: Nathan Bossart <nathandbossart@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: adam@labkey.com, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
Date: Wed, 20 Nov 2024 10:50:57 -0600
Message-ID: <Zz4TcYSNWW1_Vj--@nathan> (raw)
In-Reply-To: <158506.1732120196@sss.pgh.pa.us>
References: <Zzzdc1QLIuFoiTvE@nathan>
<3796535.1732044807@sss.pgh.pa.us>
<Zz0WPCEzx-mPvUxA@nathan>
<3976665.1732057784@sss.pgh.pa.us>
<Zz1bvchIEQPT6eTr@nathan>
<75265.1732076593@sss.pgh.pa.us>
<Zz4BxVqAZnWHFXFB@nathan>
<154104.1732118090@sss.pgh.pa.us>
<Zz4IJ041indld9jv@nathan>
<158506.1732120196@sss.pgh.pa.us>
On Wed, Nov 20, 2024 at 11:29:56AM -0500, Tom Lane wrote:
> Nathan Bossart <nathandbossart@gmail.com> writes:
>> Upthread, you mentioned that we could bypass multiple lookups unless both
>> the NAMEDATALEN-1'th and NAMEDATALEN-2'th bytes are non-ASCII. But if
>> there are encodings with the high bit set that don't require multiple bytes
>> per character, then how can we do that?
>
> Well, we don't know the length of the hypothetically-truncated
> character, but if there was one then all its bytes must have had their
> high bits set. Suppose that the untruncated name has a 4-byte
> multibyte character extending from the NAMEDATALEN-3 byte through the
> NAMEDATALEN'th byte (counting in origin zero here):
>
> [...]
>
> Now as for the shortcut cases: if C3 does not have the high bit set,
> it cannot be part of a multibyte character. Therefore the original
> encoding-aware truncation would have removed C3 and following bytes,
> but no more. The character immediately before might have been one
> byte or several, but it doesn't matter. Similarly, if C2 does not
> have the high bit set, it cannot be part of a multibyte character.
> The original truncation would have removed C3 and following bytes,
> but no more.
Oh, I think I had an off-by-one error in my mental model and was thinking
of the NAMEDATALEN-1'th byte as the last possible byte in the identifier
(i.e., name[NAMEDATALEN - 2]), whereas you meant the location where the
trailing zero would go for the largest possible all-ASCII identifier (i.e.,
name[NAMEDATALEN - 1]). Thank you for elaborating.
--
nathan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: nathandbossart@gmail.com, tgl@sss.pgh.pa.us, bertranddrouvot.pg@gmail.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: <Zz4TcYSNWW1_Vj--@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox