Skip to content

Commit 36d4c25

Browse files
committed
Bug#21053335 Initialize last_queried_column on each next().
1 parent 84f5366 commit 36d4c25

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

driver/mysql_ps_resultset.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ MySQL_Prepared_ResultSet::absolute(const int new_pos)
135135
return true;
136136
}
137137
} else if (new_pos < 0) {
138-
if ((-new_pos) > (int) num_rows || (new_pos == std::numeric_limits<int>::min())) {
138+
if ((-new_pos) > (int) num_rows || (new_pos == std::numeric_limits<int>::min())) {
139139
row_position = 0; /* before first new_pos */
140140
} else {
141141
row_position = num_rows - (-new_pos) + 1;
@@ -211,6 +211,8 @@ MySQL_Prepared_ResultSet::checkScrollable() const
211211
if (resultset_type == sql::ResultSet::TYPE_FORWARD_ONLY) {
212212
throw sql::NonScrollableException("Nonscrollable result set");
213213
}
214+
// reset last_queried_column
215+
last_queried_column = -1;
214216
}
215217
/* }}} */
216218

@@ -963,13 +965,13 @@ MySQL_Prepared_ResultSet::getString(const uint32_t columnIndex) const
963965
{
964966
char buf[28];
965967
MYSQL_TIME * t = static_cast<MYSQL_TIME *>(result_bind->rbind[columnIndex - 1].buffer);
966-
if (t->second_part) {
967-
snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d.%06lu",
968-
t->year, t->month, t->day, t->hour, t->minute, t->second, t->second_part);
969-
} else {
970-
snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d",
971-
t->year, t->month, t->day, t->hour, t->minute, t->second);
972-
}
968+
if (t->second_part) {
969+
snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d.%06lu",
970+
t->year, t->month, t->day, t->hour, t->minute, t->second, t->second_part);
971+
} else {
972+
snprintf(buf, sizeof(buf) - 1, "%04d-%02d-%02d %02d:%02d:%02d",
973+
t->year, t->month, t->day, t->hour, t->minute, t->second);
974+
}
973975
CPP_INFO_FMT("It's a datetime/timestamp %s", buf);
974976
return sql::SQLString(buf);
975977
}
@@ -985,11 +987,11 @@ MySQL_Prepared_ResultSet::getString(const uint32_t columnIndex) const
985987
{
986988
char buf[18];
987989
MYSQL_TIME * t = static_cast<MYSQL_TIME *>(result_bind->rbind[columnIndex - 1].buffer);
988-
if (t->second_part) {
989-
snprintf(buf, sizeof(buf), "%s%02d:%02d:%02d.%06lu", t->neg? "-":"", t->hour, t->minute, t->second, t->second_part);
990-
} else {
991-
snprintf(buf, sizeof(buf), "%s%02d:%02d:%02d", t->neg? "-":"", t->hour, t->minute, t->second);
992-
}
990+
if (t->second_part) {
991+
snprintf(buf, sizeof(buf), "%s%02d:%02d:%02d.%06lu", t->neg? "-":"", t->hour, t->minute, t->second, t->second_part);
992+
} else {
993+
snprintf(buf, sizeof(buf), "%s%02d:%02d:%02d", t->neg? "-":"", t->hour, t->minute, t->second);
994+
}
993995
CPP_INFO_FMT("It's a time %s", buf);
994996
return sql::SQLString(buf);
995997
}

0 commit comments

Comments
 (0)