Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vyfWm-000JXb-1f for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Mar 2026 00:28:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyfWk-007fQU-2K for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Mar 2026 00:28:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vyfWk-007fQL-19 for pgsql-hackers@lists.postgresql.org; Sat, 07 Mar 2026 00:28:18 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vyfWj-00000000uKJ-0P3y for pgsql-hackers@postgresql.org; Sat, 07 Mar 2026 00:28:17 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5a1330ac6c3so2571433e87.1 for ; Fri, 06 Mar 2026 16:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772843295; x=1773448095; darn=postgresql.org; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=PfS4YPGoj8kmbTUE6bj7rXnezrSisOjZZnvUnhWoh3g=; b=BAZ8Vh13yp8DmI0Of/DJszODCeHUDW90aItE3veMt6nGd8iZGxuI6aKWw9agR0RM/e 75aJPGvjJZe+y3Q59qwNiTHiQaX1sY0ixXaqDzbloUTY0ckEFiwYw3/0lO1KWlSymcXy S1kM0MGzhCoHHSSZmjkav9J2mBtQJ0jxR2FrdkSX/ZhfmobExxaMQArUsnwbFtqX1fXM Bo2NsiKLgurpLvjhvV9mY/SR9/uvEPBciV8xUY1GMvuP5Yf4SKZnjskUib5YWGpKeW9N lLJ1MJvjGmO+pyZutvPwmvvSh4nBo8xkt97CFD2xYkCLBy7dUaU7Xk7qTnALCDQLpF2q Fnig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772843295; x=1773448095; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PfS4YPGoj8kmbTUE6bj7rXnezrSisOjZZnvUnhWoh3g=; b=CZxbUkZapmzR9DzKbewFIoEmX7gqXuObmsw60/uBZ6W4DMdlr3qmgTf0TFg9/875mk 0oyL6Vl+3/oQqofiuvxgdJE8hH3ovEvC0gHkjRHZqVJFbTR8t8Dgby/udn0L9o0f0SGT R8qRIo2zCsGQLzNHkV3Ka0qa9ub3eSDsBW6Xryjahfl6UFhuqQysavvlDI4l7nlLIMPK cxR8Dwcda8f6rdGoVwPlNXDocfMvRNoL4o2B/wPW0/GDfC6m+RNg2YnoeMVOIBW4SGEv 0sBpwV8QdYPMcLW7pZMLaq7E4BUwAk9AG5VvpIgzSyz/a43eMF/t48J6iPxrwyCGuZXi TjEw== X-Gm-Message-State: AOJu0Yz0YlCDS3sKW6HEzAF13k3aeBL5w7KN+hndJaT2owmRuT4XqHHc /YLiBfO9K/Lp1xEKa2+LwqRrR59LUMdQ56mNTXoH9xnApe7WLNYmqsuQq9etJw== X-Gm-Gg: ATEYQzwFbVsnOjRGNBYT2kt8eAJYX7YE1vXH7/qVs1Um8NB5SgsdKRGOF9WdRTr+r0C Y6B5jJqPYL5JX4u7myXHuv0FXSs3IAHb0sd3mfdE4nQIJNY20nA6uez7n7INOYtQjuMz087IQZC d71D+cOxM2K3kXD3mCYkv2k0mZ2Z43qeWmYcHT0KmgHjWfvE2nu1g7/p4vdw+52CosOx/wZZ2/B 43cyXXVbzlrK7nT/1iC+5ms3CQobnbij52LLV5mcNCEcXT0PHTZk6FMSgidr4Jl4/pNcgZQUVUm J7jJtq57L6tUGHLOZF35tc6LTOUplTZUHqdsIH5dQwhV8BDTLgG93hDqMIxTxgSKSlVllg88F+P 44QjhUbg2s5qLKy+r/7smgC76IBDC4Nra5TfbqoyHhPvnsuXKSPg74sLv/KewCN4vQs7q5FWWBt VXwIp4UShWR7KIZlSn3IGvLaz/0alvRTjH+N0= X-Received: by 2002:ac2:5b8b:0:b0:5a1:2f0b:10db with SMTP id 2adb3069b0e04-5a13cd3bf38mr934463e87.28.1772843295296; Fri, 06 Mar 2026 16:28:15 -0800 (PST) Received: from [192.168.88.207] ([146.66.183.77]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a13d02b9e3sm614355e87.27.2026.03.06.16.28.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Mar 2026 16:28:15 -0800 (PST) Message-ID: Date: Sat, 7 Mar 2026 03:28:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US, ru To: pgsql-hackers@postgresql.org From: George Tarasov Subject: [BUG?] missing array index may result in a wrong constraint name (pg_dump, bin-upgrade, >=18) Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk     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