Browse Source

ckdb - log duplicate DB store of shares as NOTICE

master
kanoi 8 years ago
parent
commit
8496314df3
  1. 3
      src/ckdb.h
  2. 4
      src/ckdb_dbio.c

3
src/ckdb.h

@ -58,7 +58,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.7" #define DB_VERSION "1.0.7"
#define CKDB_VERSION DB_VERSION"-2.517" #define CKDB_VERSION DB_VERSION"-2.518"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -3641,6 +3641,7 @@ extern PGresult *_CKPQexecParams(PGconn *conn, const char *qry,
#define PGLOGERR(_str, _rescode, _conn) PGLOG(LOGERR, _str, _rescode, _conn) #define PGLOGERR(_str, _rescode, _conn) PGLOG(LOGERR, _str, _rescode, _conn)
#define PGLOGEMERG(_str, _rescode, _conn) PGLOG(LOGEMERG, _str, _rescode, _conn) #define PGLOGEMERG(_str, _rescode, _conn) PGLOG(LOGEMERG, _str, _rescode, _conn)
#define PGLOGNOTICE(_str, _rescode, _conn) PGLOG(LOGNOTICE, _str, _rescode, _conn)
extern char *pqerrmsg(PGconn *conn); extern char *pqerrmsg(PGconn *conn);
extern bool CKPQConn(PGconn **conn); extern bool CKPQConn(PGconn **conn);

4
src/ckdb_dbio.c

@ -4115,11 +4115,13 @@ bool shares_db(PGconn *conn, K_ITEM *s_item)
res = PQexecParams(conn, ins, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); res = PQexecParams(conn, ins, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
if (!PGOK(rescode)) { if (!PGOK(rescode)) {
// If the share is already in the db ignore the error
char *code = PQresultErrorField(res, PG_DIAG_SQLSTATE); char *code = PQresultErrorField(res, PG_DIAG_SQLSTATE);
if (!code || strcmp(code, SQL_UNIQUE_VIOLATION)) { if (!code || strcmp(code, SQL_UNIQUE_VIOLATION)) {
PGLOGERR("Insert", rescode, conn); PGLOGERR("Insert", rescode, conn);
goto unparam; goto unparam;
} else {
// If the share is already in the db use NOTICE
PGLOGNOTICE("Insert", rescode, conn);
} }
} }

Loading…
Cancel
Save