Re: BUG #17350: GIST TRGM Index is broken when combining with combining INCLUDE with a string function (e.g. lower).

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17350: GIST TRGM Index is broken when combining with combining INCLUDE with a string function (e.g. lower).
Дата
Msg-id 2878790.1641058990@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #17350: GIST TRGM Index is broken when combining with combining INCLUDE with a string function (e.g. lower).  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> If I issue the 
> following lines, instead of returning 'foo' and 'bar', postgresql will
> return  two empty lines:

>     CREATE EXTENSION IF NOT EXISTS pg_trgm ;
>     CREATE TABLE t (a VARCHAR(50));
>     INSERT INTO t VALUES ('foo') ;
>     INSERT INTO t VALUES ('BAR') ;
>     CREATE INDEX test_idx ON t USING gist(lower(a) gist_trgm_ops) INCLUDE
> (a) ;
>     set enable_seqscan=off ;
>     SELECT lower(a) FROM t ;

Fascinating!  This is actually a very ancient core-planner bug,
though you could not observe it with all index types.  The GIST AM
correctly reports that it can return the value of a, but not the
value of lower(a), in an index-only scan.  indxpath.c sees that
it can still make an index-only scan, reasoning that lower(a)
can be recomputed from the returned value of a.  But then
set_indexonlyscan_references() screws up: it's told to compute
lower(a) from a tlist that includes lower(a) and a, and it
naturally figures it can just re-use the first output column.
Then at runtime you get a NULL result since that's what the index
will output for non-returnable columns.

We need some mechanism to mark that not all of the index
columns are usable at that step.  Doesn't seem terribly hard
to fix, though.  Thanks for the report!

            regards, tom lane



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

Предыдущее
От: Dmitry Dolgov
Дата:
Сообщение: Re: BUG #17344: Assert failed on queiring async_capable foreign table with inheritance
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17351: Altering a composite type created for a partitioned table can lead to a crash