Re: turn fastgetattr and heap_getattr to inline functions - Mailing list pgsql-hackers

From Japin Li
Subject Re: turn fastgetattr and heap_getattr to inline functions
Date
Msg-id MEYP282MB166986146989BA9DC1F311B0B6199@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: turn fastgetattr and heap_getattr to inline functions  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: turn fastgetattr and heap_getattr to inline functions
List pgsql-hackers
On Thu, 24 Mar 2022 at 21:26, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> On 2022-Mar-24, Michael Paquier wrote:
>
>> Hmm.  I think that you'd better add a return at the end of each
>> function?  Some compilers are dumb in detecting that all the code
>> paths return (aka recent d0083c1) and could generate warnings, even if
>> things are coded to return all the time, like in your patch.
>
> Hmm, OK to do something about that.  I added pg_unreachable(): looking
> at LWLockAttemptLock(), it looks that that should be sufficient.

Hi,

I want to know why we do not use the following style?

+static inline Datum
+heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
+{
+    if (attnum > 0)
+    {
+        if (attnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
+            return getmissingattr(tupleDesc, attnum, isnull);
+        else
+            return fastgetattr(tup, attnum, tupleDesc, isnull);
+    }
+
+    return heap_getsysattr(tup, attnum, tupleDesc, isnull);
+}


--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Remove an unnecessary errmsg_plural in dependency.c
Next
From: Robert Haas
Date:
Subject: Re: multithreaded zstd backup compression for client and server