Обсуждение: I'd like to try to add a feature - guidance needed

Поиск
Список
Период
Сортировка

I'd like to try to add a feature - guidance needed

От
Daniel Heath
Дата:
Hi All,

I'd be happy to submit a patch if this sounds like a desirable feature, but I'm not really clear on the right place / people to start the discussion. I'd appreciate any pointers people have as to 'the right forum' for this.

I've frequently seen an issue in applications which store titles (eg of books, events, user profiles) where duplicate values are not properly vetted. 

The 'citext' type is helpful here, but I'd be keen to go further. 

I propose a 'titletext' type, which has the following properties when compared for equality:
 * Case insensitivity (like 'citext')
 * Only considers characters in [:alnum:] (that is, ignores spaces, punctuation, etc)

This would be useful for a range of situations where it's important to avoid entering duplicate values.

Given the discussion at https://www.postgresql.org/message-id/CAKFQuwY9u14TqG8Yzj%3DfAB0tydvvtK7ibgFEx3tegbPWsGjJpg%40mail.gmail.com I'd lean towards making this type not automatically coerce to text (to avoid surprising behaviour when comparing text to titletext)

Thanks,

Daniel Heath

Re: I'd like to try to add a feature - guidance needed

От
Tom Lane
Дата:
Daniel Heath <daniel@heath.cc> writes:
> I'd be happy to submit a patch if this sounds like a desirable feature, but I'm not really clear on the right place /
peopleto start the discussion. I'd appreciate any pointers people have as to 'the right forum' for this. 

pgsql-hackers is the right place; this is pretty off-topic for
pgsql-novice.

> I propose a 'titletext' type, which has the following properties when compared for equality:
>  * Case insensitivity (like 'citext')
>  * Only considers characters in [:alnum:] (that is, ignores spaces, punctuation, etc)

The straightforward way to do that is probably to clone contrib/citext
and modify its code for normalizing strings before comparison.

Peter Eisentraut is working[1] on allowing text collations to define their
own notions of equality (weaker than bitwise-equal), which in principle
would allow replacing citext with a special collation, and probably the
same for this idea.  However, what's involved in actually creating such a
collation, I don't know.

            regards, tom lane

[1] https://www.postgresql.org/message-id/flat/1ccc668f-4cbc-0bef-af67-450b47cdfee7%402ndquadrant.com