Re: Some efforts to get rid of "long" in our codebase
Andreas Karlsson <andreas@proxel.se>
From: Andreas Karlsson <andreas@proxel.se>
To: David Rowley <dgrowleyml@gmail.com>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-10T08:00:40Z
Lists: pgsql-hackers
Attachments
- 0001-Stop-using-long-TimestampDifference.patch (text/x-patch)
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