Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, adam(at)labkey(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
Date: 2024-11-22 07:45:39
Message-ID: Z0A2o+dS0MqDE2Fs@ip-10-97-1-34.eu-west-3.compute.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Thu, Nov 21, 2024 at 12:14:47PM -0600, Nathan Bossart wrote:
> On Thu, Nov 21, 2024 at 01:05:38PM -0500, Bruce Momjian wrote:
> > On Thu, Nov 21, 2024 at 11:09:14AM -0600, Nathan Bossart wrote:
> >> Yes, we still need to do that if it's possible the truncation wiped out
> >> part of a multi-byte character. But it's not possible that we truncated
> >> part of a multi-byte character if the NAMEDATALEN-1'th or NAMEDATALEN-2'th
> >> byte is ASCII, in which case we can avoid doing extra lookups.
> >
> > Why would you check for two characters at the end rather than just a
> > normal check in the main loop?
>
> It might be possible to integrate this check into the loop, which could
> potentially be cleaner. The reason I didn't at first is because it
> requires checking a byte that we will have already truncated away. We have
> to look at the original, non-truncated string for that. I'll give it a try
> (unless Bertrand beats me to it).

> >
> > I think the IS_HIGHBIT_SET needs to be integrated into the 'for' loop
> > more clearly; the 'if' check plus the comment above it is just
> > confusing.
>
> Got it. Thank you for reviewing.

What about something like in v3 attached? (I did a few tests and that seems to
work as expected).

If that's ok I can also look at the role part.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v3-0001-attempt-multibyte-aware-truncation-of-database-na.patch text/x-diff 3.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2024-11-22 10:11:42 Re: Detection of hadware feature => please do not use signal
Previous Message Tom Lane 2024-11-22 04:53:49 Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails