From: Marcin Siodelski Date: Wed, 11 Mar 2015 19:20:09 +0000 (+0100) Subject: [3673] Updated comments about the max timestamp for the MySQL and PgSQL. X-Git-Tag: trac3764_base~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f48f9ebae5a5a72e7f0296cf1c6ea8c22d1d26ad;p=thirdparty%2Fkea.git [3673] Updated comments about the max timestamp for the MySQL and PgSQL. --- diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index 45b42460b0..34f91bdf01 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -1287,7 +1287,8 @@ MySqlLeaseMgr::convertToDatabaseTime(const time_t cltt, int64_t expire_time_64 = static_cast(cltt) + static_cast(valid_lifetime); - // Prevent too large value. + // Even on 64-bit systems MySQL doesn't seem to accept the timestamps + // beyond the max value of int32_t. if (expire_time_64 > LeaseMgr::MAX_DB_TIME) { isc_throw(BadValue, "Time value is too large: " << expire_time_64); } diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index dba5d34ac1..0bd20966c0 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -315,10 +315,10 @@ public: int64_t expire_time_64 = static_cast(cltt) + static_cast(valid_lifetime); - // PostgreSQL does funny things with time if you get past Y2038. It - // will accept the values (unlike MySQL which throws) but it - // stops correctly adjusting to local time when reading them back - // out. So lets disallow it here. + // On 32-bit systems the time_t is implemented as the int32_t value. + // We want to detect overflows beyond maximum int32_t value here + // to avoid the overflow in the PostgreSQL database. The PostgreSQL + // doesn't catch those overflows on its own. if (expire_time_64 > LeaseMgr::MAX_DB_TIME) { isc_throw(isc::BadValue, "Time value is too large: " << expire_time_64); }