| From: | Andreas Karlsson <andreas(at)proxel(dot)se> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Some efforts to get rid of "long" in our codebase |
| Date: | 2025-11-10 08:00:40 |
| Message-ID: | 02d55a64-1243-4230-95f4-3749a05c03f4@proxel.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| 0001-Stop-using-long-TimestampDifference.patch | text/x-patch | 20.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2025-11-10 08:06:36 | Improve logical replication usability when tables lack primary keys |
| Previous Message | Bertrand Drouvot | 2025-11-10 07:57:39 | Re: Consistently use the XLogRecPtrIsInvalid() macro |