summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/input/mysqlRecordSet.cpp7
-rw-r--r--lib/input/mysqlRecordSet.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/input/mysqlRecordSet.cpp b/lib/input/mysqlRecordSet.cpp
index 22b7214..71c5148 100644
--- a/lib/input/mysqlRecordSet.cpp
+++ b/lib/input/mysqlRecordSet.cpp
@@ -72,7 +72,6 @@ namespace MyGrate::Input {
verify<MySQLErr>(!mysql_stmt_bind_result(stmt.get(), fields.data()), "Store result error", stmt->mysql);
verify<MySQLErr>(!mysql_stmt_store_result(stmt.get()), "Store result error", stmt->mysql);
stmtres = {stmt.get(), mysql_stmt_free_result};
- verify<MySQLErr>(!mysql_stmt_fetch(stmt.get()), "Fetch", stmt->mysql);
}
std::size_t
@@ -90,7 +89,11 @@ namespace MyGrate::Input {
DbValue
MySQLRecordSet::at(std::size_t row, std::size_t col) const
{
- mysql_stmt_data_seek(stmt.get(), row);
+ if (currentRow != row) {
+ mysql_stmt_data_seek(stmt.get(), row);
+ verify<MySQLErr>(!mysql_stmt_fetch(stmt.get()), "Fetch", stmt->mysql);
+ currentRow = row;
+ }
if (extras[col]->null) {
return nullptr;
}
diff --git a/lib/input/mysqlRecordSet.h b/lib/input/mysqlRecordSet.h
index 849a653..aec733e 100644
--- a/lib/input/mysqlRecordSet.h
+++ b/lib/input/mysqlRecordSet.h
@@ -31,6 +31,7 @@ namespace MyGrate::Input {
StmtResPtr stmtres;
std::vector<MYSQL_BIND> fields;
std::vector<ResultDataPtr> extras;
+ mutable std::size_t currentRow {static_cast<size_t>(-1)};
};
}