Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
От | Tom Lane |
---|---|
Тема | Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails |
Дата | |
Msg-id | 3072825.1731866414@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | BUG #18711: Attempting a connection with a database name longer than 63 characters now fails (PG Bug reporting form <noreply@postgresql.org>) |
Ответы |
Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
|
Список | pgsql-bugs |
PG Bug reporting form <noreply@postgresql.org> writes: > For many years, our test infrastructure has used database names that are > longer than the stated maximum length of 63 characters. The PostgreSQL > server simply truncates these names to 63 characters in all operations and > everything works fine. Starting with 17.x, our application is able to CREATE > and ALTER databases with long names, but all connection attempts using them > fail with an error: database "<very long name>" does not exist Yeah, this was an intentional change in v17: commit 562bee0fc13dc95710b8db6a48edad2f3d052f2e Author: Nathan Bossart <nathan@postgresql.org> Date: Mon Jul 3 13:18:05 2023 -0700 Don't truncate database and user names in startup packets. Unlike commands such as CREATE DATABASE, ProcessStartupPacket() does not perform multibyte-aware truncation of overlength names. This means that connection attempts might fail even if the user provides the same overlength names that were used in CREATE DATABASE, CREATE ROLE, etc. Ideally, we'd do the same multibyte- aware truncation in both code paths, but it doesn't seem worth the added complexity of trying to discover the encoding of the names. Instead, let's simply skip truncating the names in the startup packet and let the user/database lookup fail later on. With this change, users must provide the exact names stored in the catalogs, even if the names were truncated. This reverts commit d18c1d1f51. Author: Bertrand Drouvot Reviewed-by: Kyotaro Horiguchi, Tom Lane Discussion: https://postgr.es/m/07436793-1426-29b2-f924-db7422a05fb7%40gmail.com As said, the difficulty is that we don't know what encoding the incoming name is meant to be in, and with multibyte encodings that matters. The name actually stored in the catalog might be less than 63 bytes long if it was truncated in a multibyte-aware way, so that the former behavior of blindly truncating at 63 bytes can still yield unexpected no-such-database results. I can imagine still performing the truncation if the incoming name is all-ASCII, but that seems like a hack. The world isn't nearly as ASCII-centric as it was in 2001. regards, tom lane
В списке pgsql-bugs по дате отправления: