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

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(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-27 19:34:22
Message-ID: Z0d0PqBQGQQSlxB3@nathan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Nov 27, 2024 at 01:17:18PM -0500, Tom Lane wrote:
> I have an idea that might salvage something from what we've just
> been doing. The biggest single problem with the old behavior,
> AIUI, was the possibility of sending back encoding-corrupt names
> in connection failure reports. How about something like:
>
> * Don't truncate the names on sight (so we keep 562bee0fc1).
>
> * Truncate the names at NAMEDATALEN-1 just before catalog lookup
> (this restores the old lookup behavior, solving the current report).
>
> * In lookup-failure messages, be sure to report the un-truncated
> name (avoiding the bad-encoding problem).
>
> * Copy the correctly-truncated names from the catalog to any
> persistent storage such as MyProcPort, so that those are used
> for all post-connection purposes.

One possible issue with truncating the names after-the-fact is that hooks
like ClientAuthentication_hook will have already been called with the
untruncated names. If it's just the connection failure reports we are
worried about, then maybe we should save the "raw" names to MyProcPort
before truncating and be sure to use those in the log messages.

I attached a rough sketch of what I'm imagining. If we aren't thrilled
about adding new fields to "struct Port" in a minor release, we could just
do a straight revert on the back-branches and add that part to v18.

--
nathan

Attachment Content-Type Size
save_untruncated_names.patch text/plain 5.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-11-27 19:57:03 Re: Detection of hadware feature => please do not use signal
Previous Message Andres Freund 2024-11-27 19:32:11 Re: Build failure with GCC 15 (defaults to -std=gnu23)