Backport test utility functions
The resultset processing functions are helpful in writing tests that process resultsets.
This commit is contained in:
@ -515,6 +515,36 @@ int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value
|
||||
return ret;
|
||||
}
|
||||
|
||||
Result get_result(MYSQL* conn, std::string sql)
|
||||
{
|
||||
Result rval;
|
||||
MYSQL_RES* res;
|
||||
|
||||
if (mysql_query(conn, sql.c_str()) == 0 && (res = mysql_store_result(conn)))
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(res);
|
||||
|
||||
while (row)
|
||||
{
|
||||
rval.emplace_back(&row[0], &row[mysql_num_fields(res)]);
|
||||
row = mysql_fetch_row(res);
|
||||
}
|
||||
mysql_free_result(res);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Query failed: %s\n", mysql_error(conn));
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
Row get_row(MYSQL* conn, std::string sql)
|
||||
{
|
||||
Result res = get_result(conn, sql);
|
||||
return res.empty() ? Row{} : res[0];
|
||||
}
|
||||
|
||||
int get_int_version(std::string version)
|
||||
{
|
||||
std::istringstream str(version);
|
||||
|
Reference in New Issue
Block a user