Re: pgsql: Add deduplication to nbtree. - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Add deduplication to nbtree.
Date
Msg-id 27003.1583087095@sss.pgh.pa.us
Whole thread Raw
In response to pgsql: Add deduplication to nbtree.  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: pgsql: Add deduplication to nbtree.  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-committers
Peter Geoghegan <pg@bowt.ie> writes:
> Add deduplication to nbtree.

Coverity isn't very happy with the coding in _bt_update_posting():

*** CID 1460433:  Memory - corruptions  (ARRAY_VS_SINGLETON)
/srv/coverity/git/pgsql-git/postgresql/src/backend/access/nbtree/nbtdedup.c: 723 in _bt_update_posting()
717         {
718             if (d < vacposting->ndeletedtids && vacposting->deletetids[d] == i)
719             {
720                 d++;
721                 continue;
722             }
>>>     CID 1460433:  Memory - corruptions  (ARRAY_VS_SINGLETON)
>>>     Using "htids" as an array.  This might corrupt or misinterpret adjacent memory locations.
723             htids[ui++] = *BTreeTupleGetPostingN(origtuple, i);
724         }
725         Assert(ui == nhtids);
726         Assert(d == vacposting->ndeletedtids);
727         Assert(nhtids == 1 || _bt_posting_valid(itup));

I can see its point: asserting after the fact that you didn't clobber
memory isn't a terribly safe coding method, especially in a production
build where you won't even have the asserts.  Not sure if there's a
better way though.

            regards, tom lane



pgsql-committers by date:

Previous
From: Dean Rasheed
Date:
Subject: pgsql: Fix corner-case loss of precision in numeric ln().
Next
From: Peter Geoghegan
Date:
Subject: Re: pgsql: Add deduplication to nbtree.