tupdesc: simplify assert in equalTupleDescs()
Chao Li <li.evan.chao@gmail.com>
From: Chao Li <li.evan.chao@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-17T07:21:47Z
Lists: pgsql-hackers
Attachments
- v1-0001-tupdesc-simplify-assert-in-equalTupleDescs.patch (application/octet-stream) patch v1-0001
Hi, While reading the code, I saw these assertions in equalTupleDescs(): ``` CompactAttribute *cattr1 = TupleDescCompactAttr(tupdesc1, i); CompactAttribute *cattr2 = TupleDescCompactAttr(tupdesc2, i); Assert(cattr1->attnullability != ATTNULLABLE_UNKNOWN); Assert((cattr1->attnullability == ATTNULLABLE_UNKNOWN) == (cattr2->attnullability == ATTNULLABLE_UNKNOWN)); ``` The first assertion already guarantees that cattr1->attnullability is not ATTNULLABLE_UNKNOWN, so in the second one the expression cattr1->attnullability == ATTNULLABLE_UNKNOWN will always be false, That means the second assertion is effectively just checking that cattr2->attnullability is also not ATTNULLABLE_UNKNOWN. So the current code is correct, but it feels a bit harder to read than necessary. This patch just simplifies the second assertion in a direct way. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/