tupdesc: simplify assert in equalTupleDescs()

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: tupdesc: simplify assert in equalTupleDescs()
Date: 2026-03-17 07:21:47
Message-ID: 6E6BD43A-89D5-457D-8825-E7282422802F@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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/

Attachment Content-Type Size
v1-0001-tupdesc-simplify-assert-in-equalTupleDescs.patch application/octet-stream 1.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-03-17 08:05:58 Re: [PATCH] no table rewrite when set column type to constrained domain
Previous Message Kirill Reshke 2026-03-17 07:19:31 Re: SQL Property Graph Queries (SQL/PGQ)