mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 09:38:21 +00:00
Fix a few allocation size and array assignation mistakes.
Some part of the code was allocating array entries to account for included columns while it's only needed for key columns, and some other parts were trying to store data for included columns on info that's only relevant for key columns (and thus allocated in consequence). While at it, reorder a few lines to keep the order consistent between and hypo_newIndex() and hypo_injectHypotheticalIndex(). Per initial report from Zhihong Yu.
This commit is contained in:
parent
512bcd30de
commit
0a80ba3090
1 changed files with 13 additions and 13 deletions
|
|
@ -1013,21 +1013,17 @@ hypo_injectHypotheticalIndex(PlannerInfo *root,
|
|||
#endif
|
||||
|
||||
index->indexkeys = (int *) palloc(sizeof(int) * ncolumns);
|
||||
index->indexcollations = (Oid *) palloc(sizeof(int) * ncolumns);
|
||||
index->opfamily = (Oid *) palloc(sizeof(int) * ncolumns);
|
||||
index->opcintype = (Oid *) palloc(sizeof(int) * ncolumns);
|
||||
|
||||
#if PG_VERSION_NUM >= 90500
|
||||
index->canreturn = (bool *) palloc(sizeof(bool) * ncolumns);
|
||||
#endif
|
||||
index->indexcollations = (Oid *) palloc(sizeof(int) * nkeycolumns);
|
||||
index->opfamily = (Oid *) palloc(sizeof(int) * nkeycolumns);
|
||||
index->opcintype = (Oid *) palloc(sizeof(int) * nkeycolumns);
|
||||
|
||||
if ((index->relam == BTREE_AM_OID) || entry->amcanorder)
|
||||
{
|
||||
if (index->relam != BTREE_AM_OID)
|
||||
index->sortopfamily = palloc0(sizeof(Oid) * ncolumns);
|
||||
index->sortopfamily = palloc0(sizeof(Oid) * nkeycolumns);
|
||||
|
||||
index->reverse_sort = (bool *) palloc(sizeof(bool) * ncolumns);
|
||||
index->nulls_first = (bool *) palloc(sizeof(bool) * ncolumns);
|
||||
index->reverse_sort = (bool *) palloc(sizeof(bool) * nkeycolumns);
|
||||
index->nulls_first = (bool *) palloc(sizeof(bool) * nkeycolumns);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1036,6 +1032,10 @@ hypo_injectHypotheticalIndex(PlannerInfo *root,
|
|||
index->nulls_first = NULL;
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= 90500
|
||||
index->canreturn = (bool *) palloc(sizeof(bool) * ncolumns);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < ncolumns; i++)
|
||||
{
|
||||
index->indexkeys[i] = entry->indexkeys[i];
|
||||
|
|
@ -1046,9 +1046,9 @@ hypo_injectHypotheticalIndex(PlannerInfo *root,
|
|||
|
||||
for (i = 0; i < nkeycolumns; i++)
|
||||
{
|
||||
index->indexcollations[i] = entry->indexcollations[i];
|
||||
index->opfamily[i] = entry->opfamily[i];
|
||||
index->opcintype[i] = entry->opcintype[i];
|
||||
index->indexcollations[i] = entry->indexcollations[i];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1064,7 +1064,7 @@ hypo_injectHypotheticalIndex(PlannerInfo *root,
|
|||
*/
|
||||
index->sortopfamily = index->opfamily;
|
||||
|
||||
for (i = 0; i < ncolumns; i++)
|
||||
for (i = 0; i < nkeycolumns; i++)
|
||||
{
|
||||
index->reverse_sort[i] = entry->reverse_sort[i];
|
||||
index->nulls_first[i] = entry->nulls_first[i];
|
||||
|
|
@ -1074,7 +1074,7 @@ hypo_injectHypotheticalIndex(PlannerInfo *root,
|
|||
{
|
||||
if (entry->sortopfamily)
|
||||
{
|
||||
for (i = 0; i < ncolumns; i++)
|
||||
for (i = 0; i < nkeycolumns; i++)
|
||||
{
|
||||
index->sortopfamily[i] = entry->sortopfamily[i];
|
||||
index->reverse_sort[i] = entry->reverse_sort[i];
|
||||
|
|
|
|||
Loading…
Reference in a new issue