* the new index, so we can test whether it's compatible with the existing
* one. Note that ComputeIndexAttrs might fail here, but that's OK:
* DefineIndex would have called this function with the same arguments
- * later on, and it would have failed then anyway.
+ * later on, and it would have failed then anyway. Our attributeList
+ * contains only key attributes, thus we're filling ii_NumIndexAttrs and
+ * ii_NumIndexKeyAttrs with same value.
*/
indexInfo = makeNode(IndexInfo);
+ indexInfo->ii_NumIndexAttrs = numberOfAttributes;
+ indexInfo->ii_NumIndexKeyAttrs = numberOfAttributes;
indexInfo->ii_Expressions = NIL;
indexInfo->ii_ExpressionsState = NIL;
indexInfo->ii_PredicateState = NULL;
typeObjectId = (Oid *) palloc(numberOfAttributes * sizeof(Oid));
collationObjectId = (Oid *) palloc(numberOfAttributes * sizeof(Oid));
- classObjectId = (Oid *) palloc(numberOfKeyAttributes * sizeof(Oid));
+ classObjectId = (Oid *) palloc(numberOfAttributes * sizeof(Oid));
coloptions = (int16 *) palloc(numberOfAttributes * sizeof(int16));
ComputeIndexAttrs(indexInfo,
typeObjectId, collationObjectId, classObjectId,
collationOidP[attn] = attcollation;
/*
- * Skip opclass and ordering options for included columns.
+ * Included columns have no opclass and no ordering options.
*/
if (attn >= nkeycols)
{
+ classOidP[attn] = InvalidOid;
colOptionP[attn] = 0;
attn++;
continue;