summaryrefslogtreecommitdiff
path: root/src/include/pgtime.h
diff options
context:
space:
mode:
authorTom Lane2022-04-02 20:12:26 +0000
committerTom Lane2022-04-02 20:12:29 +0000
commite39f9904671082c5ad3a2c5acbdbd028fa93bf35 (patch)
tree6ab9ab1ed3b78bab977b0949e3cfcdb6af9f9cde /src/include/pgtime.h
parentf7e4d5c64fb3977e3a773e7213472be1b59dab2f (diff)
Fix overflow hazards in interval input and output conversions.
DecodeInterval (interval input) was careless about integer-overflow hazards, allowing bogus results to be obtained for sufficiently large input values. Also, since it initially converted the input to a "struct tm", it was impossible to produce the full range of representable interval values. Meanwhile, EncodeInterval (interval output) and a few other functions could suffer failures if asked to process sufficiently large interval values, because they also relied on being able to represent an interval in "struct tm" which is not designed to handle that. Fix all this stuff by introducing new struct types that are more fit for purpose. While this is clearly a bug fix, it's also an API break for any code that's calling these functions directly. So back-patching doesn't seem wise, especially in view of the lack of field complaints. Joe Koshakow, editorialized a bit by me Discussion: https://postgr.es/m/CAAvxfHff0JLYHwyBrtMx_=6wr=k2Xp+D+-X3vEhHjJYMj+mQcg@mail.gmail.com
Diffstat (limited to 'src/include/pgtime.h')
-rw-r--r--src/include/pgtime.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/pgtime.h b/src/include/pgtime.h
index 2977b13aabb..441d7847c12 100644
--- a/src/include/pgtime.h
+++ b/src/include/pgtime.h
@@ -23,6 +23,8 @@
typedef int64 pg_time_t;
/*
+ * Data structure representing a broken-down timestamp.
+ *
* CAUTION: the IANA timezone library (src/timezone/) follows the POSIX
* convention that tm_mon counts from 0 and tm_year is relative to 1900.
* However, Postgres' datetime functions generally treat tm_mon as counting
@@ -44,6 +46,7 @@ struct pg_tm
const char *tm_zone;
};
+/* These structs are opaque outside the timezone library */
typedef struct pg_tz pg_tz;
typedef struct pg_tzenum pg_tzenum;