hypopg
hypopg copied to clipboard
Correctly allocate hypoIndex entries
ncolumns
field is calculated as:
entry->ncolumns = nkeycolumns + ninccolumns;
In hypo_injectHypotheticalIndex
:
for (i = 0; i < ncolumns; i++)
{
index->sortopfamily[i] = entry->sortopfamily[i];
index->reverse_sort[i] = entry->reverse_sort[i];
index->nulls_first[i] = entry->nulls_first[i];
However, when these fields are initialized, only nkeycolumns
elements are allocated.
This PR changes the element count in allocations so that enough memory is allocated.
cc @rjuju
Hi,
Thanks for the report! However I think your proposed fix is backward: those info are only needed for key columns, so the loop should be changed instead. I found a few other similar mistakes, and while at it reordered the code a bit to make instructions order similar in both place, see https://github.com/HypoPG/hypopg/commit/0a80ba3090f3d291973f13b16fbb948d0b4d0ca1