diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-01-02 16:54:40 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-20 15:50:28 +0100 |
commit | 72922b519becc66a285ae7ae82aadb4eb4d41992 (patch) | |
tree | f74bd0e9a27c805128775d0bc62f3cb7f9f0c2a0 /connectivity | |
parent | Reduce large VARCHAR columns of the wizard sample databases to fit Firebird (diff) | |
download | core-72922b519becc66a285ae7ae82aadb4eb4d41992.tar.gz core-72922b519becc66a285ae7ae82aadb4eb4d41992.zip |
tdf#71007: Pass also fractional seconds to/from Firebird
We know that ISC_TIME is simply in units of
seconds/ISC_TIME_SECONDS_PRECISION.
Change-Id: I2896f53c2d32a773c535e19f55dd1314abd18ec9
Reviewed-on: https://gerrit.libreoffice.org/47266
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
(cherry picked from commit e0a22d47d281f61f51ead6d2831cd53c15036ffe)
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 9 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/ResultSet.cxx | 12 |
2 files changed, 16 insertions, 5 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index afe1fa3229a6..f97895ec530e 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -463,6 +463,10 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 nIndex, const css::util::Ti ISC_TIME aISCTime; isc_encode_sql_time(&aCTime, &aISCTime); + // Here we "know" that ISC_TIME is simply in units of seconds/ISC_TIME_SECONDS_PRECISION with no + // other funkiness, so we can simply add the fraction of a second. + aISCTime += rTime.NanoSeconds / (1000000000 / ISC_TIME_SECONDS_PRECISION); + setValue< ISC_TIME >(nIndex, aISCTime, SQL_TYPE_TIME); } @@ -479,6 +483,9 @@ void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 nIndex, const DateTime& ISC_TIMESTAMP aISCTimestamp; isc_encode_timestamp(&aCTime, &aISCTimestamp); + // As in previous function + aISCTimestamp.timestamp_time += rTimestamp.NanoSeconds / (1000000000 / ISC_TIME_SECONDS_PRECISION); + setValue< ISC_TIMESTAMP >(nIndex, aISCTimestamp, SQL_TIMESTAMP); } diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx index 9e8387d39a3d..20fe2a4dab1e 100644 --- a/connectivity/source/drivers/firebird/ResultSet.cxx +++ b/connectivity/source/drivers/firebird/ResultSet.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -526,9 +526,12 @@ Time OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n struct tm aCTime; isc_decode_sql_time(&aISCTime, &aCTime); - // first field is nanoseconds -- not supported in firebird or struct tm. + // First field is nanoseconds. // last field denotes UTC (true) or unknown (false) - return Time(0, aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, false); + // Here we "know" that ISC_TIME is simply in units of seconds/ISC_TIME_SECONDS_PRECISION + // with no other funkiness, so we can get the fractional seconds easily. + return Time((aISCTime % ISC_TIME_SECONDS_PRECISION) * (1000000000 / ISC_TIME_SECONDS_PRECISION), + aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, false); } else { @@ -546,7 +549,8 @@ DateTime OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT struct tm aCTime; isc_decode_timestamp(&aISCTimestamp, &aCTime); - return DateTime(0, //nanoseconds, not supported + // Ditto here, see comment in previous function about ISC_TIME and ISC_TIME_SECONDS_PRECISION. + return DateTime((aISCTimestamp.timestamp_time % ISC_TIME_SECONDS_PRECISION) * (1000000000 / ISC_TIME_SECONDS_PRECISION), //nanoseconds aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, |