Re: Remove redundant assignment of a variable in function AlterPublicationTables

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Smith <smithpb2250(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>
Subject: Re: Remove redundant assignment of a variable in function AlterPublicationTables
Date: 2025-08-20 09:18:53
Message-ID: CA8A569D-2D63-4EB4-8788-DFF5522FF40B@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Aug 20, 2025, at 16:41, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-08-20 09:22:47 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message James Pang 2025-08-20 09:03:05 Re: max_locks_per_transaction v18