|
|
@ -4333,20 +4333,23 @@ bool auths_fill(PGconn *conn) |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item; |
|
|
|
AUTHS *row; |
|
|
|
AUTHS *row; |
|
|
|
char *params[1]; |
|
|
|
// char *params[1];
|
|
|
|
int n, i, par = 0; |
|
|
|
int n, i; |
|
|
|
|
|
|
|
// int par = 0;
|
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 7; |
|
|
|
int fields = 7 + 1; // +1 = 'best'
|
|
|
|
bool ok; |
|
|
|
bool ok; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): select", __func__); |
|
|
|
LOGDEBUG("%s(): select", __func__); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: add/update a (single) fake auth every ~10min or 10min after the last one?
|
|
|
|
// TODO: add/update a (single) fake auth every ~10min or 10min after the last one?
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
sel = "select " |
|
|
|
sel = "select " |
|
|
|
"authid,userid,workername,clientid,enonce1,useragent,preauth" |
|
|
|
"authid,userid,workername,clientid,enonce1,useragent,preauth" |
|
|
|
HISTORYDATECONTROL |
|
|
|
HISTORYDATECONTROL |
|
|
|
" from auths where expirydate=$1"; |
|
|
|
" from auths where expirydate=$1"; |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
par = 0; |
|
|
|
params[par++] = tv_to_buf((tv_t *)(&default_expiry), NULL, 0); |
|
|
|
params[par++] = tv_to_buf((tv_t *)(&default_expiry), NULL, 0); |
|
|
|
PARCHK(par, params); |
|
|
|
PARCHK(par, params); |
|
|
@ -4357,6 +4360,24 @@ bool auths_fill(PGconn *conn) |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Only load the last record for each workername
|
|
|
|
|
|
|
|
sel = "with last as (" |
|
|
|
|
|
|
|
"select authid,userid,workername,clientid,enonce1,useragent,preauth" |
|
|
|
|
|
|
|
HISTORYDATECONTROL |
|
|
|
|
|
|
|
",row_number() over(partition by userid,workername " |
|
|
|
|
|
|
|
"order by expirydate desc, createdate desc)" |
|
|
|
|
|
|
|
" as best from auths" |
|
|
|
|
|
|
|
") select * from last where best=1"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = PQexec(conn, sel, CKPQ_READ); |
|
|
|
|
|
|
|
rescode = PQresultStatus(res); |
|
|
|
|
|
|
|
if (!PGOK(rescode)) { |
|
|
|
|
|
|
|
PGLOGERR("Select", rescode, conn); |
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
n = PQnfields(res); |
|
|
|
n = PQnfields(res); |
|
|
|
if (n != (fields + HISTORYDATECOUNT)) { |
|
|
|
if (n != (fields + HISTORYDATECOUNT)) { |
|
|
|