void checkLOCK(int32_t fa) { int nFields; int nTuples; int i, j; PGresult *checkLOCK_res=NULL; char Command[100]; LOG_TRACE("%s() fa(%i)(%08X)",__func__,fa,fa); snprintf(Command,sizeof(Command),"SELECT pid, classid, objid FROM pg_locks WHERE objid=%i",fa); //PQclear(checkLOCK_res); checkLOCK_res = PQexec(conn,Command); if (!checkLOCK_res) { LOG_DEBUG("In %s(): PGresult is still NULL so return", __func__); return; } if (PQresultStatus(checkLOCK_res) != PGRES_TUPLES_OK) { LOG_DEBUG("checkLOCK failed: %s", PQerrorMessage(conn)); PQclear(checkLOCK_res); return; } nFields = PQnfields(checkLOCK_res); nTuples = PQntuples(checkLOCK_res); if(nTuples > 0) { LOG_DEBUG("%s() fa(%i)(%08X) is currently LOCKED by PID %s as classid=%s objid=%s",__func__,fa,fa,PQgetvalue(checkLOCK_res,0,0),PQgetvalue(checkLOCK_res,0,1),PQgetvalue(checkLOCK_res,0,2)); PQclear(checkLOCK_res); //printLOCKS(); } else { LOG_DEBUG("%s() fa(%i)(%08X) is NOT LOCKED",__func__,fa,fa); PQclear(checkLOCK_res); } }