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

From Robert Haas
Subject Re: Improper use about DatumGetInt32
Date
Msg-id CA+TgmoYMP0PxbyAwYTunXuxTCS16=92+=cou8FpgJQuxpcGV2A@mail.gmail.com
Whole thread Raw
In response to Improper use about DatumGetInt32  ("Hou, Zhijie" <houzj.fnst@cn.fujitsu.com>)
Responses Re: Improper use about DatumGetInt32
Re: Improper use about DatumGetInt32
List pgsql-hackers
On Sun, Sep 20, 2020 at 9:17 PM Hou, Zhijie <houzj.fnst@cn.fujitsu.com> wrote:
> In (/contrib/bloom/blutils.c:277), I found it use DatumGetInt32 to get UInt32 type.
> Is it more appropriate to use DatumGetUInt32 here?

Typically, the DatumGetBlah() function that you pick should match the
SQL data type that the function is returning. So if the function
returns pg_catalog.int4, which corresponds to the C data type int32,
you would use DatumGetInt32. There is no SQL type corresponding to the
C data type uint32, so I'm not sure why we even have DatumGetUInt32.
I'm sort of suspicious that there's some fuzzy thinking going on
there.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: recovering from "found xmin ... from before relfrozenxid ..."
Next
From: Daniel Gustafsson
Date:
Subject: Re: pgindent vs dtrace on macos