Monday, October 28, 2013

Bug in QIBASE (Qt 5.1.1) always returns 00:00:00.000 as time part of TIMESTAMP


Bug in QIBASE (Qt 5.1.1) always returns 00:00:00.000 as time part of TIMESTAMP

Description


Unfortunately QIBASE driver have bug in Qt versions 5.1.0 and 5.1.1. When you trying to retrieve any TIMESTAMP value you'll have 00:00:00.000 as time part of TIMESTAMP.

To test this you can execute something like this:

select current_timestamp as dts from rdb$database

This query will return current time stamp on server which have Firebird/Interbase installed.

You will get 00:00:00.000 as time part of result :(



As I can see there is few issues opened in Digia issues system:

  1. https://bugreports.qt-project.org/browse/QTBUG-29261
  2. https://bugreports.qt-project.org/browse/QTBUG-32858

Report QTBUG-32858 is also my. I posted it in 7 Aug 2013 (when I had Qt 5.1.0) and supposed that Digia will fix this issue in Qt 5.1.1. Unfortunately this bug already present in Qt.

Solution

As I told in QTBUG-32858 solution by Ray Park (found in QTBUG-29261 issue) correctly fixes this bug.

All that you must to do is change fromTimeStamp() implementation qsql_ibase.cpp with this:

static QDateTime fromTimeStamp(char *buffer)
{
    static const QDate bd(1858, 11, 17);
    QTime t(0, 0, 0);//########## should be fixed like this to pass on isValid() 
    QDate d;

    // have to demangle the structure ourselves because isc_decode_time
    // strips the msecs
    t = t.addMSecs(int(((ISC_TIMESTAMP*)buffer)->timestamp_time / 10));
    d = bd.addDays(int(((ISC_TIMESTAMP*)buffer)->timestamp_date));

    return QDateTime(d, t);
}

Thanks to Ray Park :)

Hope it was useful.

No comments:

Post a Comment