Skip to content

Commit 140fdd0

Browse files
committed
Bug #17218692 correction merge
2 parents 0779423 + 025f433 commit 140fdd0

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

driver/mysql_ps_resultset.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,9 @@ MySQL_Prepared_ResultSet::getString(const uint32_t columnIndex) const
980980
char buf[18];
981981
MYSQL_TIME * t = static_cast<MYSQL_TIME *>(result_bind->rbind[columnIndex - 1].buffer);
982982
if (t->second_part) {
983-
snprintf(buf, sizeof(buf) - 1, "%s%02d:%02d:%02d.%06lu", t->neg? "-":"", t->hour, t->minute, t->second, t->second_part);
983+
snprintf(buf, sizeof(buf), "%s%02d:%02d:%02d.%06lu", t->neg? "-":"", t->hour, t->minute, t->second, t->second_part);
984984
} else {
985-
snprintf(buf, sizeof(buf) - 1, "%s%02d:%02d:%02d", t->neg? "-":"", t->hour, t->minute, t->second);
985+
snprintf(buf, sizeof(buf), "%s%02d:%02d:%02d", t->neg? "-":"", t->hour, t->minute, t->second);
986986
}
987987
CPP_INFO_FMT("It's a time %s", buf);
988988
return sql::SQLString(buf);

test/unit/bugs/bugs.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,5 +822,41 @@ void bugs::bug21053335()
822822
}
823823

824824

825+
void bugs::bug17218692()
826+
{
827+
logMsg("bugs::bug17218692");
828+
try
829+
{
830+
831+
stmt->execute("DROP TABLE IF EXISTS bug17218692");
832+
stmt->execute("CREATE TABLE bug17218692(c1 time(6))");
833+
stmt->execute("INSERT INTO bug17218692 VALUES('-838:59:58.987657')");
834+
835+
res.reset(stmt->executeQuery("select * from bug17218692"));
836+
res->next();
837+
838+
std::stringstream log;
839+
log<<"["<<res->getString(1)<<"]";
840+
841+
ASSERT_EQUALS(log.str(), "[-838:59:58.987657]");
842+
843+
pstmt.reset(con->prepareStatement("select * from bug17218692 "));
844+
res.reset(pstmt->executeQuery());
845+
res->next();
846+
847+
std::stringstream log2;
848+
log2 << "["<<res->getString(1)<<"]";
849+
ASSERT_EQUALS(log.str(), log2.str());
850+
851+
}
852+
catch (sql::SQLException & e)
853+
{
854+
FAIL("Exception thrown");
855+
throw;
856+
}
857+
858+
859+
}
860+
825861
} /* namespace regression */
826862
} /* namespace testsuite */

test/unit/bugs/bugs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class bugs : public unit_fixture
6262
TEST_CASE(bug68523);
6363
TEST_CASE(bug66235);
6464
TEST_CASE(bug14520822);
65+
TEST_CASE(bug17218692);
6566
TEST_CASE(bug21053335);
6667
}
6768

@@ -108,6 +109,8 @@ class bugs : public unit_fixture
108109

109110
void bug14520822();
110111

112+
void bug17218692();
113+
111114
void bug21053335();
112115

113116
};

0 commit comments

Comments
 (0)