pg_variables icon indicating copy to clipboard operation
pg_variables copied to clipboard

Possible record key hash corruption on insert after an update

Open monok0 opened this issue 2 years ago • 0 comments

PostgreSQL 14.6 (Ubuntu 14.6-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit pg_variables 1.2.5

I discovered erroneous behaviour with chains of updates to the record variable followed by an insert. The following script makes pgv_select claim that there is no record with key 33, but pgv_select on the whole collection shows, that the record is there. After that it is also possible to insert another record with key 33, meaning that the original record is either lost or its key hash is corrupted. In addition, if you add or remove a single update, it works fine, showing the record.

`Select pgv_free(); select pgv_insert('test', 'aaa', row(33::text, 'data2'::text)); select pgv_update('test','aaa', row(33::text, 'data2'::text)); select pgv_update('test','aaa', row(33::text, 'data2'::text)); select pgv_update('test','aaa', row(33::text, 'data2'::text)); select pgv_insert('test','aaa', row(32::text, 'data3'::text));

Select pgv_select('test', 'aaa', '33'::text), array(select pgv_select('test', 'aaa'));`

Output of this script изображение

Output with one update removed изображение

monok0 avatar May 23 '23 09:05 monok0