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 1tDnv4-003JH7-PL for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Nov 2024 16:51:10 +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 1tDnv3-007U2O-AR for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Nov 2024 16:51:09 +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 1tDnv2-007U2F-Vo for pgsql-bugs@lists.postgresql.org; Wed, 20 Nov 2024 16:51:09 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDnuw-002uJf-6i for pgsql-bugs@lists.postgresql.org; Wed, 20 Nov 2024 16:51:07 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7b35b1eb7e3so76808685a.1 for ; Wed, 20 Nov 2024 08:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732121461; x=1732726261; 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=nCv077C8Rc5QjmV/gxe+8uCu6fKqT6l4zCk3FqmbrZI=; b=IYPv65vXHOn8pUMT5gArAWbInyG1bBIaQ6xNmcwzfC/k43NdBveK3hM5UZCoisWdmP /f2OgyhlDr2j7ey+WG5F/UpfAJTFJvnLgJJLs6tfnX31he98igWcTTwIkkS3pyNjh2RB siPXLPDSX2JqbtWqWGlDn/SloWyM6/vZKBlVqXxKvNDmUDaItANJgJz4YKvun16KA2k2 30tjUee+TpEm0fIND0WseFF5JayOez4rEhWW0GDHs2EBVddryEJ0qaFgBZ95DCdB5z8z l1GylgGqPbjlA8ckddqLinhh2s5a+3e/FELNwLndl1J1LKwjV6uOZDzO8zvgI83NVWi2 bczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732121461; x=1732726261; 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=nCv077C8Rc5QjmV/gxe+8uCu6fKqT6l4zCk3FqmbrZI=; b=ZJXFuf2O/crdMyBDBJZ2dea9IFgc3sqLCuznC8AjFhi3bkyeZ5jMxyw54EEo5wlF5F crmSf+PhvZy7SF07m3JjVMz4EMgDUve4L5oNfLOmi6Z2ESl/qRo6/WOZerQQkQwj9eJB ftwvwZ7NgPgRHvfKilOplaJhvvN1G+L+qW5b7+PM73vUWtrx/ekR9EdMw2zYZlSSQkGV PcEpDLcsjU8Mh6ZheHVlepTVVHsIhOnH1RDoBF7pl1oshTejXqY9IKzZHAOY7rQbJaKs 2m9B5dvqBEohRJL11oYsXukeOutxC0F5MFtDy4kP6NmaqGZEgxY1PQ5kYWe2H0aC16vW jLUg== X-Forwarded-Encrypted: i=1; AJvYcCXUhW6y8PuiXEqrAJCoUAodUwpE+K6MZCxzGFrwzTvwGMmEGFZp3veqpsYuRRQjm6K7QdqJmnXGg9FV@lists.postgresql.org X-Gm-Message-State: AOJu0YzM1M11WuxEcZxjNAIr+70cfo+hdqJGhqE9vRem2f3zheNhidE0 24W2yGgD9FlMtNgc/BZSyjzC+7eVB/IngwkEz4por9mvImiaMwXT X-Google-Smtp-Source: AGHT+IHFWxb44gljFek/b1S3xWqYXpQuLOOc+Ah8ZHxblG2OrRjFDd2bsKkZgEfkGui/plx2B5qYYQ== X-Received: by 2002:a05:620a:2617:b0:7b1:3c0e:3289 with SMTP id af79cd13be357-7b50c16d0c8mr5117385a.22.1732121460782; Wed, 20 Nov 2024 08:51:00 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b485225d49sm114340485a.84.2024.11.20.08.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 08:50:59 -0800 (PST) Date: Wed, 20 Nov 2024 10:50:57 -0600 From: Nathan Bossart To: Tom Lane Cc: adam@labkey.com, Bertrand Drouvot , 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: <3796535.1732044807@sss.pgh.pa.us> <3976665.1732057784@sss.pgh.pa.us> <75265.1732076593@sss.pgh.pa.us> <154104.1732118090@sss.pgh.pa.us> <158506.1732120196@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <158506.1732120196@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Nov 20, 2024 at 11:29:56AM -0500, Tom Lane wrote: > Nathan Bossart writes: >> Upthread, you mentioned that we could bypass multiple lookups unless both >> the NAMEDATALEN-1'th and NAMEDATALEN-2'th bytes are non-ASCII. But if >> there are encodings with the high bit set that don't require multiple bytes >> per character, then how can we do that? > > Well, we don't know the length of the hypothetically-truncated > character, but if there was one then all its bytes must have had their > high bits set. Suppose that the untruncated name has a 4-byte > multibyte character extending from the NAMEDATALEN-3 byte through the > NAMEDATALEN'th byte (counting in origin zero here): > > [...] > > Now as for the shortcut cases: if C3 does not have the high bit set, > it cannot be part of a multibyte character. Therefore the original > encoding-aware truncation would have removed C3 and following bytes, > but no more. The character immediately before might have been one > byte or several, but it doesn't matter. Similarly, if C2 does not > have the high bit set, it cannot be part of a multibyte character. > The original truncation would have removed C3 and following bytes, > but no more. Oh, I think I had an off-by-one error in my mental model and was thinking of the NAMEDATALEN-1'th byte as the last possible byte in the identifier (i.e., name[NAMEDATALEN - 2]), whereas you meant the location where the trailing zero would go for the largest possible all-ASCII identifier (i.e., name[NAMEDATALEN - 1]). Thank you for elaborating. -- nathan