Re: Improper use about DatumGetInt32 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Improper use about DatumGetInt32
Date
Msg-id 1310787.1600805461@sss.pgh.pa.us
Whole thread Raw
In response to Re: Improper use about DatumGetInt32  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Improper use about DatumGetInt32  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Sep 21, 2020 at 3:53 PM Andres Freund <andres@anarazel.de> wrote:
>> I think we mostly use it for the few places where we currently expose
>> data as a signed integer on the SQL level, but internally actually treat
>> it as a unsigned data.

> So why is the right solution to that not DatumGetInt32() + a cast to uint32?

You're ignoring the xid use-case, for which DatumGetUInt32 actually is
the right thing.  I tend to agree though that if the SQL argument is
of a signed type, the least API-abusing answer is a signed DatumGetXXX
macro followed by whatever cast you need.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Lift line-length limit for pg_service.conf
Next
From: Peter Geoghegan
Date:
Subject: Re: new heapcheck contrib module