Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1CI0-0005eu-1C for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Dec 2022 20:05:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p1CHy-0002iR-MJ for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Dec 2022 20:05:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1CHy-0002iI-9V for pgsql-bugs@lists.postgresql.org; Fri, 02 Dec 2022 20:05:38 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p1CHs-0006CS-Pp for pgsql-bugs@postgresql.org; Fri, 02 Dec 2022 20:05:37 +0000 Received: by mail-pj1-x102a.google.com with SMTP id x13-20020a17090a46cd00b00218f611b6e9so6100379pjg.1 for ; Fri, 02 Dec 2022 12:05:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=7PPRNsi2QaXEqCpefcBh7A50xVla2xzV4FFo2wvGdSs=; b=JS854W93pheXdgvWeDK9c73vLLqM3iZbBMw7XZxAux41KmVjQVjGj+pJewfh/yp1x0 Y6q66DXh+TpL11hDEwWzW4OWqXk9xtjT0eu6pVOBw7Psx2HE9wFpehw7uvRCXQrfo19V 7BgEuZVQZg9JDSkUY+p+i6fvebWw6P9YU9zgnqaVkGYaczhr2RQdXkoB4NXAYK3qu14D cvYuxdSV2NkEQ5L5UjNejrm/fGJ+Denb9U4TQEJhFqOfNesNZVgKkneQ034aV54CEWCX tIUlwc1M1xbGKDx0m7Z02XADJSwfYHNKv0K7JS72ozWC+M/hkJZ3RKrgpdHk51bgC0q8 1ozw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7PPRNsi2QaXEqCpefcBh7A50xVla2xzV4FFo2wvGdSs=; b=tijf0eHIYeNUYXYixbymWtBCPPzNTJ9j5yf/GMMu9W/Xg1r7Se/rXtb+jH0/0jRq4U /FRrNVYCLCVxMdzc6F4RZEh8RI9mN5YlhqFfgoaBt23H56dQqGqDkhMyOJkrrwK2/QS8 a5JCQQAVe0B4Eu291Fa8s1qByS89srn4lFbNCfuSNxgmCpnP4u324SXKGCTd9KlzY8lA f2DEK4zmqhmlFeaFJSBOLLEdIBa6bd6ZOA3KX/tHx6MDXA+Gs8IxZgm3h6PbHQeB7Hu8 dQN5EQ1GPXgcgfK4sZu/Ea25O7UXp9XbGMPrDosfRbnXl6ijNKBN5ZvzXZ0udsngt3DY oohQ== X-Gm-Message-State: ANoB5pmUAJGT1VUXnZ0IdXyLEHAZ57f6F8xhTxGUmU/rFIOIYv+jiCSI sMPRLFlrsvD28Pj6YB9odAcnOlnig/PmzUDf X-Google-Smtp-Source: AA0mqf7AumR0xW7z5ofWbOyeQ2Cd3fqPCWCyItwi+33MoOOG81W9Xh09GS+XEf0zP6Aue4JsAE6CCg== X-Received: by 2002:a17:90a:ff15:b0:212:ebfa:d8aa with SMTP id ce21-20020a17090aff1500b00212ebfad8aamr77274954pjb.234.1670011530213; Fri, 02 Dec 2022 12:05:30 -0800 (PST) Received: from jeff-laptop.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id jc18-20020a17090325d200b001891a17bd93sm5997822plb.43.2022.12.02.12.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 12:05:29 -0800 (PST) Message-ID: <7692740d4736e79032a5dac689cf2e304c03fa78.camel@j-davis.com> Subject: Re: hashing bpchar for nondeterministic collations is broken From: Jeff Davis To: pgsql-bugs@postgresql.org Date: Fri, 02 Dec 2022 12:05:27 -0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2022-12-01 at 12:11 -0800, Jeff Davis wrote: > I don't see any major consequences Yikes, it looks like this is a problem for BPCHAR (without typmod specified): create table p_bpchar(t bpchar collate ctest_nondet, i int) partition by hash(t); create table p0_bpchar partition of p_bpchar for values with (modulus 4, remainder 0); create table p1_bpchar partition of p_bpchar for values with (modulus 4, remainder 1); create table p2_bpchar partition of p_bpchar for values with (modulus 4, remainder 2); create table p3_bpchar partition of p_bpchar for values with (modulus 4, remainder 3); insert into p_bpchar values ('a', 0), ('a ', 1), ('a ', 2), ('a ', 3), ('a ', 4), ('a ', 5), ('a ', 6), ('a ', 7); select count(*) from p0_bpchar; -- 2 select count(*) from p1_bpchar; -- 2 select count(*) from p2_bpchar; -- 3 select count(*) from p3_bpchar; -- 1 It seems like CHAR is not a problem, even though BPCHAR is documented as an alias, because the planner treats BPCHAR->CHAR as a length coercion, which trims trailing spaces. And we just documented BPCHAR in v16 (0937f6d172), so the problem is about to be worse. I suppose as of v15 we could argue that BPCHAR is just an internal detail and that people shouldn't be creating columns of that type? --=20 Jeff Davis PostgreSQL Contributor Team - AWS