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

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Tender Wang <tndrwang(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Consistently use macro HeapTupleIsValid to check the validity of tuples in tablecmds.c
Date: 2025-04-10 12:25:24
Message-ID: c40bf78d-9632-4442-9993-c71fbb3f6ced@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

agreed

> 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 to discourage
> using it.

I'd be in favor of that.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-04-10 12:37:16 Re: speedup COPY TO for partitioned table.
Previous Message Tefft, Michael J 2025-04-10 12:22:16 Capturing both IP address and hostname in the log