From ad6fcda6dfed8bf2475988bfdcbd5f9320a2a83d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 13 May 2024 16:54:38 +0200 Subject: [PATCH] Ido*sqlConnection#FieldToEscapedString(): don't overflow timestamps > long --- lib/db_ido_mysql/idomysqlconnection.cpp | 4 ++-- lib/db_ido_pgsql/idopgsqlconnection.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index aacb7d7bd7b..74cb1d7120c 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -891,9 +891,9 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va *result = static_cast(dbrefcol); } else if (DbValue::IsTimestamp(value)) { - long ts = rawvalue; + double ts = rawvalue; std::ostringstream msgbuf; - msgbuf << "FROM_UNIXTIME(" << ts << ")"; + msgbuf << "FROM_UNIXTIME(" << std::fixed << std::setprecision(0) << ts << ")"; *result = Value(msgbuf.str()); } else if (DbValue::IsObjectInsertID(value)) { auto id = static_cast(rawvalue); diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 07e88e6bb2f..db5629b8202 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -700,9 +700,9 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va *result = static_cast(dbrefcol); } else if (DbValue::IsTimestamp(value)) { - long ts = rawvalue; + double ts = rawvalue; std::ostringstream msgbuf; - msgbuf << "TO_TIMESTAMP(" << ts << ") AT TIME ZONE 'UTC'"; + msgbuf << "TO_TIMESTAMP(" << std::fixed << std::setprecision(0) << ts << ") AT TIME ZONE 'UTC'"; *result = Value(msgbuf.str()); } else if (DbValue::IsObjectInsertID(value)) { auto id = static_cast(rawvalue);