From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
Cc: | Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, 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-21 00:11:17 |
Message-ID: | aKZkJaqzKStuoQK0@paquier.xyz |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Aug 20, 2025 at 05:18:53PM +0800, Chao Li wrote:
> 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.
It does not matter to leave the code as is. We have a bunch of these
depending on how people feel on the day when they implement something.
Compilers are smart enough to optimize such things away when they don't
matter, usually. Some compiler versions and flags can also be very
picky with initializations not done, missing that sometimes a variable
is actually set in all the relevant code paths. Warnings can show
depending on the complexity of the branches used, as well.
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Chao Li | 2025-08-21 00:41:36 | Re: Remove redundant assignment of a variable in function AlterPublicationTables |
Previous Message | Michael Paquier | 2025-08-21 00:06:13 | Re: pg_get_sequence_data Shows Non-NULL last_value for Freshly Created Sequence |