Skip to content

Commit b839408

Browse files
committed
Reset last_queried_column when using forward only resultset_type
1 parent df67aff commit b839408

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

driver/mysql_ps_resultset.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,8 @@ MySQL_Prepared_ResultSet::next()
12601260
}
12611261
CPP_INFO_FMT("new_row_position=%llu ret=%d", row_position, ret);
12621262
} else {
1263+
// reset last_queried_column
1264+
last_queried_column = -1;
12631265
int result = proxy->fetch();
12641266
if (!result || result == MYSQL_DATA_TRUNCATED) {
12651267
ret = true;

driver/mysql_resultset.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ MySQL_ResultSet::absolute(const int new_pos)
101101
return true;
102102
}
103103
} else if (new_pos < 0) {
104-
if ((-new_pos) > (int) num_rows || (new_pos == std::numeric_limits<int>::min())) {
104+
if ((-new_pos) > (int) num_rows || (new_pos == std::numeric_limits<int>::min())) {
105105
row_position = 0; /* before first new_pos */
106106
} else {
107107
row_position = num_rows - (-new_pos) + 1;
@@ -509,7 +509,7 @@ MySQL_ResultSet::getInt64(const uint32_t columnIndex) const
509509
CPP_INFO_FMT("%ssigned", (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG)? "un":"");
510510
was_null = false;
511511
if (getFieldMeta(columnIndex)->type == MYSQL_TYPE_BIT &&
512-
getFieldMeta(columnIndex)->flags != (BINARY_FLAG|UNSIGNED_FLAG)) {
512+
getFieldMeta(columnIndex)->flags != (BINARY_FLAG|UNSIGNED_FLAG)) {
513513
uint64_t uval = 0;
514514
std::div_t length= std::div(getFieldMeta(columnIndex)->length, 8);
515515
if (length.rem) {
@@ -573,7 +573,7 @@ MySQL_ResultSet::getUInt64(const uint32_t columnIndex) const
573573
CPP_INFO_FMT("%ssigned", (getFieldMeta(columnIndex)->flags & UNSIGNED_FLAG)? "un":"");
574574
was_null = false;
575575
if (getFieldMeta(columnIndex)->type == MYSQL_TYPE_BIT &&
576-
getFieldMeta(columnIndex)->flags != (BINARY_FLAG|UNSIGNED_FLAG)) {
576+
getFieldMeta(columnIndex)->flags != (BINARY_FLAG|UNSIGNED_FLAG)) {
577577
uint64_t uval = 0;
578578
std::div_t length= std::div(getFieldMeta(columnIndex)->length, 8);
579579
if (length.rem) {
@@ -907,6 +907,8 @@ MySQL_ResultSet::next()
907907
ret = (row != NULL);
908908
}
909909
} else {
910+
// reset last_queried_column
911+
last_queried_column = -1;
910912
row = result->fetch_row();
911913
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy_p = proxy.lock();
912914
if (!proxy_p) {
@@ -1059,7 +1061,7 @@ MySQL_ResultSet::wasNull() const
10591061
}
10601062
if (last_queried_column == -1) {
10611063
throw sql::InvalidArgumentException("MySQL_ResultSet::wasNull: should be called only after one of the getter methods");
1062-
}
1064+
}
10631065
return was_null;
10641066
}
10651067
/* }}} */

0 commit comments

Comments
 (0)