From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | louis(dot)jachiet(at)telecom-paris(dot)fr |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17350: GIST TRGM Index is broken when combining with combining INCLUDE with a string function (e.g. lower). |
Date: | 2022-01-01 17:43:10 |
Message-ID: | 2878790.1641058990@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2022-01-01 18:00:01 | BUG #17351: Altering a composite type created for a partitioned table can lead to a crash |
Previous Message | Dmitry Dolgov | 2021-12-31 12:32:11 | Re: BUG #17344: Assert failed on queiring async_capable foreign table with inheritance |