mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Rename some function arguments for better clarity
Especially make sure that array arguments have plural names. Discussion: https://www.postgresql.org/message-id/flat/5ed89c69-f4e6-5dab-4003-63bde7460e5e%40eisentraut.org
This commit is contained in:
@ -108,9 +108,9 @@ static bool relationHasPrimaryKey(Relation rel);
|
|||||||
static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
|
static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
|
||||||
const IndexInfo *indexInfo,
|
const IndexInfo *indexInfo,
|
||||||
const List *indexColNames,
|
const List *indexColNames,
|
||||||
Oid accessMethodObjectId,
|
Oid accessMethodId,
|
||||||
const Oid *collationObjectId,
|
const Oid *collationIds,
|
||||||
const Oid *classObjectId);
|
const Oid *opclassIds);
|
||||||
static void InitializeAttributeOids(Relation indexRelation,
|
static void InitializeAttributeOids(Relation indexRelation,
|
||||||
int numatts, Oid indexoid);
|
int numatts, Oid indexoid);
|
||||||
static void AppendAttributeTuples(Relation indexRelation, const Datum *attopts);
|
static void AppendAttributeTuples(Relation indexRelation, const Datum *attopts);
|
||||||
@ -118,7 +118,7 @@ static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
|||||||
Oid parentIndexId,
|
Oid parentIndexId,
|
||||||
const IndexInfo *indexInfo,
|
const IndexInfo *indexInfo,
|
||||||
const Oid *collationOids,
|
const Oid *collationOids,
|
||||||
const Oid *classOids,
|
const Oid *opclassOids,
|
||||||
const int16 *coloptions,
|
const int16 *coloptions,
|
||||||
bool primary,
|
bool primary,
|
||||||
bool isexclusion,
|
bool isexclusion,
|
||||||
@ -286,9 +286,9 @@ static TupleDesc
|
|||||||
ConstructTupleDescriptor(Relation heapRelation,
|
ConstructTupleDescriptor(Relation heapRelation,
|
||||||
const IndexInfo *indexInfo,
|
const IndexInfo *indexInfo,
|
||||||
const List *indexColNames,
|
const List *indexColNames,
|
||||||
Oid accessMethodObjectId,
|
Oid accessMethodId,
|
||||||
const Oid *collationObjectId,
|
const Oid *collationIds,
|
||||||
const Oid *classObjectId)
|
const Oid *opclassIds)
|
||||||
{
|
{
|
||||||
int numatts = indexInfo->ii_NumIndexAttrs;
|
int numatts = indexInfo->ii_NumIndexAttrs;
|
||||||
int numkeyatts = indexInfo->ii_NumIndexKeyAttrs;
|
int numkeyatts = indexInfo->ii_NumIndexKeyAttrs;
|
||||||
@ -301,7 +301,7 @@ ConstructTupleDescriptor(Relation heapRelation,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* We need access to the index AM's API struct */
|
/* We need access to the index AM's API struct */
|
||||||
amroutine = GetIndexAmRoutineByAmId(accessMethodObjectId, false);
|
amroutine = GetIndexAmRoutineByAmId(accessMethodId, false);
|
||||||
|
|
||||||
/* ... and to the table's tuple descriptor */
|
/* ... and to the table's tuple descriptor */
|
||||||
heapTupDesc = RelationGetDescr(heapRelation);
|
heapTupDesc = RelationGetDescr(heapRelation);
|
||||||
@ -330,7 +330,7 @@ ConstructTupleDescriptor(Relation heapRelation,
|
|||||||
to->attcacheoff = -1;
|
to->attcacheoff = -1;
|
||||||
to->attislocal = true;
|
to->attislocal = true;
|
||||||
to->attcollation = (i < numkeyatts) ?
|
to->attcollation = (i < numkeyatts) ?
|
||||||
collationObjectId[i] : InvalidOid;
|
collationIds[i] : InvalidOid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the attribute name as specified by caller.
|
* Set the attribute name as specified by caller.
|
||||||
@ -436,10 +436,10 @@ ConstructTupleDescriptor(Relation heapRelation,
|
|||||||
|
|
||||||
if (i < indexInfo->ii_NumIndexKeyAttrs)
|
if (i < indexInfo->ii_NumIndexKeyAttrs)
|
||||||
{
|
{
|
||||||
tuple = SearchSysCache1(CLAOID, ObjectIdGetDatum(classObjectId[i]));
|
tuple = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassIds[i]));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for opclass %u",
|
elog(ERROR, "cache lookup failed for opclass %u",
|
||||||
classObjectId[i]);
|
opclassIds[i]);
|
||||||
opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
|
opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
|
||||||
if (OidIsValid(opclassTup->opckeytype))
|
if (OidIsValid(opclassTup->opckeytype))
|
||||||
keyType = opclassTup->opckeytype;
|
keyType = opclassTup->opckeytype;
|
||||||
@ -553,7 +553,7 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
Oid parentIndexId,
|
Oid parentIndexId,
|
||||||
const IndexInfo *indexInfo,
|
const IndexInfo *indexInfo,
|
||||||
const Oid *collationOids,
|
const Oid *collationOids,
|
||||||
const Oid *classOids,
|
const Oid *opclassOids,
|
||||||
const int16 *coloptions,
|
const int16 *coloptions,
|
||||||
bool primary,
|
bool primary,
|
||||||
bool isexclusion,
|
bool isexclusion,
|
||||||
@ -581,7 +581,7 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
|
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
|
||||||
indkey->values[i] = indexInfo->ii_IndexAttrNumbers[i];
|
indkey->values[i] = indexInfo->ii_IndexAttrNumbers[i];
|
||||||
indcollation = buildoidvector(collationOids, indexInfo->ii_NumIndexKeyAttrs);
|
indcollation = buildoidvector(collationOids, indexInfo->ii_NumIndexKeyAttrs);
|
||||||
indclass = buildoidvector(classOids, indexInfo->ii_NumIndexKeyAttrs);
|
indclass = buildoidvector(opclassOids, indexInfo->ii_NumIndexKeyAttrs);
|
||||||
indoption = buildint2vector(coloptions, indexInfo->ii_NumIndexKeyAttrs);
|
indoption = buildint2vector(coloptions, indexInfo->ii_NumIndexKeyAttrs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -679,10 +679,10 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
* May be nonzero to attach an existing valid build.
|
* May be nonzero to attach an existing valid build.
|
||||||
* indexInfo: same info executor uses to insert into the index
|
* indexInfo: same info executor uses to insert into the index
|
||||||
* indexColNames: column names to use for index (List of char *)
|
* indexColNames: column names to use for index (List of char *)
|
||||||
* accessMethodObjectId: OID of index AM to use
|
* accessMethodId: OID of index AM to use
|
||||||
* tableSpaceId: OID of tablespace to use
|
* tableSpaceId: OID of tablespace to use
|
||||||
* collationObjectId: array of collation OIDs, one per index column
|
* collationIds: array of collation OIDs, one per index column
|
||||||
* classObjectId: array of index opclass OIDs, one per index column
|
* opclassIds: array of index opclass OIDs, one per index column
|
||||||
* coloptions: array of per-index-column indoption settings
|
* coloptions: array of per-index-column indoption settings
|
||||||
* reloptions: AM-specific options
|
* reloptions: AM-specific options
|
||||||
* flags: bitmask that can include any combination of these bits:
|
* flags: bitmask that can include any combination of these bits:
|
||||||
@ -719,10 +719,10 @@ index_create(Relation heapRelation,
|
|||||||
RelFileNumber relFileNumber,
|
RelFileNumber relFileNumber,
|
||||||
IndexInfo *indexInfo,
|
IndexInfo *indexInfo,
|
||||||
const List *indexColNames,
|
const List *indexColNames,
|
||||||
Oid accessMethodObjectId,
|
Oid accessMethodId,
|
||||||
Oid tableSpaceId,
|
Oid tableSpaceId,
|
||||||
const Oid *collationObjectId,
|
const Oid *collationIds,
|
||||||
const Oid *classObjectId,
|
const Oid *opclassIds,
|
||||||
const int16 *coloptions,
|
const int16 *coloptions,
|
||||||
Datum reloptions,
|
Datum reloptions,
|
||||||
bits16 flags,
|
bits16 flags,
|
||||||
@ -806,8 +806,8 @@ index_create(Relation heapRelation,
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
|
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
|
||||||
{
|
{
|
||||||
Oid collation = collationObjectId[i];
|
Oid collation = collationIds[i];
|
||||||
Oid opclass = classObjectId[i];
|
Oid opclass = opclassIds[i];
|
||||||
|
|
||||||
if (collation)
|
if (collation)
|
||||||
{
|
{
|
||||||
@ -908,9 +908,9 @@ index_create(Relation heapRelation,
|
|||||||
indexTupDesc = ConstructTupleDescriptor(heapRelation,
|
indexTupDesc = ConstructTupleDescriptor(heapRelation,
|
||||||
indexInfo,
|
indexInfo,
|
||||||
indexColNames,
|
indexColNames,
|
||||||
accessMethodObjectId,
|
accessMethodId,
|
||||||
collationObjectId,
|
collationIds,
|
||||||
classObjectId);
|
opclassIds);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate an OID for the index, unless we were told what to use.
|
* Allocate an OID for the index, unless we were told what to use.
|
||||||
@ -964,7 +964,7 @@ index_create(Relation heapRelation,
|
|||||||
tableSpaceId,
|
tableSpaceId,
|
||||||
indexRelationId,
|
indexRelationId,
|
||||||
relFileNumber,
|
relFileNumber,
|
||||||
accessMethodObjectId,
|
accessMethodId,
|
||||||
indexTupDesc,
|
indexTupDesc,
|
||||||
relkind,
|
relkind,
|
||||||
relpersistence,
|
relpersistence,
|
||||||
@ -993,7 +993,7 @@ index_create(Relation heapRelation,
|
|||||||
* XXX should have a cleaner way to create cataloged indexes
|
* XXX should have a cleaner way to create cataloged indexes
|
||||||
*/
|
*/
|
||||||
indexRelation->rd_rel->relowner = heapRelation->rd_rel->relowner;
|
indexRelation->rd_rel->relowner = heapRelation->rd_rel->relowner;
|
||||||
indexRelation->rd_rel->relam = accessMethodObjectId;
|
indexRelation->rd_rel->relam = accessMethodId;
|
||||||
indexRelation->rd_rel->relispartition = OidIsValid(parentIndexRelid);
|
indexRelation->rd_rel->relispartition = OidIsValid(parentIndexRelid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1030,7 +1030,7 @@ index_create(Relation heapRelation,
|
|||||||
*/
|
*/
|
||||||
UpdateIndexRelation(indexRelationId, heapRelationId, parentIndexRelid,
|
UpdateIndexRelation(indexRelationId, heapRelationId, parentIndexRelid,
|
||||||
indexInfo,
|
indexInfo,
|
||||||
collationObjectId, classObjectId, coloptions,
|
collationIds, opclassIds, coloptions,
|
||||||
isprimary, is_exclusion,
|
isprimary, is_exclusion,
|
||||||
(constr_flags & INDEX_CONSTR_CREATE_DEFERRABLE) == 0,
|
(constr_flags & INDEX_CONSTR_CREATE_DEFERRABLE) == 0,
|
||||||
!concurrent && !invalid,
|
!concurrent && !invalid,
|
||||||
@ -1159,11 +1159,11 @@ index_create(Relation heapRelation,
|
|||||||
/* The default collation is pinned, so don't bother recording it */
|
/* The default collation is pinned, so don't bother recording it */
|
||||||
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
|
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
|
||||||
{
|
{
|
||||||
if (OidIsValid(collationObjectId[i]) &&
|
if (OidIsValid(collationIds[i]) &&
|
||||||
collationObjectId[i] != DEFAULT_COLLATION_OID)
|
collationIds[i] != DEFAULT_COLLATION_OID)
|
||||||
{
|
{
|
||||||
ObjectAddressSet(referenced, CollationRelationId,
|
ObjectAddressSet(referenced, CollationRelationId,
|
||||||
collationObjectId[i]);
|
collationIds[i]);
|
||||||
add_exact_object_address(&referenced, addrs);
|
add_exact_object_address(&referenced, addrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1171,7 +1171,7 @@ index_create(Relation heapRelation,
|
|||||||
/* Store dependency on operator classes */
|
/* Store dependency on operator classes */
|
||||||
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
|
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
|
||||||
{
|
{
|
||||||
ObjectAddressSet(referenced, OperatorClassRelationId, classObjectId[i]);
|
ObjectAddressSet(referenced, OperatorClassRelationId, opclassIds[i]);
|
||||||
add_exact_object_address(&referenced, addrs);
|
add_exact_object_address(&referenced, addrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,8 +142,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
|
|||||||
char toast_relname[NAMEDATALEN];
|
char toast_relname[NAMEDATALEN];
|
||||||
char toast_idxname[NAMEDATALEN];
|
char toast_idxname[NAMEDATALEN];
|
||||||
IndexInfo *indexInfo;
|
IndexInfo *indexInfo;
|
||||||
Oid collationObjectId[2];
|
Oid collationIds[2];
|
||||||
Oid classObjectId[2];
|
Oid opclassIds[2];
|
||||||
int16 coloptions[2];
|
int16 coloptions[2];
|
||||||
ObjectAddress baseobject,
|
ObjectAddress baseobject,
|
||||||
toastobject;
|
toastobject;
|
||||||
@ -312,11 +312,11 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
|
|||||||
indexInfo->ii_AmCache = NULL;
|
indexInfo->ii_AmCache = NULL;
|
||||||
indexInfo->ii_Context = CurrentMemoryContext;
|
indexInfo->ii_Context = CurrentMemoryContext;
|
||||||
|
|
||||||
collationObjectId[0] = InvalidOid;
|
collationIds[0] = InvalidOid;
|
||||||
collationObjectId[1] = InvalidOid;
|
collationIds[1] = InvalidOid;
|
||||||
|
|
||||||
classObjectId[0] = OID_BTREE_OPS_OID;
|
opclassIds[0] = OID_BTREE_OPS_OID;
|
||||||
classObjectId[1] = INT4_BTREE_OPS_OID;
|
opclassIds[1] = INT4_BTREE_OPS_OID;
|
||||||
|
|
||||||
coloptions[0] = 0;
|
coloptions[0] = 0;
|
||||||
coloptions[1] = 0;
|
coloptions[1] = 0;
|
||||||
@ -327,7 +327,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
|
|||||||
list_make2("chunk_id", "chunk_seq"),
|
list_make2("chunk_id", "chunk_seq"),
|
||||||
BTREE_AM_OID,
|
BTREE_AM_OID,
|
||||||
rel->rd_rel->reltablespace,
|
rel->rd_rel->reltablespace,
|
||||||
collationObjectId, classObjectId, coloptions, (Datum) 0,
|
collationIds, opclassIds, coloptions, (Datum) 0,
|
||||||
INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL);
|
INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL);
|
||||||
|
|
||||||
table_close(toast_rel, NoLock);
|
table_close(toast_rel, NoLock);
|
||||||
|
@ -74,10 +74,10 @@
|
|||||||
static bool CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts);
|
static bool CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts);
|
||||||
static void CheckPredicate(Expr *predicate);
|
static void CheckPredicate(Expr *predicate);
|
||||||
static void ComputeIndexAttrs(IndexInfo *indexInfo,
|
static void ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||||
Oid *typeOidP,
|
Oid *typeOids,
|
||||||
Oid *collationOidP,
|
Oid *collationOids,
|
||||||
Oid *classOidP,
|
Oid *opclassOids,
|
||||||
int16 *colOptionP,
|
int16 *colOptions,
|
||||||
const List *attList,
|
const List *attList,
|
||||||
const List *exclusionOpNames,
|
const List *exclusionOpNames,
|
||||||
Oid relId,
|
Oid relId,
|
||||||
@ -173,9 +173,9 @@ CheckIndexCompatible(Oid oldId,
|
|||||||
const List *exclusionOpNames)
|
const List *exclusionOpNames)
|
||||||
{
|
{
|
||||||
bool isconstraint;
|
bool isconstraint;
|
||||||
Oid *typeObjectId;
|
Oid *typeIds;
|
||||||
Oid *collationObjectId;
|
Oid *collationIds;
|
||||||
Oid *classObjectId;
|
Oid *opclassIds;
|
||||||
Oid accessMethodId;
|
Oid accessMethodId;
|
||||||
Oid relationId;
|
Oid relationId;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
@ -234,12 +234,12 @@ CheckIndexCompatible(Oid oldId,
|
|||||||
indexInfo = makeIndexInfo(numberOfAttributes, numberOfAttributes,
|
indexInfo = makeIndexInfo(numberOfAttributes, numberOfAttributes,
|
||||||
accessMethodId, NIL, NIL, false, false,
|
accessMethodId, NIL, NIL, false, false,
|
||||||
false, false, amsummarizing);
|
false, false, amsummarizing);
|
||||||
typeObjectId = palloc_array(Oid, numberOfAttributes);
|
typeIds = palloc_array(Oid, numberOfAttributes);
|
||||||
collationObjectId = palloc_array(Oid, numberOfAttributes);
|
collationIds = palloc_array(Oid, numberOfAttributes);
|
||||||
classObjectId = palloc_array(Oid, numberOfAttributes);
|
opclassIds = palloc_array(Oid, numberOfAttributes);
|
||||||
coloptions = palloc_array(int16, numberOfAttributes);
|
coloptions = palloc_array(int16, numberOfAttributes);
|
||||||
ComputeIndexAttrs(indexInfo,
|
ComputeIndexAttrs(indexInfo,
|
||||||
typeObjectId, collationObjectId, classObjectId,
|
typeIds, collationIds, opclassIds,
|
||||||
coloptions, attributeList,
|
coloptions, attributeList,
|
||||||
exclusionOpNames, relationId,
|
exclusionOpNames, relationId,
|
||||||
accessMethodName, accessMethodId,
|
accessMethodName, accessMethodId,
|
||||||
@ -274,9 +274,9 @@ CheckIndexCompatible(Oid oldId,
|
|||||||
d = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
|
d = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
|
||||||
old_indclass = (oidvector *) DatumGetPointer(d);
|
old_indclass = (oidvector *) DatumGetPointer(d);
|
||||||
|
|
||||||
ret = (memcmp(old_indclass->values, classObjectId,
|
ret = (memcmp(old_indclass->values, opclassIds,
|
||||||
old_natts * sizeof(Oid)) == 0 &&
|
old_natts * sizeof(Oid)) == 0 &&
|
||||||
memcmp(old_indcollation->values, collationObjectId,
|
memcmp(old_indcollation->values, collationIds,
|
||||||
old_natts * sizeof(Oid)) == 0);
|
old_natts * sizeof(Oid)) == 0);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@ -288,8 +288,8 @@ CheckIndexCompatible(Oid oldId,
|
|||||||
irel = index_open(oldId, AccessShareLock); /* caller probably has a lock */
|
irel = index_open(oldId, AccessShareLock); /* caller probably has a lock */
|
||||||
for (i = 0; i < old_natts; i++)
|
for (i = 0; i < old_natts; i++)
|
||||||
{
|
{
|
||||||
if (IsPolymorphicType(get_opclass_input_type(classObjectId[i])) &&
|
if (IsPolymorphicType(get_opclass_input_type(opclassIds[i])) &&
|
||||||
TupleDescAttr(irel->rd_att, i)->atttypid != typeObjectId[i])
|
TupleDescAttr(irel->rd_att, i)->atttypid != typeIds[i])
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
@ -329,7 +329,7 @@ CheckIndexCompatible(Oid oldId,
|
|||||||
|
|
||||||
op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right);
|
op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right);
|
||||||
if ((IsPolymorphicType(left) || IsPolymorphicType(right)) &&
|
if ((IsPolymorphicType(left) || IsPolymorphicType(right)) &&
|
||||||
TupleDescAttr(irel->rd_att, i)->atttypid != typeObjectId[i])
|
TupleDescAttr(irel->rd_att, i)->atttypid != typeIds[i])
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
@ -500,7 +500,7 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
|
|||||||
* consider offering one DDL command for catalog setup and a separate DDL
|
* consider offering one DDL command for catalog setup and a separate DDL
|
||||||
* command for steps that run opaque expressions.
|
* command for steps that run opaque expressions.
|
||||||
*
|
*
|
||||||
* 'relationId': the OID of the heap relation on which the index is to be
|
* 'tableId': the OID of the table relation on which the index is to be
|
||||||
* created
|
* created
|
||||||
* 'stmt': IndexStmt describing the properties of the new index.
|
* 'stmt': IndexStmt describing the properties of the new index.
|
||||||
* 'indexRelationId': normally InvalidOid, but during bootstrap can be
|
* 'indexRelationId': normally InvalidOid, but during bootstrap can be
|
||||||
@ -523,7 +523,7 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
|
|||||||
* Returns the object address of the created index.
|
* Returns the object address of the created index.
|
||||||
*/
|
*/
|
||||||
ObjectAddress
|
ObjectAddress
|
||||||
DefineIndex(Oid relationId,
|
DefineIndex(Oid tableId,
|
||||||
IndexStmt *stmt,
|
IndexStmt *stmt,
|
||||||
Oid indexRelationId,
|
Oid indexRelationId,
|
||||||
Oid parentIndexId,
|
Oid parentIndexId,
|
||||||
@ -538,9 +538,9 @@ DefineIndex(Oid relationId,
|
|||||||
bool concurrent;
|
bool concurrent;
|
||||||
char *indexRelationName;
|
char *indexRelationName;
|
||||||
char *accessMethodName;
|
char *accessMethodName;
|
||||||
Oid *typeObjectId;
|
Oid *typeIds;
|
||||||
Oid *collationObjectId;
|
Oid *collationIds;
|
||||||
Oid *classObjectId;
|
Oid *opclassIds;
|
||||||
Oid accessMethodId;
|
Oid accessMethodId;
|
||||||
Oid namespaceId;
|
Oid namespaceId;
|
||||||
Oid tablespaceId;
|
Oid tablespaceId;
|
||||||
@ -592,7 +592,7 @@ DefineIndex(Oid relationId,
|
|||||||
* is more efficient. Do this before any use of the concurrent option is
|
* is more efficient. Do this before any use of the concurrent option is
|
||||||
* done.
|
* done.
|
||||||
*/
|
*/
|
||||||
if (stmt->concurrent && get_rel_persistence(relationId) != RELPERSISTENCE_TEMP)
|
if (stmt->concurrent && get_rel_persistence(tableId) != RELPERSISTENCE_TEMP)
|
||||||
concurrent = true;
|
concurrent = true;
|
||||||
else
|
else
|
||||||
concurrent = false;
|
concurrent = false;
|
||||||
@ -604,7 +604,7 @@ DefineIndex(Oid relationId,
|
|||||||
if (!OidIsValid(parentIndexId))
|
if (!OidIsValid(parentIndexId))
|
||||||
{
|
{
|
||||||
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
|
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
|
||||||
relationId);
|
tableId);
|
||||||
pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
|
pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
|
||||||
concurrent ?
|
concurrent ?
|
||||||
PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY :
|
PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY :
|
||||||
@ -649,7 +649,7 @@ DefineIndex(Oid relationId,
|
|||||||
* index build; but for concurrent builds we allow INSERT/UPDATE/DELETE
|
* index build; but for concurrent builds we allow INSERT/UPDATE/DELETE
|
||||||
* (but not VACUUM).
|
* (but not VACUUM).
|
||||||
*
|
*
|
||||||
* NB: Caller is responsible for making sure that relationId refers to the
|
* NB: Caller is responsible for making sure that tableId refers to the
|
||||||
* relation on which the index should be built; except in bootstrap mode,
|
* relation on which the index should be built; except in bootstrap mode,
|
||||||
* this will typically require the caller to have already locked the
|
* this will typically require the caller to have already locked the
|
||||||
* relation. To avoid lock upgrade hazards, that lock should be at least
|
* relation. To avoid lock upgrade hazards, that lock should be at least
|
||||||
@ -660,7 +660,7 @@ DefineIndex(Oid relationId,
|
|||||||
* functions will need to be updated, too.
|
* functions will need to be updated, too.
|
||||||
*/
|
*/
|
||||||
lockmode = concurrent ? ShareUpdateExclusiveLock : ShareLock;
|
lockmode = concurrent ? ShareUpdateExclusiveLock : ShareLock;
|
||||||
rel = table_open(relationId, lockmode);
|
rel = table_open(tableId, lockmode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switch to the table owner's userid, so that any index functions are run
|
* Switch to the table owner's userid, so that any index functions are run
|
||||||
@ -899,14 +899,14 @@ DefineIndex(Oid relationId,
|
|||||||
concurrent,
|
concurrent,
|
||||||
amissummarizing);
|
amissummarizing);
|
||||||
|
|
||||||
typeObjectId = palloc_array(Oid, numberOfAttributes);
|
typeIds = palloc_array(Oid, numberOfAttributes);
|
||||||
collationObjectId = palloc_array(Oid, numberOfAttributes);
|
collationIds = palloc_array(Oid, numberOfAttributes);
|
||||||
classObjectId = palloc_array(Oid, numberOfAttributes);
|
opclassIds = palloc_array(Oid, numberOfAttributes);
|
||||||
coloptions = palloc_array(int16, numberOfAttributes);
|
coloptions = palloc_array(int16, numberOfAttributes);
|
||||||
ComputeIndexAttrs(indexInfo,
|
ComputeIndexAttrs(indexInfo,
|
||||||
typeObjectId, collationObjectId, classObjectId,
|
typeIds, collationIds, opclassIds,
|
||||||
coloptions, allIndexParams,
|
coloptions, allIndexParams,
|
||||||
stmt->excludeOpNames, relationId,
|
stmt->excludeOpNames, tableId,
|
||||||
accessMethodName, accessMethodId,
|
accessMethodName, accessMethodId,
|
||||||
amcanorder, stmt->isconstraint, root_save_userid,
|
amcanorder, stmt->isconstraint, root_save_userid,
|
||||||
root_save_sec_context, &root_save_nestlevel);
|
root_save_sec_context, &root_save_nestlevel);
|
||||||
@ -1011,7 +1011,7 @@ DefineIndex(Oid relationId,
|
|||||||
Oid idx_opfamily;
|
Oid idx_opfamily;
|
||||||
Oid idx_opcintype;
|
Oid idx_opcintype;
|
||||||
|
|
||||||
if (get_opclass_opfamily_and_input_type(classObjectId[j],
|
if (get_opclass_opfamily_and_input_type(opclassIds[j],
|
||||||
&idx_opfamily,
|
&idx_opfamily,
|
||||||
&idx_opcintype))
|
&idx_opcintype))
|
||||||
{
|
{
|
||||||
@ -1181,7 +1181,7 @@ DefineIndex(Oid relationId,
|
|||||||
parentConstraintId,
|
parentConstraintId,
|
||||||
stmt->oldNumber, indexInfo, indexColNames,
|
stmt->oldNumber, indexInfo, indexColNames,
|
||||||
accessMethodId, tablespaceId,
|
accessMethodId, tablespaceId,
|
||||||
collationObjectId, classObjectId,
|
collationIds, opclassIds,
|
||||||
coloptions, reloptions,
|
coloptions, reloptions,
|
||||||
flags, constr_flags,
|
flags, constr_flags,
|
||||||
allowSystemTableMods, !check_rights,
|
allowSystemTableMods, !check_rights,
|
||||||
@ -1262,7 +1262,7 @@ DefineIndex(Oid relationId,
|
|||||||
*/
|
*/
|
||||||
if (total_parts < 0)
|
if (total_parts < 0)
|
||||||
{
|
{
|
||||||
List *children = find_all_inheritors(relationId,
|
List *children = find_all_inheritors(tableId,
|
||||||
NoLock, NULL);
|
NoLock, NULL);
|
||||||
|
|
||||||
total_parts = list_length(children) - 1;
|
total_parts = list_length(children) - 1;
|
||||||
@ -1674,7 +1674,7 @@ DefineIndex(Oid relationId,
|
|||||||
PushActiveSnapshot(GetTransactionSnapshot());
|
PushActiveSnapshot(GetTransactionSnapshot());
|
||||||
|
|
||||||
/* Perform concurrent build of index */
|
/* Perform concurrent build of index */
|
||||||
index_concurrently_build(relationId, indexRelationId);
|
index_concurrently_build(tableId, indexRelationId);
|
||||||
|
|
||||||
/* we can do away with our snapshot */
|
/* we can do away with our snapshot */
|
||||||
PopActiveSnapshot();
|
PopActiveSnapshot();
|
||||||
@ -1720,7 +1720,7 @@ DefineIndex(Oid relationId,
|
|||||||
/*
|
/*
|
||||||
* Scan the index and the heap, insert any missing index entries.
|
* Scan the index and the heap, insert any missing index entries.
|
||||||
*/
|
*/
|
||||||
validate_index(relationId, indexRelationId, snapshot);
|
validate_index(tableId, indexRelationId, snapshot);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drop the reference snapshot. We must do this before waiting out other
|
* Drop the reference snapshot. We must do this before waiting out other
|
||||||
@ -1855,10 +1855,10 @@ CheckPredicate(Expr *predicate)
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ComputeIndexAttrs(IndexInfo *indexInfo,
|
ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||||
Oid *typeOidP,
|
Oid *typeOids,
|
||||||
Oid *collationOidP,
|
Oid *collationOids,
|
||||||
Oid *classOidP,
|
Oid *opclassOids,
|
||||||
int16 *colOptionP,
|
int16 *colOptions,
|
||||||
const List *attList, /* list of IndexElem's */
|
const List *attList, /* list of IndexElem's */
|
||||||
const List *exclusionOpNames,
|
const List *exclusionOpNames,
|
||||||
Oid relId,
|
Oid relId,
|
||||||
@ -1988,7 +1988,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typeOidP[attn] = atttype;
|
typeOids[attn] = atttype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Included columns have no collation, no opclass and no ordering
|
* Included columns have no collation, no opclass and no ordering
|
||||||
@ -2013,9 +2013,9 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
|||||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||||
errmsg("including column does not support NULLS FIRST/LAST options")));
|
errmsg("including column does not support NULLS FIRST/LAST options")));
|
||||||
|
|
||||||
classOidP[attn] = InvalidOid;
|
opclassOids[attn] = InvalidOid;
|
||||||
colOptionP[attn] = 0;
|
colOptions[attn] = 0;
|
||||||
collationOidP[attn] = InvalidOid;
|
collationOids[attn] = InvalidOid;
|
||||||
attn++;
|
attn++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -2064,7 +2064,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
|||||||
format_type_be(atttype))));
|
format_type_be(atttype))));
|
||||||
}
|
}
|
||||||
|
|
||||||
collationOidP[attn] = attcollation;
|
collationOids[attn] = attcollation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Identify the opclass to use. Use of ddl_userid is necessary due to
|
* Identify the opclass to use. Use of ddl_userid is necessary due to
|
||||||
@ -2077,7 +2077,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
|||||||
AtEOXact_GUC(false, *ddl_save_nestlevel);
|
AtEOXact_GUC(false, *ddl_save_nestlevel);
|
||||||
SetUserIdAndSecContext(ddl_userid, ddl_sec_context);
|
SetUserIdAndSecContext(ddl_userid, ddl_sec_context);
|
||||||
}
|
}
|
||||||
classOidP[attn] = ResolveOpClass(attribute->opclass,
|
opclassOids[attn] = ResolveOpClass(attribute->opclass,
|
||||||
atttype,
|
atttype,
|
||||||
accessMethodName,
|
accessMethodName,
|
||||||
accessMethodId);
|
accessMethodId);
|
||||||
@ -2132,7 +2132,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
|||||||
/*
|
/*
|
||||||
* Operator must be a member of the right opfamily, too
|
* Operator must be a member of the right opfamily, too
|
||||||
*/
|
*/
|
||||||
opfamily = get_opclass_family(classOidP[attn]);
|
opfamily = get_opclass_family(opclassOids[attn]);
|
||||||
strat = get_op_opfamily_strategy(opid, opfamily);
|
strat = get_op_opfamily_strategy(opid, opfamily);
|
||||||
if (strat == 0)
|
if (strat == 0)
|
||||||
{
|
{
|
||||||
@ -2170,20 +2170,20 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
|||||||
* zero for any un-ordered index, while ordered indexes have DESC and
|
* zero for any un-ordered index, while ordered indexes have DESC and
|
||||||
* NULLS FIRST/LAST options.
|
* NULLS FIRST/LAST options.
|
||||||
*/
|
*/
|
||||||
colOptionP[attn] = 0;
|
colOptions[attn] = 0;
|
||||||
if (amcanorder)
|
if (amcanorder)
|
||||||
{
|
{
|
||||||
/* default ordering is ASC */
|
/* default ordering is ASC */
|
||||||
if (attribute->ordering == SORTBY_DESC)
|
if (attribute->ordering == SORTBY_DESC)
|
||||||
colOptionP[attn] |= INDOPTION_DESC;
|
colOptions[attn] |= INDOPTION_DESC;
|
||||||
/* default null ordering is LAST for ASC, FIRST for DESC */
|
/* default null ordering is LAST for ASC, FIRST for DESC */
|
||||||
if (attribute->nulls_ordering == SORTBY_NULLS_DEFAULT)
|
if (attribute->nulls_ordering == SORTBY_NULLS_DEFAULT)
|
||||||
{
|
{
|
||||||
if (attribute->ordering == SORTBY_DESC)
|
if (attribute->ordering == SORTBY_DESC)
|
||||||
colOptionP[attn] |= INDOPTION_NULLS_FIRST;
|
colOptions[attn] |= INDOPTION_NULLS_FIRST;
|
||||||
}
|
}
|
||||||
else if (attribute->nulls_ordering == SORTBY_NULLS_FIRST)
|
else if (attribute->nulls_ordering == SORTBY_NULLS_FIRST)
|
||||||
colOptionP[attn] |= INDOPTION_NULLS_FIRST;
|
colOptions[attn] |= INDOPTION_NULLS_FIRST;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -74,10 +74,10 @@ extern Oid index_create(Relation heapRelation,
|
|||||||
RelFileNumber relFileNumber,
|
RelFileNumber relFileNumber,
|
||||||
IndexInfo *indexInfo,
|
IndexInfo *indexInfo,
|
||||||
const List *indexColNames,
|
const List *indexColNames,
|
||||||
Oid accessMethodObjectId,
|
Oid accessMethodId,
|
||||||
Oid tableSpaceId,
|
Oid tableSpaceId,
|
||||||
const Oid *collationObjectId,
|
const Oid *collationIds,
|
||||||
const Oid *classObjectId,
|
const Oid *opclassIds,
|
||||||
const int16 *coloptions,
|
const int16 *coloptions,
|
||||||
Datum reloptions,
|
Datum reloptions,
|
||||||
bits16 flags,
|
bits16 flags,
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
extern void RemoveObjects(DropStmt *stmt);
|
extern void RemoveObjects(DropStmt *stmt);
|
||||||
|
|
||||||
/* commands/indexcmds.c */
|
/* commands/indexcmds.c */
|
||||||
extern ObjectAddress DefineIndex(Oid relationId,
|
extern ObjectAddress DefineIndex(Oid tableId,
|
||||||
IndexStmt *stmt,
|
IndexStmt *stmt,
|
||||||
Oid indexRelationId,
|
Oid indexRelationId,
|
||||||
Oid parentIndexId,
|
Oid parentIndexId,
|
||||||
|
Reference in New Issue
Block a user