nproc = irel->rd_indam->amsupport;
- Assert(procnum >= 0 && procnum <= (uint16) nproc);
+ Assert(procnum > 0 && procnum <= (uint16) nproc);
- procindex = ((nproc + 1) * (attnum - 1)) + procnum;
+ procindex = (nproc * (attnum - 1)) + (procnum - 1);
loc = irel->rd_support;
nproc = irel->rd_indam->amsupport;
optsproc = irel->rd_indam->amoptsprocnum;
- Assert(procnum >= 0 && procnum <= (uint16) nproc);
+ Assert(procnum > 0 && procnum <= (uint16) nproc);
- procindex = ((nproc + 1) * (attnum - 1)) + procnum;
+ procindex = (nproc * (attnum - 1)) + (procnum - 1);
locinfo = irel->rd_supportinfo;
bool validate)
{
int amoptsprocnum = indrel->rd_indam->amoptsprocnum;
- Oid procid = index_getprocid(indrel, attnum, amoptsprocnum);
+ Oid procid = InvalidOid;
FmgrInfo *procinfo;
local_relopts relopts;
+ /* fetch options support procedure if specified */
+ if (amoptsprocnum != 0)
+ procid =index_getprocid(indrel, attnum, amoptsprocnum);
+
if (!OidIsValid(procid))
{
Oid opclass;
amsupport = relation->rd_indam->amsupport;
if (amsupport > 0)
{
- int nsupport = indnatts * (amsupport + 1);
+ int nsupport = indnatts * amsupport;
relation->rd_support = (RegProcedure *)
MemoryContextAllocZero(indexcxt, nsupport * sizeof(RegProcedure));
opFamily[attIndex] = opcentry->opcfamily;
opcInType[attIndex] = opcentry->opcintype;
if (maxSupportNumber > 0)
- memcpy(&indexSupport[attIndex * (maxSupportNumber + 1)],
+ memcpy(&indexSupport[attIndex * maxSupportNumber],
opcentry->supportProcs,
- (maxSupportNumber + 1) * sizeof(RegProcedure));
+ maxSupportNumber * sizeof(RegProcedure));
}
}
{
Form_pg_amproc amprocform = (Form_pg_amproc) GETSTRUCT(htup);
- if (amprocform->amprocnum < 0 ||
+ if (amprocform->amprocnum <= 0 ||
(StrategyNumber) amprocform->amprocnum > numSupport)
elog(ERROR, "invalid amproc number %d for opclass %u",
amprocform->amprocnum, operatorClassOid);
- opcentry->supportProcs[amprocform->amprocnum] = amprocform->amproc;
+ opcentry->supportProcs[amprocform->amprocnum - 1] =
+ amprocform->amproc;
}
systable_endscan(scan);
for (attnum = 1; attnum <= natts; attnum++)
{
+ if (indexrel->rd_indam->amoptsprocnum == 0)
+ continue;
+
if (!OidIsValid(index_getprocid(indexrel, attnum,
indexrel->rd_indam->amoptsprocnum)))
continue;
}
/* set up zeroed fmgr-info vector */
- nsupport = relform->relnatts * (rel->rd_indam->amsupport + 1);
+ nsupport = relform->relnatts * rel->rd_indam->amsupport;
rel->rd_supportinfo = (FmgrInfo *)
MemoryContextAllocZero(indexcxt, nsupport * sizeof(FmgrInfo));
}
/* next, write the vector of support procedure OIDs */
write_item(rel->rd_support,
- relform->relnatts * ((rel->rd_indam->amsupport + 1) * sizeof(RegProcedure)),
+ relform->relnatts * (rel->rd_indam->amsupport * sizeof(RegProcedure)),
fp);
/* next, write the vector of collation OIDs */