mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Add const decorations
in index.c and indexcmds.c and some adjacent places. This especially makes it easier to understand for some complicated function signatures which are the input and the output arguments. Discussion: https://www.postgresql.org/message-id/flat/5ed89c69-f4e6-5dab-4003-63bde7460e5e%40eisentraut.org
This commit is contained in:
@@ -914,7 +914,7 @@ AllocateAttribute(void)
|
||||
void
|
||||
index_register(Oid heap,
|
||||
Oid ind,
|
||||
IndexInfo *indexInfo)
|
||||
const IndexInfo *indexInfo)
|
||||
{
|
||||
IndexList *newind;
|
||||
MemoryContext oldcxt;
|
||||
|
@@ -697,7 +697,7 @@ void
|
||||
InsertPgAttributeTuples(Relation pg_attribute_rel,
|
||||
TupleDesc tupdesc,
|
||||
Oid new_rel_oid,
|
||||
Datum *attoptions,
|
||||
const Datum *attoptions,
|
||||
CatalogIndexState indstate)
|
||||
{
|
||||
TupleTableSlot **slot;
|
||||
|
@@ -106,20 +106,20 @@ typedef struct
|
||||
/* non-export function prototypes */
|
||||
static bool relationHasPrimaryKey(Relation rel);
|
||||
static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
|
||||
IndexInfo *indexInfo,
|
||||
List *indexColNames,
|
||||
const IndexInfo *indexInfo,
|
||||
const List *indexColNames,
|
||||
Oid accessMethodObjectId,
|
||||
Oid *collationObjectId,
|
||||
Oid *classObjectId);
|
||||
const Oid *collationObjectId,
|
||||
const Oid *classObjectId);
|
||||
static void InitializeAttributeOids(Relation indexRelation,
|
||||
int numatts, Oid indexoid);
|
||||
static void AppendAttributeTuples(Relation indexRelation, Datum *attopts);
|
||||
static void AppendAttributeTuples(Relation indexRelation, const Datum *attopts);
|
||||
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
||||
Oid parentIndexId,
|
||||
IndexInfo *indexInfo,
|
||||
Oid *collationOids,
|
||||
Oid *classOids,
|
||||
int16 *coloptions,
|
||||
const IndexInfo *indexInfo,
|
||||
const Oid *collationOids,
|
||||
const Oid *classOids,
|
||||
const int16 *coloptions,
|
||||
bool primary,
|
||||
bool isexclusion,
|
||||
bool immediate,
|
||||
@@ -205,9 +205,9 @@ relationHasPrimaryKey(Relation rel)
|
||||
*/
|
||||
void
|
||||
index_check_primary_key(Relation heapRel,
|
||||
IndexInfo *indexInfo,
|
||||
const IndexInfo *indexInfo,
|
||||
bool is_alter_table,
|
||||
IndexStmt *stmt)
|
||||
const IndexStmt *stmt)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -284,11 +284,11 @@ index_check_primary_key(Relation heapRel,
|
||||
*/
|
||||
static TupleDesc
|
||||
ConstructTupleDescriptor(Relation heapRelation,
|
||||
IndexInfo *indexInfo,
|
||||
List *indexColNames,
|
||||
const IndexInfo *indexInfo,
|
||||
const List *indexColNames,
|
||||
Oid accessMethodObjectId,
|
||||
Oid *collationObjectId,
|
||||
Oid *classObjectId)
|
||||
const Oid *collationObjectId,
|
||||
const Oid *classObjectId)
|
||||
{
|
||||
int numatts = indexInfo->ii_NumIndexAttrs;
|
||||
int numkeyatts = indexInfo->ii_NumIndexKeyAttrs;
|
||||
@@ -516,7 +516,7 @@ InitializeAttributeOids(Relation indexRelation,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
AppendAttributeTuples(Relation indexRelation, Datum *attopts)
|
||||
AppendAttributeTuples(Relation indexRelation, const Datum *attopts)
|
||||
{
|
||||
Relation pg_attribute;
|
||||
CatalogIndexState indstate;
|
||||
@@ -551,10 +551,10 @@ static void
|
||||
UpdateIndexRelation(Oid indexoid,
|
||||
Oid heapoid,
|
||||
Oid parentIndexId,
|
||||
IndexInfo *indexInfo,
|
||||
Oid *collationOids,
|
||||
Oid *classOids,
|
||||
int16 *coloptions,
|
||||
const IndexInfo *indexInfo,
|
||||
const Oid *collationOids,
|
||||
const Oid *classOids,
|
||||
const int16 *coloptions,
|
||||
bool primary,
|
||||
bool isexclusion,
|
||||
bool immediate,
|
||||
@@ -718,12 +718,12 @@ index_create(Relation heapRelation,
|
||||
Oid parentConstraintId,
|
||||
RelFileNumber relFileNumber,
|
||||
IndexInfo *indexInfo,
|
||||
List *indexColNames,
|
||||
const List *indexColNames,
|
||||
Oid accessMethodObjectId,
|
||||
Oid tableSpaceId,
|
||||
Oid *collationObjectId,
|
||||
Oid *classObjectId,
|
||||
int16 *coloptions,
|
||||
const Oid *collationObjectId,
|
||||
const Oid *classObjectId,
|
||||
const int16 *coloptions,
|
||||
Datum reloptions,
|
||||
bits16 flags,
|
||||
bits16 constr_flags,
|
||||
@@ -1908,7 +1908,7 @@ ObjectAddress
|
||||
index_constraint_create(Relation heapRelation,
|
||||
Oid indexRelationId,
|
||||
Oid parentConstraintId,
|
||||
IndexInfo *indexInfo,
|
||||
const IndexInfo *indexInfo,
|
||||
const char *constraintName,
|
||||
char constraintType,
|
||||
bits16 constr_flags,
|
||||
@@ -2537,10 +2537,10 @@ BuildDummyIndexInfo(Relation index)
|
||||
* Use build_attrmap_by_name(index2, index1) to build the attmap.
|
||||
*/
|
||||
bool
|
||||
CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
|
||||
Oid *collations1, Oid *collations2,
|
||||
Oid *opfamilies1, Oid *opfamilies2,
|
||||
AttrMap *attmap)
|
||||
CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2,
|
||||
const Oid *collations1, const Oid *collations2,
|
||||
const Oid *opfamilies1, const Oid *opfamilies2,
|
||||
const AttrMap *attmap)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -3559,7 +3559,7 @@ IndexGetRelation(Oid indexId, bool missing_ok)
|
||||
*/
|
||||
void
|
||||
reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
|
||||
ReindexParams *params)
|
||||
const ReindexParams *params)
|
||||
{
|
||||
Relation iRel,
|
||||
heapRelation;
|
||||
@@ -3872,7 +3872,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
|
||||
* index rebuild.
|
||||
*/
|
||||
bool
|
||||
reindex_relation(Oid relid, int flags, ReindexParams *params)
|
||||
reindex_relation(Oid relid, int flags, const ReindexParams *params)
|
||||
{
|
||||
Relation rel;
|
||||
Oid toast_relid;
|
||||
@@ -4177,9 +4177,9 @@ SerializeReindexState(Size maxsize, char *start_address)
|
||||
* Restore reindex state in a parallel worker.
|
||||
*/
|
||||
void
|
||||
RestoreReindexState(void *reindexstate)
|
||||
RestoreReindexState(const void *reindexstate)
|
||||
{
|
||||
SerializedReindexState *sistate = (SerializedReindexState *) reindexstate;
|
||||
const SerializedReindexState *sistate = (const SerializedReindexState *) reindexstate;
|
||||
int c = 0;
|
||||
MemoryContext oldcontext;
|
||||
|
||||
|
@@ -2831,7 +2831,7 @@ TSConfigIsVisible(Oid cfgid)
|
||||
* *nspname_p is set to NULL if there is no explicit schema name.
|
||||
*/
|
||||
void
|
||||
DeconstructQualifiedName(List *names,
|
||||
DeconstructQualifiedName(const List *names,
|
||||
char **nspname_p,
|
||||
char **objname_p)
|
||||
{
|
||||
@@ -3017,7 +3017,7 @@ CheckSetNamespace(Oid oldNspOid, Oid nspOid)
|
||||
* if we have to create or clean out the temp namespace.
|
||||
*/
|
||||
Oid
|
||||
QualifiedNameGetCreationNamespace(List *names, char **objname_p)
|
||||
QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
|
||||
{
|
||||
char *schemaname;
|
||||
Oid namespaceId;
|
||||
@@ -3084,7 +3084,7 @@ get_namespace_oid(const char *nspname, bool missing_ok)
|
||||
* Utility routine to convert a qualified-name list into RangeVar form.
|
||||
*/
|
||||
RangeVar *
|
||||
makeRangeVarFromNameList(List *names)
|
||||
makeRangeVarFromNameList(const List *names)
|
||||
{
|
||||
RangeVar *rel = makeRangeVar(NULL, NULL, -1);
|
||||
|
||||
@@ -3124,7 +3124,7 @@ makeRangeVarFromNameList(List *names)
|
||||
* but we also allow A_Star for the convenience of ColumnRef processing.
|
||||
*/
|
||||
char *
|
||||
NameListToString(List *names)
|
||||
NameListToString(const List *names)
|
||||
{
|
||||
StringInfoData string;
|
||||
ListCell *l;
|
||||
@@ -3158,7 +3158,7 @@ NameListToString(List *names)
|
||||
* so the string could be re-parsed (eg, by textToQualifiedNameList).
|
||||
*/
|
||||
char *
|
||||
NameListToQuotedString(List *names)
|
||||
NameListToQuotedString(const List *names)
|
||||
{
|
||||
StringInfoData string;
|
||||
ListCell *l;
|
||||
|
@@ -71,15 +71,15 @@
|
||||
|
||||
|
||||
/* non-export function prototypes */
|
||||
static bool CompareOpclassOptions(Datum *opts1, Datum *opts2, int natts);
|
||||
static bool CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts);
|
||||
static void CheckPredicate(Expr *predicate);
|
||||
static void ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
Oid *typeOidP,
|
||||
Oid *collationOidP,
|
||||
Oid *classOidP,
|
||||
int16 *colOptionP,
|
||||
List *attList,
|
||||
List *exclusionOpNames,
|
||||
const List *attList,
|
||||
const List *exclusionOpNames,
|
||||
Oid relId,
|
||||
const char *accessMethodName, Oid accessMethodId,
|
||||
bool amcanorder,
|
||||
@@ -88,25 +88,25 @@ static void ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
int ddl_sec_context,
|
||||
int *ddl_save_nestlevel);
|
||||
static char *ChooseIndexName(const char *tabname, Oid namespaceId,
|
||||
List *colnames, List *exclusionOpNames,
|
||||
const List *colnames, const List *exclusionOpNames,
|
||||
bool primary, bool isconstraint);
|
||||
static char *ChooseIndexNameAddition(List *colnames);
|
||||
static List *ChooseIndexColumnNames(List *indexElems);
|
||||
static void ReindexIndex(RangeVar *indexRelation, ReindexParams *params,
|
||||
static char *ChooseIndexNameAddition(const List *colnames);
|
||||
static List *ChooseIndexColumnNames(const List *indexElems);
|
||||
static void ReindexIndex(const RangeVar *indexRelation, const ReindexParams *params,
|
||||
bool isTopLevel);
|
||||
static void RangeVarCallbackForReindexIndex(const RangeVar *relation,
|
||||
Oid relId, Oid oldRelId, void *arg);
|
||||
static Oid ReindexTable(RangeVar *relation, ReindexParams *params,
|
||||
static Oid ReindexTable(const RangeVar *relation, const ReindexParams *params,
|
||||
bool isTopLevel);
|
||||
static void ReindexMultipleTables(const char *objectName,
|
||||
ReindexObjectType objectKind, ReindexParams *params);
|
||||
ReindexObjectType objectKind, const ReindexParams *params);
|
||||
static void reindex_error_callback(void *arg);
|
||||
static void ReindexPartitions(Oid relid, ReindexParams *params,
|
||||
static void ReindexPartitions(Oid relid, const ReindexParams *params,
|
||||
bool isTopLevel);
|
||||
static void ReindexMultipleInternal(List *relids,
|
||||
ReindexParams *params);
|
||||
static void ReindexMultipleInternal(const List *relids,
|
||||
const ReindexParams *params);
|
||||
static bool ReindexRelationConcurrently(Oid relationOid,
|
||||
ReindexParams *params);
|
||||
const ReindexParams *params);
|
||||
static void update_relispartition(Oid relationId, bool newval);
|
||||
static inline void set_indexsafe_procflags(void);
|
||||
|
||||
@@ -169,8 +169,8 @@ typedef struct ReindexErrorInfo
|
||||
bool
|
||||
CheckIndexCompatible(Oid oldId,
|
||||
const char *accessMethodName,
|
||||
List *attributeList,
|
||||
List *exclusionOpNames)
|
||||
const List *attributeList,
|
||||
const List *exclusionOpNames)
|
||||
{
|
||||
bool isconstraint;
|
||||
Oid *typeObjectId;
|
||||
@@ -349,7 +349,7 @@ CheckIndexCompatible(Oid oldId,
|
||||
* datums. Both elements of arrays and array themselves can be NULL.
|
||||
*/
|
||||
static bool
|
||||
CompareOpclassOptions(Datum *opts1, Datum *opts2, int natts)
|
||||
CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1859,8 +1859,8 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
Oid *collationOidP,
|
||||
Oid *classOidP,
|
||||
int16 *colOptionP,
|
||||
List *attList, /* list of IndexElem's */
|
||||
List *exclusionOpNames,
|
||||
const List *attList, /* list of IndexElem's */
|
||||
const List *exclusionOpNames,
|
||||
Oid relId,
|
||||
const char *accessMethodName,
|
||||
Oid accessMethodId,
|
||||
@@ -2225,7 +2225,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
* partition key definitions.
|
||||
*/
|
||||
Oid
|
||||
ResolveOpClass(List *opclass, Oid attrType,
|
||||
ResolveOpClass(const List *opclass, Oid attrType,
|
||||
const char *accessMethodName, Oid accessMethodId)
|
||||
{
|
||||
char *schemaname;
|
||||
@@ -2542,7 +2542,7 @@ ChooseRelationName(const char *name1, const char *name2,
|
||||
*/
|
||||
static char *
|
||||
ChooseIndexName(const char *tabname, Oid namespaceId,
|
||||
List *colnames, List *exclusionOpNames,
|
||||
const List *colnames, const List *exclusionOpNames,
|
||||
bool primary, bool isconstraint)
|
||||
{
|
||||
char *indexname;
|
||||
@@ -2596,7 +2596,7 @@ ChooseIndexName(const char *tabname, Oid namespaceId,
|
||||
* ChooseExtendedStatisticNameAddition.
|
||||
*/
|
||||
static char *
|
||||
ChooseIndexNameAddition(List *colnames)
|
||||
ChooseIndexNameAddition(const List *colnames)
|
||||
{
|
||||
char buf[NAMEDATALEN * 2];
|
||||
int buflen = 0;
|
||||
@@ -2630,7 +2630,7 @@ ChooseIndexNameAddition(List *colnames)
|
||||
* Returns a List of plain strings (char *, not String nodes).
|
||||
*/
|
||||
static List *
|
||||
ChooseIndexColumnNames(List *indexElems)
|
||||
ChooseIndexColumnNames(const List *indexElems)
|
||||
{
|
||||
List *result = NIL;
|
||||
ListCell *lc;
|
||||
@@ -2691,7 +2691,7 @@ ChooseIndexColumnNames(List *indexElems)
|
||||
* each subroutine of REINDEX.
|
||||
*/
|
||||
void
|
||||
ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool isTopLevel)
|
||||
ExecReindex(ParseState *pstate, const ReindexStmt *stmt, bool isTopLevel)
|
||||
{
|
||||
ReindexParams params = {0};
|
||||
ListCell *lc;
|
||||
@@ -2786,7 +2786,7 @@ ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool isTopLevel)
|
||||
* Recreate a specific index.
|
||||
*/
|
||||
static void
|
||||
ReindexIndex(RangeVar *indexRelation, ReindexParams *params, bool isTopLevel)
|
||||
ReindexIndex(const RangeVar *indexRelation, const ReindexParams *params, bool isTopLevel)
|
||||
{
|
||||
struct ReindexIndexCallbackState state;
|
||||
Oid indOid;
|
||||
@@ -2909,7 +2909,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation,
|
||||
* Recreate all indexes of a table (and of its toast table, if any)
|
||||
*/
|
||||
static Oid
|
||||
ReindexTable(RangeVar *relation, ReindexParams *params, bool isTopLevel)
|
||||
ReindexTable(const RangeVar *relation, const ReindexParams *params, bool isTopLevel)
|
||||
{
|
||||
Oid heapOid;
|
||||
bool result;
|
||||
@@ -2968,7 +2968,7 @@ ReindexTable(RangeVar *relation, ReindexParams *params, bool isTopLevel)
|
||||
*/
|
||||
static void
|
||||
ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
|
||||
ReindexParams *params)
|
||||
const ReindexParams *params)
|
||||
{
|
||||
Oid objectOid;
|
||||
Relation relationRelation;
|
||||
@@ -3206,7 +3206,7 @@ reindex_error_callback(void *arg)
|
||||
* by the caller.
|
||||
*/
|
||||
static void
|
||||
ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel)
|
||||
ReindexPartitions(Oid relid, const ReindexParams *params, bool isTopLevel)
|
||||
{
|
||||
List *partitions = NIL;
|
||||
char relkind = get_rel_relkind(relid);
|
||||
@@ -3300,7 +3300,7 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel)
|
||||
* and starts a new transaction when finished.
|
||||
*/
|
||||
static void
|
||||
ReindexMultipleInternal(List *relids, ReindexParams *params)
|
||||
ReindexMultipleInternal(const List *relids, const ReindexParams *params)
|
||||
{
|
||||
ListCell *l;
|
||||
|
||||
@@ -3424,7 +3424,7 @@ ReindexMultipleInternal(List *relids, ReindexParams *params)
|
||||
* anyway, and a non-concurrent reindex is more efficient.
|
||||
*/
|
||||
static bool
|
||||
ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
|
||||
ReindexRelationConcurrently(Oid relationOid, const ReindexParams *params)
|
||||
{
|
||||
typedef struct ReindexIndexInfo
|
||||
{
|
||||
|
Reference in New Issue
Block a user