diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2023-10-03 17:39:31 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2023-10-03 17:51:02 +0200 |
commit | 784162357130f63b5130cd6517db21451692f9b3 (patch) | |
tree | edaaace4b2c7caff98af659aa544ee80b1c7c53d /src/backend/commands/indexcmds.c | |
parent | af3ee8a086ca210d9461f813538d0169dbf07c2c (diff) | |
download | postgresql-784162357130f63b5130cd6517db21451692f9b3.tar.gz postgresql-784162357130f63b5130cd6517db21451692f9b3.zip |
Remove IndexInfo.ii_OpclassOptions field
It is unnecessary to include this field in IndexInfo. It is only used
by DDL code, not during execution. It is really only used to pass
local information around between functions in index.c and indexcmds.c,
for which it is clearer to use local variables, like in similar cases.
Discussion: https://www.postgresql.org/message-id/flat/f84640e3-00d3-5abd-3f41-e6a19d33c40b@eisentraut.org
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ab8b81b3020..a53861cecf7 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -77,6 +77,7 @@ static void ComputeIndexAttrs(IndexInfo *indexInfo, Oid *typeOids, Oid *collationOids, Oid *opclassOids, + Datum *opclassOptions, int16 *colOptions, const List *attList, const List *exclusionOpNames, @@ -177,6 +178,7 @@ CheckIndexCompatible(Oid oldId, Oid *typeIds; Oid *collationIds; Oid *opclassIds; + Datum *opclassOptions; Oid accessMethodId; Oid relationId; HeapTuple tuple; @@ -238,9 +240,10 @@ CheckIndexCompatible(Oid oldId, typeIds = palloc_array(Oid, numberOfAttributes); collationIds = palloc_array(Oid, numberOfAttributes); opclassIds = palloc_array(Oid, numberOfAttributes); + opclassOptions = palloc_array(Datum, numberOfAttributes); coloptions = palloc_array(int16, numberOfAttributes); ComputeIndexAttrs(indexInfo, - typeIds, collationIds, opclassIds, + typeIds, collationIds, opclassIds, opclassOptions, coloptions, attributeList, exclusionOpNames, relationId, accessMethodName, accessMethodId, @@ -298,13 +301,12 @@ CheckIndexCompatible(Oid oldId, /* Any change in opclass options break compatibility. */ if (ret) { - Datum *opclassOptions = RelationGetIndexRawAttOptions(irel); + Datum *oldOpclassOptions = RelationGetIndexRawAttOptions(irel); - ret = CompareOpclassOptions(opclassOptions, - indexInfo->ii_OpclassOptions, old_natts); + ret = CompareOpclassOptions(oldOpclassOptions, opclassOptions, old_natts); - if (opclassOptions) - pfree(opclassOptions); + if (oldOpclassOptions) + pfree(oldOpclassOptions); } /* Any change in exclusion operator selections breaks compatibility. */ @@ -540,6 +542,7 @@ DefineIndex(Oid tableId, Oid *typeIds; Oid *collationIds; Oid *opclassIds; + Datum *opclassOptions; Oid accessMethodId; Oid namespaceId; Oid tablespaceId; @@ -900,9 +903,10 @@ DefineIndex(Oid tableId, typeIds = palloc_array(Oid, numberOfAttributes); collationIds = palloc_array(Oid, numberOfAttributes); opclassIds = palloc_array(Oid, numberOfAttributes); + opclassOptions = palloc_array(Datum, numberOfAttributes); coloptions = palloc_array(int16, numberOfAttributes); ComputeIndexAttrs(indexInfo, - typeIds, collationIds, opclassIds, + typeIds, collationIds, opclassIds, opclassOptions, coloptions, allIndexParams, stmt->excludeOpNames, tableId, accessMethodName, accessMethodId, @@ -1179,7 +1183,7 @@ DefineIndex(Oid tableId, parentConstraintId, stmt->oldNumber, indexInfo, indexColNames, accessMethodId, tablespaceId, - collationIds, opclassIds, + collationIds, opclassIds, opclassOptions, coloptions, reloptions, flags, constr_flags, allowSystemTableMods, !check_rights, @@ -1855,6 +1859,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo, Oid *typeOids, Oid *collationOids, Oid *opclassOids, + Datum *opclassOptions, int16 *colOptions, const List *attList, /* list of IndexElem's */ const List *exclusionOpNames, @@ -2011,6 +2016,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo, errmsg("including column does not support NULLS FIRST/LAST options"))); opclassOids[attn] = InvalidOid; + opclassOptions[attn] = (Datum) 0; colOptions[attn] = 0; collationOids[attn] = InvalidOid; attn++; @@ -2202,14 +2208,12 @@ ComputeIndexAttrs(IndexInfo *indexInfo, { Assert(attn < nkeycols); - if (!indexInfo->ii_OpclassOptions) - indexInfo->ii_OpclassOptions = - palloc0_array(Datum, indexInfo->ii_NumIndexAttrs); - - indexInfo->ii_OpclassOptions[attn] = + opclassOptions[attn] = transformRelOptions((Datum) 0, attribute->opclassopts, NULL, NULL, false, false); } + else + opclassOptions[attn] = (Datum) 0; attn++; } |