Skip to content

Commit 11af63f

Browse files
committed
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
1 parent f4b54e1 commit 11af63f

File tree

10 files changed

+94
-94
lines changed

10 files changed

+94
-94
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ AllocateAttribute(void)
914914
void
915915
index_register(Oid heap,
916916
Oid ind,
917-
IndexInfo *indexInfo)
917+
const IndexInfo *indexInfo)
918918
{
919919
IndexList *newind;
920920
MemoryContext oldcxt;

src/backend/catalog/heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ void
697697
InsertPgAttributeTuples(Relation pg_attribute_rel,
698698
TupleDesc tupdesc,
699699
Oid new_rel_oid,
700-
Datum *attoptions,
700+
const Datum *attoptions,
701701
CatalogIndexState indstate)
702702
{
703703
TupleTableSlot **slot;

src/backend/catalog/index.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,20 @@ typedef struct
106106
/* non-export function prototypes */
107107
static bool relationHasPrimaryKey(Relation rel);
108108
static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
109-
IndexInfo *indexInfo,
110-
List *indexColNames,
109+
const IndexInfo *indexInfo,
110+
const List *indexColNames,
111111
Oid accessMethodObjectId,
112-
Oid *collationObjectId,
113-
Oid *classObjectId);
112+
const Oid *collationObjectId,
113+
const Oid *classObjectId);
114114
static void InitializeAttributeOids(Relation indexRelation,
115115
int numatts, Oid indexoid);
116-
static void AppendAttributeTuples(Relation indexRelation, Datum *attopts);
116+
static void AppendAttributeTuples(Relation indexRelation, const Datum *attopts);
117117
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
118118
Oid parentIndexId,
119-
IndexInfo *indexInfo,
120-
Oid *collationOids,
121-
Oid *classOids,
122-
int16 *coloptions,
119+
const IndexInfo *indexInfo,
120+
const Oid *collationOids,
121+
const Oid *classOids,
122+
const int16 *coloptions,
123123
bool primary,
124124
bool isexclusion,
125125
bool immediate,
@@ -205,9 +205,9 @@ relationHasPrimaryKey(Relation rel)
205205
*/
206206
void
207207
index_check_primary_key(Relation heapRel,
208-
IndexInfo *indexInfo,
208+
const IndexInfo *indexInfo,
209209
bool is_alter_table,
210-
IndexStmt *stmt)
210+
const IndexStmt *stmt)
211211
{
212212
int i;
213213

@@ -284,11 +284,11 @@ index_check_primary_key(Relation heapRel,
284284
*/
285285
static TupleDesc
286286
ConstructTupleDescriptor(Relation heapRelation,
287-
IndexInfo *indexInfo,
288-
List *indexColNames,
287+
const IndexInfo *indexInfo,
288+
const List *indexColNames,
289289
Oid accessMethodObjectId,
290-
Oid *collationObjectId,
291-
Oid *classObjectId)
290+
const Oid *collationObjectId,
291+
const Oid *classObjectId)
292292
{
293293
int numatts = indexInfo->ii_NumIndexAttrs;
294294
int numkeyatts = indexInfo->ii_NumIndexKeyAttrs;
@@ -516,7 +516,7 @@ InitializeAttributeOids(Relation indexRelation,
516516
* ----------------------------------------------------------------
517517
*/
518518
static void
519-
AppendAttributeTuples(Relation indexRelation, Datum *attopts)
519+
AppendAttributeTuples(Relation indexRelation, const Datum *attopts)
520520
{
521521
Relation pg_attribute;
522522
CatalogIndexState indstate;
@@ -551,10 +551,10 @@ static void
551551
UpdateIndexRelation(Oid indexoid,
552552
Oid heapoid,
553553
Oid parentIndexId,
554-
IndexInfo *indexInfo,
555-
Oid *collationOids,
556-
Oid *classOids,
557-
int16 *coloptions,
554+
const IndexInfo *indexInfo,
555+
const Oid *collationOids,
556+
const Oid *classOids,
557+
const int16 *coloptions,
558558
bool primary,
559559
bool isexclusion,
560560
bool immediate,
@@ -718,12 +718,12 @@ index_create(Relation heapRelation,
718718
Oid parentConstraintId,
719719
RelFileNumber relFileNumber,
720720
IndexInfo *indexInfo,
721-
List *indexColNames,
721+
const List *indexColNames,
722722
Oid accessMethodObjectId,
723723
Oid tableSpaceId,
724-
Oid *collationObjectId,
725-
Oid *classObjectId,
726-
int16 *coloptions,
724+
const Oid *collationObjectId,
725+
const Oid *classObjectId,
726+
const int16 *coloptions,
727727
Datum reloptions,
728728
bits16 flags,
729729
bits16 constr_flags,
@@ -1908,7 +1908,7 @@ ObjectAddress
19081908
index_constraint_create(Relation heapRelation,
19091909
Oid indexRelationId,
19101910
Oid parentConstraintId,
1911-
IndexInfo *indexInfo,
1911+
const IndexInfo *indexInfo,
19121912
const char *constraintName,
19131913
char constraintType,
19141914
bits16 constr_flags,
@@ -2537,10 +2537,10 @@ BuildDummyIndexInfo(Relation index)
25372537
* Use build_attrmap_by_name(index2, index1) to build the attmap.
25382538
*/
25392539
bool
2540-
CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
2541-
Oid *collations1, Oid *collations2,
2542-
Oid *opfamilies1, Oid *opfamilies2,
2543-
AttrMap *attmap)
2540+
CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2,
2541+
const Oid *collations1, const Oid *collations2,
2542+
const Oid *opfamilies1, const Oid *opfamilies2,
2543+
const AttrMap *attmap)
25442544
{
25452545
int i;
25462546

@@ -3559,7 +3559,7 @@ IndexGetRelation(Oid indexId, bool missing_ok)
35593559
*/
35603560
void
35613561
reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
3562-
ReindexParams *params)
3562+
const ReindexParams *params)
35633563
{
35643564
Relation iRel,
35653565
heapRelation;
@@ -3872,7 +3872,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
38723872
* index rebuild.
38733873
*/
38743874
bool
3875-
reindex_relation(Oid relid, int flags, ReindexParams *params)
3875+
reindex_relation(Oid relid, int flags, const ReindexParams *params)
38763876
{
38773877
Relation rel;
38783878
Oid toast_relid;
@@ -4177,9 +4177,9 @@ SerializeReindexState(Size maxsize, char *start_address)
41774177
* Restore reindex state in a parallel worker.
41784178
*/
41794179
void
4180-
RestoreReindexState(void *reindexstate)
4180+
RestoreReindexState(const void *reindexstate)
41814181
{
4182-
SerializedReindexState *sistate = (SerializedReindexState *) reindexstate;
4182+
const SerializedReindexState *sistate = (const SerializedReindexState *) reindexstate;
41834183
int c = 0;
41844184
MemoryContext oldcontext;
41854185

src/backend/catalog/namespace.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,7 @@ TSConfigIsVisible(Oid cfgid)
28312831
* *nspname_p is set to NULL if there is no explicit schema name.
28322832
*/
28332833
void
2834-
DeconstructQualifiedName(List *names,
2834+
DeconstructQualifiedName(const List *names,
28352835
char **nspname_p,
28362836
char **objname_p)
28372837
{
@@ -3017,7 +3017,7 @@ CheckSetNamespace(Oid oldNspOid, Oid nspOid)
30173017
* if we have to create or clean out the temp namespace.
30183018
*/
30193019
Oid
3020-
QualifiedNameGetCreationNamespace(List *names, char **objname_p)
3020+
QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
30213021
{
30223022
char *schemaname;
30233023
Oid namespaceId;
@@ -3084,7 +3084,7 @@ get_namespace_oid(const char *nspname, bool missing_ok)
30843084
* Utility routine to convert a qualified-name list into RangeVar form.
30853085
*/
30863086
RangeVar *
3087-
makeRangeVarFromNameList(List *names)
3087+
makeRangeVarFromNameList(const List *names)
30883088
{
30893089
RangeVar *rel = makeRangeVar(NULL, NULL, -1);
30903090

@@ -3124,7 +3124,7 @@ makeRangeVarFromNameList(List *names)
31243124
* but we also allow A_Star for the convenience of ColumnRef processing.
31253125
*/
31263126
char *
3127-
NameListToString(List *names)
3127+
NameListToString(const List *names)
31283128
{
31293129
StringInfoData string;
31303130
ListCell *l;
@@ -3158,7 +3158,7 @@ NameListToString(List *names)
31583158
* so the string could be re-parsed (eg, by textToQualifiedNameList).
31593159
*/
31603160
char *
3161-
NameListToQuotedString(List *names)
3161+
NameListToQuotedString(const List *names)
31623162
{
31633163
StringInfoData string;
31643164
ListCell *l;

0 commit comments

Comments
 (0)