Re: Some efforts to get rid of "long" in our codebase - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: Some efforts to get rid of "long" in our codebase
Date
Msg-id 02d55a64-1243-4230-95f4-3749a05c03f4@proxel.se
Whole thread Raw
In response to Some efforts to get rid of "long" in our codebase  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
On 11/6/25 12:46 PM, David Rowley wrote:
> I've attached a couple of patches to get the ball rolling.

This inspired me to write my own patch to chip away at the use of long.

The target for the attached patch is TimestampDifference() and 
feTimestampDifference() which return the timestamp difference in seconds 
and microseconds as a long and an int and replace it with in64 and 
int32. The return values of these functions are used a lot for printing 
durations to the log and sometimes to populate a struct timeval (in that 
case returning a timeval would make some sense but time_t is sadly 32 
bits on some platforms).

The patch also cleans up code a bit in check_log_duration() which was 
unnecessarily complicated.

But writing the mail made me wonder if a cleaner solution wouldn't be to 
just make TimestampDifference() return a TimeOffset and then write 
helper functions to e.g. convert a TimeOffset to a timeval or to 
milliseconds.

Andreas

Attachment

pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Consistently use the XLogRecPtrIsInvalid() macro
Next
From: Chao Li
Date:
Subject: Improve logical replication usability when tables lack primary keys