Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-10 Thread Heikki Linnakangas
On 09/04/2025 17:23, Tom Lane wrote: Heikki Linnakangas writes: Inconsistency is not good either though. I'm not sure it's worth the churn, but I could get on board a patch to actually replace all HeapTupleIsValid(tuple) calls with plain "tuple != NULL" checks. Keep HeapTupleIsValid() just for

Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-10 Thread Peter Eisentraut
On 09.04.25 16:23, Tom Lane wrote: Heikki Linnakangas writes: Inconsistency is not good either though. I'm not sure it's worth the churn, but I could get on board a patch to actually replace all HeapTupleIsValid(tuple) calls with plain "tuple != NULL" checks. Keep HeapTupleIsValid() just for co

Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-10 Thread Peter Eisentraut
On 09.04.25 14:26, Heikki Linnakangas wrote: It's a matter of taste, but personally I find 'if (tuple != NULL)' more clear than 'if (HeapTupleIsValid(tuple))'. The presence of a macro suggests that there might be other kinds of invalid tuples than a NULL pointer, which just adds mental load.

Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-10 Thread Tender Wang
Michael Paquier 于2025年4月10日周四 10:53写道: > On Wed, Apr 09, 2025 at 05:43:24PM +0300, Heikki Linnakangas wrote: > > Agreed. I use both, depending on which mood I'm in. > > Same here, extended to OidIsValid(), HeapTupleIsValid(), XLogRecPtr, > etc., and I tend to prefer such macros, except if consist

Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-09 Thread Michael Paquier
On Wed, Apr 09, 2025 at 05:43:24PM +0300, Heikki Linnakangas wrote: > Agreed. I use both, depending on which mood I'm in. Same here, extended to OidIsValid(), HeapTupleIsValid(), XLogRecPtr, etc., and I tend to prefer such macros, except if consistency of the surroundings matter most. FWIW, I thi

Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-09 Thread Tom Lane
Heikki Linnakangas writes: > Inconsistency is not good either though. I'm not sure it's worth the > churn, but I could get on board a patch to actually replace all > HeapTupleIsValid(tuple) calls with plain "tuple != NULL" checks. Keep > HeapTupleIsValid() just for compatibility, with a comment

Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-09 Thread Heikki Linnakangas
On 09/04/2025 14:51, Tender Wang wrote: Hi, While working on another patch, I find that tablecmds.c now has three ways to check the validity of catalog tuples. i. if (tuple != NULL) ii. if (!tuple) iii. if (HeapTupleIsValid(tuple) In tablecmds.c, most checks use macro HeapTupleIsValid. For c

Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c

2025-04-09 Thread Tender Wang
Hi, While working on another patch, I find that tablecmds.c now has three ways to check the validity of catalog tuples. i. if (tuple != NULL) ii. if (!tuple) iii. if (HeapTupleIsValid(tuple) In tablecmds.c, most checks use macro HeapTupleIsValid. For code readability, I changed the first and th