=== modified file 'CHANGES' --- CHANGES revid:hemant.dangi@oracle.com-20150119121220-opq2fp064unvtcqj +++ CHANGES 2015-01-20 11:03:58 +0000 @@ -34,6 +34,8 @@ - wasNull() method call before fetching the data results in assert failure (Bug#19938873) - Memory leak if result set of prepared statement used (Bug#18135088/wl#7925) +- ResultSet::getString does not return fractional seconds from DATETIME(N) + columns (Bug#68523) GA 1.1.5 - - DatabaseMetaData::getProcedures() returns syntax error for connection option === modified file 'driver/mysql_ps_resultset.cpp' --- driver/mysql_ps_resultset.cpp revid:hemant.dangi@oracle.com-20150119121220-opq2fp064unvtcqj +++ driver/mysql_ps_resultset.cpp 2015-01-20 11:03:55 +0000 @@ -955,9 +955,15 @@ switch (rs_meta->getColumnType(columnIndex)) { case sql::DataType::TIMESTAMP: { - char buf[22]; + char buf[28]; MYSQL_TIME * t = static_cast(result_bind->rbind[columnIndex - 1].buffer); - snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d", t->year, t->month, t->day, t->hour, t->minute, t->second); + if (t->second_part) { + snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d.%06lu", + t->year, t->month, t->day, t->hour, t->minute, t->second, t->second_part); + } else { + snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d", + t->year, t->month, t->day, t->hour, t->minute, t->second); + } CPP_INFO_FMT("It's a datetime/timestamp %s", buf); return sql::SQLString(buf); } @@ -971,9 +977,13 @@ } case sql::DataType::TIME: { - char buf[12]; + char buf[18]; MYSQL_TIME * t = static_cast(result_bind->rbind[columnIndex - 1].buffer); - snprintf(buf, sizeof(buf) - 1, "%s%02d:%02d:%02d", t->neg? "-":"", t->hour, t->minute, t->second); + if (t->second_part) { + snprintf(buf, sizeof(buf) - 1, "%s%02d:%02d:%02d.%06lu", t->neg? "-":"", t->hour, t->minute, t->second, t->second_part); + } else { + snprintf(buf, sizeof(buf) - 1, "%s%02d:%02d:%02d", t->neg? "-":"", t->hour, t->minute, t->second); + } CPP_INFO_FMT("It's a time %s", buf); return sql::SQLString(buf); } === modified file 'test/unit/bugs/bugs.cpp' --- test/unit/bugs/bugs.cpp revid:hemant.dangi@oracle.com-20150119121220-opq2fp064unvtcqj +++ test/unit/bugs/bugs.cpp 2015-01-20 10:57:20 +0000 @@ -660,5 +660,32 @@ } +void bugs::bug68523() +{ + try + { + stmt->execute("DROP TABLE IF EXISTS bug68523"); + stmt->execute("CREATE TABLE bug68523(ts TIMESTAMP(6))"); + stmt->execute("INSERT INTO bug68523(ts) values('2015-01-20 16:14:36.709649')"); + + pstmt.reset(con->prepareStatement("SELECT ts, TIME(ts) from bug68523")); + res.reset(pstmt->executeQuery()); + ASSERT(res->next()); + + ASSERT_EQUALS(res->getString(1), "2015-01-20 16:14:36.709649"); + ASSERT_EQUALS(res->getString(2), "16:14:36.709649"); + + stmt->execute("DROP TABLE IF EXISTS bug68523"); + } + catch (sql::SQLException &e) + { + logErr(e.what()); + logErr("SQLState: " + std::string(e.getSQLState())); + fail(e.what(), __FILE__, __LINE__); + } + +} + + } /* namespace regression */ } /* namespace testsuite */ === modified file 'test/unit/bugs/bugs.h' --- test/unit/bugs/bugs.h revid:hemant.dangi@oracle.com-20150119121220-opq2fp064unvtcqj +++ test/unit/bugs/bugs.h 2015-01-20 10:47:13 +0000 @@ -59,6 +59,7 @@ TEST_CASE(bug20085944); TEST_CASE(bug19938873_pstmt); TEST_CASE(bug19938873_stmt); + TEST_CASE(bug68523); } /** @@ -98,6 +99,7 @@ void bug19938873_stmt(); + void bug68523(); }; REGISTER_FIXTURE(bugs);