tupdesc: simplify assert in equalTupleDescs() - Mailing list pgsql-hackers

From Chao Li
Subject tupdesc: simplify assert in equalTupleDescs()
Date
Msg-id 6E6BD43A-89D5-457D-8825-E7282422802F@gmail.com
Whole thread Raw
Responses Re: tupdesc: simplify assert in equalTupleDescs()
List 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
expressioncattr1->attnullability == ATTNULLABLE_UNKNOWN will always be false, That means the second assertion is
effectivelyjust 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
assertionin a direct way. 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/





Attachment

pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: SQL Property Graph Queries (SQL/PGQ)
Next
From: jian he
Date:
Subject: Re: [PATCH] no table rewrite when set column type to constrained domain