Avoid compiler warning in non-assert builds
authorAmit Langote <amitlan@postgresql.org>
Thu, 26 Oct 2023 08:12:24 +0000 (17:12 +0900)
committerAmit Langote <amitlan@postgresql.org>
Thu, 26 Oct 2023 08:32:38 +0000 (17:32 +0900)
After 01575ad788e3, expand_single_inheritance_child()'s parentOID
variable is read only in an Assert, provoking a compiler warning in
non-assert builds.  Fix that by marking the variable with
PG_USED_FOR_ASSERTS_ONLY.

Per report and suggestion from David Rowley

Discussion: https://postgr.es/m/CAApHDvpjA_8Wxu4DCTRVAvPxC9atwMe6N%2ByvrcGsgb7mrfdpJA%40mail.gmail.com

src/backend/optimizer/util/inherit.c

index 00b65ca305b0dd1031d54f21559687adb664c673..f9d3ff1e7ac77e04217b16ca8632a63c94317032 100644 (file)
@@ -457,7 +457,8 @@ expand_single_inheritance_child(PlannerInfo *root, RangeTblEntry *parentrte,
                                Index *childRTindex_p)
 {
    Query      *parse = root->parse;
-   Oid         parentOID = RelationGetRelid(parentrel);
+   Oid         parentOID PG_USED_FOR_ASSERTS_ONLY =
+       RelationGetRelid(parentrel);
    Oid         childOID = RelationGetRelid(childrel);
    RangeTblEntry *childrte;
    Index       childRTindex;