Re: BUG #19098: Can't create unique gist index, where pg_indexes says that WITHOUT OVERLAPS does exacly that

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: n(dot)bartek3762(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, "Paul A(dot) Jungwirth" <pj(at)illuminatedcomputing(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: BUG #19098: Can't create unique gist index, where pg_indexes says that WITHOUT OVERLAPS does exacly that
Date: 2025-10-29 15:07:24
Message-ID: 2748212.1761750444@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> I think I see what you mean:

> CREATE TABLE temp (
> id bigint NOT NULL,
> valid tstzrange NOT NULL,
> CONSTRAINT temp_pkey PRIMARY KEY (id, valid WITHOUT OVERLAPS)
> );

[ Note that this example requires having installed btree_gist ]

> SELECT pg_get_indexdef('temp_pkey'::regclass);
> pg_get_indexdef
> ----------------------------------------------------------------------
> CREATE UNIQUE INDEX temp_pkey ON laurenz.temp USING gist (id, valid)

> That CREATE INDEX statement won't work.

Yes. That is a pretty serious oversight in fc0438b4e. But I don't
think your patch proposal of just suppressing the UNIQUE keyword in
pg_get_indexdef_worker improves matters, because that presumably would
result in building an index that doesn't enforce the constraint.

I have not looked at the WITHOUT OVERLAPS patch, but if the mechanism
underlying that is just to set pg_index.indisunique, then it seems
like a reasonable answer here is to allow this syntax. The question
we have is how CREATE INDEX can know that UNIQUE is supported for
index types other than btrees.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2025-10-29 15:24:46 Re: BUG #19042: Option --help not recognized at the end of command line in pg_restore
Previous Message Kirill Reshke 2025-10-29 15:03:05 Re: BUG #19098: Can't create unique gist index, where pg_indexes says that WITHOUT OVERLAPS does exacly that