From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-bugs@postgresql.org
Subject: Re: hashing bpchar for nondeterministic collations is broken
Date: Fri, 02 Dec 2022 12:05:27 -0800
Message-ID: <7692740d4736e79032a5dac689cf2e304c03fa78.camel@j-davis.com> (raw)
In-Reply-To: <eb83d0ac7b299eb08f9b900dd08a5a0c5d90e517.camel@j-davis.com>
References: <eb83d0ac7b299eb08f9b900dd08a5a0c5d90e517.camel@j-davis.com>
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?
--
Jeff Davis
PostgreSQL Contributor Team - AWS
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: pgsql@j-davis.com
Subject: Re: hashing bpchar for nondeterministic collations is broken
In-Reply-To: <7692740d4736e79032a5dac689cf2e304c03fa78.camel@j-davis.com>
References: <eb83d0ac7b299eb08f9b900dd08a5a0c5d90e517.camel@j-davis.com> <7692740d4736e79032a5dac689cf2e304c03fa78.camel@j-davis.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox