From 6b2c3f3b26aeecbce15b10978473e506a026ba09 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 3 Dec 2026 11:52:57 +0100 Subject: [PATCH 5/5] ecpg: Fix type of dt2time() argument The first argument of the ecpg version of dt2time() was of type double, a leftover from when floating-point timestamps were supported. The backend version has long taken a Timestamp. Change the ecpg version to take a timestamp (int64) as well. The main caller in timestamp2tm() already passes an int64. The caller that computes a fractional Julian day now casts explicitly, as the backend already did. --- src/interfaces/ecpg/pgtypeslib/dt.h | 2 +- src/interfaces/ecpg/pgtypeslib/dt_common.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/interfaces/ecpg/pgtypeslib/dt.h b/src/interfaces/ecpg/pgtypeslib/dt.h index 83e6cad167d..1ed51a2cd2c 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt.h +++ b/src/interfaces/ecpg/pgtypeslib/dt.h @@ -328,7 +328,7 @@ void j2date(int jd, int *year, int *month, int *day); void GetCurrentDateTime(struct tm *tm); int date2j(int y, int m, int d); void TrimTrailingZeros(char *str); -void dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec); +void dt2time(timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec); int PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d, int *year, int *month, int *day, int *hour, int *minute, int *second, diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index 8c1f485f70c..bd68ccd58f8 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -1069,7 +1069,7 @@ GetCurrentDateTime(struct tm *tm) } void -dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec) +dt2time(timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) { int64 time; @@ -2071,7 +2071,7 @@ DecodeDateTime(char **field, int *ftype, int nf, return -1; tmask |= DTK_TIME_M; - dt2time((time * USECS_PER_DAY), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + dt2time((timestamp) (time * USECS_PER_DAY), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); } break; -- 2.56.0