Re: Remove redundant assignment of a variable in function AlterPublicationTables - Mailing list pgsql-hackers

From Chao Li
Subject Re: Remove redundant assignment of a variable in function AlterPublicationTables
Date
Msg-id CA8A569D-2D63-4EB4-8788-DFF5522FF40B@gmail.com
Whole thread Raw
In response to Remove redundant assignment of a variable in function AlterPublicationTables  (Shlok Kyal <shlok.kyal.oss@gmail.com>)
Responses Re: Remove redundant assignment of a variable in function AlterPublicationTables
List pgsql-hackers


On Aug 20, 2025, at 16:41, Shlok Kyal <shlok.kyal.oss@gmail.com> wrote:

Hi,

While working on the thread [1]. We encountered that in the
'AlterPublicationTables' function, the assignment 'isnull = true' is
redundant. This assignment is not required, and the variable will be
reassigned before use.
I have attached a patch to address this.

[1]: https://www.postgresql.org/message-id/CALdSSPgiDj8S8POf_6kiUkVrt9-EqYmn%2B2ahDqpdBpyteeAz-Q%40mail.gmail.com

Thanks,
Shlok Kyal
<v1-0001-Remove-redundant-assignment-of-isnull-variable.patch>


If we look into the subsequent functions, yes, “isnull” will always be assigned. But how about if someone incidentally changed a subsequent function and moved an assignment? I think giving an initial value is a good habit without much performance burden.

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




pgsql-hackers by date:

Previous
From: James Pang
Date:
Subject: Re: max_locks_per_transaction v18
Next
From: jian he
Date:
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands