Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2023-10-03 15:39:31 +0000
committerPeter Eisentraut2023-10-03 15:51:02 +0000
commit784162357130f63b5130cd6517db21451692f9b3 (patch)
treeedaaace4b2c7caff98af659aa544ee80b1c7c53d /src/backend
parentaf3ee8a086ca210d9461f813538d0169dbf07c2c (diff)
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')
-rw-r--r--src/backend/catalog/index.c33
-rw-r--r--src/backend/catalog/toasting.c3
-rw-r--r--src/backend/commands/indexcmds.c30
-rw-r--r--src/backend/nodes/makefuncs.c3
4 files changed, 33 insertions, 36 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 3d5adab2c53..143fae01ebd 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -720,6 +720,7 @@ index_create(Relation heapRelation,
Oid tableSpaceId,
const Oid *collationIds,
const Oid *opclassIds,
+ const Datum *opclassOptions,
const int16 *coloptions,
Datum reloptions,
bits16 flags,
@@ -1015,7 +1016,7 @@ index_create(Relation heapRelation,
/*
* append ATTRIBUTE tuples for the index
*/
- AppendAttributeTuples(indexRelation, indexInfo->ii_OpclassOptions);
+ AppendAttributeTuples(indexRelation, opclassOptions);
/* ----------------
* update pg_index
@@ -1223,10 +1224,10 @@ index_create(Relation heapRelation,
indexRelation->rd_index->indnkeyatts = indexInfo->ii_NumIndexKeyAttrs;
/* Validate opclass-specific options */
- if (indexInfo->ii_OpclassOptions)
+ if (opclassOptions)
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
(void) index_opclass_options(indexRelation, i + 1,
- indexInfo->ii_OpclassOptions[i],
+ opclassOptions[i],
true);
/*
@@ -1290,7 +1291,8 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
classTuple;
Datum indclassDatum,
colOptionDatum,
- optionDatum;
+ reloptionsDatum;
+ Datum *opclassOptions;
oidvector *indclass;
int2vector *indcoloptions;
bool isnull;
@@ -1324,12 +1326,12 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
Anum_pg_index_indoption);
indcoloptions = (int2vector *) DatumGetPointer(colOptionDatum);
- /* Fetch options of index if any */
+ /* Fetch reloptions of index if any */
classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(oldIndexId));
if (!HeapTupleIsValid(classTuple))
elog(ERROR, "cache lookup failed for relation %u", oldIndexId);
- optionDatum = SysCacheGetAttr(RELOID, classTuple,
- Anum_pg_class_reloptions, &isnull);
+ reloptionsDatum = SysCacheGetAttr(RELOID, classTuple,
+ Anum_pg_class_reloptions, &isnull);
/*
* Fetch the list of expressions and predicates directly from the
@@ -1392,14 +1394,10 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
newInfo->ii_IndexAttrNumbers[i] = oldInfo->ii_IndexAttrNumbers[i];
}
- /* Extract opclass parameters for each attribute, if any */
- if (oldInfo->ii_OpclassOptions != NULL)
- {
- newInfo->ii_OpclassOptions = palloc0(sizeof(Datum) *
- newInfo->ii_NumIndexAttrs);
- for (int i = 0; i < newInfo->ii_NumIndexAttrs; i++)
- newInfo->ii_OpclassOptions[i] = get_attoptions(oldIndexId, i + 1);
- }
+ /* Extract opclass options for each attribute */
+ opclassOptions = palloc0(sizeof(Datum) * newInfo->ii_NumIndexAttrs);
+ for (int i = 0; i < newInfo->ii_NumIndexAttrs; i++)
+ opclassOptions[i] = get_attoptions(oldIndexId, i + 1);
/*
* Now create the new index.
@@ -1420,8 +1418,9 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
tablespaceOid,
indexRelation->rd_indcollation,
indclass->values,
+ opclassOptions,
indcoloptions->values,
- optionDatum,
+ reloptionsDatum,
INDEX_CREATE_SKIP_BUILD | INDEX_CREATE_CONCURRENT,
0,
true, /* allow table to be a system catalog? */
@@ -2464,8 +2463,6 @@ BuildIndexInfo(Relation index)
&ii->ii_ExclusionStrats);
}
- ii->ii_OpclassOptions = RelationGetIndexRawAttOptions(index);
-
return ii;
}
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 3fef593bf1a..989f8207913 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -299,7 +299,6 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
indexInfo->ii_ExclusionOps = NULL;
indexInfo->ii_ExclusionProcs = NULL;
indexInfo->ii_ExclusionStrats = NULL;
- indexInfo->ii_OpclassOptions = NULL;
indexInfo->ii_Unique = true;
indexInfo->ii_NullsNotDistinct = false;
indexInfo->ii_ReadyForInserts = true;
@@ -327,7 +326,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
list_make2("chunk_id", "chunk_seq"),
BTREE_AM_OID,
rel->rd_rel->reltablespace,
- collationIds, opclassIds, coloptions, (Datum) 0,
+ collationIds, opclassIds, NULL, coloptions, (Datum) 0,
INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL);
table_close(toast_rel, NoLock);
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++;
}
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 0e7e6e46d94..c6fb5719821 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -777,9 +777,6 @@ makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions,
n->ii_ExclusionProcs = NULL;
n->ii_ExclusionStrats = NULL;
- /* opclass options */
- n->ii_OpclassOptions = NULL;
-
/* speculative inserts */
n->ii_UniqueOps = NULL;
n->ii_UniqueProcs = NULL;