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 1tEAgF-005etX-Bb for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2024 17:09:23 +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 1tEAgC-00HTnx-Gd for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2024 17:09:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEAgC-00HTnp-2u for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2024 17:09:20 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tEAg9-0035Fw-8q for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2024 17:09:18 +0000 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-460dce6fff9so7550761cf.1 for ; Thu, 21 Nov 2024 09:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732208956; x=1732813756; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5xzS+3vVGmhbD1yBN1xRW31Mb/iGZSxoF3J9dzjo/nY=; b=BWgmOvZC11M2gphZw++TrFNNGkT2f2tMx//NUM1K03UKKPHIYRzWJCn2Pk7MrUfXHO gwDl2lRJeSVdOO3y2tXHa2hiO1cUOJIaTC5mQW+XmbDQFocg9L7JpZTU8++KZmFLaEs1 jgixZwshhyxdXGC0sGfgBvSHCt6Wsp1pYrR3R9SmSzVkfe7+7zNWAPhRhlLRqJb62WQT TQHLYFwga/BxUnNknaXNG+KLBWVZE9exTJFdAB2Q9zLXzIOoK44cLF3MiiNmV17t9LiV GxnOsXZYaZ/KtZw/SS31Q3Qc7AcmpWOa8PlYMNKugtDncFkq3JlJN4xodK5xhbTxwJrJ ETmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732208956; x=1732813756; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5xzS+3vVGmhbD1yBN1xRW31Mb/iGZSxoF3J9dzjo/nY=; b=ZjOVaDglCf0hAPbVaN9ogJAy2LuzN3fGKKgw5cqhUN5R1G7QMBgPyqn6+tt2pj+bcr 1nWnjpIAvldQh3FuM1uo76yRIkBkvQ19BpnQQ3yUyvaETsdoKcfKxhYYshM7Mye9Ikp5 KZZL4pl9q1iWzHI/fyy3fBDmeteSR8laPwJx/3oGq/2BJ2C1w0OSyb1GGj2AWI+imX8m RMlPpIM19pzCKS2LeMkmxqxeU3SGdeey7mfpAsdjnPSM1IsNud8yJlC51fGUnDKw39Ev zLkpoNl0qELeR/u5HNXJXWNlcAJYLatu8WXGw8mS/cGoa3vhg2KRjYXsSL8tn14Nzs5Q DmOA== X-Forwarded-Encrypted: i=1; AJvYcCVB7tM9inst8qzxEgrWy88lCinKXw5bOIS4VqrYTzqBA4rCkEzXZVxwn04edSevN+oxpzV4GbqoQ5xr@lists.postgresql.org X-Gm-Message-State: AOJu0YxSU26Lh8v85QNTjbJo/AU7glGzyI7Xvv/TMi5TKZlwj3PZhfWV OeUJdbCg2op7VqYTncH+ivgHX849dHZlEH8zZduJgQD6dd3Gg3Sa X-Gm-Gg: ASbGncuQ0lB7y99UN/UF56XwUJd6I7Zi13KUfXty3sLgEvvKdnGqpAd35aqF59f1Dnk u2a5JLTIkR6T90xDd5mn3qP8Ohhvs+gqtZufNhJivG0/MEakb26ijhN3xFik77UDoi6O3A7NwLo LSJdpNFYbE7Vd0ZfubKnKLFnmcNaHlP1bD7VbAsKGxQufNxovkjw1lRd7dPYQjHyVX290g/AC7I UAxpN5JSn3YwlikCrAy/x2UmfUOZjRJDCgDN41ZwIUfbgUYLw5FWpR61TG0CdBT+y6hUCtWVZ8g qWWc0QOff91xuFvuaXY7JwO8uiNPyjetyJdr5q8O X-Google-Smtp-Source: AGHT+IEsGlPnbJfyXazCq5TfzA+JGj1X3xraoiaOht093LSyKWxcDNes1xd5L0r9DrtvpwmOoiFBGg== X-Received: by 2002:ac8:57c4:0:b0:460:acda:1bb7 with SMTP id d75a77b69052e-4647965f3ddmr88031231cf.36.1732208956196; Thu, 21 Nov 2024 09:09:16 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4653c48fbd7sm706841cf.73.2024.11.21.09.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 09:09:15 -0800 (PST) Date: Thu, 21 Nov 2024 11:09:14 -0600 From: Nathan Bossart To: Bruce Momjian Cc: Bertrand Drouvot , Tom Lane , 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 Message-ID: References: <158506.1732120196@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 21, 2024 at 11:44:44AM -0500, Bruce Momjian wrote: > On Thu, Nov 21, 2024 at 09:14:23AM -0600, Nathan Bossart wrote: >> Tom provided a concise explanation upthread [0]. My understanding is the >> same as Bertrand's, i.e., this is an easy way to rule out a bunch of cases >> where we know that we couldn't possibly have truncated in the middle of a >> multi-byte character. This allows us to avoid doing multiple pg_database >> lookups. > > Where does Tom mention anything about checking two bytes? Here [0]. And he further elaborated on this idea here [1]. > He is > basically saying remove all trailing high-bit characters until you get a > match, because once you get a match, you are have found the point of > valid truncation for the encoding. 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. > This text: > > * If the original name is too long and we see two consecutive bytes > * with their high bits set at the truncation point, we might have > * truncated in the middle of a multibyte character. In multibyte > * encodings, every byte of a multibyte character has its high bit > * set. So if IS_HIGHBIT_SET is true for both NAMEDATALEN-1 and > * NAMEDATALEN-2, we know we're in the middle of a multibyte > * character. We need to try truncating one more byte back to find the > * start of the next character. > > needs to be fixed, at a minimum, specifically, "So if IS_HIGHBIT_SET is > true for both NAMEDATALEN-1 and NAMEDATALEN-2, we know we're in the > middle of a multibyte character." Agreed, the second-to-last sentence should be adjusted to something like "we might be in the middle of a multibyte character." We don't know for sure. >> * Try to do multibyte-aware truncation (the patch at hand). > > Yes, I am fine with that, but we need to do more than the patch does to > accomplish this, unless I am totally confused. What more do you think is required? [0] https://postgr.es/m/3976665.1732057784%40sss.pgh.pa.us [1] https://postgr.es/m/158506.1732120196%40sss.pgh.pa.us -- nathan