Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDmnu-003BBi-IX for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Nov 2024 15:39:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tDmnt-006kRL-1h for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Nov 2024 15:39:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDmns-006kRC-Ob for pgsql-bugs@lists.postgresql.org; Wed, 20 Nov 2024 15:39:40 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDmnq-002wdA-GZ for pgsql-bugs@lists.postgresql.org; Wed, 20 Nov 2024 15:39:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4AKFdZPC152769; Wed, 20 Nov 2024 10:39:35 -0500 From: Tom Lane To: Nathan Bossart cc: Bertrand Drouvot , 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: References: <18711-7503ee3e449d2c47@postgresql.org> <3072825.1731866414@sss.pgh.pa.us> <3796535.1732044807@sss.pgh.pa.us> <3976665.1732057784@sss.pgh.pa.us> <149256.1732115451@sss.pgh.pa.us> Comments: In-reply-to Nathan Bossart message dated "Wed, 20 Nov 2024 09:32:47 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <152767.1732117175.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 20 Nov 2024 10:39:35 -0500 Message-ID: <152768.1732117175@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Wed, Nov 20, 2024 at 03:20:45PM +0000, Bertrand Drouvot wrote: >> I had in mind to "fully scan" pg_database in GetDatabaseTuple(), get th= e datname >> and encoding from FormData_pg_database and start from there the compari= son = >> with the dbname passed as an argument to GetDatabaseTuple(). Thoughts? > I was wondering if we could use the database encoding to disambiguate if= we > found multiple matches, but IIUC the identifier will be truncated using = the > encoding of the database from which it was created. Yeah, you can't really assume that a database's name is stored using the encoding of that database. And even if you did, you still can't make any assumptions about pg_role. I doubt we want to do this differently for roles than databases. We've had some past discussions about tightening all this up, like insisting that names in shared catalogs are always in UTF8. But there are downsides to that too. In any case, there is no way that a seqscan of pg_database (or pg_role) is going to be adequately performant, let alone faster than at-most-four indexed probes. We just had somebody inquiring about whether it'd be okay to create a million roles... regards, tom lane