pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: adam@labkey.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: Thu, 21 Nov 2024 09:21:16 -0500
Message-ID: <Zz9B3KQGXFCGVPXy@momjian.us> (raw)
In-Reply-To: <Zz7g2s0GSBelWmpg@ip-10-97-1-34.eu-west-3.compute.internal>
References: <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>
	<Zz4TcYSNWW1_Vj--@nathan>
	<Zz5kfP7fIuoY8I45@nathan>
	<Zz7g2s0GSBelWmpg@ip-10-97-1-34.eu-west-3.compute.internal>

On Thu, Nov 21, 2024 at 07:27:22AM +0000, Bertrand Drouvot wrote:
> +		/*
> +		 * If the original name is too long and we see two consecutive bytes
> +		 * with their high bits set at the truncation point, we might have
> +		 * truncated in the middle of a multibyte character. In multibyte
> +		 * encodings, every byte of a multibyte character has its high bit
> +		 * set. So if IS_HIGHBIT_SET is true for both NAMEDATALEN-1 and
> +		 * NAMEDATALEN-2, we know we're in the middle of a multibyte
> +		 * character. We need to try truncating one more byte back to find the
> +		 * start of the next character.
> +		 */
...
> +				/*
> +				 * If we've hit a byte with high bit clear (an ASCII byte), we
> +				 * know we can't be in the middle of a multibyte character,
> +				 * because all bytes of a multibyte character must have their
> +				 * high bits set. Any following byte must therefore be the
> +				 * start of a new character, so we can stop looking for
> +				 * earlier truncation points.
> +				 */

I don't understand this logic.  Why are two bytes important?  If we knew
it was UTF8 we could check for non-first bytes always starting with
bits 10, but we can't know that.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  When a patient asks the doctor, "Am I going to die?", he means 
  "Am I going to die soon?"





view thread (67+ messages)  latest in thread

Message-ID: <Zz9B3KQGXFCGVPXy@momjian.us>
Permalink:  ../Zz9B3KQGXFCGVPXy@momjian.us/
Also on:    postgresql.org/message-id/Zz9B3KQGXFCGVPXy@momjian.us

 · 

reply

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: bruce@momjian.us, bertranddrouvot.pg@gmail.com, nathandbossart@gmail.com, tgl@sss.pgh.pa.us, 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: <Zz9B3KQGXFCGVPXy@momjian.us>

* 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