|
|
@ -2251,11 +2251,10 @@ static int64_t nextid(PGconn *conn, char *idname, int64_t increment, |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
char qry[1024]; |
|
|
|
char qry[1024]; |
|
|
|
char *params[5]; |
|
|
|
char *params[5]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
int64_t lastid; |
|
|
|
int64_t lastid; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
bool ok; |
|
|
|
bool ok; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lastid = 0; |
|
|
|
lastid = 0; |
|
|
|
|
|
|
|
|
|
|
@ -2777,13 +2776,12 @@ static bool users_pass_email(PGconn *conn, K_ITEM *u_item, char *oldhash, |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n; |
|
|
|
|
|
|
|
USERS *row, *users; |
|
|
|
USERS *row, *users; |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[5 + HISTORYDATECOUNT]; |
|
|
|
char *params[5 + HISTORYDATECOUNT]; |
|
|
|
bool hash; |
|
|
|
bool hash; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): change", __func__); |
|
|
|
LOGDEBUG("%s(): change", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -2830,17 +2828,18 @@ static bool users_pass_email(PGconn *conn, K_ITEM *u_item, char *oldhash, |
|
|
|
// Beginning of a write txn
|
|
|
|
// Beginning of a write txn
|
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto unparam; |
|
|
|
} |
|
|
|
} |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -2871,14 +2870,18 @@ static bool users_pass_email(PGconn *conn, K_ITEM *u_item, char *oldhash, |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
ok = true; |
|
|
|
ok = true; |
|
|
|
unparam: |
|
|
|
rollback: |
|
|
|
|
|
|
|
if (ok) |
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
unparam: |
|
|
|
if (conned) |
|
|
|
if (conned) |
|
|
|
PQfinish(conn); |
|
|
|
PQfinish(conn); |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -2911,7 +2914,6 @@ static K_ITEM *users_add(PGconn *conn, char *username, char *emailaddress, |
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n; |
|
|
|
|
|
|
|
USERS *row; |
|
|
|
USERS *row; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char tohash[64]; |
|
|
|
char tohash[64]; |
|
|
@ -2919,7 +2921,7 @@ static K_ITEM *users_add(PGconn *conn, char *username, char *emailaddress, |
|
|
|
__maybe_unused uint64_t tmp; |
|
|
|
__maybe_unused uint64_t tmp; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -3175,7 +3177,7 @@ static bool useratts_item_add(PGconn *conn, K_ITEM *ua_item, tv_t *cd, bool begu |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[9 + HISTORYDATECOUNT]; |
|
|
|
char *params[9 + HISTORYDATECOUNT]; |
|
|
|
int n, par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -3189,7 +3191,6 @@ static bool useratts_item_add(PGconn *conn, K_ITEM *ua_item, tv_t *cd, bool begu |
|
|
|
/* N.B. the values of the old ua_item record, if it exists,
|
|
|
|
/* N.B. the values of the old ua_item record, if it exists,
|
|
|
|
* are completely ignored i.e. you must provide all values required */ |
|
|
|
* are completely ignored i.e. you must provide all values required */ |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
|
|
|
|
if (!conn) { |
|
|
|
if (!conn) { |
|
|
|
conn = dbconnect(); |
|
|
|
conn = dbconnect(); |
|
|
|
conned = true; |
|
|
|
conned = true; |
|
|
@ -3596,11 +3597,10 @@ static K_ITEM *workers_add(PGconn *conn, int64_t userid, char *workername, |
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item, *ret = NULL; |
|
|
|
K_ITEM *item, *ret = NULL; |
|
|
|
int n; |
|
|
|
|
|
|
|
WORKERS *row; |
|
|
|
WORKERS *row; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char *params[6 + HISTORYDATECOUNT]; |
|
|
|
char *params[6 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
int32_t diffdef; |
|
|
|
int32_t diffdef; |
|
|
|
int32_t nottime; |
|
|
|
int32_t nottime; |
|
|
|
|
|
|
|
|
|
|
@ -3708,12 +3708,11 @@ static bool workers_update(PGconn *conn, K_ITEM *item, char *difficultydefault, |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
int n; |
|
|
|
|
|
|
|
WORKERS *row; |
|
|
|
WORKERS *row; |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[6 + HISTORYDATECOUNT]; |
|
|
|
char *params[6 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
int32_t diffdef; |
|
|
|
int32_t diffdef; |
|
|
|
char idlenot; |
|
|
|
char idlenot; |
|
|
|
int32_t nottime; |
|
|
|
int32_t nottime; |
|
|
@ -3756,7 +3755,8 @@ static bool workers_update(PGconn *conn, K_ITEM *item, char *difficultydefault, |
|
|
|
nottime == row->idlenotificationtime) { |
|
|
|
nottime == row->idlenotificationtime) { |
|
|
|
ok = true; |
|
|
|
ok = true; |
|
|
|
goto early; |
|
|
|
goto early; |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
upd = "update workers set expirydate=$1 where workerid=$2 and expirydate=$3"; |
|
|
|
upd = "update workers set expirydate=$1 where workerid=$2 and expirydate=$3"; |
|
|
|
par = 0; |
|
|
|
par = 0; |
|
|
|
params[par++] = tv_to_buf(cd, NULL, 0); |
|
|
|
params[par++] = tv_to_buf(cd, NULL, 0); |
|
|
@ -3771,19 +3771,18 @@ static bool workers_update(PGconn *conn, K_ITEM *item, char *difficultydefault, |
|
|
|
|
|
|
|
|
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto unparam; |
|
|
|
} |
|
|
|
} |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -3814,16 +3813,18 @@ static bool workers_update(PGconn *conn, K_ITEM *item, char *difficultydefault, |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
rollback: |
|
|
|
|
|
|
|
if (ok) |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
unparam: |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
unparam: |
|
|
|
if (conned) |
|
|
|
if (conned) |
|
|
|
PQfinish(conn); |
|
|
|
PQfinish(conn); |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -4066,8 +4067,7 @@ static K_ITEM *paymentaddresses_set(PGconn *conn, int64_t userid, char *payaddre |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[4 + HISTORYDATECOUNT]; |
|
|
|
char *params[4 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -4114,8 +4114,7 @@ static K_ITEM *paymentaddresses_set(PGconn *conn, int64_t userid, char *payaddre |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -4135,16 +4134,21 @@ static K_ITEM *paymentaddresses_set(PGconn *conn, int64_t userid, char *payaddre |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
rollback: |
|
|
|
|
|
|
|
if (ok) |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
unparam: |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
unparam: |
|
|
|
if (conned) |
|
|
|
if (conned) |
|
|
|
PQfinish(conn); |
|
|
|
PQfinish(conn); |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -4189,10 +4193,9 @@ static bool paymentaddresses_fill(PGconn *conn) |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
PAYMENTADDRESSES *row; |
|
|
|
PAYMENTADDRESSES *row; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
int par; |
|
|
|
int n, i, par = 0; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 4; |
|
|
|
int fields = 4; |
|
|
@ -4300,10 +4303,9 @@ static bool payments_fill(PGconn *conn) |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
PAYMENTS *row; |
|
|
|
PAYMENTS *row; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
int par; |
|
|
|
int n, i, par = 0; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 8; |
|
|
|
int fields = 8; |
|
|
@ -4507,12 +4509,11 @@ static K_ITEM *optioncontrol_item_add(PGconn *conn, K_ITEM *oc_item, tv_t *cd, b |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *old_item, look; |
|
|
|
K_ITEM *old_item, look; |
|
|
|
int n; |
|
|
|
|
|
|
|
OPTIONCONTROL *row; |
|
|
|
OPTIONCONTROL *row; |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[4 + HISTORYDATECOUNT]; |
|
|
|
char *params[4 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -4524,7 +4525,6 @@ static K_ITEM *optioncontrol_item_add(PGconn *conn, K_ITEM *oc_item, tv_t *cd, b |
|
|
|
old_item = find_in_ktree(optioncontrol_root, &look, cmp_optioncontrol, ctx); |
|
|
|
old_item = find_in_ktree(optioncontrol_root, &look, cmp_optioncontrol, ctx); |
|
|
|
K_RUNLOCK(optioncontrol_free); |
|
|
|
K_RUNLOCK(optioncontrol_free); |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
|
|
|
|
if (!conn) { |
|
|
|
if (!conn) { |
|
|
|
conn = dbconnect(); |
|
|
|
conn = dbconnect(); |
|
|
|
conned = true; |
|
|
|
conned = true; |
|
|
@ -4678,10 +4678,9 @@ static bool optioncontrol_fill(PGconn *conn) |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
OPTIONCONTROL *row; |
|
|
|
OPTIONCONTROL *row; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
int par; |
|
|
|
int n, i, par = 0; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 4; |
|
|
|
int fields = 4; |
|
|
@ -4855,12 +4854,11 @@ static int64_t workinfo_add(PGconn *conn, char *workinfoidstr, char *poolinstanc |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
char ndiffbin[TXT_SML+1]; |
|
|
|
char ndiffbin[TXT_SML+1]; |
|
|
|
int n; |
|
|
|
|
|
|
|
int64_t workinfoid = -1; |
|
|
|
int64_t workinfoid = -1; |
|
|
|
WORKINFO *row; |
|
|
|
WORKINFO *row; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char *params[11 + HISTORYDATECOUNT]; |
|
|
|
char *params[11 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -4907,8 +4905,8 @@ static int64_t workinfo_add(PGconn *conn, char *workinfoidstr, char *poolinstanc |
|
|
|
} |
|
|
|
} |
|
|
|
K_WUNLOCK(workinfo_free); |
|
|
|
K_WUNLOCK(workinfo_free); |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
|
|
|
|
if (!confirm_sharesummary) { |
|
|
|
if (!confirm_sharesummary) { |
|
|
|
|
|
|
|
par = 0; |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->poolinstance, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->poolinstance, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->transactiontree, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->transactiontree, NULL, 0); |
|
|
@ -5307,10 +5305,9 @@ static bool workinfo_fill(PGconn *conn) |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
WORKINFO *row; |
|
|
|
WORKINFO *row; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
int par; |
|
|
|
int n, i, par = 0; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 10; |
|
|
|
int fields = 10; |
|
|
@ -5970,9 +5967,8 @@ static bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row |
|
|
|
if (new || !(row->inserted)) { |
|
|
|
if (new || !(row->inserted)) { |
|
|
|
MODIFYDATEINIT(row, cd, by, code, inet); |
|
|
|
MODIFYDATEINIT(row, cd, by, code, inet); |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!confirm_sharesummary) { |
|
|
|
if (!confirm_sharesummary) { |
|
|
|
|
|
|
|
par = 0; |
|
|
|
params[par++] = bigint_to_buf(row->userid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->userid, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->workername, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->workername, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
@ -6027,8 +6023,8 @@ static bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row |
|
|
|
stats_update = true; |
|
|
|
stats_update = true; |
|
|
|
|
|
|
|
|
|
|
|
if (stats_update) { |
|
|
|
if (stats_update) { |
|
|
|
par = 0; |
|
|
|
|
|
|
|
if (!confirm_sharesummary) { |
|
|
|
if (!confirm_sharesummary) { |
|
|
|
|
|
|
|
par = 0; |
|
|
|
params[par++] = bigint_to_buf(row->userid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->userid, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->workername, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->workername, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
@ -6074,8 +6070,8 @@ static bool _sharesummary_update(PGconn *conn, SHARES *s_row, SHAREERRORS *e_row |
|
|
|
ok = true; |
|
|
|
ok = true; |
|
|
|
goto late; |
|
|
|
goto late; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
par = 0; |
|
|
|
|
|
|
|
if (!confirm_sharesummary) { |
|
|
|
if (!confirm_sharesummary) { |
|
|
|
|
|
|
|
par = 0; |
|
|
|
params[par++] = bigint_to_buf(row->userid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->userid, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->workername, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->workername, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->workinfoid, NULL, 0); |
|
|
@ -6465,8 +6461,7 @@ static bool blocks_stats(PGconn *conn, int32_t height, char *blockhash, |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
bool ok = false, update_old = false; |
|
|
|
bool ok = false, update_old = false; |
|
|
|
int par = 0; |
|
|
|
int n, par = 0; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): confirm", __func__); |
|
|
|
LOGDEBUG("%s(): confirm", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -6513,19 +6508,18 @@ static bool blocks_stats(PGconn *conn, int32_t height, char *blockhash, |
|
|
|
|
|
|
|
|
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto unparam; |
|
|
|
} |
|
|
|
} |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
update_old = true; |
|
|
|
update_old = true; |
|
|
@ -6562,15 +6556,18 @@ static bool blocks_stats(PGconn *conn, int32_t height, char *blockhash, |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
rollback: |
|
|
|
|
|
|
|
if (ok) |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
unparam: |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
unparam: |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
free(params[n]); |
|
|
|
free(params[n]); |
|
|
|
|
|
|
|
|
|
|
@ -6613,9 +6610,8 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash, |
|
|
|
char *upd, *ins; |
|
|
|
char *upd, *ins; |
|
|
|
char *params[17 + HISTORYDATECOUNT]; |
|
|
|
char *params[17 + HISTORYDATECOUNT]; |
|
|
|
bool ok = false, update_old = false; |
|
|
|
bool ok = false, update_old = false; |
|
|
|
int par = 0; |
|
|
|
int n, par = 0; |
|
|
|
char want = '?'; |
|
|
|
char want = '?'; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -6718,10 +6714,14 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash, |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto unparam; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// We didn't use a Begin
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
|
|
|
|
goto unparam; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case BLOCKS_ORPHAN: |
|
|
|
case BLOCKS_ORPHAN: |
|
|
|
case BLOCKS_42: |
|
|
|
case BLOCKS_42: |
|
|
@ -6787,19 +6787,18 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash, |
|
|
|
|
|
|
|
|
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
res = PQexec(conn, "Begin", CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
PGLOGERR("Begin", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto unparam; |
|
|
|
} |
|
|
|
} |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
res = PQexecParams(conn, upd, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_WRITE); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
rescode = PQresultStatus(res); |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
PGLOGERR("Update", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
@ -6852,13 +6851,10 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash, |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
if (!PGOK(rescode)) { |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
goto rollback; |
|
|
|
goto unparam; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
update_old = true; |
|
|
|
update_old = true; |
|
|
|
|
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
LOGERR("%s(): %s.failed.invalid confirm='%s'", |
|
|
|
LOGERR("%s(): %s.failed.invalid confirm='%s'", |
|
|
@ -6867,8 +6863,14 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
ok = true; |
|
|
|
unparam: |
|
|
|
rollback: |
|
|
|
|
|
|
|
if (ok) |
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
unparam: |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
for (n = 0; n < par; n++) |
|
|
|
free(params[n]); |
|
|
|
free(params[n]); |
|
|
|
flail: |
|
|
|
flail: |
|
|
@ -7148,12 +7150,11 @@ __maybe_unused static bool miningpayouts_add(PGconn *conn, char *username, char |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *m_item, *u_item; |
|
|
|
K_ITEM *m_item, *u_item; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
int n; |
|
|
|
|
|
|
|
MININGPAYOUTS *row; |
|
|
|
MININGPAYOUTS *row; |
|
|
|
USERS *users; |
|
|
|
USERS *users; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char *params[5 + HISTORYDATECOUNT]; |
|
|
|
char *params[5 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -7233,10 +7234,9 @@ static bool miningpayouts_fill(PGconn *conn) |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
MININGPAYOUTS *row; |
|
|
|
MININGPAYOUTS *row; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
int par; |
|
|
|
int n, i, par = 0; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 5; |
|
|
|
int fields = 5; |
|
|
@ -7372,13 +7372,12 @@ static char *auths_add(PGconn *conn, char *poolinstance, char *username, |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_ITEM *a_item, *u_item; |
|
|
|
K_ITEM *a_item, *u_item; |
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
int n; |
|
|
|
|
|
|
|
USERS *users; |
|
|
|
USERS *users; |
|
|
|
AUTHS *row; |
|
|
|
AUTHS *row; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char *secuserid = NULL; |
|
|
|
char *secuserid = NULL; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -7499,10 +7498,9 @@ static bool auths_fill(PGconn *conn) |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
AUTHS *row; |
|
|
|
AUTHS *row; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
int par; |
|
|
|
int n, i, par = 0; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 7; |
|
|
|
int fields = 7; |
|
|
@ -7647,11 +7645,10 @@ static bool poolstats_add(PGconn *conn, bool store, char *poolinstance, |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
K_ITEM *p_item; |
|
|
|
K_ITEM *p_item; |
|
|
|
int n; |
|
|
|
|
|
|
|
POOLSTATS *row; |
|
|
|
POOLSTATS *row; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char *params[8 + SIMPLEDATECOUNT]; |
|
|
|
char *params[8 + SIMPLEDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
|
LOGDEBUG("%s(): add", __func__); |
|
|
@ -7683,8 +7680,8 @@ static bool poolstats_add(PGconn *conn, bool store, char *poolinstance, |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
|
|
|
|
if (store) { |
|
|
|
if (store) { |
|
|
|
|
|
|
|
par = 0; |
|
|
|
params[par++] = str_to_buf(row->poolinstance, NULL, 0); |
|
|
|
params[par++] = str_to_buf(row->poolinstance, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->elapsed, NULL, 0); |
|
|
|
params[par++] = bigint_to_buf(row->elapsed, NULL, 0); |
|
|
|
params[par++] = int_to_buf(row->users, NULL, 0); |
|
|
|
params[par++] = int_to_buf(row->users, NULL, 0); |
|
|
@ -7968,8 +7965,7 @@ static bool userstats_add_db(PGconn *conn, USERSTATS *row) |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
char *params[10 + SIMPLEDATECOUNT]; |
|
|
|
char *params[10 + SIMPLEDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): store", __func__); |
|
|
|
LOGDEBUG("%s(): store", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -9458,13 +9454,12 @@ static char *cmd_newid(PGconn *conn, char *cmd, char *id, tv_t *now, char *by, |
|
|
|
K_ITEM *i_idname, *i_idvalue, *look; |
|
|
|
K_ITEM *i_idname, *i_idvalue, *look; |
|
|
|
IDCONTROL *row; |
|
|
|
IDCONTROL *row; |
|
|
|
char *params[2 + MODIFYDATECOUNT]; |
|
|
|
char *params[2 + MODIFYDATECOUNT]; |
|
|
|
int par; |
|
|
|
int n, par = 0; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); |
|
|
|
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); |
|
|
|
|
|
|
|
|
|
|
@ -10947,10 +10942,8 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id, |
|
|
|
ua_item = NULL; |
|
|
|
ua_item = NULL; |
|
|
|
db++; |
|
|
|
db++; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
|
goto bats; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!ua_item) { |
|
|
|
if (!ua_item) { |
|
|
@ -11008,16 +11001,19 @@ static char *cmd_setatts(PGconn *conn, char *cmd, char *id, |
|
|
|
begun = true; |
|
|
|
begun = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!useratts_item_add(conn, ua_item, now, begun)) { |
|
|
|
if (!useratts_item_add(conn, ua_item, now, begun)) { |
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
reason = "DBERR"; |
|
|
|
reason = "DBERR"; |
|
|
|
goto bats; |
|
|
|
goto rollback; |
|
|
|
} |
|
|
|
} |
|
|
|
db++; |
|
|
|
db++; |
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rollback: |
|
|
|
|
|
|
|
if (!reason) |
|
|
|
|
|
|
|
res = PQexec(conn, "Commit", CKPQ_WRITE); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
res = PQexec(conn, "Rollback", CKPQ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
bats: |
|
|
|
bats: |
|
|
|
if (conned) |
|
|
|
if (conned) |
|
|
|
PQfinish(conn); |
|
|
|
PQfinish(conn); |
|
|
|