citext on exclude using gist

Started by Jean Carlo Giambastiani Lopesover 3 years ago3 messagesgeneral
Jump to latest
#1Jean Carlo Giambastiani Lopes
jean.lopes@hotmail.com.br

Hi,

I'm trying to use a citext column in the following manner without success:

create extension btree_gist;
create extension citext;
create table my_table(
foo citext,
bar numrange,
primary key (foo, bar),
exclude using gist (foo with =, bar with &&)
);

is this possible? If so, what's wrong on this snippet?

Regards,
Jean Lopes

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jean Carlo Giambastiani Lopes (#1)
Re: citext on exclude using gist

Jean Carlo Giambastiani Lopes <jean.lopes@hotmail.com.br> writes:

I'm trying to use a citext column in the following manner without success:

create extension btree_gist;
create extension citext;
create table my_table(
foo citext,
bar numrange,
primary key (foo, bar),
exclude using gist (foo with =, bar with &&)
);

is this possible? If so, what's wrong on this snippet?

btree_gist knows nothing of citext, so it's not providing any suitable
operator class.

(Code-wise it probably wouldn't be that hard to add, but I see no good way
to deal with the inter-extension connection other than to give btree_gist
a hard dependency on citext, which people wouldn't appreciate too much.)

You could fake it with

exclude using gist (lower(foo) with =, bar with &&)

which is surely conceptually ugly, but I think it gives compatible
semantics.

regards, tom lane

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#2)
Re: citext on exclude using gist

On Tue, Jul 19, 2022 at 4:43 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Jean Carlo Giambastiani Lopes <jean.lopes@hotmail.com.br> writes:

I'm trying to use a citext column in the following manner without

success:

create extension btree_gist;
create extension citext;
create table my_table(
foo citext,
bar numrange,
primary key (foo, bar),
exclude using gist (foo with =, bar with &&)
);

is this possible? If so, what's wrong on this snippet?

btree_gist knows nothing of citext, so it's not providing any suitable
operator class.

(Code-wise it probably wouldn't be that hard to add, but I see no good way
to deal with the inter-extension connection other than to give btree_gist
a hard dependency on citext, which people wouldn't appreciate too much.)

I'd expect that creating a "btree_gist_citext" extension would provide a
pathway forward here. IIUC, it could even depend on the two extensions it
is expanding upon.

David J.