]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Rename validate_relation_kind()
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 23 Feb 2026 16:38:06 +0000 (17:38 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 23 Feb 2026 16:38:06 +0000 (17:38 +0100)
There are three static definitions of validate_relation_kind() in the
codebase, one each in table.c, indexam.c and sequence.c, validating that
the given relation is a table, an index or a sequence respectively.
The compiler knows which definition to use where because they are static.
But this could be confusing to a reader. Rename these functions so that
their names reflect the kind of relation they are validating. While at
it, also update the comments in table.c to clarify the definition of
table-like relkinds so that we don't have to maintain the exclusion list
as the set of relkinds undergoes changes.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6d3fef19-a420-4e11-8235-8ea534bf2080%40eisentraut.org

src/backend/access/index/indexam.c
src/backend/access/sequence/sequence.c
src/backend/access/table/table.c

index 4ed0508c605be8d18d1cf6dfe6baffb1c3e2ce77..43f64a0e7219c3747eea93f0688585103d189cc3 100644 (file)
@@ -107,7 +107,7 @@ do { \
 static IndexScanDesc index_beginscan_internal(Relation indexRelation,
                                                                                          int nkeys, int norderbys, Snapshot snapshot,
                                                                                          ParallelIndexScanDesc pscan, bool temp_snap);
-static inline void validate_relation_kind(Relation r);
+static inline void validate_relation_as_index(Relation r);
 
 
 /* ----------------------------------------------------------------
@@ -136,7 +136,7 @@ index_open(Oid relationId, LOCKMODE lockmode)
 
        r = relation_open(relationId, lockmode);
 
-       validate_relation_kind(r);
+       validate_relation_as_index(r);
 
        return r;
 }
@@ -159,7 +159,7 @@ try_index_open(Oid relationId, LOCKMODE lockmode)
        if (!r)
                return NULL;
 
-       validate_relation_kind(r);
+       validate_relation_as_index(r);
 
        return r;
 }
@@ -188,13 +188,13 @@ index_close(Relation relation, LOCKMODE lockmode)
 }
 
 /* ----------------
- *             validate_relation_kind - check the relation's kind
+ *             validate_relation_as_index
  *
  *             Make sure relkind is an index or a partitioned index.
  * ----------------
  */
 static inline void
-validate_relation_kind(Relation r)
+validate_relation_as_index(Relation r)
 {
        if (r->rd_rel->relkind != RELKIND_INDEX &&
                r->rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
index 6897f8432d676b92e6219fa187b3eefef9756cb9..81f46163749d9c1ff6631badc5d933a02d20e38c 100644 (file)
@@ -24,7 +24,7 @@
 #include "access/sequence.h"
 #include "utils/rel.h"
 
-static inline void validate_relation_kind(Relation r);
+static inline void validate_relation_as_sequence(Relation r);
 
 /* ----------------
  *             sequence_open - open a sequence relation by relation OID
@@ -40,7 +40,7 @@ sequence_open(Oid relationId, LOCKMODE lockmode)
 
        r = relation_open(relationId, lockmode);
 
-       validate_relation_kind(r);
+       validate_relation_as_sequence(r);
 
        return r;
 }
@@ -61,13 +61,13 @@ sequence_close(Relation relation, LOCKMODE lockmode)
 }
 
 /* ----------------
- *             validate_relation_kind - check the relation's kind
+ *             validate_relation_as_sequence
  *
  *             Make sure relkind is a sequence.
  * ----------------
  */
 static inline void
-validate_relation_kind(Relation r)
+validate_relation_as_sequence(Relation r)
 {
        if (r->rd_rel->relkind != RELKIND_SEQUENCE)
                ereport(ERROR,
index 0d8662a145268b04e7642601edaa0555b8748499..3479b4633effd922114673783c7f26faa8ca858b 100644 (file)
@@ -25,7 +25,7 @@
 #include "access/table.h"
 #include "utils/rel.h"
 
-static inline void validate_relation_kind(Relation r);
+static inline void validate_relation_as_table(Relation r);
 
 /* ----------------
  *             table_open - open a table relation by relation OID
@@ -43,7 +43,7 @@ table_open(Oid relationId, LOCKMODE lockmode)
 
        r = relation_open(relationId, lockmode);
 
-       validate_relation_kind(r);
+       validate_relation_as_table(r);
 
        return r;
 }
@@ -67,7 +67,7 @@ try_table_open(Oid relationId, LOCKMODE lockmode)
        if (!r)
                return NULL;
 
-       validate_relation_kind(r);
+       validate_relation_as_table(r);
 
        return r;
 }
@@ -86,7 +86,7 @@ table_openrv(const RangeVar *relation, LOCKMODE lockmode)
 
        r = relation_openrv(relation, lockmode);
 
-       validate_relation_kind(r);
+       validate_relation_as_table(r);
 
        return r;
 }
@@ -108,7 +108,7 @@ table_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
        r = relation_openrv_extended(relation, lockmode, missing_ok);
 
        if (r)
-               validate_relation_kind(r);
+               validate_relation_as_table(r);
 
        return r;
 }
@@ -129,14 +129,14 @@ table_close(Relation relation, LOCKMODE lockmode)
 }
 
 /* ----------------
- *             validate_relation_kind - check the relation's kind
+ *             validate_relation_as_table
  *
- *             Make sure relkind is table-like.  In particular, this excludes indexes
- *             and composite types, which cannot be read from in a query.
+ *             Make sure relkind is table-like, that is, something that could be read
+ *             from or written to directly in a query.
  * ----------------
  */
 static inline void
-validate_relation_kind(Relation r)
+validate_relation_as_table(Relation r)
 {
        if (r->rd_rel->relkind != RELKIND_RELATION &&
                r->rd_rel->relkind != RELKIND_SEQUENCE &&