[BUG] false positive in bt_index_check in case of short 4B varlena datum

Поиск
Список
Период
Сортировка
От Michael Zhilin
Тема [BUG] false positive in bt_index_check in case of short 4B varlena datum
Дата
Msg-id 7bdbe559-d61a-4ae4-a6e1-48abdf3024cc@postgrespro.ru
обсуждение исходный текст
Ответы Re: [BUG] false positive in bt_index_check in case of short 4B varlena datum
Re: [BUG] false positive in bt_index_check in case of short 4B varlena datum
Список pgsql-bugs
Hi,

Following example produces error raised from bt_index_check.

drop table if exists t;
create table t (v text);
alter table t alter column v set storage plain;
insert into t values ('x');
copy t to '/tmp/1.lst';
copy t from '/tmp/1.lst';
create index t_idx on t(v);
create extension if not exists amcheck;
select bt_index_check('t_idx', true);

postgres=# select bt_index_check('t_idx', true);
ERROR:  heap tuple (0,2) from table "t" lacks matching index tuple within index "t_idx"
HINT:  Retrying verification using the function bt_index_parent_check() might provide a more specific error.

As result table contains 2 logically identical tuples:
 - one contains varlena 'x' with 1B (1-byte) header (added by INSERT statement)
 - one contains varlena 'x' with 4B (4-bytes) header (added by COPY statement)
CREATE INDEX statement builds index with posting list referencing both heap tuples.
The function bt_index_check calculates fingerprints of 1B and 4B header datums,
they are different and function returns error.

The attached patch allows to avoid such kind of false positives by converting short
4B datums to 1B before fingerprinting. Also it contains test for provided case.

Thank you,
 Michael

--
Michael Zhilin
Postgres Professional
Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #18245: pg_restore accepts same output file name as input file name
Следующее
От: Alexander Lakhin
Дата:
Сообщение: Re: [BUG] false positive in bt_index_check in case of short 4B varlena datum