@@ -1426,7 +1426,7 @@ RelationInitIndexAccessInfo(Relation relation)
1426
1426
amsupport = relation -> rd_indam -> amsupport ;
1427
1427
if (amsupport > 0 )
1428
1428
{
1429
- int nsupport = indnatts * ( amsupport + 1 ) ;
1429
+ int nsupport = indnatts * amsupport ;
1430
1430
1431
1431
relation -> rd_support = (RegProcedure * )
1432
1432
MemoryContextAllocZero (indexcxt , nsupport * sizeof (RegProcedure ));
@@ -1541,9 +1541,9 @@ IndexSupportInitialize(oidvector *indclass,
1541
1541
opFamily [attIndex ] = opcentry -> opcfamily ;
1542
1542
opcInType [attIndex ] = opcentry -> opcintype ;
1543
1543
if (maxSupportNumber > 0 )
1544
- memcpy (& indexSupport [attIndex * ( maxSupportNumber + 1 ) ],
1544
+ memcpy (& indexSupport [attIndex * maxSupportNumber ],
1545
1545
opcentry -> supportProcs ,
1546
- ( maxSupportNumber + 1 ) * sizeof (RegProcedure ));
1546
+ maxSupportNumber * sizeof (RegProcedure ));
1547
1547
}
1548
1548
}
1549
1549
@@ -1695,12 +1695,13 @@ LookupOpclassInfo(Oid operatorClassOid,
1695
1695
{
1696
1696
Form_pg_amproc amprocform = (Form_pg_amproc ) GETSTRUCT (htup );
1697
1697
1698
- if (amprocform -> amprocnum < 0 ||
1698
+ if (amprocform -> amprocnum <= 0 ||
1699
1699
(StrategyNumber ) amprocform -> amprocnum > numSupport )
1700
1700
elog (ERROR , "invalid amproc number %d for opclass %u" ,
1701
1701
amprocform -> amprocnum , operatorClassOid );
1702
1702
1703
- opcentry -> supportProcs [amprocform -> amprocnum ] = amprocform -> amproc ;
1703
+ opcentry -> supportProcs [amprocform -> amprocnum - 1 ] =
1704
+ amprocform -> amproc ;
1704
1705
}
1705
1706
1706
1707
systable_endscan (scan );
@@ -5201,6 +5202,9 @@ RelationGetIndexRawAttOptions(Relation indexrel)
5201
5202
5202
5203
for (attnum = 1 ; attnum <= natts ; attnum ++ )
5203
5204
{
5205
+ if (indexrel -> rd_indam -> amoptsprocnum == 0 )
5206
+ continue ;
5207
+
5204
5208
if (!OidIsValid (index_getprocid (indexrel , attnum ,
5205
5209
indexrel -> rd_indam -> amoptsprocnum )))
5206
5210
continue ;
@@ -5661,7 +5665,7 @@ load_relcache_init_file(bool shared)
5661
5665
}
5662
5666
5663
5667
/* set up zeroed fmgr-info vector */
5664
- nsupport = relform -> relnatts * ( rel -> rd_indam -> amsupport + 1 ) ;
5668
+ nsupport = relform -> relnatts * rel -> rd_indam -> amsupport ;
5665
5669
rel -> rd_supportinfo = (FmgrInfo * )
5666
5670
MemoryContextAllocZero (indexcxt , nsupport * sizeof (FmgrInfo ));
5667
5671
}
@@ -5962,7 +5966,7 @@ write_relcache_init_file(bool shared)
5962
5966
5963
5967
/* next, write the vector of support procedure OIDs */
5964
5968
write_item (rel -> rd_support ,
5965
- relform -> relnatts * (( rel -> rd_indam -> amsupport + 1 ) * sizeof (RegProcedure )),
5969
+ relform -> relnatts * (rel -> rd_indam -> amsupport * sizeof (RegProcedure )),
5966
5970
fp );
5967
5971
5968
5972
/* next, write the vector of collation OIDs */
0 commit comments