getDataSources() can be called multiple-times, use SQL_FETCH_FIRST and SQL_FETCH_NEXT
--- a/src/DriverManager.cpp Mon Jun 01 17:23:27 2020 +0200
+++ b/src/DriverManager.cpp Tue Jun 02 18:40:20 2020 +0200
@@ -47,8 +47,11 @@
memset(description, 0, sizeof (description));
SQLSMALLINT nameLength;
SQLSMALLINT descriptionLength;
- while (true) {
- SQLRETURN result = SQLDataSources(environment, SQL_FETCH_NEXT, name, sizeof (name), &nameLength, description, sizeof (description), &descriptionLength);
+ for (int i = 0; true; i++) {
+ SQLRETURN result = SQLDataSources(environment, i == 0 ? SQL_FETCH_FIRST : SQL_FETCH_NEXT,
+ name, sizeof (name), &nameLength,
+ description, sizeof (description), &descriptionLength);
+ // TODO: description field actually contains the driver name – see comments in unixODBC file: DriverManager/SQLDataSources.c
// TODO: check nameLength and descriptionLength whether values were truncated?
if (OdbcCommon::isSuccessful(result)) list.push_back({convertor.from_bytes((char*) name), convertor.from_bytes((char*) description)});
else if (result == SQL_NO_DATA_FOUND) break;