aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2023-07-03 13:18:05 -0700
committerNathan Bossart <nathan@postgresql.org>2023-07-03 13:18:05 -0700
commit562bee0fc13dc95710b8db6a48edad2f3d052f2e (patch)
treeea45d2dbec4e5fd3376e5d04ef5ab358c040b4ca
parent29cf61ade3f245aa40f427a1d6345287ef77e622 (diff)
downloadpostgresql-562bee0fc13dc95710b8db6a48edad2f3d052f2e.tar.gz
postgresql-562bee0fc13dc95710b8db6a48edad2f3d052f2e.zip
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
-rw-r--r--src/backend/postmaster/postmaster.c9
1 files changed, 0 insertions, 9 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 4c49393fc5a..0b1de9efb27 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2290,15 +2290,6 @@ retry1:
}
}
- /*
- * Truncate given database and user names to length of a Postgres name.
- * This avoids lookup failures when overlength names are given.
- */
- if (strlen(port->database_name) >= NAMEDATALEN)
- port->database_name[NAMEDATALEN - 1] = '\0';
- if (strlen(port->user_name) >= NAMEDATALEN)
- port->user_name[NAMEDATALEN - 1] = '\0';
-
if (am_walsender)
MyBackendType = B_WAL_SENDER;
else