This commit is contained in:
Wolfgang Hottgenroth 2021-04-29 16:31:43 +02:00
parent f6b138bfdd
commit e0699369b5
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F

View File

@ -148,15 +148,17 @@ t_device *findDevice(t_commonHandle *handle, char *deviceId) {
logmsg(LOG_DEBUG, "Statement: %s", stmt); logmsg(LOG_DEBUG, "Statement: %s", stmt);
PGresult *res2 = PQexec(handle->conn, stmt); PGresult *res2 = PQexec(handle->conn, stmt);
ExecStatusType execStatus = PQresultStatus(res2); ExecStatusType execStatus = PQresultStatus(res2);
switch(execStatus) { if (execStatus != PGRES_TUPLES_OK) {
case PGRES_COMMAND_OK: logmsg(LOG_INFO, "findDevice query fails, database returns %s", PQresStatus(execStatus));
logmsg(LOG_INFO, "findDevice select returns PGRES_COMMAND_OK"); } else {
break; int ntuples = PQtuples(res2);
case PGRES_TUPLES_OK: if (ntuples == 0) {
logmsg(LOG_INFO, "findDevice select returns PGRES_TUPLES_OK"); logmsg(LOG_ERR, "no device found");
break; } else if (ntuples == 1) {
default: logmsg(LOG_DEBUG, "device found");
logmsg(LOG_INFO, "findDevice select returns something else: %s", PQresStatus(execStatus)); } else {
logmsg(LOG_ERR, "strange number of devices found: %d", ntuples);
}
} }
PQclear(res2); PQclear(res2);
} }