Re: should check collations when creating partitioned index

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: should check collations when creating partitioned index
Дата
Msg-id 6f4dbc555c58ba5b2db1a3dd94944b6f2a4f33f6.camel@cybertec.at
обсуждение исходный текст
Ответ на should check collations when creating partitioned index  (Peter Eisentraut <peter@eisentraut.org>)
Ответы Re: should check collations when creating partitioned index  (Peter Eisentraut <peter@eisentraut.org>)
Список pgsql-hackers
On Mon, 2023-11-13 at 10:24 +0100, Peter Eisentraut wrote:
>       * If this table is partitioned and we're creating a unique index, primary
>       * key, or exclusion constraint, make sure that the partition key is a
>       * subset of the index's columns.  Otherwise it would be possible to
>       * violate uniqueness by putting values that ought to be unique in
>       * different partitions.
>
> But this currently doesn't check that the collations between the
> partition key and the index definition match.  So you can construct a
> unique index that fails to enforce uniqueness.
>
> Here is a partitioned case that doesn't work correctly:
>
> create collation case_insensitive (provider=icu,
> locale='und-u-ks-level2', deterministic=false);
> create table t1 (a int, b text) partition by hash (b);
> create table t1a partition of t1 for values with (modulus 2, remainder 0);
> create table t1b partition of t1 for values with (modulus 2, remainder 1);
> create unique index i1 on t1 (b collate case_insensitive);
> insert into t1 values (1, 'a'), (2, 'A');  -- this succeeds
>
> The attached patch adds the required collation check.  In the example,
> it would not allow the index i1 to be created.

The patch looks good, but I think the error message needs love:

> +        ereport(ERROR,
> +            errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> +            errmsg("collation of column \"%s\" does not match between partition key and index definition",
> +                   NameStr(att->attname)));

"does not match between" sounds weird.  How about

  collation of index column \"%s\" must match collation of the partitioning key column

This will be backpatched, right?  What if somebody already created an index like that?
Does this warrant an entry in the "however" for the release notes, or is the case
exotic enough that we can assume that nobody is affected?

Yours,
Laurenz Albe



В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Christensen
Дата:
Сообщение: Re: [PATCHES] Post-special page storage TDE support
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [PATCHES] Post-special page storage TDE support