| From: | George Tarasov <george(dot)v(dot)tarasov(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | [BUG?] missing array index may result in a wrong constraint name (pg_dump, bin-upgrade, >=18) |
| Date: | 2026-03-07 00:28:14 |
| Message-ID: | f3029f25-acc9-4cb9-a74f-fe93bcfb3a27@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-03-07 01:11:46 | Re: Skipping schema changes in publication |
| Previous Message | Jacob Champion | 2026-03-07 00:27:12 | Re: [oauth] Stabilize the libpq-oauth ABI (and allow alternative implementations?) |