Re: pgsql: Add deduplication to nbtree.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Add deduplication to nbtree.
Date: 2020-03-01 18:24:55
Message-ID: 27003.1583087095@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Peter Geoghegan <pg(at)bowt(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2020-03-01 18:57:10 Re: pgsql: Add deduplication to nbtree.
Previous Message Dean Rasheed 2020-03-01 14:54:11 pgsql: Fix corner-case loss of precision in numeric ln().