diff options
Diffstat (limited to '')
-rw-r--r-- | ts3db.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -1,6 +1,7 @@ #include "ts3db.h" #include <libpq-fe.h> #include <stdbool.h> +#include <string.h> #define MAX_CONNECTIONS 100 @@ -182,15 +183,18 @@ unsigned long long ts3dbplugin_getlastinsertid(unsigned int connection_nr) { log("getlastinsertid", LOG_DEVELOP); const PGresult *result = get_last_result(connection_nr); - Oid value = PQoidValue(result); - fprintf(stderr, "%llu\n", value); - if (value == InvalidOid) { - log("0", LOG_DEVELOP); - return 0; + if (PQnfields(result) == 1) { + if (strcmp(PQfname(result, 0), "last_inserted_id") == 0) { + const char *count = PQgetvalue(result, 0, 0); + unsigned long long number; + + sscanf(count, "%llu", &number); + return number; + } } - return value; + return 0; } unsigned int ts3dbplugin_open(unsigned int connection_nr, const char* query, |