Greetings!

I performed static code analysis and got an error: ALWAYS FALSE SUBEXPR!
Let's look at a little snippet (pg_dump.c:10203).

    /*
     * In binary upgrade of inheritance child tables, must have a
     * constraint name that we can UPDATE later; same if there's a
     * comment on the constraint.
     */
    if ((dopt->binary_upgrade &&
         !tbinfo->ispartition &&
         !tbinfo->notnull_islocal) ||
         ^^^^^^^^^^^^^^^^^^^^^^^^            ALWAYS FALSE SUBEXPR!
        !PQgetisnull(res, r, i_notnull_comment))
    {

It seems like index "[j]" is missing for this subexpression to make any sense.

"notnull_islocal" is an array of bools.  It is _always_ created before this snippet in function "getTableAttrs()".  So, the value of tbinfo->notnull_islocal is _always_ TRUE (it is a valid memory pointer), and therefore the entire subexpression is _always_ FALSE. And so, in binary upgrade mode this condition may not be evaluated as expected
(when there's NO comment on the constraint!).

To be honest, I don't fully understand the overall logic behind these preparations for further processing (in pg_dump), but it seems like "[j]" index is definitely missing.

That is how it should be.

     /*
     * In binary upgrade of inheritance child tables, must have a
     * constraint name that we can UPDATE later; same if there's a
     * comment on the constraint.
     */
    if ((dopt->binary_upgrade &&
         !tbinfo->ispartition &&
         !tbinfo->notnull_islocal[j]) ||
                                 ^^^                  MISSING ARRAY INDEX!
        !PQgetisnull(res, r, i_notnull_comment))
    {

Dear, Hackers! Please review.
Is there a really mistake here or am I wrong to raise this issue?

Thanks!
George Tarasov



Reply via email to