]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix misuse of Relids for storing attribute numbers
authorRichard Guo <rguo@postgresql.org>
Fri, 12 Sep 2025 02:12:19 +0000 (11:12 +0900)
committerRichard Guo <rguo@postgresql.org>
Fri, 12 Sep 2025 02:12:19 +0000 (11:12 +0900)
The typedef Relids (Bitmapset *) is intended to represent set of
relation identifiers, but was incorrectly used in several places to
store sets of attribute numbers.  This is my oversight in e2debb643.

Fix that by replacing such usages with Bitmapset * to reflect the
correct semantics.

Author: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAEG8a3LJhp_xriXf39iCz0TsK+M-2biuhDhpLC6Baxw8+ZYT3A@mail.gmail.com

src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/plancat.c
src/include/optimizer/plancat.h

index 6f0b338d2cdf12c9bf3a77c43c8e4d7b389be0fa..ae0bd073ca917f7f0322834047ca8f9839aa8208 100644 (file)
@@ -4203,7 +4203,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
 bool
 var_is_nonnullable(PlannerInfo *root, Var *var, bool use_rel_info)
 {
-       Relids          notnullattnums = NULL;
+       Bitmapset  *notnullattnums = NULL;
 
        Assert(IsA(var, Var));
 
index 4536bdd6cb4d71ec7681359257084e3ca7534181..572d626b2c4d2dda0558fd6e6eccf1458fca20a8 100644 (file)
@@ -62,7 +62,7 @@ get_relation_info_hook_type get_relation_info_hook = NULL;
 typedef struct NotnullHashEntry
 {
        Oid                     relid;                  /* OID of the relation */
-       Relids          notnullattnums; /* attnums of NOT NULL columns */
+       Bitmapset  *notnullattnums; /* attnums of NOT NULL columns */
 } NotnullHashEntry;
 
 
@@ -683,7 +683,7 @@ get_relation_notnullatts(PlannerInfo *root, Relation relation)
        Oid                     relid = RelationGetRelid(relation);
        NotnullHashEntry *hentry;
        bool            found;
-       Relids          notnullattnums = NULL;
+       Bitmapset  *notnullattnums = NULL;
 
        /* bail out if the relation has no not-null constraints */
        if (relation->rd_att->constr == NULL ||
@@ -750,7 +750,7 @@ get_relation_notnullatts(PlannerInfo *root, Relation relation)
  *       Searches the hash table and returns the column not-null constraint
  *       information for a given relation.
  */
-Relids
+Bitmapset *
 find_relation_notnullatts(PlannerInfo *root, Oid relid)
 {
        NotnullHashEntry *hentry;
index dd8f2cd157f6faaa999ca9835887ff90467e3118..9610707683235a2af0b1efc11bc50bf63903b8a8 100644 (file)
@@ -30,7 +30,7 @@ extern void get_relation_info(PlannerInfo *root, Oid relationObjectId,
 
 extern void get_relation_notnullatts(PlannerInfo *root, Relation relation);
 
-extern Relids find_relation_notnullatts(PlannerInfo *root, Oid relid);
+extern Bitmapset *find_relation_notnullatts(PlannerInfo *root, Oid relid);
 
 extern List *infer_arbiter_indexes(PlannerInfo *root);