diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2020-03-30 23:40:22 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2020-03-30 23:43:25 +0300 |
commit | 851b14b0c69b3773753a3c202bff42c3e4425d8d (patch) | |
tree | a914d7d7a08f75df5364d0e19ce852399c8b32ce /src/backend/utils/cache/relcache.c | |
parent | 4b42a89938ac9d2ec06e9d831356407040e9094c (diff) | |
download | postgresql-851b14b0c69b3773753a3c202bff42c3e4425d8d.tar.gz postgresql-851b14b0c69b3773753a3c202bff42c3e4425d8d.zip |
Remove rudiments of supporting procnum == 0 from 911e702077
Early versions of opclass options patch uses zero support procedure as opclass
options procedure. This commit removes rudiments of it, which were committed
in 911e702077. Also, it implements correct handling of amoptsprocnum == 0.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index fa82ab9c5c9..f8e2c6e88e9 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -1426,7 +1426,7 @@ RelationInitIndexAccessInfo(Relation relation) 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)); @@ -1541,9 +1541,9 @@ IndexSupportInitialize(oidvector *indclass, 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)); } } @@ -1695,12 +1695,13 @@ LookupOpclassInfo(Oid operatorClassOid, { 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); @@ -5201,6 +5202,9 @@ RelationGetIndexRawAttOptions(Relation indexrel) for (attnum = 1; attnum <= natts; attnum++) { + if (indexrel->rd_indam->amoptsprocnum == 0) + continue; + if (!OidIsValid(index_getprocid(indexrel, attnum, indexrel->rd_indam->amoptsprocnum))) continue; @@ -5661,7 +5665,7 @@ load_relcache_init_file(bool shared) } /* 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)); } @@ -5962,7 +5966,7 @@ write_relcache_init_file(bool shared) /* 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 */ |