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